mirror of https://github.com/GNOME/gimp.git
added signals "plug-in-opened" and "plug-in-closed". Added functions
2006-05-05 Michael Natterer <mitch@gimp.org> * app/plug-in/gimppluginmanager.[ch]: added signals "plug-in-opened" and "plug-in-closed". Added functions gimp_plug_in_manager_add_open_plug_in() and _remove_open_plugin() which maintain the list of open plug-ins and emit the signals. * app/plug-in/gimpplugin.c (gimp_plug_in_open) (gimp_plug_in_close): don't touch manager->open_plug_ins and don't ref/unref the plug-in. Call above new functions instead. Don't call gimp_pdb_dialogs_check(). * app/core/gimp-gui.[ch] * app/gui/gui-vtable.c: removed gimp_pdb_dialogs_check(). * app/widgets/gimppdbdialog.[ch]: removed gimp_pdb_dialogs_check_callback() and connect to the plug-in-manager's "plug-in-closed" signal instead.
This commit is contained in:
parent
d033ddda1b
commit
808b65cd31
19
ChangeLog
19
ChangeLog
|
@ -1,3 +1,22 @@
|
|||
2006-05-05 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/plug-in/gimppluginmanager.[ch]: added signals
|
||||
"plug-in-opened" and "plug-in-closed". Added functions
|
||||
gimp_plug_in_manager_add_open_plug_in() and _remove_open_plugin()
|
||||
which maintain the list of open plug-ins and emit the signals.
|
||||
|
||||
* app/plug-in/gimpplugin.c (gimp_plug_in_open)
|
||||
(gimp_plug_in_close): don't touch manager->open_plug_ins and don't
|
||||
ref/unref the plug-in. Call above new functions instead. Don't
|
||||
call gimp_pdb_dialogs_check().
|
||||
|
||||
* app/core/gimp-gui.[ch]
|
||||
* app/gui/gui-vtable.c: removed gimp_pdb_dialogs_check().
|
||||
|
||||
* app/widgets/gimppdbdialog.[ch]: removed
|
||||
gimp_pdb_dialogs_check_callback() and connect to the
|
||||
plug-in-manager's "plug-in-closed" signal instead.
|
||||
|
||||
2006-05-04 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/plug-in/gimppluginshm.c: cleaned up a bit.
|
||||
|
|
|
@ -60,7 +60,6 @@ gimp_gui_init (Gimp *gimp)
|
|||
gimp->gui.progress_free = NULL;
|
||||
gimp->gui.pdb_dialog_set = NULL;
|
||||
gimp->gui.pdb_dialog_close = NULL;
|
||||
gimp->gui.pdb_dialogs_check = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -392,12 +391,3 @@ gimp_pdb_dialog_close (Gimp *gimp,
|
|||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_pdb_dialogs_check (Gimp *gimp)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
|
||||
if (gimp->gui.pdb_dialogs_check)
|
||||
gimp->gui.pdb_dialogs_check (gimp);
|
||||
}
|
||||
|
|
|
@ -75,7 +75,6 @@ struct _GimpGui
|
|||
gboolean (* pdb_dialog_close) (Gimp *gimp,
|
||||
GimpContainer *container,
|
||||
const gchar *callback_name);
|
||||
void (* pdb_dialogs_check) (Gimp *gimp);
|
||||
};
|
||||
|
||||
|
||||
|
@ -137,7 +136,6 @@ gboolean gimp_pdb_dialog_set (Gimp *gimp,
|
|||
gboolean gimp_pdb_dialog_close (Gimp *gimp,
|
||||
GimpContainer *container,
|
||||
const gchar *callback_name);
|
||||
void gimp_pdb_dialogs_check (Gimp *gimp);
|
||||
|
||||
|
||||
#endif /* __GIMP_GUI_H__ */
|
||||
|
|
|
@ -119,7 +119,6 @@ static gboolean gui_pdb_dialog_set (Gimp *gimp,
|
|||
static gboolean gui_pdb_dialog_close (Gimp *gimp,
|
||||
GimpContainer *container,
|
||||
const gchar *callback_name);
|
||||
static void gui_pdb_dialogs_check (Gimp *gimp);
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
@ -149,7 +148,6 @@ gui_vtable_init (Gimp *gimp)
|
|||
gimp->gui.pdb_dialog_new = gui_pdb_dialog_new;
|
||||
gimp->gui.pdb_dialog_set = gui_pdb_dialog_set;
|
||||
gimp->gui.pdb_dialog_close = gui_pdb_dialog_close;
|
||||
gimp->gui.pdb_dialogs_check = gui_pdb_dialogs_check;
|
||||
}
|
||||
|
||||
|
||||
|
@ -557,24 +555,3 @@ gui_pdb_dialog_close (Gimp *gimp,
|
|||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gui_pdb_dialogs_check (Gimp *gimp)
|
||||
{
|
||||
GimpPdbDialogClass *klass;
|
||||
|
||||
if ((klass = g_type_class_peek (GIMP_TYPE_BRUSH_SELECT)))
|
||||
gimp_pdb_dialogs_check_callback (klass);
|
||||
|
||||
if ((klass = g_type_class_peek (GIMP_TYPE_FONT_SELECT)))
|
||||
gimp_pdb_dialogs_check_callback (klass);
|
||||
|
||||
if ((klass = g_type_class_peek (GIMP_TYPE_GRADIENT_SELECT)))
|
||||
gimp_pdb_dialogs_check_callback (klass);
|
||||
|
||||
if ((klass = g_type_class_peek (GIMP_TYPE_PALETTE_SELECT)))
|
||||
gimp_pdb_dialogs_check_callback (klass);
|
||||
|
||||
if ((klass = g_type_class_peek (GIMP_TYPE_PATTERN_SELECT)))
|
||||
gimp_pdb_dialogs_check_callback (klass);
|
||||
}
|
||||
|
|
|
@ -373,16 +373,13 @@ gimp_plug_in_open (GimpPlugIn *plug_in,
|
|||
|
||||
plug_in->input_id = g_source_attach (source, NULL);
|
||||
g_source_unref (source);
|
||||
|
||||
plug_in->manager->open_plug_ins =
|
||||
g_slist_prepend (plug_in->manager->open_plug_ins, plug_in);
|
||||
}
|
||||
|
||||
g_object_ref (plug_in);
|
||||
|
||||
plug_in->open = TRUE;
|
||||
plug_in->call_mode = call_mode;
|
||||
|
||||
gimp_plug_in_manager_add_open_plug_in (plug_in->manager, plug_in);
|
||||
|
||||
cleanup:
|
||||
|
||||
if (debug)
|
||||
|
@ -551,13 +548,7 @@ gimp_plug_in_close (GimpPlugIn *plug_in,
|
|||
while (plug_in->temp_procedures)
|
||||
gimp_plug_in_remove_temp_proc (plug_in, plug_in->temp_procedures->data);
|
||||
|
||||
/* Close any dialogs that this plugin might have opened */
|
||||
gimp_pdb_dialogs_check (plug_in->manager->gimp);
|
||||
|
||||
plug_in->manager->open_plug_ins =
|
||||
g_slist_remove (plug_in->manager->open_plug_ins, plug_in);
|
||||
|
||||
g_object_unref (plug_in);
|
||||
gimp_plug_in_manager_remove_open_plug_in (plug_in->manager, plug_in);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
@ -59,6 +59,8 @@
|
|||
|
||||
enum
|
||||
{
|
||||
PLUG_IN_OPENED,
|
||||
PLUG_IN_CLOSED,
|
||||
MENU_BRANCH_ADDED,
|
||||
LAST_PLUG_INS_CHANGED,
|
||||
LAST_SIGNAL
|
||||
|
@ -95,6 +97,28 @@ gimp_plug_in_manager_class_init (GimpPlugInManagerClass *klass)
|
|||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
|
||||
|
||||
manager_signals[PLUG_IN_OPENED] =
|
||||
g_signal_new ("plug-in-opened",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GimpPlugInManagerClass,
|
||||
plug_in_opened),
|
||||
NULL, NULL,
|
||||
gimp_marshal_VOID__OBJECT,
|
||||
G_TYPE_NONE, 1,
|
||||
GIMP_TYPE_PLUG_IN);
|
||||
|
||||
manager_signals[PLUG_IN_CLOSED] =
|
||||
g_signal_new ("plug-in-closed",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GimpPlugInManagerClass,
|
||||
plug_in_closed),
|
||||
NULL, NULL,
|
||||
gimp_marshal_VOID__OBJECT,
|
||||
G_TYPE_NONE, 1,
|
||||
GIMP_TYPE_PLUG_IN);
|
||||
|
||||
manager_signals[MENU_BRANCH_ADDED] =
|
||||
g_signal_new ("menu-branch-added",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
|
@ -689,6 +713,35 @@ gimp_plug_in_manager_set_last_plug_in (GimpPlugInManager *manager,
|
|||
g_signal_emit (manager, manager_signals[LAST_PLUG_INS_CHANGED], 0);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_plug_in_manager_add_open_plug_in (GimpPlugInManager *manager,
|
||||
GimpPlugIn *plug_in)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager));
|
||||
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
|
||||
|
||||
manager->open_plug_ins = g_slist_prepend (manager->open_plug_ins,
|
||||
g_object_ref (plug_in));
|
||||
|
||||
g_signal_emit (manager, manager_signals[PLUG_IN_OPENED], 0,
|
||||
plug_in);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_plug_in_manager_remove_open_plug_in (GimpPlugInManager *manager,
|
||||
GimpPlugIn *plug_in)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager));
|
||||
g_return_if_fail (GIMP_IS_PLUG_IN (plug_in));
|
||||
|
||||
manager->open_plug_ins = g_slist_remove (manager->open_plug_ins, plug_in);
|
||||
|
||||
g_signal_emit (manager, manager_signals[PLUG_IN_CLOSED], 0,
|
||||
plug_in);
|
||||
|
||||
g_object_unref (plug_in);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_plug_in_manager_plug_in_push (GimpPlugInManager *manager,
|
||||
GimpPlugIn *plug_in)
|
||||
|
|
|
@ -68,6 +68,11 @@ struct _GimpPlugInManagerClass
|
|||
{
|
||||
GimpObjectClass parent_class;
|
||||
|
||||
void (* plug_in_opened) (GimpPlugInManager *manager,
|
||||
GimpPlugIn *plug_in);
|
||||
void (* plug_in_closed) (GimpPlugInManager *manager,
|
||||
GimpPlugIn *plug_in);
|
||||
|
||||
void (* menu_branch_added) (GimpPlugInManager *manager,
|
||||
const gchar *prog_name,
|
||||
const gchar *menu_path,
|
||||
|
@ -91,20 +96,25 @@ void gimp_plug_in_manager_exit (GimpPlugInManager *manager);
|
|||
* handlers, which are organized around the plug-in data structure.
|
||||
* This could all be done a little better, but oh well. -josh
|
||||
*/
|
||||
void gimp_plug_in_manager_add_procedure (GimpPlugInManager *manager,
|
||||
GimpPlugInProcedure *procedure);
|
||||
void gimp_plug_in_manager_add_procedure (GimpPlugInManager *manager,
|
||||
GimpPlugInProcedure *procedure);
|
||||
|
||||
void gimp_plug_in_manager_add_temp_proc (GimpPlugInManager *manager,
|
||||
GimpTemporaryProcedure *procedure);
|
||||
void gimp_plug_in_manager_remove_temp_proc (GimpPlugInManager *manager,
|
||||
GimpTemporaryProcedure *procedure);
|
||||
void gimp_plug_in_manager_add_temp_proc (GimpPlugInManager *manager,
|
||||
GimpTemporaryProcedure *procedure);
|
||||
void gimp_plug_in_manager_remove_temp_proc (GimpPlugInManager *manager,
|
||||
GimpTemporaryProcedure *procedure);
|
||||
|
||||
void gimp_plug_in_manager_set_last_plug_in (GimpPlugInManager *manager,
|
||||
GimpPlugInProcedure *procedure);
|
||||
void gimp_plug_in_manager_add_open_plug_in (GimpPlugInManager *manager,
|
||||
GimpPlugIn *plug_in);
|
||||
void gimp_plug_in_manager_remove_open_plug_in (GimpPlugInManager *manager,
|
||||
GimpPlugIn *plug_in);
|
||||
|
||||
void gimp_plug_in_manager_plug_in_push (GimpPlugInManager *manager,
|
||||
GimpPlugIn *plug_in);
|
||||
void gimp_plug_in_manager_plug_in_pop (GimpPlugInManager *manager);
|
||||
void gimp_plug_in_manager_set_last_plug_in (GimpPlugInManager *manager,
|
||||
GimpPlugInProcedure *procedure);
|
||||
|
||||
void gimp_plug_in_manager_plug_in_push (GimpPlugInManager *manager,
|
||||
GimpPlugIn *plug_in);
|
||||
void gimp_plug_in_manager_plug_in_pop (GimpPlugInManager *manager);
|
||||
|
||||
|
||||
#endif /* __GIMP_PLUG_IN_MANAGER_H__ */
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpcontext.h"
|
||||
|
||||
#include "pdb/gimppdb.h"
|
||||
|
@ -72,6 +73,9 @@ static void gimp_pdb_dialog_response (GtkDialog *dialog,
|
|||
static void gimp_pdb_dialog_context_changed (GimpContext *context,
|
||||
GimpObject *object,
|
||||
GimpPdbDialog *dialog);
|
||||
static void gimp_pdb_dialog_plug_in_closed (GimpPlugInManager *manager,
|
||||
GimpPlugIn *plug_in,
|
||||
GimpPdbDialog *dialog);
|
||||
|
||||
|
||||
static GimpDialogClass *parent_class = NULL;
|
||||
|
@ -207,6 +211,10 @@ gimp_pdb_dialog_constructor (GType type,
|
|||
g_signal_connect_object (dialog->context, signal_name,
|
||||
G_CALLBACK (gimp_pdb_dialog_context_changed),
|
||||
dialog, 0);
|
||||
g_signal_connect_object (dialog->context->gimp->plug_in_manager,
|
||||
"plug-in-closed",
|
||||
G_CALLBACK (gimp_pdb_dialog_plug_in_closed),
|
||||
dialog, 0);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
@ -363,31 +371,6 @@ gimp_pdb_dialog_get_by_callback (GimpPdbDialogClass *klass,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_pdb_dialogs_check_callback (GimpPdbDialogClass *klass)
|
||||
{
|
||||
GList *list;
|
||||
|
||||
g_return_if_fail (GIMP_IS_PDB_DIALOG_CLASS (klass));
|
||||
|
||||
list = klass->dialogs;
|
||||
|
||||
while (list)
|
||||
{
|
||||
GimpPdbDialog *dialog = list->data;
|
||||
|
||||
list = g_list_next (list);
|
||||
|
||||
if (dialog->caller_context && dialog->callback_name)
|
||||
{
|
||||
if (! gimp_pdb_lookup_procedure (dialog->pdb, dialog->callback_name))
|
||||
{
|
||||
gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
|
@ -399,3 +382,17 @@ gimp_pdb_dialog_context_changed (GimpContext *context,
|
|||
if (object)
|
||||
gimp_pdb_dialog_run_callback (dialog, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_pdb_dialog_plug_in_closed (GimpPlugInManager *manager,
|
||||
GimpPlugIn *plug_in,
|
||||
GimpPdbDialog *dialog)
|
||||
{
|
||||
if (dialog->caller_context && dialog->callback_name)
|
||||
{
|
||||
if (! gimp_pdb_lookup_procedure (dialog->pdb, dialog->callback_name))
|
||||
{
|
||||
gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,6 @@ void gimp_pdb_dialog_run_callback (GimpPdbDialog *dialog,
|
|||
|
||||
GimpPdbDialog * gimp_pdb_dialog_get_by_callback (GimpPdbDialogClass *klass,
|
||||
const gchar *callback_name);
|
||||
void gimp_pdb_dialogs_check_callback (GimpPdbDialogClass *klass);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
|
Loading…
Reference in New Issue