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

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Mon Jun 18 17:51:33 EEST 2007
Author: moimart
Date: 2007-06-18 17:51:27 +0300 (Mon, 18 Jun 2007)
New Revision: 12333

Modified:
   projects/haf/trunk/hildon-desktop/ChangeLog
   projects/haf/trunk/hildon-desktop/libhildonwm/hd-entry-info.c
   projects/haf/trunk/hildon-desktop/libhildonwm/hd-entry-info.h
   projects/haf/trunk/hildon-desktop/src/hn-app-button.c
   projects/haf/trunk/hildon-desktop/src/hn-app-button.h
   projects/haf/trunk/hildon-desktop/src/hn-app-switcher.c
Log:
2007-06-18  Moises Martinez  <moises.martinez at nokia.com>

        * src/hn-app-switcher.c:
        - Set icon geometry to application socket or to entire appswitcher
        according to position.
        * src/hn-app-button.[ch]:
        - Save last entry info used.
        * libhildonwm/hd-entry-info.[ch]:
        - Added support for icon geometry. Added flag to not override last
        icon geometry if it was already set.
        Fixes partially: NB#56505
	* ChangeLog updated.



Modified: projects/haf/trunk/hildon-desktop/ChangeLog
===================================================================
--- projects/haf/trunk/hildon-desktop/ChangeLog	2007-06-18 14:27:56 UTC (rev 12332)
+++ projects/haf/trunk/hildon-desktop/ChangeLog	2007-06-18 14:51:27 UTC (rev 12333)
@@ -1,3 +1,15 @@
+2007-06-18  Moises Martinez  <moises.martinez at nokia.com>
+
+	* src/hn-app-switcher.c:
+	- Set icon geometry to application socket or to entire appswitcher
+	according to position.
+	* src/hn-app-button.[ch]:
+	- Save last entry info used.
+	* libhildonwm/hd-entry-info.[ch]:
+	- Added support for icon geometry. Added flag to not override last
+	icon geometry if it was already set.
+	Fixes partially: NB#56505
+
 2007-06-18  Johan Bilien  <johan.bilien at nokia.com>
 
 	* data/statusbar.conf.in: added new plugin

Modified: projects/haf/trunk/hildon-desktop/libhildonwm/hd-entry-info.c
===================================================================
--- projects/haf/trunk/hildon-desktop/libhildonwm/hd-entry-info.c	2007-06-18 14:27:56 UTC (rev 12332)
+++ projects/haf/trunk/hildon-desktop/libhildonwm/hd-entry-info.c	2007-06-18 14:51:27 UTC (rev 12333)
@@ -26,6 +26,8 @@
 #include <stdlib.h>
 #include <glib/gi18n.h>
 
+#include <X11/Xatom.h>
+
 #include "hd-entry-info.h"
 
 #include "hd-wm-watchable-app.h"
@@ -48,6 +50,7 @@
   GHashTable *icon_cache;
   
   guint ignore_urgent : 1;
+  guint override_icon_geometry : 1;
 } RealEntryInfo;
 
 #define REAL_ENTRY_INFO(x) ((RealEntryInfo *) (x))
@@ -64,6 +67,7 @@
   retval->parent = NULL;
   retval->children = NULL;
   retval->ignore_urgent = FALSE;
+  retval->override_icon_geometry = TRUE;
   retval->icon_cache = g_hash_table_new_full (g_direct_hash,
                                               g_direct_equal,
                                               NULL,
@@ -430,6 +434,49 @@
   }
 }
 
+void 
+hd_entry_info_set_icon_geometry (HDEntryInfo *info,
+                                 gint x,
+                                 gint y,
+                                 gint width,
+                                 gint height,
+				 gboolean override)
+{
+  gulong data[4];
+  RealEntryInfo *real;
+  gboolean old_override_flag;
+  GdkDisplay *display = gdk_x11_lookup_xdisplay (GDK_DISPLAY ());
+  
+  g_return_if_fail (info != NULL);
+
+  real = REAL_ENTRY_INFO (info);
+
+  if (real->type == HD_ENTRY_INVALID)
+    return;	  
+
+  old_override_flag = real->override_icon_geometry;
+
+  real->override_icon_geometry = override;
+
+  if (!old_override_flag && !override)
+    return;
+
+  data[0] = x;
+  data[1] = y;
+  data[2] = width;
+  data[3] = height;
+
+  gdk_error_trap_push ();
+
+  XChangeProperty (GDK_DISPLAY (),
+                   hd_entry_info_get_x_window (info),
+                   gdk_x11_get_xatom_by_name_for_display (display,"_NET_WM_ICON_GEOMETRY"),
+                   XA_CARDINAL, 32, PropModeReplace,
+                   (guchar *)&data, 4);
+
+  gdk_error_trap_pop ();
+}
+
 void
 hd_entry_info_close (HDEntryInfo *info)
 {

Modified: projects/haf/trunk/hildon-desktop/libhildonwm/hd-entry-info.h
===================================================================
--- projects/haf/trunk/hildon-desktop/libhildonwm/hd-entry-info.h	2007-06-18 14:27:56 UTC (rev 12332)
+++ projects/haf/trunk/hildon-desktop/libhildonwm/hd-entry-info.h	2007-06-18 14:51:27 UTC (rev 12333)
@@ -87,6 +87,13 @@
 void         hd_entry_info_set_icon        (HDEntryInfo *info,
 				            GdkPixbuf   *icon);
 
+void         hd_entry_info_set_icon_geometry (HDEntryInfo *info,
+					      gint x,
+					      gint y,
+					      gint width,
+					      gint height,
+					      gboolean override);
+
 const gchar *hd_entry_info_get_app_icon_name (HDEntryInfo *info);
 GdkPixbuf *  hd_entry_info_get_app_icon      (HDEntryInfo *info,
                                               gint         size,

Modified: projects/haf/trunk/hildon-desktop/src/hn-app-button.c
===================================================================
--- projects/haf/trunk/hildon-desktop/src/hn-app-button.c	2007-06-18 14:27:56 UTC (rev 12332)
+++ projects/haf/trunk/hildon-desktop/src/hn-app-button.c	2007-06-18 14:51:27 UTC (rev 12333)
@@ -136,6 +136,8 @@
   guint is_blinking  : 1;
   guint is_thumbable : 1;
 
+  HDEntryInfo *last_entry;
+
   HNAppSwitcher *app_switcher;
 };
 
@@ -1000,6 +1002,8 @@
   priv->is_blinking = FALSE;
   priv->is_thumbable = FALSE;
 
+  priv->last_entry = NULL;
+
   gtk_widget_set_size_request (GTK_WIDGET (app_button), -1, BUTTON_HEIGHT);
   gtk_widget_set_sensitive (GTK_WIDGET (app_button), FALSE);
 }
@@ -1097,6 +1101,14 @@
   return button->priv->info;
 }
 
+HDEntryInfo *
+hn_app_button_get_last_entry_info (HNAppButton *button)
+{
+  g_return_val_if_fail (HN_IS_APP_BUTTON (button), NULL);
+
+  return button->priv->last_entry;
+}
+
 static GdkPixbuf *
 get_pixbuf_for_entry_info (HDEntryInfo *info)
 {
@@ -1220,65 +1232,68 @@
 {
   g_return_if_fail (HN_IS_APP_BUTTON (button));
 
+  button->priv->last_entry = button->priv->info;
   button->priv->info = NULL;
 
   HN_MARK();
 
   if (info)
-    {
-      GdkPixbuf *app_pixbuf;
+  {
+    GdkPixbuf *app_pixbuf;
       
-      app_pixbuf = get_pixbuf_for_entry_info (info);
-      if (app_pixbuf)
-	{
-          GdkPixbuf *pixbuf;
+    app_pixbuf = get_pixbuf_for_entry_info (info);
 
-	  /* compose the application icon with the number of
-	   * instances running
-	   */
-	  pixbuf = hn_app_button_compose_app_pixbuf (button, app_pixbuf, info);
-	  if (pixbuf)
-            {
-              gtk_image_set_from_pixbuf (GTK_IMAGE (button->priv->icon),
-			                 pixbuf);
-	      g_object_unref (pixbuf);
-	    }
-	  else
-            gtk_image_set_from_pixbuf (GTK_IMAGE (button->priv->icon),
-			               app_pixbuf);
+    if (app_pixbuf)
+    {
+      GdkPixbuf *pixbuf;
 
-	  g_object_unref (app_pixbuf);
-	}
+      /* compose the application icon with the number of
+       * instances running
+       */
+      pixbuf = hn_app_button_compose_app_pixbuf (button, app_pixbuf, info);
+
+      if (pixbuf)
+      {
+        gtk_image_set_from_pixbuf (GTK_IMAGE (button->priv->icon),
+ 		                   pixbuf);
+        g_object_unref (pixbuf);
+      }
       else
-	HN_DBG ("Unable to find the icon (even the default one)");
+        gtk_image_set_from_pixbuf (GTK_IMAGE (button->priv->icon),
+    		                   app_pixbuf);
 
+      g_object_unref (app_pixbuf);
+    }
+    else
+      g_debug ("Unable to find the icon (even the default one)");
+
       /* the newly composed image is static */
-      if (button->priv->is_blinking &&
-	  button->priv->app_switcher && 
-	  !hn_app_switcher_get_system_inactivity (button->priv->app_switcher))
-      {
-        hn_app_button_icon_animation (button->priv->icon, button->priv->is_blinking);
-      }
+    if (button->priv->is_blinking &&
+        button->priv->app_switcher && 
+        !hn_app_switcher_get_system_inactivity (button->priv->app_switcher))
+    {
+      hn_app_button_icon_animation (button->priv->icon, button->priv->is_blinking);
+    }
       
-      gtk_widget_show (button->priv->icon);
-      gtk_widget_set_sensitive (GTK_WIDGET (button), TRUE);
-      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
-		                    hd_entry_info_is_active (info));
+    gtk_widget_show (button->priv->icon);
+    gtk_widget_set_sensitive (GTK_WIDGET (button), TRUE);
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
+	                          hd_entry_info_is_active (info));
       
-      g_object_set (G_OBJECT (button), "can-focus", TRUE, NULL);
+    g_object_set (G_OBJECT (button), "can-focus", TRUE, NULL);
       
-      button->priv->info = info;
-    }
+    button->priv->info = info;
+  }
   else
-    {
-      gtk_widget_hide (button->priv->icon);
-      gtk_widget_set_sensitive (GTK_WIDGET (button), FALSE);
+  {
+    gtk_widget_hide (button->priv->icon);
+    gtk_widget_set_sensitive (GTK_WIDGET (button), FALSE);
 
-      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), FALSE);
-      gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (button));
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), FALSE);
+    gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (button));
 
-      g_object_set (G_OBJECT (button), "can-focus", FALSE, NULL);
-    }
+    g_object_set (G_OBJECT (button), "can-focus", FALSE, NULL);
+  }
 }
 
 void

Modified: projects/haf/trunk/hildon-desktop/src/hn-app-button.h
===================================================================
--- projects/haf/trunk/hildon-desktop/src/hn-app-button.h	2007-06-18 14:27:56 UTC (rev 12332)
+++ projects/haf/trunk/hildon-desktop/src/hn-app-button.h	2007-06-18 14:51:27 UTC (rev 12333)
@@ -81,6 +81,7 @@
 						 GdkPixbuf   *pixbuf);
 GdkPixbuf *  hn_app_button_get_pixbuf_from_icon (HNAppButton *button);
 HDEntryInfo *hn_app_button_get_entry_info       (HNAppButton *button);
+HDEntryInfo *hn_app_button_get_last_entry_info  (HNAppButton *button);
 void         hn_app_button_set_entry_info       (HNAppButton *button,
 					         HDEntryInfo *info);
 gboolean     hn_app_button_get_is_blinking      (HNAppButton *button);

Modified: projects/haf/trunk/hildon-desktop/src/hn-app-switcher.c
===================================================================
--- projects/haf/trunk/hildon-desktop/src/hn-app-switcher.c	2007-06-18 14:27:56 UTC (rev 12332)
+++ projects/haf/trunk/hildon-desktop/src/hn-app-switcher.c	2007-06-18 14:51:27 UTC (rev 12333)
@@ -562,10 +562,22 @@
   const GList          *l, *children = hd_entry_info_get_children(entry);
   gboolean              urgent = FALSE;
   HNAppButton          *app_button = HN_APP_BUTTON (priv->buttons[pos]);
+  gboolean 	       update_icon_geometry;
+ 
+  update_icon_geometry = 
+   (hn_app_button_get_last_entry_info (app_button) != entry) ? TRUE : FALSE;
   
   /* deal with urgency flags */
   for (l = children; l != NULL; l = l->next)
   {
+    if (update_icon_geometry)	    
+      hd_entry_info_set_icon_geometry (l->data,	    
+		      		       GTK_WIDGET (app_button)->allocation.x,
+				       GTK_WIDGET (app_button)->allocation.y,
+				       GTK_WIDGET (app_button)->allocation.width,
+				       GTK_WIDGET (app_button)->allocation.height,
+				       TRUE);
+	  
     /*
      * If the entry is urgent and the ignore flag is not set, the button
      * should blink
@@ -577,10 +589,10 @@
       urgent = TRUE;
     }
 
-      /*
-       * if the info is not urgent, we need to clear any leftover
-       * ignore_urgent flag
-       */
+   /*
+    * if the info is not urgent, we need to clear any leftover
+    * ignore_urgent flag
+    */
     if(!hd_entry_info_is_urgent(l->data) &&
        hd_entry_info_get_ignore_urgent(l->data))
     {
@@ -638,7 +650,7 @@
 
   /* then refresh the icons of the application buttons */
   for (l = hd_wm_get_applications (app_switcher->hdwm), pos = 0;
-       l != NULL && pos < priv->nitems;
+       l != NULL;
        l = l->next, pos++)
   {
     HDEntryInfo *entry = l->data;
@@ -650,16 +662,26 @@
       continue;
     }
 
-    if (active_button < 0 &&
-        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->buttons[pos]))&&
-        !hd_entry_info_is_active (entry))
+    if (pos < priv->nitems)
+    {	    
+      if (active_button < 0 &&
+          gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->buttons[pos]))&&
+          !hd_entry_info_is_active (entry))
+      {
+          active_button = pos;
+      }
+      
+      refresh_app_button (app_switcher, entry, pos);
+    }
+    else
     {
-        active_button = pos;
-    }
-      
-    refresh_app_button (app_switcher, entry, pos);
-
-    g_debug ("Showing object");
+      hd_entry_info_set_icon_geometry (l->data,	    
+		      		       GTK_WIDGET (app_switcher)->allocation.x,
+				       GTK_WIDGET (app_switcher)->allocation.y,
+				       GTK_WIDGET (app_switcher)->allocation.width,
+				       GTK_WIDGET (app_switcher)->allocation.height,
+				       FALSE);
+    }	    
   }
 
   if (active_button >= 0)


More information about the maemo-commits mailing list