2006-12-09 21:33:38 +00:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2001-01-22 03:30:42 +00:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-17 22:28:01 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2001-01-22 03:30:42 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 22:28:01 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2001-01-22 03:30:42 +00: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 23:27:07 +02:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2001-01-22 03:30:42 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2001-02-04 04:51:17 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2012-03-29 19:19:01 +02:00
|
|
|
#include <gegl.h>
|
2001-01-22 03:30:42 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2003-08-21 16:20:28 +00:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-01-24 22:36:18 +00:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2002-03-14 17:07:02 +00:00
|
|
|
#include "widgets-types.h"
|
2001-01-22 03:30:42 +00:00
|
|
|
|
2003-11-20 20:36:55 +00:00
|
|
|
#include "config/gimpguiconfig.h"
|
|
|
|
|
2001-07-04 19:31:35 +00:00
|
|
|
#include "core/gimp.h"
|
2001-05-09 02:32:03 +00:00
|
|
|
#include "core/gimpcontext.h"
|
2021-07-05 12:33:35 +02:00
|
|
|
#include "core/gimpdisplay.h"
|
|
|
|
|
2005-02-11 01:23:41 +00:00
|
|
|
#include "file/file-open.h"
|
|
|
|
|
2012-04-10 12:09:37 +02:00
|
|
|
#include "gimpcairo-wilber.h"
|
2002-03-14 17:07:02 +00:00
|
|
|
#include "gimpdevices.h"
|
|
|
|
#include "gimpdialogfactory.h"
|
2009-09-15 07:58:14 +02:00
|
|
|
#include "gimpdockwindow.h"
|
2003-08-22 01:42:57 +00:00
|
|
|
#include "gimphelp-ids.h"
|
2010-01-22 20:48:34 +01:00
|
|
|
#include "gimppanedbox.h"
|
2024-07-27 15:39:05 +00:00
|
|
|
#include "gimpviewrenderer.h"
|
2002-03-14 17:07:02 +00:00
|
|
|
#include "gimptoolbox.h"
|
|
|
|
#include "gimptoolbox-color-area.h"
|
2003-06-06 15:14:47 +00:00
|
|
|
#include "gimptoolbox-dnd.h"
|
2004-05-31 20:30:52 +00:00
|
|
|
#include "gimptoolbox-image-area.h"
|
2002-03-14 17:07:02 +00:00
|
|
|
#include "gimptoolbox-indicator-area.h"
|
2010-11-19 23:52:09 +01:00
|
|
|
#include "gimptoolpalette.h"
|
2004-04-29 12:52:29 +00:00
|
|
|
#include "gimpuimanager.h"
|
2024-07-27 15:39:05 +00:00
|
|
|
#include "gimpview.h"
|
2003-07-02 09:54:48 +00:00
|
|
|
#include "gimpwidgets-utils.h"
|
2001-04-17 21:43:29 +00:00
|
|
|
|
2006-02-07 11:07:47 +00:00
|
|
|
#include "about.h"
|
|
|
|
|
2003-03-25 16:38:19 +00:00
|
|
|
#include "gimp-intl.h"
|
2001-01-22 03:30:42 +00:00
|
|
|
|
|
|
|
|
2009-12-05 21:20:18 +01:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
2011-08-07 19:49:37 +02:00
|
|
|
PROP_CONTEXT
|
2009-12-05 21:20:18 +01:00
|
|
|
};
|
|
|
|
|
2002-03-18 19:34:06 +00:00
|
|
|
|
2009-10-04 15:43:03 +02:00
|
|
|
struct _GimpToolboxPrivate
|
|
|
|
{
|
2009-12-05 21:20:18 +01:00
|
|
|
GimpContext *context;
|
2009-10-04 15:43:03 +02:00
|
|
|
|
2009-12-05 21:20:18 +01:00
|
|
|
GtkWidget *vbox;
|
2009-10-04 15:43:03 +02:00
|
|
|
|
2009-12-05 21:20:18 +01:00
|
|
|
GtkWidget *header;
|
2010-05-10 17:30:17 +02:00
|
|
|
GtkWidget *tool_palette;
|
2010-11-24 20:45:14 +01:00
|
|
|
GtkWidget *area_box;
|
2009-12-05 21:20:18 +01:00
|
|
|
GtkWidget *color_area;
|
|
|
|
GtkWidget *foo_area;
|
|
|
|
GtkWidget *image_area;
|
2009-10-04 15:43:03 +02:00
|
|
|
|
2009-12-05 21:20:18 +01:00
|
|
|
gint area_rows;
|
|
|
|
gint area_columns;
|
2010-01-22 20:48:34 +01:00
|
|
|
|
|
|
|
GimpPanedBox *drag_handler;
|
2010-05-10 17:54:49 +02:00
|
|
|
|
|
|
|
gboolean in_destruction;
|
2009-10-04 15:43:03 +02:00
|
|
|
};
|
|
|
|
|
2001-12-12 01:16:39 +00:00
|
|
|
|
2011-08-07 19:49:37 +02:00
|
|
|
static void gimp_toolbox_constructed (GObject *object);
|
|
|
|
static void gimp_toolbox_dispose (GObject *object);
|
2010-11-19 23:52:09 +01:00
|
|
|
static void gimp_toolbox_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gimp_toolbox_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
2018-06-05 18:42:46 +02:00
|
|
|
|
2024-07-27 15:39:05 +00:00
|
|
|
static void gimp_toolbox_style_updated (GtkWidget *widget);
|
2010-11-19 23:52:09 +01:00
|
|
|
static gboolean gimp_toolbox_button_press_event (GtkWidget *widget,
|
|
|
|
GdkEventButton *event);
|
|
|
|
static void gimp_toolbox_drag_leave (GtkWidget *widget,
|
|
|
|
GdkDragContext *context,
|
|
|
|
guint time,
|
|
|
|
GimpToolbox *toolbox);
|
|
|
|
static gboolean gimp_toolbox_drag_motion (GtkWidget *widget,
|
|
|
|
GdkDragContext *context,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
guint time,
|
|
|
|
GimpToolbox *toolbox);
|
|
|
|
static gboolean gimp_toolbox_drag_drop (GtkWidget *widget,
|
|
|
|
GdkDragContext *context,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
guint time,
|
|
|
|
GimpToolbox *toolbox);
|
|
|
|
static gchar * gimp_toolbox_get_description (GimpDock *dock,
|
|
|
|
gboolean complete);
|
|
|
|
static void gimp_toolbox_set_host_geometry_hints (GimpDock *dock,
|
|
|
|
GtkWindow *window);
|
|
|
|
static void gimp_toolbox_book_added (GimpDock *dock,
|
|
|
|
GimpDockbook *dockbook);
|
|
|
|
static void gimp_toolbox_book_removed (GimpDock *dock,
|
|
|
|
GimpDockbook *dockbook);
|
2022-09-26 21:53:13 +02:00
|
|
|
|
|
|
|
static void gimp_toolbox_notify_theme (GimpGuiConfig *config,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GimpToolbox *toolbox);
|
|
|
|
|
|
|
|
static void gimp_toolbox_palette_style_updated (GtkWidget *palette,
|
|
|
|
GimpToolbox *toolbox);
|
|
|
|
|
2011-11-04 00:28:04 +01:00
|
|
|
static void gimp_toolbox_wilber_style_updated (GtkWidget *widget,
|
2011-11-02 00:31:23 +01:00
|
|
|
GimpToolbox *toolbox);
|
2022-09-26 21:53:13 +02:00
|
|
|
static gboolean gimp_toolbox_draw_wilber (GtkWidget *widget,
|
|
|
|
cairo_t *cr);
|
2010-11-19 23:52:09 +01:00
|
|
|
static GtkWidget * toolbox_create_color_area (GimpToolbox *toolbox,
|
|
|
|
GimpContext *context);
|
|
|
|
static GtkWidget * toolbox_create_foo_area (GimpToolbox *toolbox,
|
|
|
|
GimpContext *context);
|
|
|
|
static GtkWidget * toolbox_create_image_area (GimpToolbox *toolbox,
|
|
|
|
GimpContext *context);
|
|
|
|
static void toolbox_paste_received (GtkClipboard *clipboard,
|
|
|
|
const gchar *text,
|
|
|
|
gpointer data);
|
2005-02-11 01:23:41 +00:00
|
|
|
|
2001-01-22 03:30:42 +00: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 12:09:39 -04:00
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (GimpToolbox, gimp_toolbox, GIMP_TYPE_DOCK)
|
2002-03-14 17:07:02 +00:00
|
|
|
|
2005-12-19 22:37:49 +00:00
|
|
|
#define parent_class gimp_toolbox_parent_class
|
2001-01-22 03:30:42 +00:00
|
|
|
|
2002-03-14 17:07:02 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_toolbox_class_init (GimpToolboxClass *klass)
|
|
|
|
{
|
2009-09-13 09:22:59 +02:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
|
|
|
GimpDockClass *dock_class = GIMP_DOCK_CLASS (klass);
|
2002-03-14 17:07:02 +00:00
|
|
|
|
2010-11-19 23:52:09 +01:00
|
|
|
object_class->constructed = gimp_toolbox_constructed;
|
2010-05-10 17:54:49 +02:00
|
|
|
object_class->dispose = gimp_toolbox_dispose;
|
2009-12-05 21:20:18 +01:00
|
|
|
object_class->set_property = gimp_toolbox_set_property;
|
|
|
|
object_class->get_property = gimp_toolbox_get_property;
|
2004-05-17 13:38:03 +00:00
|
|
|
|
2009-09-13 14:14:08 +02:00
|
|
|
widget_class->button_press_event = gimp_toolbox_button_press_event;
|
2024-07-27 15:39:05 +00:00
|
|
|
widget_class->style_updated = gimp_toolbox_style_updated;
|
2002-03-18 19:34:06 +00:00
|
|
|
|
2010-03-13 17:18:47 +01:00
|
|
|
dock_class->get_description = gimp_toolbox_get_description;
|
2009-09-13 14:14:08 +02:00
|
|
|
dock_class->set_host_geometry_hints = gimp_toolbox_set_host_geometry_hints;
|
|
|
|
dock_class->book_added = gimp_toolbox_book_added;
|
|
|
|
dock_class->book_removed = gimp_toolbox_book_removed;
|
2002-10-25 13:21:54 +00:00
|
|
|
|
2009-12-05 21:20:18 +01:00
|
|
|
g_object_class_install_property (object_class, PROP_CONTEXT,
|
|
|
|
g_param_spec_object ("context",
|
|
|
|
NULL, NULL,
|
|
|
|
GIMP_TYPE_CONTEXT,
|
|
|
|
GIMP_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT));
|
2002-03-14 17:07:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_toolbox_init (GimpToolbox *toolbox)
|
2001-01-22 03:30:42 +00: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 12:09:39 -04:00
|
|
|
toolbox->p = gimp_toolbox_get_instance_private (toolbox);
|
2009-10-04 15:43:03 +02:00
|
|
|
|
2024-08-24 23:03:04 +02:00
|
|
|
gimp_help_connect (GTK_WIDGET (toolbox), NULL, gimp_standard_help_func,
|
2019-08-09 13:11:30 +02:00
|
|
|
GIMP_HELP_TOOLBOX, NULL, NULL);
|
2004-05-17 13:38:03 +00:00
|
|
|
}
|
|
|
|
|
2010-11-19 23:52:09 +01:00
|
|
|
static void
|
|
|
|
gimp_toolbox_constructed (GObject *object)
|
2004-05-17 13:38:03 +00:00
|
|
|
{
|
2011-02-06 13:37:33 +01:00
|
|
|
GimpToolbox *toolbox = GIMP_TOOLBOX (object);
|
|
|
|
GimpGuiConfig *config;
|
|
|
|
GtkWidget *main_vbox;
|
2021-07-05 12:33:35 +02:00
|
|
|
GtkWidget *event_box;
|
2002-03-14 17:07:02 +00:00
|
|
|
|
2018-02-11 22:23:10 +01:00
|
|
|
gimp_assert (GIMP_IS_CONTEXT (toolbox->p->context));
|
2010-11-20 15:18:09 +01:00
|
|
|
|
2010-11-19 23:52:09 +01:00
|
|
|
config = GIMP_GUI_CONFIG (toolbox->p->context->gimp->config);
|
2004-05-17 13:38:03 +00:00
|
|
|
|
2009-01-04 10:28:31 +00:00
|
|
|
main_vbox = gimp_dock_get_main_vbox (GIMP_DOCK (toolbox));
|
2002-03-14 17:07:02 +00:00
|
|
|
|
2011-09-30 11:29:11 +02:00
|
|
|
toolbox->p->vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
|
2009-10-04 15:43:03 +02:00
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), toolbox->p->vbox, FALSE, FALSE, 0);
|
|
|
|
gtk_box_reorder_child (GTK_BOX (main_vbox), toolbox->p->vbox, 0);
|
2024-05-29 13:43:17 +00:00
|
|
|
gtk_widget_set_visible (toolbox->p->vbox, TRUE);
|
2002-03-14 17:07:02 +00:00
|
|
|
|
2010-01-22 20:48:34 +01:00
|
|
|
/* Use g_signal_connect() also for the toolbox itself so we can pass
|
|
|
|
* data and reuse the same function for the vbox
|
|
|
|
*/
|
|
|
|
g_signal_connect (toolbox, "drag-leave",
|
|
|
|
G_CALLBACK (gimp_toolbox_drag_leave),
|
|
|
|
toolbox);
|
|
|
|
g_signal_connect (toolbox, "drag-motion",
|
|
|
|
G_CALLBACK (gimp_toolbox_drag_motion),
|
|
|
|
toolbox);
|
|
|
|
g_signal_connect (toolbox, "drag-drop",
|
|
|
|
G_CALLBACK (gimp_toolbox_drag_drop),
|
|
|
|
toolbox);
|
|
|
|
g_signal_connect (toolbox->p->vbox, "drag-leave",
|
|
|
|
G_CALLBACK (gimp_toolbox_drag_leave),
|
|
|
|
toolbox);
|
|
|
|
g_signal_connect (toolbox->p->vbox, "drag-motion",
|
|
|
|
G_CALLBACK (gimp_toolbox_drag_motion),
|
|
|
|
toolbox);
|
|
|
|
g_signal_connect (toolbox->p->vbox, "drag-drop",
|
|
|
|
G_CALLBACK (gimp_toolbox_drag_drop),
|
|
|
|
toolbox);
|
|
|
|
|
2024-07-27 15:39:05 +00:00
|
|
|
g_signal_connect_object (config,
|
|
|
|
"notify::theme",
|
|
|
|
G_CALLBACK (gimp_toolbox_style_updated),
|
|
|
|
toolbox, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
|
|
|
|
g_signal_connect_object (config,
|
|
|
|
"notify::override-theme-icon-size",
|
|
|
|
G_CALLBACK (gimp_toolbox_style_updated),
|
|
|
|
toolbox, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
|
|
|
|
g_signal_connect_object (config,
|
|
|
|
"notify::custom-icon-size",
|
|
|
|
G_CALLBACK (gimp_toolbox_style_updated),
|
|
|
|
toolbox, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
|
|
|
|
|
2021-07-05 12:33:35 +02:00
|
|
|
event_box = gtk_event_box_new ();
|
|
|
|
gtk_box_pack_start (GTK_BOX (toolbox->p->vbox), event_box, FALSE, FALSE, 0);
|
|
|
|
g_signal_connect_swapped (event_box, "button-press-event",
|
|
|
|
G_CALLBACK (gimp_toolbox_button_press_event),
|
|
|
|
toolbox);
|
2024-05-29 13:43:17 +00:00
|
|
|
gtk_widget_set_visible (event_box, TRUE);
|
2021-07-05 12:33:35 +02:00
|
|
|
|
2009-10-04 15:43:03 +02:00
|
|
|
toolbox->p->header = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (toolbox->p->header), GTK_SHADOW_NONE);
|
2021-07-05 12:33:35 +02:00
|
|
|
gtk_container_add (GTK_CONTAINER (event_box), toolbox->p->header);
|
2008-08-28 14:30:47 +00:00
|
|
|
|
2012-10-31 23:15:42 +01:00
|
|
|
g_object_bind_property (config, "toolbox-wilber",
|
|
|
|
toolbox->p->header, "visible",
|
|
|
|
G_BINDING_SYNC_CREATE);
|
2008-03-26 20:27:44 +00:00
|
|
|
|
2011-11-04 00:28:04 +01:00
|
|
|
g_signal_connect (toolbox->p->header, "style-updated",
|
|
|
|
G_CALLBACK (gimp_toolbox_wilber_style_updated),
|
2011-11-02 00:31:23 +01:00
|
|
|
toolbox);
|
2010-10-15 16:07:18 +02:00
|
|
|
g_signal_connect (toolbox->p->header, "draw",
|
|
|
|
G_CALLBACK (gimp_toolbox_draw_wilber),
|
2010-10-15 16:03:36 +02:00
|
|
|
toolbox);
|
|
|
|
|
2009-10-04 15:43:03 +02:00
|
|
|
gimp_help_set_help_data (toolbox->p->header,
|
2008-03-26 20:47:45 +00:00
|
|
|
_("Drop image files here to open them"), NULL);
|
|
|
|
|
2011-08-07 19:49:37 +02:00
|
|
|
toolbox->p->tool_palette = gimp_tool_palette_new ();
|
|
|
|
gimp_tool_palette_set_toolbox (GIMP_TOOL_PALETTE (toolbox->p->tool_palette),
|
|
|
|
toolbox);
|
2010-05-10 17:30:17 +02:00
|
|
|
gtk_box_pack_start (GTK_BOX (toolbox->p->vbox), toolbox->p->tool_palette,
|
2010-11-19 23:52:09 +01:00
|
|
|
FALSE, FALSE, 0);
|
2024-05-29 13:43:17 +00:00
|
|
|
gtk_widget_set_visible (toolbox->p->tool_palette, TRUE);
|
2004-05-31 20:30:52 +00:00
|
|
|
|
2018-06-05 18:42:46 +02:00
|
|
|
toolbox->p->area_box = gtk_flow_box_new ();
|
|
|
|
gtk_flow_box_set_selection_mode (GTK_FLOW_BOX (toolbox->p->area_box),
|
|
|
|
GTK_SELECTION_NONE);
|
2010-11-24 20:45:14 +01:00
|
|
|
gtk_box_pack_start (GTK_BOX (toolbox->p->vbox), toolbox->p->area_box,
|
2008-03-26 20:47:45 +00:00
|
|
|
FALSE, FALSE, 0);
|
2024-05-29 13:43:17 +00:00
|
|
|
gtk_widget_set_visible (toolbox->p->area_box, TRUE);
|
2004-05-17 13:38:03 +00:00
|
|
|
|
2011-02-06 13:37:33 +01:00
|
|
|
gtk_widget_add_events (GTK_WIDGET (toolbox), GDK_POINTER_MOTION_MASK);
|
|
|
|
gimp_devices_add_widget (toolbox->p->context->gimp, GTK_WIDGET (toolbox));
|
2004-05-17 13:38:03 +00:00
|
|
|
|
2010-11-20 15:18:09 +01:00
|
|
|
toolbox->p->color_area = toolbox_create_color_area (toolbox,
|
|
|
|
toolbox->p->context);
|
2018-06-05 18:42:46 +02:00
|
|
|
gtk_flow_box_insert (GTK_FLOW_BOX (toolbox->p->area_box),
|
|
|
|
toolbox->p->color_area, -1);
|
2004-05-31 20:30:52 +00:00
|
|
|
|
2018-06-05 18:42:46 +02:00
|
|
|
g_object_bind_property (config, "toolbox-color-area",
|
|
|
|
toolbox->p->color_area, "visible",
|
|
|
|
G_BINDING_SYNC_CREATE);
|
2004-05-31 20:30:52 +00:00
|
|
|
|
2009-12-05 21:20:18 +01:00
|
|
|
toolbox->p->foo_area = toolbox_create_foo_area (toolbox, toolbox->p->context);
|
2018-06-05 18:42:46 +02:00
|
|
|
gtk_flow_box_insert (GTK_FLOW_BOX (toolbox->p->area_box),
|
|
|
|
toolbox->p->foo_area, -1);
|
2004-05-31 20:30:52 +00:00
|
|
|
|
2018-06-05 18:42:46 +02:00
|
|
|
g_object_bind_property (config, "toolbox-foo-area",
|
|
|
|
toolbox->p->foo_area, "visible",
|
|
|
|
G_BINDING_SYNC_CREATE);
|
2004-05-31 20:30:52 +00:00
|
|
|
|
2010-11-20 15:18:09 +01:00
|
|
|
toolbox->p->image_area = toolbox_create_image_area (toolbox,
|
|
|
|
toolbox->p->context);
|
2018-06-05 18:42:46 +02:00
|
|
|
gtk_flow_box_insert (GTK_FLOW_BOX (toolbox->p->area_box),
|
|
|
|
toolbox->p->image_area, -1);
|
2004-05-31 20:30:52 +00:00
|
|
|
|
2018-06-05 18:42:46 +02:00
|
|
|
g_object_bind_property (config, "toolbox-image-area",
|
|
|
|
toolbox->p->image_area, "visible",
|
|
|
|
G_BINDING_SYNC_CREATE);
|
2004-05-31 20:30:52 +00:00
|
|
|
|
2010-11-20 15:18:09 +01:00
|
|
|
gimp_toolbox_dnd_init (GIMP_TOOLBOX (toolbox), toolbox->p->vbox);
|
2002-03-14 17:07:02 +00:00
|
|
|
}
|
|
|
|
|
2010-05-10 17:54:49 +02:00
|
|
|
static void
|
|
|
|
gimp_toolbox_dispose (GObject *object)
|
|
|
|
{
|
|
|
|
GimpToolbox *toolbox = GIMP_TOOLBOX (object);
|
|
|
|
|
|
|
|
toolbox->p->in_destruction = TRUE;
|
|
|
|
|
2017-07-15 18:38:01 +02:00
|
|
|
g_clear_object (&toolbox->p->context);
|
2010-06-24 12:49:54 +02:00
|
|
|
|
2010-05-10 17:54:49 +02:00
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
|
|
|
|
|
|
toolbox->p->in_destruction = FALSE;
|
|
|
|
}
|
|
|
|
|
2009-12-05 21:20:18 +01:00
|
|
|
static void
|
|
|
|
gimp_toolbox_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpToolbox *toolbox = GIMP_TOOLBOX (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_CONTEXT:
|
|
|
|
toolbox->p->context = g_value_dup_object (value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_toolbox_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpToolbox *toolbox = GIMP_TOOLBOX (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_CONTEXT:
|
|
|
|
g_value_set_object (value, toolbox->p->context);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-27 15:39:05 +00:00
|
|
|
static void
|
|
|
|
gimp_toolbox_style_updated (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
GimpToolbox *toolbox = GIMP_TOOLBOX (widget);
|
|
|
|
GtkWidget *area;
|
|
|
|
GtkIconSize tool_icon_size;
|
|
|
|
gint pixel_size;
|
|
|
|
gint width;
|
|
|
|
gint height;
|
|
|
|
|
|
|
|
gtk_widget_style_get (widget,
|
|
|
|
"tool-icon-size", &tool_icon_size,
|
|
|
|
NULL);
|
|
|
|
gtk_icon_size_lookup (tool_icon_size, &pixel_size, NULL);
|
|
|
|
|
|
|
|
width = pixel_size * (13/6.0f);
|
|
|
|
height = pixel_size * 1.75f;
|
|
|
|
|
|
|
|
/* Image Area */
|
|
|
|
area = gtk_grid_get_child_at (GTK_GRID (toolbox->p->image_area), 0, 0);
|
|
|
|
gimp_view_renderer_set_size_full (GIMP_VIEW (area)->renderer,
|
|
|
|
width, height, 0);
|
|
|
|
|
|
|
|
/* Brush Area */
|
|
|
|
area = gtk_grid_get_child_at (GTK_GRID (toolbox->p->foo_area), 0, 0);
|
|
|
|
gimp_view_renderer_set_size_full (GIMP_VIEW (area)->renderer,
|
|
|
|
pixel_size, pixel_size, 0);
|
|
|
|
|
|
|
|
/* Pattern Area */
|
|
|
|
area = gtk_grid_get_child_at (GTK_GRID (toolbox->p->foo_area), 1, 0);
|
|
|
|
gimp_view_renderer_set_size_full (GIMP_VIEW (area)->renderer,
|
|
|
|
pixel_size, pixel_size, 0);
|
|
|
|
|
|
|
|
/* Gradient Area */
|
|
|
|
area = gtk_grid_get_child_at (GTK_GRID (toolbox->p->foo_area), 0, 1);
|
|
|
|
gimp_view_renderer_set_size_full (GIMP_VIEW (area)->renderer,
|
|
|
|
width, (pixel_size / 2), 0);
|
|
|
|
}
|
|
|
|
|
2008-04-25 07:05:48 +00:00
|
|
|
static gboolean
|
|
|
|
gimp_toolbox_button_press_event (GtkWidget *widget,
|
|
|
|
GdkEventButton *event)
|
|
|
|
{
|
2010-11-20 15:18:09 +01:00
|
|
|
GimpToolbox *toolbox = GIMP_TOOLBOX (widget);
|
2021-07-05 12:33:35 +02:00
|
|
|
GimpDisplay *display;
|
2021-07-05 15:24:12 +02:00
|
|
|
gboolean stop_event = GDK_EVENT_PROPAGATE;
|
2010-11-20 15:18:09 +01:00
|
|
|
|
2008-04-25 07:05:48 +00:00
|
|
|
if (event->type == GDK_BUTTON_PRESS && event->button == 2)
|
|
|
|
{
|
|
|
|
GtkClipboard *clipboard;
|
|
|
|
|
|
|
|
clipboard = gtk_widget_get_clipboard (widget, GDK_SELECTION_PRIMARY);
|
|
|
|
gtk_clipboard_request_text (clipboard,
|
|
|
|
toolbox_paste_received,
|
2014-05-02 20:20:46 +02:00
|
|
|
g_object_ref (toolbox));
|
2008-04-25 07:05:48 +00:00
|
|
|
|
2021-07-05 15:24:12 +02:00
|
|
|
stop_event = GDK_EVENT_STOP;
|
|
|
|
}
|
|
|
|
else if ((display = gimp_context_get_display (toolbox->p->context)))
|
|
|
|
{
|
|
|
|
/* Any button event in empty spaces or the Wilber area gives focus
|
|
|
|
* to the top image.
|
|
|
|
*/
|
|
|
|
gimp_display_grab_focus (display);
|
2008-04-25 07:05:48 +00:00
|
|
|
}
|
|
|
|
|
2021-07-05 15:24:12 +02:00
|
|
|
return stop_event;
|
2008-04-25 07:05:48 +00:00
|
|
|
}
|
|
|
|
|
2010-01-22 20:48:34 +01:00
|
|
|
static void
|
|
|
|
gimp_toolbox_drag_leave (GtkWidget *widget,
|
|
|
|
GdkDragContext *context,
|
|
|
|
guint time,
|
|
|
|
GimpToolbox *toolbox)
|
|
|
|
{
|
2021-02-09 11:50:23 +01:00
|
|
|
gimp_highlight_widget (widget, FALSE, NULL);
|
2010-01-22 20:48:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gimp_toolbox_drag_motion (GtkWidget *widget,
|
|
|
|
GdkDragContext *context,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
guint time,
|
|
|
|
GimpToolbox *toolbox)
|
|
|
|
{
|
2015-02-19 21:18:21 +01:00
|
|
|
gboolean handle;
|
|
|
|
|
|
|
|
if (gimp_paned_box_will_handle_drag (toolbox->p->drag_handler,
|
|
|
|
widget,
|
|
|
|
context,
|
|
|
|
x, y,
|
|
|
|
time))
|
|
|
|
{
|
|
|
|
gdk_drag_status (context, 0, time);
|
2021-02-09 11:50:23 +01:00
|
|
|
gimp_highlight_widget (widget, FALSE, NULL);
|
2015-02-19 21:18:21 +01:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
handle = (gtk_drag_dest_find_target (widget, context, NULL) != GDK_NONE);
|
|
|
|
|
|
|
|
gdk_drag_status (context, handle ? GDK_ACTION_MOVE : 0, time);
|
2021-02-09 11:50:23 +01:00
|
|
|
gimp_highlight_widget (widget, handle, NULL);
|
2015-02-19 21:18:21 +01:00
|
|
|
|
|
|
|
/* Return TRUE so drag_leave() is called */
|
|
|
|
return TRUE;
|
2010-01-22 20:48:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gimp_toolbox_drag_drop (GtkWidget *widget,
|
|
|
|
GdkDragContext *context,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
guint time,
|
|
|
|
GimpToolbox *toolbox)
|
|
|
|
{
|
2015-02-19 21:18:21 +01:00
|
|
|
GdkAtom target;
|
|
|
|
gboolean dropped = FALSE;
|
2010-01-22 20:48:34 +01:00
|
|
|
|
|
|
|
if (gimp_paned_box_will_handle_drag (toolbox->p->drag_handler,
|
|
|
|
widget,
|
|
|
|
context,
|
|
|
|
x, y,
|
|
|
|
time))
|
|
|
|
{
|
2015-02-19 21:18:21 +01:00
|
|
|
return FALSE;
|
2010-01-22 20:48:34 +01:00
|
|
|
}
|
2015-02-19 21:18:21 +01:00
|
|
|
|
|
|
|
target = gtk_drag_dest_find_target (widget, context, NULL);
|
|
|
|
|
|
|
|
if (target != GDK_NONE)
|
2010-01-22 20:48:34 +01:00
|
|
|
{
|
2015-02-19 21:18:21 +01:00
|
|
|
/* The URI handlers etc will handle this */
|
|
|
|
gtk_drag_get_data (widget, context, target, time);
|
|
|
|
dropped = TRUE;
|
2010-01-22 20:48:34 +01:00
|
|
|
}
|
2023-05-25 01:50:07 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_drag_finish (context, FALSE,
|
|
|
|
gdk_drag_context_get_selected_action (context) ==
|
|
|
|
GDK_ACTION_MOVE,
|
|
|
|
time);
|
|
|
|
}
|
2010-01-22 20:48:34 +01:00
|
|
|
|
2023-05-25 01:50:07 +02:00
|
|
|
return dropped;
|
2010-01-22 20:48:34 +01:00
|
|
|
}
|
|
|
|
|
2009-09-13 13:14:18 +02:00
|
|
|
static gchar *
|
2010-03-13 20:02:55 +01:00
|
|
|
gimp_toolbox_get_description (GimpDock *dock,
|
|
|
|
gboolean complete)
|
2009-09-13 13:14:18 +02:00
|
|
|
{
|
2010-03-13 17:18:47 +01:00
|
|
|
GString *desc = g_string_new (_("Toolbox"));
|
2010-03-13 20:02:55 +01:00
|
|
|
gchar *dock_desc = GIMP_DOCK_CLASS (parent_class)->get_description (dock,
|
|
|
|
complete);
|
2010-03-05 08:26:24 +01:00
|
|
|
|
2010-03-13 17:18:47 +01:00
|
|
|
if (dock_desc && strlen (dock_desc) > 0)
|
2010-03-05 08:26:24 +01:00
|
|
|
{
|
2010-03-13 17:18:47 +01:00
|
|
|
g_string_append (desc, GIMP_DOCK_BOOK_SEPARATOR);
|
|
|
|
g_string_append (desc, dock_desc);
|
2010-03-05 08:26:24 +01:00
|
|
|
}
|
|
|
|
|
2010-03-13 17:18:47 +01:00
|
|
|
g_free (dock_desc);
|
2010-03-05 08:26:24 +01:00
|
|
|
|
2010-03-13 17:18:47 +01:00
|
|
|
return g_string_free (desc, FALSE /*free_segment*/);
|
2009-09-13 13:14:18 +02:00
|
|
|
}
|
|
|
|
|
2002-10-25 13:21:54 +00:00
|
|
|
static void
|
|
|
|
gimp_toolbox_book_added (GimpDock *dock,
|
|
|
|
GimpDockbook *dockbook)
|
|
|
|
{
|
2010-11-19 23:52:09 +01:00
|
|
|
if (GIMP_DOCK_CLASS (parent_class)->book_added)
|
|
|
|
GIMP_DOCK_CLASS (parent_class)->book_added (dock, dockbook);
|
2010-05-10 17:54:49 +02:00
|
|
|
|
2009-01-04 10:28:31 +00:00
|
|
|
if (g_list_length (gimp_dock_get_dockbooks (dock)) == 1)
|
2005-09-11 21:08:27 +00:00
|
|
|
{
|
2009-09-13 14:14:08 +02:00
|
|
|
gimp_dock_invalidate_geometry (dock);
|
2005-09-11 21:08:27 +00:00
|
|
|
}
|
2002-10-25 13:21:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_toolbox_book_removed (GimpDock *dock,
|
|
|
|
GimpDockbook *dockbook)
|
|
|
|
{
|
2010-05-10 17:54:49 +02:00
|
|
|
GimpToolbox *toolbox = GIMP_TOOLBOX (dock);
|
|
|
|
|
2010-11-19 23:52:09 +01:00
|
|
|
if (GIMP_DOCK_CLASS (parent_class)->book_removed)
|
|
|
|
GIMP_DOCK_CLASS (parent_class)->book_removed (dock, dockbook);
|
2010-03-13 20:02:55 +01:00
|
|
|
|
2011-10-09 00:27:53 +02:00
|
|
|
if (! gimp_dock_get_dockbooks (dock) &&
|
2010-05-10 17:54:49 +02:00
|
|
|
! toolbox->p->in_destruction)
|
2005-09-11 21:08:27 +00:00
|
|
|
{
|
2009-09-13 14:14:08 +02:00
|
|
|
gimp_dock_invalidate_geometry (dock);
|
2005-09-11 21:08:27 +00:00
|
|
|
}
|
2002-10-25 13:21:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-09-13 14:14:08 +02:00
|
|
|
gimp_toolbox_set_host_geometry_hints (GimpDock *dock,
|
|
|
|
GtkWindow *window)
|
2002-10-25 13:21:54 +00:00
|
|
|
{
|
2010-11-20 10:20:52 +01:00
|
|
|
GimpToolbox *toolbox = GIMP_TOOLBOX (dock);
|
|
|
|
gint button_width;
|
|
|
|
gint button_height;
|
2002-03-14 17:07:02 +00:00
|
|
|
|
2010-11-20 10:20:52 +01:00
|
|
|
if (gimp_tool_palette_get_button_size (GIMP_TOOL_PALETTE (toolbox->p->tool_palette),
|
|
|
|
&button_width, &button_height))
|
2002-03-14 17:07:02 +00:00
|
|
|
{
|
2010-11-20 20:44:16 +01:00
|
|
|
GdkGeometry geometry;
|
2002-03-14 17:07:02 +00:00
|
|
|
|
2010-11-20 20:44:16 +01:00
|
|
|
geometry.min_width = 2 * button_width;
|
|
|
|
geometry.min_height = -1;
|
|
|
|
geometry.base_width = button_width;
|
2010-12-08 10:18:09 +01:00
|
|
|
geometry.base_height = 0;
|
2010-11-20 20:44:16 +01:00
|
|
|
geometry.width_inc = button_width;
|
2010-12-08 10:18:09 +01:00
|
|
|
geometry.height_inc = 1;
|
2002-03-14 17:07:02 +00:00
|
|
|
|
2009-09-13 14:14:08 +02:00
|
|
|
gtk_window_set_geometry_hints (window,
|
2002-03-14 17:07:02 +00:00
|
|
|
NULL,
|
2003-11-20 20:36:55 +00:00
|
|
|
&geometry,
|
2003-01-14 22:06:06 +00:00
|
|
|
GDK_HINT_MIN_SIZE |
|
2010-11-20 20:44:16 +01:00
|
|
|
GDK_HINT_BASE_SIZE |
|
2003-01-14 22:06:06 +00:00
|
|
|
GDK_HINT_RESIZE_INC |
|
|
|
|
GDK_HINT_USER_POS);
|
2009-03-28 13:19:53 +00:00
|
|
|
|
2009-09-13 14:14:08 +02:00
|
|
|
gimp_dialog_factory_set_has_min_size (window, TRUE);
|
2002-03-14 17:07:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
2009-12-05 21:20:18 +01:00
|
|
|
gimp_toolbox_new (GimpDialogFactory *factory,
|
2009-09-26 16:21:10 +02:00
|
|
|
GimpContext *context,
|
|
|
|
GimpUIManager *ui_manager)
|
2002-03-14 17:07:02 +00:00
|
|
|
{
|
2010-11-20 15:18:09 +01:00
|
|
|
g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (factory), NULL);
|
|
|
|
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
|
|
|
g_return_val_if_fail (GIMP_IS_UI_MANAGER (ui_manager), NULL);
|
|
|
|
|
2009-12-05 21:20:18 +01:00
|
|
|
return g_object_new (GIMP_TYPE_TOOLBOX,
|
2011-08-07 19:49:37 +02:00
|
|
|
"context", context,
|
2009-12-05 21:20:18 +01:00
|
|
|
NULL);
|
|
|
|
}
|
2002-03-14 17:07:02 +00:00
|
|
|
|
2009-12-05 21:20:18 +01:00
|
|
|
GimpContext *
|
|
|
|
gimp_toolbox_get_context (GimpToolbox *toolbox)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_TOOLBOX (toolbox), NULL);
|
|
|
|
|
|
|
|
return toolbox->p->context;
|
|
|
|
}
|
2001-10-25 13:30:01 +00:00
|
|
|
|
2010-01-22 20:48:34 +01:00
|
|
|
void
|
|
|
|
gimp_toolbox_set_drag_handler (GimpToolbox *toolbox,
|
|
|
|
GimpPanedBox *drag_handler)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_TOOLBOX (toolbox));
|
|
|
|
|
|
|
|
toolbox->p->drag_handler = drag_handler;
|
|
|
|
}
|
|
|
|
|
2001-12-12 01:16:39 +00:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
2022-09-26 21:53:13 +02:00
|
|
|
static void
|
|
|
|
gimp_toolbox_notify_theme (GimpGuiConfig *config,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GimpToolbox *toolbox)
|
|
|
|
{
|
|
|
|
gimp_toolbox_palette_style_updated (GTK_WIDGET (toolbox->p->tool_palette), toolbox);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_toolbox_palette_style_updated (GtkWidget *widget,
|
|
|
|
GimpToolbox *toolbox)
|
|
|
|
{
|
|
|
|
GtkIconSize tool_icon_size = GTK_ICON_SIZE_LARGE_TOOLBAR;
|
|
|
|
gint icon_width = 40;
|
|
|
|
gint icon_height = 38;
|
|
|
|
|
|
|
|
gtk_widget_style_get (widget,
|
|
|
|
"tool-icon-size", &tool_icon_size,
|
|
|
|
NULL);
|
|
|
|
gtk_icon_size_lookup (tool_icon_size, &icon_width, &icon_height);
|
|
|
|
|
|
|
|
gtk_widget_set_size_request (toolbox->p->color_area,
|
|
|
|
(gint) (icon_width * 1.75),
|
|
|
|
(gint) (icon_height * 1.75));
|
|
|
|
gtk_widget_queue_resize (toolbox->p->color_area);
|
|
|
|
}
|
|
|
|
|
2011-11-02 00:31:23 +01:00
|
|
|
static void
|
2011-11-04 00:28:04 +01:00
|
|
|
gimp_toolbox_wilber_style_updated (GtkWidget *widget,
|
|
|
|
GimpToolbox *toolbox)
|
2011-11-02 00:31:23 +01:00
|
|
|
{
|
|
|
|
gint button_width;
|
|
|
|
gint button_height;
|
|
|
|
|
|
|
|
if (gimp_tool_palette_get_button_size (GIMP_TOOL_PALETTE (toolbox->p->tool_palette),
|
|
|
|
&button_width, &button_height))
|
|
|
|
{
|
2011-11-04 00:28:04 +01:00
|
|
|
gtk_widget_set_size_request (widget,
|
|
|
|
button_width * PANGO_SCALE_SMALL,
|
|
|
|
button_height * PANGO_SCALE_SMALL);
|
2011-11-02 00:31:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-15 16:03:36 +02:00
|
|
|
static gboolean
|
2010-10-15 16:07:18 +02:00
|
|
|
gimp_toolbox_draw_wilber (GtkWidget *widget,
|
|
|
|
cairo_t *cr)
|
2010-10-15 16:03:36 +02:00
|
|
|
{
|
|
|
|
gimp_cairo_draw_toolbox_wilber (widget, cr);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-05-31 20:30:52 +00:00
|
|
|
static GtkWidget *
|
2002-03-14 17:07:02 +00:00
|
|
|
toolbox_create_color_area (GimpToolbox *toolbox,
|
2001-12-12 01:16:39 +00:00
|
|
|
GimpContext *context)
|
|
|
|
{
|
2022-08-20 23:48:44 +02:00
|
|
|
GtkWidget *col_area;
|
|
|
|
GtkIconSize tool_icon_size = GTK_ICON_SIZE_LARGE_TOOLBAR;
|
|
|
|
gint icon_width = 40;
|
|
|
|
gint icon_height = 38;
|
|
|
|
|
|
|
|
gtk_widget_style_get (GTK_WIDGET (toolbox->p->tool_palette),
|
|
|
|
"tool-icon-size", &tool_icon_size,
|
|
|
|
NULL);
|
|
|
|
gtk_icon_size_lookup (tool_icon_size, &icon_width, &icon_height);
|
|
|
|
col_area = gimp_toolbox_color_area_create (toolbox,
|
|
|
|
(gint) (icon_width * 1.75),
|
|
|
|
(gint) (icon_height * 1.75));
|
2018-05-04 12:58:22 +02:00
|
|
|
g_object_set (col_area,
|
|
|
|
"halign", GTK_ALIGN_CENTER,
|
|
|
|
"valign", GTK_ALIGN_CENTER,
|
2024-05-29 13:43:17 +00:00
|
|
|
"margin-start", 2,
|
|
|
|
"margin-end", 2,
|
2018-05-04 12:58:22 +02:00
|
|
|
"margin-top", 2,
|
|
|
|
"margin-bottom", 2,
|
|
|
|
NULL);
|
|
|
|
|
2022-09-26 21:53:13 +02:00
|
|
|
g_signal_connect (toolbox->p->tool_palette, "style-updated",
|
|
|
|
G_CALLBACK (gimp_toolbox_palette_style_updated),
|
|
|
|
toolbox);
|
|
|
|
g_signal_connect_after (GIMP_GUI_CONFIG (toolbox->p->context->gimp->config),
|
|
|
|
"notify::theme",
|
|
|
|
G_CALLBACK (gimp_toolbox_notify_theme),
|
|
|
|
toolbox);
|
Issue #7023: icon size selection on GIMP 2.99.
This kinda reverts commit 6aebd30de142286c41e6cd90abedc4082a13fcea ("app: remove
icon sizing preferences"), except that the code base is different enough since
this old commit was mainly for GIMP 2.10.x.
In any case, after initially thinking that GTK+3 handling for high density
display would be enough, we finally decide that adding back a Preferences-wide
setting for overriding the theme-set icon size is a good idea (additionally to
GTK+3 automatic support).
The base idea for removing the feature was that GTK+3 has high density display
support, through the "scale factor". Typically a high density display will
normally be set as using a ×2 scale factor so all icons will be double size.
Unfortunately it turns out it's not enough.
For instance, on very small screen estate, even with a scale factor of 1, if the
theme sets 24px toolbox icons, it may still take too much space.
Oppositely on huge screens, even with ×2 factor scale detected by the OS, the
icons may still feel too small (this is possibly what happens with #7023).
Furthermore there is also a matter of taste. Some people like small icons even
when they have the space. Others may want bigger icons, easy to click on.
Finally you can like a theme for its color scheme for instance, but it may not
have the icon size you want. Right now, we'd need to duplicate every theme in
small or bigger size. Instead of doing so, let's just have this global setting
overriding the theme rules.
Comparison with the 2.10 implementation:
- We still provide 4 sizes: small, medium, large and huge.
- We don't have the "Guess ideal size" setting anymore. Instead this is now a
mix of the GTK+3 scale factor logic and the theme-set or custom size. I.e.
that on a high density display with ×2 scale factor, we could have toolbox
icons up to 96 pixels (48×2)!
- We now try to have less custom code in widgets as we append the CSS rules to
the theme (similar to what we were already doing for dark theme or icon
variants). What happens in widget code is mostly to connect to changes in
themes and redraw the widgets which need to be.
- The custom size will now affect: toolbox icons, the FG/BG editor widget (in
both the toolbox and the color dockable), dockable tab icons, the main
dockable buttons, eye and lock header icons in item tree views, eye and lock
cell icons in the item lists.
There are still a bunch of areas where it is not taken into account, such as
plug-ins, and various dialogs, but even in custom-made interface in dockables.
Ultimately it might be interesting to have a way to sync more buttons and
widgets to a global size settings.
Lastly, I fixed a bunch of existing bugs where we were updating icon sizes with
gtk_image_set_from_icon_name() using the const icon name taken from
gtk_image_get_icon_name(). As this was reusing the same string pointer, we were
ending with freeing the icon name.
2022-09-26 22:56:08 +02:00
|
|
|
g_signal_connect_after (GIMP_GUI_CONFIG (toolbox->p->context->gimp->config),
|
|
|
|
"notify::override-theme-icon-size",
|
|
|
|
G_CALLBACK (gimp_toolbox_notify_theme),
|
|
|
|
toolbox);
|
|
|
|
g_signal_connect_after (GIMP_GUI_CONFIG (toolbox->p->context->gimp->config),
|
|
|
|
"notify::custom-icon-size",
|
|
|
|
G_CALLBACK (gimp_toolbox_notify_theme),
|
|
|
|
toolbox);
|
2018-05-04 12:58:22 +02:00
|
|
|
return col_area;
|
2004-05-31 20:30:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GtkWidget *
|
|
|
|
toolbox_create_foo_area (GimpToolbox *toolbox,
|
|
|
|
GimpContext *context)
|
|
|
|
{
|
|
|
|
GtkWidget *foo_area;
|
|
|
|
|
|
|
|
foo_area = gimp_toolbox_indicator_area_create (toolbox);
|
2018-05-04 12:58:22 +02:00
|
|
|
g_object_set (foo_area,
|
|
|
|
"halign", GTK_ALIGN_CENTER,
|
|
|
|
"valign", GTK_ALIGN_CENTER,
|
2024-05-29 13:43:17 +00:00
|
|
|
"margin-start", 2,
|
|
|
|
"margin-end", 2,
|
2018-05-04 12:58:22 +02:00
|
|
|
"margin-top", 2,
|
|
|
|
"margin-bottom", 2,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
return foo_area;
|
2001-12-12 01:16:39 +00:00
|
|
|
}
|
|
|
|
|
2004-05-31 20:30:52 +00:00
|
|
|
static GtkWidget *
|
|
|
|
toolbox_create_image_area (GimpToolbox *toolbox,
|
|
|
|
GimpContext *context)
|
2001-12-12 01:16:39 +00:00
|
|
|
{
|
2024-07-27 15:39:05 +00:00
|
|
|
GtkWidget *image_area;
|
|
|
|
GtkWidget *grid;
|
|
|
|
GtkIconSize tool_icon_size;
|
|
|
|
gint width = 52;
|
|
|
|
gint height = 42;
|
|
|
|
|
|
|
|
grid = gtk_grid_new ();
|
|
|
|
gtk_grid_set_row_spacing (GTK_GRID (grid), 2);
|
|
|
|
gtk_grid_set_column_spacing (GTK_GRID (grid), 2);
|
|
|
|
|
|
|
|
gtk_widget_style_get (GTK_WIDGET (toolbox),
|
|
|
|
"tool-icon-size", &tool_icon_size,
|
|
|
|
NULL);
|
|
|
|
gtk_icon_size_lookup (tool_icon_size, &width, &height);
|
|
|
|
width *= (13/6.0f);
|
|
|
|
height *= 1.75f;
|
|
|
|
|
|
|
|
image_area = gimp_toolbox_image_area_create (toolbox, width, height);
|
|
|
|
gtk_grid_attach (GTK_GRID (grid), image_area, 0, 0, 1, 1);
|
|
|
|
gtk_widget_set_visible (grid, TRUE);
|
2001-12-12 01:16:39 +00:00
|
|
|
|
2024-07-27 15:39:05 +00:00
|
|
|
g_object_set (grid,
|
2018-05-04 12:58:22 +02:00
|
|
|
"halign", GTK_ALIGN_CENTER,
|
|
|
|
"valign", GTK_ALIGN_CENTER,
|
2024-05-29 13:43:17 +00:00
|
|
|
"margin-start", 2,
|
|
|
|
"margin-end", 2,
|
2018-05-04 12:58:22 +02:00
|
|
|
"margin-top", 2,
|
|
|
|
"margin-bottom", 2,
|
|
|
|
NULL);
|
|
|
|
|
2024-07-27 15:39:05 +00:00
|
|
|
return grid;
|
2004-05-31 20:30:52 +00:00
|
|
|
}
|
|
|
|
|
2005-02-11 01:23:41 +00:00
|
|
|
static void
|
|
|
|
toolbox_paste_received (GtkClipboard *clipboard,
|
|
|
|
const gchar *text,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2014-05-02 20:20:46 +02:00
|
|
|
GimpToolbox *toolbox = GIMP_TOOLBOX (data);
|
|
|
|
GimpContext *context = toolbox->p->context;
|
2005-02-11 01:23:41 +00:00
|
|
|
|
2005-02-11 11:14:10 +00:00
|
|
|
if (text)
|
2005-02-11 01:23:41 +00:00
|
|
|
{
|
2005-02-11 11:14:10 +00:00
|
|
|
const gchar *newline = strchr (text, '\n');
|
|
|
|
gchar *copy;
|
2014-07-07 00:46:25 +02:00
|
|
|
GFile *file = NULL;
|
2005-02-11 01:23:41 +00:00
|
|
|
|
2005-02-11 11:14:10 +00:00
|
|
|
if (newline)
|
|
|
|
copy = g_strndup (text, newline - text);
|
|
|
|
else
|
|
|
|
copy = g_strdup (text);
|
2005-02-11 01:23:41 +00:00
|
|
|
|
2005-02-11 11:14:10 +00:00
|
|
|
g_strstrip (copy);
|
2005-02-11 01:23:41 +00:00
|
|
|
|
2005-02-11 11:14:10 +00:00
|
|
|
if (strlen (copy))
|
2014-07-07 00:46:25 +02:00
|
|
|
file = g_file_new_for_commandline_arg (copy);
|
|
|
|
|
|
|
|
g_free (copy);
|
|
|
|
|
|
|
|
if (file)
|
2005-02-11 01:23:41 +00:00
|
|
|
{
|
2014-05-02 20:20:46 +02:00
|
|
|
GtkWidget *widget = GTK_WIDGET (toolbox);
|
2005-02-11 11:14:10 +00:00
|
|
|
GimpImage *image;
|
2021-07-05 15:24:12 +02:00
|
|
|
GimpDisplay *display;
|
2005-02-11 11:14:10 +00:00
|
|
|
GimpPDBStatusType status;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
image = file_open_with_display (context->gimp, context, NULL,
|
2014-07-07 00:46:25 +02:00
|
|
|
file, FALSE,
|
2018-04-29 17:27:47 +02:00
|
|
|
G_OBJECT (gimp_widget_get_monitor (widget)),
|
2014-05-02 20:20:46 +02:00
|
|
|
&status, &error);
|
2005-02-11 01:23:41 +00:00
|
|
|
|
2005-02-11 11:14:10 +00:00
|
|
|
if (! image && status != GIMP_PDB_CANCEL)
|
|
|
|
{
|
2006-10-09 18:49:15 +00:00
|
|
|
gimp_message (context->gimp, NULL, GIMP_MESSAGE_ERROR,
|
|
|
|
_("Opening '%s' failed:\n\n%s"),
|
2014-07-07 00:46:25 +02:00
|
|
|
gimp_file_get_utf8_name (file), error->message);
|
2005-02-11 11:14:10 +00:00
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
2021-07-05 15:24:12 +02:00
|
|
|
else if ((display = gimp_context_get_display (context)))
|
|
|
|
{
|
|
|
|
/* Giving focus to newly opened image. */
|
|
|
|
gimp_display_grab_focus (display);
|
|
|
|
}
|
2005-02-11 01:23:41 +00:00
|
|
|
|
2014-07-07 00:46:25 +02:00
|
|
|
g_object_unref (file);
|
|
|
|
}
|
2005-02-11 01:23:41 +00:00
|
|
|
}
|
|
|
|
|
2021-07-05 13:01:47 +02:00
|
|
|
g_object_unref (toolbox);
|
2005-02-11 01:23:41 +00:00
|
|
|
}
|