[Xfce4-commits] <xfce4-panel:andrzejr/deskbar-github> panel-preferences-dialog: refactoring, property transformation moved to panel-window.
Andrzej
noreply at xfce.org
Mon Dec 12 11:40:47 CET 2011
Updating branch refs/heads/andrzejr/deskbar-github
to f2a53c02b2077e0701e5bd932a3720a40a8b38f7 (commit)
from ef10316d2a840371f8a6dcf9494ca883a648b6da (commit)
commit f2a53c02b2077e0701e5bd932a3720a40a8b38f7
Author: Andrzej <ndrwrdck at gmail.com>
Date: Thu Dec 1 12:29:54 2011 +0900
panel-preferences-dialog: refactoring, property transformation moved to panel-window.
panel/panel-preferences-dialog.c | 78 +---------------------------
panel/panel-preferences-dialog.glade | 8 ++--
panel/panel-window.c | 94 +++++++++++++++++++++++++++++++++-
3 files changed, 97 insertions(+), 83 deletions(-)
diff --git a/panel/panel-preferences-dialog.c b/panel/panel-preferences-dialog.c
index 5653433..c429a8c 100644
--- a/panel/panel-preferences-dialog.c
+++ b/panel/panel-preferences-dialog.c
@@ -386,66 +386,6 @@ panel_preferences_dialog_bindings_add (PanelPreferencesDialog *dialog,
}
-static gboolean
-transform_icon_size_to_panel_size (const GValue *src_value,
- GValue *dst_value,
- gpointer user_data)
-{
- guint icon_size, nrows;
- GValue nrows_value;
-
- if (!user_data)
- return FALSE;
- g_value_init (&nrows_value, G_TYPE_UINT);
- g_object_get_property (G_OBJECT (user_data), "nrows", &nrows_value);
-
- icon_size = g_value_get_double (src_value);
- nrows = g_value_get_uint (&nrows_value);
- g_value_set_uint (dst_value, icon_size * nrows);
- return TRUE;
-}
-
-
-static gboolean
-transform_panel_size_to_icon_size (const GValue *src_value,
- GValue *dst_value,
- gpointer user_data)
-{
- guint panel_size, nrows;
- GValue nrows_value;
-
- if (!user_data)
- return FALSE;
- g_value_init (&nrows_value, G_TYPE_UINT);
- g_object_get_property (G_OBJECT (user_data), "nrows", &nrows_value);
-
- panel_size = g_value_get_uint (src_value);
- nrows = g_value_get_uint (&nrows_value);
- g_value_set_double (dst_value, panel_size / nrows);
- return TRUE;
-}
-
-
-static gboolean
-transform_nrows_to_panel_size (const GValue *src_value,
- GValue *dst_value,
- gpointer user_data)
-{
- guint icon_size, nrows;
- GValue icon_size_value;
-
- if (!user_data)
- return FALSE;
- g_value_init (&icon_size_value, G_TYPE_DOUBLE);
- g_object_get_property (G_OBJECT (user_data), "value", &icon_size_value);
- icon_size = g_value_get_double (&icon_size_value);
-
- nrows = g_value_get_uint (src_value);
- g_value_set_uint (dst_value, icon_size * nrows);
- return TRUE;
-}
-
-
static void
panel_preferences_dialog_bindings_update (PanelPreferencesDialog *dialog)
{
@@ -461,7 +401,6 @@ panel_preferences_dialog_bindings_update (PanelPreferencesDialog *dialog)
gint n = 0, i;
gchar *name, *title;
gboolean span_monitors_sensitive = FALSE;
- GObject *size_object, *nrows_object;
/* leave when there is no active panel */
panel_return_if_fail (G_IS_OBJECT (dialog->active));
@@ -474,7 +413,7 @@ panel_preferences_dialog_bindings_update (PanelPreferencesDialog *dialog)
panel_preferences_dialog_bindings_add (dialog, "position-locked", "active");
panel_preferences_dialog_bindings_add (dialog, "autohide", "active");
panel_preferences_dialog_bindings_add (dialog, "disable-struts", "active");
- /* panel_preferences_dialog_bindings_add (dialog, "size", "value"); */
+ panel_preferences_dialog_bindings_add (dialog, "icon-size", "value");
panel_preferences_dialog_bindings_add (dialog, "length", "value");
panel_preferences_dialog_bindings_add (dialog, "length-adjust", "active");
panel_preferences_dialog_bindings_add (dialog, "background-alpha", "value");
@@ -486,21 +425,6 @@ panel_preferences_dialog_bindings_update (PanelPreferencesDialog *dialog)
panel_preferences_dialog_bindings_add (dialog, "nrows", "value");
panel_preferences_dialog_bindings_add (dialog, "deskbar-mode", "active");
- size_object = gtk_builder_get_object (GTK_BUILDER (dialog), "size");
- dialog->bindings =
- g_slist_prepend (dialog->bindings,
- exo_mutual_binding_new_full (G_OBJECT (dialog->active), "size", size_object, "value",
- transform_panel_size_to_icon_size,
- transform_icon_size_to_panel_size,
- NULL, dialog->active));
- dialog->bindings =
- g_slist_prepend (dialog->bindings,
- exo_binding_new_full (G_OBJECT (dialog->active), "nrows", G_OBJECT (dialog->active), "size",
- transform_nrows_to_panel_size,
- NULL, size_object));
-
-
-
/* watch image changes from the panel */
dialog->bg_image_notify_handler_id = g_signal_connect_swapped (G_OBJECT (dialog->active),
diff --git a/panel/panel-preferences-dialog.glade b/panel/panel-preferences-dialog.glade
index ec9e6bd..222cd54 100644
--- a/panel/panel-preferences-dialog.glade
+++ b/panel/panel-preferences-dialog.glade
@@ -55,7 +55,7 @@
<property name="step_increment">1</property>
<property name="page_increment">1</property>
</object>
- <object class="GtkAdjustment" id="size">
+ <object class="GtkAdjustment" id="icon-size">
<property name="value">16</property>
<property name="lower">16</property>
<property name="upper">128</property>
@@ -395,7 +395,7 @@
<property name="xalign">0</property>
<property name="label" translatable="yes">Icon _Size (pixels):</property>
<property name="use_underline">True</property>
- <property name="mnemonic_widget">size-scale</property>
+ <property name="mnemonic_widget">icon-size-scale</property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
@@ -446,11 +446,11 @@
</packing>
</child>
<child>
- <object class="GtkHScale" id="size-scale">
+ <object class="GtkHScale" id="icon-size-scale">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="update_policy">discontinuous</property>
- <property name="adjustment">size</property>
+ <property name="adjustment">icon-size</property>
<property name="digits">0</property>
<property name="value_pos">right</property>
</object>
diff --git a/panel/panel-window.c b/panel/panel-window.c
index 9f684cb..be8d4e1 100644
--- a/panel/panel-window.c
+++ b/panel/panel-window.c
@@ -147,6 +147,7 @@ enum
{
PROP_0,
PROP_HORIZONTAL,
+ PROP_ICON_SIZE,
PROP_SIZE,
PROP_LENGTH,
PROP_LENGTH_ADJUST,
@@ -261,6 +262,7 @@ struct _PanelWindow
guint struts_disabled : 1;
/* window positioning */
+ guint icon_size;
guint size;
gdouble length;
guint length_adjust : 1;
@@ -351,6 +353,12 @@ panel_window_class_init (PanelWindowClass *klass)
EXO_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
+ PROP_ICON_SIZE,
+ g_param_spec_uint ("icon-size", NULL, NULL,
+ 16, 128, 48,
+ EXO_PARAM_READWRITE));
+
+ g_object_class_install_property (gobject_class,
PROP_SIZE,
g_param_spec_uint ("size", NULL, NULL,
16, 128*8, 48,
@@ -450,6 +458,66 @@ panel_window_class_init (PanelWindowClass *klass)
+static gboolean
+transform_icon_size_to_panel_size (const GValue *src_value,
+ GValue *dst_value,
+ gpointer user_data)
+{
+ guint icon_size, nrows;
+ GValue nrows_value;
+
+ if (!user_data)
+ return FALSE;
+ g_value_init (&nrows_value, G_TYPE_UINT);
+ g_object_get_property (G_OBJECT (user_data), "nrows", &nrows_value);
+
+ icon_size = g_value_get_uint (src_value);
+ nrows = g_value_get_uint (&nrows_value);
+ g_value_set_uint (dst_value, icon_size * nrows);
+ return TRUE;
+}
+
+
+static gboolean
+transform_panel_size_to_icon_size (const GValue *src_value,
+ GValue *dst_value,
+ gpointer user_data)
+{
+ guint panel_size, nrows;
+ GValue nrows_value;
+
+ if (!user_data)
+ return FALSE;
+ g_value_init (&nrows_value, G_TYPE_UINT);
+ g_object_get_property (G_OBJECT (user_data), "nrows", &nrows_value);
+
+ panel_size = g_value_get_uint (src_value);
+ nrows = g_value_get_uint (&nrows_value);
+ g_value_set_uint (dst_value, panel_size / nrows);
+ return TRUE;
+}
+
+
+static gboolean
+transform_nrows_to_panel_size (const GValue *src_value,
+ GValue *dst_value,
+ gpointer user_data)
+{
+ guint icon_size, nrows;
+ GValue icon_size_value;
+
+ if (!user_data)
+ return FALSE;
+ g_value_init (&icon_size_value, G_TYPE_UINT);
+ g_object_get_property (G_OBJECT (user_data), "icon-size", &icon_size_value);
+ icon_size = g_value_get_uint (&icon_size_value);
+
+ nrows = g_value_get_uint (src_value);
+ g_value_set_uint (dst_value, icon_size * nrows);
+ return TRUE;
+}
+
+
static void
panel_window_init (PanelWindow *window)
{
@@ -458,10 +526,11 @@ panel_window_init (PanelWindow *window)
window->struts_edge = STRUTS_EDGE_NONE;
window->struts_disabled = FALSE;
window->horizontal = TRUE;
- window->size = 30;
+ window->icon_size = 30;
+ window->nrows = 1;
+ window->size = window->icon_size * window->nrows;
window->length = 0.10;
window->length_adjust = TRUE;
- window->nrows = 1;
window->deskbar_mode = FALSE;
window->snap_position = SNAP_POSITION_NONE;
window->span_monitors = FALSE;
@@ -490,6 +559,14 @@ panel_window_init (PanelWindow *window)
/* set the screen */
panel_window_screen_changed (GTK_WIDGET (window), NULL);
+
+ exo_mutual_binding_new_full (G_OBJECT (window), "icon-size", G_OBJECT (window), "size",
+ transform_icon_size_to_panel_size,
+ transform_panel_size_to_icon_size,
+ NULL, window);
+ exo_binding_new_full (G_OBJECT (window), "nrows", G_OBJECT (window), "size",
+ transform_nrows_to_panel_size,
+ NULL, window);
}
@@ -509,6 +586,10 @@ panel_window_get_property (GObject *object,
g_value_set_boolean (value, window->horizontal);
break;
+ case PROP_ICON_SIZE:
+ g_value_set_uint (value, window->icon_size);
+ break;
+
case PROP_SIZE:
g_value_set_uint (value, window->size);
break;
@@ -594,6 +675,15 @@ panel_window_set_property (GObject *object,
panel_window_plugins_update (window, PLUGIN_PROP_SCREEN_POSITION);
break;
+ case PROP_ICON_SIZE:
+ val_uint = g_value_get_uint (value);
+ if (window->icon_size != val_uint)
+ {
+ window->icon_size = val_uint;
+ }
+ /* the "size" property will be updated automatically */
+ break;
+
case PROP_SIZE:
val_uint = g_value_get_uint (value);
if (window->size != val_uint)
More information about the Xfce4-commits
mailing list