summaryrefslogtreecommitdiff
path: root/gtk/gtkmenushell.c
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2002-02-03 01:25:32 +0000
committerOwen Taylor <otaylor@src.gnome.org>2002-02-03 01:25:32 +0000
commitae7521bd9daa8b389a878dc7e9b2b0a5753b6b7f (patch)
treee774eada70ef95da9ad062848f0fc158f4021c51 /gtk/gtkmenushell.c
parent0ed21b67d92d659f33ccedc96549527af5bf7386 (diff)
downloadgtk+-ae7521bd9daa8b389a878dc7e9b2b0a5753b6b7f.tar.gz
Non-exported _gtk_menu_select_first() function that selects the first item
Sat Feb 2 20:16:04 2002 Owen Taylor <otaylor@redhat.com> * gtk/gtkmenushell.c (_gtk_menu_shell_select_first): Non-exported _gtk_menu_select_first() function that selects the first item of the menu in a standard way. (Skipping tearoffs.) * gtk/gtkmenushell.c gtk/gtkentry.c gtk/gtktextview.c gtkmenuitem.c: Use _gtk_menu_shell_select_first(). * gtk/gtkmenuitem.c (gtk_real_menu_item_select): Remember if we are starting the timeout from a keypress so we can set menushell->ignore_enter properly. * gtk/gtknotebook.c (focus_child_in): Return something meaningful if there are no children. * gtk/gtkmenu.c (gtk_menu_key_press): Fix precendence problem.
Diffstat (limited to 'gtk/gtkmenushell.c')
-rw-r--r--gtk/gtkmenushell.c43
1 files changed, 35 insertions, 8 deletions
diff --git a/gtk/gtkmenushell.c b/gtk/gtkmenushell.c
index a09c222613..46355216ad 100644
--- a/gtk/gtkmenushell.c
+++ b/gtk/gtkmenushell.c
@@ -33,6 +33,7 @@
#include "gtkmenuitem.h"
#include "gtkmenushell.h"
#include "gtksignal.h"
+#include "gtktearoffmenuitem.h"
#include "gtkwindow.h"
#define MENU_SHELL_TIMEOUT 500
@@ -926,6 +927,38 @@ gtk_menu_shell_move_selected (GtkMenuShell *menu_shell,
}
}
+/**
+ * _gtk_menu_shell_select_first:
+ * @menu_shell: a #GtkMenuShell
+ *
+ * Select the first visible child of the menu shell, unless
+ * it's a tearoff item.
+ **/
+void
+_gtk_menu_shell_select_first (GtkMenuShell *menu_shell)
+{
+ GtkWidget *to_select = NULL;
+ GList *tmp_list;
+
+ tmp_list = menu_shell->children;
+ while (tmp_list)
+ {
+ GtkWidget *child = tmp_list->data;
+
+ if (GTK_WIDGET_VISIBLE (child))
+ {
+ to_select = child;
+ if (!GTK_IS_TEAROFF_MENU_ITEM (child))
+ break;
+ }
+
+ tmp_list = tmp_list->next;
+ }
+
+ if (to_select)
+ gtk_menu_shell_select_item (menu_shell, to_select);
+}
+
static void
gtk_menu_shell_select_submenu_first (GtkMenuShell *menu_shell)
{
@@ -934,11 +967,7 @@ gtk_menu_shell_select_submenu_first (GtkMenuShell *menu_shell)
menu_item = GTK_MENU_ITEM (menu_shell->active_menu_item);
if (menu_item->submenu)
- {
- GtkMenuShell *submenu = GTK_MENU_SHELL (menu_item->submenu);
- if (submenu->children)
- gtk_menu_shell_select_item (submenu, submenu->children->data);
- }
+ _gtk_menu_shell_select_first (GTK_MENU_SHELL (menu_item->submenu));
}
static void
@@ -974,9 +1003,7 @@ gtk_real_menu_shell_move_current (GtkMenuShell *menu_shell,
_gtk_menu_item_is_selectable (menu_shell->active_menu_item) &&
GTK_MENU_ITEM (menu_shell->active_menu_item)->submenu)
{
- menu_shell = GTK_MENU_SHELL (GTK_MENU_ITEM (menu_shell->active_menu_item)->submenu);
- if (menu_shell->children)
- gtk_menu_shell_select_item (menu_shell, menu_shell->children->data);
+ gtk_menu_shell_select_submenu_first (menu_shell);
}
else
{