widgets: Connect GimpToolPresetEditor to icon size changes
Inspired by Mark Sweeney's work. GimpToolPresetEditor has an icon next to its title which does not react to icon size changes. GimpToolPresetEditor's parent_instance, GimpEditor, already has a "button-icon-size" CSS style which can be accessed in its children. This patch adds signals to listen for icon size changes and update the icon size accordingly.
This commit is contained in:
parent
e4ae257ae7
commit
ff9f71e9a6
1 changed files with 42 additions and 11 deletions
|
|
@ -59,19 +59,21 @@ struct _GimpToolPresetEditorPrivate
|
|||
|
||||
/* local function prototypes */
|
||||
|
||||
static void gimp_tool_preset_editor_constructed (GObject *object);
|
||||
static void gimp_tool_preset_editor_finalize (GObject *object);
|
||||
static void gimp_tool_preset_editor_constructed (GObject *object);
|
||||
static void gimp_tool_preset_editor_finalize (GObject *object);
|
||||
|
||||
static void gimp_tool_preset_editor_set_data (GimpDataEditor *editor,
|
||||
GimpData *data);
|
||||
static void gimp_tool_preset_editor_style_updated (GtkWidget *widget);
|
||||
|
||||
static void gimp_tool_preset_editor_sync_data (GimpToolPresetEditor *editor);
|
||||
static void gimp_tool_preset_editor_notify_model (GimpToolPreset *options,
|
||||
const GParamSpec *pspec,
|
||||
GimpToolPresetEditor *editor);
|
||||
static void gimp_tool_preset_editor_notify_data (GimpToolPreset *options,
|
||||
const GParamSpec *pspec,
|
||||
GimpToolPresetEditor *editor);
|
||||
static void gimp_tool_preset_editor_set_data (GimpDataEditor *editor,
|
||||
GimpData *data);
|
||||
|
||||
static void gimp_tool_preset_editor_sync_data (GimpToolPresetEditor *editor);
|
||||
static void gimp_tool_preset_editor_notify_model (GimpToolPreset *options,
|
||||
const GParamSpec *pspec,
|
||||
GimpToolPresetEditor *editor);
|
||||
static void gimp_tool_preset_editor_notify_data (GimpToolPreset *options,
|
||||
const GParamSpec *pspec,
|
||||
GimpToolPresetEditor *editor);
|
||||
|
||||
|
||||
|
||||
|
|
@ -88,12 +90,15 @@ gimp_tool_preset_editor_class_init (GimpToolPresetEditorClass *klass)
|
|||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GimpDataEditorClass *editor_class = GIMP_DATA_EDITOR_CLASS (klass);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
object_class->constructed = gimp_tool_preset_editor_constructed;
|
||||
object_class->finalize = gimp_tool_preset_editor_finalize;
|
||||
|
||||
editor_class->set_data = gimp_tool_preset_editor_set_data;
|
||||
editor_class->title = _("Tool Preset Editor");
|
||||
|
||||
widget_class->style_updated = gimp_tool_preset_editor_style_updated;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -196,6 +201,15 @@ gimp_tool_preset_editor_constructed (GObject *object)
|
|||
"tool-preset-editor",
|
||||
"tool-preset-editor-restore", NULL);
|
||||
|
||||
g_signal_connect_object (data_editor->context->gimp->config,
|
||||
"notify::override-theme-icon-size",
|
||||
G_CALLBACK (gimp_tool_preset_editor_style_updated),
|
||||
editor, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
|
||||
g_signal_connect_object (data_editor->context->gimp->config,
|
||||
"notify::custom-icon-size",
|
||||
G_CALLBACK (gimp_tool_preset_editor_style_updated),
|
||||
editor, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
|
||||
|
||||
if (data_editor->data)
|
||||
gimp_tool_preset_editor_sync_data (editor);
|
||||
}
|
||||
|
|
@ -210,6 +224,23 @@ gimp_tool_preset_editor_finalize (GObject *object)
|
|||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_tool_preset_editor_style_updated (GtkWidget *widget)
|
||||
{
|
||||
GimpToolPresetEditor *editor = GIMP_TOOL_PRESET_EDITOR (widget);
|
||||
gint icon_size = 16;
|
||||
GtkIconSize button_icon_size;
|
||||
|
||||
GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
|
||||
|
||||
gtk_widget_style_get (widget,
|
||||
"button-icon-size", &button_icon_size,
|
||||
NULL);
|
||||
gtk_icon_size_lookup (button_icon_size, &icon_size, NULL);
|
||||
gtk_image_set_pixel_size (GTK_IMAGE (editor->priv->tool_icon), icon_size);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gimp_tool_preset_editor_set_data (GimpDataEditor *editor,
|
||||
GimpData *data)
|
||||
|
|
|
|||
Loading…
Reference in a new issue