static void plug_in_actions_add_proc (GimpActionGroup *group, GimpPlugInProcedure *proc) { GimpProcedureActionEntry entry; const gchar *locale_domain; GList *list; locale_domain = gimp_plug_in_procedure_get_locale_domain (proc); entry.name = gimp_object_get_name (proc); entry.icon_name = gimp_viewable_get_icon_name (GIMP_VIEWABLE (proc)); entry.label = gimp_procedure_get_menu_label (GIMP_PROCEDURE (proc)); entry.accelerator = NULL; entry.tooltip = gimp_procedure_get_blurb (GIMP_PROCEDURE (proc)); entry.procedure = GIMP_PROCEDURE (proc); entry.help_id = gimp_procedure_get_help_id (GIMP_PROCEDURE (proc)); gimp_action_group_add_procedure_actions (group, &entry, 1, G_CALLBACK (plug_in_run_cmd_callback)); for (list = proc->menu_paths; list; list = g_list_next (list)) { const gchar *original = list->data; const gchar *translated = dgettext (locale_domain, original); if (plug_in_actions_check_translation (original, translated)) plug_in_actions_build_path (group, original, translated); else plug_in_actions_build_path (group, original, original); } if (proc->image_types_val) { GimpContext *context = gimp_get_user_context (group->gimp); GimpImage *image = gimp_context_get_image (context); GimpDrawable *drawable = NULL; gboolean sensitive; const gchar *tooltip; if (image) drawable = gimp_image_get_active_drawable (image); sensitive = gimp_procedure_get_sensitive (GIMP_PROCEDURE (proc), GIMP_OBJECT (drawable), &tooltip); gimp_action_group_set_action_sensitive (group, gimp_object_get_name (proc), sensitive); if (! sensitive && drawable && tooltip) gimp_action_group_set_action_tooltip (group, gimp_object_get_name (proc), tooltip); } }
void plug_in_actions_update (GimpActionGroup *group, gpointer data) { GimpImage *image = action_data_get_image (data); GimpPlugInManager *manager = group->gimp->plug_in_manager; GimpDrawable *drawable = NULL; GSList *list; if (image) drawable = gimp_image_get_active_drawable (image); for (list = manager->plug_in_procedures; list; list = g_slist_next (list)) { GimpPlugInProcedure *proc = list->data; if (proc->menu_label && ! proc->file_proc && proc->image_types_val) { GimpProcedure *procedure = GIMP_PROCEDURE (proc); gboolean sensitive; const gchar *tooltip; sensitive = gimp_procedure_get_sensitive (procedure, GIMP_OBJECT (drawable), &tooltip); gimp_action_group_set_action_sensitive (group, gimp_object_get_name (proc), sensitive); if (sensitive || ! drawable || ! tooltip) tooltip = gimp_procedure_get_blurb (procedure); gimp_action_group_set_action_tooltip (group, gimp_object_get_name (proc), tooltip); } } }
void filters_actions_update (GimpActionGroup *group, gpointer data) { GimpImage *image; GimpDrawable *drawable = NULL; gboolean writable = FALSE; gboolean gray = FALSE; gboolean alpha = FALSE; image = action_data_get_image (data); if (image) { drawable = gimp_image_get_active_drawable (image); if (drawable) { GimpItem *item; alpha = gimp_drawable_has_alpha (drawable); gray = gimp_drawable_is_gray (drawable); if (GIMP_IS_LAYER_MASK (drawable)) item = GIMP_ITEM (gimp_layer_mask_get_layer (GIMP_LAYER_MASK (drawable))); else item = GIMP_ITEM (drawable); writable = ! gimp_item_is_content_locked (item); if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable))) writable = FALSE; } } #define SET_SENSITIVE(action,condition) \ gimp_action_group_set_action_sensitive (group, action, (condition) != 0) SET_SENSITIVE ("filters-alien-map", writable); SET_SENSITIVE ("filters-antialias", writable); SET_SENSITIVE ("filters-apply-canvas", writable); SET_SENSITIVE ("filters-apply-lens", writable); SET_SENSITIVE ("filters-bump-map", writable); SET_SENSITIVE ("filters-c2g", writable && !gray); SET_SENSITIVE ("filters-cartoon", writable); SET_SENSITIVE ("filters-channel-mixer", writable); SET_SENSITIVE ("filters-checkerboard", writable); SET_SENSITIVE ("filters-color-enhance", writable && !gray); SET_SENSITIVE ("filters-color-exchange", writable); SET_SENSITIVE ("filters-color-reduction", writable); SET_SENSITIVE ("filters-color-rotate", writable); SET_SENSITIVE ("filters-color-temperature", writable && !gray); SET_SENSITIVE ("filters-color-to-alpha", writable && !gray && alpha); SET_SENSITIVE ("filters-convolution-matrix", writable); SET_SENSITIVE ("filters-cubism", writable); SET_SENSITIVE ("filters-deinterlace", writable); SET_SENSITIVE ("filters-desaturate", writable && !gray); SET_SENSITIVE ("filters-difference-of-gaussians", writable); SET_SENSITIVE ("filters-diffraction-patterns", writable); SET_SENSITIVE ("filters-displace", writable); SET_SENSITIVE ("filters-distance-map", writable); SET_SENSITIVE ("filters-dropshadow", writable && alpha); SET_SENSITIVE ("filters-edge", writable); SET_SENSITIVE ("filters-edge-laplace", writable); SET_SENSITIVE ("filters-edge-sobel", writable); SET_SENSITIVE ("filters-emboss", writable); SET_SENSITIVE ("filters-engrave", writable); SET_SENSITIVE ("filters-exposure", writable); SET_SENSITIVE ("filters-fractal-trace", writable); SET_SENSITIVE ("filters-gaussian-blur", writable); SET_SENSITIVE ("filters-gaussian-blur-selective", writable); SET_SENSITIVE ("filters-gegl-graph", writable); SET_SENSITIVE ("filters-grid", writable); SET_SENSITIVE ("filters-high-pass", writable); SET_SENSITIVE ("filters-illusion", writable); SET_SENSITIVE ("filters-kaleidoscope", writable); SET_SENSITIVE ("filters-lens-distortion", writable); SET_SENSITIVE ("filters-lens-flare", writable); SET_SENSITIVE ("filters-maze", writable); SET_SENSITIVE ("filters-mono-mixer", writable && !gray); SET_SENSITIVE ("filters-mosaic", writable); SET_SENSITIVE ("filters-motion-blur-circular", writable); SET_SENSITIVE ("filters-motion-blur-linear", writable); SET_SENSITIVE ("filters-motion-blur-zoom", writable); SET_SENSITIVE ("filters-noise-cell", writable); SET_SENSITIVE ("filters-noise-cie-lch", writable); SET_SENSITIVE ("filters-noise-hsv", writable && !gray); SET_SENSITIVE ("filters-noise-hurl", writable); SET_SENSITIVE ("filters-noise-perlin", writable); SET_SENSITIVE ("filters-noise-pick", writable); SET_SENSITIVE ("filters-noise-reduction", writable); SET_SENSITIVE ("filters-noise-rgb", writable); SET_SENSITIVE ("filters-noise-simplex", writable); SET_SENSITIVE ("filters-noise-slur", writable); SET_SENSITIVE ("filters-noise-solid", writable); SET_SENSITIVE ("filters-noise-spread", writable); SET_SENSITIVE ("filters-oilify", writable); SET_SENSITIVE ("filters-panorama-projection", writable); SET_SENSITIVE ("filters-photocopy", writable); SET_SENSITIVE ("filters-pixelize", writable); SET_SENSITIVE ("filters-plasma", writable); SET_SENSITIVE ("filters-polar-coordinates", writable); SET_SENSITIVE ("filters-posterize", writable); SET_SENSITIVE ("filters-red-eye-removal", writable && !gray); SET_SENSITIVE ("filters-ripple", writable); SET_SENSITIVE ("filters-saturation", writable && !gray); SET_SENSITIVE ("filters-semi-flatten", writable && alpha); SET_SENSITIVE ("filters-sepia", writable && !gray); SET_SENSITIVE ("filters-shift", writable); SET_SENSITIVE ("filters-sinus", writable); SET_SENSITIVE ("filters-softglow", writable); SET_SENSITIVE ("filters-stretch-contrast", writable); SET_SENSITIVE ("filters-stretch-contrast-hsv", writable); SET_SENSITIVE ("filters-supernova", writable); SET_SENSITIVE ("filters-threshold-alpha", writable && alpha); SET_SENSITIVE ("filters-tile-glass", writable); SET_SENSITIVE ("filters-tile-paper", writable); SET_SENSITIVE ("filters-tile-seamless", writable); SET_SENSITIVE ("filters-unsharp-mask", writable); SET_SENSITIVE ("filters-value-propagate", writable); SET_SENSITIVE ("filters-video-degradation", writable); SET_SENSITIVE ("filters-vignette", writable); SET_SENSITIVE ("filters-waves", writable); SET_SENSITIVE ("filters-whirl-pinch", writable); SET_SENSITIVE ("filters-wind", writable); #undef SET_SENSITIVE { GimpProcedure *proc = gimp_filter_history_nth (group->gimp, 0); gint i; if (proc && gimp_procedure_get_sensitive (proc, GIMP_OBJECT (drawable))) { gimp_action_group_set_action_sensitive (group, "filters-repeat", TRUE); gimp_action_group_set_action_sensitive (group, "filters-reshow", TRUE); } else { gimp_action_group_set_action_sensitive (group, "filters-repeat", FALSE); gimp_action_group_set_action_sensitive (group, "filters-reshow", FALSE); } for (i = 0; i < gimp_filter_history_length (group->gimp); i++) { gchar *name = g_strdup_printf ("filter-recent-%02d", i + 1); gboolean sensitive; proc = gimp_filter_history_nth (group->gimp, i); sensitive = gimp_procedure_get_sensitive (proc, GIMP_OBJECT (drawable)); gimp_action_group_set_action_sensitive (group, name, sensitive); g_free (name); } } }