[maemo-commits] [maemo-commits] r13784 - in projects/haf/trunk/hildon-desktop: . libhildondesktop

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Wed Sep 12 18:44:13 EEST 2007
Author: lucasr
Date: 2007-09-12 18:44:10 +0300 (Wed, 12 Sep 2007)
New Revision: 13784

Modified:
   projects/haf/trunk/hildon-desktop/ChangeLog
   projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-menu.c
Log:
2007-09-12  Lucas Rocha  <lucas.rocha at nokia.com>

	* libhildondesktop/hildon-desktop-popup-menu.c
	(hildon_desktop_popup_menu_item_is_selectable,
	hildon_desktop_popup_menu_motion_notify,
	hildon_desktop_popup_menu_press_event,
	hildon_desktop_popup_menu_select_item): do not allow selection on
	separators, non-sensitive, non-visible widgets, and empty menu items.
	Fixes: NB#60575.


Modified: projects/haf/trunk/hildon-desktop/ChangeLog
===================================================================
--- projects/haf/trunk/hildon-desktop/ChangeLog	2007-09-12 15:25:15 UTC (rev 13783)
+++ projects/haf/trunk/hildon-desktop/ChangeLog	2007-09-12 15:44:10 UTC (rev 13784)
@@ -1,3 +1,13 @@
+2007-09-12  Lucas Rocha  <lucas.rocha at nokia.com>
+
+	* libhildondesktop/hildon-desktop-popup-menu.c
+	(hildon_desktop_popup_menu_item_is_selectable,
+	hildon_desktop_popup_menu_motion_notify,
+	hildon_desktop_popup_menu_press_event,
+	hildon_desktop_popup_menu_select_item): do not allow selection on
+	separators, non-sensitive, non-visible widgets, and empty menu items.
+	Fixes: NB#60575.
+
 2007-09-12  Moises Martinez  <moises.martinez at nokia.com>
 
 	* libhildonwm/hd-keys.c: (hd_keys_shortcut_new):

Modified: projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-menu.c
===================================================================
--- projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-menu.c	2007-09-12 15:25:15 UTC (rev 13783)
+++ projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-menu.c	2007-09-12 15:44:10 UTC (rev 13784)
@@ -248,6 +248,19 @@
   return TRUE;
 }
 
+static gboolean
+hildon_desktop_popup_menu_item_is_selectable (GtkWidget *menu_item)
+{
+  if ((!GTK_BIN (menu_item)->child &&
+      GTK_IS_MENU_ITEM (menu_item)) ||
+      GTK_IS_SEPARATOR_MENU_ITEM (menu_item) ||
+      !GTK_WIDGET_IS_SENSITIVE (menu_item) ||
+      !GTK_WIDGET_VISIBLE (menu_item))
+    return FALSE;
+
+  return TRUE;
+}
+	
 static GObject *
 hildon_desktop_popup_menu_constructor (GType gtype,
                                        guint n_params,
@@ -541,7 +554,8 @@
 
     if ((x >= 0) && (x <= w) && (y >= 0) && (y <= h))
     {
-      if (menu->priv->selected_item != GTK_MENU_ITEM (l->data))
+      if (hildon_desktop_popup_menu_item_is_selectable (GTK_WIDGET (l->data)) &&
+          menu->priv->selected_item != GTK_MENU_ITEM (l->data))
       {
         gtk_item_deselect (GTK_ITEM (menu->priv->selected_item));
         gtk_item_select (GTK_ITEM (l->data));
@@ -699,7 +713,8 @@
     {
       if (GTK_IS_MENU_ITEM (l->data))
       {
-        if (menu->priv->selected_item != GTK_MENU_ITEM (l->data))
+        if (hildon_desktop_popup_menu_item_is_selectable (GTK_WIDGET (l->data)) &&
+            menu->priv->selected_item != GTK_MENU_ITEM (l->data))
         {
           gtk_item_deselect (GTK_ITEM (menu->priv->selected_item));
           gtk_item_select (GTK_ITEM (l->data));
@@ -1016,12 +1031,15 @@
   g_return_if_fail (HILDON_DESKTOP_IS_POPUP_MENU (menu));
   g_return_if_fail (GTK_IS_MENU_ITEM (item));
 
-  if (GTK_IS_ITEM (menu->priv->selected_item))
-    gtk_item_deselect (GTK_ITEM (menu->priv->selected_item));	    
+  if (hildon_desktop_popup_menu_item_is_selectable (GTK_WIDGET (item)))
+  {
+    if (GTK_IS_ITEM (menu->priv->selected_item))
+      gtk_item_deselect (GTK_ITEM (menu->priv->selected_item));	    
 
-  gtk_item_select (GTK_ITEM (item));
-  menu->priv->selected_item = item;
-  hildon_desktop_menu_check_scroll_item (menu);
+    gtk_item_select (GTK_ITEM (item));
+    menu->priv->selected_item = item;
+    hildon_desktop_menu_check_scroll_item (menu);
+  }
 } 
 
 void 
@@ -1047,7 +1065,7 @@
 
   for (l = children; l != NULL; l = g_list_next (l))
   {	  
-    if (!GTK_IS_SEPARATOR_MENU_ITEM (l->data))
+    if (hildon_desktop_popup_menu_item_is_selectable (GTK_WIDGET (l->data)))
     {
       if (GTK_IS_ITEM (menu->priv->selected_item))
         gtk_item_deselect (GTK_ITEM (menu->priv->selected_item));
@@ -1072,7 +1090,7 @@
 
   for (l = g_list_last (children); l != NULL; l = g_list_previous (l))
   {
-    if (!GTK_IS_SEPARATOR_MENU_ITEM (l->data))
+    if (hildon_desktop_popup_menu_item_is_selectable (GTK_WIDGET (l->data)))
     {
       if (GTK_IS_ITEM (menu->priv->selected_item))
         gtk_item_deselect (GTK_ITEM (menu->priv->selected_item));


More information about the maemo-commits mailing list