[maemo-commits] [maemo-commits] r11447 - in projects/haf/trunk/hildon-desktop: . src

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Fri May 4 15:44:53 EEST 2007
Author: moimart
Date: 2007-05-04 15:44:52 +0300 (Fri, 04 May 2007)
New Revision: 11447

Modified:
   projects/haf/trunk/hildon-desktop/ChangeLog
   projects/haf/trunk/hildon-desktop/src/hd-switcher-menu-item.c
   projects/haf/trunk/hildon-desktop/src/hd-switcher-menu-item.h
   projects/haf/trunk/hildon-desktop/src/hd-switcher-menu.c
Log:

	* src/hd-switcher-menu-item.[ch]:
        - Several minor bugfixes.
        * src/hd-switcher-menu.c:
        - Added basic support for notifications.
	* ChangeLog updated.



Modified: projects/haf/trunk/hildon-desktop/ChangeLog
===================================================================
--- projects/haf/trunk/hildon-desktop/ChangeLog	2007-05-04 12:24:30 UTC (rev 11446)
+++ projects/haf/trunk/hildon-desktop/ChangeLog	2007-05-04 12:44:52 UTC (rev 11447)
@@ -1,3 +1,10 @@
+2007-05-04  Moises Martinez  <moises.martinez at nokia.com>
+
+	* src/hd-switcher-menu-item.[ch]:
+	- Several minor bugfixes. 
+	* src/hd-switcher-menu.c:
+	- Added basic support for notifications.
+
 2007-05-04  Lucas Rocha  <lucas.rocha at nokia.com>
 
 	* libhildondesktop/hildon-desktop-notification-manager.[ch]: several

Modified: projects/haf/trunk/hildon-desktop/src/hd-switcher-menu-item.c
===================================================================
--- projects/haf/trunk/hildon-desktop/src/hd-switcher-menu-item.c	2007-05-04 12:24:30 UTC (rev 11446)
+++ projects/haf/trunk/hildon-desktop/src/hd-switcher-menu-item.c	2007-05-04 12:44:52 UTC (rev 11447)
@@ -139,6 +139,15 @@
   if (priv->pixbuf_anim)
     g_object_unref (priv->pixbuf_anim); 
 
+  if (priv->notification_icon)
+    g_object_unref (priv->notification_icon);
+
+  if (priv->notification_summary)
+    g_free (priv->notification_summary);
+
+  if (priv->notification_body)
+    g_free (priv->notification_body);	  
+
   G_OBJECT_CLASS (hd_switcher_menu_item_parent_class)->finalize (gobject);
 }
 
@@ -414,6 +423,8 @@
       gtk_image_set_from_pixbuf 
         (GTK_IMAGE (priv->icon), priv->notification_icon);
 
+    g_debug ("Id: %d Summary of notification: %s", priv->notification_id, priv->notification_summary);
+    
     gtk_label_set_text (GTK_LABEL (priv->label), 
 		        priv->notification_summary); /* TODO: Insert timestamp */
     gtk_label_set_text (GTK_LABEL (priv->label2),
@@ -494,27 +505,34 @@
 hd_switcher_menu_item_activate (GtkMenuItem *menu_item)
 {
   HDEntryInfo *info;
+  
+  info = hd_switcher_menu_item_get_entry_info (HD_SWITCHER_MENU_ITEM (menu_item));
 
-  info = hd_switcher_menu_item_get_entry_info (HD_SWITCHER_MENU_ITEM (menu_item));
-  g_assert (info != NULL);
+  if (info != NULL)
+  {
+    HN_DBG ("Raising application '%s'", hd_entry_info_peek_title (info));
   
-  HN_DBG ("Raising application '%s'", hd_entry_info_peek_title (info));
-  
-  hd_wm_top_item (info);
+    hd_wm_top_item (info);
+  }
+  else
+  if (HD_SWITCHER_MENU_ITEM (menu_item)->priv->notification_id != -1)
+  {
+    hildon_desktop_notification_manager_call_action 
+      (HD_SWITCHER_MENU_ITEM (menu_item)->priv->nm, 
+       HD_SWITCHER_MENU_ITEM (menu_item)->priv->notification_id,
+       "default");
+  }	  
 }
 
 static gboolean
 hd_switcher_menu_item_button_release_event (GtkWidget      *widget,
-                                     GdkEventButton *event)
+                                            GdkEventButton *event)
 {
   HDSwitcherMenuItem *menuitem = HD_SWITCHER_MENU_ITEM(widget);
   gint x, y;
   
   HN_DBG ("menu item clicked ended");
   
-  g_return_val_if_fail (menuitem && menuitem->priv && menuitem->priv->info,
-                        FALSE);
-
   if(!menuitem->priv->show_close ||
      !menuitem->priv->close)
     return FALSE;
@@ -546,11 +564,6 @@
     {
       GError *error = NULL;
 
-      hildon_desktop_notification_manager_call_action 
-        (menuitem->priv->nm, 
-	 menuitem->priv->notification_id,
-	 "default");
-
       hildon_desktop_notification_manager_close_notification
         (menuitem->priv->nm,
 	 menuitem->priv->notification_id,
@@ -578,9 +591,6 @@
   
   HN_DBG ("menu item clicked");
   
-  g_return_val_if_fail (menuitem && menuitem->priv && menuitem->priv->info,
-                        FALSE);
-
   if(!menuitem->priv->show_close ||
      !menuitem->priv->close)
     return FALSE;
@@ -663,25 +673,25 @@
 				   g_param_spec_int ("notification-id",
 					   	     "Id of notification",
 						     "The id of the notification",
-						      0,
+						      -1,
 						      G_MAXINT,
 						      -1,
-						     (G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)));
+						     (G_PARAM_CONSTRUCT | G_PARAM_READWRITE)));
   g_object_class_install_property (gobject_class,
 		  		   MENU_PROP_NOT_SUMMARY,
 				   g_param_spec_string ("notification-summary",
 					   		"Summary of notification",
 							"The summary of the notification",
-							NULL,
-							(G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)));
+							"",
+							(G_PARAM_CONSTRUCT | G_PARAM_READWRITE)));
  
   g_object_class_install_property (gobject_class,
 		  		   MENU_PROP_NOT_BODY,
 				   g_param_spec_string ("notification-body",
 					   		"Body of notification",
 							"The body of the notification",
-							NULL,
-							(G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE))); 
+							"",
+							(G_PARAM_CONSTRUCT | G_PARAM_READWRITE))); 
  
   g_object_class_install_property (gobject_class,
 		  		   MENU_PROP_NOT_BODY,
@@ -689,7 +699,7 @@
 					   		"Icon notification",
 							"The icon of the notification",
 							GDK_TYPE_PIXBUF,
-							(G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE))); 
+							(G_PARAM_CONSTRUCT | G_PARAM_READWRITE))); 
  
   g_type_class_add_private (klass, sizeof (HDSwitcherMenuItemPrivate));
 }
@@ -757,7 +767,7 @@
   HDSwitcherMenuItemPrivate *priv;
   GdkPixbuf *pixbuf;
   
-  g_return_if_fail (HN_IS_APP_MENU_ITEM (menuitem));
+  g_return_if_fail (HD_IS_SWITCHER_MENU_ITEM (menuitem));
   g_return_if_fail (info != NULL);
 
   priv = menuitem->priv;
@@ -814,7 +824,7 @@
 HDEntryInfo *
 hd_switcher_menu_item_get_entry_info (HDSwitcherMenuItem *menuitem)
 {
-  g_return_val_if_fail (HN_IS_APP_MENU_ITEM (menuitem), NULL);
+  g_return_val_if_fail (HD_IS_SWITCHER_MENU_ITEM (menuitem), NULL);
 
   return menuitem->priv->info;
 }
@@ -823,7 +833,7 @@
 hd_switcher_menu_item_set_is_blinking (HDSwitcherMenuItem *menuitem,
 				  gboolean       is_blinking)
 {
-  g_return_if_fail (HN_IS_APP_MENU_ITEM (menuitem));
+  g_return_if_fail (HD_IS_SWITCHER_MENU_ITEM (menuitem));
 
   hd_switcher_menu_item_icon_animation (menuitem->priv->icon, is_blinking);
 }
@@ -831,7 +841,15 @@
 gboolean
 hd_switcher_menu_item_get_is_blinking (HDSwitcherMenuItem *menuitem)
 {
-  g_return_val_if_fail (HN_IS_APP_MENU_ITEM (menuitem), FALSE);
+  g_return_val_if_fail (HD_IS_SWITCHER_MENU_ITEM (menuitem), FALSE);
 
   return menuitem->priv->is_blinking;
 }
+
+gint 
+hd_switcher_menu_item_get_notification_id (HDSwitcherMenuItem *menuitem)
+{
+  g_return_val_if_fail (HD_IS_SWITCHER_MENU_ITEM (menuitem), -1);
+
+  return menuitem->priv->notification_id;
+}	

Modified: projects/haf/trunk/hildon-desktop/src/hd-switcher-menu-item.h
===================================================================
--- projects/haf/trunk/hildon-desktop/src/hd-switcher-menu-item.h	2007-05-04 12:24:30 UTC (rev 11446)
+++ projects/haf/trunk/hildon-desktop/src/hd-switcher-menu-item.h	2007-05-04 12:44:52 UTC (rev 11447)
@@ -39,9 +39,9 @@
 
 #define HD_TYPE_SWITCHER_MENU_ITEM		 (hd_switcher_menu_item_get_type ())
 #define HD_SWITCHER_MENU_ITEM(obj)		 (G_TYPE_CHECK_INSTANCE_CAST ((obj), HD_TYPE_SWITCHER_MENU_ITEM, HDSwitcherMenuItem))
-#define HN_IS_APP_MENU_ITEM(obj)	 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), HD_TYPE_SWITCHER_MENU_ITEM))
+#define HD_IS_SWITCHER_MENU_ITEM(obj)	 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), HD_TYPE_SWITCHER_MENU_ITEM))
 #define HD_SWITCHER_MENU_ITEM_CLASS(klass)	 (G_TYPE_CHECK_CLASS_CAST ((klass), HD_TYPE_SWITCHER_MENU_ITEM, HDSwitcherMenuItemClass))
-#define HN_IS_APP_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), HD_TYPE_SWITCHER_MENU_ITEM))
+#define HD_IS_SWITCHER_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), HD_TYPE_SWITCHER_MENU_ITEM))
 #define HD_SWITCHER_MENU_ITEM_GET_CLASS(obj)	 (G_TYPE_INSTANCE_GET_CLASS ((obj), HD_TYPE_SWITCHER_MENU_ITEM, HDSwitcherMenuItemClass))
 
 typedef struct _HDSwitcherMenuItem        HDSwitcherMenuItem;
@@ -81,6 +81,8 @@
 					       gboolean       is_blinking);
 gboolean     hd_switcher_menu_item_get_is_blinking (HDSwitcherMenuItem *menuitem);
 
+gint	     hd_switcher_menu_item_get_notification_id (HDSwitcherMenuItem *menuitem);
+
 G_END_DECLS
 
 #endif /* HD_SWITCHER_MENU_ITEM_H */

Modified: projects/haf/trunk/hildon-desktop/src/hd-switcher-menu.c
===================================================================
--- projects/haf/trunk/hildon-desktop/src/hd-switcher-menu.c	2007-05-04 12:24:30 UTC (rev 11446)
+++ projects/haf/trunk/hildon-desktop/src/hd-switcher-menu.c	2007-05-04 12:44:52 UTC (rev 11447)
@@ -113,8 +113,8 @@
                                                     GtkTreeIter    *iter,
                                                     HDSwitcherMenu *switcher);
 
-static void hd_switcher_menu_notification_deleted_cb (GtkTreeModel   *tree_model,
-                                                      GtkTreePath    *path,
+static void hd_switcher_menu_notification_deleted_cb (HildonDesktopNotificationManager *nm,
+                                                      gint 	      id,
                                                       HDSwitcherMenu *switcher);
 
 static void hd_switcher_menu_notification_changed_cb (GtkTreeModel   *tree_model,
@@ -264,13 +264,13 @@
                     G_CALLBACK (hd_switcher_menu_long_press_cb),
                     (gpointer)switcher);
 
-  g_signal_connect (switcher->nm,
-		    "row-inserted",
-		    G_CALLBACK (hd_switcher_menu_notification_added_cb),
-		    (gpointer)switcher);
+  g_signal_connect_after (switcher->nm,
+		          "row-inserted",
+		          G_CALLBACK (hd_switcher_menu_notification_added_cb),
+		          (gpointer)switcher);
 
   g_signal_connect (switcher->nm,
-                    "row-deleted",
+                    "notification-closed",
                     G_CALLBACK (hd_switcher_menu_notification_deleted_cb),
                     (gpointer)switcher);
 
@@ -492,6 +492,8 @@
       gtk_widget_destroy (GTK_WIDGET (l->data));
   }
 
+  g_list_free (children);
+
   for (l = hd_wm_get_applications (hdwm); l != NULL; l = l->next)
   {
     GtkWidget *menu_item;
@@ -568,7 +570,7 @@
 
   for (l = children; l != NULL; l = g_list_next (l))
   {
-    if (GTK_IS_SEPARATOR_MENU_ITEM (l->data))
+    if (!GTK_IS_SEPARATOR_MENU_ITEM (l->data))
     {	    
       _info = hd_switcher_menu_item_get_entry_info (HD_SWITCHER_MENU_ITEM (l->data));
 
@@ -616,6 +618,8 @@
     }
   }
 
+  g_list_free (children);
+
   if (menu_item)
   {
     hd_switcher_menu_item_set_entry_info (HD_SWITCHER_MENU_ITEM (menu_item), info);
@@ -661,24 +665,61 @@
 }
 
 static void 
-hd_switcher_menu_notification_added_cb (GtkTreeModel   *tree_model,
+hd_switcher_menu_notification_changed_cb (GtkTreeModel   *tree_model,
                                         GtkTreePath    *path,
                                         GtkTreeIter    *iter,
                                         HDSwitcherMenu *switcher)
 {
+  GdkPixbuf *icon = NULL;
+  gchar *summary = NULL, *body = NULL;
+  guint id;
+  GtkWidget *menu_item;
+	
 
+  gtk_tree_model_get (tree_model,
+		      iter,
+		      HD_NM_COL_ID, &id,
+		      HD_NM_COL_ICON, &icon,
+		      HD_NM_COL_SUMMARY, &summary,
+		      HD_NM_COL_BODY, &body,
+		      -1);
+  g_debug ("Summary %s %s --------->",summary,body);
+  menu_item = 
+    hd_switcher_menu_item_new_from_notification 
+      (id, icon, summary, body, TRUE);
+
+  hildon_desktop_popup_menu_add_item
+    (switcher->priv->menu_notifications, GTK_MENU_ITEM (menu_item));
 }
 
 static void 
-hd_switcher_menu_notification_deleted_cb (GtkTreeModel   *tree_model,
-                                          GtkTreePath    *path,
+hd_switcher_menu_notification_deleted_cb (HildonDesktopNotificationManager   *nm,
+                                          gint 		  id,
                                           HDSwitcherMenu *switcher)
 {
+  GList *children = NULL, *l;
+  
+  children =
+    hildon_desktop_popup_menu_get_children (switcher->priv->menu_notifications);    	  
+  
+  for (l = children; l != NULL; l = g_list_next (l))
+  {
+    gint _id =
+      hd_switcher_menu_item_get_notification_id (HD_SWITCHER_MENU_ITEM (l->data));	    
+	  
+    if (_id == id)      
+    {
+      hildon_desktop_popup_menu_remove_item (switcher->priv->menu_notifications,
+	                                     GTK_MENU_ITEM (l->data));
+      break;
+    }	    
+  }	  
 
+  g_list_free (children);
 }
 
 static void 
-hd_switcher_menu_notification_changed_cb (GtkTreeModel   *tree_model,
+hd_switcher_menu_notification_added_cb   (GtkTreeModel   *tree_model,
                                           GtkTreePath    *path,
                                           GtkTreeIter    *iter,
                                           HDSwitcherMenu *switcher)


More information about the maemo-commits mailing list