summaryrefslogtreecommitdiff
path: root/gtk/gtkmenu.c
diff options
context:
space:
mode:
authorMichael Natterer <mitch@imendio.com>2007-04-27 14:49:37 +0000
committerMichael Natterer <mitch@src.gnome.org>2007-04-27 14:49:37 +0000
commit533d3fcc76b39fc4c71afae9c2a31e8147851b8c (patch)
treee920ae1729522ef4580cca5134faa28bd64deb5e /gtk/gtkmenu.c
parent069d78ed31fc1c0a9cb7621d27fe10d7b974315b (diff)
downloadgtk+-533d3fcc76b39fc4c71afae9c2a31e8147851b8c.tar.gz
Merged heavily modified patch from maemo-gtk which enables opening and
2007-04-27 Michael Natterer <mitch@imendio.com> Merged heavily modified patch from maemo-gtk which enables opening and closing submenus on click, and introduces some usability changes when gtk-touchscreen-mode is enabled (bug #128968): * gtk/gtkmenushell.c (struct GtkMenuShellPrivate): added boolean "activated_submenu" to indicate that the current mouse operation (click or drag) has opened a submenu. (gtk_menu_shell_button_press): pop up submenus without delay and record the fact in "activated_submenu". (gtk_menu_shell_button_release): if a submenu was explicitely opened, or not opened by this release's button_press, or enough time has passed since timeout-opening it, close the submenu here. (gtk_menu_shell_enter_notify): when entering a menu item with any mouse button pressed, open its submenu. (gtk_real_menu_shell_move_current): in touchsreen mode, close the submenu when moving the focus away from it via keyboard-navigation. * gtk/gtkmenuitem.[ch] (_gtk_menu_item_popup_submenu): added parameter "gboolean with_delay" so GtkMenuShell can control this for the different scenarios of submenu showing. (_gtk_menu_item_popdown_submenu): new function. also needed by GtkMenuShell for closing submenus on click. Renamed internal function gtk_menu_item_select_timeout() to gtk_menu_item_popup_timeout(). (gtk_menu_item_real_popup_submenu): new utility function which does the actual popup and records the exact time of the popup when the menu was timeout-opened (using g_get_current_time()). (gtk_real_menu_item_select): don't add the popup timeout when in touchscreen mode. * gtk/gtkmenu.c (gtk_menu_popup): in touchscreen mode, select the first item of every opened menu. svn path=/trunk/; revision=17659
Diffstat (limited to 'gtk/gtkmenu.c')
-rw-r--r--gtk/gtkmenu.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index 9c92b04401..71de7d7c2e 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -1429,6 +1429,19 @@ gtk_menu_popup (GtkMenu *menu,
gtk_menu_scroll_to (menu, menu->scroll_offset);
+ /* if no item is selected, select the first one */
+ if (!menu_shell->active_menu_item)
+ {
+ gboolean touchscreen_mode;
+
+ g_object_get (gtk_widget_get_settings (GTK_WIDGET (menu)),
+ "gtk-touchscreen-mode", &touchscreen_mode,
+ NULL);
+
+ if (touchscreen_mode)
+ gtk_menu_shell_select_first (menu_shell, TRUE);
+ }
+
/* Once everything is set up correctly, map the toplevel window on
the screen.
*/