[maemo-commits] [maemo-commits] r15349 - in projects/haf/trunk/gtk+: . gtk

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Fri Apr 4 13:31:48 EEST 2008
Author: mitch
Date: 2008-04-04 13:31:45 +0300 (Fri, 04 Apr 2008)
New Revision: 15349

Modified:
   projects/haf/trunk/gtk+/ChangeLog
   projects/haf/trunk/gtk+/gtk/gtkmenu.c
   projects/haf/trunk/gtk+/gtk/gtkmenu.h
   projects/haf/trunk/gtk+/gtk/gtkwidget.c
Log:
2008-04-04  Michael Natterer  <mitch at imendio.com>

	Change how GtkMenu's "context_menu" flag gets set.

	Should fix NB#80760 (context sensitive menu disappears after
	stylus releasing):

	* gtk/gtkmenu.[ch]: replace _gtk_menu_enable_context_menu_behavior()
	by _gtk_menu_push/pop_context_menu_behavior() which increase/decrease
	an internal counter.

	(gtk_menu_popup): set the "context_menu" flag to TRUE if the
	counter is > 0 and this is not a submenu.

	(gtk_menu_popdown): set the flag to FALSE again.

	* gtk/gtkwidget.c (gtk_widget_real_tap_and_hold_setup): don't
	call the removed _gtk_menu_enable_context_menu_behavior().

	(gtk_widget_tap_and_hold_timeout): call the new push/pop API
	around emitting the tap-and-hold signal, so all menus popped up by
	that signal behave as context menus, not only the ones correctly
	registered with tap_and_hold_setup().



Modified: projects/haf/trunk/gtk+/ChangeLog
===================================================================
--- projects/haf/trunk/gtk+/ChangeLog	2008-04-04 10:24:00 UTC (rev 15348)
+++ projects/haf/trunk/gtk+/ChangeLog	2008-04-04 10:31:45 UTC (rev 15349)
@@ -1,3 +1,27 @@
+2008-04-04  Michael Natterer  <mitch at imendio.com>
+
+	Change how GtkMenu's "context_menu" flag gets set.
+
+	Should fix NB#80760 (context sensitive menu disappears after
+	stylus releasing):
+
+	* gtk/gtkmenu.[ch]: replace _gtk_menu_enable_context_menu_behavior()
+	by _gtk_menu_push/pop_context_menu_behavior() which increase/decrease
+	an internal counter.
+
+	(gtk_menu_popup): set the "context_menu" flag to TRUE if the
+	counter is > 0 and this is not a submenu.
+
+	(gtk_menu_popdown): set the flag to FALSE again.
+
+	* gtk/gtkwidget.c (gtk_widget_real_tap_and_hold_setup): don't
+	call the removed _gtk_menu_enable_context_menu_behavior().
+
+	(gtk_widget_tap_and_hold_timeout): call the new push/pop API
+	around emitting the tap-and-hold signal, so all menus popped up by
+	that signal behave as context menus, not only the ones correctly
+	registered with tap_and_hold_setup().
+
 2008-03-31  Kristian Rietveld  <kris at imendio.com>
 
 	Introduce a changed signal for GtkCellRendererCombo to be

Modified: projects/haf/trunk/gtk+/gtk/gtkmenu.c
===================================================================
--- projects/haf/trunk/gtk+/gtk/gtkmenu.c	2008-04-04 10:24:00 UTC (rev 15348)
+++ projects/haf/trunk/gtk+/gtk/gtkmenu.c	2008-04-04 10:31:45 UTC (rev 15349)
@@ -266,6 +266,10 @@
 
 static guint menu_signals[LAST_SIGNAL] = { 0 };
 
+#ifdef MAEMO_CHANGES
+static gint context_menu_counter = 0;
+#endif
+
 static GtkMenuPrivate *
 gtk_menu_get_private (GtkMenu *menu)
 {
@@ -1570,6 +1574,8 @@
 
 #ifdef MAEMO_CHANGES
   /* Hildon: save position of the pointer during popup. Not multihead safe. */
+  priv->context_menu = (context_menu_counter > 0) && !parent_menu_item;
+
   if (priv->context_menu)
     gdk_display_get_pointer (gtk_widget_get_display (widget), NULL,
                              &priv->popup_pointer_x,
@@ -1617,6 +1623,10 @@
 
   private->have_position = FALSE;
 
+#ifdef MAEMO_CHANGES
+  private->context_menu = FALSE;
+#endif
+
   gtk_menu_stop_scrolling (menu);
   
   gtk_menu_stop_navigating_submenu (menu);
@@ -5414,13 +5424,19 @@
 }
 
 #ifdef MAEMO_CHANGES
-/* Hildon function to make context menus behave according to spec */
+/* Hildon functions to make context menus behave according to spec */
 void
-_gtk_menu_enable_context_menu_behavior (GtkMenu *menu)
+_gtk_menu_push_context_menu_behavior (void)
 {
-  GtkMenuPrivate *priv = gtk_menu_get_private (menu);
+  context_menu_counter++;
+}
 
-  priv->context_menu = TRUE;
+void
+_gtk_menu_pop_context_menu_behavior (void)
+{
+  g_return_if_fail (context_menu_counter > 0);
+
+  context_menu_counter--;
 }
 #endif /* MAEMO_CHANGES */
 

Modified: projects/haf/trunk/gtk+/gtk/gtkmenu.h
===================================================================
--- projects/haf/trunk/gtk+/gtk/gtkmenu.h	2008-04-04 10:24:00 UTC (rev 15348)
+++ projects/haf/trunk/gtk+/gtk/gtkmenu.h	2008-04-04 10:31:45 UTC (rev 15349)
@@ -199,7 +199,8 @@
 GList*     gtk_menu_get_for_attach_widget (GtkWidget           *widget); 
 
 #ifdef MAEMO_CHANGES
-void       _gtk_menu_enable_context_menu_behavior (GtkMenu *menu);
+void       _gtk_menu_push_context_menu_behavior (void);
+void       _gtk_menu_pop_context_menu_behavior  (void);
 #endif /* MAEMO_CHANGES */
 
 #ifndef GTK_DISABLE_DEPRECATED

Modified: projects/haf/trunk/gtk+/gtk/gtkwidget.c
===================================================================
--- projects/haf/trunk/gtk+/gtk/gtkwidget.c	2008-04-04 10:24:00 UTC (rev 15348)
+++ projects/haf/trunk/gtk+/gtk/gtkwidget.c	2008-04-04 10:31:45 UTC (rev 15349)
@@ -9019,7 +9019,6 @@
     {
       g_object_ref (menu);
       gtk_object_sink (GTK_OBJECT (menu));
-      _gtk_menu_enable_context_menu_behavior (GTK_MENU (menu));
 
       if (gtk_menu_get_attach_widget (GTK_MENU (menu)) == NULL)
 	gtk_menu_attach_to_widget (GTK_MENU (menu), widget, NULL);
@@ -9100,8 +9099,13 @@
     {
       tap_and_hold_remove_timer (widget);
       _gtk_widget_grab_notify (widget, FALSE);
+
+      _gtk_menu_push_context_menu_behavior ();
+
       g_signal_emit (widget, widget_signals[TAP_AND_HOLD], 0);
 
+      _gtk_menu_pop_context_menu_behavior ();
+
       GDK_THREADS_LEAVE ();
       return FALSE;
     }


More information about the maemo-commits mailing list