diff --git a/ChangeLog b/ChangeLog index 7825df28ed..3fdf523154 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2004-08-08 Michael Natterer + + * app/plug-in/plug-in-proc.[ch] (plug_in_proc_def_get_sensitive): + new function which checks a GimpImageType against the + proc_def->image_types_val mask. + + * app/actions/plug-in-actions.c: use the new function here. Also + separated setting the "Repeat last" and "Reshow last" actions' + labels from setting their sensitivity and made them use the same + sensitivity logic as all other plug-in actions. Fixes bug #149567. + 2004-08-07 Simon Budig * libgimpwidgets/gimpcolorscales.c: emit the COLOR_CHANGED signal diff --git a/app/actions/plug-in-actions.c b/app/actions/plug-in-actions.c index 35aaf7992c..48586456dd 100644 --- a/app/actions/plug-in-actions.c +++ b/app/actions/plug-in-actions.c @@ -50,8 +50,6 @@ static void plug_in_actions_last_changed (Gimp *gimp, GimpActionGroup *group); -static void plug_in_actions_update_last (GimpActionGroup *group, - gpointer data); static gboolean plug_in_actions_check_translation (const gchar *original, const gchar *translated); static void plug_in_actions_build_path (GimpActionGroup *group, @@ -140,6 +138,7 @@ plug_in_actions_setup (GimpActionGroup *group) g_signal_connect_object (group->gimp, "last-plug-in-changed", G_CALLBACK (plug_in_actions_last_changed), group, 0); + plug_in_actions_last_changed (group->gimp, group); } void @@ -171,32 +170,7 @@ plug_in_actions_update (GimpActionGroup *group, ! proc_def->prefixes && ! proc_def->magics) { - gboolean sensitive; - - switch (type) - { - case GIMP_RGB_IMAGE: - sensitive = proc_def->image_types_val & PLUG_IN_RGB_IMAGE; - break; - case GIMP_RGBA_IMAGE: - sensitive = proc_def->image_types_val & PLUG_IN_RGBA_IMAGE; - break; - case GIMP_GRAY_IMAGE: - sensitive = proc_def->image_types_val & PLUG_IN_GRAY_IMAGE; - break; - case GIMP_GRAYA_IMAGE: - sensitive = proc_def->image_types_val & PLUG_IN_GRAYA_IMAGE; - break; - case GIMP_INDEXED_IMAGE: - sensitive = proc_def->image_types_val & PLUG_IN_INDEXED_IMAGE; - break; - case GIMP_INDEXEDA_IMAGE: - sensitive = proc_def->image_types_val & PLUG_IN_INDEXEDA_IMAGE; - break; - default: - sensitive = FALSE; - break; - } + gboolean sensitive = plug_in_proc_def_get_sensitive (proc_def, type); gimp_action_group_set_action_sensitive (group, proc_def->db_info.name, @@ -204,7 +178,17 @@ plug_in_actions_update (GimpActionGroup *group, } } - plug_in_actions_update_last (group, data); + if (group->gimp->last_plug_in && + plug_in_proc_def_get_sensitive (group->gimp->last_plug_in, type)) + { + gimp_action_group_set_action_sensitive (group, "plug-in-repeat", TRUE); + gimp_action_group_set_action_sensitive (group, "plug-in-reshow", TRUE); + } + else + { + gimp_action_group_set_action_sensitive (group, "plug-in-repeat", FALSE); + gimp_action_group_set_action_sensitive (group, "plug-in-reshow", FALSE); + } } void @@ -323,16 +307,9 @@ static void plug_in_actions_last_changed (Gimp *gimp, GimpActionGroup *group) { - plug_in_actions_update_last (group, NULL); -} - -static void -plug_in_actions_update_last (GimpActionGroup *group, - gpointer data) -{ - if (group->gimp->last_plug_in) + if (gimp->last_plug_in) { - PlugInProcDef *proc_def = group->gimp->last_plug_in; + PlugInProcDef *proc_def = gimp->last_plug_in; const gchar *progname; const gchar *domain; gchar *label; @@ -354,9 +331,6 @@ plug_in_actions_update_last (GimpActionGroup *group, g_free (repeat); g_free (reshow); - - gimp_action_group_set_action_sensitive (group, "plug-in-repeat", TRUE); - gimp_action_group_set_action_sensitive (group, "plug-in-reshow", TRUE); } else { @@ -364,9 +338,6 @@ plug_in_actions_update_last (GimpActionGroup *group, _("Repeat Last")); gimp_action_group_set_action_label (group, "plug-in-reshow", _("Re-Show Last")); - - gimp_action_group_set_action_sensitive (group, "plug-in-repeat", FALSE); - gimp_action_group_set_action_sensitive (group, "plug-in-reshow", FALSE); } } diff --git a/app/pdb/gimppluginprocedure.c b/app/pdb/gimppluginprocedure.c index 3332450d46..5fd393df46 100644 --- a/app/pdb/gimppluginprocedure.c +++ b/app/pdb/gimppluginprocedure.c @@ -243,3 +243,39 @@ plug_in_proc_def_get_help_id (const PlugInProcDef *proc_def, return help_id; } + +gboolean +plug_in_proc_def_get_sensitive (const PlugInProcDef *proc_def, + GimpImageType image_type) +{ + gboolean sensitive; + + g_return_val_if_fail (proc_def != NULL, FALSE); + + switch (image_type) + { + case GIMP_RGB_IMAGE: + sensitive = proc_def->image_types_val & PLUG_IN_RGB_IMAGE; + break; + case GIMP_RGBA_IMAGE: + sensitive = proc_def->image_types_val & PLUG_IN_RGBA_IMAGE; + break; + case GIMP_GRAY_IMAGE: + sensitive = proc_def->image_types_val & PLUG_IN_GRAY_IMAGE; + break; + case GIMP_GRAYA_IMAGE: + sensitive = proc_def->image_types_val & PLUG_IN_GRAYA_IMAGE; + break; + case GIMP_INDEXED_IMAGE: + sensitive = proc_def->image_types_val & PLUG_IN_INDEXED_IMAGE; + break; + case GIMP_INDEXEDA_IMAGE: + sensitive = proc_def->image_types_val & PLUG_IN_INDEXEDA_IMAGE; + break; + default: + sensitive = FALSE; + break; + } + + return sensitive ? TRUE : FALSE; +} diff --git a/app/pdb/gimppluginprocedure.h b/app/pdb/gimppluginprocedure.h index 1e321f739b..3dd8525671 100644 --- a/app/pdb/gimppluginprocedure.h +++ b/app/pdb/gimppluginprocedure.h @@ -63,6 +63,8 @@ const gchar * plug_in_proc_def_get_stock_id (const PlugInProcDef *proc_def) GdkPixbuf * plug_in_proc_def_get_pixbuf (const PlugInProcDef *proc_def); gchar * plug_in_proc_def_get_help_id (const PlugInProcDef *proc_def, const gchar *help_domain); +gboolean plug_in_proc_def_get_sensitive (const PlugInProcDef *proc_def, + GimpImageType image_type); #endif /* __PLUG_IN_PROC_H__ */ diff --git a/app/plug-in/gimppluginprocedure.c b/app/plug-in/gimppluginprocedure.c index 3332450d46..5fd393df46 100644 --- a/app/plug-in/gimppluginprocedure.c +++ b/app/plug-in/gimppluginprocedure.c @@ -243,3 +243,39 @@ plug_in_proc_def_get_help_id (const PlugInProcDef *proc_def, return help_id; } + +gboolean +plug_in_proc_def_get_sensitive (const PlugInProcDef *proc_def, + GimpImageType image_type) +{ + gboolean sensitive; + + g_return_val_if_fail (proc_def != NULL, FALSE); + + switch (image_type) + { + case GIMP_RGB_IMAGE: + sensitive = proc_def->image_types_val & PLUG_IN_RGB_IMAGE; + break; + case GIMP_RGBA_IMAGE: + sensitive = proc_def->image_types_val & PLUG_IN_RGBA_IMAGE; + break; + case GIMP_GRAY_IMAGE: + sensitive = proc_def->image_types_val & PLUG_IN_GRAY_IMAGE; + break; + case GIMP_GRAYA_IMAGE: + sensitive = proc_def->image_types_val & PLUG_IN_GRAYA_IMAGE; + break; + case GIMP_INDEXED_IMAGE: + sensitive = proc_def->image_types_val & PLUG_IN_INDEXED_IMAGE; + break; + case GIMP_INDEXEDA_IMAGE: + sensitive = proc_def->image_types_val & PLUG_IN_INDEXEDA_IMAGE; + break; + default: + sensitive = FALSE; + break; + } + + return sensitive ? TRUE : FALSE; +} diff --git a/app/plug-in/gimppluginprocedure.h b/app/plug-in/gimppluginprocedure.h index 1e321f739b..3dd8525671 100644 --- a/app/plug-in/gimppluginprocedure.h +++ b/app/plug-in/gimppluginprocedure.h @@ -63,6 +63,8 @@ const gchar * plug_in_proc_def_get_stock_id (const PlugInProcDef *proc_def) GdkPixbuf * plug_in_proc_def_get_pixbuf (const PlugInProcDef *proc_def); gchar * plug_in_proc_def_get_help_id (const PlugInProcDef *proc_def, const gchar *help_domain); +gboolean plug_in_proc_def_get_sensitive (const PlugInProcDef *proc_def, + GimpImageType image_type); #endif /* __PLUG_IN_PROC_H__ */ diff --git a/app/plug-in/plug-in-proc-def.c b/app/plug-in/plug-in-proc-def.c index 3332450d46..5fd393df46 100644 --- a/app/plug-in/plug-in-proc-def.c +++ b/app/plug-in/plug-in-proc-def.c @@ -243,3 +243,39 @@ plug_in_proc_def_get_help_id (const PlugInProcDef *proc_def, return help_id; } + +gboolean +plug_in_proc_def_get_sensitive (const PlugInProcDef *proc_def, + GimpImageType image_type) +{ + gboolean sensitive; + + g_return_val_if_fail (proc_def != NULL, FALSE); + + switch (image_type) + { + case GIMP_RGB_IMAGE: + sensitive = proc_def->image_types_val & PLUG_IN_RGB_IMAGE; + break; + case GIMP_RGBA_IMAGE: + sensitive = proc_def->image_types_val & PLUG_IN_RGBA_IMAGE; + break; + case GIMP_GRAY_IMAGE: + sensitive = proc_def->image_types_val & PLUG_IN_GRAY_IMAGE; + break; + case GIMP_GRAYA_IMAGE: + sensitive = proc_def->image_types_val & PLUG_IN_GRAYA_IMAGE; + break; + case GIMP_INDEXED_IMAGE: + sensitive = proc_def->image_types_val & PLUG_IN_INDEXED_IMAGE; + break; + case GIMP_INDEXEDA_IMAGE: + sensitive = proc_def->image_types_val & PLUG_IN_INDEXEDA_IMAGE; + break; + default: + sensitive = FALSE; + break; + } + + return sensitive ? TRUE : FALSE; +} diff --git a/app/plug-in/plug-in-proc-def.h b/app/plug-in/plug-in-proc-def.h index 1e321f739b..3dd8525671 100644 --- a/app/plug-in/plug-in-proc-def.h +++ b/app/plug-in/plug-in-proc-def.h @@ -63,6 +63,8 @@ const gchar * plug_in_proc_def_get_stock_id (const PlugInProcDef *proc_def) GdkPixbuf * plug_in_proc_def_get_pixbuf (const PlugInProcDef *proc_def); gchar * plug_in_proc_def_get_help_id (const PlugInProcDef *proc_def, const gchar *help_domain); +gboolean plug_in_proc_def_get_sensitive (const PlugInProcDef *proc_def, + GimpImageType image_type); #endif /* __PLUG_IN_PROC_H__ */ diff --git a/app/plug-in/plug-in-proc.c b/app/plug-in/plug-in-proc.c index 3332450d46..5fd393df46 100644 --- a/app/plug-in/plug-in-proc.c +++ b/app/plug-in/plug-in-proc.c @@ -243,3 +243,39 @@ plug_in_proc_def_get_help_id (const PlugInProcDef *proc_def, return help_id; } + +gboolean +plug_in_proc_def_get_sensitive (const PlugInProcDef *proc_def, + GimpImageType image_type) +{ + gboolean sensitive; + + g_return_val_if_fail (proc_def != NULL, FALSE); + + switch (image_type) + { + case GIMP_RGB_IMAGE: + sensitive = proc_def->image_types_val & PLUG_IN_RGB_IMAGE; + break; + case GIMP_RGBA_IMAGE: + sensitive = proc_def->image_types_val & PLUG_IN_RGBA_IMAGE; + break; + case GIMP_GRAY_IMAGE: + sensitive = proc_def->image_types_val & PLUG_IN_GRAY_IMAGE; + break; + case GIMP_GRAYA_IMAGE: + sensitive = proc_def->image_types_val & PLUG_IN_GRAYA_IMAGE; + break; + case GIMP_INDEXED_IMAGE: + sensitive = proc_def->image_types_val & PLUG_IN_INDEXED_IMAGE; + break; + case GIMP_INDEXEDA_IMAGE: + sensitive = proc_def->image_types_val & PLUG_IN_INDEXEDA_IMAGE; + break; + default: + sensitive = FALSE; + break; + } + + return sensitive ? TRUE : FALSE; +} diff --git a/app/plug-in/plug-in-proc.h b/app/plug-in/plug-in-proc.h index 1e321f739b..3dd8525671 100644 --- a/app/plug-in/plug-in-proc.h +++ b/app/plug-in/plug-in-proc.h @@ -63,6 +63,8 @@ const gchar * plug_in_proc_def_get_stock_id (const PlugInProcDef *proc_def) GdkPixbuf * plug_in_proc_def_get_pixbuf (const PlugInProcDef *proc_def); gchar * plug_in_proc_def_get_help_id (const PlugInProcDef *proc_def, const gchar *help_domain); +gboolean plug_in_proc_def_get_sensitive (const PlugInProcDef *proc_def, + GimpImageType image_type); #endif /* __PLUG_IN_PROC_H__ */