mirror of https://github.com/GNOME/gimp.git
new function for stuff which needs to be done once, not on every
2003-09-30 Michael Natterer <mitch@gimp.org> * 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 <ToolOptions>. * 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 <ToolOptions> item_factory when the resp. buttons are clicked.
This commit is contained in:
parent
695fb9822e
commit
dedbe33b8d
19
ChangeLog
19
ChangeLog
|
@ -1,3 +1,22 @@
|
|||
2003-09-30 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* 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 <ToolOptions>.
|
||||
|
||||
* 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 <ToolOptions>
|
||||
item_factory when the resp. buttons are clicked.
|
||||
|
||||
2003-09-29 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/core/gimptoolinfo.[ch]: added a GimpContainer of tool
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -259,7 +259,8 @@ menus_init (Gimp *gimp)
|
|||
gimp_menu_factory_menu_register (global_menu_factory, "<ToolOptions>",
|
||||
_("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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ GimpItemFactoryEntry tool_options_menu_entries[] =
|
|||
tool_options_save_new_cmd_callback, 0,
|
||||
"<StockItem>", GTK_STOCK_NEW },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
GIMP_HELP_TOOL_OPTIONS_SAVE, NULL },
|
||||
{ { N_("/Save Options to/new-separator"), "",
|
||||
NULL, 0,
|
||||
"<Separator>", 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 = "<StockItem>";
|
||||
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
|
||||
}
|
||||
|
|
|
@ -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__ */
|
||||
|
|
|
@ -259,7 +259,8 @@ menus_init (Gimp *gimp)
|
|||
gimp_menu_factory_menu_register (global_menu_factory, "<ToolOptions>",
|
||||
_("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);
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ GimpItemFactoryEntry tool_options_menu_entries[] =
|
|||
tool_options_save_new_cmd_callback, 0,
|
||||
"<StockItem>", GTK_STOCK_NEW },
|
||||
NULL,
|
||||
NULL, NULL },
|
||||
GIMP_HELP_TOOL_OPTIONS_SAVE, NULL },
|
||||
{ { N_("/Save Options to/new-separator"), "",
|
||||
NULL, 0,
|
||||
"<Separator>", 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 = "<StockItem>";
|
||||
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
|
||||
}
|
||||
|
|
|
@ -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__ */
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -46,6 +46,7 @@ struct _GimpToolOptionsEditor
|
|||
|
||||
GtkWidget *save_button;
|
||||
GtkWidget *restore_button;
|
||||
GtkWidget *delete_button;
|
||||
GtkWidget *reset_button;
|
||||
|
||||
GimpToolOptions *visible_tool_options;
|
||||
|
|
Loading…
Reference in New Issue