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

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Thu Aug 30 17:22:59 EEST 2007
Author: lucasr
Date: 2007-08-30 17:22:55 +0300 (Thu, 30 Aug 2007)
New Revision: 13499

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:
2007-08-30  Lucas Rocha  <lucas.rocha at nokia.com>

	* src/hd-switcher-menu.c (hd_switcher_menu_changed_info_cb): refresh
	applications menu items when a generic entry info change notification
	arrives. 
	* src/hd-switcher-menu-item.c (hd_switcher_menu_item_set_entry_info,
	hd_switcher_menu_item_class_init,
	hd_switcher_menu_item_compose_bkill_pixbuf): add bgkill emblem on
	entry info update in menu item. Fixes #59573.


Modified: projects/haf/trunk/hildon-desktop/ChangeLog
===================================================================
--- projects/haf/trunk/hildon-desktop/ChangeLog	2007-08-30 14:21:29 UTC (rev 13498)
+++ projects/haf/trunk/hildon-desktop/ChangeLog	2007-08-30 14:22:55 UTC (rev 13499)
@@ -1,3 +1,13 @@
+2007-08-30  Lucas Rocha  <lucas.rocha at nokia.com>
+
+	* src/hd-switcher-menu.c (hd_switcher_menu_changed_info_cb): refresh
+	applications menu items when a generic entry info change notification
+	arrives. 
+	* src/hd-switcher-menu-item.c (hd_switcher_menu_item_set_entry_info,
+	hd_switcher_menu_item_class_init,
+	hd_switcher_menu_item_compose_bkill_pixbuf): add bgkill emblem on
+	entry info update in menu item. Fixes #59573.
+
 2007-08-30 Johan Bilien  <johan.bilien at nokia.com>
 
 	* src/hd-plugin-manager.c (hd_plugin_manager_sync):

Modified: projects/haf/trunk/hildon-desktop/src/hd-switcher-menu-item.c
===================================================================
--- projects/haf/trunk/hildon-desktop/src/hd-switcher-menu-item.c	2007-08-30 14:21:29 UTC (rev 13498)
+++ projects/haf/trunk/hildon-desktop/src/hd-switcher-menu-item.c	2007-08-30 14:22:55 UTC (rev 13499)
@@ -74,6 +74,7 @@
 #define AS_BUTTON_HEIGHT           38
 #define AS_ROW_HEIGHT 		   30
 #define AS_ICON_SIZE               26
+#define AS_GROUP_ICON_SIZE         16
 #define AS_CLOSE_BUTTON_SIZE       16
 #define AS_CLOSE_BUTTON_THUMB_SIZE 40
 #define AS_TOOLTIP_WIDTH           360
@@ -746,6 +747,12 @@
                                                         0,
                                                         NULL);
   
+  klass->bkilled_emblem = gtk_icon_theme_load_icon (icon_theme,
+                                                    "qgn_indi_bkilled",
+                                                    AS_GROUP_ICON_SIZE,
+                                                    0,
+                                                    NULL);
+  
   g_object_class_install_property (gobject_class,
 		  		   MENU_PROP_SHOW_CLOSE,
 				   g_param_spec_boolean ("show-close",
@@ -819,6 +826,48 @@
   g_type_class_add_private (klass, sizeof (HDSwitcherMenuItemPrivate));
 }
 
+static GdkPixbuf *
+hd_switcher_menu_item_compose_bkill_pixbuf (HDSwitcherMenuItem *menuitem,
+				            const GdkPixbuf    *src,
+				            HDWMEntryInfo	     *info)
+{
+  HDSwitcherMenuItemClass *menuitem_class;
+  GdkPixbuf *retval;
+  gint dest_width, dest_height;
+  gint off_x, off_y;
+
+  g_return_val_if_fail (HD_IS_SWITCHER_MENU_ITEM (menuitem), NULL);
+  g_return_val_if_fail (GDK_IS_PIXBUF (src), NULL);
+  g_return_val_if_fail (info != NULL, NULL);
+
+  menuitem_class = HD_SWITCHER_MENU_ITEM_GET_CLASS (menuitem);
+
+  if (!menuitem_class->bkilled_emblem)
+    return NULL;
+
+  /* Make a copy of the source pixbuf, and also make
+   * sure that it has an alpha channel
+   */
+  retval = gdk_pixbuf_add_alpha (src, FALSE, 255, 255, 255);
+
+  dest_width = gdk_pixbuf_get_width (retval);
+  dest_height = gdk_pixbuf_get_height (retval);
+
+  off_x = dest_width - gdk_pixbuf_get_width (menuitem_class->bkilled_emblem);
+  off_y = dest_height - gdk_pixbuf_get_height (menuitem_class->bkilled_emblem);
+
+  gdk_pixbuf_composite (menuitem_class->bkilled_emblem, 
+		        retval,
+		        0, 0,
+			dest_width, dest_height,
+			off_x, off_y,
+			1.0, 1.0,
+			GDK_INTERP_BILINEAR,
+			0xFF);
+
+  return retval;
+}
+
 static void
 hd_switcher_menu_item_init (HDSwitcherMenuItem *menuitem)
 {
@@ -943,10 +992,29 @@
       }
     }
   }
+
   
   if (pixbuf)
   {
-    gtk_image_set_from_pixbuf (GTK_IMAGE (priv->icon), pixbuf);
+    GdkPixbuf *app_pixbuf;
+	  
+    if (hd_wm_entry_info_is_hibernating (info))
+    {
+      app_pixbuf = hd_switcher_menu_item_compose_bkill_pixbuf (menuitem, 
+		                                               pixbuf,
+							       info);
+    }
+    else
+    {
+      app_pixbuf = gdk_pixbuf_copy (pixbuf);
+    }
+
+    if (app_pixbuf)
+    {
+      gtk_image_set_from_pixbuf (GTK_IMAGE (priv->icon), app_pixbuf);
+      g_object_unref (app_pixbuf);
+    }
+ 
     g_object_unref (pixbuf);
   }
   

Modified: projects/haf/trunk/hildon-desktop/src/hd-switcher-menu-item.h
===================================================================
--- projects/haf/trunk/hildon-desktop/src/hd-switcher-menu-item.h	2007-08-30 14:21:29 UTC (rev 13498)
+++ projects/haf/trunk/hildon-desktop/src/hd-switcher-menu-item.h	2007-08-30 14:22:55 UTC (rev 13499)
@@ -59,6 +59,7 @@
 {
   GtkImageMenuItemClass parent_class;
 
+  GdkPixbuf *bkilled_emblem;
   GdkPixbuf *close_button;
   GdkPixbuf *thumb_close_button;
 };

Modified: projects/haf/trunk/hildon-desktop/src/hd-switcher-menu.c
===================================================================
--- projects/haf/trunk/hildon-desktop/src/hd-switcher-menu.c	2007-08-30 14:21:29 UTC (rev 13498)
+++ projects/haf/trunk/hildon-desktop/src/hd-switcher-menu.c	2007-08-30 14:22:55 UTC (rev 13499)
@@ -1908,6 +1908,26 @@
   return app_pixbuf;
 }	
 
+static void
+hd_switcher_menu_refresh_items (HDSwitcherMenu *switcher)
+{
+  GList *children = NULL, *l;
+
+  children =
+    hildon_desktop_popup_menu_get_children (switcher->priv->menu_applications);
+
+  for (l = children; l != NULL; l = g_list_next (l))
+  {
+    if (HD_IS_SWITCHER_MENU_ITEM (l->data))
+    {
+      HDWMEntryInfo *info =	    
+        hd_switcher_menu_item_get_entry_info (HD_SWITCHER_MENU_ITEM (l->data));
+
+      hd_switcher_menu_item_set_entry_info (HD_SWITCHER_MENU_ITEM (l->data), info);
+    }	    
+  }	  
+}
+	
 static void 
 hd_switcher_menu_changed_info_cb (HDWM *hdwm,
 				  HDWMEntryInfo *info,
@@ -1919,8 +1939,11 @@
   gboolean make_it_blink = FALSE;
 
   if (!info)
-    return;	  
-
+  {
+    hd_switcher_menu_refresh_items (switcher);
+    return;
+  }
+    
   /* We have to guess whether it is in app switcher's slots or not*/
   
   if (HD_WM_IS_APPLICATION (info))


More information about the maemo-commits mailing list