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

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Mon May 28 16:47:37 EEST 2007
Author: moimart
Date: 2007-05-28 16:47:36 +0300 (Mon, 28 May 2007)
New Revision: 11905

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

        * src/hd-switcher-menu.c: Attach to toggle button.
        * libhildondesktop/hildon-desktop-popup-window.[ch]:
        - Added method for attaching widget.
        - Send fake key when popping-down the menu and the pointer is not on
        the attached widget.
	* ChangeLog updated.




Modified: projects/haf/trunk/hildon-desktop/ChangeLog
===================================================================
--- projects/haf/trunk/hildon-desktop/ChangeLog	2007-05-28 13:30:35 UTC (rev 11904)
+++ projects/haf/trunk/hildon-desktop/ChangeLog	2007-05-28 13:47:36 UTC (rev 11905)
@@ -1,3 +1,11 @@
+2007-05-28  Moises Martinez  <moises.martinez at nokia.com>
+
+	* src/hd-switcher-menu.c: Attach to toggle button.
+	* libhildondesktop/hildon-desktop-popup-window.[ch]:
+	- Added method for attaching widget.
+	- Send fake key when popping-down the menu and the pointer is not on
+	the attached widget.
+
 2007-05-28  Johan Bilien  <johan.bilien at nokia.com>
 
 	* src/hd-home-window.c:

Modified: projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-window.c
===================================================================
--- projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-window.c	2007-05-28 13:30:35 UTC (rev 11904)
+++ projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-window.c	2007-05-28 13:47:36 UTC (rev 11905)
@@ -91,17 +91,12 @@
 						     		     GdkEventCrossing *event,
 						     		     HildonDesktopPopupWindow *popup);
 
-static gboolean hildon_desktop_popup_window_composited_button_press (GtkWidget *widget,
-		                                                     GdkEventButton *event,
-	                                                             HildonDesktopPopupWindow *popup);
-
 static gboolean hildon_desktop_popup_window_composited_button_release (GtkWidget *widget,
 		                                                       GdkEventButton *event,
 	                                                               HildonDesktopPopupWindow *popup);
 
 static gboolean popup_grab_on_window (GdkWindow *window, guint32 activate_time, gboolean grab_keyboard);
 
-static gboolean hildon_desktop_popup_window_button_press_event (GtkWidget *widget, GdkEventButton *event);
 static gboolean hildon_desktop_popup_window_button_release_event (GtkWidget *widget, GdkEventButton *event);
 #ifdef HAVE_XTEST
 static void hildon_desktop_popup_menu_fake_button_event (GdkEventButton *event, gboolean press);
@@ -171,7 +166,6 @@
 
   widget_class->motion_notify_event     = hildon_desktop_popup_window_motion_notify;
   widget_class->leave_notify_event      = hildon_desktop_popup_window_leave_notify;
-  widget_class->button_press_event      = hildon_desktop_popup_window_button_press_event;
   widget_class->button_release_event    = hildon_desktop_popup_window_button_release_event;
   widget_class->key_press_event 	= hildon_desktop_popup_window_key_press_event;
 	  
@@ -275,11 +269,6 @@
 		    	      GDK_WINDOW_TYPE_HINT_MENU);
 
     g_signal_connect (popup->priv->extra_panes[i],
-		      "button-press-event",
-		      G_CALLBACK (hildon_desktop_popup_window_composited_button_press),
-		      (gpointer)popup);
-    
-    g_signal_connect (popup->priv->extra_panes[i],
 		      "button-release-event",
 		      G_CALLBACK (hildon_desktop_popup_window_composited_button_release),
 		      (gpointer)popup); 
@@ -603,20 +592,6 @@
 }
 
 static gboolean
-hildon_desktop_popup_window_composited_button_press (GtkWidget *widget,
-                                                     GdkEventButton *event,
-                                                     HildonDesktopPopupWindow *popup)
-{
-  if (!event)
-    return FALSE;
-#ifdef HAVE_XTEST
-  hildon_desktop_popup_menu_fake_button_event (event, TRUE);
-#endif
-
-  return TRUE;
-}
-
-static gboolean
 hildon_desktop_popup_window_composited_button_release (GtkWidget *widget,
                                                        GdkEventButton *event,
                                                        HildonDesktopPopupWindow *popup)
@@ -665,29 +640,29 @@
 
   /* Event outside of popup or in button area, close in clean way */
   if (!in_panes_area || in_window_area)
+  {	  
     hildon_desktop_popup_window_popdown (popup);
-
 #ifdef HAVE_XTEST
-  hildon_desktop_popup_menu_fake_button_event (event, FALSE);
+    if (popup->priv->attached_widget)
+    {	    
+      gtk_widget_get_pointer (popup->priv->attached_widget, &x, &y);
+
+      w = popup->priv->attached_widget->allocation.width;
+      h = popup->priv->attached_widget->allocation.height;
+      
+      if ((x < 0) || (x > w) || (y < 0) || (y > h))
+      {	      
+        hildon_desktop_popup_menu_fake_button_event (event, TRUE);	      
+        hildon_desktop_popup_menu_fake_button_event (event, FALSE);
+      }
+    }
 #endif
+  }
+  
   return TRUE;
 }
 
 static gboolean
-hildon_desktop_popup_window_button_press_event (GtkWidget *widget,
-                                                GdkEventButton *event)
-{
-  if (!event)
-    return FALSE;
-
-#ifdef HAVE_XTEST
-  hildon_desktop_popup_menu_fake_button_event (event, TRUE);
-#endif  
-
-  return TRUE;
-}
-
-static gboolean
 hildon_desktop_popup_window_button_release_event (GtkWidget *widget,
                                                   GdkEventButton *event)
 {
@@ -724,11 +699,24 @@
 
   /* Event outside of popup or in button area, close in clean way */
   if (!in_panes_area || in_window_area)
+  {	  
     hildon_desktop_popup_window_popdown (popup);
-
 #ifdef HAVE_XTEST
-  hildon_desktop_popup_menu_fake_button_event (event, FALSE);
+    if (popup->priv->attached_widget)
+    {	    
+      gtk_widget_get_pointer (popup->priv->attached_widget, &x, &y);
+
+      w = popup->priv->attached_widget->allocation.width;
+      h = popup->priv->attached_widget->allocation.height;
+      
+      if ((x < 0) || (x > w) || (y < 0) || (y > h))
+      {	      
+        hildon_desktop_popup_menu_fake_button_event (event, TRUE);	      
+        hildon_desktop_popup_menu_fake_button_event (event, FALSE);
+      }
+    }
 #endif
+  }
   return TRUE;
 }
 
@@ -1009,6 +997,14 @@
 }	
 
 void 
+hildon_desktop_popup_window_attach_widget (HildonDesktopPopupWindow *popup, GtkWidget *widget)
+{
+  g_return_if_fail (widget && GTK_IS_WIDGET (widget));
+
+  popup->priv->attached_widget = widget;
+}	
+
+void 
 hildon_desktop_popup_window_popup (HildonDesktopPopupWindow *popup,
 				   HDPopupWindowPositionFunc func,
 				   gpointer		     func_data,

Modified: projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-window.h
===================================================================
--- projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-window.h	2007-05-28 13:30:35 UTC (rev 11904)
+++ projects/haf/trunk/hildon-desktop/libhildondesktop/hildon-desktop-popup-window.h	2007-05-28 13:47:36 UTC (rev 11905)
@@ -87,6 +87,9 @@
 hildon_desktop_popup_window_jump_to_pane (HildonDesktopPopupWindow *popup, gint pane);
 
 void 
+hildon_desktop_popup_window_attach_widget (HildonDesktopPopupWindow *popup, GtkWidget *widget);
+
+void 
 hildon_desktop_popup_window_popup (HildonDesktopPopupWindow *popup,
 				   HDPopupWindowPositionFunc func,
 				   gpointer                  func_data,

Modified: projects/haf/trunk/hildon-desktop/src/hd-switcher-menu.c
===================================================================
--- projects/haf/trunk/hildon-desktop/src/hd-switcher-menu.c	2007-05-28 13:30:35 UTC (rev 11904)
+++ projects/haf/trunk/hildon-desktop/src/hd-switcher-menu.c	2007-05-28 13:47:36 UTC (rev 11905)
@@ -430,6 +430,9 @@
   switcher->priv->popup_window =
     HILDON_DESKTOP_POPUP_WINDOW 
       (hildon_desktop_popup_window_new (1,GTK_ORIENTATION_HORIZONTAL,HD_POPUP_WINDOW_DIRECTION_RIGHT_BOTTOM));	     
+
+  hildon_desktop_popup_window_attach_widget
+    (switcher->priv->popup_window, button);	  
   
   switcher->priv->notifications_window = 
     hildon_desktop_popup_window_get_pane (switcher->priv->popup_window, 0);


More information about the maemo-commits mailing list