2006-12-09 13:33:38 -08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2001-01-21 21:08:44 -08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
|
*
|
2003-09-29 13:26:09 -07:00
|
|
|
* gimptooloptionseditor.c
|
|
|
|
|
* Copyright (C) 2003 Michael Natterer <mitch@gimp.org>
|
|
|
|
|
*
|
2009-01-17 14:28:01 -08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2001-01-21 21:08:44 -08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 14:28:01 -08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2001-01-21 21: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
|
2018-07-11 14:27:07 -07:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2001-01-21 21:08:44 -08:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
2012-03-29 10:19:01 -07:00
|
|
|
#include <gegl.h>
|
2001-01-21 21:08:44 -08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
2019-07-31 01:16:21 -07:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-01-24 14:36:18 -08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2001-01-21 21:08:44 -08:00
|
|
|
|
2003-09-29 13:26:09 -07:00
|
|
|
#include "widgets-types.h"
|
2001-01-21 21:08:44 -08:00
|
|
|
|
2001-07-07 05:17:23 -07:00
|
|
|
#include "core/gimp.h"
|
2001-05-08 19:32:03 -07:00
|
|
|
#include "core/gimpcontext.h"
|
2003-09-29 15:23:44 -07:00
|
|
|
#include "core/gimplist.h"
|
2001-05-09 15:34:59 -07:00
|
|
|
#include "core/gimptoolinfo.h"
|
2003-06-29 13:40:45 -07:00
|
|
|
#include "core/gimptooloptions.h"
|
2001-05-08 19:32:03 -07:00
|
|
|
|
2003-09-29 13:26:09 -07:00
|
|
|
#include "gimpdnd.h"
|
2003-10-10 14:24:12 -07:00
|
|
|
#include "gimpdocked.h"
|
2003-09-29 13:26:09 -07:00
|
|
|
#include "gimphelp-ids.h"
|
|
|
|
|
#include "gimpmenufactory.h"
|
2005-02-04 12:47:42 -08:00
|
|
|
#include "gimppropwidgets.h"
|
2004-08-24 10:16:46 -07:00
|
|
|
#include "gimpview.h"
|
2004-08-25 15:31:44 -07:00
|
|
|
#include "gimpviewrenderer.h"
|
2003-09-29 13:26:09 -07:00
|
|
|
#include "gimptooloptionseditor.h"
|
2004-04-22 10:14:22 -07:00
|
|
|
#include "gimpuimanager.h"
|
2003-09-29 15:23:44 -07:00
|
|
|
#include "gimpwidgets-utils.h"
|
2001-05-24 18:24:12 -07:00
|
|
|
|
2003-03-25 08:38:19 -08:00
|
|
|
#include "gimp-intl.h"
|
2001-01-21 21:08:44 -08:00
|
|
|
|
2009-12-24 08:40:45 -08:00
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
PROP_0,
|
|
|
|
|
PROP_GIMP,
|
|
|
|
|
};
|
2001-01-21 21:08:44 -08:00
|
|
|
|
2009-12-23 13:39:47 -08:00
|
|
|
struct _GimpToolOptionsEditorPrivate
|
|
|
|
|
{
|
|
|
|
|
Gimp *gimp;
|
|
|
|
|
|
|
|
|
|
GtkWidget *scrolled_window;
|
|
|
|
|
GtkWidget *options_vbox;
|
2010-09-16 08:46:10 -07:00
|
|
|
GtkWidget *title_label;
|
2009-12-23 13:39:47 -08:00
|
|
|
|
|
|
|
|
GtkWidget *save_button;
|
|
|
|
|
GtkWidget *restore_button;
|
|
|
|
|
GtkWidget *delete_button;
|
|
|
|
|
GtkWidget *reset_button;
|
|
|
|
|
|
|
|
|
|
GimpToolOptions *visible_tool_options;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void gimp_tool_options_editor_docked_iface_init (GimpDockedInterface *iface);
|
2011-01-14 00:38:11 -08:00
|
|
|
static void gimp_tool_options_editor_constructed (GObject *object);
|
2010-09-26 13:38:01 -07:00
|
|
|
static void gimp_tool_options_editor_dispose (GObject *object);
|
2009-12-24 08:40:45 -08:00
|
|
|
static void gimp_tool_options_editor_set_property (GObject *object,
|
|
|
|
|
guint property_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
static void gimp_tool_options_editor_get_property (GObject *object,
|
|
|
|
|
guint property_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
2010-09-26 13:38:01 -07:00
|
|
|
|
2009-12-23 13:39:47 -08:00
|
|
|
static GtkWidget * gimp_tool_options_editor_get_preview (GimpDocked *docked,
|
|
|
|
|
GimpContext *context,
|
|
|
|
|
GtkIconSize size);
|
|
|
|
|
static gchar * gimp_tool_options_editor_get_title (GimpDocked *docked);
|
2010-06-11 14:18:49 -07:00
|
|
|
static gboolean gimp_tool_options_editor_get_prefer_icon (GimpDocked *docked);
|
2009-12-23 13:39:47 -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);
|
|
|
|
|
static void gimp_tool_options_editor_delete_clicked (GtkWidget *widget,
|
|
|
|
|
GimpToolOptionsEditor *editor);
|
|
|
|
|
static void gimp_tool_options_editor_drop_tool (GtkWidget *widget,
|
|
|
|
|
gint x,
|
|
|
|
|
gint y,
|
|
|
|
|
GimpViewable *viewable,
|
|
|
|
|
gpointer data);
|
|
|
|
|
static void gimp_tool_options_editor_tool_changed (GimpContext *context,
|
|
|
|
|
GimpToolInfo *tool_info,
|
|
|
|
|
GimpToolOptionsEditor *editor);
|
2011-03-23 01:27:29 -07:00
|
|
|
static void gimp_tool_options_editor_presets_update (GimpToolOptionsEditor *editor);
|
2003-09-29 15:56:46 -07:00
|
|
|
|
2001-01-21 21:08:44 -08:00
|
|
|
|
2005-12-19 14:37:49 -08:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GimpToolOptionsEditor, gimp_tool_options_editor,
|
|
|
|
|
GIMP_TYPE_EDITOR,
|
app, libgimp*, modules: don't use g_type_class_add_private() ...
... and G_TYPE_INSTANCE_GET_PRIVATE()
g_type_class_add_private() and G_TYPE_INSTANCE_GET_PRIVATE() were
deprecated in GLib 2.58. Instead, use
G_DEFINE_[ABSTRACT_]TYPE_WITH_PRIVATE(), and
G_ADD_PRIVATE[_DYNAMIC](), and the implictly-defined
foo_get_instance_private() functions, all of which are available in
the GLib versions we depend on.
This commit only covers types registered using one of the
G_DEFINE_FOO() macros (i.e., most types), but not types with a
custom registration function, of which we still have a few -- GLib
currently only provides a (non-deprecated) public API for adding a
private struct using the G_DEFINE_FOO() macros.
Note that this commit was 99% auto-generated (because I'm not
*that* crazy :), so if there are any style mismatches... we'll have
to live with them for now.
2018-09-18 09:09:39 -07:00
|
|
|
G_ADD_PRIVATE (GimpToolOptionsEditor)
|
2005-12-19 14:37:49 -08:00
|
|
|
G_IMPLEMENT_INTERFACE (GIMP_TYPE_DOCKED,
|
2006-05-15 02:46:31 -07:00
|
|
|
gimp_tool_options_editor_docked_iface_init))
|
2001-01-21 21:08:44 -08:00
|
|
|
|
2005-12-19 14:37:49 -08:00
|
|
|
#define parent_class gimp_tool_options_editor_parent_class
|
2001-01-21 21:08:44 -08:00
|
|
|
|
2001-04-17 09:00:27 -07:00
|
|
|
|
2003-09-29 13:26:09 -07:00
|
|
|
static void
|
|
|
|
|
gimp_tool_options_editor_class_init (GimpToolOptionsEditorClass *klass)
|
|
|
|
|
{
|
2010-09-26 13:38:01 -07:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2002-03-10 07:05:58 -08:00
|
|
|
|
2011-01-14 00:38:11 -08:00
|
|
|
object_class->constructed = gimp_tool_options_editor_constructed;
|
2010-09-26 13:38:01 -07:00
|
|
|
object_class->dispose = gimp_tool_options_editor_dispose;
|
2009-12-24 08:40:45 -08:00
|
|
|
object_class->set_property = gimp_tool_options_editor_set_property;
|
|
|
|
|
object_class->get_property = gimp_tool_options_editor_get_property;
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_GIMP,
|
|
|
|
|
g_param_spec_object ("gimp",
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
GIMP_TYPE_GIMP,
|
|
|
|
|
GIMP_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
2003-09-29 13:26:09 -07:00
|
|
|
}
|
2002-03-10 07:05:58 -08:00
|
|
|
|
2011-01-14 00:38:11 -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;
|
|
|
|
|
docked_iface->get_prefer_icon = gimp_tool_options_editor_get_prefer_icon;
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-29 13:26:09 -07:00
|
|
|
static void
|
|
|
|
|
gimp_tool_options_editor_init (GimpToolOptionsEditor *editor)
|
|
|
|
|
{
|
2008-03-08 06:33:16 -08:00
|
|
|
GtkScrolledWindow *scrolled_window;
|
2004-05-13 08:50:55 -07:00
|
|
|
|
app, libgimp*, modules: don't use g_type_class_add_private() ...
... and G_TYPE_INSTANCE_GET_PRIVATE()
g_type_class_add_private() and G_TYPE_INSTANCE_GET_PRIVATE() were
deprecated in GLib 2.58. Instead, use
G_DEFINE_[ABSTRACT_]TYPE_WITH_PRIVATE(), and
G_ADD_PRIVATE[_DYNAMIC](), and the implictly-defined
foo_get_instance_private() functions, all of which are available in
the GLib versions we depend on.
This commit only covers types registered using one of the
G_DEFINE_FOO() macros (i.e., most types), but not types with a
custom registration function, of which we still have a few -- GLib
currently only provides a (non-deprecated) public API for adding a
private struct using the G_DEFINE_FOO() macros.
Note that this commit was 99% auto-generated (because I'm not
*that* crazy :), so if there are any style mismatches... we'll have
to live with them for now.
2018-09-18 09:09:39 -07:00
|
|
|
editor->p = gimp_tool_options_editor_get_instance_private (editor);
|
2009-12-23 13:39:47 -08:00
|
|
|
|
2004-05-13 08:50:55 -07: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);
|
|
|
|
|
|
2010-09-16 08:46:10 -07:00
|
|
|
/* The label containing the tool options title */
|
|
|
|
|
editor->p->title_label = gtk_label_new (NULL);
|
2016-09-08 10:11:20 -07:00
|
|
|
gtk_label_set_xalign (GTK_LABEL (editor->p->title_label), 0.0);
|
2010-09-16 12:06:56 -07:00
|
|
|
gimp_label_set_attributes (GTK_LABEL (editor->p->title_label),
|
|
|
|
|
PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD,
|
|
|
|
|
-1);
|
2016-09-08 10:11:20 -07:00
|
|
|
gtk_box_pack_start (GTK_BOX (editor), editor->p->title_label,
|
|
|
|
|
FALSE, FALSE, 0);
|
2010-09-16 08:46:10 -07:00
|
|
|
gtk_widget_show (editor->p->title_label);
|
|
|
|
|
|
2009-12-23 13:39:47 -08:00
|
|
|
editor->p->scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
|
|
|
|
scrolled_window = GTK_SCROLLED_WINDOW (editor->p->scrolled_window);
|
2008-03-08 06:33:16 -08:00
|
|
|
|
|
|
|
|
gtk_scrolled_window_set_policy (scrolled_window,
|
2004-05-13 08:50:55 -07:00
|
|
|
GTK_POLICY_AUTOMATIC,
|
|
|
|
|
GTK_POLICY_AUTOMATIC);
|
2018-07-06 05:24:43 -07:00
|
|
|
gtk_scrolled_window_set_overlay_scrolling (scrolled_window, FALSE);
|
2008-03-08 06:33:16 -08:00
|
|
|
|
2010-10-30 06:42:25 -07:00
|
|
|
gtk_box_pack_start (GTK_BOX (editor), editor->p->scrolled_window,
|
|
|
|
|
TRUE, TRUE, 0);
|
2009-12-23 13:39:47 -08:00
|
|
|
gtk_widget_show (editor->p->scrolled_window);
|
2008-03-08 06:33:16 -08:00
|
|
|
|
2004-05-13 08:50:55 -07:00
|
|
|
/* The vbox containing the tool options */
|
2011-09-30 02:29:11 -07:00
|
|
|
editor->p->options_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
2018-07-06 05:24:43 -07:00
|
|
|
gtk_container_add (GTK_CONTAINER (scrolled_window), editor->p->options_vbox);
|
2009-12-23 13:39:47 -08:00
|
|
|
gtk_widget_show (editor->p->options_vbox);
|
2004-05-13 08:50:55 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2011-01-14 00:38:11 -08:00
|
|
|
gimp_tool_options_editor_constructed (GObject *object)
|
2004-05-13 08:50:55 -07:00
|
|
|
{
|
2011-01-14 00:38:11 -08:00
|
|
|
GimpToolOptionsEditor *editor = GIMP_TOOL_OPTIONS_EDITOR (object);
|
|
|
|
|
GimpContext *user_context;
|
2004-05-13 08:50:55 -07:00
|
|
|
|
2012-11-12 12:51:22 -08:00
|
|
|
G_OBJECT_CLASS (parent_class)->constructed (object);
|
2002-03-10 07:05:58 -08:00
|
|
|
|
2009-12-23 13:39:47 -08:00
|
|
|
editor->p->save_button =
|
2017-03-05 07:01:59 -08:00
|
|
|
gimp_editor_add_button (GIMP_EDITOR (editor),
|
|
|
|
|
GIMP_ICON_DOCUMENT_SAVE,
|
2011-03-23 01:27:29 -07:00
|
|
|
_("Save Tool Preset..."),
|
2003-09-29 13:26:09 -07:00
|
|
|
GIMP_HELP_TOOL_OPTIONS_SAVE,
|
|
|
|
|
G_CALLBACK (gimp_tool_options_editor_save_clicked),
|
2002-03-10 07:05:58 -08:00
|
|
|
NULL,
|
2023-02-09 12:50:54 -08:00
|
|
|
G_OBJECT (editor));
|
2002-03-10 07:05:58 -08:00
|
|
|
|
2009-12-23 13:39:47 -08:00
|
|
|
editor->p->restore_button =
|
2017-03-05 07:01:59 -08:00
|
|
|
gimp_editor_add_button (GIMP_EDITOR (editor),
|
|
|
|
|
GIMP_ICON_DOCUMENT_REVERT,
|
2011-03-23 01:27:29 -07:00
|
|
|
_("Restore Tool Preset..."),
|
2003-09-29 13:26:09 -07:00
|
|
|
GIMP_HELP_TOOL_OPTIONS_RESTORE,
|
|
|
|
|
G_CALLBACK (gimp_tool_options_editor_restore_clicked),
|
2002-03-10 07:05:58 -08:00
|
|
|
NULL,
|
2023-02-09 12:50:54 -08:00
|
|
|
G_OBJECT (editor));
|
2002-03-10 07:05:58 -08:00
|
|
|
|
2009-12-23 13:39:47 -08:00
|
|
|
editor->p->delete_button =
|
2017-03-05 07:01:59 -08:00
|
|
|
gimp_editor_add_button (GIMP_EDITOR (editor),
|
|
|
|
|
GIMP_ICON_EDIT_DELETE,
|
2011-03-23 01:27:29 -07:00
|
|
|
_("Delete Tool Preset..."),
|
2003-09-29 15:23:44 -07:00
|
|
|
GIMP_HELP_TOOL_OPTIONS_DELETE,
|
|
|
|
|
G_CALLBACK (gimp_tool_options_editor_delete_clicked),
|
|
|
|
|
NULL,
|
2023-02-09 12:50:54 -08:00
|
|
|
G_OBJECT (editor));
|
2003-09-29 15:23:44 -07:00
|
|
|
|
2009-12-23 13:39:47 -08:00
|
|
|
editor->p->reset_button =
|
2004-05-13 08:50:55 -07: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 07:05:58 -08:00
|
|
|
|
2009-12-24 08:40:45 -08:00
|
|
|
user_context = gimp_get_user_context (editor->p->gimp);
|
|
|
|
|
|
|
|
|
|
g_signal_connect_object (user_context, "tool-changed",
|
|
|
|
|
G_CALLBACK (gimp_tool_options_editor_tool_changed),
|
|
|
|
|
editor,
|
|
|
|
|
0);
|
|
|
|
|
|
|
|
|
|
gimp_tool_options_editor_tool_changed (user_context,
|
|
|
|
|
gimp_context_get_tool (user_context),
|
|
|
|
|
editor);
|
2003-10-10 14:24:12 -07:00
|
|
|
}
|
|
|
|
|
|
2010-09-26 13:38:01 -07:00
|
|
|
static void
|
|
|
|
|
gimp_tool_options_editor_dispose (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
GimpToolOptionsEditor *editor = GIMP_TOOL_OPTIONS_EDITOR (object);
|
|
|
|
|
|
|
|
|
|
if (editor->p->options_vbox)
|
|
|
|
|
{
|
|
|
|
|
GList *options;
|
|
|
|
|
GList *list;
|
|
|
|
|
|
|
|
|
|
options =
|
|
|
|
|
gtk_container_get_children (GTK_CONTAINER (editor->p->options_vbox));
|
|
|
|
|
|
|
|
|
|
for (list = options; list; list = g_list_next (list))
|
|
|
|
|
{
|
|
|
|
|
gtk_container_remove (GTK_CONTAINER (editor->p->options_vbox),
|
|
|
|
|
GTK_WIDGET (list->data));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_list_free (options);
|
|
|
|
|
editor->p->options_vbox = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-24 08:40:45 -08:00
|
|
|
static void
|
|
|
|
|
gimp_tool_options_editor_set_property (GObject *object,
|
|
|
|
|
guint property_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
GimpToolOptionsEditor *editor = GIMP_TOOL_OPTIONS_EDITOR (object);
|
|
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_GIMP:
|
|
|
|
|
editor->p->gimp = g_value_get_object (value);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_tool_options_editor_get_property (GObject *object,
|
|
|
|
|
guint property_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
GimpToolOptionsEditor *editor = GIMP_TOOL_OPTIONS_EDITOR (object);
|
|
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_GIMP:
|
|
|
|
|
g_value_set_object (value, editor->p->gimp);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-10 14:24:12 -07:00
|
|
|
static GtkWidget *
|
|
|
|
|
gimp_tool_options_editor_get_preview (GimpDocked *docked,
|
|
|
|
|
GimpContext *context,
|
|
|
|
|
GtkIconSize size)
|
|
|
|
|
{
|
2018-04-28 17:53:51 -07:00
|
|
|
GtkWidget *view;
|
|
|
|
|
gint width;
|
|
|
|
|
gint height;
|
2003-10-10 14:24:12 -07:00
|
|
|
|
2018-04-28 17:53:51 -07:00
|
|
|
gtk_icon_size_lookup (size, &width, &height);
|
2006-08-29 14:44:51 -07:00
|
|
|
view = gimp_prop_view_new (G_OBJECT (context), "tool", context, height);
|
2004-08-24 10:16:46 -07:00
|
|
|
GIMP_VIEW (view)->renderer->size = -1;
|
2004-08-25 15:31:44 -07:00
|
|
|
gimp_view_renderer_set_size_full (GIMP_VIEW (view)->renderer,
|
|
|
|
|
width, height, 0);
|
2003-10-10 14:24:12 -07:00
|
|
|
|
2004-08-24 10:16:46 -07:00
|
|
|
return view;
|
2003-10-21 07:49:12 -07:00
|
|
|
}
|
2003-10-10 14:24:12 -07:00
|
|
|
|
2003-10-21 07:49:12 -07: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-10 14:24:12 -07:00
|
|
|
|
2009-12-23 13:39:47 -08:00
|
|
|
context = gimp_get_user_context (editor->p->gimp);
|
2003-10-10 14:24:12 -07:00
|
|
|
|
2003-10-21 07:49:12 -07:00
|
|
|
tool_info = gimp_context_get_tool (context);
|
2003-10-10 14:24:12 -07:00
|
|
|
|
2017-07-04 12:58:11 -07:00
|
|
|
return tool_info ? g_strdup (tool_info->label) : NULL;
|
2003-10-10 14:24:12 -07:00
|
|
|
}
|
|
|
|
|
|
2010-06-11 14:18:49 -07:00
|
|
|
static gboolean
|
|
|
|
|
gimp_tool_options_editor_get_prefer_icon (GimpDocked *docked)
|
|
|
|
|
{
|
|
|
|
|
/* We support get_preview() for tab tyles, but we prefer to show our
|
|
|
|
|
* icon
|
|
|
|
|
*/
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2004-05-13 08:50:55 -07:00
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
|
2003-09-29 13:26:09 -07:00
|
|
|
GtkWidget *
|
|
|
|
|
gimp_tool_options_editor_new (Gimp *gimp,
|
|
|
|
|
GimpMenuFactory *menu_factory)
|
2001-01-21 21:08:44 -08:00
|
|
|
{
|
2003-09-29 13:26:09 -07: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-09 09:32:52 -08:00
|
|
|
|
2009-12-24 08:40:45 -08:00
|
|
|
return g_object_new (GIMP_TYPE_TOOL_OPTIONS_EDITOR,
|
|
|
|
|
"gimp", gimp,
|
|
|
|
|
"menu-factory", menu_factory,
|
|
|
|
|
"menu-identifier", "<ToolOptions>",
|
|
|
|
|
"ui-path", "/tool-options-popup",
|
|
|
|
|
NULL);
|
2001-02-23 13:32:47 -08:00
|
|
|
}
|
2001-01-21 21:08:44 -08:00
|
|
|
|
2009-12-24 08:31:45 -08:00
|
|
|
GimpToolOptions *
|
|
|
|
|
gimp_tool_options_editor_get_tool_options (GimpToolOptionsEditor *editor)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_TOOL_OPTIONS_EDITOR (editor), NULL);
|
|
|
|
|
|
|
|
|
|
return editor->p->visible_tool_options;
|
|
|
|
|
}
|
2004-05-13 08:50:55 -07:00
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
2003-09-29 15:23:44 -07:00
|
|
|
static void
|
|
|
|
|
gimp_tool_options_editor_menu_popup (GimpToolOptionsEditor *editor,
|
|
|
|
|
GtkWidget *button,
|
|
|
|
|
const gchar *path)
|
|
|
|
|
{
|
2004-04-22 10:14:22 -07:00
|
|
|
GimpEditor *gimp_editor = GIMP_EDITOR (editor);
|
|
|
|
|
|
2011-04-09 10:51:51 -07:00
|
|
|
gimp_ui_manager_update (gimp_editor_get_ui_manager (gimp_editor),
|
|
|
|
|
gimp_editor_get_popup_data (gimp_editor));
|
2004-04-29 05:52:29 -07:00
|
|
|
|
2018-05-01 15:44:38 -07:00
|
|
|
gimp_ui_manager_ui_popup_at_widget (gimp_editor_get_ui_manager (gimp_editor),
|
2023-02-27 09:49:45 -08:00
|
|
|
path, NULL, NULL,
|
2018-05-01 15:44:38 -07:00
|
|
|
button,
|
|
|
|
|
GDK_GRAVITY_WEST,
|
|
|
|
|
GDK_GRAVITY_NORTH_EAST,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL, NULL);
|
2003-09-29 15:23:44 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_tool_options_editor_save_clicked (GtkWidget *widget,
|
|
|
|
|
GimpToolOptionsEditor *editor)
|
|
|
|
|
{
|
2009-12-23 13:39:47 -08:00
|
|
|
if (gtk_widget_get_sensitive (editor->p->restore_button) /* evil but correct */)
|
2003-09-29 15:56:46 -07:00
|
|
|
{
|
2004-04-30 08:29:11 -07:00
|
|
|
gimp_tool_options_editor_menu_popup (editor, widget,
|
2023-03-03 04:59:24 -08:00
|
|
|
"/tool-options-popup/Tool Options Menu/Save Tool Preset");
|
2003-09-29 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2011-04-09 10:51:51 -07:00
|
|
|
gimp_ui_manager_activate_action (gimp_editor_get_ui_manager (GIMP_EDITOR (editor)),
|
2006-12-15 04:03:47 -08:00
|
|
|
"tool-options",
|
2011-03-23 01:27:29 -07:00
|
|
|
"tool-options-save-new-preset");
|
2003-09-29 15:56:46 -07:00
|
|
|
}
|
2001-01-21 21:08:44 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2003-09-29 13:26:09 -07:00
|
|
|
gimp_tool_options_editor_restore_clicked (GtkWidget *widget,
|
|
|
|
|
GimpToolOptionsEditor *editor)
|
2001-01-21 21:08:44 -08:00
|
|
|
{
|
2004-04-30 08:29:11 -07:00
|
|
|
gimp_tool_options_editor_menu_popup (editor, widget,
|
2023-03-03 04:59:24 -08:00
|
|
|
"/tool-options-popup/Tool Options Menu/Restore Tool Preset");
|
2003-09-29 15:23:44 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_tool_options_editor_delete_clicked (GtkWidget *widget,
|
|
|
|
|
GimpToolOptionsEditor *editor)
|
|
|
|
|
{
|
2004-04-30 08:29:11 -07:00
|
|
|
gimp_tool_options_editor_menu_popup (editor, widget,
|
2023-03-03 04:59:24 -08:00
|
|
|
"/tool-options-popup/Tool Options Menu/Delete Tool Preset");
|
2003-09-29 13:26:09 -07:00
|
|
|
}
|
2003-02-08 07:27:51 -08:00
|
|
|
|
2003-09-29 13:26:09 -07:00
|
|
|
static void
|
|
|
|
|
gimp_tool_options_editor_drop_tool (GtkWidget *widget,
|
2004-12-31 06:36:30 -08:00
|
|
|
gint x,
|
|
|
|
|
gint y,
|
2003-09-29 13:26:09 -07:00
|
|
|
GimpViewable *viewable,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GimpToolOptionsEditor *editor = GIMP_TOOL_OPTIONS_EDITOR (data);
|
|
|
|
|
GimpContext *context;
|
2003-03-26 05:39:00 -08:00
|
|
|
|
2009-12-23 13:39:47 -08:00
|
|
|
context = gimp_get_user_context (editor->p->gimp);
|
2003-03-26 05:39:00 -08:00
|
|
|
|
2003-09-29 13:26:09 -07:00
|
|
|
gimp_context_set_tool (context, GIMP_TOOL_INFO (viewable));
|
2001-01-21 21:08:44 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2003-09-29 13:26:09 -07:00
|
|
|
gimp_tool_options_editor_tool_changed (GimpContext *context,
|
|
|
|
|
GimpToolInfo *tool_info,
|
|
|
|
|
GimpToolOptionsEditor *editor)
|
2001-01-21 21:08:44 -08:00
|
|
|
{
|
2011-03-23 01:27:29 -07:00
|
|
|
GimpContainer *presets;
|
|
|
|
|
GtkWidget *options_gui;
|
2003-09-29 13:26:09 -07:00
|
|
|
|
2009-12-23 13:39:47 -08:00
|
|
|
if (tool_info && tool_info->tool_options == editor->p->visible_tool_options)
|
2003-09-29 15:56:46 -07:00
|
|
|
return;
|
|
|
|
|
|
2009-12-23 13:39:47 -08:00
|
|
|
if (editor->p->visible_tool_options)
|
2003-09-29 13:26:09 -07:00
|
|
|
{
|
2009-12-23 13:39:47 -08:00
|
|
|
presets = editor->p->visible_tool_options->tool_info->presets;
|
2003-09-29 15:56:46 -07:00
|
|
|
|
|
|
|
|
if (presets)
|
|
|
|
|
g_signal_handlers_disconnect_by_func (presets,
|
2011-03-23 01:27:29 -07:00
|
|
|
gimp_tool_options_editor_presets_update,
|
2003-09-29 15:56:46 -07:00
|
|
|
editor);
|
|
|
|
|
|
2010-10-31 05:05:15 -07:00
|
|
|
options_gui = gimp_tools_get_tool_options_gui (editor->p->visible_tool_options);
|
2003-09-29 13:26:09 -07:00
|
|
|
|
|
|
|
|
if (options_gui)
|
|
|
|
|
gtk_widget_hide (options_gui);
|
|
|
|
|
|
2009-12-23 13:39:47 -08:00
|
|
|
editor->p->visible_tool_options = NULL;
|
2003-09-29 13:26:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (tool_info && tool_info->tool_options)
|
|
|
|
|
{
|
2006-12-10 11:13:58 -08:00
|
|
|
presets = tool_info->presets;
|
2003-09-29 15:56:46 -07:00
|
|
|
|
|
|
|
|
if (presets)
|
2011-03-23 01:27:29 -07:00
|
|
|
{
|
|
|
|
|
g_signal_connect_object (presets, "add",
|
|
|
|
|
G_CALLBACK (gimp_tool_options_editor_presets_update),
|
|
|
|
|
G_OBJECT (editor), G_CONNECT_SWAPPED);
|
|
|
|
|
g_signal_connect_object (presets, "remove",
|
|
|
|
|
G_CALLBACK (gimp_tool_options_editor_presets_update),
|
|
|
|
|
G_OBJECT (editor), G_CONNECT_SWAPPED);
|
|
|
|
|
g_signal_connect_object (presets, "thaw",
|
|
|
|
|
G_CALLBACK (gimp_tool_options_editor_presets_update),
|
|
|
|
|
G_OBJECT (editor), G_CONNECT_SWAPPED);
|
|
|
|
|
}
|
2003-09-29 15:56:46 -07:00
|
|
|
|
2010-10-31 05:05:15 -07:00
|
|
|
options_gui = gimp_tools_get_tool_options_gui (tool_info->tool_options);
|
2003-09-29 13:26:09 -07:00
|
|
|
|
2008-06-28 08:50:27 -07:00
|
|
|
if (! gtk_widget_get_parent (options_gui))
|
2009-12-23 13:39:47 -08:00
|
|
|
gtk_box_pack_start (GTK_BOX (editor->p->options_vbox), options_gui,
|
2003-09-29 13:26:09 -07:00
|
|
|
FALSE, FALSE, 0);
|
2001-07-07 10:36:00 -07:00
|
|
|
|
2003-09-29 13:26:09 -07:00
|
|
|
gtk_widget_show (options_gui);
|
|
|
|
|
|
2009-12-23 13:39:47 -08:00
|
|
|
editor->p->visible_tool_options = tool_info->tool_options;
|
2004-01-30 14:10:31 -08:00
|
|
|
|
2009-12-23 13:39:47 -08:00
|
|
|
gimp_help_set_help_data (editor->p->scrolled_window, NULL,
|
2004-01-30 14:10:31 -08:00
|
|
|
tool_info->help_id);
|
2001-02-23 13:32:47 -08:00
|
|
|
|
2011-06-29 13:51:10 -07:00
|
|
|
gimp_tool_options_editor_presets_update (editor);
|
|
|
|
|
}
|
2003-10-21 07:49:12 -07:00
|
|
|
|
2010-09-16 08:46:10 -07:00
|
|
|
if (editor->p->title_label != NULL)
|
|
|
|
|
{
|
2010-09-16 12:06:56 -07:00
|
|
|
gchar *title;
|
|
|
|
|
|
|
|
|
|
title = gimp_docked_get_title (GIMP_DOCKED (editor));
|
|
|
|
|
gtk_label_set_text (GTK_LABEL (editor->p->title_label), title);
|
2010-09-16 08:46:10 -07:00
|
|
|
g_free (title);
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-21 07:49:12 -07:00
|
|
|
gimp_docked_title_changed (GIMP_DOCKED (editor));
|
2003-09-29 15:56:46 -07:00
|
|
|
}
|
|
|
|
|
|
2006-12-11 07:16:13 -08:00
|
|
|
static void
|
2011-03-23 01:27:29 -07:00
|
|
|
gimp_tool_options_editor_presets_update (GimpToolOptionsEditor *editor)
|
2003-09-29 15:56:46 -07:00
|
|
|
{
|
2011-03-23 01:27:29 -07:00
|
|
|
GimpToolInfo *tool_info = editor->p->visible_tool_options->tool_info;
|
|
|
|
|
gboolean save_sensitive = FALSE;
|
|
|
|
|
gboolean restore_sensitive = FALSE;
|
|
|
|
|
gboolean delete_sensitive = FALSE;
|
|
|
|
|
gboolean reset_sensitive = FALSE;
|
2003-09-29 15:56:46 -07:00
|
|
|
|
2011-03-23 01:27:29 -07:00
|
|
|
if (tool_info->presets)
|
2003-09-29 15:56:46 -07:00
|
|
|
{
|
|
|
|
|
save_sensitive = TRUE;
|
|
|
|
|
reset_sensitive = TRUE;
|
|
|
|
|
|
2011-03-23 01:27:29 -07:00
|
|
|
if (! gimp_container_is_empty (tool_info->presets))
|
2003-09-29 15:56:46 -07:00
|
|
|
{
|
|
|
|
|
restore_sensitive = TRUE;
|
|
|
|
|
delete_sensitive = TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-02-23 13:32:47 -08:00
|
|
|
|
2009-12-23 13:39:47 -08:00
|
|
|
gtk_widget_set_sensitive (editor->p->save_button, save_sensitive);
|
|
|
|
|
gtk_widget_set_sensitive (editor->p->restore_button, restore_sensitive);
|
|
|
|
|
gtk_widget_set_sensitive (editor->p->delete_button, delete_sensitive);
|
|
|
|
|
gtk_widget_set_sensitive (editor->p->reset_button, reset_sensitive);
|
2001-01-21 21:08:44 -08:00
|
|
|
}
|