Commit 367cacdf authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

Add an extra parameter to _gtk_menu_item_select_first() to allow us to

Fri Jul  5 20:18:23 2002  Owen Taylor  <otaylor@redhat.com>

        * gtk/gtkmenushell.[ch] gtk/gtkmenubar.c gtk/gtkmenuitem.c
        gtk/gtkentry.c gtk/gtktextview.c: Add an extra parameter
        to _gtk_menu_item_select_first() to allow us to choose
        whether we want to select the first item predictably
        or to select the first sensitive item. Fixes problem
        with insensitive menu items and keynav. (#85796,
        reported by Bill Haneman and others.)
parent e05a9660
Fri Jul 5 20:18:23 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkmenushell.[ch] gtk/gtkmenubar.c gtk/gtkmenuitem.c
gtk/gtkentry.c gtk/gtktextview.c: Add an extra parameter
to _gtk_menu_item_select_first() to allow us to choose
whether we want to select the first item predictably
or to select the first sensitive item. Fixes problem
with insensitive menu items and keynav. (#85796,
reported by Bill Haneman and others.)
Fri Jul 5 02:50:24 2002 Jonathan Blandford <jrb@gnome.org>
* gtk/gtktreeview.c (gtk_tree_view_collapse_all): fix warning.
......
Fri Jul 5 20:18:23 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkmenushell.[ch] gtk/gtkmenubar.c gtk/gtkmenuitem.c
gtk/gtkentry.c gtk/gtktextview.c: Add an extra parameter
to _gtk_menu_item_select_first() to allow us to choose
whether we want to select the first item predictably
or to select the first sensitive item. Fixes problem
with insensitive menu items and keynav. (#85796,
reported by Bill Haneman and others.)
Fri Jul 5 02:50:24 2002 Jonathan Blandford <jrb@gnome.org>
* gtk/gtktreeview.c (gtk_tree_view_collapse_all): fix warning.
......
Fri Jul 5 20:18:23 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkmenushell.[ch] gtk/gtkmenubar.c gtk/gtkmenuitem.c
gtk/gtkentry.c gtk/gtktextview.c: Add an extra parameter
to _gtk_menu_item_select_first() to allow us to choose
whether we want to select the first item predictably
or to select the first sensitive item. Fixes problem
with insensitive menu items and keynav. (#85796,
reported by Bill Haneman and others.)
Fri Jul 5 02:50:24 2002 Jonathan Blandford <jrb@gnome.org>
* gtk/gtktreeview.c (gtk_tree_view_collapse_all): fix warning.
......
Fri Jul 5 20:18:23 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkmenushell.[ch] gtk/gtkmenubar.c gtk/gtkmenuitem.c
gtk/gtkentry.c gtk/gtktextview.c: Add an extra parameter
to _gtk_menu_item_select_first() to allow us to choose
whether we want to select the first item predictably
or to select the first sensitive item. Fixes problem
with insensitive menu items and keynav. (#85796,
reported by Bill Haneman and others.)
Fri Jul 5 02:50:24 2002 Jonathan Blandford <jrb@gnome.org>
* gtk/gtktreeview.c (gtk_tree_view_collapse_all): fix warning.
......
Fri Jul 5 20:18:23 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkmenushell.[ch] gtk/gtkmenubar.c gtk/gtkmenuitem.c
gtk/gtkentry.c gtk/gtktextview.c: Add an extra parameter
to _gtk_menu_item_select_first() to allow us to choose
whether we want to select the first item predictably
or to select the first sensitive item. Fixes problem
with insensitive menu items and keynav. (#85796,
reported by Bill Haneman and others.)
Fri Jul 5 02:50:24 2002 Jonathan Blandford <jrb@gnome.org>
* gtk/gtktreeview.c (gtk_tree_view_collapse_all): fix warning.
......
Fri Jul 5 20:18:23 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkmenushell.[ch] gtk/gtkmenubar.c gtk/gtkmenuitem.c
gtk/gtkentry.c gtk/gtktextview.c: Add an extra parameter
to _gtk_menu_item_select_first() to allow us to choose
whether we want to select the first item predictably
or to select the first sensitive item. Fixes problem
with insensitive menu items and keynav. (#85796,
reported by Bill Haneman and others.)
Fri Jul 5 02:50:24 2002 Jonathan Blandford <jrb@gnome.org>
* gtk/gtktreeview.c (gtk_tree_view_collapse_all): fix warning.
......
......@@ -3922,7 +3922,7 @@ popup_targets_received (GtkClipboard *clipboard,
gtk_menu_popup (GTK_MENU (entry->popup_menu), NULL, NULL,
popup_position_func, entry,
info->button, info->time);
_gtk_menu_shell_select_first (GTK_MENU_SHELL (entry->popup_menu));
_gtk_menu_shell_select_first (GTK_MENU_SHELL (entry->popup_menu), FALSE);
}
}
......
......@@ -450,7 +450,7 @@ window_key_press_handler (GtkWidget *widget,
GtkMenuShell *menu_shell = GTK_MENU_SHELL (menubars->data);
_gtk_menu_shell_activate (menu_shell);
_gtk_menu_shell_select_first (menu_shell);
_gtk_menu_shell_select_first (menu_shell, FALSE);
g_list_free (menubars);
......
......@@ -804,7 +804,7 @@ gtk_real_menu_item_activate_item (GtkMenuItem *menu_item)
gtk_menu_shell_select_item (GTK_MENU_SHELL (widget->parent), widget);
gtk_menu_item_popup_submenu (widget);
_gtk_menu_shell_select_first (GTK_MENU_SHELL (menu_item->submenu));
_gtk_menu_shell_select_first (GTK_MENU_SHELL (menu_item->submenu), FALSE);
submenu = GTK_MENU_SHELL (menu_item->submenu);
}
}
......
......@@ -994,12 +994,19 @@ gtk_menu_shell_move_selected (GtkMenuShell *menu_shell,
/**
* _gtk_menu_shell_select_first:
* @menu_shell: a #GtkMenuShell
* @search_sensitive: if %TRUE, search for the first selectable
* menu item, otherwise select nothing if
* the first item isn't sensitive. This
* should be %FALSE if the menu is being
* popped up initially.
*
* Select the first visible child of the menu shell, unless
* it's a tearoff item.
* Select the first visible or selectable child of the menu shell;
* don't select tearoff items unless the only item is a tearoff
* item.
**/
void
_gtk_menu_shell_select_first (GtkMenuShell *menu_shell)
_gtk_menu_shell_select_first (GtkMenuShell *menu_shell,
gboolean search_sensitive)
{
GtkWidget *to_select = NULL;
GList *tmp_list;
......@@ -1009,7 +1016,8 @@ _gtk_menu_shell_select_first (GtkMenuShell *menu_shell)
{
GtkWidget *child = tmp_list->data;
if (GTK_WIDGET_VISIBLE (child))
if ((!search_sensitive && GTK_WIDGET_VISIBLE (child)) ||
_gtk_menu_item_is_selectable (child))
{
to_select = child;
if (!GTK_IS_TEAROFF_MENU_ITEM (child))
......@@ -1023,6 +1031,33 @@ _gtk_menu_shell_select_first (GtkMenuShell *menu_shell)
gtk_menu_shell_select_item (menu_shell, to_select);
}
static void
gtk_menu_shell_select_last (GtkMenuShell *menu_shell,
gboolean search_sensitive)
{
GtkWidget *to_select = NULL;
GList *tmp_list;
tmp_list = g_list_last (menu_shell->children);
while (tmp_list)
{
GtkWidget *child = tmp_list->data;
if ((!search_sensitive && GTK_WIDGET_VISIBLE (child)) ||
_gtk_menu_item_is_selectable (child))
{
to_select = child;
if (!GTK_IS_TEAROFF_MENU_ITEM (child))
break;
}
tmp_list = tmp_list->prev;
}
if (to_select)
gtk_menu_shell_select_item (menu_shell, to_select);
}
static void
gtk_menu_shell_select_submenu_first (GtkMenuShell *menu_shell)
{
......@@ -1031,7 +1066,7 @@ gtk_menu_shell_select_submenu_first (GtkMenuShell *menu_shell)
menu_item = GTK_MENU_ITEM (menu_shell->active_menu_item);
if (menu_item->submenu)
_gtk_menu_shell_select_first (GTK_MENU_SHELL (menu_item->submenu));
_gtk_menu_shell_select_first (GTK_MENU_SHELL (menu_item->submenu), TRUE);
}
static void
......@@ -1097,14 +1132,14 @@ gtk_real_menu_shell_move_current (GtkMenuShell *menu_shell,
if (!had_selection &&
!menu_shell->active_menu_item &&
menu_shell->children)
gtk_menu_shell_select_item (menu_shell, g_list_last (menu_shell->children)->data);
gtk_menu_shell_select_last (menu_shell, TRUE);
break;
case GTK_MENU_DIR_NEXT:
gtk_menu_shell_move_selected (menu_shell, 1);
if (!had_selection &&
!menu_shell->active_menu_item &&
menu_shell->children)
gtk_menu_shell_select_item (menu_shell, menu_shell->children->data);
_gtk_menu_shell_select_first (menu_shell, TRUE);
break;
}
......
......@@ -111,7 +111,8 @@ void gtk_menu_shell_activate_item (GtkMenuShell *menu_shell,
GtkWidget *menu_item,
gboolean force_deactivate);
void _gtk_menu_shell_select_first (GtkMenuShell *menu_shell);
void _gtk_menu_shell_select_first (GtkMenuShell *menu_shell,
gboolean search_sensitive);
void _gtk_menu_shell_activate (GtkMenuShell *menu_shell);
#ifdef __cplusplus
......
......@@ -6447,7 +6447,7 @@ popup_targets_received (GtkClipboard *clipboard,
gtk_menu_popup (GTK_MENU (text_view->popup_menu), NULL, NULL,
popup_position_func, text_view,
0, gtk_get_current_event_time ());
_gtk_menu_shell_select_first (GTK_MENU_SHELL (text_view->popup_menu));
_gtk_menu_shell_select_first (GTK_MENU_SHELL (text_view->popup_menu), FALSE);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment