2006-12-09 21:33:38 +00:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2002-11-05 00:02:56 +00:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* gimpcoloreditor.c
|
|
|
|
* Copyright (C) 2002 Michael Natterer <mitch@gimp.org>
|
|
|
|
*
|
2009-01-17 22:28:01 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2002-11-05 00:02:56 +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
|
2002-11-05 00:02:56 +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/>.
|
2002-11-05 00:02:56 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2003-10-11 16:50:35 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2012-03-29 19:19:01 +02:00
|
|
|
#include <gegl.h>
|
2002-11-05 00:02:56 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2019-07-31 10:16:21 +02:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2002-11-05 00:02:56 +00:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
#include "widgets-types.h"
|
|
|
|
|
2006-09-26 08:55:41 +00:00
|
|
|
#include "config/gimpcoreconfig.h"
|
|
|
|
|
|
|
|
#include "core/gimp.h"
|
2002-11-05 00:02:56 +00:00
|
|
|
#include "core/gimpcontext.h"
|
|
|
|
|
|
|
|
#include "gimpcoloreditor.h"
|
2015-12-23 03:32:25 +01:00
|
|
|
#include "gimpcolorhistory.h"
|
2003-10-10 21:24:12 +00:00
|
|
|
#include "gimpdocked.h"
|
2004-05-27 12:41:22 +00:00
|
|
|
#include "gimpfgbgeditor.h"
|
2005-03-31 13:39:18 +00:00
|
|
|
#include "gimpfgbgview.h"
|
2007-05-25 11:42:28 +00:00
|
|
|
#include "gimpsessioninfo-aux.h"
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2003-03-25 16:38:19 +00:00
|
|
|
#include "gimp-intl.h"
|
2002-11-05 00:02:56 +00:00
|
|
|
|
|
|
|
|
2005-05-29 13:48:03 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_CONTEXT
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-12-19 22:37:49 +00:00
|
|
|
static void gimp_color_editor_docked_iface_init (GimpDockedInterface *iface);
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2015-12-23 03:32:25 +01:00
|
|
|
static void gimp_color_editor_constructed (GObject *object);
|
2010-09-26 22:38:01 +02:00
|
|
|
static void gimp_color_editor_dispose (GObject *object);
|
2005-05-29 13:48:03 +00:00
|
|
|
static void gimp_color_editor_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gimp_color_editor_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
2011-01-09 20:38:01 +01:00
|
|
|
static void gimp_color_editor_style_updated (GtkWidget *widget);
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2004-05-23 10:04:41 +00:00
|
|
|
static void gimp_color_editor_set_aux_info (GimpDocked *docked,
|
|
|
|
GList *aux_info);
|
2003-10-11 16:50:35 +00:00
|
|
|
static GList *gimp_color_editor_get_aux_info (GimpDocked *docked);
|
2006-08-29 21:44:51 +00:00
|
|
|
static GtkWidget *gimp_color_editor_get_preview (GimpDocked *docked,
|
|
|
|
GimpContext *context,
|
|
|
|
GtkIconSize size);
|
2004-05-23 10:04:41 +00:00
|
|
|
static void gimp_color_editor_set_context (GimpDocked *docked,
|
|
|
|
GimpContext *context);
|
2003-10-10 21:24:12 +00:00
|
|
|
|
2002-11-05 00:02:56 +00:00
|
|
|
static void gimp_color_editor_fg_changed (GimpContext *context,
|
2023-11-14 20:04:14 +01:00
|
|
|
GeglColor *color,
|
2002-11-05 00:02:56 +00:00
|
|
|
GimpColorEditor *editor);
|
|
|
|
static void gimp_color_editor_bg_changed (GimpContext *context,
|
2023-11-14 20:04:14 +01:00
|
|
|
GeglColor *color,
|
2002-11-05 00:02:56 +00:00
|
|
|
GimpColorEditor *editor);
|
|
|
|
static void gimp_color_editor_color_changed (GimpColorSelector *selector,
|
|
|
|
const GimpRGB *rgb,
|
|
|
|
const GimpHSV *hsv,
|
|
|
|
GimpColorEditor *editor);
|
|
|
|
static void gimp_color_editor_tab_toggled (GtkWidget *widget,
|
|
|
|
GimpColorEditor *editor);
|
2004-05-27 12:41:22 +00:00
|
|
|
static void gimp_color_editor_fg_bg_notify (GtkWidget *widget,
|
|
|
|
GParamSpec *pspec,
|
2002-11-05 00:02:56 +00:00
|
|
|
GimpColorEditor *editor);
|
|
|
|
static void gimp_color_editor_color_picked (GtkWidget *widget,
|
|
|
|
const GimpRGB *rgb,
|
|
|
|
GimpColorEditor *editor);
|
2005-05-19 17:08:03 +00:00
|
|
|
static void gimp_color_editor_entry_changed (GimpColorHexEntry *entry,
|
|
|
|
GimpColorEditor *editor);
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2015-12-23 03:32:25 +01:00
|
|
|
static void gimp_color_editor_history_selected (GimpColorHistory *history,
|
|
|
|
const GimpRGB *rgb,
|
|
|
|
GimpColorEditor *editor);
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2005-12-19 22:37:49 +00:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GimpColorEditor, gimp_color_editor, GIMP_TYPE_EDITOR,
|
|
|
|
G_IMPLEMENT_INTERFACE (GIMP_TYPE_DOCKED,
|
2006-05-15 09:46:31 +00:00
|
|
|
gimp_color_editor_docked_iface_init))
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2005-12-19 22:37:49 +00:00
|
|
|
#define parent_class gimp_color_editor_parent_class
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2005-12-19 22:37:49 +00:00
|
|
|
static GimpDockedInterface *parent_docked_iface = NULL;
|
2002-11-05 00:02:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_editor_class_init (GimpColorEditorClass* klass)
|
|
|
|
{
|
2010-09-26 22:38:01 +02:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2011-01-09 20:38:01 +01:00
|
|
|
object_class->constructed = gimp_color_editor_constructed;
|
|
|
|
object_class->dispose = gimp_color_editor_dispose;
|
|
|
|
object_class->set_property = gimp_color_editor_set_property;
|
|
|
|
object_class->get_property = gimp_color_editor_get_property;
|
2005-05-29 13:48:03 +00:00
|
|
|
|
2011-01-09 20:38:01 +01:00
|
|
|
widget_class->style_updated = gimp_color_editor_style_updated;
|
2005-05-29 13:48:03 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_CONTEXT,
|
|
|
|
g_param_spec_object ("context",
|
|
|
|
NULL, NULL,
|
|
|
|
GIMP_TYPE_CONTEXT,
|
2015-12-23 03:32:25 +01:00
|
|
|
G_PARAM_CONSTRUCT |
|
2006-01-18 20:29:40 +00:00
|
|
|
GIMP_PARAM_READWRITE));
|
2002-11-05 00:02:56 +00:00
|
|
|
}
|
|
|
|
|
2006-08-29 21:44:51 +00:00
|
|
|
static void
|
|
|
|
gimp_color_editor_docked_iface_init (GimpDockedInterface *iface)
|
|
|
|
{
|
|
|
|
parent_docked_iface = g_type_interface_peek_parent (iface);
|
|
|
|
|
|
|
|
if (! parent_docked_iface)
|
|
|
|
parent_docked_iface = g_type_default_interface_peek (GIMP_TYPE_DOCKED);
|
|
|
|
|
|
|
|
iface->get_preview = gimp_color_editor_get_preview;
|
|
|
|
iface->set_aux_info = gimp_color_editor_set_aux_info;
|
|
|
|
iface->get_aux_info = gimp_color_editor_get_aux_info;
|
|
|
|
iface->set_context = gimp_color_editor_set_context;
|
|
|
|
}
|
|
|
|
|
2002-11-05 00:02:56 +00:00
|
|
|
static void
|
|
|
|
gimp_color_editor_init (GimpColorEditor *editor)
|
|
|
|
{
|
|
|
|
GtkWidget *notebook;
|
2005-05-19 17:08:03 +00:00
|
|
|
GtkWidget *hbox;
|
2005-05-20 10:54:44 +00:00
|
|
|
GtkWidget *button;
|
2002-11-05 00:02:56 +00:00
|
|
|
gint content_spacing;
|
|
|
|
gint button_spacing;
|
|
|
|
GtkIconSize button_icon_size;
|
|
|
|
GimpRGB rgb;
|
|
|
|
GimpHSV hsv;
|
|
|
|
GList *list;
|
|
|
|
GSList *group;
|
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
|
|
|
gint icon_width = 40;
|
|
|
|
gint icon_height = 38;
|
2002-11-05 00:02:56 +00:00
|
|
|
|
|
|
|
editor->context = NULL;
|
|
|
|
editor->edit_bg = FALSE;
|
|
|
|
|
|
|
|
gimp_rgba_set (&rgb, 0.0, 0.0, 0.0, 1.0);
|
|
|
|
gimp_rgb_to_hsv (&rgb, &hsv);
|
|
|
|
|
|
|
|
gtk_widget_style_get (GTK_WIDGET (editor),
|
2005-08-03 09:34:55 +00:00
|
|
|
"content-spacing", &content_spacing,
|
2006-04-12 12:49:29 +00:00
|
|
|
"button-spacing", &button_spacing,
|
2005-08-03 09:34:55 +00:00
|
|
|
"button-icon-size", &button_icon_size,
|
2006-04-12 12:49:29 +00:00
|
|
|
NULL);
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2011-09-30 11:29:11 +02:00
|
|
|
editor->hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, button_spacing);
|
|
|
|
gtk_box_set_homogeneous (GTK_BOX (editor->hbox), TRUE);
|
2002-11-05 00:02:56 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (editor), editor->hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (editor->hbox);
|
|
|
|
|
|
|
|
editor->notebook = gimp_color_selector_new (GIMP_TYPE_COLOR_NOTEBOOK,
|
|
|
|
&rgb, &hsv,
|
2018-03-04 15:44:02 +01:00
|
|
|
GIMP_COLOR_SELECTOR_RED);
|
2002-11-05 00:02:56 +00:00
|
|
|
gimp_color_selector_set_show_alpha (GIMP_COLOR_SELECTOR (editor->notebook),
|
|
|
|
FALSE);
|
|
|
|
gtk_box_pack_start (GTK_BOX (editor), editor->notebook,
|
|
|
|
TRUE, TRUE, content_spacing);
|
|
|
|
gtk_widget_show (editor->notebook);
|
|
|
|
|
2005-05-27 16:51:39 +00:00
|
|
|
g_signal_connect (editor->notebook, "color-changed",
|
2002-11-05 00:02:56 +00:00
|
|
|
G_CALLBACK (gimp_color_editor_color_changed),
|
|
|
|
editor);
|
|
|
|
|
2011-01-02 02:20:09 +01:00
|
|
|
notebook = gimp_color_notebook_get_notebook (GIMP_COLOR_NOTEBOOK (editor->notebook));
|
2002-11-05 00:02:56 +00:00
|
|
|
|
|
|
|
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE);
|
|
|
|
gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), FALSE);
|
|
|
|
|
|
|
|
gimp_color_notebook_set_has_page (GIMP_COLOR_NOTEBOOK (editor->notebook),
|
|
|
|
GIMP_TYPE_COLOR_SCALES, TRUE);
|
|
|
|
|
|
|
|
group = NULL;
|
|
|
|
|
2011-01-02 02:20:09 +01:00
|
|
|
for (list = gimp_color_notebook_get_selectors (GIMP_COLOR_NOTEBOOK (editor->notebook));
|
2002-11-05 00:02:56 +00:00
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
|
|
|
{
|
|
|
|
GimpColorSelector *selector;
|
|
|
|
GimpColorSelectorClass *selector_class;
|
|
|
|
GtkWidget *button;
|
|
|
|
GtkWidget *image;
|
|
|
|
|
|
|
|
selector = GIMP_COLOR_SELECTOR (list->data);
|
|
|
|
selector_class = GIMP_COLOR_SELECTOR_GET_CLASS (selector);
|
|
|
|
|
|
|
|
button = gtk_radio_button_new (group);
|
|
|
|
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
|
|
|
|
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
|
|
|
|
gtk_box_pack_start (GTK_BOX (editor->hbox), button, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2014-05-10 08:33:29 +02:00
|
|
|
image = gtk_image_new_from_icon_name (selector_class->icon_name,
|
2018-05-10 17:55:49 +02:00
|
|
|
GTK_ICON_SIZE_MENU);
|
2002-11-05 00:02:56 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (button), image);
|
|
|
|
gtk_widget_show (image);
|
|
|
|
|
2003-07-19 01:43:51 +00:00
|
|
|
gimp_help_set_help_data (button,
|
2006-04-12 12:49:29 +00:00
|
|
|
selector_class->name, selector_class->help_id);
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2003-10-11 16:50:35 +00:00
|
|
|
g_object_set_data (G_OBJECT (button), "selector", selector);
|
|
|
|
g_object_set_data (G_OBJECT (selector), "button", button);
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2003-01-05 22:07:10 +00:00
|
|
|
g_signal_connect (button, "toggled",
|
2002-11-05 00:02:56 +00:00
|
|
|
G_CALLBACK (gimp_color_editor_tab_toggled),
|
|
|
|
editor);
|
|
|
|
}
|
|
|
|
|
2011-09-30 11:29:11 +02:00
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
2019-02-12 13:44:01 +01:00
|
|
|
gtk_box_set_homogeneous (GTK_BOX (hbox), FALSE);
|
2005-05-19 17:08:03 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (editor), hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
2004-05-27 12:41:22 +00:00
|
|
|
/* FG/BG editor */
|
|
|
|
editor->fg_bg = gimp_fg_bg_editor_new (NULL);
|
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_icon_size_lookup (button_icon_size, &icon_width, &icon_height);
|
|
|
|
gtk_widget_set_size_request (editor->fg_bg,
|
|
|
|
(gint) (icon_width * 1.75),
|
|
|
|
(gint) (icon_height * 1.75));
|
2019-02-12 14:32:43 +01:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), editor->fg_bg, FALSE, FALSE, 0);
|
2004-05-27 12:41:22 +00:00
|
|
|
gtk_widget_show (editor->fg_bg);
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2004-05-27 12:41:22 +00:00
|
|
|
g_signal_connect (editor->fg_bg, "notify::active-color",
|
|
|
|
G_CALLBACK (gimp_color_editor_fg_bg_notify),
|
|
|
|
editor);
|
2005-05-19 17:08:03 +00:00
|
|
|
|
2005-05-20 10:54:44 +00:00
|
|
|
/* The color picker */
|
|
|
|
button = gimp_pick_button_new ();
|
2019-02-12 13:44:01 +01:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
2005-05-20 10:54:44 +00:00
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2005-08-03 09:34:55 +00:00
|
|
|
g_signal_connect (button, "color-picked",
|
2005-05-20 10:54:44 +00:00
|
|
|
G_CALLBACK (gimp_color_editor_color_picked),
|
|
|
|
editor);
|
|
|
|
|
|
|
|
/* The hex triplet entry */
|
2005-05-19 17:08:03 +00:00
|
|
|
editor->hex_entry = gimp_color_hex_entry_new ();
|
2019-02-12 13:44:01 +01:00
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), editor->hex_entry, TRUE, TRUE, 0);
|
2005-05-19 17:08:03 +00:00
|
|
|
gtk_widget_show (editor->hex_entry);
|
|
|
|
|
2005-05-27 16:51:39 +00:00
|
|
|
g_signal_connect (editor->hex_entry, "color-changed",
|
2005-05-19 17:08:03 +00:00
|
|
|
G_CALLBACK (gimp_color_editor_entry_changed),
|
|
|
|
editor);
|
2002-11-05 00:02:56 +00:00
|
|
|
}
|
|
|
|
|
2015-12-23 03:32:25 +01:00
|
|
|
static void
|
|
|
|
gimp_color_editor_constructed (GObject *object)
|
|
|
|
{
|
|
|
|
GimpColorEditor *editor = GIMP_COLOR_EDITOR (object);
|
|
|
|
GtkWidget *history;
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->constructed (object);
|
|
|
|
|
|
|
|
/* The color history */
|
|
|
|
history = gimp_color_history_new (editor->context, 12);
|
|
|
|
gtk_box_pack_end (GTK_BOX (editor), history, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (history);
|
|
|
|
|
|
|
|
g_signal_connect (history, "color-selected",
|
|
|
|
G_CALLBACK (gimp_color_editor_history_selected),
|
|
|
|
editor);
|
|
|
|
}
|
|
|
|
|
2010-09-26 22:38:01 +02:00
|
|
|
static void
|
|
|
|
gimp_color_editor_dispose (GObject *object)
|
|
|
|
{
|
|
|
|
GimpColorEditor *editor = GIMP_COLOR_EDITOR (object);
|
|
|
|
|
|
|
|
if (editor->context)
|
|
|
|
gimp_docked_set_context (GIMP_DOCKED (editor), NULL);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
2005-05-29 13:48:03 +00:00
|
|
|
static void
|
|
|
|
gimp_color_editor_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_CONTEXT:
|
|
|
|
gimp_docked_set_context (GIMP_DOCKED (object),
|
|
|
|
g_value_get_object (value));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_editor_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpColorEditor *editor = GIMP_COLOR_EDITOR (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_CONTEXT:
|
|
|
|
g_value_set_object (value, editor->context);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-12-19 22:37:49 +00:00
|
|
|
|
2005-03-31 13:39:18 +00:00
|
|
|
static GtkWidget *
|
|
|
|
gimp_color_editor_get_preview (GimpDocked *docked,
|
|
|
|
GimpContext *context,
|
|
|
|
GtkIconSize size)
|
|
|
|
{
|
2018-04-29 02:53:51 +02:00
|
|
|
GtkWidget *preview;
|
|
|
|
gint width;
|
|
|
|
gint height;
|
2005-03-31 13:39:18 +00:00
|
|
|
|
|
|
|
preview = gimp_fg_bg_view_new (context);
|
|
|
|
|
2018-04-29 02:53:51 +02:00
|
|
|
if (gtk_icon_size_lookup (size, &width, &height))
|
2005-03-31 13:39:18 +00:00
|
|
|
gtk_widget_set_size_request (preview, width, height);
|
|
|
|
|
|
|
|
return preview;
|
|
|
|
}
|
|
|
|
|
2003-10-18 17:10:36 +00:00
|
|
|
#define AUX_INFO_CURRENT_PAGE "current-page"
|
|
|
|
|
2002-11-05 00:02:56 +00:00
|
|
|
static void
|
2003-10-11 16:50:35 +00:00
|
|
|
gimp_color_editor_set_aux_info (GimpDocked *docked,
|
|
|
|
GList *aux_info)
|
2002-11-05 00:02:56 +00:00
|
|
|
{
|
2003-10-11 16:50:35 +00:00
|
|
|
GimpColorEditor *editor = GIMP_COLOR_EDITOR (docked);
|
2011-01-02 02:20:09 +01:00
|
|
|
GtkWidget *notebook;
|
2003-10-11 16:50:35 +00:00
|
|
|
GList *list;
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2011-01-02 02:20:09 +01:00
|
|
|
notebook = gimp_color_notebook_get_notebook (GIMP_COLOR_NOTEBOOK (editor->notebook));
|
|
|
|
|
2005-06-04 22:49:53 +00:00
|
|
|
parent_docked_iface->set_aux_info (docked, aux_info);
|
|
|
|
|
2003-10-11 16:50:35 +00:00
|
|
|
for (list = aux_info; list; list = g_list_next (list))
|
|
|
|
{
|
|
|
|
GimpSessionInfoAux *aux = list->data;
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2003-10-18 17:10:36 +00:00
|
|
|
if (! strcmp (aux->name, AUX_INFO_CURRENT_PAGE))
|
2003-10-11 16:50:35 +00:00
|
|
|
{
|
|
|
|
GList *children;
|
|
|
|
GList *child;
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2003-10-11 16:50:35 +00:00
|
|
|
children = gtk_container_get_children (GTK_CONTAINER (notebook));
|
|
|
|
|
|
|
|
for (child = children; child; child = g_list_next (child))
|
|
|
|
{
|
|
|
|
if (! strcmp (G_OBJECT_TYPE_NAME (child->data), aux->value))
|
|
|
|
{
|
|
|
|
GtkWidget *button;
|
|
|
|
|
|
|
|
button = g_object_get_data (G_OBJECT (child->data), "button");
|
|
|
|
|
|
|
|
if (button)
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
|
|
|
|
TRUE);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free (children);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static GList *
|
|
|
|
gimp_color_editor_get_aux_info (GimpDocked *docked)
|
|
|
|
{
|
|
|
|
GimpColorEditor *editor = GIMP_COLOR_EDITOR (docked);
|
|
|
|
GimpColorNotebook *notebook = GIMP_COLOR_NOTEBOOK (editor->notebook);
|
2011-01-02 02:20:09 +01:00
|
|
|
GimpColorSelector *current;
|
2005-06-04 22:49:53 +00:00
|
|
|
GList *aux_info;
|
|
|
|
|
|
|
|
aux_info = parent_docked_iface->get_aux_info (docked);
|
2003-10-11 16:50:35 +00:00
|
|
|
|
2011-01-02 02:20:09 +01:00
|
|
|
current = gimp_color_notebook_get_current_selector (notebook);
|
|
|
|
|
|
|
|
if (current)
|
2003-10-11 16:50:35 +00:00
|
|
|
{
|
|
|
|
GimpSessionInfoAux *aux;
|
|
|
|
|
2003-10-18 17:10:36 +00:00
|
|
|
aux = gimp_session_info_aux_new (AUX_INFO_CURRENT_PAGE,
|
2011-01-02 02:20:09 +01:00
|
|
|
G_OBJECT_TYPE_NAME (current));
|
2003-10-11 16:50:35 +00:00
|
|
|
aux_info = g_list_append (aux_info, aux);
|
|
|
|
}
|
|
|
|
|
|
|
|
return aux_info;
|
2002-11-05 00:02:56 +00:00
|
|
|
}
|
|
|
|
|
2003-10-10 21:24:12 +00:00
|
|
|
static void
|
2004-05-23 10:04:41 +00:00
|
|
|
gimp_color_editor_set_context (GimpDocked *docked,
|
|
|
|
GimpContext *context)
|
2003-10-10 21:24:12 +00:00
|
|
|
{
|
2004-05-23 10:04:41 +00:00
|
|
|
GimpColorEditor *editor = GIMP_COLOR_EDITOR (docked);
|
2002-11-05 00:02:56 +00:00
|
|
|
|
|
|
|
if (context == editor->context)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (editor->context)
|
|
|
|
{
|
2003-01-05 22:07:10 +00:00
|
|
|
g_signal_handlers_disconnect_by_func (editor->context,
|
2006-04-12 12:49:29 +00:00
|
|
|
gimp_color_editor_fg_changed,
|
|
|
|
editor);
|
2003-01-05 22:07:10 +00:00
|
|
|
g_signal_handlers_disconnect_by_func (editor->context,
|
2006-04-12 12:49:29 +00:00
|
|
|
gimp_color_editor_bg_changed,
|
|
|
|
editor);
|
2002-11-05 00:02:56 +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
|
|
|
g_signal_handlers_disconnect_by_func (editor->context->gimp->config,
|
|
|
|
G_CALLBACK (gimp_color_editor_style_updated),
|
|
|
|
editor);
|
|
|
|
|
2002-11-05 00:02:56 +00:00
|
|
|
g_object_unref (editor->context);
|
|
|
|
}
|
|
|
|
|
2006-08-29 21:44:51 +00:00
|
|
|
editor->context = context;
|
|
|
|
|
|
|
|
if (editor->context)
|
2002-11-05 00:02:56 +00:00
|
|
|
{
|
2023-11-14 20:04:14 +01:00
|
|
|
GeglColor *color;
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2006-08-29 21:44:51 +00:00
|
|
|
g_object_ref (editor->context);
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2005-05-27 16:51:39 +00:00
|
|
|
g_signal_connect (editor->context, "foreground-changed",
|
2006-04-12 12:49:29 +00:00
|
|
|
G_CALLBACK (gimp_color_editor_fg_changed),
|
|
|
|
editor);
|
2005-05-27 16:51:39 +00:00
|
|
|
g_signal_connect (editor->context, "background-changed",
|
2006-04-12 12:49:29 +00:00
|
|
|
G_CALLBACK (gimp_color_editor_bg_changed),
|
|
|
|
editor);
|
2002-11-05 00:02:56 +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
|
|
|
g_signal_connect_object (editor->context->gimp->config,
|
|
|
|
"notify::theme",
|
|
|
|
G_CALLBACK (gimp_color_editor_style_updated),
|
|
|
|
editor, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
|
|
|
|
g_signal_connect_object (context->gimp->config,
|
|
|
|
"notify::override-theme-icon-size",
|
|
|
|
G_CALLBACK (gimp_color_editor_style_updated),
|
|
|
|
editor, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
|
|
|
|
g_signal_connect_object (context->gimp->config,
|
|
|
|
"notify::custom-icon-size",
|
|
|
|
G_CALLBACK (gimp_color_editor_style_updated),
|
|
|
|
editor, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
|
|
|
|
|
2002-11-05 00:02:56 +00:00
|
|
|
if (editor->edit_bg)
|
|
|
|
{
|
2023-11-14 20:04:14 +01:00
|
|
|
color = gimp_context_get_background (editor->context);
|
|
|
|
gimp_color_editor_bg_changed (editor->context, color, editor);
|
2002-11-05 00:02:56 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-11-14 20:04:14 +01:00
|
|
|
color = gimp_context_get_foreground (editor->context);
|
|
|
|
gimp_color_editor_fg_changed (editor->context, color, editor);
|
2002-11-05 00:02:56 +00:00
|
|
|
}
|
2006-09-26 08:55:41 +00:00
|
|
|
|
2006-11-03 21:29:42 +00:00
|
|
|
g_object_set_data (G_OBJECT (context->gimp->config->color_management),
|
|
|
|
"gimp-context", editor->context);
|
|
|
|
|
2006-09-26 08:55:41 +00:00
|
|
|
gimp_color_selector_set_config (GIMP_COLOR_SELECTOR (editor->notebook),
|
|
|
|
context->gimp->config->color_management);
|
2006-11-03 21:29:42 +00:00
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (context->gimp->config->color_management),
|
|
|
|
"gimp-context", NULL);
|
2002-11-05 00:02:56 +00:00
|
|
|
}
|
2004-05-27 12:41:22 +00:00
|
|
|
|
|
|
|
gimp_fg_bg_editor_set_context (GIMP_FG_BG_EDITOR (editor->fg_bg), context);
|
2002-11-05 00:02:56 +00:00
|
|
|
}
|
|
|
|
|
2004-05-23 10:04:41 +00:00
|
|
|
GtkWidget *
|
|
|
|
gimp_color_editor_new (GimpContext *context)
|
|
|
|
{
|
2005-05-29 13:48:03 +00:00
|
|
|
return g_object_new (GIMP_TYPE_COLOR_EDITOR,
|
|
|
|
"context", context,
|
|
|
|
NULL);
|
2004-05-23 10:04:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-01-09 20:38:01 +01:00
|
|
|
gimp_color_editor_style_updated (GtkWidget *widget)
|
2004-05-23 10:04:41 +00:00
|
|
|
{
|
|
|
|
GimpColorEditor *editor = GIMP_COLOR_EDITOR (widget);
|
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
|
|
|
GtkIconSize button_icon_size;
|
|
|
|
gint icon_width = 40;
|
|
|
|
gint icon_height = 38;
|
2004-05-23 10:04:41 +00:00
|
|
|
|
2011-01-09 20:38:01 +01:00
|
|
|
GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
|
2004-05-23 10:04:41 +00:00
|
|
|
|
|
|
|
if (editor->hbox)
|
|
|
|
gimp_editor_set_box_style (GIMP_EDITOR (editor), GTK_BOX (editor->hbox));
|
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_style_get (GTK_WIDGET (editor),
|
|
|
|
"button-icon-size", &button_icon_size,
|
|
|
|
NULL);
|
|
|
|
gtk_icon_size_lookup (button_icon_size, &icon_width, &icon_height);
|
|
|
|
gtk_widget_set_size_request (editor->fg_bg,
|
|
|
|
(gint) (icon_width * 1.75),
|
|
|
|
(gint) (icon_height * 1.75));
|
2004-05-23 10:04:41 +00:00
|
|
|
}
|
|
|
|
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2005-05-19 17:08:03 +00:00
|
|
|
static void
|
|
|
|
gimp_color_editor_set_color (GimpColorEditor *editor,
|
2023-11-14 20:04:14 +01:00
|
|
|
GeglColor *color)
|
2005-05-19 17:08:03 +00:00
|
|
|
{
|
2023-11-14 20:04:14 +01:00
|
|
|
GimpRGB rgb;
|
2005-05-19 17:08:03 +00:00
|
|
|
GimpHSV hsv;
|
|
|
|
|
2023-11-14 20:04:14 +01:00
|
|
|
gegl_color_get_pixel (color, babl_format ("R'G'B'A double"), &rgb);
|
|
|
|
gimp_rgb_to_hsv (&rgb, &hsv);
|
2005-05-19 17:08:03 +00:00
|
|
|
|
|
|
|
g_signal_handlers_block_by_func (editor->notebook,
|
|
|
|
gimp_color_editor_color_changed,
|
|
|
|
editor);
|
|
|
|
|
|
|
|
gimp_color_selector_set_color (GIMP_COLOR_SELECTOR (editor->notebook),
|
2023-11-14 20:04:14 +01:00
|
|
|
&rgb, &hsv);
|
2005-05-19 17:08:03 +00:00
|
|
|
|
|
|
|
g_signal_handlers_unblock_by_func (editor->notebook,
|
|
|
|
gimp_color_editor_color_changed,
|
|
|
|
editor);
|
|
|
|
|
|
|
|
g_signal_handlers_block_by_func (editor->hex_entry,
|
|
|
|
gimp_color_editor_entry_changed,
|
|
|
|
editor);
|
|
|
|
|
2023-12-09 20:53:39 +09:00
|
|
|
gimp_color_hex_entry_set_color (GIMP_COLOR_HEX_ENTRY (editor->hex_entry), color);
|
2005-05-19 17:08:03 +00:00
|
|
|
|
|
|
|
g_signal_handlers_unblock_by_func (editor->hex_entry,
|
|
|
|
gimp_color_editor_entry_changed,
|
|
|
|
editor);
|
|
|
|
}
|
2002-11-05 00:02:56 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_editor_fg_changed (GimpContext *context,
|
2023-11-14 20:04:14 +01:00
|
|
|
GeglColor *color,
|
2002-11-05 00:02:56 +00:00
|
|
|
GimpColorEditor *editor)
|
|
|
|
{
|
|
|
|
if (! editor->edit_bg)
|
2023-11-14 20:04:14 +01:00
|
|
|
gimp_color_editor_set_color (editor, color);
|
2002-11-05 00:02:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_editor_bg_changed (GimpContext *context,
|
2023-11-14 20:04:14 +01:00
|
|
|
GeglColor *color,
|
2002-11-05 00:02:56 +00:00
|
|
|
GimpColorEditor *editor)
|
|
|
|
{
|
|
|
|
if (editor->edit_bg)
|
2023-11-14 20:04:14 +01:00
|
|
|
gimp_color_editor_set_color (editor, color);
|
2002-11-05 00:02:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_editor_color_changed (GimpColorSelector *selector,
|
|
|
|
const GimpRGB *rgb,
|
|
|
|
const GimpHSV *hsv,
|
|
|
|
GimpColorEditor *editor)
|
|
|
|
{
|
2023-12-09 20:53:39 +09:00
|
|
|
GeglColor *color = gegl_color_new ("black");
|
|
|
|
|
|
|
|
gegl_color_set_rgba_with_space (color, rgb->r, rgb->g, rgb->b, rgb->a, NULL);
|
|
|
|
|
2002-11-05 00:02:56 +00:00
|
|
|
if (editor->context)
|
|
|
|
{
|
|
|
|
if (editor->edit_bg)
|
|
|
|
{
|
2003-01-05 22:07:10 +00:00
|
|
|
g_signal_handlers_block_by_func (editor->context,
|
2002-11-05 00:02:56 +00:00
|
|
|
gimp_color_editor_bg_changed,
|
|
|
|
editor);
|
|
|
|
|
2023-11-13 23:29:20 +01:00
|
|
|
gimp_context_set_background (editor->context, color);
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2003-01-05 22:07:10 +00:00
|
|
|
g_signal_handlers_unblock_by_func (editor->context,
|
2002-11-05 00:02:56 +00:00
|
|
|
gimp_color_editor_bg_changed,
|
|
|
|
editor);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-01-05 22:07:10 +00:00
|
|
|
g_signal_handlers_block_by_func (editor->context,
|
2002-11-05 00:02:56 +00:00
|
|
|
gimp_color_editor_fg_changed,
|
|
|
|
editor);
|
|
|
|
|
2023-11-13 23:29:20 +01:00
|
|
|
gimp_context_set_foreground (editor->context, color);
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2003-01-05 22:07:10 +00:00
|
|
|
g_signal_handlers_unblock_by_func (editor->context,
|
2002-11-05 00:02:56 +00:00
|
|
|
gimp_color_editor_fg_changed,
|
|
|
|
editor);
|
|
|
|
}
|
|
|
|
}
|
2005-05-19 17:08:03 +00:00
|
|
|
|
|
|
|
g_signal_handlers_block_by_func (editor->hex_entry,
|
|
|
|
gimp_color_editor_entry_changed,
|
|
|
|
editor);
|
|
|
|
|
2023-12-09 20:53:39 +09:00
|
|
|
gimp_color_hex_entry_set_color (GIMP_COLOR_HEX_ENTRY (editor->hex_entry), color);
|
2005-05-19 17:08:03 +00:00
|
|
|
|
|
|
|
g_signal_handlers_unblock_by_func (editor->hex_entry,
|
|
|
|
gimp_color_editor_entry_changed,
|
|
|
|
editor);
|
2023-12-09 20:53:39 +09:00
|
|
|
|
|
|
|
g_object_unref (color);
|
2002-11-05 00:02:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_editor_tab_toggled (GtkWidget *widget,
|
|
|
|
GimpColorEditor *editor)
|
|
|
|
{
|
2008-06-28 15:50:27 +00:00
|
|
|
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
|
2002-11-05 00:02:56 +00:00
|
|
|
{
|
|
|
|
GtkWidget *selector;
|
|
|
|
|
|
|
|
selector = g_object_get_data (G_OBJECT (widget), "selector");
|
|
|
|
|
|
|
|
if (selector)
|
|
|
|
{
|
|
|
|
GtkWidget *notebook;
|
|
|
|
gint page_num;
|
|
|
|
|
2011-01-02 02:20:09 +01:00
|
|
|
notebook = gimp_color_notebook_get_notebook (GIMP_COLOR_NOTEBOOK (editor->notebook));
|
2002-11-05 00:02:56 +00:00
|
|
|
|
|
|
|
page_num = gtk_notebook_page_num (GTK_NOTEBOOK (notebook), selector);
|
|
|
|
|
|
|
|
if (page_num >= 0)
|
|
|
|
gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), page_num);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-05-27 12:41:22 +00:00
|
|
|
gimp_color_editor_fg_bg_notify (GtkWidget *widget,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GimpColorEditor *editor)
|
2002-11-05 00:02:56 +00:00
|
|
|
{
|
2004-05-27 12:41:22 +00:00
|
|
|
gboolean edit_bg;
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2004-05-27 12:41:22 +00:00
|
|
|
edit_bg = (GIMP_FG_BG_EDITOR (widget)->active_color ==
|
|
|
|
GIMP_ACTIVE_COLOR_BACKGROUND);
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2004-05-27 12:41:22 +00:00
|
|
|
if (edit_bg != editor->edit_bg)
|
|
|
|
{
|
|
|
|
editor->edit_bg = edit_bg;
|
|
|
|
|
|
|
|
if (editor->context)
|
2002-11-05 00:02:56 +00:00
|
|
|
{
|
2023-11-14 20:04:14 +01:00
|
|
|
GeglColor *color;
|
2002-11-05 00:02:56 +00:00
|
|
|
|
2004-05-27 12:41:22 +00:00
|
|
|
if (edit_bg)
|
2002-11-05 00:02:56 +00:00
|
|
|
{
|
2023-11-14 20:04:14 +01:00
|
|
|
color = gimp_context_get_background (editor->context);
|
|
|
|
gimp_color_editor_bg_changed (editor->context, color, editor);
|
2004-05-27 12:41:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-11-14 20:04:14 +01:00
|
|
|
color = gimp_context_get_foreground (editor->context);
|
|
|
|
gimp_color_editor_fg_changed (editor->context, color, editor);
|
2002-11-05 00:02:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_editor_color_picked (GtkWidget *widget,
|
|
|
|
const GimpRGB *rgb,
|
|
|
|
GimpColorEditor *editor)
|
|
|
|
{
|
2004-05-27 12:41:22 +00:00
|
|
|
if (editor->context)
|
|
|
|
{
|
2023-11-13 23:29:20 +01:00
|
|
|
GeglColor *color = gegl_color_new ("black");
|
|
|
|
|
|
|
|
gegl_color_set_rgba_with_space (color, rgb->r, rgb->g, rgb->b, rgb->a, NULL);
|
|
|
|
|
2004-05-27 12:41:22 +00:00
|
|
|
if (editor->edit_bg)
|
2023-11-13 23:29:20 +01:00
|
|
|
gimp_context_set_background (editor->context, color);
|
2004-05-27 12:41:22 +00:00
|
|
|
else
|
2023-11-13 23:29:20 +01:00
|
|
|
gimp_context_set_foreground (editor->context, color);
|
|
|
|
|
|
|
|
g_object_unref (color);
|
2004-05-27 12:41:22 +00:00
|
|
|
}
|
2002-11-05 00:02:56 +00:00
|
|
|
}
|
2005-05-19 17:08:03 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_editor_entry_changed (GimpColorHexEntry *entry,
|
|
|
|
GimpColorEditor *editor)
|
|
|
|
{
|
2023-12-09 20:53:39 +09:00
|
|
|
GeglColor *color;
|
2005-05-19 17:08:03 +00:00
|
|
|
|
2023-12-09 20:53:39 +09:00
|
|
|
color = gimp_color_hex_entry_get_color (entry);
|
2005-05-19 17:08:03 +00:00
|
|
|
|
|
|
|
if (editor->context)
|
|
|
|
{
|
|
|
|
if (editor->edit_bg)
|
2023-11-13 23:29:20 +01:00
|
|
|
gimp_context_set_background (editor->context, color);
|
2005-05-19 17:08:03 +00:00
|
|
|
else
|
2023-11-13 23:29:20 +01:00
|
|
|
gimp_context_set_foreground (editor->context, color);
|
2005-05-19 17:08:03 +00:00
|
|
|
}
|
2023-11-13 23:29:20 +01:00
|
|
|
|
|
|
|
g_object_unref (color);
|
2005-05-19 17:08:03 +00:00
|
|
|
}
|
2015-12-23 03:32:25 +01:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_editor_history_selected (GimpColorHistory *history,
|
|
|
|
const GimpRGB *rgb,
|
|
|
|
GimpColorEditor *editor)
|
|
|
|
{
|
|
|
|
if (editor->context)
|
|
|
|
{
|
2023-11-13 23:29:20 +01:00
|
|
|
GeglColor *color = gegl_color_new ("black");
|
|
|
|
|
|
|
|
gegl_color_set_rgba_with_space (color, rgb->r, rgb->g, rgb->b, rgb->a, NULL);
|
|
|
|
|
2015-12-23 03:32:25 +01:00
|
|
|
if (editor->edit_bg)
|
2023-11-13 23:29:20 +01:00
|
|
|
gimp_context_set_background (editor->context, color);
|
2015-12-23 03:32:25 +01:00
|
|
|
else
|
2023-11-13 23:29:20 +01:00
|
|
|
gimp_context_set_foreground (editor->context, color);
|
|
|
|
|
|
|
|
g_object_unref (color);
|
2015-12-23 03:32:25 +01:00
|
|
|
}
|
|
|
|
}
|