mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-04 01:43:24 +00:00
tools, libgimpwidgets: Connect SelectionOptions to icon size
This patch resizes the selection mode icons based on the user's icon size settings. It creates a new function in gimpenumwidgets.c to update sizes, then connects to GimpGuiConfig's icon size update notifications in GimpSelectionOptions.
This commit is contained in:
parent
ee2f86105c
commit
816fb1c676
4 changed files with 97 additions and 11 deletions
|
@ -26,6 +26,10 @@
|
||||||
|
|
||||||
#include "tools-types.h"
|
#include "tools-types.h"
|
||||||
|
|
||||||
|
#include "config/gimpguiconfig.h"
|
||||||
|
|
||||||
|
#include "core/gimp.h"
|
||||||
|
|
||||||
#include "widgets/gimppropwidgets.h"
|
#include "widgets/gimppropwidgets.h"
|
||||||
#include "widgets/gimpwidgets-utils.h"
|
#include "widgets/gimpwidgets-utils.h"
|
||||||
|
|
||||||
|
@ -53,6 +57,10 @@ static void gimp_selection_options_get_property (GObject *object,
|
||||||
guint property_id,
|
guint property_id,
|
||||||
GValue *value,
|
GValue *value,
|
||||||
GParamSpec *pspec);
|
GParamSpec *pspec);
|
||||||
|
static void gimp_selection_options_style_updated (GimpGuiConfig *config,
|
||||||
|
GParamSpec *pspec,
|
||||||
|
GtkWidget *box);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
G_DEFINE_TYPE (GimpSelectionOptions, gimp_selection_options,
|
G_DEFINE_TYPE (GimpSelectionOptions, gimp_selection_options,
|
||||||
|
@ -203,6 +211,8 @@ GtkWidget *
|
||||||
gimp_selection_options_gui (GimpToolOptions *tool_options)
|
gimp_selection_options_gui (GimpToolOptions *tool_options)
|
||||||
{
|
{
|
||||||
GObject *config = G_OBJECT (tool_options);
|
GObject *config = G_OBJECT (tool_options);
|
||||||
|
GimpContext *context = GIMP_CONTEXT (tool_options);
|
||||||
|
GimpGuiConfig *gui_config = GIMP_GUI_CONFIG (context->gimp->config);
|
||||||
GimpSelectionOptions *options = GIMP_SELECTION_OPTIONS (tool_options);
|
GimpSelectionOptions *options = GIMP_SELECTION_OPTIONS (tool_options);
|
||||||
GtkWidget *vbox = gimp_tool_options_gui (tool_options);
|
GtkWidget *vbox = gimp_tool_options_gui (tool_options);
|
||||||
GtkWidget *button;
|
GtkWidget *button;
|
||||||
|
@ -228,6 +238,17 @@ gimp_selection_options_gui (GimpToolOptions *tool_options)
|
||||||
|
|
||||||
box = gimp_prop_enum_icon_box_new (config, "operation",
|
box = gimp_prop_enum_icon_box_new (config, "operation",
|
||||||
"gimp-selection", 0, 0);
|
"gimp-selection", 0, 0);
|
||||||
|
|
||||||
|
g_signal_connect_object (gui_config,
|
||||||
|
"notify::override-theme-icon-size",
|
||||||
|
G_CALLBACK (gimp_selection_options_style_updated),
|
||||||
|
box, G_CONNECT_AFTER);
|
||||||
|
g_signal_connect_object (gui_config,
|
||||||
|
"notify::custom-icon-size",
|
||||||
|
G_CALLBACK (gimp_selection_options_style_updated),
|
||||||
|
box, G_CONNECT_AFTER);
|
||||||
|
gimp_selection_options_style_updated (gui_config, NULL, box);
|
||||||
|
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), box, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (hbox), box, FALSE, FALSE, 0);
|
||||||
|
|
||||||
children = gtk_container_get_children (GTK_CONTAINER (box));
|
children = gtk_container_get_children (GTK_CONTAINER (box));
|
||||||
|
@ -288,3 +309,32 @@ gimp_selection_options_gui (GimpToolOptions *tool_options)
|
||||||
|
|
||||||
return vbox;
|
return vbox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_selection_options_style_updated (GimpGuiConfig *config,
|
||||||
|
GParamSpec *pspec,
|
||||||
|
GtkWidget *box)
|
||||||
|
{
|
||||||
|
GtkIconSize icon_size = GTK_ICON_SIZE_MENU;
|
||||||
|
|
||||||
|
if (config->override_icon_size)
|
||||||
|
{
|
||||||
|
switch (config->custom_icon_size)
|
||||||
|
{
|
||||||
|
case GIMP_ICON_SIZE_LARGE:
|
||||||
|
icon_size = GTK_ICON_SIZE_LARGE_TOOLBAR;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GIMP_ICON_SIZE_HUGE:
|
||||||
|
icon_size = GTK_ICON_SIZE_DND;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GIMP_ICON_SIZE_MEDIUM:
|
||||||
|
case GIMP_ICON_SIZE_SMALL:
|
||||||
|
default:
|
||||||
|
icon_size = GTK_ICON_SIZE_MENU;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gimp_enum_icon_box_set_icon_size (box, icon_size);
|
||||||
|
}
|
||||||
|
|
|
@ -474,3 +474,36 @@ gimp_enum_icon_box_set_child_padding (GtkWidget *icon_box,
|
||||||
|
|
||||||
g_list_free (children);
|
g_list_free (children);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gimp_enum_icon_box_set_icon_size:
|
||||||
|
* @icon_box: an icon box widget
|
||||||
|
* @icon_size: the #GtkIconSize enum
|
||||||
|
*
|
||||||
|
* Sets the icon size of all buttons in a box created by
|
||||||
|
* gimp_enum_icon_box_new().
|
||||||
|
*
|
||||||
|
* Since: 3.0
|
||||||
|
**/
|
||||||
|
void
|
||||||
|
gimp_enum_icon_box_set_icon_size (GtkWidget *icon_box,
|
||||||
|
GtkIconSize icon_size)
|
||||||
|
{
|
||||||
|
GList *children;
|
||||||
|
GList *list;
|
||||||
|
|
||||||
|
g_return_if_fail (GTK_IS_CONTAINER (icon_box));
|
||||||
|
|
||||||
|
children = gtk_container_get_children (GTK_CONTAINER (icon_box));
|
||||||
|
|
||||||
|
for (list = children; list; list = g_list_next (list))
|
||||||
|
{
|
||||||
|
GtkWidget *child = gtk_bin_get_child (GTK_BIN (list->data));
|
||||||
|
|
||||||
|
g_object_set (child,
|
||||||
|
"icon-size", icon_size,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_list_free (children);
|
||||||
|
}
|
||||||
|
|
|
@ -76,6 +76,8 @@ GtkWidget * gimp_enum_icon_box_new_with_range (GType enum_type,
|
||||||
void gimp_enum_icon_box_set_child_padding (GtkWidget *icon_box,
|
void gimp_enum_icon_box_set_child_padding (GtkWidget *icon_box,
|
||||||
gint xpad,
|
gint xpad,
|
||||||
gint ypad);
|
gint ypad);
|
||||||
|
void gimp_enum_icon_box_set_icon_size (GtkWidget *icon_box,
|
||||||
|
GtkIconSize icon_size);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -179,6 +179,7 @@ EXPORTS
|
||||||
gimp_enum_icon_box_new
|
gimp_enum_icon_box_new
|
||||||
gimp_enum_icon_box_new_with_range
|
gimp_enum_icon_box_new_with_range
|
||||||
gimp_enum_icon_box_set_child_padding
|
gimp_enum_icon_box_set_child_padding
|
||||||
|
gimp_enum_icon_box_set_icon_size
|
||||||
gimp_enum_label_get_type
|
gimp_enum_label_get_type
|
||||||
gimp_enum_label_new
|
gimp_enum_label_new
|
||||||
gimp_enum_label_set_value
|
gimp_enum_label_set_value
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue