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

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Fri May 25 17:06:52 EEST 2007
Author: moimart
Date: 2007-05-25 17:06:51 +0300 (Fri, 25 May 2007)
New Revision: 11860

Modified:
   projects/haf/trunk/hildon-desktop/ChangeLog
   projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-menu.c
   projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-menu.h
   projects/haf/trunk/hildon-desktop/src/hd-switcher-menu.c
Log:
2007-05-25  Moises Martinez  <moises.martinez at nokia.com>

        * src/hd-switcher-menu.c:
        - Highlight next application when menu is opened and home key is
        pressed. Fixes: NB#57666
        - Select highlighted application when menu opened and long home key
        press.
        * libhildondesktop/hildon-desktop-popup-menu.[ch]:
        - Added methods to select previous/next item.
        - _get_selected_item is not const any longer.
        - Fixed misbehaviors when scrolling and the controls are off.
	* ChangeLog updated.




Modified: projects/haf/trunk/hildon-desktop/ChangeLog
===================================================================
--- projects/haf/trunk/hildon-desktop/ChangeLog	2007-05-25 14:01:58 UTC (rev 11859)
+++ projects/haf/trunk/hildon-desktop/ChangeLog	2007-05-25 14:06:51 UTC (rev 11860)
@@ -1,3 +1,15 @@
+2007-05-25  Moises Martinez  <moises.martinez at nokia.com>
+
+	* src/hd-switcher-menu.c:
+	- Highlight next application when menu is opened and home key is
+	pressed. Fixes: NB#57666
+	- Select highlighted application when menu opened and long home key
+	press.
+	* libhildondesktop/hildon-desktop-popup-menu.[ch]:
+	- Added methods to select previous/next item.
+	- _get_selected_item is not const any longer.
+	- Fixed misbehaviors when scrolling and the controls are off.
+
 2007-05-25  Johan Bilien  <johan.bilien at nokia.com>
 
 	* src/hd-panel-window.c:

Modified: projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-menu.c
===================================================================
--- projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-menu.c	2007-05-25 14:01:58 UTC (rev 11859)
+++ projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-menu.c	2007-05-25 14:06:51 UTC (rev 11860)
@@ -130,10 +130,10 @@
   widget_class->motion_notify_event  = hildon_desktop_popup_menu_motion_notify;
   widget_class->button_release_event = hildon_desktop_popup_menu_release_event;
   widget_class->key_press_event      = hildon_desktop_popup_menu_key_press_event;
-
+  
   widget_class->size_request = hildon_desktop_popup_menu_size_request;
   widget_class->size_allocate = hildon_desktop_popup_menu_size_allocate;
-  
+
   g_type_class_add_private (object_class, sizeof (HildonDesktopPopupMenuPrivate));
 
   signals[SIGNAL_POPUP_RESIZE] =
@@ -556,7 +556,8 @@
         gtk_item_select   (GTK_ITEM (item->data));
 	menu->priv->selected_item = GTK_MENU_ITEM (item->data);
 
-	hildon_desktop_menu_check_scroll_item (menu, GTK_SCROLL_STEP_UP);
+	if (menu->priv->controls_on)
+  	  hildon_desktop_menu_check_scroll_item (menu, GTK_SCROLL_STEP_UP);
 	
 	break;
       }
@@ -579,7 +580,8 @@
         gtk_item_select   (GTK_ITEM (item->data));
 	menu->priv->selected_item = GTK_MENU_ITEM (item->data);
 
-	hildon_desktop_menu_check_scroll_item (menu, GTK_SCROLL_STEP_DOWN);
+	if (menu->priv->controls_on)
+	  hildon_desktop_menu_check_scroll_item (menu, GTK_SCROLL_STEP_DOWN);
 	
 	break;
       }
@@ -684,9 +686,9 @@
       g_signal_emit_by_name (menu, "popup-menu-resize");
 	    
       gtk_widget_queue_resize (GTK_WIDGET (menu));    
-      gtk_widget_queue_resize (parent); 
+      gtk_widget_queue_resize (parent);
     }
-
+    
     if (GTK_WIDGET_REALIZED (parent))
       gdk_window_resize (parent->window,
 		         req.width,
@@ -698,6 +700,47 @@
   g_list_free (children);
 }	
 
+static void 
+hildon_desktop_popup_menu_select_next_prev_item (HildonDesktopPopupMenu *menu, gboolean next)
+{
+  GList *children, *item, *l;
+  GtkMenuItem *previous_selected_item;
+  
+  if (!menu->priv->selected_item)
+    return;	  
+
+  previous_selected_item = menu->priv->selected_item;
+
+  children = gtk_container_get_children (GTK_CONTAINER (menu->priv->box_items));
+
+  if (children)
+  {
+    l = item = g_list_find (children, menu->priv->selected_item);
+
+    while (l)
+    {
+      if (l != item)
+      {
+        if (l->data && !GTK_IS_SEPARATOR_MENU_ITEM (l->data) && GTK_IS_MENU_ITEM (l->data))
+        {
+          hildon_desktop_popup_menu_select_item (menu, GTK_MENU_ITEM (l->data));
+	  break;
+        }		
+      }	      
+
+      if (next)
+        l = l->next;
+      else
+	l = l->prev;      
+    }	    
+
+    if (previous_selected_item == menu->priv->selected_item) /* TODO: This only cover one case. */
+      hildon_desktop_popup_menu_select_first_item (menu);    /* It doesn't take into account the direction */
+	    
+    g_list_free (children);
+  }	  
+}
+
 void
 hildon_desktop_popup_menu_add_item (HildonDesktopPopupMenu *menu, GtkMenuItem *item)
 {
@@ -832,12 +875,26 @@
   g_list_free (children);				  
 }	
 
-const GtkMenuItem *
+	
+
+GtkMenuItem *
 hildon_desktop_popup_menu_get_selected_item (HildonDesktopPopupMenu *menu)
 {
   return menu->priv->selected_item;
 }
 
+void 
+hildon_desktop_popup_menu_select_next_item (HildonDesktopPopupMenu *menu)
+{
+  hildon_desktop_popup_menu_select_next_prev_item (menu, TRUE);
+}	
+
+void 
+hildon_desktop_popup_menu_select_prev_item (HildonDesktopPopupMenu *menu)
+{
+  hildon_desktop_popup_menu_select_next_prev_item (menu, FALSE); 
+}	
+
 void   
 hildon_desktop_popup_menu_scroll_to_selected (HildonDesktopPopupMenu *menu)
 {
@@ -846,6 +903,9 @@
  
   if (!HILDON_DESKTOP_IS_POPUP_MENU (menu))
     return;
+
+  if (!menu->priv->controls_on)
+    return;	  
  
   if (menu->priv->selected_item)
   {    	  

Modified: projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-menu.h
===================================================================
--- projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-menu.h	2007-05-25 14:01:58 UTC (rev 11859)
+++ projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-menu.h	2007-05-25 14:06:51 UTC (rev 11860)
@@ -78,9 +78,15 @@
 void
 hildon_desktop_popup_menu_activate_item (HildonDesktopPopupMenu *menu, GtkMenuItem *item);
 
-const GtkMenuItem *
+GtkMenuItem *
 hildon_desktop_popup_menu_get_selected_item (HildonDesktopPopupMenu *menu);
 
+void 
+hildon_desktop_popup_menu_select_next_item (HildonDesktopPopupMenu *menu);
+
+void 
+hildon_desktop_popup_menu_select_prev_item (HildonDesktopPopupMenu *menu);
+
 void   
 hildon_desktop_popup_menu_scroll_to_selected (HildonDesktopPopupMenu *menu);
 

Modified: projects/haf/trunk/hildon-desktop/src/hd-switcher-menu.c
===================================================================
--- projects/haf/trunk/hildon-desktop/src/hd-switcher-menu.c	2007-05-25 14:01:58 UTC (rev 11859)
+++ projects/haf/trunk/hildon-desktop/src/hd-switcher-menu.c	2007-05-25 14:06:51 UTC (rev 11860)
@@ -281,6 +281,8 @@
   {
     hildon_desktop_popup_window_popdown (window);
 
+    switcher->priv->is_open = FALSE;
+
     if (event->keyval == GDK_Escape)
     {
       /* pass focus to the last active application */
@@ -741,6 +743,8 @@
     hildon_desktop_popup_window_popdown
       (switcher->priv->popup_window);
 
+  switcher->priv->is_open = FALSE;
+  
   gtk_toggle_button_set_active
     (GTK_TOGGLE_BUTTON (switcher->priv->toggle_button), FALSE);
 }	
@@ -830,9 +834,13 @@
      gtk_widget_set_sensitive (switcher->priv->toggle_button, FALSE);
      
      if (switcher->priv->is_open)
+     {	     
        hildon_desktop_popup_window_popdown 
          (switcher->priv->popup_window);	       
-
+ 
+       switcher->priv->is_open = FALSE;
+     }
+     
      gtk_toggle_button_set_active 
        (GTK_TOGGLE_BUTTON (switcher->priv->toggle_button), FALSE);
   }
@@ -1000,9 +1008,16 @@
   if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (switcher->priv->toggle_button)))
   {
     hildon_desktop_popup_window_popdown (switcher->priv->popup_window);
+    switcher->priv->is_open = FALSE;
     return;
-  }    
-	
+  }   
+
+  if (switcher->priv->is_open)
+  {	  
+    hildon_desktop_popup_menu_select_next_item (switcher->priv->menu_applications);
+    g_debug ("selecting next item");
+  }
+    
   hildon_desktop_popup_window_popup 
    (switcher->priv->popup_window,
     hd_switcher_menu_position_func,
@@ -1455,7 +1470,8 @@
   {
     hildon_desktop_popup_menu_activate_item 
       (switcher->priv->menu_applications, 
-       GTK_MENU_ITEM (switcher->priv->active_menu_item));
+       hildon_desktop_popup_menu_get_selected_item 
+         (switcher->priv->menu_applications));
   }
   else
     hd_wm_top_desktop ();


More information about the maemo-commits mailing list