[Xfce4-commits] <xfce4-panel:andrzejr/deskbar-github> panel-window: fixing some start-up clean-up errors.

Andrzej noreply at xfce.org
Mon Dec 12 11:40:50 CET 2011


Updating branch refs/heads/andrzejr/deskbar-github
         to 8be7247f461778711e906bb5e35ce4cda0128d7d (commit)
       from 762683f79f2096946b748070701faf76691f998b (commit)

commit 8be7247f461778711e906bb5e35ce4cda0128d7d
Author: Andrzej <ndrwrdck at gmail.com>
Date:   Tue Dec 6 21:10:49 2011 +0900

    panel-window: fixing some start-up clean-up errors.
    
    The panel didn't could hang if some of the properties were missing in the config.

 panel/panel-window.c |   60 ++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 48 insertions(+), 12 deletions(-)

diff --git a/panel/panel-window.c b/panel/panel-window.c
index be8d4e1..62d554e 100644
--- a/panel/panel-window.c
+++ b/panel/panel-window.c
@@ -80,6 +80,7 @@ static void         panel_window_set_property               (GObject          *o
                                                              const GValue     *value,
                                                              GParamSpec       *pspec);
 static void         panel_window_finalize                   (GObject          *object);
+static void         panel_window_dispose                    (GObject          *object);
 static gboolean     panel_window_expose_event               (GtkWidget        *widget,
                                                              GdkEventExpose   *event);
 static gboolean     panel_window_enter_notify_event         (GtkWidget        *widget,
@@ -299,6 +300,10 @@ struct _PanelWindow
   guint32              grab_time;
   gint                 grab_x;
   gint                 grab_y;
+  /* property bindings */
+  ExoMutualBinding    *icon_size_binding;
+  ExoBinding          *nrows_binding;
+
 };
 
 /* used for a full XfcePanelWindow name in the class, but not in the code */
@@ -329,6 +334,7 @@ panel_window_class_init (PanelWindowClass *klass)
   gobject_class->get_property = panel_window_get_property;
   gobject_class->set_property = panel_window_set_property;
   gobject_class->finalize = panel_window_finalize;
+  gobject_class->dispose = panel_window_dispose;
 
   gtkwidget_class = GTK_WIDGET_CLASS (klass);
   gtkwidget_class->expose_event = panel_window_expose_event;
@@ -464,7 +470,7 @@ transform_icon_size_to_panel_size (const GValue *src_value,
                                    gpointer      user_data)
 {
   guint icon_size, nrows;
-  GValue nrows_value;
+  GValue nrows_value = {0,};
 
   if (!user_data)
     return FALSE;
@@ -473,6 +479,8 @@ transform_icon_size_to_panel_size (const GValue *src_value,
 
   icon_size = g_value_get_uint (src_value);
   nrows = g_value_get_uint (&nrows_value);
+  if (nrows < 1)
+    nrows = 1;
   g_value_set_uint (dst_value, icon_size * nrows);
   return TRUE;
 }
@@ -484,7 +492,7 @@ transform_panel_size_to_icon_size (const GValue *src_value,
                                    gpointer      user_data)
 {
   guint panel_size, nrows;
-  GValue nrows_value;
+  GValue nrows_value = {0,};
 
   if (!user_data)
     return FALSE;
@@ -493,6 +501,8 @@ transform_panel_size_to_icon_size (const GValue *src_value,
 
   panel_size = g_value_get_uint (src_value);
   nrows = g_value_get_uint (&nrows_value);
+  if (nrows < 1)
+    nrows = 1;
   g_value_set_uint (dst_value, panel_size / nrows);
   return TRUE;
 }
@@ -504,7 +514,7 @@ transform_nrows_to_panel_size (const GValue *src_value,
                                gpointer      user_data)
 {
   guint icon_size, nrows;
-  GValue icon_size_value;
+  GValue icon_size_value = {0,};
 
   if (!user_data)
     return FALSE;
@@ -513,6 +523,8 @@ transform_nrows_to_panel_size (const GValue *src_value,
   icon_size = g_value_get_uint (&icon_size_value);
 
   nrows = g_value_get_uint (src_value);
+  if (nrows < 1)
+    nrows = 1;
   g_value_set_uint (dst_value, icon_size * nrows);
   return TRUE;
 }
@@ -526,9 +538,9 @@ panel_window_init (PanelWindow *window)
   window->struts_edge = STRUTS_EDGE_NONE;
   window->struts_disabled = FALSE;
   window->horizontal = TRUE;
-  window->icon_size = 30;
   window->nrows = 1;
-  window->size = window->icon_size * window->nrows;
+  window->icon_size = 30;
+  window->size = 30;
   window->length = 0.10;
   window->length_adjust = TRUE;
   window->deskbar_mode = FALSE;
@@ -560,13 +572,15 @@ 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);
+  window->icon_size_binding =
+    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);
+  window->nrows_binding =
+    exo_binding_new_full (G_OBJECT (window), "nrows", G_OBJECT (window), "size",
+			  transform_nrows_to_panel_size,
+			  NULL, window);
 }
 
 
@@ -811,6 +825,28 @@ panel_window_set_property (GObject      *object,
 
 
 static void
+panel_window_dispose (GObject *object)
+{
+  PanelWindow *window = PANEL_WINDOW (object);
+
+  /* disconnect properties */
+  if (window->icon_size_binding)
+    {
+      exo_mutual_binding_unbind (window->icon_size_binding);
+      window->icon_size_binding = NULL;
+    }
+  if (window->nrows_binding)
+    {
+      exo_binding_unbind (window->nrows_binding);
+      window->nrows_binding = NULL;
+    }
+
+  (*G_OBJECT_CLASS (panel_window_parent_class)->dispose) (object);
+}
+
+
+
+static void
 panel_window_finalize (GObject *object)
 {
   PanelWindow *window = PANEL_WINDOW (object);


More information about the Xfce4-commits mailing list