
2004-01-31 Michael Natterer <mitch@gimp.org> Use the global <Image> accel_group in all docks except the toolbox (the latter needs GTK+ 2.4's new menu features). Addresses bug #119878: * app/gui/buffers-commands.c * app/gui/channels-commands.c * app/gui/data-commands.c * app/gui/documents-commands.c * app/gui/drawable-commands.c * app/gui/edit-commands.c * app/gui/file-commands.c * app/gui/gradients-commands.c * app/gui/image-commands.c * app/gui/layers-commands.c * app/gui/plug-in-commands.c * app/gui/select-commands.c * app/gui/tool-options-commands.c * app/gui/tools-commands.c * app/gui/vectors-commands.c * app/gui/view-commands.c: changed the various return_if_no_foo() macros to also accept a GimpDock as user_data. * app/gui/image-menu.c (image_menu_update): don't update the display related menu items if they don't exist (see below). * app/gui/gui.c (gui_display_changed): simplified. * app/widgets/gimpimagedock.[ch]: create an "<Image>" item_factory and attach its accel_group to the dock. Destroy all display related menu items. Destroy the layer stack navigation items because their default shortcuts interfere with tree and grid view keybindings. Connect to "image_changed" of the dock's private context and to "flush" of the image container to update the item_factory's state.
202 lines
6.1 KiB
C
202 lines
6.1 KiB
C
/* The GIMP -- an 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 2 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, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
#include <string.h>
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
#include "gui-types.h"
|
|
|
|
#include "config/gimpconfig.h"
|
|
#include "config/gimpconfig-utils.h"
|
|
|
|
#include "core/gimp.h"
|
|
#include "core/gimplist.h"
|
|
#include "core/gimptoolinfo.h"
|
|
#include "core/gimptooloptions.h"
|
|
|
|
#include "widgets/gimpeditor.h"
|
|
#include "widgets/gimphelp-ids.h"
|
|
#include "widgets/gimpitemfactory.h"
|
|
#include "widgets/gimptooloptionseditor.h"
|
|
|
|
#include "tool-options-commands.h"
|
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
|
/* local function prototypes */
|
|
|
|
static void tool_options_save_callback (GtkWidget *widget,
|
|
const gchar *name,
|
|
gpointer data);
|
|
static void tool_options_rename_callback (GtkWidget *widget,
|
|
const gchar *name,
|
|
gpointer data);
|
|
|
|
|
|
/* public functions */
|
|
|
|
void
|
|
tool_options_save_to_cmd_callback (GtkWidget *widget,
|
|
gpointer data,
|
|
guint action)
|
|
{
|
|
GimpToolOptions *options = GIMP_TOOL_OPTIONS (data);
|
|
gchar *name;
|
|
|
|
name = g_strdup (gimp_object_get_name (GIMP_OBJECT (options)));
|
|
|
|
gimp_config_sync (GIMP_CONFIG (options->tool_info->tool_options),
|
|
GIMP_CONFIG (options), 0);
|
|
gimp_object_set_name (GIMP_OBJECT (options), name);
|
|
|
|
g_free (name);
|
|
}
|
|
|
|
void
|
|
tool_options_save_new_cmd_callback (GtkWidget *widget,
|
|
gpointer data,
|
|
guint action)
|
|
{
|
|
GimpEditor *editor = GIMP_EDITOR (data);
|
|
GimpContext *context;
|
|
GimpToolInfo *tool_info;
|
|
GtkWidget *qbox;
|
|
|
|
context = gimp_get_user_context (editor->item_factory->gimp);
|
|
tool_info = gimp_context_get_tool (context);
|
|
|
|
qbox = gimp_query_string_box (_("Save Tool Options"),
|
|
GTK_WIDGET (editor),
|
|
gimp_standard_help_func,
|
|
GIMP_HELP_TOOL_OPTIONS_DIALOG,
|
|
_("Enter a name for the saved options"),
|
|
_("Saved Options"),
|
|
NULL, NULL,
|
|
tool_options_save_callback, tool_info);
|
|
gtk_widget_show (qbox);
|
|
}
|
|
|
|
void
|
|
tool_options_restore_from_cmd_callback (GtkWidget *widget,
|
|
gpointer data,
|
|
guint action)
|
|
{
|
|
GimpToolOptions *options = GIMP_TOOL_OPTIONS (data);
|
|
|
|
gimp_config_sync (GIMP_CONFIG (options),
|
|
GIMP_CONFIG (options->tool_info->tool_options), 0);
|
|
}
|
|
|
|
void
|
|
tool_options_rename_saved_cmd_callback (GtkWidget *widget,
|
|
gpointer data,
|
|
guint action)
|
|
{
|
|
GimpToolOptions *options = GIMP_TOOL_OPTIONS (data);
|
|
GtkWidget *qbox;
|
|
|
|
qbox = gimp_query_string_box (_("Rename Saved Tool Options"),
|
|
widget,
|
|
gimp_standard_help_func,
|
|
GIMP_HELP_TOOL_OPTIONS_DIALOG,
|
|
_("Enter a new name for the saved options"),
|
|
GIMP_OBJECT (options)->name,
|
|
NULL, NULL,
|
|
tool_options_rename_callback, options);
|
|
gtk_widget_show (qbox);
|
|
}
|
|
|
|
void
|
|
tool_options_delete_saved_cmd_callback (GtkWidget *widget,
|
|
gpointer data,
|
|
guint action)
|
|
{
|
|
GimpToolOptions *options = GIMP_TOOL_OPTIONS (data);
|
|
|
|
gimp_container_remove (options->tool_info->options_presets,
|
|
GIMP_OBJECT (options));
|
|
}
|
|
|
|
void
|
|
tool_options_reset_cmd_callback (GtkWidget *widget,
|
|
gpointer data,
|
|
guint action)
|
|
{
|
|
GimpToolOptionsEditor *editor = GIMP_TOOL_OPTIONS_EDITOR (data);
|
|
|
|
if (GTK_WIDGET_SENSITIVE (editor->reset_button))
|
|
gtk_button_clicked (GTK_BUTTON (editor->reset_button));
|
|
}
|
|
|
|
void
|
|
tool_options_reset_all_cmd_callback (GtkWidget *widget,
|
|
gpointer data,
|
|
guint action)
|
|
{
|
|
GimpToolOptionsEditor *editor = GIMP_TOOL_OPTIONS_EDITOR (data);
|
|
|
|
if (GTK_WIDGET_SENSITIVE (editor->reset_button))
|
|
gimp_button_extended_clicked (GIMP_BUTTON (editor->reset_button),
|
|
GDK_SHIFT_MASK);
|
|
}
|
|
|
|
|
|
/* private functions */
|
|
|
|
static void
|
|
tool_options_save_callback (GtkWidget *widget,
|
|
const gchar *name,
|
|
gpointer data)
|
|
{
|
|
GimpToolInfo *tool_info = GIMP_TOOL_INFO (data);
|
|
GimpConfig *copy;
|
|
|
|
if (! name || ! strlen (name))
|
|
name = _("Saved Options");
|
|
|
|
copy = gimp_config_duplicate (GIMP_CONFIG (tool_info->tool_options));
|
|
|
|
gimp_object_set_name (GIMP_OBJECT (copy), name);
|
|
gimp_list_uniquefy_name (GIMP_LIST (tool_info->options_presets),
|
|
GIMP_OBJECT (copy), TRUE);
|
|
|
|
gimp_container_insert (tool_info->options_presets, GIMP_OBJECT (copy), -1);
|
|
g_object_unref (copy);
|
|
}
|
|
|
|
static void
|
|
tool_options_rename_callback (GtkWidget *widget,
|
|
const gchar *name,
|
|
gpointer data)
|
|
{
|
|
GimpToolOptions *options = GIMP_TOOL_OPTIONS (data);
|
|
|
|
if (! name || ! strlen (name))
|
|
name = _("Saved Options");
|
|
|
|
gimp_object_set_name (GIMP_OBJECT (options), name);
|
|
gimp_list_uniquefy_name (GIMP_LIST (options->tool_info->options_presets),
|
|
GIMP_OBJECT (options), TRUE);
|
|
}
|