From ac50da2ad4220f8dcf060574e27b0047f104d2ff Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Wed, 30 Dec 2015 11:53:52 +0100 Subject: [PATCH] Bug 759316 - "Recently used" menu not updated with gegl filters This preparation commit only moves code around and renames it, the history is still a list of plug-ins only: - move app/core/gimp-filter-history.c to app/plug-in/gimppluginmanager-history.c and clean it up - move the actions that create the submenus under "Filters" from the "plug-in" to the "filters" action group - move the code that creates and updates the history actions to the "filters" action group - add menu setup code for the "filters" menu - move the "history-changed" signal from GimpPlugInManager to Gimp --- app/actions/filters-actions.c | 290 +++++++++++++++++++++++- app/actions/filters-commands.c | 64 ++++++ app/actions/filters-commands.h | 7 + app/actions/plug-in-actions.c | 242 +------------------- app/actions/plug-in-commands.c | 74 +----- app/actions/plug-in-commands.h | 18 +- app/config/gimpcoreconfig.c | 16 +- app/config/gimpcoreconfig.h | 2 +- app/config/gimprc-blurbs.h | 4 +- app/core/Makefile.am | 2 + app/core/gimp-filter-history.c | 137 +++++++++++ app/core/gimp-filter-history.h | 35 +++ app/core/gimp.c | 27 +++ app/core/gimp.h | 156 +++++++------ app/menus/Makefile.am | 2 + app/menus/filters-menu.c | 63 +++++ app/menus/filters-menu.h | 26 +++ app/menus/image-menu.c | 2 + app/menus/plug-in-menus.c | 4 +- app/plug-in/Makefile.am | 2 - app/plug-in/gimppluginmanager-history.c | 125 ---------- app/plug-in/gimppluginmanager-history.h | 35 --- app/plug-in/gimppluginmanager.c | 40 +--- app/plug-in/gimppluginmanager.h | 4 - menus/image-menu.xml.in | 48 ++-- 25 files changed, 799 insertions(+), 626 deletions(-) create mode 100644 app/core/gimp-filter-history.c create mode 100644 app/core/gimp-filter-history.h create mode 100644 app/menus/filters-menu.c create mode 100644 app/menus/filters-menu.h delete mode 100644 app/plug-in/gimppluginmanager-history.c delete mode 100644 app/plug-in/gimppluginmanager-history.h diff --git a/app/actions/filters-actions.c b/app/actions/filters-actions.c index 15815e1c7c..0583ea5fe8 100644 --- a/app/actions/filters-actions.c +++ b/app/actions/filters-actions.c @@ -24,11 +24,15 @@ #include "actions-types.h" +#include "core/gimp-filter-history.h" #include "core/gimpimage.h" #include "core/gimplayermask.h" +#include "plug-in/gimppluginprocedure.h" /* FIXME history */ + #include "widgets/gimpactiongroup.h" #include "widgets/gimphelp-ids.h" +#include "widgets/gimpuimanager.h" #include "actions.h" #include "filters-actions.h" @@ -37,6 +41,60 @@ #include "gimp-intl.h" +/* local function prototypes */ + +static void filters_actions_history_changed (Gimp *gimp, + GimpActionGroup *group); + + +/* private variables */ + +static const GimpActionEntry filters_menu_actions[] = +{ + { "filters-menu", NULL, NC_("filters-action", + "Filte_rs") }, + { "filters-recent-menu", NULL, NC_("filters-action", + "Recently Used") }, + { "filters-blur-menu", NULL, NC_("filters-action", + "_Blur") }, + { "filters-noise-menu", NULL, NC_("filters-action", + "_Noise") }, + { "filters-edge-detect-menu", NULL, NC_("filters-action", + "Edge-De_tect") }, + { "filters-enhance-menu", NULL, NC_("filters-action", + "En_hance") }, + { "filters-combine-menu", NULL, NC_("filters-action", + "C_ombine") }, + { "filters-generic-menu", NULL, NC_("filters-action", + "_Generic") }, + { "filters-light-shadow-menu", NULL, NC_("filters-action", + "_Light and Shadow") }, + { "filters-distorts-menu", NULL, NC_("filters-action", + "_Distorts") }, + { "filters-artistic-menu", NULL, NC_("filters-action", + "_Artistic") }, + { "filters-decor-menu", NULL, NC_("filters-action", + "_Decor") }, + { "filters-map-menu", NULL, NC_("filters-action", + "_Map") }, + { "filters-render-menu", NULL, NC_("filters-action", + "_Render") }, + { "filters-render-clouds-menu", NULL, NC_("filters-action", + "_Clouds") }, + { "filters-render-fractals-menu", NULL, NC_("filters-action", + "_Fractals") }, + { "filters-render-nature-menu", NULL, NC_("filters-action", + "_Nature") }, + { "filters-render-noise-menu", NULL, NC_("filters-action", + "N_oise") }, + { "filters-render-pattern-menu", NULL, NC_("filters-action", + "_Pattern") }, + { "filters-web-menu", NULL, NC_("filters-action", + "_Web") }, + { "filters-animation-menu", NULL, NC_("filters-action", + "An_imation") } +}; + static const GimpStringActionEntry filters_actions[] = { { "filters-alien-map", GIMP_STOCK_GEGL, @@ -447,19 +505,47 @@ static const GimpStringActionEntry filters_actions[] = { "filters-wind", GIMP_STOCK_GEGL, NC_("filters-action", "W_ind..."), NULL, NULL, "gegl:wind", - NULL /* FIXME GIMP_HELP_FILTER_WIND */ }, + NULL /* FIXME GIMP_HELP_FILTER_WIND */ } }; +static const GimpEnumActionEntry filters_repeat_actions[] = +{ + { "filters-repeat", "system-run", + NC_("filters-action", "Re_peat Last"), "F", + NC_("filters-action", + "Rerun the last used filter using the same settings"), + GIMP_RUN_WITH_LAST_VALS, FALSE, + GIMP_HELP_FILTER_REPEAT }, + + { "filters-reshow", GIMP_STOCK_RESHOW_FILTER, + NC_("filters-action", "R_e-Show Last"), "F", + NC_("filters-action", "Show the last used filter dialog again"), + GIMP_RUN_INTERACTIVE, FALSE, + GIMP_HELP_FILTER_RESHOW } +}; + + void filters_actions_setup (GimpActionGroup *group) { - gint i; + GimpPlugInActionEntry *entries; + gint n_entries; + gint i; + + gimp_action_group_add_actions (group, "filters-action", + filters_menu_actions, + G_N_ELEMENTS (filters_menu_actions)); gimp_action_group_add_string_actions (group, "filters-action", filters_actions, G_N_ELEMENTS (filters_actions), G_CALLBACK (filters_filter_cmd_callback)); + gimp_action_group_add_enum_actions (group, "filters-action", + filters_repeat_actions, + G_N_ELEMENTS (filters_repeat_actions), + G_CALLBACK (filters_repeat_cmd_callback)); + for (i = 0; i < G_N_ELEMENTS (filters_actions); i++) { const GimpStringActionEntry *entry = &filters_actions[i]; @@ -471,6 +557,38 @@ filters_actions_setup (GimpActionGroup *group) gimp_action_group_set_action_tooltip (group, entry->name, description); } + + n_entries = gimp_filter_history_size (group->gimp); + + entries = g_new0 (GimpPlugInActionEntry, n_entries); + + for (i = 0; i < n_entries; i++) + { + entries[i].name = g_strdup_printf ("filter-recent-%02d", i + 1); + entries[i].icon_name = NULL; + entries[i].label = ""; + entries[i].accelerator = ""; + entries[i].tooltip = NULL; + entries[i].procedure = NULL; + entries[i].help_id = GIMP_HELP_FILTER_RESHOW; + } + + gimp_action_group_add_plug_in_actions (group, entries, n_entries, + G_CALLBACK (filters_history_cmd_callback)); + + for (i = 0; i < n_entries; i++) + { + gimp_action_group_set_action_visible (group, entries[i].name, FALSE); + g_free ((gchar *) entries[i].name); + } + + g_free (entries); + + g_signal_connect_object (group->gimp, "filter-history-changed", + G_CALLBACK (filters_actions_history_changed), + group, 0); + + filters_actions_history_changed (group->gimp, group); } void @@ -593,4 +711,172 @@ filters_actions_update (GimpActionGroup *group, SET_SENSITIVE ("filters-wind", writable); #undef SET_SENSITIVE + + { + GimpPlugInProcedure *proc = gimp_filter_history_nth (group->gimp, 0); + gint i; + + if (proc && gimp_plug_in_procedure_get_sensitive (proc, 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_plug_in_procedure_get_sensitive (proc, drawable); + + gimp_action_group_set_action_sensitive (group, name, sensitive); + + g_free (name); + } + } +} + +static GimpActionGroup * +filters_actions_get_plug_in_group (GimpActionGroup *group) +{ + GList *list; + + for (list = gimp_ui_managers_from_name (""); + list; + list = g_list_next (list)) + { + GimpUIManager *manager = list->data; + + /* if this is our UI manager */ + if (gimp_ui_manager_get_action_group (manager, "filters") == group) + return gimp_ui_manager_get_action_group (manager, "plug-in"); + } + + /* this happens during initial UI manager construction */ + return NULL; +} + +static void +filters_actions_history_changed (Gimp *gimp, + GimpActionGroup *group) +{ + GimpPlugInProcedure *proc; + GimpActionGroup *plug_in_group; + gint i; + + plug_in_group = filters_actions_get_plug_in_group (group); + + proc = gimp_filter_history_nth (gimp, 0); + + if (proc) + { + const gchar *label; + gchar *repeat; + gchar *reshow; + gboolean sensitive = FALSE; + + label = gimp_plug_in_procedure_get_label (proc); + + /* copy the sensitivity of the plug-in procedure's actual action + * instead of calling filters_actions_update() because doing the + * latter would set the sensitivity of this image's action on + * all images' actions. See bug #517683. + */ + if (plug_in_group) + { + GtkAction *actual_action = + gtk_action_group_get_action (GTK_ACTION_GROUP (plug_in_group), + gimp_object_get_name (proc)); + if (actual_action) + sensitive = gtk_action_get_sensitive (actual_action); + } + + repeat = g_strdup_printf (_("Re_peat \"%s\""), label); + reshow = g_strdup_printf (_("R_e-Show \"%s\""), label); + + gimp_action_group_set_action_label (group, "filters-repeat", repeat); + gimp_action_group_set_action_label (group, "filters-reshow", reshow); + + gimp_action_group_set_action_sensitive (group, "filters-repeat", + sensitive); + gimp_action_group_set_action_sensitive (group, "filters-reshow", + sensitive); + + g_free (repeat); + g_free (reshow); + } + else + { + gimp_action_group_set_action_label (group, "filters-repeat", + _("Repeat Last")); + gimp_action_group_set_action_label (group, "filters-reshow", + _("Re-Show Last")); + + 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 (gimp); i++) + { + GtkAction *action; + const gchar *label; + gchar *name; + gboolean sensitive = FALSE; + + name = g_strdup_printf ("filter-recent-%02d", i + 1); + action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), name); + g_free (name); + + proc = gimp_filter_history_nth (gimp, i); + + if (proc->menu_label) + { + label = dgettext (gimp_plug_in_procedure_get_locale_domain (proc), + proc->menu_label); + } + else + { + label = gimp_plug_in_procedure_get_label (proc); + } + + /* see comment above */ + if (plug_in_group) + { + GtkAction *actual_action = + gtk_action_group_get_action (GTK_ACTION_GROUP (plug_in_group), + gimp_object_get_name (proc)); + if (actual_action) + sensitive = gtk_action_get_sensitive (actual_action); + } + + g_object_set (action, + "visible", TRUE, + "sensitive", sensitive, + "procedure", proc, + "label", label, + "icon-name", gimp_plug_in_procedure_get_icon_name (proc), + "tooltip", gimp_plug_in_procedure_get_blurb (proc), + NULL); + } + + for (; i < gimp_filter_history_size (gimp); i++) + { + GtkAction *action; + gchar *name = g_strdup_printf ("filter-recent-%02d", i + 1); + + action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), name); + g_free (name); + + g_object_set (action, + "visible", FALSE, + "procedure", NULL, + NULL); + } } diff --git a/app/actions/filters-commands.c b/app/actions/filters-commands.c index 6635154bac..5cbc894f8a 100644 --- a/app/actions/filters-commands.c +++ b/app/actions/filters-commands.c @@ -25,15 +25,19 @@ #include "actions-types.h" #include "core/gimp.h" +#include "core/gimp-filter-history.h" #include "core/gimpcontext.h" #include "core/gimpimage.h" #include "core/gimptoolinfo.h" +#include "pdb/gimpprocedure.h" /* FIXME history */ + #include "tools/gimpoperationtool.h" #include "tools/tool_manager.h" #include "actions.h" #include "filters-commands.h" +#include "plug-in-commands.h" /* FIXME history */ #include "gimp-intl.h" @@ -93,3 +97,63 @@ filters_filter_cmd_callback (GtkAction *action, g_free (label); } } + +void +filters_repeat_cmd_callback (GtkAction *action, + gint value, + gpointer data) +{ + GimpPlugInProcedure *procedure; + Gimp *gimp; + GimpDisplay *display; + GimpRunMode run_mode; + return_if_no_gimp (gimp, data); + return_if_no_display (display, data); + + run_mode = (GimpRunMode) value; + + procedure = gimp_filter_history_nth (gimp, 0); + + if (procedure) + { + GimpValueArray *args; + gint n_args; + + args = gimp_procedure_get_arguments (GIMP_PROCEDURE (procedure)); + + g_value_set_int (gimp_value_array_index (args, 0), run_mode); + + n_args = plug_in_collect_display_args (action, display, + GIMP_PROCEDURE (procedure)->args, + args, 1); + + plug_in_procedure_execute (procedure, gimp, display, args, n_args); + + gimp_value_array_unref (args); + } +} + +void +filters_history_cmd_callback (GtkAction *action, + GimpPlugInProcedure *procedure, + gpointer data) +{ + Gimp *gimp; + GimpDisplay *display; + GimpValueArray *args; + gint n_args; + return_if_no_gimp (gimp, data); + return_if_no_display (display, data); + + args = gimp_procedure_get_arguments (GIMP_PROCEDURE (procedure)); + + g_value_set_int (gimp_value_array_index (args, 0), GIMP_RUN_INTERACTIVE); + + n_args = plug_in_collect_display_args (action, display, + GIMP_PROCEDURE (procedure)->args, + args, 1); + + plug_in_procedure_execute (procedure, gimp, display, args, n_args); + + gimp_value_array_unref (args); +} diff --git a/app/actions/filters-commands.h b/app/actions/filters-commands.h index 744b49e92e..5cb2b0d5e4 100644 --- a/app/actions/filters-commands.h +++ b/app/actions/filters-commands.h @@ -23,5 +23,12 @@ void filters_filter_cmd_callback (GtkAction *action, const gchar *operation, gpointer data); +void filters_repeat_cmd_callback (GtkAction *action, + gint value, + gpointer data); +void filters_history_cmd_callback (GtkAction *action, + GimpPlugInProcedure *proc, + gpointer data); + #endif /* __FILTERS_COMMANDS_H__ */ diff --git a/app/actions/plug-in-actions.c b/app/actions/plug-in-actions.c index 9c6f3f9563..6bdbc19ac4 100644 --- a/app/actions/plug-in-actions.c +++ b/app/actions/plug-in-actions.c @@ -34,7 +34,6 @@ #include "plug-in/gimppluginmanager.h" #include "plug-in/gimppluginmanager-help-domain.h" -#include "plug-in/gimppluginmanager-history.h" #include "plug-in/gimppluginmanager-locale-domain.h" #include "plug-in/gimppluginmanager-menu-branch.h" #include "plug-in/gimppluginprocedure.h" @@ -68,8 +67,6 @@ static void plug_in_actions_menu_path_added (GimpPlugInProcedure *proc, static void plug_in_actions_add_proc (GimpActionGroup *group, GimpPlugInProcedure *proc); -static void plug_in_actions_history_changed (GimpPlugInManager *manager, - GimpActionGroup *group); static gboolean plug_in_actions_check_translation (const gchar *original, const gchar *translated); static void plug_in_actions_build_path (GimpActionGroup *group, @@ -81,49 +78,6 @@ static void plug_in_actions_build_path (GimpActionGroup *group static const GimpActionEntry plug_in_actions[] = { - { "plug-in-menu", NULL, NC_("plug-in-action", - "Filte_rs") }, - { "plug-in-recent-menu", NULL, NC_("plug-in-action", - "Recently Used") }, - { "plug-in-blur-menu", NULL, NC_("plug-in-action", - "_Blur") }, - { "plug-in-noise-menu", NULL, NC_("plug-in-action", - "_Noise") }, - { "plug-in-edge-detect-menu", NULL, NC_("plug-in-action", - "Edge-De_tect") }, - { "plug-in-enhance-menu", NULL, NC_("plug-in-action", - "En_hance") }, - { "plug-in-combine-menu", NULL, NC_("plug-in-action", - "C_ombine") }, - { "plug-in-generic-menu", NULL, NC_("plug-in-action", - "_Generic") }, - { "plug-in-light-shadow-menu", NULL, NC_("plug-in-action", - "_Light and Shadow") }, - { "plug-in-distorts-menu", NULL, NC_("plug-in-action", - "_Distorts") }, - { "plug-in-artistic-menu", NULL, NC_("plug-in-action", - "_Artistic") }, - { "plug-in-decor-menu", NULL, NC_("plug-in-action", - "_Decor") }, - { "plug-in-map-menu", NULL, NC_("plug-in-action", - "_Map") }, - { "plug-in-render-menu", NULL, NC_("plug-in-action", - "_Render") }, - { "plug-in-render-clouds-menu", NULL, NC_("plug-in-action", - "_Clouds") }, - { "plug-in-render-fractals-menu", NULL, NC_("plug-in-action", - "_Fractals") }, - { "plug-in-render-nature-menu", NULL, NC_("plug-in-action", - "_Nature") }, - { "plug-in-render-noise-menu", NULL, NC_("plug-in-action", - "N_oise") }, - { "plug-in-render-pattern-menu", NULL, NC_("plug-in-action", - "_Pattern") }, - { "plug-in-web-menu", NULL, NC_("plug-in-action", - "_Web") }, - { "plug-in-animation-menu", NULL, NC_("plug-in-action", - "An_imation") }, - { "plug-in-reset-all", GIMP_STOCK_RESET, NC_("plug-in-action", "Reset all _Filters"), NULL, NC_("plug-in-action", "Reset all plug-ins to their default settings"), @@ -131,43 +85,19 @@ static const GimpActionEntry plug_in_actions[] = GIMP_HELP_FILTER_RESET_ALL } }; -static const GimpEnumActionEntry plug_in_repeat_actions[] = -{ - { "plug-in-repeat", "system-run", - NC_("plug-in-action", "Re_peat Last"), "F", - NC_("plug-in-action", - "Rerun the last used plug-in using the same settings"), - GIMP_RUN_WITH_LAST_VALS, FALSE, - GIMP_HELP_FILTER_REPEAT }, - - { "plug-in-reshow", GIMP_STOCK_RESHOW_FILTER, - NC_("plug-in-action", "R_e-Show Last"), "F", - NC_("plug-in-action", "Show the last used plug-in dialog again"), - GIMP_RUN_INTERACTIVE, FALSE, - GIMP_HELP_FILTER_RESHOW } -}; - /* public functions */ void plug_in_actions_setup (GimpActionGroup *group) { - GimpPlugInManager *manager = group->gimp->plug_in_manager; - GimpPlugInActionEntry *entries; - GSList *list; - gint n_entries; - gint i; + GimpPlugInManager *manager = group->gimp->plug_in_manager; + GSList *list; gimp_action_group_add_actions (group, "plug-in-action", plug_in_actions, G_N_ELEMENTS (plug_in_actions)); - gimp_action_group_add_enum_actions (group, "plug-in-action", - plug_in_repeat_actions, - G_N_ELEMENTS (plug_in_repeat_actions), - G_CALLBACK (plug_in_repeat_cmd_callback)); - for (list = gimp_plug_in_manager_get_menu_branches (manager); list; list = g_slist_next (list)) @@ -204,38 +134,6 @@ plug_in_actions_setup (GimpActionGroup *group) g_signal_connect_object (group->gimp->pdb, "unregister-procedure", G_CALLBACK (plug_in_actions_unregister_procedure), group, 0); - - n_entries = gimp_plug_in_manager_history_size (manager); - - entries = g_new0 (GimpPlugInActionEntry, n_entries); - - for (i = 0; i < n_entries; i++) - { - entries[i].name = g_strdup_printf ("plug-in-recent-%02d", i + 1); - entries[i].icon_name = NULL; - entries[i].label = ""; - entries[i].accelerator = ""; - entries[i].tooltip = NULL; - entries[i].procedure = NULL; - entries[i].help_id = GIMP_HELP_FILTER_RESHOW; - } - - gimp_action_group_add_plug_in_actions (group, entries, n_entries, - G_CALLBACK (plug_in_history_cmd_callback)); - - for (i = 0; i < n_entries; i++) - { - gimp_action_group_set_action_visible (group, entries[i].name, FALSE); - g_free ((gchar *) entries[i].name); - } - - g_free (entries); - - g_signal_connect_object (manager, "history-changed", - G_CALLBACK (plug_in_actions_history_changed), - group, 0); - - plug_in_actions_history_changed (manager, group); } void @@ -246,7 +144,6 @@ plug_in_actions_update (GimpActionGroup *group, GimpPlugInManager *manager = group->gimp->plug_in_manager; GimpDrawable *drawable = NULL; GSList *list; - gint i; if (image) drawable = gimp_image_get_active_drawable (image); @@ -267,32 +164,6 @@ plug_in_actions_update (GimpActionGroup *group, sensitive); } } - - if (manager->history && - gimp_plug_in_procedure_get_sensitive (manager->history->data, drawable)) - { - 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); - } - - for (list = manager->history, i = 0; list; list = list->next, i++) - { - GimpPlugInProcedure *proc = list->data; - gchar *name = g_strdup_printf ("plug-in-recent-%02d", - i + 1); - gboolean sensitive; - - sensitive = gimp_plug_in_procedure_get_sensitive (proc, drawable); - - gimp_action_group_set_action_sensitive (group, name, sensitive); - - g_free (name); - } } @@ -522,115 +393,6 @@ plug_in_actions_add_proc (GimpActionGroup *group, } } -static void -plug_in_actions_history_changed (GimpPlugInManager *manager, - GimpActionGroup *group) -{ - GimpPlugInProcedure *proc; - gint i; - - proc = gimp_plug_in_manager_history_nth (manager, 0); - - if (proc) - { - GtkAction *actual_action; - const gchar *label; - gchar *repeat; - gchar *reshow; - gboolean sensitive = FALSE; - - label = gimp_plug_in_procedure_get_label (proc); - - /* copy the sensitivity of the plug-in procedure's actual action - * instead of calling plug_in_actions_update() because doing the - * latter would set the sensitivity of this image's action on - * all images' actions. See bug #517683. - */ - actual_action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), - gimp_object_get_name (proc)); - if (actual_action) - sensitive = gtk_action_get_sensitive (actual_action); - - repeat = g_strdup_printf (_("Re_peat \"%s\""), label); - reshow = g_strdup_printf (_("R_e-Show \"%s\""), label); - - gimp_action_group_set_action_label (group, "plug-in-repeat", repeat); - gimp_action_group_set_action_label (group, "plug-in-reshow", reshow); - - gimp_action_group_set_action_sensitive (group, - "plug-in-repeat", sensitive); - gimp_action_group_set_action_sensitive (group, - "plug-in-reshow", sensitive); - - g_free (repeat); - g_free (reshow); - } - else - { - gimp_action_group_set_action_label (group, "plug-in-repeat", - _("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); - } - - for (i = 0; i < gimp_plug_in_manager_history_length (manager); i++) - { - GtkAction *action; - GtkAction *actual_action; - const gchar *label; - gchar *name; - gboolean sensitive = FALSE; - - name = g_strdup_printf ("plug-in-recent-%02d", i + 1); - action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), name); - g_free (name); - - proc = gimp_plug_in_manager_history_nth (manager, i); - - if (proc->menu_label) - { - label = dgettext (gimp_plug_in_procedure_get_locale_domain (proc), - proc->menu_label); - } - else - { - label = gimp_plug_in_procedure_get_label (proc); - } - - /* see comment above */ - actual_action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), - gimp_object_get_name (proc)); - if (actual_action) - sensitive = gtk_action_get_sensitive (actual_action); - - g_object_set (action, - "visible", TRUE, - "sensitive", sensitive, - "procedure", proc, - "label", label, - "icon-name", gimp_plug_in_procedure_get_icon_name (proc), - "tooltip", gimp_plug_in_procedure_get_blurb (proc), - NULL); - } - - for (; i < gimp_plug_in_manager_history_size (manager); i++) - { - GtkAction *action; - gchar *name = g_strdup_printf ("plug-in-recent-%02d", i + 1); - - action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), name); - g_free (name); - - g_object_set (action, - "visible", FALSE, - "procedure", NULL, - NULL); - } -} - static gboolean plug_in_actions_check_translation (const gchar *original, const gchar *translated) diff --git a/app/actions/plug-in-commands.c b/app/actions/plug-in-commands.c index aba0d97da7..3efd5bbf37 100644 --- a/app/actions/plug-in-commands.c +++ b/app/actions/plug-in-commands.c @@ -28,6 +28,7 @@ #include "actions-types.h" #include "core/gimp.h" +#include "core/gimp-filter-history.h" #include "core/gimp-utils.h" #include "core/gimpcontainer.h" #include "core/gimpcontext.h" @@ -39,7 +40,6 @@ #include "plug-in/gimppluginmanager.h" #include "plug-in/gimppluginmanager-data.h" -#include "plug-in/gimppluginmanager-history.h" #include "pdb/gimpprocedure.h" @@ -63,11 +63,13 @@ /* local function prototypes */ +#if 0 static void plug_in_procedure_execute (GimpPlugInProcedure *procedure, Gimp *gimp, GimpDisplay *display, GimpValueArray *args, gint n_args); +#endif static gint plug_in_collect_data_args (GtkAction *action, GimpObject *object, @@ -85,11 +87,13 @@ static gint plug_in_collect_item_args (GtkAction *action, GParamSpec **pspecs, GimpValueArray *args, gint n_args); +#if 0 static gint plug_in_collect_display_args (GtkAction *action, GimpDisplay *display, GParamSpec **pspecs, GimpValueArray *args, gint n_args); +#endif static void plug_in_reset_all_response (GtkWidget *dialog, gint response_id, Gimp *gimp); @@ -193,66 +197,6 @@ plug_in_run_cmd_callback (GtkAction *action, gimp_value_array_unref (args); } -void -plug_in_repeat_cmd_callback (GtkAction *action, - gint value, - gpointer data) -{ - GimpPlugInProcedure *procedure; - Gimp *gimp; - GimpDisplay *display; - GimpRunMode run_mode; - return_if_no_gimp (gimp, data); - return_if_no_display (display, data); - - run_mode = (GimpRunMode) value; - - procedure = gimp_plug_in_manager_history_nth (gimp->plug_in_manager, 0); - - if (procedure) - { - GimpValueArray *args; - gint n_args; - - args = gimp_procedure_get_arguments (GIMP_PROCEDURE (procedure)); - - g_value_set_int (gimp_value_array_index (args, 0), run_mode); - - n_args = plug_in_collect_display_args (action, display, - GIMP_PROCEDURE (procedure)->args, - args, 1); - - plug_in_procedure_execute (procedure, gimp, display, args, n_args); - - gimp_value_array_unref (args); - } -} - -void -plug_in_history_cmd_callback (GtkAction *action, - GimpPlugInProcedure *procedure, - gpointer data) -{ - Gimp *gimp; - GimpDisplay *display; - GimpValueArray *args; - gint n_args; - return_if_no_gimp (gimp, data); - return_if_no_display (display, data); - - args = gimp_procedure_get_arguments (GIMP_PROCEDURE (procedure)); - - g_value_set_int (gimp_value_array_index (args, 0), GIMP_RUN_INTERACTIVE); - - n_args = plug_in_collect_display_args (action, display, - GIMP_PROCEDURE (procedure)->args, - args, 1); - - plug_in_procedure_execute (procedure, gimp, display, args, n_args); - - gimp_value_array_unref (args); -} - void plug_in_reset_all_cmd_callback (GtkAction *action, gpointer data) @@ -289,7 +233,8 @@ plug_in_reset_all_cmd_callback (GtkAction *action, /* private functions */ -static void +/* FIXME history */ +void plug_in_procedure_execute (GimpPlugInProcedure *procedure, Gimp *gimp, GimpDisplay *display, @@ -319,7 +264,7 @@ plug_in_procedure_execute (GimpPlugInProcedure *procedure, if (GIMP_PROCEDURE (procedure)->num_args >= 2 && GIMP_IS_PARAM_SPEC_IMAGE_ID (GIMP_PROCEDURE (procedure)->args[1])) { - gimp_plug_in_manager_history_add (gimp->plug_in_manager, procedure); + gimp_filter_history_add (gimp, procedure); } } } @@ -414,7 +359,8 @@ plug_in_collect_item_args (GtkAction *action, return n_args; } -static gint +/* FIXME history */ +gint plug_in_collect_display_args (GtkAction *action, GimpDisplay *display, GParamSpec **pspecs, diff --git a/app/actions/plug-in-commands.h b/app/actions/plug-in-commands.h index d99a0f8b5c..94bdf83fa4 100644 --- a/app/actions/plug-in-commands.h +++ b/app/actions/plug-in-commands.h @@ -22,15 +22,21 @@ void plug_in_run_cmd_callback (GtkAction *action, GimpPlugInProcedure *proc, gpointer data); -void plug_in_repeat_cmd_callback (GtkAction *action, - gint value, - gpointer data); -void plug_in_history_cmd_callback (GtkAction *action, - GimpPlugInProcedure *proc, - gpointer data); void plug_in_reset_all_cmd_callback (GtkAction *action, gpointer data); +/* FIXME history */ +void plug_in_procedure_execute (GimpPlugInProcedure *procedure, + Gimp *gimp, + GimpDisplay *display, + GimpValueArray *args, + gint n_args); +gint plug_in_collect_display_args (GtkAction *action, + GimpDisplay *display, + GParamSpec **pspecs, + GimpValueArray *args, + gint n_args); + #endif /* __PLUG_IN_COMMANDS_H__ */ diff --git a/app/config/gimpcoreconfig.c b/app/config/gimpcoreconfig.c index 09536d7648..38c8a98c4e 100644 --- a/app/config/gimpcoreconfig.c +++ b/app/config/gimpcoreconfig.c @@ -97,7 +97,7 @@ enum PROP_UNDO_LEVELS, PROP_UNDO_SIZE, PROP_UNDO_PREVIEW_SIZE, - PROP_PLUG_IN_HISTORY_SIZE, + PROP_FILTER_HISTORY_SIZE, PROP_PLUGINRC_PATH, PROP_LAYER_PREVIEWS, PROP_LAYER_PREVIEW_SIZE, @@ -454,9 +454,9 @@ gimp_core_config_class_init (GimpCoreConfigClass *klass) GIMP_VIEW_SIZE_LARGE, GIMP_PARAM_STATIC_STRINGS | GIMP_CONFIG_PARAM_RESTART); - GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_PLUG_IN_HISTORY_SIZE, - "plug-in-history-size", - PLUG_IN_HISTORY_SIZE_BLURB, + GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_FILTER_HISTORY_SIZE, + "plug-in-history-size", /* compat name */ + FILTER_HISTORY_SIZE_BLURB, 0, 256, 10, GIMP_PARAM_STATIC_STRINGS | GIMP_CONFIG_PARAM_RESTART); @@ -749,8 +749,8 @@ gimp_core_config_set_property (GObject *object, gimp_config_sync (g_value_get_object (value), G_OBJECT (core_config->default_grid), 0); break; - case PROP_PLUG_IN_HISTORY_SIZE: - core_config->plug_in_history_size = g_value_get_int (value); + case PROP_FILTER_HISTORY_SIZE: + core_config->filter_history_size = g_value_get_int (value); break; case PROP_UNDO_LEVELS: core_config->levels_of_undo = g_value_get_int (value); @@ -930,8 +930,8 @@ gimp_core_config_get_property (GObject *object, case PROP_DEFAULT_GRID: g_value_set_object (value, core_config->default_grid); break; - case PROP_PLUG_IN_HISTORY_SIZE: - g_value_set_int (value, core_config->plug_in_history_size); + case PROP_FILTER_HISTORY_SIZE: + g_value_set_int (value, core_config->filter_history_size); break; case PROP_UNDO_LEVELS: g_value_set_int (value, core_config->levels_of_undo); diff --git a/app/config/gimpcoreconfig.h b/app/config/gimpcoreconfig.h index e83d02a5f2..c0ae721d3b 100644 --- a/app/config/gimpcoreconfig.h +++ b/app/config/gimpcoreconfig.h @@ -81,7 +81,7 @@ struct _GimpCoreConfig gint levels_of_undo; guint64 undo_size; GimpViewSize undo_preview_size; - gint plug_in_history_size; + gint filter_history_size; gchar *plug_in_rc_path; gboolean layer_previews; GimpViewSize layer_preview_size; diff --git a/app/config/gimprc-blurbs.h b/app/config/gimprc-blurbs.h index 76a4ab5fd2..fd51d9ff16 100644 --- a/app/config/gimprc-blurbs.h +++ b/app/config/gimprc-blurbs.h @@ -270,8 +270,8 @@ _("When enabled, the X server is queried for the mouse's current position " \ "be slower. Conversely, on some X servers enabling this option results " \ "in faster painting.") -#define PLUG_IN_HISTORY_SIZE_BLURB \ -"How many recently used plug-ins to keep on the Filters menu." +#define FILTER_HISTORY_SIZE_BLURB \ +"How many recently used filters and plug-ins to keep on the Filters menu." #define PLUG_IN_PATH_BLURB \ "Sets the plug-in search path." diff --git a/app/core/Makefile.am b/app/core/Makefile.am index d0cea1e9d6..c4ce10f705 100644 --- a/app/core/Makefile.am +++ b/app/core/Makefile.am @@ -37,6 +37,8 @@ libappcore_a_sources = \ gimp-contexts.h \ gimp-edit.c \ gimp-edit.h \ + gimp-filter-history.c \ + gimp-filter-history.h \ gimp-gradients.c \ gimp-gradients.h \ gimp-gui.c \ diff --git a/app/core/gimp-filter-history.c b/app/core/gimp-filter-history.c new file mode 100644 index 0000000000..32924327ef --- /dev/null +++ b/app/core/gimp-filter-history.c @@ -0,0 +1,137 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995-2003 Spencer Kimball and Peter Mattis + * + * gimp-filter-history.c + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "config.h" + +#include + +#include "libgimpbase/gimpbase.h" + +#include "core-types.h" + +#include "config/gimpcoreconfig.h" + +#include "gimp.h" +#include "gimp-filter-history.h" + +#include "plug-in/gimppluginmanager.h" +#include "plug-in/gimppluginprocedure.h" + + +guint +gimp_filter_history_size (Gimp *gimp) +{ + g_return_val_if_fail (GIMP_IS_GIMP (gimp), 0); + + return MAX (1, gimp->config->filter_history_size); +} + +guint +gimp_filter_history_length (Gimp *gimp) +{ + g_return_val_if_fail (GIMP_IS_GIMP (gimp), 0); + + return g_list_length (gimp->filter_history); +} + +GimpPlugInProcedure * +gimp_filter_history_nth (Gimp *gimp, + gint n) +{ + g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); + + return g_list_nth_data (gimp->filter_history, n); +} + +void +gimp_filter_history_add (Gimp *gimp, + GimpPlugInProcedure *procedure) +{ + GList *link; + gint history_size; + + g_return_if_fail (GIMP_IS_GIMP (gimp)); + g_return_if_fail (GIMP_IS_PLUG_IN_PROCEDURE (procedure)); + + /* return early if the procedure is already at the top */ + if (gimp->filter_history && gimp->filter_history->data == procedure) + return; + + history_size = gimp_filter_history_size (gimp); + + link = g_list_find (gimp->filter_history, procedure); + + if (link) + { + gimp->filter_history = g_list_delete_link (gimp->filter_history, link); + gimp->filter_history = g_list_prepend (gimp->filter_history, procedure); + } + else + { + gimp->filter_history = g_list_prepend (gimp->filter_history, + g_object_ref (procedure)); + } + + link = g_list_nth (gimp->filter_history, history_size); + + if (link) + { + gimp->filter_history = g_list_remove_link (gimp->filter_history, link); + g_object_unref (link->data); + g_list_free (link); + } + + gimp_filter_history_changed (gimp); +} + +void +gimp_filter_history_remove (Gimp *gimp, + GimpPlugInProcedure *procedure) +{ + GList *link; + + g_return_if_fail (GIMP_IS_GIMP (gimp)); + g_return_if_fail (GIMP_IS_PLUG_IN_PROCEDURE (procedure)); + + link = g_list_find (gimp->filter_history, procedure); + + if (link) + { + gimp->filter_history = g_list_delete_link (gimp->filter_history, link); + g_object_unref (procedure); + + gimp_filter_history_changed (gimp); + } +} + +void +gimp_filter_history_clear (Gimp *gimp) +{ + g_return_if_fail (GIMP_IS_GIMP (gimp)); + + if (gimp->filter_history) + { + g_list_free_full (gimp->filter_history, (GDestroyNotify) g_object_unref); + gimp->filter_history = NULL; + + gimp_filter_history_changed (gimp); + } +} + + diff --git a/app/core/gimp-filter-history.h b/app/core/gimp-filter-history.h new file mode 100644 index 0000000000..3796d5c0dc --- /dev/null +++ b/app/core/gimp-filter-history.h @@ -0,0 +1,35 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * gimp-filter-history.h + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef __GIMP_FILTER_HISTORY_H__ +#define __GIMP_FILTER_HISTORY_H__ + + +guint gimp_filter_history_size (Gimp *gimp); +guint gimp_filter_history_length (Gimp *gimp); +GimpPlugInProcedure * gimp_filter_history_nth (Gimp *gimp, + gint n); +void gimp_filter_history_add (Gimp *gimp, + GimpPlugInProcedure *procedure); +void gimp_filter_history_remove (Gimp *gimp, + GimpPlugInProcedure *procedure); +void gimp_filter_history_clear (Gimp *gimp); + + +#endif /* __GIMP_FILTER_HISTORY_H__ */ diff --git a/app/core/gimp.c b/app/core/gimp.c index 1fbb40b2bc..3f61060a77 100644 --- a/app/core/gimp.c +++ b/app/core/gimp.c @@ -44,6 +44,7 @@ #include "gimp.h" #include "gimp-contexts.h" +#include "gimp-filter-history.h" #include "gimp-gradients.h" #include "gimp-memsize.h" #include "gimp-modules.h" @@ -93,6 +94,7 @@ enum RESTORE, EXIT, BUFFER_CHANGED, + FILTER_HISTORY_CHANGED, IMAGE_OPENED, LAST_SIGNAL }; @@ -186,6 +188,16 @@ gimp_class_init (GimpClass *klass) gimp_marshal_VOID__VOID, G_TYPE_NONE, 0); + gimp_signals[FILTER_HISTORY_CHANGED] = + g_signal_new ("filter-history-changed", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GimpClass, + filter_history_changed), + NULL, NULL, + gimp_marshal_VOID__VOID, + G_TYPE_NONE, 0); + gimp_signals[IMAGE_OPENED] = g_signal_new ("image-opened", G_TYPE_FROM_CLASS (klass), @@ -348,6 +360,8 @@ gimp_dispose (GObject *object) if (gimp->tool_preset_factory) gimp_data_factory_data_free (gimp->tool_preset_factory); + gimp_filter_history_clear (gimp); + G_OBJECT_CLASS (parent_class)->dispose (object); } @@ -577,6 +591,11 @@ gimp_get_memsize (GimpObject *object, memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->plug_in_manager), gui_size); + memsize += gimp_g_list_get_memsize_foreach (gimp->filter_history, + (GimpMemsizeFunc) + gimp_object_get_memsize, + gui_size); + memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->image_table), 0); memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->item_table), 0); @@ -1436,6 +1455,14 @@ gimp_message_literal (Gimp *gimp, gimp_show_message (gimp, handler, severity, NULL, message); } +void +gimp_filter_history_changed (Gimp *gimp) +{ + g_return_if_fail (GIMP_IS_GIMP (gimp)); + + g_signal_emit (gimp, gimp_signals[FILTER_HISTORY_CHANGED], 0); +} + void gimp_image_opened (Gimp *gimp, GFile *file) diff --git a/app/core/gimp.h b/app/core/gimp.h index b560822cb6..6ae8997982 100644 --- a/app/core/gimp.h +++ b/app/core/gimp.h @@ -76,6 +76,8 @@ struct _Gimp GimpPlugInManager *plug_in_manager; + GList *filter_history; + GimpContainer *images; guint32 next_guide_ID; guint32 next_sample_point_ID; @@ -128,99 +130,103 @@ struct _GimpClass { GimpObjectClass parent_class; - void (* initialize) (Gimp *gimp, - GimpInitStatusFunc status_callback); - void (* restore) (Gimp *gimp, - GimpInitStatusFunc status_callback); - gboolean (* exit) (Gimp *gimp, - gboolean force); + void (* initialize) (Gimp *gimp, + GimpInitStatusFunc status_callback); + void (* restore) (Gimp *gimp, + GimpInitStatusFunc status_callback); + gboolean (* exit) (Gimp *gimp, + gboolean force); - void (* buffer_changed) (Gimp *gimp); + void (* buffer_changed) (Gimp *gimp); + + void (* filter_history_changed) (Gimp *gimp); /* emitted if an image is loaded and opened with a display */ - void (* image_opened) (Gimp *gimp, - GFile *file); + void (* image_opened) (Gimp *gimp, + GFile *file); }; -GType gimp_get_type (void) G_GNUC_CONST; +GType gimp_get_type (void) G_GNUC_CONST; -Gimp * gimp_new (const gchar *name, - const gchar *session_name, - GFile *default_folder, - gboolean be_verbose, - gboolean no_data, - gboolean no_fonts, - gboolean no_interface, - gboolean use_shm, - gboolean use_cpu_accel, - gboolean console_messages, - gboolean show_playground, - GimpStackTraceMode stack_trace_mode, - GimpPDBCompatMode pdb_compat_mode); -void gimp_set_show_gui (Gimp *gimp, - gboolean show_gui); -gboolean gimp_get_show_gui (Gimp *gimp); +Gimp * gimp_new (const gchar *name, + const gchar *session_name, + GFile *default_folder, + gboolean be_verbose, + gboolean no_data, + gboolean no_fonts, + gboolean no_interface, + gboolean use_shm, + gboolean use_cpu_accel, + gboolean console_messages, + gboolean show_playground, + GimpStackTraceMode stack_trace_mode, + GimpPDBCompatMode pdb_compat_mode); +void gimp_set_show_gui (Gimp *gimp, + gboolean show_gui); +gboolean gimp_get_show_gui (Gimp *gimp); -void gimp_load_config (Gimp *gimp, - GFile *alternate_system_gimprc, - GFile *alternate_gimprc); -void gimp_initialize (Gimp *gimp, - GimpInitStatusFunc status_callback); -void gimp_restore (Gimp *gimp, - GimpInitStatusFunc status_callback); -gboolean gimp_is_restored (Gimp *gimp); +void gimp_load_config (Gimp *gimp, + GFile *alternate_system_gimprc, + GFile *alternate_gimprc); +void gimp_initialize (Gimp *gimp, + GimpInitStatusFunc status_callback); +void gimp_restore (Gimp *gimp, + GimpInitStatusFunc status_callback); +gboolean gimp_is_restored (Gimp *gimp); -void gimp_exit (Gimp *gimp, - gboolean force); +void gimp_exit (Gimp *gimp, + gboolean force); -GList * gimp_get_image_iter (Gimp *gimp); -GList * gimp_get_display_iter (Gimp *gimp); -GList * gimp_get_image_windows (Gimp *gimp); -GList * gimp_get_paint_info_iter (Gimp *gimp); -GList * gimp_get_tool_info_iter (Gimp *gimp); +GList * gimp_get_image_iter (Gimp *gimp); +GList * gimp_get_display_iter (Gimp *gimp); +GList * gimp_get_image_windows (Gimp *gimp); +GList * gimp_get_paint_info_iter (Gimp *gimp); +GList * gimp_get_tool_info_iter (Gimp *gimp); -void gimp_set_global_buffer (Gimp *gimp, - GimpBuffer *buffer); +void gimp_set_global_buffer (Gimp *gimp, + GimpBuffer *buffer); -GimpImage * gimp_create_image (Gimp *gimp, - gint width, - gint height, - GimpImageBaseType type, - GimpPrecision precision, - gboolean attach_comment); +GimpImage * gimp_create_image (Gimp *gimp, + gint width, + gint height, + GimpImageBaseType type, + GimpPrecision precision, + gboolean attach_comment); -void gimp_set_default_context (Gimp *gimp, - GimpContext *context); -GimpContext * gimp_get_default_context (Gimp *gimp); +void gimp_set_default_context (Gimp *gimp, + GimpContext *context); +GimpContext * gimp_get_default_context (Gimp *gimp); -void gimp_set_user_context (Gimp *gimp, - GimpContext *context); -GimpContext * gimp_get_user_context (Gimp *gimp); +void gimp_set_user_context (Gimp *gimp, + GimpContext *context); +GimpContext * gimp_get_user_context (Gimp *gimp); -GimpToolInfo * gimp_get_tool_info (Gimp *gimp, - const gchar *tool_name); +GimpToolInfo * gimp_get_tool_info (Gimp *gimp, + const gchar *tool_name); -void gimp_message (Gimp *gimp, - GObject *handler, - GimpMessageSeverity severity, - const gchar *format, - ...) G_GNUC_PRINTF (4, 5); -void gimp_message_valist (Gimp *gimp, - GObject *handler, - GimpMessageSeverity severity, - const gchar *format, - va_list args) G_GNUC_PRINTF (4, 0); -void gimp_message_literal (Gimp *gimp, - GObject *handler, - GimpMessageSeverity severity, - const gchar *message); +void gimp_message (Gimp *gimp, + GObject *handler, + GimpMessageSeverity severity, + const gchar *format, + ...) G_GNUC_PRINTF (4, 5); +void gimp_message_valist (Gimp *gimp, + GObject *handler, + GimpMessageSeverity severity, + const gchar *format, + va_list args) G_GNUC_PRINTF (4, 0); +void gimp_message_literal (Gimp *gimp, + GObject *handler, + GimpMessageSeverity severity, + const gchar *message); -void gimp_image_opened (Gimp *gimp, - GFile *file); +void gimp_filter_history_changed (Gimp *gimp); -GFile * gimp_get_temp_file (Gimp *gimp, - const gchar *extension); +void gimp_image_opened (Gimp *gimp, + GFile *file); + +GFile * gimp_get_temp_file (Gimp *gimp, + const gchar *extension); #endif /* __GIMP_H__ */ diff --git a/app/menus/Makefile.am b/app/menus/Makefile.am index 96b3b498d0..32968bbd8f 100644 --- a/app/menus/Makefile.am +++ b/app/menus/Makefile.am @@ -20,6 +20,8 @@ libappmenus_a_SOURCES = \ dockable-menu.h \ file-menu.c \ file-menu.h \ + filters-menu.c \ + filters-menu.h \ image-menu.c \ image-menu.h \ plug-in-menus.c \ diff --git a/app/menus/filters-menu.c b/app/menus/filters-menu.c new file mode 100644 index 0000000000..8d3f9a6218 --- /dev/null +++ b/app/menus/filters-menu.c @@ -0,0 +1,63 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "config.h" + +#include + +#include "menus-types.h" + +#include "core/gimp.h" +#include "core/gimp-filter-history.h" + +#include "widgets/gimpuimanager.h" + +#include "filters-menu.h" + + +/* public functions */ + +void +filters_menu_setup (GimpUIManager *manager, + const gchar *ui_path) +{ + guint merge_id; + gint i; + + g_return_if_fail (GIMP_IS_UI_MANAGER (manager)); + g_return_if_fail (ui_path != NULL); + + merge_id = gtk_ui_manager_new_merge_id (GTK_UI_MANAGER (manager)); + + for (i = 0; i < gimp_filter_history_size (manager->gimp); i++) + { + gchar *action_name; + gchar *action_path; + + action_name = g_strdup_printf ("filter-recent-%02d", i + 1); + action_path = g_strdup_printf ("%s/Filters/Recently Used/Filters", + ui_path); + + gtk_ui_manager_add_ui (GTK_UI_MANAGER (manager), merge_id, + action_path, action_name, action_name, + GTK_UI_MANAGER_MENUITEM, + FALSE); + + g_free (action_name); + g_free (action_path); + } +} diff --git a/app/menus/filters-menu.h b/app/menus/filters-menu.h new file mode 100644 index 0000000000..7f8f969afb --- /dev/null +++ b/app/menus/filters-menu.h @@ -0,0 +1,26 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef __FILTERS_MENU_H__ +#define __FILTERS_MENU_H__ + + +void filters_menu_setup (GimpUIManager *manager, + const gchar *ui_path); + + +#endif /* __FILTERS_MENU_H__ */ diff --git a/app/menus/image-menu.c b/app/menus/image-menu.c index 0dc49f4657..52b9152e1f 100644 --- a/app/menus/image-menu.c +++ b/app/menus/image-menu.c @@ -24,6 +24,7 @@ #include "menus-types.h" #include "file-menu.h" +#include "filters-menu.h" #include "image-menu.h" #include "plug-in-menus.h" #include "window-menu.h" @@ -42,6 +43,7 @@ image_menu_setup (GimpUIManager *manager, file_menu_setup (manager, ui_path); windows_menu_setup (manager, ui_path); plug_in_menus_setup (manager, ui_path); + filters_menu_setup (manager, ui_path); path = g_strconcat (ui_path, "/View", NULL); window_menu_setup (manager, "view", path); diff --git a/app/menus/plug-in-menus.c b/app/menus/plug-in-menus.c index 322a9b2c80..9bcf41d6c7 100644 --- a/app/menus/plug-in-menus.c +++ b/app/menus/plug-in-menus.c @@ -98,12 +98,12 @@ plug_in_menus_setup (GimpUIManager *manager, merge_id = gtk_ui_manager_new_merge_id (GTK_UI_MANAGER (manager)); - for (i = 0; i < manager->gimp->config->plug_in_history_size; i++) + for (i = 0; i < manager->gimp->config->filter_history_size; i++) { gchar *action_name; gchar *action_path; - action_name = g_strdup_printf ("plug-in-recent-%02d", i + 1); + action_name = g_strdup_printf ("filter-recent-%02d", i + 1); action_path = g_strdup_printf ("%s/Filters/Recently Used/Plug-Ins", ui_path); diff --git a/app/plug-in/Makefile.am b/app/plug-in/Makefile.am index b28fec5dda..b8585f470c 100644 --- a/app/plug-in/Makefile.am +++ b/app/plug-in/Makefile.am @@ -48,8 +48,6 @@ libappplug_in_a_SOURCES = \ gimppluginmanager-file.h \ gimppluginmanager-help-domain.c \ gimppluginmanager-help-domain.h \ - gimppluginmanager-history.c \ - gimppluginmanager-history.h \ gimppluginmanager-locale-domain.c \ gimppluginmanager-locale-domain.h \ gimppluginmanager-menu-branch.c \ diff --git a/app/plug-in/gimppluginmanager-history.c b/app/plug-in/gimppluginmanager-history.c deleted file mode 100644 index edf524a101..0000000000 --- a/app/plug-in/gimppluginmanager-history.c +++ /dev/null @@ -1,125 +0,0 @@ -/* GIMP - The GNU Image Manipulation Program - * Copyright (C) 1995-2003 Spencer Kimball and Peter Mattis - * - * gimppluginmanager-history.c - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "config.h" - -#include - -#include "libgimpbase/gimpbase.h" - -#include "plug-in-types.h" - -#include "config/gimpcoreconfig.h" - -#include "core/gimp.h" - -#include "gimppluginmanager.h" -#include "gimppluginmanager-history.h" -#include "gimppluginprocedure.h" - - -guint -gimp_plug_in_manager_history_size (GimpPlugInManager *manager) -{ - g_return_val_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager), 0); - - return MAX (1, manager->gimp->config->plug_in_history_size); -} - -guint -gimp_plug_in_manager_history_length (GimpPlugInManager *manager) -{ - g_return_val_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager), 0); - - return g_slist_length (manager->history); -} - -GimpPlugInProcedure * -gimp_plug_in_manager_history_nth (GimpPlugInManager *manager, - guint n) -{ - g_return_val_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager), NULL); - - return g_slist_nth_data (manager->history, n); -} - -void -gimp_plug_in_manager_history_add (GimpPlugInManager *manager, - GimpPlugInProcedure *procedure) -{ - GSList *list; - gint history_size; - - g_return_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager)); - g_return_if_fail (GIMP_IS_PLUG_IN_PROCEDURE (procedure)); - - /* return early if the procedure is already at the top */ - if (manager->history && manager->history->data == procedure) - return; - - history_size = gimp_plug_in_manager_history_size (manager); - - manager->history = g_slist_remove (manager->history, procedure); - manager->history = g_slist_prepend (manager->history, procedure); - - list = g_slist_nth (manager->history, history_size); - - if (list) - { - manager->history = g_slist_remove_link (manager->history, list); - g_slist_free (list); - } - - gimp_plug_in_manager_history_changed (manager); -} - -void -gimp_plug_in_manager_history_remove (GimpPlugInManager *manager, - GimpPlugInProcedure *procedure) -{ - GSList *link; - - g_return_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager)); - g_return_if_fail (GIMP_IS_PLUG_IN_PROCEDURE (procedure)); - - link = g_slist_find (manager->history, procedure); - - if (link) - { - manager->history = g_slist_delete_link (manager->history, link); - - gimp_plug_in_manager_history_changed (manager); - } -} - -void -gimp_plug_in_manager_history_clear (GimpPlugInManager *manager) -{ - g_return_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager)); - - if (manager->history) - { - g_slist_free (manager->history); - manager->history = NULL; - - gimp_plug_in_manager_history_changed (manager); - } -} - - diff --git a/app/plug-in/gimppluginmanager-history.h b/app/plug-in/gimppluginmanager-history.h deleted file mode 100644 index 5c3915f53d..0000000000 --- a/app/plug-in/gimppluginmanager-history.h +++ /dev/null @@ -1,35 +0,0 @@ -/* GIMP - The GNU Image Manipulation Program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * gimppluginmanager-history.h - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef __GIMP_PLUG_IN_MANAGER_HISTORY_H__ -#define __GIMP_PLUG_IN_MANAGER_HISTORY_H__ - - -guint gimp_plug_in_manager_history_size (GimpPlugInManager *manager); -guint gimp_plug_in_manager_history_length (GimpPlugInManager *manager); -GimpPlugInProcedure * gimp_plug_in_manager_history_nth (GimpPlugInManager *manager, - guint n); -void gimp_plug_in_manager_history_add (GimpPlugInManager *manager, - GimpPlugInProcedure *procedure); -void gimp_plug_in_manager_history_remove (GimpPlugInManager *manager, - GimpPlugInProcedure *procedure); -void gimp_plug_in_manager_history_clear (GimpPlugInManager *manager); - - -#endif /* __GIMP_PLUG_IN_MANAGER_HISTORY_H__ */ diff --git a/app/plug-in/gimppluginmanager.c b/app/plug-in/gimppluginmanager.c index 7078219de5..d5c7e263b8 100644 --- a/app/plug-in/gimppluginmanager.c +++ b/app/plug-in/gimppluginmanager.c @@ -32,6 +32,7 @@ #include "config/gimpcoreconfig.h" #include "core/gimp.h" +#include "core/gimp-filter-history.h" #include "core/gimp-memsize.h" #include "core/gimpmarshal.h" @@ -45,7 +46,6 @@ #include "gimppluginmanager.h" #include "gimppluginmanager-data.h" #include "gimppluginmanager-help-domain.h" -#include "gimppluginmanager-history.h" #include "gimppluginmanager-locale-domain.h" #include "gimppluginmanager-menu-branch.h" #include "gimppluginshm.h" @@ -59,12 +59,10 @@ enum PLUG_IN_OPENED, PLUG_IN_CLOSED, MENU_BRANCH_ADDED, - HISTORY_CHANGED, LAST_SIGNAL }; -static void gimp_plug_in_manager_dispose (GObject *object); static void gimp_plug_in_manager_finalize (GObject *object); static gint64 gimp_plug_in_manager_get_memsize (GimpObject *object, @@ -119,17 +117,6 @@ gimp_plug_in_manager_class_init (GimpPlugInManagerClass *klass) G_TYPE_STRING, G_TYPE_STRING); - manager_signals[HISTORY_CHANGED] = - g_signal_new ("history-changed", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GimpPlugInManagerClass, - history_changed), - NULL, NULL, - gimp_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - object_class->dispose = gimp_plug_in_manager_dispose; object_class->finalize = gimp_plug_in_manager_finalize; gimp_object_class->get_memsize = gimp_plug_in_manager_get_memsize; @@ -140,16 +127,6 @@ gimp_plug_in_manager_init (GimpPlugInManager *manager) { } -static void -gimp_plug_in_manager_dispose (GObject *object) -{ - GimpPlugInManager *manager = GIMP_PLUG_IN_MANAGER (object); - - gimp_plug_in_manager_history_clear (manager); - - G_OBJECT_CLASS (parent_class)->dispose (object); -} - static void gimp_plug_in_manager_finalize (GObject *object) { @@ -239,7 +216,6 @@ gimp_plug_in_manager_get_memsize (GimpObject *object, gimp_object_get_memsize, gui_size); memsize += gimp_g_slist_get_memsize (manager->plug_in_stack, 0); - memsize += gimp_g_slist_get_memsize (manager->history, 0); memsize += 0; /* FIXME manager->shm */ memsize += gimp_object_get_memsize (GIMP_OBJECT (manager->interpreter_db), @@ -361,7 +337,7 @@ gimp_plug_in_manager_add_procedure (GimpPlugInManager *manager, manager->export_procs = g_slist_remove (manager->export_procs, tmp_proc); /* and from the history */ - gimp_plug_in_manager_history_remove (manager, tmp_proc); + gimp_filter_history_remove (manager->gimp, tmp_proc); g_object_unref (tmp_proc); @@ -396,8 +372,8 @@ gimp_plug_in_manager_remove_temp_proc (GimpPlugInManager *manager, manager->plug_in_procedures = g_slist_remove (manager->plug_in_procedures, procedure); - gimp_plug_in_manager_history_remove (manager, - GIMP_PLUG_IN_PROCEDURE (procedure)); + gimp_filter_history_remove (manager->gimp, + GIMP_PLUG_IN_PROCEDURE (procedure)); gimp_pdb_unregister_procedure (manager->gimp->pdb, GIMP_PROCEDURE (procedure)); @@ -461,11 +437,3 @@ gimp_plug_in_manager_plug_in_pop (GimpPlugInManager *manager) else manager->current_plug_in = NULL; } - -void -gimp_plug_in_manager_history_changed (GimpPlugInManager *manager) -{ - g_return_if_fail (GIMP_IS_PLUG_IN_MANAGER (manager)); - - g_signal_emit (manager, manager_signals[HISTORY_CHANGED], 0); -} diff --git a/app/plug-in/gimppluginmanager.h b/app/plug-in/gimppluginmanager.h index 5f42b86382..83db14e258 100644 --- a/app/plug-in/gimppluginmanager.h +++ b/app/plug-in/gimppluginmanager.h @@ -55,7 +55,6 @@ struct _GimpPlugInManager GimpPlugIn *current_plug_in; GSList *open_plug_ins; GSList *plug_in_stack; - GSList *history; GimpPlugInShm *shm; GimpInterpreterDB *interpreter_db; @@ -77,7 +76,6 @@ struct _GimpPlugInManagerClass GFile *file, const gchar *menu_path, const gchar *menu_label); - void (* history_changed) (GimpPlugInManager *manager); }; @@ -110,7 +108,5 @@ 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_history_changed (GimpPlugInManager *manager); - #endif /* __GIMP_PLUG_IN_MANAGER_H__ */ diff --git a/menus/image-menu.xml.in b/menus/image-menu.xml.in index b04bdfb2ac..9a4e1b10a7 100644 --- a/menus/image-menu.xml.in +++ b/menus/image-menu.xml.in @@ -642,15 +642,15 @@ - - - - - + + + + + - + @@ -660,14 +660,14 @@ - + - + @@ -683,7 +683,7 @@ - + @@ -696,7 +696,7 @@ - + @@ -705,20 +705,20 @@ - + - + - - + + @@ -727,8 +727,8 @@ - - + + @@ -737,18 +737,18 @@ - - - - - + + + + + - + @@ -757,10 +757,10 @@ - + - +