Commit 1f9e763f authored by Sean Davis's avatar Sean Davis 🕶

Add support for panel icon-size settings

parent 552d2de9
Pipeline #1247 passed with stages
in 4 minutes and 27 seconds
......@@ -90,6 +90,7 @@ struct _SnConfig
GtkOrientation panel_orientation;
gint nrows;
gint panel_size;
gint panel_icon_size;
};
G_DEFINE_TYPE (SnConfig, sn_config, G_TYPE_OBJECT)
......@@ -117,6 +118,7 @@ enum
ITEM_LIST_CHANGED,
COLLECT_KNOWN_ITEMS,
LEGACY_ITEM_LIST_CHANGED,
ICONS_CHANGED,
LAST_SIGNAL
};
......@@ -163,7 +165,7 @@ sn_config_class_init (SnConfigClass *klass)
g_object_class_install_property (object_class,
PROP_ICON_SIZE,
g_param_spec_int ("icon-size", NULL, NULL,
12, 64, DEFAULT_ICON_SIZE,
0, 64, DEFAULT_ICON_SIZE,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
......@@ -242,6 +244,14 @@ sn_config_class_init (SnConfigClass *klass)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
sn_config_signals[ICONS_CHANGED] =
g_signal_new (g_intern_static_string ("icons-changed"),
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
0, NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
sn_config_signals[ITEM_LIST_CHANGED] =
g_signal_new (g_intern_static_string ("items-list-changed"),
G_TYPE_FROM_CLASS (object_class),
......@@ -439,6 +449,7 @@ sn_config_set_property (GObject *object,
if (config->icon_size != val)
{
config->icon_size = val;
g_signal_emit (G_OBJECT (config), sn_config_signals[ICONS_CHANGED], 0);
g_signal_emit (G_OBJECT (config), sn_config_signals[CONFIGURATION_CHANGED], 0);
}
break;
......@@ -568,7 +579,20 @@ sn_config_get_icon_size (SnConfig *config)
{
g_return_val_if_fail (XFCE_IS_SN_CONFIG (config), DEFAULT_ICON_SIZE);
return config->icon_size;
if (config->icon_size > 0)
return config->icon_size;
return config->panel_icon_size;
}
gboolean
sn_config_get_icon_size_is_automatic (SnConfig *config)
{
g_return_val_if_fail (XFCE_IS_SN_CONFIG (config), FALSE);
return config->icon_size == 0;
}
......@@ -720,7 +744,8 @@ sn_config_get_panel_orientation (SnConfig *config)
void
sn_config_set_size (SnConfig *config,
gint panel_size,
gint nrows)
gint nrows,
gint icon_size)
{
gboolean needs_update = FALSE;
......@@ -738,6 +763,13 @@ sn_config_set_size (SnConfig *config,
needs_update = TRUE;
}
if (config->panel_icon_size != icon_size)
{
config->panel_icon_size = icon_size;
needs_update = TRUE;
g_signal_emit (G_OBJECT (config), sn_config_signals[ICONS_CHANGED], 0);
}
if (needs_update)
g_signal_emit (G_OBJECT (config), sn_config_signals[CONFIGURATION_CHANGED], 0);
}
......
......@@ -48,7 +48,8 @@ GtkOrientation sn_config_get_panel_orientation (SnConfig
void sn_config_set_size (SnConfig *config,
gint panel_size,
gint nrows);
gint nrows,
gint icon_size);
gint sn_config_get_nrows (SnConfig *config);
......@@ -63,6 +64,9 @@ gboolean sn_config_get_symbolic_icons (SnConfig
gboolean sn_config_get_menu_is_primary (SnConfig *config);
gint sn_config_get_icon_size (SnConfig *config);
gboolean sn_config_get_icon_size_is_automatic (SnConfig *config);
void sn_config_get_dimensions (SnConfig *config,
gint *ret_icon_size,
gint *ret_n_rows,
......
......@@ -35,6 +35,10 @@
#define DEFAULT_ICON_SIZE 22
static gboolean sn_dialog_build (SnDialog *dialog);
static void sn_dialog_finalize (GObject *object);
......@@ -52,6 +56,9 @@ struct _SnDialog
GtkBuilder *builder;
GtkWidget *dialog;
GtkWidget *auto_size;
GtkWidget *size_spinbutton;
GtkWidget *size_revealer;
GObject *store;
GObject *legacy_store;
SnConfig *config;
......@@ -656,6 +663,29 @@ sn_dialog_dialog_unref (SnDialog *dialog)
static void
reveal_icon_size (GtkWidget *widget,
GParamSpec *pspec,
SnDialog *dialog)
{
gboolean active;
gint icon_size;
g_return_if_fail (XFCE_IS_SN_DIALOG (dialog));
active = gtk_switch_get_active (GTK_SWITCH (widget));
if (active)
icon_size = 0;
else
icon_size = DEFAULT_ICON_SIZE;
gtk_revealer_set_reveal_child (GTK_REVEALER (dialog->size_revealer), !active);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->size_spinbutton), icon_size);
}
static gboolean
sn_dialog_build (SnDialog *dialog)
{
......@@ -682,12 +712,30 @@ sn_dialog_build (SnDialog *dialog)
G_CALLBACK (gtk_widget_destroy),
dialog->dialog);
object = gtk_builder_get_object (dialog->builder, "switch-auto-size");
g_return_val_if_fail (GTK_IS_WIDGET (object), FALSE);
dialog->auto_size = GTK_WIDGET (object);
object = gtk_builder_get_object (dialog->builder, "spinbutton-icon-size");
g_return_val_if_fail (GTK_IS_WIDGET (object), FALSE);
g_object_bind_property (G_OBJECT (dialog->config), "icon-size",
G_OBJECT (gtk_spin_button_get_adjustment
(GTK_SPIN_BUTTON (object))), "value",
G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
dialog->size_spinbutton = GTK_WIDGET (object);
object = gtk_builder_get_object (dialog->builder, "revealer-icon-size");
g_return_val_if_fail (GTK_IS_WIDGET (object), FALSE);
dialog->size_revealer = GTK_WIDGET (object);
if (sn_config_get_icon_size_is_automatic (dialog->config))
{
gtk_switch_set_active (GTK_SWITCH (dialog->auto_size), TRUE);
gtk_revealer_set_reveal_child (GTK_REVEALER (dialog->size_revealer), FALSE);
}
g_signal_connect (G_OBJECT (dialog->auto_size), "notify::active",
G_CALLBACK (reveal_icon_size), dialog);
object = gtk_builder_get_object (dialog->builder, "checkbutton-single-row");
g_return_val_if_fail (GTK_IS_WIDGET (object), FALSE);
......
This diff is collapsed.
......@@ -188,6 +188,8 @@ sn_icon_box_new (SnItem *item,
settings = gtk_settings_get_default ();
sn_signal_connect_weak_swapped (config, "icons-changed",
G_CALLBACK (sn_icon_box_icon_changed), box);
sn_signal_connect_weak_swapped (config, "notify::icon-size",
G_CALLBACK (sn_icon_box_icon_changed), box);
sn_signal_connect_weak_swapped (config, "notify::symbolic-icons",
......
......@@ -149,7 +149,10 @@ sn_plugin_size_changed (XfcePanelPlugin *panel_plugin,
{
SnPlugin *plugin = XFCE_SN_PLUGIN (panel_plugin);
sn_config_set_size (plugin->config, size, xfce_panel_plugin_get_nrows (panel_plugin));
sn_config_set_size (plugin->config,
size,
xfce_panel_plugin_get_nrows (panel_plugin),
xfce_panel_plugin_get_icon_size (panel_plugin));
systray_plugin_size_changed (panel_plugin,
xfce_panel_plugin_get_size (panel_plugin));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment