mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 17:33:25 +00:00
dialogs, gui, widgets: Connect GimpPrefsBox to icon size changes
Inspired by Mark Sweeney's work. This patch allows the icons in the tree view in Preferences Dialog to scale based on user icon scale preferences. Rather than add a GimpGuiConfig to GimpPrefsBox, we make a call to style_updated () from the Preferences Dialog to signal a change.
This commit is contained in:
parent
86cf17e09c
commit
6bbaaeb39e
3 changed files with 80 additions and 5 deletions
|
@ -90,6 +90,7 @@ static GtkWidget * prefs_dialog_new (Gimp *gimp,
|
|||
static void prefs_response (GtkWidget *widget,
|
||||
gint response_id,
|
||||
GtkWidget *dialog);
|
||||
static void prefs_box_style_updated (GtkWidget *widget);
|
||||
|
||||
static void prefs_color_management_reset (GtkWidget *widget,
|
||||
GObject *config);
|
||||
|
@ -391,6 +392,14 @@ prefs_response (GtkWidget *widget,
|
|||
gtk_widget_destroy (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
prefs_box_style_updated (GtkWidget *widget)
|
||||
{
|
||||
GimpPrefsBox *box = GIMP_PREFS_BOX (widget);
|
||||
|
||||
GTK_WIDGET_GET_CLASS (box)->style_updated (GTK_WIDGET (box));
|
||||
}
|
||||
|
||||
static void
|
||||
prefs_color_management_reset (GtkWidget *widget,
|
||||
GObject *config)
|
||||
|
@ -1193,6 +1202,16 @@ prefs_dialog_new (Gimp *gimp,
|
|||
|
||||
g_object_set_data (G_OBJECT (dialog), "prefs-box", prefs_box);
|
||||
|
||||
/* Notify the prefs box to update its tree icon sizes
|
||||
* based on user preferences */
|
||||
g_signal_connect_object (config,
|
||||
"notify::override-theme-icon-size",
|
||||
G_CALLBACK (prefs_box_style_updated),
|
||||
prefs_box, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
|
||||
g_signal_connect_object (config,
|
||||
"notify::custom-icon-size",
|
||||
G_CALLBACK (prefs_box_style_updated),
|
||||
prefs_box, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
|
||||
|
||||
/**********************/
|
||||
/* System Resources */
|
||||
|
|
|
@ -484,6 +484,8 @@ themes_apply_theme (Gimp *gimp,
|
|||
"\n"
|
||||
"* { -GimpColorNotebook-tab-icon-size: %s; }"
|
||||
"\n"
|
||||
"* { -GimpPrefsBox-tab-icon-size: %s; }"
|
||||
"\n"
|
||||
"* { -GimpEditor-button-icon-size: %s; }"
|
||||
"\n"
|
||||
"* { -GimpDisplayShell-button-icon-size: %s; }"
|
||||
|
@ -496,8 +498,8 @@ themes_apply_theme (Gimp *gimp,
|
|||
"\n"
|
||||
"paned separator { padding: %dpx; }",
|
||||
tool_icon_size, tool_icon_size, tab_icon_size, tab_icon_size,
|
||||
button_icon_size, button_icon_size, tool_icon_size, pal_padding,
|
||||
tab_padding, sep_padding);
|
||||
tab_icon_size, button_icon_size, button_icon_size, tool_icon_size,
|
||||
pal_padding, tab_padding, sep_padding);
|
||||
}
|
||||
|
||||
if (! error && config->font_relative_size != 1.0)
|
||||
|
|
|
@ -64,7 +64,13 @@ struct _GimpPrefsBoxPrivate
|
|||
#define GET_PRIVATE(obj) (((GimpPrefsBox *) (obj))->priv)
|
||||
|
||||
|
||||
static void gimp_prefs_box_finalize (GObject *object);
|
||||
static void gimp_prefs_box_finalize (GObject *object);
|
||||
|
||||
static void gimp_prefs_box_style_updated (GtkWidget *widget);
|
||||
static gboolean gimp_prefs_box_style_updated_foreach (GtkTreeModel *model,
|
||||
GtkTreePath *path,
|
||||
GtkTreeIter *iter,
|
||||
gpointer data);
|
||||
|
||||
static void gimp_prefs_box_tree_select_callback (GtkTreeSelection *sel,
|
||||
GimpPrefsBox *box);
|
||||
|
@ -78,9 +84,21 @@ G_DEFINE_TYPE_WITH_PRIVATE (GimpPrefsBox, gimp_prefs_box, GTK_TYPE_BOX)
|
|||
static void
|
||||
gimp_prefs_box_class_init (GimpPrefsBoxClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
object_class->finalize = gimp_prefs_box_finalize;
|
||||
|
||||
widget_class->style_updated = gimp_prefs_box_style_updated;
|
||||
|
||||
gtk_widget_class_install_style_property (widget_class,
|
||||
g_param_spec_enum ("tab-icon-size",
|
||||
NULL, NULL,
|
||||
GTK_TYPE_ICON_SIZE,
|
||||
GTK_ICON_SIZE_BUTTON,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
gtk_widget_class_set_css_name (widget_class, "GimpPrefsBox");
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -90,6 +108,7 @@ gimp_prefs_box_init (GimpPrefsBox *box)
|
|||
GtkTreeViewColumn *column;
|
||||
GtkCellRenderer *cell;
|
||||
GtkTreeSelection *sel;
|
||||
GtkIconSize tab_icon_size;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *vbox;
|
||||
|
@ -98,7 +117,11 @@ gimp_prefs_box_init (GimpPrefsBox *box)
|
|||
|
||||
private = box->priv;
|
||||
|
||||
private->tree_icon_size = GTK_ICON_SIZE_BUTTON;
|
||||
gtk_widget_style_get (GTK_WIDGET (box),
|
||||
"tab-icon-size", &tab_icon_size,
|
||||
NULL);
|
||||
|
||||
private->tree_icon_size = tab_icon_size;
|
||||
private->page_icon_size = GTK_ICON_SIZE_DIALOG;
|
||||
|
||||
gtk_orientable_set_orientation (GTK_ORIENTABLE (box),
|
||||
|
@ -208,6 +231,37 @@ gimp_prefs_box_finalize (GObject *object)
|
|||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_prefs_box_style_updated (GtkWidget *widget)
|
||||
{
|
||||
GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
|
||||
|
||||
if (GET_PRIVATE (widget)->store)
|
||||
gtk_tree_model_foreach (GTK_TREE_MODEL (GET_PRIVATE (widget)->store),
|
||||
gimp_prefs_box_style_updated_foreach,
|
||||
widget);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_prefs_box_style_updated_foreach (GtkTreeModel *model,
|
||||
GtkTreePath *path,
|
||||
GtkTreeIter *iter,
|
||||
gpointer data)
|
||||
{
|
||||
GimpPrefsBox *box = GIMP_PREFS_BOX (data);
|
||||
GtkIconSize tab_icon_size;
|
||||
|
||||
gtk_widget_style_get (GTK_WIDGET (box),
|
||||
"tab-icon-size", &tab_icon_size,
|
||||
NULL);
|
||||
|
||||
gtk_tree_store_set (GTK_TREE_STORE (model), iter,
|
||||
COLUMN_TREE_ICON_SIZE, tab_icon_size,
|
||||
-1);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_prefs_box_tree_select_callback (GtkTreeSelection *sel,
|
||||
GimpPrefsBox *box)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue