added "name" attributes to all submenus.

2004-05-13  Michael Natterer  <mitch@gimp.org>

	* menus/tool-options-menu.xml: added "name" attributes to all
	submenus.

	* app/menus/tool-options-menu.c: use the menu names instead of the
	overly long action names.

	* app/actions/colormap-editor-commands.c
	* app/actions/tool-options-commands.c: added some callback
	implementations.

	* app/widgets/gimpcolormapeditor.c
	* app/widgets/gimptooloptionseditor.c: removed the callbacks here
	and use action buttons.

	* app/actions/actions.c
	* app/actions/colormap-editor-actions.c
	* app/actions/edit-actions.c: code review / cleanup.
This commit is contained in:
Michael Natterer 2004-05-13 15:50:55 +00:00 committed by Michael Natterer
parent b5ebbaaf36
commit b8739d5901
12 changed files with 296 additions and 277 deletions

View File

@ -1,3 +1,23 @@
2004-05-13 Michael Natterer <mitch@gimp.org>
* menus/tool-options-menu.xml: added "name" attributes to all
submenus.
* app/menus/tool-options-menu.c: use the menu names instead of the
overly long action names.
* app/actions/colormap-editor-commands.c
* app/actions/tool-options-commands.c: added some callback
implementations.
* app/widgets/gimpcolormapeditor.c
* app/widgets/gimptooloptionseditor.c: removed the callbacks here
and use action buttons.
* app/actions/actions.c
* app/actions/colormap-editor-actions.c
* app/actions/edit-actions.c: code review / cleanup.
2004-05-13 Michael Natterer <mitch@gimp.org>
* app/core/gimpcontainer.c (gimp_container_add_handler): don't

View File

@ -311,4 +311,3 @@ action_data_get_widget (gpointer data)
return NULL;
}

View File

@ -27,9 +27,9 @@
#include "core/gimpimage.h"
#include "widgets/gimpactiongroup.h"
#include "widgets/gimpcolormapeditor.h"
#include "widgets/gimphelp-ids.h"
#include "actions.h"
#include "colormap-editor-actions.h"
#include "colormap-editor-commands.h"
@ -79,13 +79,11 @@ void
colormap_editor_actions_update (GimpActionGroup *group,
gpointer data)
{
GimpColormapEditor *editor;
GimpImage *gimage;
gboolean indexed = FALSE;
gint num_colors = 0;
GimpImage *gimage;
gboolean indexed = FALSE;
gint num_colors = 0;
editor = GIMP_COLORMAP_EDITOR (data);
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
gimage = action_data_get_image (data);
if (gimage)
{

View File

@ -24,8 +24,13 @@
#include "actions-types.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimpimage-colormap.h"
#include "widgets/gimpcolormapeditor.h"
#include "actions.h"
#include "colormap-editor-commands.h"
@ -46,9 +51,21 @@ colormap_editor_add_color_cmd_callback (GtkAction *action,
gint value,
gpointer data)
{
GimpColormapEditor *editor = GIMP_COLORMAP_EDITOR (data);
GimpContext *context;
GimpImage *gimage;
return_if_no_context (context, data);
return_if_no_image (gimage, data);
if (GTK_WIDGET_SENSITIVE (editor->add_button))
gimp_button_extended_clicked (GIMP_BUTTON (editor->add_button),
value ? GDK_CONTROL_MASK : 0);
if (gimage->num_cols < 256)
{
GimpRGB color;
if (value)
gimp_context_get_background (context, &color);
else
gimp_context_get_foreground (context, &color);
gimp_image_add_colormap_entry (gimage, &color);
gimp_image_flush (gimage);
}
}

View File

@ -27,9 +27,9 @@
#include "core/gimpimage.h"
#include "widgets/gimpactiongroup.h"
#include "widgets/gimpcolormapeditor.h"
#include "widgets/gimphelp-ids.h"
#include "actions.h"
#include "colormap-editor-actions.h"
#include "colormap-editor-commands.h"
@ -79,13 +79,11 @@ void
colormap_editor_actions_update (GimpActionGroup *group,
gpointer data)
{
GimpColormapEditor *editor;
GimpImage *gimage;
gboolean indexed = FALSE;
gint num_colors = 0;
GimpImage *gimage;
gboolean indexed = FALSE;
gint num_colors = 0;
editor = GIMP_COLORMAP_EDITOR (data);
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
gimage = action_data_get_image (data);
if (gimage)
{

View File

@ -24,8 +24,13 @@
#include "actions-types.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimpimage-colormap.h"
#include "widgets/gimpcolormapeditor.h"
#include "actions.h"
#include "colormap-editor-commands.h"
@ -46,9 +51,21 @@ colormap_editor_add_color_cmd_callback (GtkAction *action,
gint value,
gpointer data)
{
GimpColormapEditor *editor = GIMP_COLORMAP_EDITOR (data);
GimpContext *context;
GimpImage *gimage;
return_if_no_context (context, data);
return_if_no_image (gimage, data);
if (GTK_WIDGET_SENSITIVE (editor->add_button))
gimp_button_extended_clicked (GIMP_BUTTON (editor->add_button),
value ? GDK_CONTROL_MASK : 0);
if (gimage->num_cols < 256)
{
GimpRGB color;
if (value)
gimp_context_get_background (context, &color);
else
gimp_context_get_foreground (context, &color);
gimp_image_add_colormap_entry (gimage, &color);
gimp_image_flush (gimage);
}
}

View File

@ -151,6 +151,7 @@ edit_actions_setup (GimpActionGroup *group)
{
GimpContext *user_context;
GimpRGB color;
GimpPattern *pattern;
gimp_action_group_add_actions (group,
edit_actions,
@ -183,6 +184,9 @@ edit_actions_setup (GimpActionGroup *group)
gimp_context_get_background (user_context, &color);
edit_actions_background_changed (user_context, &color, group);
pattern = gimp_context_get_pattern (user_context);
edit_actions_pattern_changed (user_context, pattern, group);
}
void
@ -190,16 +194,37 @@ edit_actions_update (GimpActionGroup *group,
gpointer data)
{
GimpImage *gimage;
GimpDrawable *drawable = NULL;
gboolean sel = FALSE;
GimpDrawable *drawable = NULL;
gchar *undo_name = NULL;
gchar *redo_name = NULL;
gboolean undo_enabled = FALSE;
gimage = action_data_get_image (data);
if (gimage)
{
sel = ! gimp_channel_is_empty (gimp_image_get_mask (gimage));
GimpUndo *undo;
GimpUndo *redo;
drawable = gimp_image_active_drawable (gimage);
undo_enabled = gimp_image_undo_is_enabled (gimage);
if (undo_enabled)
{
undo = gimp_undo_stack_peek (gimage->undo_stack);
redo = gimp_undo_stack_peek (gimage->redo_stack);
if (undo)
undo_name =
g_strdup_printf (_("_Undo %s"),
gimp_object_get_name (GIMP_OBJECT (undo)));
if (redo)
redo_name =
g_strdup_printf (_("_Redo %s"),
gimp_object_get_name (GIMP_OBJECT (redo)));
}
}
#define SET_LABEL(action,label) \
@ -207,42 +232,15 @@ edit_actions_update (GimpActionGroup *group,
#define SET_SENSITIVE(action,condition) \
gimp_action_group_set_action_sensitive (group, action, (condition) != 0)
{
gchar *undo_name = NULL;
gchar *redo_name = NULL;
gboolean enabled = FALSE;
SET_LABEL ("edit-undo", undo_name ? undo_name : _("_Undo"));
SET_LABEL ("edit-redo", redo_name ? redo_name : _("_Redo"));
if (gimage && gimp_image_undo_is_enabled (gimage))
{
GimpUndo *undo;
GimpUndo *redo;
SET_SENSITIVE ("edit-undo", undo_enabled && undo_name);
SET_SENSITIVE ("edit-redo", undo_enabled && redo_name);
SET_SENSITIVE ("edit-undo-clear", undo_enabled && (redo_name || redo_name));
undo = gimp_undo_stack_peek (gimage->undo_stack);
redo = gimp_undo_stack_peek (gimage->redo_stack);
enabled = TRUE;
if (undo)
undo_name =
g_strdup_printf (_("_Undo %s"),
gimp_object_get_name (GIMP_OBJECT (undo)));
if (redo)
redo_name =
g_strdup_printf (_("_Redo %s"),
gimp_object_get_name (GIMP_OBJECT (redo)));
}
SET_LABEL ("edit-undo", undo_name ? undo_name : _("_Undo"));
SET_LABEL ("edit-redo", redo_name ? redo_name : _("_Redo"));
SET_SENSITIVE ("edit-undo", enabled && undo_name);
SET_SENSITIVE ("edit-redo", enabled && redo_name);
SET_SENSITIVE ("edit-undo-clear", enabled && (redo_name || redo_name));
g_free (undo_name);
g_free (redo_name);
}
g_free (undo_name);
g_free (redo_name);
SET_SENSITIVE ("edit-cut", drawable);
SET_SENSITIVE ("edit-copy", drawable);

View File

@ -174,21 +174,54 @@ void
tool_options_reset_cmd_callback (GtkAction *action,
gpointer data)
{
GimpToolOptionsEditor *editor = GIMP_TOOL_OPTIONS_EDITOR (data);
GimpEditor *editor = GIMP_EDITOR (data);
GimpContext *context = gimp_get_user_context (editor->ui_manager->gimp);
GimpToolInfo *tool_info = gimp_context_get_tool (context);
if (GTK_WIDGET_SENSITIVE (editor->reset_button))
gtk_button_clicked (GTK_BUTTON (editor->reset_button));
gimp_tool_options_reset (tool_info->tool_options);
}
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);
}
}
}
void
tool_options_reset_all_cmd_callback (GtkAction *action,
gpointer data)
{
GimpToolOptionsEditor *editor = GIMP_TOOL_OPTIONS_EDITOR (data);
GimpEditor *editor = GIMP_EDITOR (data);
GtkWidget *qbox;
if (GTK_WIDGET_SENSITIVE (editor->reset_button))
gimp_button_extended_clicked (GIMP_BUTTON (editor->reset_button),
GDK_SHIFT_MASK);
qbox = gimp_query_boolean_box (_("Reset Tool Options"),
GTK_WIDGET (editor),
gimp_standard_help_func,
GIMP_HELP_TOOL_OPTIONS_RESET,
GTK_STOCK_DIALOG_QUESTION,
_("Do you really want to reset all "
"tool options to default values?"),
GIMP_STOCK_RESET, GTK_STOCK_CANCEL,
G_OBJECT (editor), "unmap",
tool_options_reset_all_callback,
editor->ui_manager->gimp);
gtk_widget_show (qbox);
}

View File

@ -47,7 +47,7 @@ static void tool_options_menu_update_presets (GimpUIManager *manager,
guint merge_id,
const gchar *ui_path,
const gchar *menu_path,
const gchar *action_prefix,
const gchar *which_action,
GimpContainer *presets);
@ -110,23 +110,19 @@ tool_options_menu_update_after (GimpUIManager *manager,
GUINT_TO_POINTER (merge_id));
tool_options_menu_update_presets (manager, merge_id, ui_path,
"tool-options-save-menu",
"tool-options-save-",
"Save", "save",
tool_info->options_presets);
tool_options_menu_update_presets (manager, merge_id, ui_path,
"tool-options-restore-menu",
"tool-options-restore-",
"Restore", "restore",
tool_info->options_presets);
tool_options_menu_update_presets (manager, merge_id, ui_path,
"tool-options-rename-menu",
"tool-options-rename-",
"Rename", "rename",
tool_info->options_presets);
tool_options_menu_update_presets (manager, merge_id, ui_path,
"tool-options-delete-menu",
"tool-options-delete-",
"Delete", "delete",
tool_info->options_presets);
gtk_ui_manager_ensure_update (GTK_UI_MANAGER (manager));
@ -137,11 +133,11 @@ tool_options_menu_update_presets (GimpUIManager *manager,
guint merge_id,
const gchar *ui_path,
const gchar *menu_path,
const gchar *action_prefix,
const gchar *which_action,
GimpContainer *presets)
{
gint n_children;
gint i;
gint n_children;
gint i;
n_children = gimp_container_num_children (presets);
@ -150,8 +146,8 @@ tool_options_menu_update_presets (GimpUIManager *manager,
gchar *action_name;
gchar *path;
action_name = g_strdup_printf ("tool-options-%s-%03d", which_action, i);
path = g_strdup_printf ("%s/%s", ui_path, menu_path);
action_name = g_strdup_printf ("%s%03d", action_prefix, i);
gtk_ui_manager_add_ui (GTK_UI_MANAGER (manager), merge_id,
path, action_name, action_name,

View File

@ -88,6 +88,10 @@ enum
static void gimp_colormap_editor_class_init (GimpColormapEditorClass *klass);
static void gimp_colormap_editor_init (GimpColormapEditor *colormap_editor);
static GObject * gimp_colormap_editor_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static void gimp_colormap_editor_destroy (GtkObject *object);
static void gimp_colormap_editor_unmap (GtkWidget *widget);
@ -127,11 +131,6 @@ static gboolean gimp_colormap_hex_entry_focus_out (GtkEntry *entry,
static void gimp_colormap_edit_clicked (GtkWidget *widget,
GimpColormapEditor *editor);
static void gimp_colormap_add_clicked (GtkWidget *widget,
GimpColormapEditor *editor);
static void gimp_colormap_add_ext_clicked (GtkWidget *widget,
GdkModifierType state,
GimpColormapEditor *editor);
static void gimp_colormap_image_mode_changed (GimpImage *gimage,
GimpColormapEditor *editor);
@ -148,41 +147,38 @@ static GimpImageEditorClass *parent_class = NULL;
GType
gimp_colormap_editor_get_type (void)
{
static GType gcd_type = 0;
static GType type = 0;
if (! gcd_type)
if (! type)
{
static const GTypeInfo gcd_info =
static const GTypeInfo info =
{
sizeof (GimpColormapEditorClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_colormap_editor_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpColormapEditor),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_colormap_editor_init,
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_colormap_editor_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpColormapEditor),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_colormap_editor_init,
};
gcd_type = g_type_register_static (GIMP_TYPE_IMAGE_EDITOR,
"GimpColormapEditor",
&gcd_info, 0);
type = g_type_register_static (GIMP_TYPE_IMAGE_EDITOR,
"GimpColormapEditor",
&info, 0);
}
return gcd_type;
return type;
}
static void
gimp_colormap_editor_class_init (GimpColormapEditorClass* klass)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GimpImageEditorClass *image_editor_class;
object_class = GTK_OBJECT_CLASS (klass);
widget_class = GTK_WIDGET_CLASS (klass);
image_editor_class = GIMP_IMAGE_EDITOR_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GimpImageEditorClass *image_editor_class = GIMP_IMAGE_EDITOR_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
@ -196,7 +192,9 @@ gimp_colormap_editor_class_init (GimpColormapEditorClass* klass)
G_TYPE_NONE, 1,
GDK_TYPE_MODIFIER_TYPE);
object_class->destroy = gimp_colormap_editor_destroy;
object_class->constructor = gimp_colormap_editor_constructor;
gtk_object_class->destroy = gimp_colormap_editor_destroy;
widget_class->unmap = gimp_colormap_editor_unmap;
@ -208,8 +206,6 @@ gimp_colormap_editor_class_init (GimpColormapEditorClass* klass)
static void
gimp_colormap_editor_init (GimpColormapEditor *editor)
{
gchar *str;
editor->col_index = 0;
editor->dnd_col_index = 0;
editor->palette = NULL;
@ -220,6 +216,20 @@ gimp_colormap_editor_init (GimpColormapEditor *editor)
editor->index_spinbutton = NULL;
editor->color_entry = NULL;
editor->color_notebook = NULL;
}
static GObject *
gimp_colormap_editor_constructor (GType type,
guint n_params,
GObjectConstructParam *params)
{
GObject *object;
GimpColormapEditor *editor;
gchar *str;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
editor = GIMP_COLORMAP_EDITOR (object);
editor->edit_button =
gimp_editor_add_button (GIMP_EDITOR (editor),
@ -232,13 +242,16 @@ gimp_colormap_editor_init (GimpColormapEditor *editor)
str = g_strdup_printf (_("Add Color from FG\n%s from BG"),
gimp_get_mod_name_control ());
editor->add_button =
gimp_editor_add_button (GIMP_EDITOR (editor),
GTK_STOCK_ADD, str,
GIMP_HELP_INDEXED_PALETTE_ADD,
G_CALLBACK (gimp_colormap_add_clicked),
G_CALLBACK (gimp_colormap_add_ext_clicked),
editor);
gimp_editor_add_action_button (GIMP_EDITOR (editor), "colormap-editor",
"colormap-editor-add-color-from-fg",
"colormap-editor-add-color-from-bg",
GDK_CONTROL_MASK,
NULL);
gimp_help_set_help_data (editor->add_button, str,
GIMP_HELP_INDEXED_PALETTE_ADD);
g_free (str);
return object;
}
static void
@ -929,36 +942,6 @@ gimp_colormap_edit_clicked (GtkWidget *widget,
}
}
static void
gimp_colormap_add_clicked (GtkWidget *widget,
GimpColormapEditor *editor)
{
gimp_colormap_add_ext_clicked (widget, 0, editor);
}
static void
gimp_colormap_add_ext_clicked (GtkWidget *widget,
GdkModifierType state,
GimpColormapEditor *editor)
{
GimpImage *gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
if (gimage && gimage->num_cols < 256)
{
GimpContext *context;
GimpRGB color;
context = gimp_get_user_context (gimage->gimp);
if (state & GDK_CONTROL_MASK)
gimp_context_get_background (context, &color);
else
gimp_context_get_foreground (context, &color);
gimp_image_add_colormap_entry (gimage, &color);
}
}
static void
gimp_colormap_image_mode_changed (GimpImage *gimage,
GimpColormapEditor *editor)

View File

@ -51,6 +51,10 @@ static void gimp_tool_options_editor_class_init (GimpToolOptionsEditorC
static void gimp_tool_options_editor_init (GimpToolOptionsEditor *editor);
static void gimp_tool_options_editor_docked_iface_init (GimpDockedInterface *docked_iface);
static GObject * gimp_tool_options_editor_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static void gimp_tool_options_editor_destroy (GtkObject *object);
static GtkWidget *gimp_tool_options_editor_get_preview (GimpDocked *docked,
@ -64,12 +68,6 @@ static void gimp_tool_options_editor_restore_clicked (GtkWidget *w
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,
gpointer data);
@ -126,18 +124,62 @@ gimp_tool_options_editor_get_type (void)
static void
gimp_tool_options_editor_class_init (GimpToolOptionsEditorClass *klass)
{
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->destroy = gimp_tool_options_editor_destroy;
object_class->constructor = gimp_tool_options_editor_constructor;
gtk_object_class->destroy = gimp_tool_options_editor_destroy;
}
static void
gimp_tool_options_editor_init (GimpToolOptionsEditor *editor)
{
GtkWidget *scrolled_win;
gchar *str;
GtkWidget *sw;
gtk_widget_set_size_request (GTK_WIDGET (editor), -1, 200);
gimp_dnd_viewable_dest_add (GTK_WIDGET (editor),
GIMP_TYPE_TOOL_INFO,
gimp_tool_options_editor_drop_tool,
editor);
editor->scrolled_window = sw = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_container_add (GTK_CONTAINER (editor), sw);
gtk_widget_show (sw);
/* The vbox containing the tool options */
editor->options_vbox = gtk_vbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (editor->options_vbox), 2);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw),
editor->options_vbox);
gtk_widget_show (editor->options_vbox);
}
static void
gimp_tool_options_editor_docked_iface_init (GimpDockedInterface *docked_iface)
{
docked_iface->get_preview = gimp_tool_options_editor_get_preview;
docked_iface->get_title = gimp_tool_options_editor_get_title;
}
static GObject *
gimp_tool_options_editor_constructor (GType type,
guint n_params,
GObjectConstructParam *params)
{
GObject *object;
GimpToolOptionsEditor *editor;
gchar *str;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
editor = GIMP_TOOL_OPTIONS_EDITOR (object);
editor->save_button =
gimp_editor_add_button (GIMP_EDITOR (editor), GTK_STOCK_SAVE,
@ -167,40 +209,16 @@ gimp_tool_options_editor_init (GimpToolOptionsEditor *editor)
"%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);
gimp_editor_add_action_button (GIMP_EDITOR (editor), "tool-options",
"tool-options-reset",
"tool-options-reset-all",
GDK_SHIFT_MASK,
NULL);
gimp_help_set_help_data (editor->reset_button, str,
GIMP_HELP_TOOL_OPTIONS_RESET);
g_free (str);
editor->scrolled_window = scrolled_win = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_container_add (GTK_CONTAINER (editor), scrolled_win);
gtk_widget_show (scrolled_win);
/* The vbox containing the tool options */
editor->options_vbox = gtk_vbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (editor->options_vbox), 2);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_win),
editor->options_vbox);
gtk_widget_show (editor->options_vbox);
/* dnd stuff */
gimp_dnd_viewable_dest_add (GTK_WIDGET (editor),
GIMP_TYPE_TOOL_INFO,
gimp_tool_options_editor_drop_tool,
editor);
}
static void
gimp_tool_options_editor_docked_iface_init (GimpDockedInterface *docked_iface)
{
docked_iface->get_preview = gimp_tool_options_editor_get_preview;
docked_iface->get_title = gimp_tool_options_editor_get_title;
return object;
}
static void
@ -266,6 +284,9 @@ gimp_tool_options_editor_get_title (GimpDocked *docked)
return g_strdup_printf (_("%s Options"), tool_info->blurb);
}
/* public functions */
GtkWidget *
gimp_tool_options_editor_new (Gimp *gimp,
GimpMenuFactory *menu_factory)
@ -276,17 +297,15 @@ gimp_tool_options_editor_new (Gimp *gimp,
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (GIMP_IS_MENU_FACTORY (menu_factory), NULL);
user_context = gimp_get_user_context (gimp);
editor = g_object_new (GIMP_TYPE_TOOL_OPTIONS_EDITOR, NULL);
editor = g_object_new (GIMP_TYPE_TOOL_OPTIONS_EDITOR,
"menu-factory", menu_factory,
"menu-identifier", "<ToolOptions>",
"ui-path", "/tool-options-popup",
NULL);
editor->gimp = gimp;
gtk_widget_set_size_request (GTK_WIDGET (editor), -1, 200);
gimp_editor_create_menu (GIMP_EDITOR (editor), menu_factory,
"<ToolOptions>", "/tool-options-popup",
editor);
user_context = gimp_get_user_context (gimp);
g_signal_connect_object (user_context, "tool_changed",
G_CALLBACK (gimp_tool_options_editor_tool_changed),
@ -300,6 +319,9 @@ gimp_tool_options_editor_new (Gimp *gimp,
return GTK_WIDGET (editor);
}
/* private functions */
static void
gimp_tool_options_editor_menu_pos (GtkMenu *menu,
gint *x,
@ -341,23 +363,25 @@ gimp_tool_options_editor_save_clicked (GtkWidget *widget,
if (GTK_WIDGET_SENSITIVE (editor->restore_button) /* evil but correct */)
{
gimp_tool_options_editor_menu_popup (editor, widget,
"/tool-options-popup"
"/tool-options-save-menu");
"/tool-options-popup/Save");
}
else
{
#if 0
GtkItemFactory *item_factory;
GtkWidget *item;
GimpActionGroup *group;
item_factory = GTK_ITEM_FACTORY (GIMP_EDITOR (editor)->item_factory);
group = gimp_ui_manager_get_action_group (GIMP_EDITOR (editor)->ui_manager,
"tool-options");
item = gtk_item_factory_get_widget (item_factory,
"/Save Options to/New Entry...");
if (group)
{
GtkAction *action;
if (item)
gtk_widget_activate (item);
#endif
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group),
"tool-options-save-new");
if (action)
gtk_action_activate (action);
}
}
}
@ -366,8 +390,7 @@ gimp_tool_options_editor_restore_clicked (GtkWidget *widget,
GimpToolOptionsEditor *editor)
{
gimp_tool_options_editor_menu_popup (editor, widget,
"/tool-options-popup"
"/tool-options-restore-menu");
"/tool-options-popup/Restore");
}
static void
@ -375,70 +398,7 @@ gimp_tool_options_editor_delete_clicked (GtkWidget *widget,
GimpToolOptionsEditor *editor)
{
gimp_tool_options_editor_menu_popup (editor, widget,
"/tool-options-popup"
"/tool-options-delete-menu");
}
static void
gimp_tool_options_editor_reset_clicked (GtkWidget *widget,
GimpToolOptionsEditor *editor)
{
gimp_tool_options_editor_reset_ext_clicked (widget, 0, editor);
}
static void
gimp_tool_options_editor_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);
}
}
}
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"),
GTK_WIDGET (editor),
gimp_standard_help_func,
GIMP_HELP_TOOL_OPTIONS_RESET,
GTK_STOCK_DIALOG_QUESTION,
_("Do you really want to reset all "
"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);
}
"/tool-options-popup/Delete");
}
static void

View File

@ -3,13 +3,13 @@
<ui>
<popup action="tool-options-popup">
<menu action="tool-options-save-menu">
<menu action="tool-options-save-menu" name="Save">
<menuitem action="tool-options-save-new" />
<separator />
</menu>
<menu action="tool-options-restore-menu" />
<menu action="tool-options-rename-menu" />
<menu action="tool-options-delete-menu" />
<menu action="tool-options-restore-menu" name="Restore" />
<menu action="tool-options-rename-menu" name="Rename" />
<menu action="tool-options-delete-menu" name="Delete" />
<separator />
<menuitem action="tool-options-reset" />
<menuitem action="tool-options-reset-all" />