2006-12-09 21:33:38 +00:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2001-04-10 16:03:40 +00:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* gimpdockbook.c
|
2007-09-17 15:40:01 +00:00
|
|
|
* Copyright (C) 2001-2007 Michael Natterer <mitch@gimp.org>
|
2001-04-10 16:03:40 +00:00
|
|
|
*
|
2009-01-17 22:28:01 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2001-04-10 16:03:40 +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-04-10 16:03:40 +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-04-10 16:03:40 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2001-11-23 16:25:01 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2012-03-29 19:19:01 +02:00
|
|
|
#include <gegl.h>
|
2012-02-01 20:32:22 +01:00
|
|
|
#undef GTK_DISABLE_DEPRECATED
|
2001-04-10 16:03:40 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2019-07-31 10:16:21 +02:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-04-10 16:03:40 +00:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2001-05-08 03:48:54 +00:00
|
|
|
#include "widgets-types.h"
|
2001-04-10 16:03:40 +00:00
|
|
|
|
2017-03-10 06:04:20 +01:00
|
|
|
#include "config/gimpguiconfig.h"
|
|
|
|
|
|
|
|
#include "core/gimp.h"
|
2003-01-10 17:55:53 +00:00
|
|
|
#include "core/gimpcontext.h"
|
|
|
|
|
2023-03-07 18:23:38 +01:00
|
|
|
#include "menus/menus.h"
|
|
|
|
|
2019-07-02 03:54:38 +02:00
|
|
|
#include "gimpactiongroup.h"
|
2011-07-03 16:36:38 +02:00
|
|
|
#include "gimpdialogfactory.h"
|
2001-05-08 03:48:54 +00:00
|
|
|
#include "gimpdnd.h"
|
2009-09-13 09:31:21 +02:00
|
|
|
#include "gimpdock.h"
|
2001-04-10 16:03:40 +00:00
|
|
|
#include "gimpdockable.h"
|
|
|
|
#include "gimpdockbook.h"
|
2008-05-19 21:11:03 +00:00
|
|
|
#include "gimpdocked.h"
|
2011-05-13 18:56:03 +02:00
|
|
|
#include "gimpdockcontainer.h"
|
2009-09-15 07:58:14 +02:00
|
|
|
#include "gimpdockwindow.h"
|
2003-08-26 10:07:01 +00:00
|
|
|
#include "gimphelp-ids.h"
|
2003-01-10 17:55:53 +00:00
|
|
|
#include "gimpmenufactory.h"
|
2009-10-24 18:52:48 +02:00
|
|
|
#include "gimppanedbox.h"
|
2005-10-30 18:41:18 +00:00
|
|
|
#include "gimpstringaction.h"
|
|
|
|
#include "gimpuimanager.h"
|
2004-08-24 17:16:46 +00:00
|
|
|
#include "gimpview.h"
|
2018-05-02 14:53:56 +02:00
|
|
|
#include "gimpwidgets-utils.h"
|
2001-11-23 16:25:01 +00:00
|
|
|
|
app: Use a GdkWindow instead of GimpDockSeparators for dockable DND
Make drag-and-drop rearrangement of dockables happen directly in the
existing widget hierarchy so we don't have to use special, ugly
widgets (read GimpDockSeparator:s) for that.
More specifically, make edges of dockables and dockbooks have the same
semantics as the GimpDockSeparators had. We put a highlight colored
GdkWindow on top of the widget in question to highlight these special
drop areas. This GdkWindow is not taken into consideration in the GTK+
drag-and-drop code, so it does not interupt the DND interaction.
To achive this, there is a problem we must solve: Drag events in GTK+
are propagated inwards and out, but we sometimes want ancenstor
widgets to take care of drop events. We solve this by introducing the
concept of "drag handlers". A drag handler is asked if it will handle
a given drag event, and if it will, a client will let the drag event
be propagated upwards in the widget hierarchy. Right now, the
GimpPanedBox is the only "drag handler". The code could be generalized
more but it doesn't feel worth it at this point.
The size of the special drop area is 5px, the same size as the default
GtkPaned handles. This is because the plan is to later use these
handles as drop areas too.
Other changes of interest are:
* We need to take care of "drag-motion", "drag-drop" and widget
highlightning ourselves. We can not use the GtkDestDefaults
conveniences with gtk_drag_dest_set() any longer since we need more
control.
* Make the drop callback pass the insert index directly instead of a
GimpDockSeparator
* Add some GIMP_LOG() debug output for DND
* Disable the GimpDockSeparator code in GimpToolbox
2009-11-29 18:22:12 +01:00
|
|
|
#include "gimp-log.h"
|
2010-05-26 18:10:31 +02:00
|
|
|
#include "gimp-intl.h"
|
2001-04-10 16:03:40 +00:00
|
|
|
|
2012-02-01 20:32:22 +01:00
|
|
|
|
2010-05-26 18:10:31 +02:00
|
|
|
#define DEFAULT_TAB_ICON_SIZE GTK_ICON_SIZE_BUTTON
|
|
|
|
#define DND_WIDGET_ICON_SIZE GTK_ICON_SIZE_BUTTON
|
|
|
|
#define MENU_WIDGET_SPACING 4
|
|
|
|
#define TAB_HOVER_TIMEOUT 500
|
|
|
|
#define GIMP_DOCKABLE_DETACH_REF_KEY "gimp-dockable-detach-ref"
|
2001-05-06 16:14:34 +00:00
|
|
|
|
|
|
|
|
2003-05-03 11:59:44 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
DOCKABLE_ADDED,
|
|
|
|
DOCKABLE_REMOVED,
|
|
|
|
DOCKABLE_REORDERED,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2012-02-01 20:38:10 +01:00
|
|
|
|
2020-02-03 00:02:49 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GimpDockbookDragCallback callback;
|
|
|
|
gpointer data;
|
|
|
|
} GimpDockbookDragCallbackData;
|
|
|
|
|
2009-09-13 16:30:09 +02:00
|
|
|
struct _GimpDockbookPrivate
|
|
|
|
{
|
2010-06-11 23:18:49 +02:00
|
|
|
GimpDock *dock;
|
|
|
|
GimpUIManager *ui_manager;
|
2009-09-13 16:30:09 +02:00
|
|
|
|
2010-06-11 23:18:49 +02:00
|
|
|
guint tab_hover_timeout;
|
|
|
|
GimpDockable *tab_hover_dockable;
|
app: Use a GdkWindow instead of GimpDockSeparators for dockable DND
Make drag-and-drop rearrangement of dockables happen directly in the
existing widget hierarchy so we don't have to use special, ugly
widgets (read GimpDockSeparator:s) for that.
More specifically, make edges of dockables and dockbooks have the same
semantics as the GimpDockSeparators had. We put a highlight colored
GdkWindow on top of the widget in question to highlight these special
drop areas. This GdkWindow is not taken into consideration in the GTK+
drag-and-drop code, so it does not interupt the DND interaction.
To achive this, there is a problem we must solve: Drag events in GTK+
are propagated inwards and out, but we sometimes want ancenstor
widgets to take care of drop events. We solve this by introducing the
concept of "drag handlers". A drag handler is asked if it will handle
a given drag event, and if it will, a client will let the drag event
be propagated upwards in the widget hierarchy. Right now, the
GimpPanedBox is the only "drag handler". The code could be generalized
more but it doesn't feel worth it at this point.
The size of the special drop area is 5px, the same size as the default
GtkPaned handles. This is because the plan is to later use these
handles as drop areas too.
Other changes of interest are:
* We need to take care of "drag-motion", "drag-drop" and widget
highlightning ourselves. We can not use the GtkDestDefaults
conveniences with gtk_drag_dest_set() any longer since we need more
control.
* Make the drop callback pass the insert index directly instead of a
GimpDockSeparator
* Add some GIMP_LOG() debug output for DND
* Disable the GimpDockSeparator code in GimpToolbox
2009-11-29 18:22:12 +01:00
|
|
|
|
2010-06-11 23:18:49 +02:00
|
|
|
GimpPanedBox *drag_handler;
|
|
|
|
|
|
|
|
GtkWidget *menu_button;
|
2009-09-13 16:30:09 +02:00
|
|
|
};
|
|
|
|
|
2003-05-03 11:59:44 +00:00
|
|
|
|
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
|
|
|
static void gimp_dockbook_style_updated (GtkWidget *widget);
|
2020-02-03 00:02:49 +02:00
|
|
|
static void gimp_dockbook_drag_begin (GtkWidget *widget,
|
|
|
|
GdkDragContext *context);
|
|
|
|
static void gimp_dockbook_drag_end (GtkWidget *widget,
|
|
|
|
GdkDragContext *context);
|
2018-06-08 02:40:31 +02:00
|
|
|
static gboolean gimp_dockbook_drag_motion (GtkWidget *widget,
|
|
|
|
GdkDragContext *context,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
guint time);
|
|
|
|
static gboolean gimp_dockbook_drag_drop (GtkWidget *widget,
|
|
|
|
GdkDragContext *context,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
guint time);
|
|
|
|
static gboolean gimp_dockbook_popup_menu (GtkWidget *widget);
|
|
|
|
|
|
|
|
static GtkNotebook *gimp_dockbook_create_window (GtkNotebook *notebook,
|
|
|
|
GtkWidget *page,
|
|
|
|
gint x,
|
|
|
|
gint y);
|
|
|
|
static void gimp_dockbook_page_added (GtkNotebook *notebook,
|
|
|
|
GtkWidget *child,
|
|
|
|
guint page_num);
|
|
|
|
static void gimp_dockbook_page_removed (GtkNotebook *notebook,
|
|
|
|
GtkWidget *child,
|
|
|
|
guint page_num);
|
|
|
|
static void gimp_dockbook_page_reordered (GtkNotebook *notebook,
|
|
|
|
GtkWidget *child,
|
|
|
|
guint page_num);
|
|
|
|
|
2023-09-21 05:30:48 +00:00
|
|
|
static gboolean gimp_dockbook_tab_scroll_cb (GtkWidget *widget,
|
|
|
|
GdkEventScroll *event);
|
|
|
|
|
2018-06-08 02:40:31 +02:00
|
|
|
static gboolean gimp_dockbook_menu_button_press (GimpDockbook *dockbook,
|
|
|
|
GdkEventButton *bevent,
|
|
|
|
GtkWidget *button);
|
|
|
|
static gboolean gimp_dockbook_show_menu (GimpDockbook *dockbook);
|
|
|
|
static void gimp_dockbook_menu_end (GimpDockable *dockable);
|
|
|
|
static void gimp_dockbook_tab_locked_notify (GimpDockable *dockable,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GimpDockbook *dockbook);
|
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
|
|
|
|
2018-06-08 02:40:31 +02:00
|
|
|
static void gimp_dockbook_help_func (const gchar *help_id,
|
|
|
|
gpointer help_data);
|
2017-03-10 06:04:20 +01:00
|
|
|
|
2001-04-10 16:03:40 +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 (GimpDockbook, gimp_dockbook, GTK_TYPE_NOTEBOOK)
|
2005-12-19 22:37:49 +00:00
|
|
|
|
|
|
|
#define parent_class gimp_dockbook_parent_class
|
2001-04-10 16:03:40 +00:00
|
|
|
|
2005-12-19 22:37:49 +00:00
|
|
|
static guint dockbook_signals[LAST_SIGNAL] = { 0 };
|
2003-05-03 11:59:44 +00:00
|
|
|
|
2018-06-08 01:37:19 +02:00
|
|
|
static const GtkTargetEntry dialog_target_table[] = { GIMP_TARGET_NOTEBOOK_TAB };
|
2001-04-10 16:03:40 +00:00
|
|
|
|
2020-02-03 00:02:49 +02:00
|
|
|
static GList *drag_callbacks = NULL;
|
|
|
|
|
2001-04-10 16:03:40 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_dockbook_class_init (GimpDockbookClass *klass)
|
|
|
|
{
|
2018-06-08 01:37:19 +02:00
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
|
|
|
GtkNotebookClass *notebook_class = GTK_NOTEBOOK_CLASS (klass);
|
2001-04-10 16:03:40 +00:00
|
|
|
|
2003-05-03 11:59:44 +00:00
|
|
|
dockbook_signals[DOCKABLE_ADDED] =
|
2005-05-27 13:05:26 +00:00
|
|
|
g_signal_new ("dockable-added",
|
2004-08-24 17:16:46 +00:00
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpDockbookClass, dockable_added),
|
2020-01-12 11:06:05 +01:00
|
|
|
NULL, NULL, NULL,
|
2004-08-24 17:16:46 +00:00
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
GIMP_TYPE_DOCKABLE);
|
2003-05-03 11:59:44 +00:00
|
|
|
|
|
|
|
dockbook_signals[DOCKABLE_REMOVED] =
|
2005-05-27 13:05:26 +00:00
|
|
|
g_signal_new ("dockable-removed",
|
2004-08-24 17:16:46 +00:00
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpDockbookClass, dockable_removed),
|
2020-01-12 11:06:05 +01:00
|
|
|
NULL, NULL, NULL,
|
2004-08-24 17:16:46 +00:00
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
GIMP_TYPE_DOCKABLE);
|
2003-05-03 11:59:44 +00:00
|
|
|
|
|
|
|
dockbook_signals[DOCKABLE_REORDERED] =
|
2005-05-27 13:05:26 +00:00
|
|
|
g_signal_new ("dockable-reordered",
|
2004-08-24 17:16:46 +00:00
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpDockbookClass, dockable_reordered),
|
2020-01-12 11:06:05 +01:00
|
|
|
NULL, NULL, NULL,
|
2004-08-24 17:16:46 +00:00
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
GIMP_TYPE_DOCKABLE);
|
2003-05-03 11:59:44 +00:00
|
|
|
|
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
|
|
|
widget_class->style_updated = gimp_dockbook_style_updated;
|
2020-02-03 00:02:49 +02:00
|
|
|
widget_class->drag_begin = gimp_dockbook_drag_begin;
|
|
|
|
widget_class->drag_end = gimp_dockbook_drag_end;
|
2018-06-08 01:37:19 +02:00
|
|
|
widget_class->drag_motion = gimp_dockbook_drag_motion;
|
|
|
|
widget_class->drag_drop = gimp_dockbook_drag_drop;
|
|
|
|
widget_class->popup_menu = gimp_dockbook_popup_menu;
|
2003-05-03 11:59:44 +00:00
|
|
|
|
2018-06-08 01:37:19 +02:00
|
|
|
notebook_class->create_window = gimp_dockbook_create_window;
|
|
|
|
notebook_class->page_added = gimp_dockbook_page_added;
|
|
|
|
notebook_class->page_removed = gimp_dockbook_page_removed;
|
|
|
|
notebook_class->page_reordered = gimp_dockbook_page_reordered;
|
|
|
|
|
|
|
|
klass->dockable_added = NULL;
|
|
|
|
klass->dockable_removed = NULL;
|
|
|
|
klass->dockable_reordered = NULL;
|
2001-11-29 16:44:51 +00:00
|
|
|
|
2002-03-18 19:34:06 +00:00
|
|
|
gtk_widget_class_install_style_property (widget_class,
|
2005-05-27 13:05:26 +00:00
|
|
|
g_param_spec_enum ("tab-icon-size",
|
2002-05-10 14:50:27 +00:00
|
|
|
NULL, NULL,
|
|
|
|
GTK_TYPE_ICON_SIZE,
|
2003-03-21 19:18:52 +00:00
|
|
|
DEFAULT_TAB_ICON_SIZE,
|
2006-01-18 20:29:40 +00:00
|
|
|
GIMP_PARAM_READABLE));
|
2001-04-10 16:03:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_dockbook_init (GimpDockbook *dockbook)
|
|
|
|
{
|
2010-01-31 20:22:24 +01:00
|
|
|
GtkNotebook *notebook = GTK_NOTEBOOK (dockbook);
|
2018-05-26 16:28:58 +02:00
|
|
|
GtkWidget *image;
|
2010-01-31 20:22:24 +01: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
|
|
|
dockbook->p = gimp_dockbook_get_instance_private (dockbook);
|
2001-04-10 16:03:40 +00:00
|
|
|
|
2010-05-26 18:10:31 +02:00
|
|
|
/* Various init */
|
2010-01-31 20:22:24 +01:00
|
|
|
gtk_notebook_popup_enable (notebook);
|
|
|
|
gtk_notebook_set_scrollable (notebook, TRUE);
|
|
|
|
gtk_notebook_set_show_border (notebook, FALSE);
|
2010-05-26 18:10:31 +02:00
|
|
|
gtk_notebook_set_show_tabs (notebook, TRUE);
|
2018-06-08 01:37:19 +02:00
|
|
|
gtk_notebook_set_group_name (notebook, "gimp-dockbook");
|
2001-04-10 16:03:40 +00:00
|
|
|
|
2023-09-21 05:30:48 +00:00
|
|
|
gtk_widget_add_events (GTK_WIDGET (notebook),
|
|
|
|
GDK_SCROLL_MASK);
|
|
|
|
g_signal_connect (GTK_WIDGET (notebook), "scroll-event",
|
|
|
|
G_CALLBACK (gimp_dockbook_tab_scroll_cb),
|
|
|
|
NULL);
|
|
|
|
|
2001-04-10 16:03:40 +00:00
|
|
|
gtk_drag_dest_set (GTK_WIDGET (dockbook),
|
app: Use a GdkWindow instead of GimpDockSeparators for dockable DND
Make drag-and-drop rearrangement of dockables happen directly in the
existing widget hierarchy so we don't have to use special, ugly
widgets (read GimpDockSeparator:s) for that.
More specifically, make edges of dockables and dockbooks have the same
semantics as the GimpDockSeparators had. We put a highlight colored
GdkWindow on top of the widget in question to highlight these special
drop areas. This GdkWindow is not taken into consideration in the GTK+
drag-and-drop code, so it does not interupt the DND interaction.
To achive this, there is a problem we must solve: Drag events in GTK+
are propagated inwards and out, but we sometimes want ancenstor
widgets to take care of drop events. We solve this by introducing the
concept of "drag handlers". A drag handler is asked if it will handle
a given drag event, and if it will, a client will let the drag event
be propagated upwards in the widget hierarchy. Right now, the
GimpPanedBox is the only "drag handler". The code could be generalized
more but it doesn't feel worth it at this point.
The size of the special drop area is 5px, the same size as the default
GtkPaned handles. This is because the plan is to later use these
handles as drop areas too.
Other changes of interest are:
* We need to take care of "drag-motion", "drag-drop" and widget
highlightning ourselves. We can not use the GtkDestDefaults
conveniences with gtk_drag_dest_set() any longer since we need more
control.
* Make the drop callback pass the insert index directly instead of a
GimpDockSeparator
* Add some GIMP_LOG() debug output for DND
* Disable the GimpDockSeparator code in GimpToolbox
2009-11-29 18:22:12 +01:00
|
|
|
0,
|
2001-10-17 11:33:43 +00:00
|
|
|
dialog_target_table, G_N_ELEMENTS (dialog_target_table),
|
2001-04-10 16:03:40 +00:00
|
|
|
GDK_ACTION_MOVE);
|
2010-05-26 18:10:31 +02:00
|
|
|
|
|
|
|
/* Menu button */
|
|
|
|
dockbook->p->menu_button = gtk_button_new ();
|
|
|
|
gtk_widget_set_can_focus (dockbook->p->menu_button, FALSE);
|
|
|
|
gtk_button_set_relief (GTK_BUTTON (dockbook->p->menu_button),
|
|
|
|
GTK_RELIEF_NONE);
|
2011-11-17 00:17:46 +01:00
|
|
|
gtk_notebook_set_action_widget (notebook,
|
|
|
|
dockbook->p->menu_button,
|
|
|
|
GTK_PACK_END);
|
2010-05-26 18:10:31 +02:00
|
|
|
gtk_widget_show (dockbook->p->menu_button);
|
|
|
|
|
2017-03-05 16:01:59 +01:00
|
|
|
image = gtk_image_new_from_icon_name (GIMP_ICON_MENU_LEFT,
|
|
|
|
GTK_ICON_SIZE_MENU);
|
2014-05-07 15:30:38 +02:00
|
|
|
gtk_image_set_pixel_size (GTK_IMAGE (image), 12);
|
2017-03-05 16:01:59 +01:00
|
|
|
gtk_image_set_from_icon_name (GTK_IMAGE (image), GIMP_ICON_MENU_LEFT,
|
|
|
|
GTK_ICON_SIZE_MENU);
|
2010-05-26 18:10:31 +02:00
|
|
|
gtk_container_add (GTK_CONTAINER (dockbook->p->menu_button), image);
|
|
|
|
gtk_widget_show (image);
|
|
|
|
|
|
|
|
gimp_help_set_help_data (dockbook->p->menu_button, _("Configure this tab"),
|
|
|
|
GIMP_HELP_DOCK_TAB_MENU);
|
|
|
|
|
|
|
|
g_signal_connect_swapped (dockbook->p->menu_button, "button-press-event",
|
|
|
|
G_CALLBACK (gimp_dockbook_menu_button_press),
|
|
|
|
dockbook);
|
2001-04-10 16:03:40 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
static void
|
|
|
|
gimp_dockbook_style_updated (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
GimpDockbook *dockbook = GIMP_DOCKBOOK (widget);
|
|
|
|
GimpContext *context;
|
|
|
|
GtkWidget *tab_widget;
|
|
|
|
GList *children;
|
|
|
|
GList *iter;
|
2024-07-10 10:03:32 +00:00
|
|
|
GtkIconSize tab_size = DEFAULT_TAB_ICON_SIZE;
|
|
|
|
gint icon_size = 12;
|
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
|
|
|
|
|
|
|
GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
|
|
|
|
|
|
|
|
if (! dockbook->p->dock ||
|
|
|
|
! (context = gimp_dock_get_context (dockbook->p->dock)))
|
|
|
|
return;
|
|
|
|
|
2024-07-10 10:03:32 +00:00
|
|
|
/* Update size of 'Configure this tab' icon */
|
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
|
|
|
children = gtk_container_get_children (GTK_CONTAINER (dockbook));
|
|
|
|
for (iter = children; iter; iter = g_list_next (iter))
|
|
|
|
{
|
|
|
|
GimpDockable *dockable = GIMP_DOCKABLE (iter->data);
|
|
|
|
|
|
|
|
tab_widget = gimp_dockbook_create_tab_widget (dockbook, dockable);
|
|
|
|
gtk_notebook_set_tab_label (GTK_NOTEBOOK (dockbook),
|
|
|
|
GTK_WIDGET (dockable),
|
|
|
|
tab_widget);
|
|
|
|
}
|
|
|
|
g_list_free (children);
|
|
|
|
|
2024-07-10 10:03:32 +00:00
|
|
|
children = gtk_container_get_children (GTK_CONTAINER (dockbook->p->menu_button));
|
|
|
|
gtk_widget_style_get (GTK_WIDGET (dockbook),
|
|
|
|
"tab-icon-size", &tab_size,
|
|
|
|
NULL);
|
|
|
|
gtk_icon_size_lookup (tab_size, &icon_size, NULL);
|
|
|
|
gtk_image_set_pixel_size (GTK_IMAGE (children->data), icon_size * 0.75f);
|
|
|
|
g_list_free (children);
|
|
|
|
|
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
|
|
|
gimp_dock_invalidate_geometry (GIMP_DOCK (dockbook->p->dock));
|
|
|
|
}
|
|
|
|
|
2020-02-03 00:02:49 +02:00
|
|
|
static void
|
|
|
|
gimp_dockbook_drag_begin (GtkWidget *widget,
|
|
|
|
GdkDragContext *context)
|
|
|
|
{
|
|
|
|
GList *iter;
|
|
|
|
|
|
|
|
if (GTK_WIDGET_CLASS (parent_class)->drag_begin)
|
|
|
|
GTK_WIDGET_CLASS (parent_class)->drag_begin (widget, context);
|
|
|
|
|
|
|
|
iter = drag_callbacks;
|
|
|
|
|
|
|
|
while (iter)
|
|
|
|
{
|
|
|
|
GimpDockbookDragCallbackData *callback_data = iter->data;
|
|
|
|
|
|
|
|
iter = g_list_next (iter);
|
|
|
|
|
|
|
|
callback_data->callback (context, TRUE, callback_data->data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_dockbook_drag_end (GtkWidget *widget,
|
|
|
|
GdkDragContext *context)
|
|
|
|
{
|
|
|
|
GList *iter;
|
|
|
|
|
|
|
|
iter = drag_callbacks;
|
|
|
|
|
|
|
|
while (iter)
|
|
|
|
{
|
|
|
|
GimpDockbookDragCallbackData *callback_data = iter->data;
|
|
|
|
|
|
|
|
iter = g_list_next (iter);
|
|
|
|
|
|
|
|
callback_data->callback (context, FALSE, callback_data->data);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GTK_WIDGET_CLASS (parent_class)->drag_end)
|
|
|
|
GTK_WIDGET_CLASS (parent_class)->drag_end (widget, context);
|
|
|
|
}
|
|
|
|
|
app: Use a GdkWindow instead of GimpDockSeparators for dockable DND
Make drag-and-drop rearrangement of dockables happen directly in the
existing widget hierarchy so we don't have to use special, ugly
widgets (read GimpDockSeparator:s) for that.
More specifically, make edges of dockables and dockbooks have the same
semantics as the GimpDockSeparators had. We put a highlight colored
GdkWindow on top of the widget in question to highlight these special
drop areas. This GdkWindow is not taken into consideration in the GTK+
drag-and-drop code, so it does not interupt the DND interaction.
To achive this, there is a problem we must solve: Drag events in GTK+
are propagated inwards and out, but we sometimes want ancenstor
widgets to take care of drop events. We solve this by introducing the
concept of "drag handlers". A drag handler is asked if it will handle
a given drag event, and if it will, a client will let the drag event
be propagated upwards in the widget hierarchy. Right now, the
GimpPanedBox is the only "drag handler". The code could be generalized
more but it doesn't feel worth it at this point.
The size of the special drop area is 5px, the same size as the default
GtkPaned handles. This is because the plan is to later use these
handles as drop areas too.
Other changes of interest are:
* We need to take care of "drag-motion", "drag-drop" and widget
highlightning ourselves. We can not use the GtkDestDefaults
conveniences with gtk_drag_dest_set() any longer since we need more
control.
* Make the drop callback pass the insert index directly instead of a
GimpDockSeparator
* Add some GIMP_LOG() debug output for DND
* Disable the GimpDockSeparator code in GimpToolbox
2009-11-29 18:22:12 +01:00
|
|
|
static gboolean
|
|
|
|
gimp_dockbook_drag_motion (GtkWidget *widget,
|
|
|
|
GdkDragContext *context,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
guint time)
|
|
|
|
{
|
2015-02-19 21:18:21 +01:00
|
|
|
GimpDockbook *dockbook = GIMP_DOCKBOOK (widget);
|
|
|
|
|
|
|
|
if (gimp_paned_box_will_handle_drag (dockbook->p->drag_handler,
|
|
|
|
widget,
|
|
|
|
context,
|
|
|
|
x, y,
|
|
|
|
time))
|
|
|
|
{
|
|
|
|
gdk_drag_status (context, 0, time);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-06-08 01:37:19 +02:00
|
|
|
return GTK_WIDGET_CLASS (parent_class)->drag_motion (widget, context,
|
|
|
|
x, y, time);
|
app: Use a GdkWindow instead of GimpDockSeparators for dockable DND
Make drag-and-drop rearrangement of dockables happen directly in the
existing widget hierarchy so we don't have to use special, ugly
widgets (read GimpDockSeparator:s) for that.
More specifically, make edges of dockables and dockbooks have the same
semantics as the GimpDockSeparators had. We put a highlight colored
GdkWindow on top of the widget in question to highlight these special
drop areas. This GdkWindow is not taken into consideration in the GTK+
drag-and-drop code, so it does not interupt the DND interaction.
To achive this, there is a problem we must solve: Drag events in GTK+
are propagated inwards and out, but we sometimes want ancenstor
widgets to take care of drop events. We solve this by introducing the
concept of "drag handlers". A drag handler is asked if it will handle
a given drag event, and if it will, a client will let the drag event
be propagated upwards in the widget hierarchy. Right now, the
GimpPanedBox is the only "drag handler". The code could be generalized
more but it doesn't feel worth it at this point.
The size of the special drop area is 5px, the same size as the default
GtkPaned handles. This is because the plan is to later use these
handles as drop areas too.
Other changes of interest are:
* We need to take care of "drag-motion", "drag-drop" and widget
highlightning ourselves. We can not use the GtkDestDefaults
conveniences with gtk_drag_dest_set() any longer since we need more
control.
* Make the drop callback pass the insert index directly instead of a
GimpDockSeparator
* Add some GIMP_LOG() debug output for DND
* Disable the GimpDockSeparator code in GimpToolbox
2009-11-29 18:22:12 +01:00
|
|
|
}
|
|
|
|
|
2001-04-10 16:03:40 +00:00
|
|
|
static gboolean
|
|
|
|
gimp_dockbook_drag_drop (GtkWidget *widget,
|
2004-08-24 17:16:46 +00:00
|
|
|
GdkDragContext *context,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
guint time)
|
2001-04-10 16:03:40 +00:00
|
|
|
{
|
app: Use a GdkWindow instead of GimpDockSeparators for dockable DND
Make drag-and-drop rearrangement of dockables happen directly in the
existing widget hierarchy so we don't have to use special, ugly
widgets (read GimpDockSeparator:s) for that.
More specifically, make edges of dockables and dockbooks have the same
semantics as the GimpDockSeparators had. We put a highlight colored
GdkWindow on top of the widget in question to highlight these special
drop areas. This GdkWindow is not taken into consideration in the GTK+
drag-and-drop code, so it does not interupt the DND interaction.
To achive this, there is a problem we must solve: Drag events in GTK+
are propagated inwards and out, but we sometimes want ancenstor
widgets to take care of drop events. We solve this by introducing the
concept of "drag handlers". A drag handler is asked if it will handle
a given drag event, and if it will, a client will let the drag event
be propagated upwards in the widget hierarchy. Right now, the
GimpPanedBox is the only "drag handler". The code could be generalized
more but it doesn't feel worth it at this point.
The size of the special drop area is 5px, the same size as the default
GtkPaned handles. This is because the plan is to later use these
handles as drop areas too.
Other changes of interest are:
* We need to take care of "drag-motion", "drag-drop" and widget
highlightning ourselves. We can not use the GtkDestDefaults
conveniences with gtk_drag_dest_set() any longer since we need more
control.
* Make the drop callback pass the insert index directly instead of a
GimpDockSeparator
* Add some GIMP_LOG() debug output for DND
* Disable the GimpDockSeparator code in GimpToolbox
2009-11-29 18:22:12 +01:00
|
|
|
GimpDockbook *dockbook = GIMP_DOCKBOOK (widget);
|
|
|
|
|
|
|
|
if (gimp_paned_box_will_handle_drag (dockbook->p->drag_handler,
|
|
|
|
widget,
|
|
|
|
context,
|
|
|
|
x, y,
|
|
|
|
time))
|
|
|
|
{
|
2015-02-19 21:18:21 +01:00
|
|
|
return FALSE;
|
app: Use a GdkWindow instead of GimpDockSeparators for dockable DND
Make drag-and-drop rearrangement of dockables happen directly in the
existing widget hierarchy so we don't have to use special, ugly
widgets (read GimpDockSeparator:s) for that.
More specifically, make edges of dockables and dockbooks have the same
semantics as the GimpDockSeparators had. We put a highlight colored
GdkWindow on top of the widget in question to highlight these special
drop areas. This GdkWindow is not taken into consideration in the GTK+
drag-and-drop code, so it does not interupt the DND interaction.
To achive this, there is a problem we must solve: Drag events in GTK+
are propagated inwards and out, but we sometimes want ancenstor
widgets to take care of drop events. We solve this by introducing the
concept of "drag handlers". A drag handler is asked if it will handle
a given drag event, and if it will, a client will let the drag event
be propagated upwards in the widget hierarchy. Right now, the
GimpPanedBox is the only "drag handler". The code could be generalized
more but it doesn't feel worth it at this point.
The size of the special drop area is 5px, the same size as the default
GtkPaned handles. This is because the plan is to later use these
handles as drop areas too.
Other changes of interest are:
* We need to take care of "drag-motion", "drag-drop" and widget
highlightning ourselves. We can not use the GtkDestDefaults
conveniences with gtk_drag_dest_set() any longer since we need more
control.
* Make the drop callback pass the insert index directly instead of a
GimpDockSeparator
* Add some GIMP_LOG() debug output for DND
* Disable the GimpDockSeparator code in GimpToolbox
2009-11-29 18:22:12 +01:00
|
|
|
}
|
|
|
|
|
2018-06-08 01:37:19 +02:00
|
|
|
if (widget == gtk_drag_get_source_widget (context))
|
|
|
|
{
|
|
|
|
GList *children = gtk_container_get_children (GTK_CONTAINER (widget));
|
|
|
|
gint n_children = g_list_length (children);
|
|
|
|
|
|
|
|
g_list_free (children);
|
app: Use a GdkWindow instead of GimpDockSeparators for dockable DND
Make drag-and-drop rearrangement of dockables happen directly in the
existing widget hierarchy so we don't have to use special, ugly
widgets (read GimpDockSeparator:s) for that.
More specifically, make edges of dockables and dockbooks have the same
semantics as the GimpDockSeparators had. We put a highlight colored
GdkWindow on top of the widget in question to highlight these special
drop areas. This GdkWindow is not taken into consideration in the GTK+
drag-and-drop code, so it does not interupt the DND interaction.
To achive this, there is a problem we must solve: Drag events in GTK+
are propagated inwards and out, but we sometimes want ancenstor
widgets to take care of drop events. We solve this by introducing the
concept of "drag handlers". A drag handler is asked if it will handle
a given drag event, and if it will, a client will let the drag event
be propagated upwards in the widget hierarchy. Right now, the
GimpPanedBox is the only "drag handler". The code could be generalized
more but it doesn't feel worth it at this point.
The size of the special drop area is 5px, the same size as the default
GtkPaned handles. This is because the plan is to later use these
handles as drop areas too.
Other changes of interest are:
* We need to take care of "drag-motion", "drag-drop" and widget
highlightning ourselves. We can not use the GtkDestDefaults
conveniences with gtk_drag_dest_set() any longer since we need more
control.
* Make the drop callback pass the insert index directly instead of a
GimpDockSeparator
* Add some GIMP_LOG() debug output for DND
* Disable the GimpDockSeparator code in GimpToolbox
2009-11-29 18:22:12 +01:00
|
|
|
|
2018-06-08 01:37:19 +02:00
|
|
|
/* we dragged the only tab, and want to drop it back on the same
|
|
|
|
* notebook, this would remove and add the page, causing the
|
|
|
|
* dockbook to be destroyed in the process because it becomes
|
|
|
|
* empty
|
|
|
|
*/
|
|
|
|
if (n_children == 1)
|
|
|
|
return FALSE;
|
|
|
|
}
|
2015-02-19 21:18:21 +01:00
|
|
|
|
2018-06-08 01:37:19 +02:00
|
|
|
return GTK_WIDGET_CLASS (parent_class)->drag_drop (widget, context,
|
|
|
|
x, y, time);
|
2003-10-05 17:26:21 +00:00
|
|
|
}
|
2001-04-10 16:03:40 +00:00
|
|
|
|
2010-05-26 18:10:31 +02:00
|
|
|
static gboolean
|
|
|
|
gimp_dockbook_popup_menu (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
return gimp_dockbook_show_menu (GIMP_DOCKBOOK (widget));
|
|
|
|
}
|
|
|
|
|
2018-06-08 01:37:19 +02:00
|
|
|
static GtkNotebook *
|
|
|
|
gimp_dockbook_create_window (GtkNotebook *notebook,
|
|
|
|
GtkWidget *page,
|
|
|
|
gint x,
|
|
|
|
gint y)
|
|
|
|
{
|
|
|
|
GimpDockbook *dockbook = GIMP_DOCKBOOK (notebook);
|
|
|
|
GimpDialogFactory *dialog_factory;
|
|
|
|
GimpMenuFactory *menu_factory;
|
|
|
|
GimpDockWindow *src_dock_window;
|
|
|
|
GimpDock *src_dock;
|
|
|
|
GtkWidget *new_dock;
|
|
|
|
GimpDockWindow *new_dock_window;
|
|
|
|
GtkWidget *new_dockbook;
|
|
|
|
|
|
|
|
src_dock = gimp_dockbook_get_dock (dockbook);
|
|
|
|
src_dock_window = gimp_dock_window_from_dock (src_dock);
|
|
|
|
|
|
|
|
dialog_factory = gimp_dock_get_dialog_factory (src_dock);
|
2023-03-07 18:23:38 +01:00
|
|
|
menu_factory = menus_get_global_menu_factory (gimp_dialog_factory_get_context (dialog_factory)->gimp);
|
2018-06-08 01:37:19 +02:00
|
|
|
|
|
|
|
new_dock = gimp_dock_with_window_new (dialog_factory,
|
|
|
|
gimp_widget_get_monitor (page),
|
|
|
|
FALSE);
|
|
|
|
|
|
|
|
new_dock_window = gimp_dock_window_from_dock (GIMP_DOCK (new_dock));
|
|
|
|
gtk_window_set_position (GTK_WINDOW (new_dock_window), GTK_WIN_POS_MOUSE);
|
|
|
|
if (src_dock_window)
|
|
|
|
gimp_dock_window_setup (new_dock_window, src_dock_window);
|
|
|
|
|
|
|
|
new_dockbook = gimp_dockbook_new (menu_factory);
|
|
|
|
|
|
|
|
gimp_dock_add_book (GIMP_DOCK (new_dock), GIMP_DOCKBOOK (new_dockbook), 0);
|
|
|
|
|
|
|
|
gtk_widget_show (GTK_WIDGET (new_dock_window));
|
|
|
|
gtk_widget_show (new_dock);
|
|
|
|
|
|
|
|
return GTK_NOTEBOOK (new_dockbook);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_dockbook_page_added (GtkNotebook *notebook,
|
|
|
|
GtkWidget *child,
|
|
|
|
guint page_num)
|
|
|
|
{
|
|
|
|
GimpDockbook *dockbook = GIMP_DOCKBOOK (notebook);
|
|
|
|
GimpDockable *dockable = GIMP_DOCKABLE (child);
|
|
|
|
GtkWidget *tab_widget;
|
|
|
|
GtkWidget *menu_widget;
|
|
|
|
|
|
|
|
GIMP_LOG (DND, "GimpDockable %p added to GimpDockbook %p",
|
|
|
|
dockable, dockbook);
|
|
|
|
|
|
|
|
tab_widget = gimp_dockbook_create_tab_widget (dockbook, dockable);
|
|
|
|
|
|
|
|
/* For the notebook right-click menu, always use the icon style */
|
|
|
|
menu_widget =
|
|
|
|
gimp_dockable_create_tab_widget (dockable,
|
|
|
|
gimp_dock_get_context (dockbook->p->dock),
|
|
|
|
GIMP_TAB_STYLE_ICON_BLURB,
|
|
|
|
GTK_ICON_SIZE_MENU);
|
|
|
|
|
|
|
|
gtk_notebook_set_tab_label (notebook, child, tab_widget);
|
|
|
|
gtk_notebook_set_menu_label (notebook, child, menu_widget);
|
|
|
|
|
2018-06-08 01:53:46 +02:00
|
|
|
if (! gimp_dockable_get_locked (dockable))
|
2018-06-08 01:37:19 +02:00
|
|
|
{
|
|
|
|
gtk_notebook_set_tab_reorderable (notebook, child, TRUE);
|
|
|
|
gtk_notebook_set_tab_detachable (notebook, child, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_dockable_set_dockbook (dockable, dockbook);
|
|
|
|
|
|
|
|
gimp_dockable_set_context (dockable,
|
|
|
|
gimp_dock_get_context (dockbook->p->dock));
|
|
|
|
|
|
|
|
g_signal_connect (dockable, "notify::locked",
|
|
|
|
G_CALLBACK (gimp_dockbook_tab_locked_notify),
|
|
|
|
dockbook);
|
|
|
|
|
2018-06-17 15:14:15 +02:00
|
|
|
gtk_widget_show (child);
|
2018-06-08 01:37:19 +02:00
|
|
|
gtk_notebook_set_current_page (notebook, page_num);
|
|
|
|
|
|
|
|
g_signal_emit (dockbook, dockbook_signals[DOCKABLE_ADDED], 0, dockable);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_dockbook_page_removed (GtkNotebook *notebook,
|
|
|
|
GtkWidget *child,
|
|
|
|
guint page_num)
|
|
|
|
{
|
|
|
|
GimpDockbook *dockbook = GIMP_DOCKBOOK (notebook);
|
|
|
|
GimpDockable *dockable = GIMP_DOCKABLE (child);
|
|
|
|
|
|
|
|
GIMP_LOG (DND, "GimpDockable removed %p from GimpDockbook %p",
|
|
|
|
dockable, dockbook);
|
|
|
|
|
|
|
|
g_signal_handlers_disconnect_by_func (dockable,
|
|
|
|
G_CALLBACK (gimp_dockbook_tab_locked_notify),
|
|
|
|
dockbook);
|
|
|
|
|
|
|
|
gimp_dockable_set_dockbook (dockable, NULL);
|
|
|
|
|
|
|
|
gimp_dockable_set_context (dockable, NULL);
|
|
|
|
|
|
|
|
g_signal_emit (dockbook, dockbook_signals[DOCKABLE_REMOVED], 0, dockable);
|
|
|
|
|
|
|
|
if (dockbook->p->dock)
|
|
|
|
{
|
|
|
|
GList *children = gtk_container_get_children (GTK_CONTAINER (dockbook));
|
|
|
|
|
|
|
|
if (! children)
|
|
|
|
gimp_dock_remove_book (dockbook->p->dock, dockbook);
|
|
|
|
|
|
|
|
g_list_free (children);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-21 05:30:48 +00:00
|
|
|
/* Restore GTK2 behavior of mouse-scrolling to switch between
|
|
|
|
* notebook tabs. References Geany's notebook_tab_bar_click_cb ()
|
|
|
|
* at https://github.com/geany/geany/blob/master/src/notebook.c
|
|
|
|
*/
|
|
|
|
static gboolean
|
|
|
|
gimp_dockbook_tab_scroll_cb (GtkWidget *widget,
|
|
|
|
GdkEventScroll *event)
|
|
|
|
{
|
|
|
|
GtkNotebook *notebook = GTK_NOTEBOOK (widget);
|
|
|
|
GtkWidget *page = NULL;
|
|
|
|
|
|
|
|
page = gtk_notebook_get_nth_page (notebook,
|
|
|
|
gtk_notebook_get_current_page (notebook));
|
|
|
|
if (! page)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
switch (event->direction)
|
|
|
|
{
|
|
|
|
case GDK_SCROLL_RIGHT:
|
|
|
|
case GDK_SCROLL_DOWN:
|
|
|
|
gtk_notebook_next_page (notebook);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_SCROLL_LEFT:
|
|
|
|
case GDK_SCROLL_UP:
|
|
|
|
gtk_notebook_prev_page (notebook);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-06-08 01:37:19 +02:00
|
|
|
static void
|
|
|
|
gimp_dockbook_page_reordered (GtkNotebook *notebook,
|
|
|
|
GtkWidget *child,
|
|
|
|
guint page_num)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-05-26 18:10:31 +02:00
|
|
|
static gboolean
|
|
|
|
gimp_dockbook_menu_button_press (GimpDockbook *dockbook,
|
|
|
|
GdkEventButton *bevent,
|
|
|
|
GtkWidget *button)
|
|
|
|
{
|
|
|
|
gboolean handled = FALSE;
|
|
|
|
|
|
|
|
if (bevent->button == 1 && bevent->type == GDK_BUTTON_PRESS)
|
|
|
|
handled = gimp_dockbook_show_menu (dockbook);
|
|
|
|
|
|
|
|
return handled;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gimp_dockbook_show_menu (GimpDockbook *dockbook)
|
|
|
|
{
|
2018-05-26 16:28:58 +02:00
|
|
|
GimpUIManager *dockbook_ui_manager;
|
|
|
|
GimpUIManager *dialog_ui_manager;
|
|
|
|
const gchar *dialog_ui_path;
|
|
|
|
gpointer dialog_popup_data;
|
|
|
|
GimpDockable *dockable;
|
|
|
|
gint page_num;
|
2010-05-26 18:10:31 +02:00
|
|
|
|
2023-03-07 18:23:38 +01:00
|
|
|
dockbook_ui_manager = dockbook->p->ui_manager;
|
2010-05-26 18:10:31 +02:00
|
|
|
|
|
|
|
if (! dockbook_ui_manager)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
|
|
|
|
dockable = GIMP_DOCKABLE (gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook),
|
|
|
|
page_num));
|
|
|
|
|
2010-06-12 18:45:02 +02:00
|
|
|
if (! dockable)
|
2010-05-26 18:10:31 +02:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
dialog_ui_manager = gimp_dockable_get_menu (dockable,
|
|
|
|
&dialog_ui_path,
|
|
|
|
&dialog_popup_data);
|
|
|
|
|
|
|
|
/* an action callback may destroy both dockable and dockbook, so
|
|
|
|
* reference them for gimp_dockbook_menu_end()
|
|
|
|
*/
|
|
|
|
g_object_ref (dockable);
|
|
|
|
g_object_set_data_full (G_OBJECT (dockable), GIMP_DOCKABLE_DETACH_REF_KEY,
|
|
|
|
g_object_ref (dockbook),
|
|
|
|
g_object_unref);
|
|
|
|
|
2023-05-23 16:31:57 +02:00
|
|
|
if (dialog_ui_manager)
|
|
|
|
gimp_ui_manager_update (dialog_ui_manager, dialog_popup_data);
|
|
|
|
|
|
|
|
gimp_ui_manager_update (dockbook_ui_manager, dockable);
|
|
|
|
|
2018-05-02 00:44:38 +02:00
|
|
|
gimp_ui_manager_ui_popup_at_widget (dockbook_ui_manager,
|
|
|
|
"/dockable-popup",
|
2023-02-27 18:49:45 +01:00
|
|
|
dialog_ui_manager,
|
|
|
|
dialog_ui_path,
|
2018-05-02 00:44:38 +02:00
|
|
|
dockbook->p->menu_button,
|
|
|
|
GDK_GRAVITY_WEST,
|
|
|
|
GDK_GRAVITY_NORTH_EAST,
|
|
|
|
NULL,
|
|
|
|
(GDestroyNotify) gimp_dockbook_menu_end,
|
|
|
|
dockable);
|
2010-05-26 18:10:31 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_dockbook_menu_end (GimpDockable *dockable)
|
|
|
|
{
|
2010-06-12 18:45:02 +02:00
|
|
|
/* release gimp_dockbook_show_menu()'s references */
|
2010-05-26 18:10:31 +02:00
|
|
|
g_object_set_data (G_OBJECT (dockable), GIMP_DOCKABLE_DETACH_REF_KEY, NULL);
|
|
|
|
g_object_unref (dockable);
|
|
|
|
}
|
|
|
|
|
2001-04-10 16:03:40 +00:00
|
|
|
|
2018-06-08 01:37:19 +02:00
|
|
|
/* public functions */
|
2001-04-10 16:03:40 +00:00
|
|
|
|
2003-10-05 17:26:21 +00:00
|
|
|
GtkWidget *
|
|
|
|
gimp_dockbook_new (GimpMenuFactory *menu_factory)
|
|
|
|
{
|
|
|
|
GimpDockbook *dockbook;
|
2001-04-10 16:03:40 +00:00
|
|
|
|
2003-10-05 17:26:21 +00:00
|
|
|
g_return_val_if_fail (GIMP_IS_MENU_FACTORY (menu_factory), NULL);
|
2001-04-10 16:03:40 +00:00
|
|
|
|
2003-10-05 17:26:21 +00:00
|
|
|
dockbook = g_object_new (GIMP_TYPE_DOCKBOOK, NULL);
|
2001-04-10 16:03:40 +00:00
|
|
|
|
2023-03-07 18:23:38 +01:00
|
|
|
dockbook->p->ui_manager = gimp_menu_factory_get_manager (menu_factory,
|
2016-11-23 07:01:41 +01:00
|
|
|
"<Dockable>",
|
2018-05-14 00:34:16 +02:00
|
|
|
dockbook);
|
2004-04-22 17:14:22 +00:00
|
|
|
|
2024-08-24 23:03:04 +02:00
|
|
|
gimp_help_connect (GTK_WIDGET (dockbook), NULL, gimp_dockbook_help_func,
|
2019-08-09 13:11:30 +02:00
|
|
|
GIMP_HELP_DOCK, dockbook, NULL);
|
2003-10-05 17:26:21 +00:00
|
|
|
|
|
|
|
return GTK_WIDGET (dockbook);
|
2001-04-10 16:03:40 +00:00
|
|
|
}
|
|
|
|
|
2009-09-13 16:30:09 +02:00
|
|
|
GimpDock *
|
|
|
|
gimp_dockbook_get_dock (GimpDockbook *dockbook)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DOCKBOOK (dockbook), NULL);
|
|
|
|
|
|
|
|
return dockbook->p->dock;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_dockbook_set_dock (GimpDockbook *dockbook,
|
|
|
|
GimpDock *dock)
|
|
|
|
{
|
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
|
|
|
GimpContext *context;
|
|
|
|
|
2009-09-13 16:30:09 +02:00
|
|
|
g_return_if_fail (GIMP_IS_DOCKBOOK (dockbook));
|
|
|
|
g_return_if_fail (dock == NULL || GIMP_IS_DOCK (dock));
|
|
|
|
|
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
|
|
|
if (dockbook->p->dock &&
|
|
|
|
(context = gimp_dock_get_context (dockbook->p->dock)) != NULL)
|
|
|
|
{
|
|
|
|
g_signal_handlers_disconnect_by_func (GIMP_GUI_CONFIG (context->gimp->config),
|
|
|
|
G_CALLBACK (gimp_dockbook_style_updated),
|
|
|
|
dockbook);
|
|
|
|
}
|
|
|
|
|
2009-09-13 16:30:09 +02:00
|
|
|
dockbook->p->dock = dock;
|
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
|
|
|
|
|
|
|
if (dockbook->p->dock &&
|
|
|
|
(context = gimp_dock_get_context (dockbook->p->dock)) != NULL)
|
|
|
|
{
|
|
|
|
g_signal_connect_object (GIMP_GUI_CONFIG (context->gimp->config),
|
|
|
|
"notify::theme",
|
|
|
|
G_CALLBACK (gimp_dockbook_style_updated),
|
|
|
|
dockbook, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
|
|
|
|
g_signal_connect_object (GIMP_GUI_CONFIG (context->gimp->config),
|
|
|
|
"notify::override-theme-icon-size",
|
|
|
|
G_CALLBACK (gimp_dockbook_style_updated),
|
|
|
|
dockbook, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
|
|
|
|
g_signal_connect_object (GIMP_GUI_CONFIG (context->gimp->config),
|
|
|
|
"notify::custom-icon-size",
|
|
|
|
G_CALLBACK (gimp_dockbook_style_updated),
|
|
|
|
dockbook, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
|
|
|
|
}
|
2009-09-13 16:30:09 +02:00
|
|
|
}
|
|
|
|
|
2011-07-03 16:36:38 +02:00
|
|
|
/**
|
|
|
|
* gimp_dockbook_add_from_dialog_factory:
|
|
|
|
* @dockbook: The #DockBook
|
|
|
|
* @identifiers: The dockable identifier(s)
|
|
|
|
*
|
2018-03-24 16:49:01 -04:00
|
|
|
* Add a dockable from the dialog factory associated with the dockbook.
|
2011-07-03 16:36:38 +02:00
|
|
|
**/
|
|
|
|
GtkWidget *
|
|
|
|
gimp_dockbook_add_from_dialog_factory (GimpDockbook *dockbook,
|
2018-06-08 02:40:31 +02:00
|
|
|
const gchar *identifiers)
|
2011-07-03 16:36:38 +02:00
|
|
|
{
|
|
|
|
GtkWidget *dockable;
|
|
|
|
GimpDock *dock;
|
|
|
|
gchar *identifier;
|
|
|
|
gchar *p;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_DOCKBOOK (dockbook), NULL);
|
|
|
|
g_return_val_if_fail (identifiers != NULL, NULL);
|
|
|
|
|
|
|
|
identifier = g_strdup (identifiers);
|
|
|
|
|
|
|
|
p = strchr (identifier, '|');
|
|
|
|
|
|
|
|
if (p)
|
|
|
|
*p = '\0';
|
|
|
|
|
|
|
|
dock = gimp_dockbook_get_dock (dockbook);
|
|
|
|
dockable = gimp_dialog_factory_dockable_new (gimp_dock_get_dialog_factory (dock),
|
|
|
|
dock,
|
|
|
|
identifier, -1);
|
|
|
|
|
|
|
|
g_free (identifier);
|
|
|
|
|
|
|
|
/* Maybe gimp_dialog_factory_dockable_new() returned an already
|
|
|
|
* existing singleton dockable, so check if it already is
|
|
|
|
* attached to a dockbook.
|
|
|
|
*/
|
|
|
|
if (dockable && ! gimp_dockable_get_dockbook (GIMP_DOCKABLE (dockable)))
|
2018-06-08 02:40:31 +02:00
|
|
|
gtk_notebook_append_page (GTK_NOTEBOOK (dockbook),
|
|
|
|
dockable, NULL);
|
2011-07-03 16:36:38 +02:00
|
|
|
|
|
|
|
return dockable;
|
|
|
|
}
|
|
|
|
|
2010-01-06 13:33:47 +01:00
|
|
|
/**
|
|
|
|
* gimp_dockbook_update_with_context:
|
|
|
|
* @dockbook:
|
|
|
|
* @context:
|
|
|
|
*
|
|
|
|
* Set @context on all dockables in @dockbook.
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gimp_dockbook_update_with_context (GimpDockbook *dockbook,
|
|
|
|
GimpContext *context)
|
|
|
|
{
|
|
|
|
GList *children = gtk_container_get_children (GTK_CONTAINER (dockbook));
|
2018-05-26 16:28:58 +02:00
|
|
|
GList *iter;
|
2010-01-06 13:33:47 +01:00
|
|
|
|
2018-05-26 16:28:58 +02:00
|
|
|
for (iter = children; iter; iter = g_list_next (iter))
|
2010-01-06 13:33:47 +01:00
|
|
|
{
|
|
|
|
GimpDockable *dockable = GIMP_DOCKABLE (iter->data);
|
|
|
|
|
|
|
|
gimp_dockable_set_context (dockable, context);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free (children);
|
|
|
|
}
|
|
|
|
|
2003-07-08 15:07:56 +00:00
|
|
|
GtkWidget *
|
2008-05-19 21:11:03 +00:00
|
|
|
gimp_dockbook_create_tab_widget (GimpDockbook *dockbook,
|
|
|
|
GimpDockable *dockable)
|
2002-03-20 12:57:59 +00:00
|
|
|
{
|
2009-09-15 07:58:14 +02:00
|
|
|
GtkWidget *tab_widget;
|
|
|
|
GimpDockWindow *dock_window;
|
2019-07-02 03:54:38 +02:00
|
|
|
GimpAction *action = NULL;
|
2018-05-31 02:59:05 +02:00
|
|
|
GtkIconSize tab_size = DEFAULT_TAB_ICON_SIZE;
|
2002-03-20 12:57:59 +00:00
|
|
|
|
2018-05-31 02:59:05 +02:00
|
|
|
gtk_widget_style_get (GTK_WIDGET (dockbook),
|
|
|
|
"tab-icon-size", &tab_size,
|
|
|
|
NULL);
|
2010-04-18 17:42:26 +02:00
|
|
|
tab_widget =
|
2018-05-26 16:28:58 +02:00
|
|
|
gimp_dockable_create_tab_widget (dockable,
|
|
|
|
gimp_dock_get_context (dockbook->p->dock),
|
|
|
|
gimp_dockable_get_tab_style (dockable),
|
2018-05-31 02:59:05 +02:00
|
|
|
tab_size);
|
2018-05-26 16:28:58 +02:00
|
|
|
|
2018-06-08 01:37:19 +02:00
|
|
|
if (GIMP_IS_VIEW (tab_widget))
|
2018-05-26 16:28:58 +02:00
|
|
|
{
|
|
|
|
GtkWidget *event_box;
|
|
|
|
|
|
|
|
event_box = gtk_event_box_new ();
|
|
|
|
gtk_event_box_set_visible_window (GTK_EVENT_BOX (event_box), FALSE);
|
|
|
|
gtk_event_box_set_above_child (GTK_EVENT_BOX (event_box), TRUE);
|
|
|
|
gtk_container_add (GTK_CONTAINER (event_box), tab_widget);
|
|
|
|
gtk_widget_show (tab_widget);
|
|
|
|
|
|
|
|
tab_widget = event_box;
|
|
|
|
}
|
2002-03-20 12:57:59 +00:00
|
|
|
|
2005-10-30 18:41:18 +00:00
|
|
|
/* EEK */
|
2009-09-15 07:58:14 +02:00
|
|
|
dock_window = gimp_dock_window_from_dock (dockbook->p->dock);
|
2011-05-13 18:56:03 +02:00
|
|
|
if (dock_window &&
|
|
|
|
gimp_dock_container_get_ui_manager (GIMP_DOCK_CONTAINER (dock_window)))
|
2005-10-30 18:41:18 +00:00
|
|
|
{
|
|
|
|
const gchar *dialog_id;
|
|
|
|
|
|
|
|
dialog_id = g_object_get_data (G_OBJECT (dockable),
|
|
|
|
"gimp-dialog-identifier");
|
|
|
|
|
|
|
|
if (dialog_id)
|
|
|
|
{
|
2011-05-13 18:56:03 +02:00
|
|
|
GimpDockContainer *dock_container;
|
|
|
|
GimpActionGroup *group;
|
|
|
|
|
|
|
|
dock_container = GIMP_DOCK_CONTAINER (dock_window);
|
2005-10-30 18:41:18 +00:00
|
|
|
|
|
|
|
group = gimp_ui_manager_get_action_group
|
2011-05-13 18:56:03 +02:00
|
|
|
(gimp_dock_container_get_ui_manager (dock_container), "dialogs");
|
2005-10-30 18:41:18 +00:00
|
|
|
|
|
|
|
if (group)
|
|
|
|
{
|
|
|
|
GList *actions;
|
|
|
|
GList *list;
|
|
|
|
|
2019-07-02 03:54:38 +02:00
|
|
|
actions = gimp_action_group_list_actions (group);
|
2005-10-30 18:41:18 +00:00
|
|
|
|
|
|
|
for (list = actions; list; list = g_list_next (list))
|
|
|
|
{
|
|
|
|
if (GIMP_IS_STRING_ACTION (list->data) &&
|
|
|
|
strstr (GIMP_STRING_ACTION (list->data)->value,
|
|
|
|
dialog_id))
|
|
|
|
{
|
|
|
|
action = list->data;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free (actions);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (action)
|
|
|
|
gimp_widget_set_accel_help (tab_widget, action);
|
|
|
|
else
|
2010-01-05 00:30:10 +01:00
|
|
|
gimp_help_set_help_data (tab_widget,
|
|
|
|
gimp_dockable_get_blurb (dockable),
|
|
|
|
gimp_dockable_get_help_id (dockable));
|
2002-03-20 12:57:59 +00:00
|
|
|
|
|
|
|
return tab_widget;
|
|
|
|
}
|
|
|
|
|
app: Use a GdkWindow instead of GimpDockSeparators for dockable DND
Make drag-and-drop rearrangement of dockables happen directly in the
existing widget hierarchy so we don't have to use special, ugly
widgets (read GimpDockSeparator:s) for that.
More specifically, make edges of dockables and dockbooks have the same
semantics as the GimpDockSeparators had. We put a highlight colored
GdkWindow on top of the widget in question to highlight these special
drop areas. This GdkWindow is not taken into consideration in the GTK+
drag-and-drop code, so it does not interupt the DND interaction.
To achive this, there is a problem we must solve: Drag events in GTK+
are propagated inwards and out, but we sometimes want ancenstor
widgets to take care of drop events. We solve this by introducing the
concept of "drag handlers". A drag handler is asked if it will handle
a given drag event, and if it will, a client will let the drag event
be propagated upwards in the widget hierarchy. Right now, the
GimpPanedBox is the only "drag handler". The code could be generalized
more but it doesn't feel worth it at this point.
The size of the special drop area is 5px, the same size as the default
GtkPaned handles. This is because the plan is to later use these
handles as drop areas too.
Other changes of interest are:
* We need to take care of "drag-motion", "drag-drop" and widget
highlightning ourselves. We can not use the GtkDestDefaults
conveniences with gtk_drag_dest_set() any longer since we need more
control.
* Make the drop callback pass the insert index directly instead of a
GimpDockSeparator
* Add some GIMP_LOG() debug output for DND
* Disable the GimpDockSeparator code in GimpToolbox
2009-11-29 18:22:12 +01:00
|
|
|
/**
|
|
|
|
* gimp_dockable_set_drag_handler:
|
|
|
|
* @dockable:
|
|
|
|
* @handler:
|
|
|
|
*
|
|
|
|
* Set a drag handler that will be asked if it will handle drag events
|
|
|
|
* before the dockbook handles the event itself.
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gimp_dockbook_set_drag_handler (GimpDockbook *dockbook,
|
|
|
|
GimpPanedBox *drag_handler)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DOCKBOOK (dockbook));
|
|
|
|
|
|
|
|
dockbook->p->drag_handler = drag_handler;
|
|
|
|
}
|
|
|
|
|
2020-02-03 00:02:49 +02:00
|
|
|
void
|
|
|
|
gimp_dockbook_add_drag_callback (GimpDockbookDragCallback callback,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpDockbookDragCallbackData *callback_data;
|
|
|
|
|
|
|
|
callback_data = g_slice_new (GimpDockbookDragCallbackData);
|
|
|
|
|
|
|
|
callback_data->callback = callback;
|
|
|
|
callback_data->data = data;
|
|
|
|
|
|
|
|
drag_callbacks = g_list_prepend (drag_callbacks, callback_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_dockbook_remove_drag_callback (GimpDockbookDragCallback callback,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GList *iter;
|
|
|
|
|
|
|
|
iter = drag_callbacks;
|
|
|
|
|
|
|
|
while (iter)
|
|
|
|
{
|
|
|
|
GimpDockbookDragCallbackData *callback_data = iter->data;
|
|
|
|
GList *next = g_list_next (iter);
|
|
|
|
|
|
|
|
if (callback_data->callback == callback &&
|
|
|
|
callback_data->data == data)
|
|
|
|
{
|
|
|
|
g_slice_free (GimpDockbookDragCallbackData, callback_data);
|
|
|
|
|
|
|
|
drag_callbacks = g_list_delete_link (drag_callbacks, iter);
|
|
|
|
}
|
|
|
|
|
|
|
|
iter = next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-26 16:28:58 +02:00
|
|
|
|
2018-06-08 01:37:19 +02:00
|
|
|
/* private functions */
|
2007-09-17 15:40:01 +00:00
|
|
|
|
2008-05-19 21:11:03 +00:00
|
|
|
static void
|
|
|
|
gimp_dockbook_tab_locked_notify (GimpDockable *dockable,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GimpDockbook *dockbook)
|
|
|
|
{
|
2018-06-08 01:53:46 +02:00
|
|
|
gboolean locked = gimp_dockable_get_locked (dockable);
|
2008-05-19 21:11:03 +00:00
|
|
|
|
2018-06-08 01:37:19 +02:00
|
|
|
gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (dockbook),
|
|
|
|
GTK_WIDGET (dockable), ! locked);
|
|
|
|
gtk_notebook_set_tab_detachable (GTK_NOTEBOOK (dockbook),
|
|
|
|
GTK_WIDGET (dockable), ! locked);
|
2008-05-19 21:11:03 +00:00
|
|
|
}
|
|
|
|
|
2003-08-26 10:07:01 +00:00
|
|
|
static void
|
|
|
|
gimp_dockbook_help_func (const gchar *help_id,
|
|
|
|
gpointer help_data)
|
|
|
|
{
|
2008-05-19 21:11:03 +00:00
|
|
|
GimpDockbook *dockbook = GIMP_DOCKBOOK (help_data);
|
2003-08-26 10:07:01 +00:00
|
|
|
GtkWidget *dockable;
|
|
|
|
gint page_num;
|
|
|
|
|
|
|
|
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
|
|
|
|
|
|
|
|
dockable = gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook), page_num);
|
|
|
|
|
|
|
|
if (GIMP_IS_DOCKABLE (dockable))
|
2010-01-05 00:30:10 +01:00
|
|
|
gimp_standard_help_func (gimp_dockable_get_help_id (GIMP_DOCKABLE (dockable)),
|
|
|
|
NULL);
|
2003-08-26 10:07:01 +00:00
|
|
|
else
|
|
|
|
gimp_standard_help_func (GIMP_HELP_DOCK, NULL);
|
|
|
|
}
|