summaryrefslogtreecommitdiff
path: root/gtk/gtkmenu.c
diff options
context:
space:
mode:
authorTim Janik <timj@gtk.org>2003-11-27 15:51:32 +0000
committerTim Janik <timj@src.gnome.org>2003-11-27 15:51:32 +0000
commit448b576dc1c7e4c957614b821902e6c16c213934 (patch)
treecff96106bf060cd413c8fedb21bf97e972d330d7 /gtk/gtkmenu.c
parent6e63e7f75a857b3d67c03505dd05771fda7c1d32 (diff)
downloadgtk+-448b576dc1c7e4c957614b821902e6c16c213934.tar.gz
allow accel activation depending on sensitivity and the attach widget.
Thu Nov 27 16:19:03 2003 Tim Janik <timj@gtk.org> * gtk/gtkmenu.c: allow accel activation depending on sensitivity and the attach widget. * gtk/gtkmenuitem.c: allow accel activation depending on visibility, sensitivity and the parent menu. * gtk/gtkwidget.[hc]: introduced ::can-activate-accel signal which checks whether accelerators may activate a widget. the default handler demands the widget be sensitive and visible+viewable. * gtk/gtkaccelgroup.[hc]: export gtk_accel_group_activate().
Diffstat (limited to 'gtk/gtkmenu.c')
-rw-r--r--gtk/gtkmenu.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index db002aa4cf..3999ee545f 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -215,6 +215,8 @@ static void gtk_menu_update_title (GtkMenu *menu);
static void menu_grab_transfer_window_destroy (GtkMenu *menu);
static GdkWindow *menu_grab_transfer_window_get (GtkMenu *menu);
+static gboolean gtk_menu_real_can_activate_accel (GtkWidget *widget,
+ guint signal_id);
static void _gtk_menu_refresh_accel_paths (GtkMenu *menu,
gboolean group_changed);
@@ -318,6 +320,7 @@ gtk_menu_class_init (GtkMenuClass *class)
widget_class->motion_notify_event = gtk_menu_motion_notify;
widget_class->style_set = gtk_menu_style_set;
widget_class->focus = gtk_menu_focus;
+ widget_class->can_activate_accel = gtk_menu_real_can_activate_accel;
container_class->remove = gtk_menu_remove;
container_class->get_child_property = gtk_menu_get_child_property;
@@ -1416,6 +1419,19 @@ gtk_menu_get_accel_group (GtkMenu *menu)
return menu->accel_group;
}
+static gboolean
+gtk_menu_real_can_activate_accel (GtkWidget *widget,
+ guint signal_id)
+{
+ /* menu items chain here to figure whether they can activate their accelerators.
+ * despite ordinary widgets, menus allow accel activation even if invisible
+ * since that's the usual case for submenus/popup-menus. however, the state
+ * of the attch widget affects "activeness" of the menu.
+ */
+ GtkWidget *awidget = gtk_menu_get_attach_widget (GTK_MENU (widget));
+ return awidget ? gtk_widget_can_activate_accel (awidget, signal_id) : GTK_WIDGET_IS_SENSITIVE (widget);
+}
+
/**
* gtk_menu_set_accel_path
* @menu: a valid #GtkMenu