2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2001-01-22 13:08:44 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2003-09-30 04:26:09 +08:00
|
|
|
* gimptooloptionseditor.c
|
|
|
|
* Copyright (C) 2003 Michael Natterer <mitch@gimp.org>
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2001-01-22 13:08:44 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2001-01-22 13:08:44 +08:00
|
|
|
* (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
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2001-01-22 13:08:44 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2001-01-22 13:08:44 +08:00
|
|
|
|
2003-09-30 04:26:09 +08:00
|
|
|
#include "widgets-types.h"
|
2001-01-22 13:08:44 +08:00
|
|
|
|
2001-07-07 20:17:23 +08:00
|
|
|
#include "core/gimp.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpcontext.h"
|
2003-09-30 06:23:44 +08:00
|
|
|
#include "core/gimplist.h"
|
2001-05-10 06:34:59 +08:00
|
|
|
#include "core/gimptoolinfo.h"
|
2003-06-30 04:40:45 +08:00
|
|
|
#include "core/gimptooloptions.h"
|
2006-12-11 23:16:13 +08:00
|
|
|
#include "core/gimptoolpresets.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
|
2003-09-30 04:26:09 +08:00
|
|
|
#include "gimpdnd.h"
|
2003-10-11 05:24:12 +08:00
|
|
|
#include "gimpdocked.h"
|
2003-09-30 04:26:09 +08:00
|
|
|
#include "gimphelp-ids.h"
|
|
|
|
#include "gimpmenufactory.h"
|
2005-02-05 04:47:42 +08:00
|
|
|
#include "gimppropwidgets.h"
|
2004-08-25 01:16:46 +08:00
|
|
|
#include "gimpview.h"
|
2004-08-26 06:31:44 +08:00
|
|
|
#include "gimpviewrenderer.h"
|
2003-09-30 04:26:09 +08:00
|
|
|
#include "gimptooloptionseditor.h"
|
2004-04-23 01:14:22 +08:00
|
|
|
#include "gimpuimanager.h"
|
2003-09-30 06:23:44 +08:00
|
|
|
#include "gimpwidgets-utils.h"
|
2001-05-25 09:24:12 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2001-01-22 13:08:44 +08:00
|
|
|
|
|
|
|
|
2005-12-20 06:37:49 +08:00
|
|
|
static void gimp_tool_options_editor_docked_iface_init (GimpDockedInterface *iface);
|
2001-01-22 13:08:44 +08:00
|
|
|
|
2004-05-13 23:50:55 +08:00
|
|
|
static GObject * gimp_tool_options_editor_constructor (GType type,
|
|
|
|
guint n_params,
|
|
|
|
GObjectConstructParam *params);
|
|
|
|
|
2003-09-30 04:26:09 +08:00
|
|
|
static void gimp_tool_options_editor_destroy (GtkObject *object);
|
2001-01-22 13:08:44 +08:00
|
|
|
|
2003-10-11 05:24:12 +08:00
|
|
|
static GtkWidget *gimp_tool_options_editor_get_preview (GimpDocked *docked,
|
|
|
|
GimpContext *context,
|
|
|
|
GtkIconSize size);
|
2003-10-21 22:49:12 +08:00
|
|
|
static gchar *gimp_tool_options_editor_get_title (GimpDocked *docked);
|
2003-10-11 05:24:12 +08:00
|
|
|
|
2003-09-30 04:26:09 +08:00
|
|
|
static void gimp_tool_options_editor_save_clicked (GtkWidget *widget,
|
|
|
|
GimpToolOptionsEditor *editor);
|
|
|
|
static void gimp_tool_options_editor_restore_clicked (GtkWidget *widget,
|
|
|
|
GimpToolOptionsEditor *editor);
|
2003-09-30 06:23:44 +08:00
|
|
|
static void gimp_tool_options_editor_delete_clicked (GtkWidget *widget,
|
|
|
|
GimpToolOptionsEditor *editor);
|
2003-09-30 04:26:09 +08:00
|
|
|
static void gimp_tool_options_editor_drop_tool (GtkWidget *widget,
|
2004-12-31 22:36:30 +08:00
|
|
|
gint x,
|
|
|
|
gint y,
|
2003-09-30 04:26:09 +08:00
|
|
|
GimpViewable *viewable,
|
|
|
|
gpointer data);
|
2002-03-10 23:05:58 +08:00
|
|
|
|
2003-09-30 04:26:09 +08:00
|
|
|
static void gimp_tool_options_editor_tool_changed (GimpContext *context,
|
|
|
|
GimpToolInfo *tool_info,
|
|
|
|
GimpToolOptionsEditor *editor);
|
2001-01-22 13:08:44 +08:00
|
|
|
|
2006-12-11 23:16:13 +08:00
|
|
|
static void gimp_tool_options_editor_presets_changed (GimpToolPresets *presets,
|
2003-09-30 06:56:46 +08:00
|
|
|
GimpToolOptionsEditor *editor);
|
2006-12-11 23:16:13 +08:00
|
|
|
static void gimp_tool_options_editor_presets_update (GimpToolOptionsEditor *editor,
|
|
|
|
GimpToolPresets *presets);
|
|
|
|
static void gimp_tool_options_editor_save_presets (GimpToolOptionsEditor *editor);
|
2003-09-30 06:56:46 +08:00
|
|
|
|
2001-01-22 13:08:44 +08:00
|
|
|
|
2005-12-20 06:37:49 +08:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GimpToolOptionsEditor, gimp_tool_options_editor,
|
|
|
|
GIMP_TYPE_EDITOR,
|
|
|
|
G_IMPLEMENT_INTERFACE (GIMP_TYPE_DOCKED,
|
2006-05-15 17:46:31 +08:00
|
|
|
gimp_tool_options_editor_docked_iface_init))
|
2001-01-22 13:08:44 +08:00
|
|
|
|
2005-12-20 06:37:49 +08:00
|
|
|
#define parent_class gimp_tool_options_editor_parent_class
|
2001-01-22 13:08:44 +08:00
|
|
|
|
2001-04-18 00:00:27 +08:00
|
|
|
|
2003-09-30 04:26:09 +08:00
|
|
|
static void
|
|
|
|
gimp_tool_options_editor_class_init (GimpToolOptionsEditorClass *klass)
|
|
|
|
{
|
2004-05-13 23:50:55 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass);
|
2002-03-10 23:05:58 +08:00
|
|
|
|
2004-05-13 23:50:55 +08:00
|
|
|
object_class->constructor = gimp_tool_options_editor_constructor;
|
|
|
|
|
|
|
|
gtk_object_class->destroy = gimp_tool_options_editor_destroy;
|
2003-09-30 04:26:09 +08:00
|
|
|
}
|
2002-03-10 23:05:58 +08:00
|
|
|
|
2003-09-30 04:26:09 +08:00
|
|
|
static void
|
|
|
|
gimp_tool_options_editor_init (GimpToolOptionsEditor *editor)
|
|
|
|
{
|
2008-03-08 22:33:16 +08:00
|
|
|
GtkScrolledWindow *scrolled_window;
|
|
|
|
GtkWidget *viewport;
|
2004-05-13 23:50:55 +08:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2008-03-08 22:33:16 +08:00
|
|
|
editor->scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
|
|
|
scrolled_window = GTK_SCROLLED_WINDOW (editor->scrolled_window);
|
|
|
|
|
|
|
|
gtk_scrolled_window_set_policy (scrolled_window,
|
2004-05-13 23:50:55 +08:00
|
|
|
GTK_POLICY_AUTOMATIC,
|
|
|
|
GTK_POLICY_AUTOMATIC);
|
2008-03-08 22:33:16 +08:00
|
|
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (editor), editor->scrolled_window);
|
|
|
|
gtk_widget_show (editor->scrolled_window);
|
|
|
|
|
|
|
|
viewport = gtk_viewport_new (gtk_scrolled_window_get_hadjustment (scrolled_window),
|
|
|
|
gtk_scrolled_window_get_vadjustment (scrolled_window));
|
|
|
|
gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport), GTK_SHADOW_NONE);
|
|
|
|
gtk_container_add (GTK_CONTAINER (scrolled_window), viewport);
|
|
|
|
gtk_widget_show (viewport);
|
2004-05-13 23:50:55 +08:00
|
|
|
|
|
|
|
/* The vbox containing the tool options */
|
|
|
|
editor->options_vbox = gtk_vbox_new (FALSE, 0);
|
2008-03-08 22:33:16 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (viewport), editor->options_vbox);
|
2004-05-13 23:50:55 +08:00
|
|
|
gtk_widget_show (editor->options_vbox);
|
2006-12-11 23:16:13 +08:00
|
|
|
|
|
|
|
editor->save_queue = NULL;
|
|
|
|
editor->save_idle_id = 0;
|
2004-05-13 23:50:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
|
|
|
|
|
|
|
editor = GIMP_TOOL_OPTIONS_EDITOR (object);
|
2002-03-10 23:05:58 +08:00
|
|
|
|
2003-09-30 04:26:09 +08:00
|
|
|
editor->save_button =
|
|
|
|
gimp_editor_add_button (GIMP_EDITOR (editor), GTK_STOCK_SAVE,
|
2003-09-30 06:56:46 +08:00
|
|
|
_("Save options to..."),
|
2003-09-30 04:26:09 +08:00
|
|
|
GIMP_HELP_TOOL_OPTIONS_SAVE,
|
|
|
|
G_CALLBACK (gimp_tool_options_editor_save_clicked),
|
2002-03-10 23:05:58 +08:00
|
|
|
NULL,
|
2003-09-30 04:26:09 +08:00
|
|
|
editor);
|
2002-03-10 23:05:58 +08:00
|
|
|
|
2003-09-30 04:26:09 +08:00
|
|
|
editor->restore_button =
|
|
|
|
gimp_editor_add_button (GIMP_EDITOR (editor), GTK_STOCK_REVERT_TO_SAVED,
|
2003-09-30 06:56:46 +08:00
|
|
|
_("Restore options from..."),
|
2003-09-30 04:26:09 +08:00
|
|
|
GIMP_HELP_TOOL_OPTIONS_RESTORE,
|
|
|
|
G_CALLBACK (gimp_tool_options_editor_restore_clicked),
|
2002-03-10 23:05:58 +08:00
|
|
|
NULL,
|
2003-09-30 04:26:09 +08:00
|
|
|
editor);
|
2002-03-10 23:05:58 +08:00
|
|
|
|
2003-09-30 06:23:44 +08:00
|
|
|
editor->delete_button =
|
|
|
|
gimp_editor_add_button (GIMP_EDITOR (editor), GTK_STOCK_DELETE,
|
2003-09-30 06:56:46 +08:00
|
|
|
_("Delete saved options..."),
|
2003-09-30 06:23:44 +08:00
|
|
|
GIMP_HELP_TOOL_OPTIONS_DELETE,
|
|
|
|
G_CALLBACK (gimp_tool_options_editor_delete_clicked),
|
|
|
|
NULL,
|
|
|
|
editor);
|
|
|
|
|
2003-09-30 04:26:09 +08:00
|
|
|
editor->reset_button =
|
2004-05-13 23:50:55 +08:00
|
|
|
gimp_editor_add_action_button (GIMP_EDITOR (editor), "tool-options",
|
|
|
|
"tool-options-reset",
|
|
|
|
"tool-options-reset-all",
|
|
|
|
GDK_SHIFT_MASK,
|
|
|
|
NULL);
|
2002-03-10 23:05:58 +08:00
|
|
|
|
2004-05-13 23:50:55 +08:00
|
|
|
return object;
|
2003-10-11 05:24:12 +08:00
|
|
|
}
|
|
|
|
|
2002-03-10 23:05:58 +08:00
|
|
|
static void
|
2003-09-30 04:26:09 +08:00
|
|
|
gimp_tool_options_editor_destroy (GtkObject *object)
|
2001-01-22 13:08:44 +08:00
|
|
|
{
|
2003-09-30 04:26:09 +08:00
|
|
|
GimpToolOptionsEditor *editor = GIMP_TOOL_OPTIONS_EDITOR (object);
|
2002-03-10 23:05:58 +08:00
|
|
|
|
2003-09-30 04:26:09 +08:00
|
|
|
if (editor->options_vbox)
|
2001-04-18 00:00:27 +08:00
|
|
|
{
|
2003-09-30 04:26:09 +08:00
|
|
|
GList *options;
|
|
|
|
GList *list;
|
|
|
|
|
|
|
|
options =
|
|
|
|
gtk_container_get_children (GTK_CONTAINER (editor->options_vbox));
|
2001-01-22 13:08:44 +08:00
|
|
|
|
2003-09-30 04:26:09 +08:00
|
|
|
for (list = options; list; list = g_list_next (list))
|
|
|
|
{
|
|
|
|
g_object_ref (list->data);
|
|
|
|
gtk_container_remove (GTK_CONTAINER (editor->options_vbox),
|
|
|
|
GTK_WIDGET (list->data));
|
|
|
|
}
|
2001-02-24 05:32:47 +08:00
|
|
|
|
2003-09-30 04:26:09 +08:00
|
|
|
g_list_free (options);
|
|
|
|
editor->options_vbox = NULL;
|
|
|
|
}
|
|
|
|
|
2006-12-11 23:16:13 +08:00
|
|
|
gimp_tool_options_editor_save_presets (editor);
|
|
|
|
|
2003-09-30 04:26:09 +08:00
|
|
|
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
2002-03-10 23:05:58 +08:00
|
|
|
}
|
2001-02-24 05:32:47 +08:00
|
|
|
|
2003-10-11 05:24:12 +08:00
|
|
|
static GtkWidget *
|
|
|
|
gimp_tool_options_editor_get_preview (GimpDocked *docked,
|
|
|
|
GimpContext *context,
|
|
|
|
GtkIconSize size)
|
|
|
|
{
|
2005-11-03 04:18:13 +08:00
|
|
|
GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (docked));
|
|
|
|
GtkWidget *view;
|
|
|
|
gint width;
|
|
|
|
gint height;
|
|
|
|
|
|
|
|
gtk_icon_size_lookup_for_settings (settings, size, &width, &height);
|
2003-10-11 05:24:12 +08:00
|
|
|
|
2006-08-30 05:44:51 +08:00
|
|
|
view = gimp_prop_view_new (G_OBJECT (context), "tool", context, height);
|
2004-08-25 01:16:46 +08:00
|
|
|
GIMP_VIEW (view)->renderer->size = -1;
|
2004-08-26 06:31:44 +08:00
|
|
|
gimp_view_renderer_set_size_full (GIMP_VIEW (view)->renderer,
|
|
|
|
width, height, 0);
|
2003-10-11 05:24:12 +08:00
|
|
|
|
2004-08-25 01:16:46 +08:00
|
|
|
return view;
|
2003-10-21 22:49:12 +08:00
|
|
|
}
|
2003-10-11 05:24:12 +08:00
|
|
|
|
2003-10-21 22:49:12 +08:00
|
|
|
static gchar *
|
|
|
|
gimp_tool_options_editor_get_title (GimpDocked *docked)
|
|
|
|
{
|
|
|
|
GimpToolOptionsEditor *editor = GIMP_TOOL_OPTIONS_EDITOR (docked);
|
|
|
|
GimpContext *context;
|
|
|
|
GimpToolInfo *tool_info;
|
2003-10-11 05:24:12 +08:00
|
|
|
|
2003-10-21 22:49:12 +08:00
|
|
|
context = gimp_get_user_context (editor->gimp);
|
2003-10-11 05:24:12 +08:00
|
|
|
|
2003-10-21 22:49:12 +08:00
|
|
|
tool_info = gimp_context_get_tool (context);
|
2003-10-11 05:24:12 +08:00
|
|
|
|
2007-09-24 03:09:37 +08:00
|
|
|
return tool_info ? g_strdup (tool_info->blurb) : NULL;
|
2003-10-11 05:24:12 +08:00
|
|
|
}
|
|
|
|
|
2004-05-13 23:50:55 +08:00
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
2003-09-30 04:26:09 +08:00
|
|
|
GtkWidget *
|
|
|
|
gimp_tool_options_editor_new (Gimp *gimp,
|
|
|
|
GimpMenuFactory *menu_factory)
|
2001-01-22 13:08:44 +08:00
|
|
|
{
|
2003-09-30 04:26:09 +08:00
|
|
|
GimpToolOptionsEditor *editor;
|
|
|
|
GimpContext *user_context;
|
2003-02-10 01:32:52 +08:00
|
|
|
|
2003-09-30 04:26:09 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
|
|
|
g_return_val_if_fail (GIMP_IS_MENU_FACTORY (menu_factory), NULL);
|
2003-02-10 01:32:52 +08:00
|
|
|
|
2004-05-13 23:50:55 +08:00
|
|
|
editor = g_object_new (GIMP_TYPE_TOOL_OPTIONS_EDITOR,
|
|
|
|
"menu-factory", menu_factory,
|
|
|
|
"menu-identifier", "<ToolOptions>",
|
|
|
|
"ui-path", "/tool-options-popup",
|
|
|
|
NULL);
|
2001-01-22 13:08:44 +08:00
|
|
|
|
2003-09-30 04:26:09 +08:00
|
|
|
editor->gimp = gimp;
|
2003-02-10 01:32:52 +08:00
|
|
|
|
2004-05-13 23:50:55 +08:00
|
|
|
user_context = gimp_get_user_context (gimp);
|
2003-02-09 07:56:16 +08:00
|
|
|
|
2005-05-28 00:51:39 +08:00
|
|
|
g_signal_connect_object (user_context, "tool-changed",
|
2003-09-30 04:26:09 +08:00
|
|
|
G_CALLBACK (gimp_tool_options_editor_tool_changed),
|
|
|
|
editor,
|
|
|
|
0);
|
2003-02-09 07:56:16 +08:00
|
|
|
|
2003-09-30 04:26:09 +08:00
|
|
|
gimp_tool_options_editor_tool_changed (user_context,
|
|
|
|
gimp_context_get_tool (user_context),
|
|
|
|
editor);
|
|
|
|
|
|
|
|
return GTK_WIDGET (editor);
|
2001-02-24 05:32:47 +08:00
|
|
|
}
|
2001-01-22 13:08:44 +08:00
|
|
|
|
2004-05-13 23:50:55 +08:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
2001-01-22 13:08:44 +08:00
|
|
|
static void
|
2003-09-30 06:23:44 +08:00
|
|
|
gimp_tool_options_editor_menu_pos (GtkMenu *menu,
|
|
|
|
gint *x,
|
|
|
|
gint *y,
|
2004-05-17 21:38:03 +08:00
|
|
|
gpointer data)
|
2001-01-22 13:08:44 +08:00
|
|
|
{
|
2004-05-17 21:38:03 +08:00
|
|
|
gimp_button_menu_position (GTK_WIDGET (data), menu, GTK_POS_RIGHT, x, y);
|
2003-09-30 06:23:44 +08:00
|
|
|
}
|
2001-10-29 19:47:11 +08:00
|
|
|
|
2003-09-30 06:23:44 +08:00
|
|
|
static void
|
|
|
|
gimp_tool_options_editor_menu_popup (GimpToolOptionsEditor *editor,
|
|
|
|
GtkWidget *button,
|
|
|
|
const gchar *path)
|
|
|
|
{
|
2004-04-23 01:14:22 +08:00
|
|
|
GimpEditor *gimp_editor = GIMP_EDITOR (editor);
|
|
|
|
|
2005-02-09 04:55:00 +08:00
|
|
|
gtk_ui_manager_get_widget (GTK_UI_MANAGER (gimp_editor->ui_manager),
|
|
|
|
gimp_editor->ui_path);
|
2004-04-30 23:29:11 +08:00
|
|
|
gimp_ui_manager_update (gimp_editor->ui_manager, gimp_editor->popup_data);
|
2004-04-29 20:52:29 +08:00
|
|
|
|
2004-05-17 21:38:03 +08:00
|
|
|
gimp_ui_manager_ui_popup (gimp_editor->ui_manager, path,
|
|
|
|
button,
|
|
|
|
gimp_tool_options_editor_menu_pos, button,
|
|
|
|
NULL, NULL);
|
2003-09-30 06:23:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_tool_options_editor_save_clicked (GtkWidget *widget,
|
|
|
|
GimpToolOptionsEditor *editor)
|
|
|
|
{
|
2003-09-30 06:56:46 +08:00
|
|
|
if (GTK_WIDGET_SENSITIVE (editor->restore_button) /* evil but correct */)
|
|
|
|
{
|
2004-04-30 23:29:11 +08:00
|
|
|
gimp_tool_options_editor_menu_popup (editor, widget,
|
2004-05-13 23:50:55 +08:00
|
|
|
"/tool-options-popup/Save");
|
2003-09-30 06:56:46 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-12-15 20:03:47 +08:00
|
|
|
gimp_ui_manager_activate_action (GIMP_EDITOR (editor)->ui_manager,
|
|
|
|
"tool-options",
|
|
|
|
"tool-options-save-new");
|
2003-09-30 06:56:46 +08:00
|
|
|
}
|
2001-01-22 13:08:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-09-30 04:26:09 +08:00
|
|
|
gimp_tool_options_editor_restore_clicked (GtkWidget *widget,
|
|
|
|
GimpToolOptionsEditor *editor)
|
2001-01-22 13:08:44 +08:00
|
|
|
{
|
2004-04-30 23:29:11 +08:00
|
|
|
gimp_tool_options_editor_menu_popup (editor, widget,
|
2004-05-13 23:50:55 +08:00
|
|
|
"/tool-options-popup/Restore");
|
2003-09-30 06:23:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_tool_options_editor_delete_clicked (GtkWidget *widget,
|
|
|
|
GimpToolOptionsEditor *editor)
|
|
|
|
{
|
2004-04-30 23:29:11 +08:00
|
|
|
gimp_tool_options_editor_menu_popup (editor, widget,
|
2004-05-13 23:50:55 +08:00
|
|
|
"/tool-options-popup/Delete");
|
2003-09-30 04:26:09 +08:00
|
|
|
}
|
2003-02-08 23:27:51 +08:00
|
|
|
|
2003-09-30 04:26:09 +08:00
|
|
|
static void
|
|
|
|
gimp_tool_options_editor_drop_tool (GtkWidget *widget,
|
2004-12-31 22:36:30 +08:00
|
|
|
gint x,
|
|
|
|
gint y,
|
2003-09-30 04:26:09 +08:00
|
|
|
GimpViewable *viewable,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpToolOptionsEditor *editor = GIMP_TOOL_OPTIONS_EDITOR (data);
|
|
|
|
GimpContext *context;
|
2003-03-26 21:39:00 +08:00
|
|
|
|
2003-09-30 04:26:09 +08:00
|
|
|
context = gimp_get_user_context (editor->gimp);
|
2003-03-26 21:39:00 +08:00
|
|
|
|
2003-09-30 04:26:09 +08:00
|
|
|
gimp_context_set_tool (context, GIMP_TOOL_INFO (viewable));
|
2001-01-22 13:08:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-09-30 04:26:09 +08:00
|
|
|
gimp_tool_options_editor_tool_changed (GimpContext *context,
|
|
|
|
GimpToolInfo *tool_info,
|
|
|
|
GimpToolOptionsEditor *editor)
|
2001-01-22 13:08:44 +08:00
|
|
|
{
|
2006-12-11 03:13:58 +08:00
|
|
|
GimpToolPresets *presets;
|
|
|
|
GtkWidget *options_gui;
|
2003-09-30 04:26:09 +08:00
|
|
|
|
2003-09-30 06:56:46 +08:00
|
|
|
if (tool_info && tool_info->tool_options == editor->visible_tool_options)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (editor->visible_tool_options)
|
2003-09-30 04:26:09 +08:00
|
|
|
{
|
2006-12-11 03:13:58 +08:00
|
|
|
presets = editor->visible_tool_options->tool_info->presets;
|
2003-09-30 06:56:46 +08:00
|
|
|
|
|
|
|
if (presets)
|
|
|
|
g_signal_handlers_disconnect_by_func (presets,
|
|
|
|
gimp_tool_options_editor_presets_changed,
|
|
|
|
editor);
|
|
|
|
|
2003-09-30 04:26:09 +08:00
|
|
|
options_gui = g_object_get_data (G_OBJECT (editor->visible_tool_options),
|
|
|
|
"gimp-tool-options-gui");
|
|
|
|
|
|
|
|
if (options_gui)
|
|
|
|
gtk_widget_hide (options_gui);
|
|
|
|
|
|
|
|
editor->visible_tool_options = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tool_info && tool_info->tool_options)
|
|
|
|
{
|
2006-12-11 03:13:58 +08:00
|
|
|
presets = tool_info->presets;
|
2003-09-30 06:56:46 +08:00
|
|
|
|
|
|
|
if (presets)
|
2006-12-11 23:16:13 +08:00
|
|
|
g_signal_connect_object (presets, "changed",
|
|
|
|
G_CALLBACK (gimp_tool_options_editor_presets_changed),
|
|
|
|
G_OBJECT (editor), 0);
|
2003-09-30 06:56:46 +08:00
|
|
|
|
2003-09-30 04:26:09 +08:00
|
|
|
options_gui = g_object_get_data (G_OBJECT (tool_info->tool_options),
|
|
|
|
"gimp-tool-options-gui");
|
|
|
|
|
2008-06-28 23:50:27 +08:00
|
|
|
if (! gtk_widget_get_parent (options_gui))
|
2003-09-30 04:26:09 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (editor->options_vbox), options_gui,
|
|
|
|
FALSE, FALSE, 0);
|
2001-07-08 01:36:00 +08:00
|
|
|
|
2003-09-30 04:26:09 +08:00
|
|
|
gtk_widget_show (options_gui);
|
|
|
|
|
|
|
|
editor->visible_tool_options = tool_info->tool_options;
|
2004-01-31 06:10:31 +08:00
|
|
|
|
|
|
|
gimp_help_set_help_data (editor->scrolled_window, NULL,
|
|
|
|
tool_info->help_id);
|
2003-09-30 04:26:09 +08:00
|
|
|
}
|
2003-09-30 06:56:46 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
presets = NULL;
|
|
|
|
}
|
2001-02-24 05:32:47 +08:00
|
|
|
|
2006-12-11 23:16:13 +08:00
|
|
|
gimp_tool_options_editor_presets_update (editor, presets);
|
2003-10-21 22:49:12 +08:00
|
|
|
|
|
|
|
gimp_docked_title_changed (GIMP_DOCKED (editor));
|
2003-09-30 06:56:46 +08:00
|
|
|
}
|
|
|
|
|
2006-12-11 23:16:13 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_tool_options_editor_save_presets_idle (GimpToolOptionsEditor *editor)
|
|
|
|
{
|
|
|
|
editor->save_idle_id = 0;
|
|
|
|
|
|
|
|
gimp_tool_options_editor_save_presets (editor);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_tool_options_editor_queue_save_presets (GimpToolOptionsEditor *editor,
|
|
|
|
GimpToolPresets *presets)
|
|
|
|
{
|
|
|
|
if (g_list_find (editor->save_queue, presets))
|
|
|
|
return;
|
|
|
|
|
|
|
|
editor->save_queue = g_list_append (editor->save_queue, presets);
|
|
|
|
|
|
|
|
if (! editor->save_idle_id)
|
|
|
|
{
|
|
|
|
editor->save_idle_id =
|
|
|
|
g_idle_add ((GSourceFunc) gimp_tool_options_editor_save_presets_idle,
|
|
|
|
editor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_tool_options_editor_save_presets (GimpToolOptionsEditor *editor)
|
|
|
|
{
|
|
|
|
GList *list;
|
|
|
|
|
|
|
|
if (editor->save_idle_id)
|
|
|
|
{
|
|
|
|
g_source_remove (editor->save_idle_id);
|
|
|
|
editor->save_idle_id = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (list = editor->save_queue; list; list = list->next)
|
|
|
|
{
|
|
|
|
GimpToolPresets *presets = list->data;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
if (! gimp_tool_presets_save (presets, &error))
|
|
|
|
{
|
|
|
|
gimp_message (editor->gimp, G_OBJECT (editor), GIMP_MESSAGE_ERROR,
|
|
|
|
_("Error saving tool options presets: %s"),
|
|
|
|
error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free (editor->save_queue);
|
|
|
|
|
|
|
|
editor->save_queue = NULL;
|
|
|
|
}
|
|
|
|
|
2003-09-30 06:56:46 +08:00
|
|
|
static void
|
2006-12-11 23:16:13 +08:00
|
|
|
gimp_tool_options_editor_presets_changed (GimpToolPresets *presets,
|
2003-09-30 06:56:46 +08:00
|
|
|
GimpToolOptionsEditor *editor)
|
2006-12-11 23:16:13 +08:00
|
|
|
{
|
|
|
|
gimp_tool_options_editor_queue_save_presets (editor, presets);
|
|
|
|
|
|
|
|
gimp_tool_options_editor_presets_update (editor, presets);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_tool_options_editor_presets_update (GimpToolOptionsEditor *editor,
|
|
|
|
GimpToolPresets *presets)
|
2003-09-30 06:56:46 +08:00
|
|
|
{
|
|
|
|
gboolean save_sensitive = FALSE;
|
|
|
|
gboolean restore_sensitive = FALSE;
|
|
|
|
gboolean delete_sensitive = FALSE;
|
|
|
|
gboolean reset_sensitive = FALSE;
|
|
|
|
|
2006-12-11 23:16:13 +08:00
|
|
|
if (presets)
|
2003-09-30 06:56:46 +08:00
|
|
|
{
|
|
|
|
save_sensitive = TRUE;
|
|
|
|
reset_sensitive = TRUE;
|
|
|
|
|
2006-12-11 23:16:13 +08:00
|
|
|
if (! gimp_container_is_empty (GIMP_CONTAINER (presets)))
|
2003-09-30 06:56:46 +08:00
|
|
|
{
|
|
|
|
restore_sensitive = TRUE;
|
|
|
|
delete_sensitive = TRUE;
|
|
|
|
}
|
|
|
|
}
|
2001-02-24 05:32:47 +08:00
|
|
|
|
2003-09-30 06:56:46 +08:00
|
|
|
gtk_widget_set_sensitive (editor->save_button, save_sensitive);
|
|
|
|
gtk_widget_set_sensitive (editor->restore_button, restore_sensitive);
|
|
|
|
gtk_widget_set_sensitive (editor->delete_button, delete_sensitive);
|
|
|
|
gtk_widget_set_sensitive (editor->reset_button, reset_sensitive);
|
2001-01-22 13:08:44 +08:00
|
|
|
}
|