[maemo-commits] [maemo-commits] r9633 - in projects/haf/branches/maemo-af-desktop/hildon-desktop: . libhildondesktop src

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Mon Feb 5 14:20:34 EET 2007
Author: moimart
Date: 2007-02-05 14:20:33 +0200 (Mon, 05 Feb 2007)
New Revision: 9633

Modified:
   projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog
   projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hildon-desktop-panel-expandable.c
   projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/statusbar-item.c
   projects/haf/branches/maemo-af-desktop/hildon-desktop/src/hd-plugin-loader-legacy.c
Log:

	* src/hd-plugin-loader-legacy.c:
        - Connect to change of "condition" property instead of
        old signal.
        * libhildondesktop/statusbar-item.c:
        - g_object_notify "condition" property changes
        * libhildondesktop/hildon-desktop-panel-expandable.c:
        - Changed list of items by a hash table
	* ChangeLog updated.



Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog
===================================================================
--- projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog	2007-02-05 12:09:40 UTC (rev 9632)
+++ projects/haf/branches/maemo-af-desktop/hildon-desktop/ChangeLog	2007-02-05 12:20:33 UTC (rev 9633)
@@ -1,3 +1,13 @@
+2007-02-05  Moises Martinez  <moises.martinez at nokia.com>
+
+	* src/hd-plugin-loader-legacy.c:
+	- Connect to change of "condition" property instead of 
+	old signal.
+	* libhildondesktop/statusbar-item.c:
+	- g_object_notify "condition" property changes
+	* libhildondesktop/hildon-desktop-panel-expandable.c:
+	- Changed list of items by a hash table
+
 2007-02-02  Johan Bilien  <johan.bilien at nokia.com>
 
 	* libhildondesktop/hildon-desktop-item.c: Fixed

Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hildon-desktop-panel-expandable.c
===================================================================
--- projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hildon-desktop-panel-expandable.c	2007-02-05 12:09:40 UTC (rev 9632)
+++ projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/hildon-desktop-panel-expandable.c	2007-02-05 12:20:33 UTC (rev 9633)
@@ -40,17 +40,17 @@
 
 struct _HildonDesktopPanelExpandablePrivate
 {
-  guint     items_p_row;
-  guint     n_items;
+  guint       items_p_row;
+  guint       n_items;
 
-  GList     *items;
+  GHashTable *items;
 
-  GtkWindow *extension_window;
-  GtkTable  *extension_table;
+  GtkWindow  *extension_window;
+  GtkTable   *extension_table;
 
-  gboolean   extension_opened;
+  gboolean    extension_opened;
 
-  GtkWidget *arrow;
+  GtkWidget  *arrow;
 };
 
 enum
@@ -132,7 +132,11 @@
 
   panel->priv->items_p_row = 0;
   panel->priv->n_items = 0;
-  panel->priv->items = NULL;
+  
+  panel->priv->items = g_hash_table_new_full (g_str_hash,
+		  			      g_str_equal,
+					      (GDestroyNotify) g_free,
+					      (GDestroyNotify) gtk_widget_destroy);
 
   panel->priv->extension_opened = FALSE;
 
@@ -192,6 +196,8 @@
 
   gtk_widget_destroy (GTK_WIDGET (panel->priv->extension_window));
 
+  g_hash_table_destroy (panel->priv->items);
+
   G_OBJECT_CLASS (hildon_desktop_panel_expandable_parent_class)->finalize (object);
 }
 
@@ -258,6 +264,13 @@
 }
 
 static void 
+hildon_desktop_panel_expandable_button_destroyed (GtkWidget *widget, gpointer _panel)
+{
+  g_hash_table_remove (HILDON_DESKTOP_PANEL_EXPANDABLE (_panel)->priv->items,
+		       HILDON_DESKTOP_ITEM (widget)->id);
+}
+
+static void 
 hildon_desktop_panel_expandable_add_button (HildonDesktopPanel *panel, GtkWidget *button)
 {
   HildonDesktopPanelItem *item = HILDON_DESKTOP_PANEL_ITEM (button);
@@ -270,6 +283,11 @@
   
   gtk_widget_set_size_request (button, item_width, item_height);
 
+  g_signal_connect (button,
+		    "destroy",
+		    G_CALLBACK (hildon_desktop_panel_expandable_button_destroyed),
+		    (gpointer)panel);
+
   if (STATUSBAR_IS_ITEM (button))
   {
     g_signal_connect_after (STATUSBAR_ITEM (item),
@@ -306,14 +324,17 @@
     }
   }
   
-  if (g_list_find (ex_panel->priv->items, item) == NULL)
+  if (g_hash_table_lookup (ex_panel->priv->items, HILDON_DESKTOP_ITEM (item)->id) == NULL)
   {
     if (STATUSBAR_IS_ITEM (button) && !STATUSBAR_ITEM (button)->condition)
     {	  
       gtk_object_sink (GTK_OBJECT (item));
       g_object_ref (G_OBJECT (item));
     }
-    ex_panel->priv->items = g_list_append (ex_panel->priv->items, item);
+    
+    g_hash_table_insert (ex_panel->priv->items,
+			 HILDON_DESKTOP_ITEM (item)->id,
+			 (gpointer)item);
   }
 }
 
@@ -380,6 +401,21 @@
 }
 
 static void 
+hildon_desktop_panel_expandable_hash_adding (gchar *key, 
+					     HildonDesktopItem *item,
+					     HildonDesktopPanelExpandable *panel)
+{
+
+  hildon_desktop_panel_expandable_add_button (HILDON_DESKTOP_PANEL (panel),
+		      			      GTK_WIDGET (item));
+
+  if (STATUSBAR_IS_ITEM (item) && !STATUSBAR_ITEM (item)->condition)
+    g_debug ("not unreffing");
+  else
+    g_object_unref (G_OBJECT (item));
+}
+
+static void 
 hildon_desktop_panel_expandable_arrange_items (HildonDesktopPanelExpandable *panel)
 {
   /*TODO: Improve this!! This horribly slow!!!!! */
@@ -407,21 +443,12 @@
 		    	  GTK_WIDGET (l->data));
   }
 
-  for (l=panel->priv->items;l;l=g_list_next (l)){ g_debug ("2pointerrrr %p %s",l->data,HILDON_DESKTOP_ITEM (l->data)->id);}
-
   panel->priv->n_items = 0;
 
-  for (l = panel->priv->items; l ; l = g_list_next (l))
-  {
-    hildon_desktop_panel_expandable_add_button (HILDON_DESKTOP_PANEL (panel),
-		      				GTK_WIDGET (l->data));
+  g_hash_table_foreach (panel->priv->items,
+		  	(GHFunc)hildon_desktop_panel_expandable_hash_adding,
+			(gpointer)panel);
 
-    if (STATUSBAR_IS_ITEM (l->data) && !STATUSBAR_ITEM (l->data)->condition)
-      g_debug ("not unreffing");
-    else
-      g_object_unref (G_OBJECT (l->data));
-  }
-
   g_list_free (children_panel);
   g_list_free (children_table);
 }

Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/statusbar-item.c
===================================================================
--- projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/statusbar-item.c	2007-02-05 12:09:40 UTC (rev 9632)
+++ projects/haf/branches/maemo-af-desktop/hildon-desktop/libhildondesktop/statusbar-item.c	2007-02-05 12:20:33 UTC (rev 9633)
@@ -129,9 +129,7 @@
 static void 
 statusbar_item_update_condition (StatusbarItem *item, gboolean condition)
 {
-  item->condition = condition;
-
-  g_debug ("Changing condition %s %d",HILDON_DESKTOP_ITEM (item)->id, item->condition);
+  g_object_set (G_OBJECT (item), "condition", condition, NULL);
 }
 
 static void 
@@ -162,6 +160,7 @@
   {
     case SB_PROP_CONDITION:
       sbitem->condition = g_value_get_boolean (value);
+      g_object_notify (object, "condition");
       break;
     case SB_PROP_MANDATORY:
       sbitem->mandatory = g_value_get_boolean (value);

Modified: projects/haf/branches/maemo-af-desktop/hildon-desktop/src/hd-plugin-loader-legacy.c
===================================================================
--- projects/haf/branches/maemo-af-desktop/hildon-desktop/src/hd-plugin-loader-legacy.c	2007-02-05 12:09:40 UTC (rev 9632)
+++ projects/haf/branches/maemo-af-desktop/hildon-desktop/src/hd-plugin-loader-legacy.c	2007-02-05 12:20:33 UTC (rev 9633)
@@ -709,7 +709,7 @@
       set_conditional_data->cb = (SBSetConditional)symbols.set_conditional;
       set_conditional_data->module_data = module_data;
 
-      g_signal_connect (item, "hildon-status-bar-update-conditional",
+      g_signal_connect (item, "notify::condition",
                         G_CALLBACK (hd_plugin_loader_legacy_status_bar_set_conditional),
                         set_conditional_data);
     }


More information about the maemo-commits mailing list