Use _gtk_menu_item_popup_submenu() to make keynav into submenus work

2004-12-15  Matthias Clasen  <mclasen@redhat.com>

	* gtk/gtkmenushell.c (gtk_menu_shell_select_submenu_first)
	(gtk_real_menu_shell_activate_current): Use
	_gtk_menu_item_popup_submenu() to make keynav into submenus work
	instantaneously, independent of the popup delay.  (#161140)

	* gtk/gtkmenuitem.[hc]: _-prefix gtk_menu_item_popup_submenu() and
	make it non-static.

	* gtk/gtkmenuitem.c (gtk_menu_item_paint): Remove unused variables.
This commit is contained in:
Matthias Clasen 2004-12-15 16:27:30 +00:00 committed by Matthias Clasen
parent b418bf3aa4
commit 8b927c6f58
10 changed files with 74 additions and 80 deletions

View File

@ -1,3 +1,15 @@
2004-12-15 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkmenushell.c (gtk_menu_shell_select_submenu_first)
(gtk_real_menu_shell_activate_current): Use
_gtk_menu_item_popup_submenu() to make keynav into submenus work
instantaneously, independent of the popup delay. (#161140)
* gtk/gtkmenuitem.[hc]: _-prefix gtk_menu_item_popup_submenu() and
make it non-static.
* gtk/gtkmenuitem.c (gtk_menu_item_paint): Remove unused variables.
2004-12-15 James M. Cape <jcape@ignore-your.tv> 2004-12-15 James M. Cape <jcape@ignore-your.tv>
* gtk/gtkfilechooserbutton.c (struct _GtkFileChooserButtonPrivate) * gtk/gtkfilechooserbutton.c (struct _GtkFileChooserButtonPrivate)

View File

@ -1,3 +1,15 @@
2004-12-15 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkmenushell.c (gtk_menu_shell_select_submenu_first)
(gtk_real_menu_shell_activate_current): Use
_gtk_menu_item_popup_submenu() to make keynav into submenus work
instantaneously, independent of the popup delay. (#161140)
* gtk/gtkmenuitem.[hc]: _-prefix gtk_menu_item_popup_submenu() and
make it non-static.
* gtk/gtkmenuitem.c (gtk_menu_item_paint): Remove unused variables.
2004-12-15 James M. Cape <jcape@ignore-your.tv> 2004-12-15 James M. Cape <jcape@ignore-your.tv>
* gtk/gtkfilechooserbutton.c (struct _GtkFileChooserButtonPrivate) * gtk/gtkfilechooserbutton.c (struct _GtkFileChooserButtonPrivate)

View File

@ -1,3 +1,15 @@
2004-12-15 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkmenushell.c (gtk_menu_shell_select_submenu_first)
(gtk_real_menu_shell_activate_current): Use
_gtk_menu_item_popup_submenu() to make keynav into submenus work
instantaneously, independent of the popup delay. (#161140)
* gtk/gtkmenuitem.[hc]: _-prefix gtk_menu_item_popup_submenu() and
make it non-static.
* gtk/gtkmenuitem.c (gtk_menu_item_paint): Remove unused variables.
2004-12-15 James M. Cape <jcape@ignore-your.tv> 2004-12-15 James M. Cape <jcape@ignore-your.tv>
* gtk/gtkfilechooserbutton.c (struct _GtkFileChooserButtonPrivate) * gtk/gtkfilechooserbutton.c (struct _GtkFileChooserButtonPrivate)

View File

@ -1,3 +1,15 @@
2004-12-15 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkmenushell.c (gtk_menu_shell_select_submenu_first)
(gtk_real_menu_shell_activate_current): Use
_gtk_menu_item_popup_submenu() to make keynav into submenus work
instantaneously, independent of the popup delay. (#161140)
* gtk/gtkmenuitem.[hc]: _-prefix gtk_menu_item_popup_submenu() and
make it non-static.
* gtk/gtkmenuitem.c (gtk_menu_item_paint): Remove unused variables.
2004-12-15 James M. Cape <jcape@ignore-your.tv> 2004-12-15 James M. Cape <jcape@ignore-your.tv>
* gtk/gtkfilechooserbutton.c (struct _GtkFileChooserButtonPrivate) * gtk/gtkfilechooserbutton.c (struct _GtkFileChooserButtonPrivate)

View File

@ -288,8 +288,6 @@ gtk_cell_view_new_with_text
gtk_cell_view_set_background_color gtk_cell_view_set_background_color
gtk_cell_view_set_displayed_row gtk_cell_view_set_displayed_row
gtk_cell_view_set_model gtk_cell_view_set_model
gtk_cell_view_set_value
gtk_cell_view_set_values
gtk_check_button_get_type G_GNUC_CONST gtk_check_button_get_type G_GNUC_CONST
gtk_check_button_new gtk_check_button_new
gtk_check_button_new_with_label gtk_check_button_new_with_label

View File

@ -76,9 +76,10 @@ static void gtk_cell_view_size_allocate (GtkWidget *wid
GtkAllocation *allocation); GtkAllocation *allocation);
static gboolean gtk_cell_view_expose (GtkWidget *widget, static gboolean gtk_cell_view_expose (GtkWidget *widget,
GdkEventExpose *event); GdkEventExpose *event);
static void gtk_cell_view_set_valuesv (GtkCellView *cellview, static void gtk_cell_view_set_value (GtkCellView *cell_view,
GtkCellRenderer *renderer, GtkCellRenderer *renderer,
va_list args); gchar *property,
GValue *value);
static GtkCellViewCellInfo *gtk_cell_view_get_cell_info (GtkCellView *cellview, static GtkCellViewCellInfo *gtk_cell_view_get_cell_info (GtkCellView *cellview,
GtkCellRenderer *renderer); GtkCellRenderer *renderer);
static void gtk_cell_view_set_cell_data (GtkCellView *cell_view); static void gtk_cell_view_set_cell_data (GtkCellView *cell_view);
@ -795,7 +796,7 @@ gtk_cell_view_new_with_text (const gchar *text)
g_value_init (&value, G_TYPE_STRING); g_value_init (&value, G_TYPE_STRING);
g_value_set_string (&value, text); g_value_set_string (&value, text);
gtk_cell_view_set_values (cellview, renderer, "text", &value, NULL); gtk_cell_view_set_value (cellview, renderer, "text", &value);
g_value_unset (&value); g_value_unset (&value);
return GTK_WIDGET (cellview); return GTK_WIDGET (cellview);
@ -829,7 +830,7 @@ gtk_cell_view_new_with_markup (const gchar *markup)
g_value_init (&value, G_TYPE_STRING); g_value_init (&value, G_TYPE_STRING);
g_value_set_string (&value, markup); g_value_set_string (&value, markup);
gtk_cell_view_set_values (cellview, renderer, "markup", &value, NULL); gtk_cell_view_set_value (cellview, renderer, "markup", &value);
g_value_unset (&value); g_value_unset (&value);
return GTK_WIDGET (cellview); return GTK_WIDGET (cellview);
@ -861,7 +862,7 @@ gtk_cell_view_new_with_pixbuf (GdkPixbuf *pixbuf)
g_value_init (&value, GDK_TYPE_PIXBUF); g_value_init (&value, GDK_TYPE_PIXBUF);
g_value_set_object (&value, pixbuf); g_value_set_object (&value, pixbuf);
gtk_cell_view_set_values (cellview, renderer, "pixbuf", &value, NULL); gtk_cell_view_set_value (cellview, renderer, "pixbuf", &value);
g_value_unset (&value); g_value_unset (&value);
return GTK_WIDGET (cellview); return GTK_WIDGET (cellview);
@ -879,7 +880,7 @@ gtk_cell_view_new_with_pixbuf (GdkPixbuf *pixbuf)
* *
* Since: 2.6 * Since: 2.6
*/ */
void static void
gtk_cell_view_set_value (GtkCellView *cell_view, gtk_cell_view_set_value (GtkCellView *cell_view,
GtkCellRenderer *renderer, GtkCellRenderer *renderer,
gchar *property, gchar *property,
@ -895,52 +896,6 @@ gtk_cell_view_set_value (GtkCellView *cell_view,
gtk_widget_queue_draw (GTK_WIDGET (cell_view)); gtk_widget_queue_draw (GTK_WIDGET (cell_view));
} }
static void
gtk_cell_view_set_valuesv (GtkCellView *cell_view,
GtkCellRenderer *renderer,
va_list args)
{
gchar *attribute;
GValue *value;
attribute = va_arg (args, gchar *);
while (attribute)
{
value = va_arg (args, GValue *);
gtk_cell_view_set_value (cell_view, renderer, attribute, value);
attribute = va_arg (args, gchar *);
}
}
/**
* gtk_cell_view_set_values:
* @cell_view: a #GtkCellView widget
* @renderer: one of the renderers of @cell_view
* @Varargs: a list of pairs of property names and #GValue<!-- -->s,
* finished by %NULL
*
* Sets multiple properties of a cell renderer of @cell_view, and
* makes sure the display of @cell_view is updated.
*
* Since: 2.6
*/
void
gtk_cell_view_set_values (GtkCellView *cell_view,
GtkCellRenderer *renderer,
...)
{
va_list args;
g_return_if_fail (GTK_IS_CELL_VIEW (cell_view));
g_return_if_fail (GTK_IS_CELL_RENDERER (renderer));
g_return_if_fail (gtk_cell_view_get_cell_info (cell_view, renderer));
va_start (args, renderer);
gtk_cell_view_set_valuesv (cell_view, renderer, args);
va_end (args);
}
/** /**
* gtk_cell_view_set_model: * gtk_cell_view_set_model:
* @cell_view: a #GtkCellView * @cell_view: a #GtkCellView

View File

@ -56,15 +56,6 @@ GtkWidget *gtk_cell_view_new_with_text (const gchar *text);
GtkWidget *gtk_cell_view_new_with_markup (const gchar *markup); GtkWidget *gtk_cell_view_new_with_markup (const gchar *markup);
GtkWidget *gtk_cell_view_new_with_pixbuf (GdkPixbuf *pixbuf); GtkWidget *gtk_cell_view_new_with_pixbuf (GdkPixbuf *pixbuf);
void gtk_cell_view_set_value (GtkCellView *cell_view,
GtkCellRenderer *renderer,
gchar *property,
GValue *value);
void gtk_cell_view_set_values (GtkCellView *cell_view,
GtkCellRenderer *renderer,
...);
void gtk_cell_view_set_model (GtkCellView *cell_view, void gtk_cell_view_set_model (GtkCellView *cell_view,
GtkTreeModel *model); GtkTreeModel *model);
void gtk_cell_view_set_displayed_row (GtkCellView *cell_view, void gtk_cell_view_set_displayed_row (GtkCellView *cell_view,

View File

@ -80,7 +80,6 @@ static gboolean gtk_menu_item_mnemonic_activate (GtkWidget *widget,
gboolean group_cycling); gboolean group_cycling);
static gint gtk_menu_item_select_timeout (gpointer data); static gint gtk_menu_item_select_timeout (gpointer data);
static void gtk_menu_item_popup_submenu (gpointer data);
static void gtk_menu_item_position_menu (GtkMenu *menu, static void gtk_menu_item_position_menu (GtkMenu *menu,
gint *x, gint *x,
gint *y, gint *y,
@ -199,7 +198,7 @@ gtk_menu_item_class_init (GtkMenuItemClass *klass)
g_signal_new ("toggle_size_allocate", g_signal_new ("toggle_size_allocate",
G_OBJECT_CLASS_TYPE (gobject_class), G_OBJECT_CLASS_TYPE (gobject_class),
G_SIGNAL_RUN_FIRST, G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkMenuItemClass, toggle_size_allocate), G_STRUCT_OFFSET (GtkMenuItemClass, toggle_size_allocate),
NULL, NULL, NULL, NULL,
_gtk_marshal_NONE__INT, _gtk_marshal_NONE__INT,
G_TYPE_NONE, 1, G_TYPE_NONE, 1,
@ -718,7 +717,6 @@ gtk_menu_item_paint (GtkWidget *widget,
if (menu_item->submenu && menu_item->show_submenu_indicator) if (menu_item->submenu && menu_item->show_submenu_indicator)
{ {
GtkRequisition child_requisition;
gint arrow_x, arrow_y; gint arrow_x, arrow_y;
gint arrow_size; gint arrow_size;
gint arrow_extent; gint arrow_extent;
@ -728,7 +726,6 @@ gtk_menu_item_paint (GtkWidget *widget,
PangoContext *context; PangoContext *context;
PangoFontMetrics *metrics; PangoFontMetrics *metrics;
gint ascent, descent; gint ascent, descent;
PangoLayout *layout;
direction = gtk_widget_get_direction (widget); direction = gtk_widget_get_direction (widget);
@ -871,7 +868,7 @@ gtk_real_menu_item_select (GtkItem *item)
gdk_event_free (event); gdk_event_free (event);
} }
else else
gtk_menu_item_popup_submenu (menu_item); _gtk_menu_item_popup_submenu (GTK_WIDGET (menu_item));
} }
gtk_widget_set_state (GTK_WIDGET (menu_item), GTK_STATE_PRELIGHT); gtk_widget_set_state (GTK_WIDGET (menu_item), GTK_STATE_PRELIGHT);
@ -944,7 +941,7 @@ gtk_real_menu_item_activate_item (GtkMenuItem *menu_item)
_gtk_menu_shell_activate (menu_shell); _gtk_menu_shell_activate (menu_shell);
gtk_menu_shell_select_item (GTK_MENU_SHELL (widget->parent), widget); gtk_menu_shell_select_item (GTK_MENU_SHELL (widget->parent), widget);
gtk_menu_item_popup_submenu (widget); _gtk_menu_item_popup_submenu (widget);
gtk_menu_shell_select_first (GTK_MENU_SHELL (menu_item->submenu), TRUE); gtk_menu_shell_select_first (GTK_MENU_SHELL (menu_item->submenu), TRUE);
submenu = GTK_MENU_SHELL (menu_item->submenu); submenu = GTK_MENU_SHELL (menu_item->submenu);
@ -984,7 +981,7 @@ gtk_menu_item_select_timeout (gpointer data)
if ((GTK_IS_MENU_SHELL (parent) && GTK_MENU_SHELL (parent)->active) || if ((GTK_IS_MENU_SHELL (parent) && GTK_MENU_SHELL (parent)->active) ||
(GTK_IS_MENU (parent) && GTK_MENU (parent)->torn_off)) (GTK_IS_MENU (parent) && GTK_MENU (parent)->torn_off))
{ {
gtk_menu_item_popup_submenu (data); _gtk_menu_item_popup_submenu (GTK_WIDGET (menu_item));
if (menu_item->timer_from_keypress && menu_item->submenu) if (menu_item->timer_from_keypress && menu_item->submenu)
GTK_MENU_SHELL (menu_item->submenu)->ignore_enter = TRUE; GTK_MENU_SHELL (menu_item->submenu)->ignore_enter = TRUE;
} }
@ -994,13 +991,11 @@ gtk_menu_item_select_timeout (gpointer data)
return FALSE; return FALSE;
} }
static void void
gtk_menu_item_popup_submenu (gpointer data) _gtk_menu_item_popup_submenu (GtkWidget *widget)
{ {
GtkWidget *widget;
GtkMenuItem *menu_item; GtkMenuItem *menu_item;
widget = GTK_WIDGET (data);
menu_item = GTK_MENU_ITEM (widget); menu_item = GTK_MENU_ITEM (widget);
if (menu_item->timer) if (menu_item->timer)

View File

@ -121,6 +121,7 @@ void _gtk_menu_item_refresh_accel_path (GtkMenuItem *menu_item,
GtkAccelGroup *accel_group, GtkAccelGroup *accel_group,
gboolean group_changed); gboolean group_changed);
gboolean _gtk_menu_item_is_selectable (GtkWidget *menu_item); gboolean _gtk_menu_item_is_selectable (GtkWidget *menu_item);
void _gtk_menu_item_popup_submenu (GtkWidget *menu_item);
#ifndef GTK_DISABLE_DEPRECATED #ifndef GTK_DISABLE_DEPRECATED
#define gtk_menu_item_right_justify(menu_item) gtk_menu_item_set_right_justified ((menu_item), TRUE) #define gtk_menu_item_right_justify(menu_item) gtk_menu_item_set_right_justified ((menu_item), TRUE)

View File

@ -1070,7 +1070,10 @@ gtk_menu_shell_select_submenu_first (GtkMenuShell *menu_shell)
menu_item = GTK_MENU_ITEM (menu_shell->active_menu_item); menu_item = GTK_MENU_ITEM (menu_shell->active_menu_item);
if (menu_item->submenu) if (menu_item->submenu)
gtk_menu_shell_select_first (GTK_MENU_SHELL (menu_item->submenu), TRUE); {
_gtk_menu_item_popup_submenu (menu_item);
gtk_menu_shell_select_first (GTK_MENU_SHELL (menu_item->submenu), TRUE);
}
} }
static void static void
@ -1190,13 +1193,16 @@ gtk_real_menu_shell_activate_current (GtkMenuShell *menu_shell,
gboolean force_hide) gboolean force_hide)
{ {
if (menu_shell->active_menu_item && if (menu_shell->active_menu_item &&
_gtk_menu_item_is_selectable (menu_shell->active_menu_item) && _gtk_menu_item_is_selectable (menu_shell->active_menu_item))
GTK_MENU_ITEM (menu_shell->active_menu_item)->submenu == NULL) {
{
if (GTK_MENU_ITEM (menu_shell->active_menu_item)->submenu == NULL)
gtk_menu_shell_activate_item (menu_shell, gtk_menu_shell_activate_item (menu_shell,
menu_shell->active_menu_item, menu_shell->active_menu_item,
force_hide); force_hide);
} else
_gtk_menu_item_popup_submenu (menu_shell->active_menu_item);
}
} }
static void static void