diff --git a/ChangeLog b/ChangeLog index 5cdc9854f9..f9a2455663 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2003-09-30 Michael Natterer + + * app/gui/tool-options-menu.[ch] (tool_options_menu_setup): new + function for stuff which needs to be done once, not on every + tool_options_menu_update(). Cleanup. + + * app/gui/menus.c: register it as setup_func of . + + * app/gui/tool-options-commands.c: removed the "Reset" + implementations and activate GimpToolOptionsEditor's buttons + accordingly. + + * app/widgets/gimphelp-ids.h: added GIMP_HELP_TOOL_OPTIONS_DELETE. + + * app/widgets/gimptooloptionseditor.[ch]: moved "Reset" + implementations to this file. Added "Delete" button. Pop up the + "Save", "Restore" and "Delete" submenus of the + item_factory when the resp. buttons are clicked. + 2003-09-29 Michael Natterer * app/core/gimptoolinfo.[ch]: added a GimpContainer of tool diff --git a/app/actions/tool-options-commands.c b/app/actions/tool-options-commands.c index 13f21b1524..7eb979ba8e 100644 --- a/app/actions/tool-options-commands.c +++ b/app/actions/tool-options-commands.c @@ -37,6 +37,7 @@ #include "widgets/gimpeditor.h" #include "widgets/gimphelp-ids.h" #include "widgets/gimpitemfactory.h" +#include "widgets/gimptooloptionseditor.h" #include "tool-options-commands.h" @@ -45,12 +46,9 @@ /* local function prototypes */ -static void tool_options_save_callback (GtkWidget *widget, - const gchar *name, - gpointer data); -static void tool_options_reset_all_callback (GtkWidget *widget, - gboolean reset_all, - gpointer data); +static void tool_options_save_callback (GtkWidget *widget, + const gchar *name, + gpointer data); /* public functions */ @@ -118,16 +116,10 @@ tool_options_reset_cmd_callback (GtkWidget *widget, gpointer data, guint action) { - GimpEditor *editor; - GimpContext *context; - GimpToolInfo *tool_info; + GimpToolOptionsEditor *editor = GIMP_TOOL_OPTIONS_EDITOR (data); - editor = GIMP_EDITOR (data); - - context = gimp_get_user_context (editor->item_factory->gimp); - tool_info = gimp_context_get_tool (context); - - gimp_tool_options_reset (tool_info->tool_options); + if (GTK_WIDGET_SENSITIVE (editor->reset_button)) + gtk_button_clicked (GTK_BUTTON (editor->reset_button)); } void @@ -135,22 +127,11 @@ tool_options_reset_all_cmd_callback (GtkWidget *widget, gpointer data, guint action) { - GimpEditor *editor; - GtkWidget *qbox; + GimpToolOptionsEditor *editor = GIMP_TOOL_OPTIONS_EDITOR (data); - editor = GIMP_EDITOR (data); - - qbox = gimp_query_boolean_box (_("Reset Tool Options"), - gimp_standard_help_func, - GIMP_HELP_TOOL_OPTIONS_RESET, - GTK_STOCK_DIALOG_QUESTION, - _("Do you really want to reset all\n" - "tool options to default values?"), - GIMP_STOCK_RESET, GTK_STOCK_CANCEL, - G_OBJECT (editor), "unmap", - tool_options_reset_all_callback, - editor->item_factory->gimp); - gtk_widget_show (qbox); + if (GTK_WIDGET_SENSITIVE (editor->reset_button)) + gimp_button_extended_clicked (GIMP_BUTTON (editor->reset_button), + GDK_SHIFT_MASK); } @@ -176,25 +157,3 @@ tool_options_save_callback (GtkWidget *widget, gimp_container_insert (tool_info->options_presets, GIMP_OBJECT (copy), -1); g_object_unref (copy); } - -static void -tool_options_reset_all_callback (GtkWidget *widget, - gboolean reset_all, - gpointer data) -{ - Gimp *gimp = GIMP (data); - - if (reset_all) - { - GList *list; - - for (list = GIMP_LIST (gimp->tool_info_list)->list; - list; - list = g_list_next (list)) - { - GimpToolInfo *tool_info = list->data; - - gimp_tool_options_reset (tool_info->tool_options); - } - } -} diff --git a/app/gui/menus.c b/app/gui/menus.c index dc538d4a37..a11a349d19 100644 --- a/app/gui/menus.c +++ b/app/gui/menus.c @@ -259,7 +259,8 @@ menus_init (Gimp *gimp) gimp_menu_factory_menu_register (global_menu_factory, "", _("Tool Options Menu"), GIMP_HELP_TOOL_OPTIONS_DIALOG, - NULL, tool_options_menu_update, TRUE, + tool_options_menu_setup, + tool_options_menu_update, TRUE, n_tool_options_menu_entries, tool_options_menu_entries); } diff --git a/app/gui/tool-options-commands.c b/app/gui/tool-options-commands.c index 13f21b1524..7eb979ba8e 100644 --- a/app/gui/tool-options-commands.c +++ b/app/gui/tool-options-commands.c @@ -37,6 +37,7 @@ #include "widgets/gimpeditor.h" #include "widgets/gimphelp-ids.h" #include "widgets/gimpitemfactory.h" +#include "widgets/gimptooloptionseditor.h" #include "tool-options-commands.h" @@ -45,12 +46,9 @@ /* local function prototypes */ -static void tool_options_save_callback (GtkWidget *widget, - const gchar *name, - gpointer data); -static void tool_options_reset_all_callback (GtkWidget *widget, - gboolean reset_all, - gpointer data); +static void tool_options_save_callback (GtkWidget *widget, + const gchar *name, + gpointer data); /* public functions */ @@ -118,16 +116,10 @@ tool_options_reset_cmd_callback (GtkWidget *widget, gpointer data, guint action) { - GimpEditor *editor; - GimpContext *context; - GimpToolInfo *tool_info; + GimpToolOptionsEditor *editor = GIMP_TOOL_OPTIONS_EDITOR (data); - editor = GIMP_EDITOR (data); - - context = gimp_get_user_context (editor->item_factory->gimp); - tool_info = gimp_context_get_tool (context); - - gimp_tool_options_reset (tool_info->tool_options); + if (GTK_WIDGET_SENSITIVE (editor->reset_button)) + gtk_button_clicked (GTK_BUTTON (editor->reset_button)); } void @@ -135,22 +127,11 @@ tool_options_reset_all_cmd_callback (GtkWidget *widget, gpointer data, guint action) { - GimpEditor *editor; - GtkWidget *qbox; + GimpToolOptionsEditor *editor = GIMP_TOOL_OPTIONS_EDITOR (data); - editor = GIMP_EDITOR (data); - - qbox = gimp_query_boolean_box (_("Reset Tool Options"), - gimp_standard_help_func, - GIMP_HELP_TOOL_OPTIONS_RESET, - GTK_STOCK_DIALOG_QUESTION, - _("Do you really want to reset all\n" - "tool options to default values?"), - GIMP_STOCK_RESET, GTK_STOCK_CANCEL, - G_OBJECT (editor), "unmap", - tool_options_reset_all_callback, - editor->item_factory->gimp); - gtk_widget_show (qbox); + if (GTK_WIDGET_SENSITIVE (editor->reset_button)) + gimp_button_extended_clicked (GIMP_BUTTON (editor->reset_button), + GDK_SHIFT_MASK); } @@ -176,25 +157,3 @@ tool_options_save_callback (GtkWidget *widget, gimp_container_insert (tool_info->options_presets, GIMP_OBJECT (copy), -1); g_object_unref (copy); } - -static void -tool_options_reset_all_callback (GtkWidget *widget, - gboolean reset_all, - gpointer data) -{ - Gimp *gimp = GIMP (data); - - if (reset_all) - { - GList *list; - - for (list = GIMP_LIST (gimp->tool_info_list)->list; - list; - list = g_list_next (list)) - { - GimpToolInfo *tool_info = list->data; - - gimp_tool_options_reset (tool_info->tool_options); - } - } -} diff --git a/app/gui/tool-options-menu.c b/app/gui/tool-options-menu.c index fde4cd9837..bf3c7c947b 100644 --- a/app/gui/tool-options-menu.c +++ b/app/gui/tool-options-menu.c @@ -44,7 +44,7 @@ GimpItemFactoryEntry tool_options_menu_entries[] = tool_options_save_new_cmd_callback, 0, "", GTK_STOCK_NEW }, NULL, - NULL, NULL }, + GIMP_HELP_TOOL_OPTIONS_SAVE, NULL }, { { N_("/Save Options to/new-separator"), "", NULL, 0, "", NULL }, @@ -81,6 +81,15 @@ GimpItemFactoryEntry tool_options_menu_entries[] = gint n_tool_options_menu_entries = G_N_ELEMENTS (tool_options_menu_entries); +void +tool_options_menu_setup (GimpItemFactory *factory) +{ + gimp_item_factory_set_sensitive (GTK_ITEM_FACTORY (factory), + "/Restore Options from/(None)", FALSE); + gimp_item_factory_set_sensitive (GTK_ITEM_FACTORY (factory), + "/Delete Saved Options/(None)", FALSE); +} + void tool_options_menu_update (GtkItemFactory *factory, gpointer data) @@ -97,17 +106,12 @@ tool_options_menu_update (GtkItemFactory *factory, #define SET_VISIBLE(menu,condition) \ gimp_item_factory_set_visible (factory, menu, (condition) != 0) -#define SET_SENSITIVE(menu,condition) \ - gimp_item_factory_set_sensitive (factory, menu, (condition) != 0) SET_VISIBLE ("/Save Options to", tool_info->options_presets); SET_VISIBLE ("/Restore Options from", tool_info->options_presets); SET_VISIBLE ("/Delete Saved Options", tool_info->options_presets); SET_VISIBLE ("/reset-separator", tool_info->options_presets); - SET_SENSITIVE ("/Restore Options from/(None)", FALSE); - SET_SENSITIVE ("/Delete Saved Options/(None)", FALSE); - if (! tool_info->options_presets) return; @@ -116,19 +120,16 @@ tool_options_menu_update (GtkItemFactory *factory, delete_menu = gtk_item_factory_get_widget (factory, "/Delete Saved Options"); list = g_list_nth (GTK_MENU_SHELL (save_menu)->children, 1); - while (g_list_next (list)) - gtk_widget_destroy (list->next->data); + gtk_widget_destroy (g_list_next (list)->data); list = g_list_nth (GTK_MENU_SHELL (restore_menu)->children, 0); - while (g_list_next (list)) - gtk_widget_destroy (list->next->data); + gtk_widget_destroy (g_list_next (list)->data); list = g_list_nth (GTK_MENU_SHELL (delete_menu)->children, 0); - while (g_list_next (list)) - gtk_widget_destroy (list->next->data); + gtk_widget_destroy (g_list_next (list)->data); if (gimp_container_num_children (tool_info->options_presets)) { @@ -146,7 +147,7 @@ tool_options_menu_update (GtkItemFactory *factory, entry.entry.item_type = ""; entry.entry.extra_data = GTK_STOCK_SAVE; entry.quark_string = NULL; - entry.help_id = NULL; + entry.help_id = GIMP_HELP_TOOL_OPTIONS_SAVE; entry.description = NULL; for (list = GIMP_LIST (tool_info->options_presets)->list; @@ -165,6 +166,7 @@ tool_options_menu_update (GtkItemFactory *factory, entry.entry.callback = tool_options_restore_from_cmd_callback; entry.entry.extra_data = GTK_STOCK_REVERT_TO_SAVED; + entry.help_id = GIMP_HELP_TOOL_OPTIONS_RESTORE; for (list = GIMP_LIST (tool_info->options_presets)->list; list; @@ -182,6 +184,7 @@ tool_options_menu_update (GtkItemFactory *factory, entry.entry.callback = tool_options_delete_saved_cmd_callback; entry.entry.extra_data = GTK_STOCK_DELETE; + entry.help_id = GIMP_HELP_TOOL_OPTIONS_DELETE; for (list = GIMP_LIST (tool_info->options_presets)->list; list; @@ -205,5 +208,4 @@ tool_options_menu_update (GtkItemFactory *factory, } #undef SET_VISIBLE -#undef SET_SENSITIVE } diff --git a/app/gui/tool-options-menu.h b/app/gui/tool-options-menu.h index 29e6fd23fe..5dbbd146e9 100644 --- a/app/gui/tool-options-menu.h +++ b/app/gui/tool-options-menu.h @@ -24,8 +24,9 @@ extern GimpItemFactoryEntry tool_options_menu_entries[]; extern gint n_tool_options_menu_entries; -void tool_options_menu_update (GtkItemFactory *factory, - gpointer data); +void tool_options_menu_setup (GimpItemFactory *factory); +void tool_options_menu_update (GtkItemFactory *factory, + gpointer data); #endif /* __TOOL_OPTIONS_MENU_H__ */ diff --git a/app/menus/menus.c b/app/menus/menus.c index dc538d4a37..a11a349d19 100644 --- a/app/menus/menus.c +++ b/app/menus/menus.c @@ -259,7 +259,8 @@ menus_init (Gimp *gimp) gimp_menu_factory_menu_register (global_menu_factory, "", _("Tool Options Menu"), GIMP_HELP_TOOL_OPTIONS_DIALOG, - NULL, tool_options_menu_update, TRUE, + tool_options_menu_setup, + tool_options_menu_update, TRUE, n_tool_options_menu_entries, tool_options_menu_entries); } diff --git a/app/menus/tool-options-menu.c b/app/menus/tool-options-menu.c index fde4cd9837..bf3c7c947b 100644 --- a/app/menus/tool-options-menu.c +++ b/app/menus/tool-options-menu.c @@ -44,7 +44,7 @@ GimpItemFactoryEntry tool_options_menu_entries[] = tool_options_save_new_cmd_callback, 0, "", GTK_STOCK_NEW }, NULL, - NULL, NULL }, + GIMP_HELP_TOOL_OPTIONS_SAVE, NULL }, { { N_("/Save Options to/new-separator"), "", NULL, 0, "", NULL }, @@ -81,6 +81,15 @@ GimpItemFactoryEntry tool_options_menu_entries[] = gint n_tool_options_menu_entries = G_N_ELEMENTS (tool_options_menu_entries); +void +tool_options_menu_setup (GimpItemFactory *factory) +{ + gimp_item_factory_set_sensitive (GTK_ITEM_FACTORY (factory), + "/Restore Options from/(None)", FALSE); + gimp_item_factory_set_sensitive (GTK_ITEM_FACTORY (factory), + "/Delete Saved Options/(None)", FALSE); +} + void tool_options_menu_update (GtkItemFactory *factory, gpointer data) @@ -97,17 +106,12 @@ tool_options_menu_update (GtkItemFactory *factory, #define SET_VISIBLE(menu,condition) \ gimp_item_factory_set_visible (factory, menu, (condition) != 0) -#define SET_SENSITIVE(menu,condition) \ - gimp_item_factory_set_sensitive (factory, menu, (condition) != 0) SET_VISIBLE ("/Save Options to", tool_info->options_presets); SET_VISIBLE ("/Restore Options from", tool_info->options_presets); SET_VISIBLE ("/Delete Saved Options", tool_info->options_presets); SET_VISIBLE ("/reset-separator", tool_info->options_presets); - SET_SENSITIVE ("/Restore Options from/(None)", FALSE); - SET_SENSITIVE ("/Delete Saved Options/(None)", FALSE); - if (! tool_info->options_presets) return; @@ -116,19 +120,16 @@ tool_options_menu_update (GtkItemFactory *factory, delete_menu = gtk_item_factory_get_widget (factory, "/Delete Saved Options"); list = g_list_nth (GTK_MENU_SHELL (save_menu)->children, 1); - while (g_list_next (list)) - gtk_widget_destroy (list->next->data); + gtk_widget_destroy (g_list_next (list)->data); list = g_list_nth (GTK_MENU_SHELL (restore_menu)->children, 0); - while (g_list_next (list)) - gtk_widget_destroy (list->next->data); + gtk_widget_destroy (g_list_next (list)->data); list = g_list_nth (GTK_MENU_SHELL (delete_menu)->children, 0); - while (g_list_next (list)) - gtk_widget_destroy (list->next->data); + gtk_widget_destroy (g_list_next (list)->data); if (gimp_container_num_children (tool_info->options_presets)) { @@ -146,7 +147,7 @@ tool_options_menu_update (GtkItemFactory *factory, entry.entry.item_type = ""; entry.entry.extra_data = GTK_STOCK_SAVE; entry.quark_string = NULL; - entry.help_id = NULL; + entry.help_id = GIMP_HELP_TOOL_OPTIONS_SAVE; entry.description = NULL; for (list = GIMP_LIST (tool_info->options_presets)->list; @@ -165,6 +166,7 @@ tool_options_menu_update (GtkItemFactory *factory, entry.entry.callback = tool_options_restore_from_cmd_callback; entry.entry.extra_data = GTK_STOCK_REVERT_TO_SAVED; + entry.help_id = GIMP_HELP_TOOL_OPTIONS_RESTORE; for (list = GIMP_LIST (tool_info->options_presets)->list; list; @@ -182,6 +184,7 @@ tool_options_menu_update (GtkItemFactory *factory, entry.entry.callback = tool_options_delete_saved_cmd_callback; entry.entry.extra_data = GTK_STOCK_DELETE; + entry.help_id = GIMP_HELP_TOOL_OPTIONS_DELETE; for (list = GIMP_LIST (tool_info->options_presets)->list; list; @@ -205,5 +208,4 @@ tool_options_menu_update (GtkItemFactory *factory, } #undef SET_VISIBLE -#undef SET_SENSITIVE } diff --git a/app/menus/tool-options-menu.h b/app/menus/tool-options-menu.h index 29e6fd23fe..5dbbd146e9 100644 --- a/app/menus/tool-options-menu.h +++ b/app/menus/tool-options-menu.h @@ -24,8 +24,9 @@ extern GimpItemFactoryEntry tool_options_menu_entries[]; extern gint n_tool_options_menu_entries; -void tool_options_menu_update (GtkItemFactory *factory, - gpointer data); +void tool_options_menu_setup (GimpItemFactory *factory); +void tool_options_menu_update (GtkItemFactory *factory, + gpointer data); #endif /* __TOOL_OPTIONS_MENU_H__ */ diff --git a/app/widgets/gimphelp-ids.h b/app/widgets/gimphelp-ids.h index f69edafc01..1c824c036f 100644 --- a/app/widgets/gimphelp-ids.h +++ b/app/widgets/gimphelp-ids.h @@ -327,6 +327,7 @@ #define GIMP_HELP_TOOL_OPTIONS_DIALOG "gimp-tool-options-dialog" #define GIMP_HELP_TOOL_OPTIONS_SAVE "gimp-tool-options-save" #define GIMP_HELP_TOOL_OPTIONS_RESTORE "gimp-tool-options-restore" +#define GIMP_HELP_TOOL_OPTIONS_DELETE "gimp-tool-options-delete" #define GIMP_HELP_TOOL_OPTIONS_RESET "gimp-tool-options-reset" #define GIMP_HELP_ERRORS_DIALOG "gimp-errors-dialog" diff --git a/app/widgets/gimptooloptionseditor.c b/app/widgets/gimptooloptionseditor.c index 8343a10982..3354e1eb3b 100644 --- a/app/widgets/gimptooloptionseditor.c +++ b/app/widgets/gimptooloptionseditor.c @@ -29,13 +29,16 @@ #include "core/gimp.h" #include "core/gimpcontext.h" +#include "core/gimplist.h" #include "core/gimptoolinfo.h" #include "core/gimptooloptions.h" #include "gimpdnd.h" #include "gimphelp-ids.h" +#include "gimpitemfactory.h" #include "gimpmenufactory.h" #include "gimptooloptionseditor.h" +#include "gimpwidgets-utils.h" #include "gimp-intl.h" @@ -49,8 +52,13 @@ static void gimp_tool_options_editor_save_clicked (GtkWidget *w GimpToolOptionsEditor *editor); static void gimp_tool_options_editor_restore_clicked (GtkWidget *widget, GimpToolOptionsEditor *editor); +static void gimp_tool_options_editor_delete_clicked (GtkWidget *widget, + GimpToolOptionsEditor *editor); static void gimp_tool_options_editor_reset_clicked (GtkWidget *widget, GimpToolOptionsEditor *editor); +static void gimp_tool_options_editor_reset_ext_clicked (GtkWidget *widget, + GdkModifierType state, + GimpToolOptionsEditor *editor); static void gimp_tool_options_editor_drop_tool (GtkWidget *widget, GimpViewable *viewable, @@ -108,10 +116,11 @@ static void gimp_tool_options_editor_init (GimpToolOptionsEditor *editor) { GtkWidget *scrolled_win; + gchar *str; editor->save_button = gimp_editor_add_button (GIMP_EDITOR (editor), GTK_STOCK_SAVE, - _("Save current settings as default values"), + _("Save options"), GIMP_HELP_TOOL_OPTIONS_SAVE, G_CALLBACK (gimp_tool_options_editor_save_clicked), NULL, @@ -119,20 +128,32 @@ gimp_tool_options_editor_init (GimpToolOptionsEditor *editor) editor->restore_button = gimp_editor_add_button (GIMP_EDITOR (editor), GTK_STOCK_REVERT_TO_SAVED, - _("Restore saved default values"), + _("Restore saved options"), GIMP_HELP_TOOL_OPTIONS_RESTORE, G_CALLBACK (gimp_tool_options_editor_restore_clicked), NULL, editor); - editor->reset_button = - gimp_editor_add_button (GIMP_EDITOR (editor), GIMP_STOCK_RESET, - _("Reset to factory defaults"), - GIMP_HELP_TOOL_OPTIONS_RESET, - G_CALLBACK (gimp_tool_options_editor_reset_clicked), + editor->delete_button = + gimp_editor_add_button (GIMP_EDITOR (editor), GTK_STOCK_DELETE, + _("Delete saved options"), + GIMP_HELP_TOOL_OPTIONS_DELETE, + G_CALLBACK (gimp_tool_options_editor_delete_clicked), NULL, editor); + str = g_strdup_printf (_("Reset to default values\n" + "%s Reset all Tool Options"), + gimp_get_mod_name_shift ()); + editor->reset_button = + gimp_editor_add_button (GIMP_EDITOR (editor), GIMP_STOCK_RESET, + str, + GIMP_HELP_TOOL_OPTIONS_RESET, + G_CALLBACK (gimp_tool_options_editor_reset_clicked), + G_CALLBACK (gimp_tool_options_editor_reset_ext_clicked), + editor); + g_free (str); + scrolled_win = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win), GTK_POLICY_NEVER, @@ -219,59 +240,117 @@ gimp_tool_options_editor_new (Gimp *gimp, return GTK_WIDGET (editor); } +static void +gimp_tool_options_editor_menu_pos (GtkMenu *menu, + gint *x, + gint *y, + gboolean *push_in, + gpointer func_data) +{ + gimp_button_menu_position (GTK_WIDGET (func_data), menu, GTK_POS_RIGHT, x, y); +} + +static void +gimp_tool_options_editor_menu_popup (GimpToolOptionsEditor *editor, + GtkWidget *button, + const gchar *path) +{ + GtkItemFactory *item_factory; + GtkWidget *menu; + + item_factory = GTK_ITEM_FACTORY (GIMP_EDITOR (editor)->item_factory); + + gimp_item_factory_update (GIMP_EDITOR (editor)->item_factory, + GIMP_EDITOR (editor)->item_factory_data); + + menu = gtk_item_factory_get_widget (item_factory, path); + + if (menu) + gtk_menu_popup (GTK_MENU (menu), NULL, NULL, + gimp_tool_options_editor_menu_pos, button, + 1, GDK_CURRENT_TIME); +} + static void gimp_tool_options_editor_save_clicked (GtkWidget *widget, GimpToolOptionsEditor *editor) { - GimpToolInfo *tool_info; - - tool_info = gimp_context_get_tool (gimp_get_user_context (editor->gimp)); - - if (tool_info) - { - GError *error = NULL; - - if (! gimp_tool_options_serialize (tool_info->tool_options, "user", - &error)) - { - g_message ("EEK: %s\n", error->message); - g_clear_error (&error); - } - } + gimp_tool_options_editor_menu_popup (editor, widget, "/Save Options to"); } static void gimp_tool_options_editor_restore_clicked (GtkWidget *widget, GimpToolOptionsEditor *editor) { - GimpToolInfo *tool_info; + gimp_tool_options_editor_menu_popup (editor, widget, "/Restore Options from"); +} - tool_info = gimp_context_get_tool (gimp_get_user_context (editor->gimp)); - - if (tool_info) - { - /* Need to reset the tool-options since only the changes - * from the default values are written to disk. - */ - g_object_freeze_notify (G_OBJECT (tool_info->tool_options)); - - gimp_tool_options_reset (tool_info->tool_options); - gimp_tool_options_deserialize (tool_info->tool_options, "user", NULL); - - g_object_thaw_notify (G_OBJECT (tool_info->tool_options)); - } +static void +gimp_tool_options_editor_delete_clicked (GtkWidget *widget, + GimpToolOptionsEditor *editor) +{ + gimp_tool_options_editor_menu_popup (editor, widget, "/Delete Saved Options"); } static void gimp_tool_options_editor_reset_clicked (GtkWidget *widget, GimpToolOptionsEditor *editor) { - GimpToolInfo *tool_info; + gimp_tool_options_editor_reset_ext_clicked (widget, 0, editor); +} - tool_info = gimp_context_get_tool (gimp_get_user_context (editor->gimp)); +static void +gimp_tool_options_editor_reset_all_callback (GtkWidget *widget, + gboolean reset_all, + gpointer data) +{ + Gimp *gimp = GIMP (data); - if (tool_info) - gimp_tool_options_reset (tool_info->tool_options); + if (reset_all) + { + GList *list; + + for (list = GIMP_LIST (gimp->tool_info_list)->list; + list; + list = g_list_next (list)) + { + GimpToolInfo *tool_info = list->data; + + gimp_tool_options_reset (tool_info->tool_options); + } + } +} + +static void +gimp_tool_options_editor_reset_ext_clicked (GtkWidget *widget, + GdkModifierType state, + GimpToolOptionsEditor *editor) +{ + if (state & GDK_SHIFT_MASK) + { + GtkWidget *qbox; + + qbox = gimp_query_boolean_box (_("Reset Tool Options"), + gimp_standard_help_func, + GIMP_HELP_TOOL_OPTIONS_RESET, + GTK_STOCK_DIALOG_QUESTION, + _("Do you really want to reset all\n" + "tool options to default values?"), + GIMP_STOCK_RESET, GTK_STOCK_CANCEL, + G_OBJECT (editor), "unmap", + gimp_tool_options_editor_reset_all_callback, + editor->gimp); + gtk_widget_show (qbox); + } + else + { + GimpToolInfo *tool_info; + + tool_info = gimp_context_get_tool (gimp_get_user_context (editor->gimp)); + + if (tool_info) + gimp_tool_options_reset (tool_info->tool_options); + } } static void diff --git a/app/widgets/gimptooloptionseditor.h b/app/widgets/gimptooloptionseditor.h index 2c744b1d9e..69b09fafbd 100644 --- a/app/widgets/gimptooloptionseditor.h +++ b/app/widgets/gimptooloptionseditor.h @@ -46,6 +46,7 @@ struct _GimpToolOptionsEditor GtkWidget *save_button; GtkWidget *restore_button; + GtkWidget *delete_button; GtkWidget *reset_button; GimpToolOptions *visible_tool_options;