summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/menu_gtk.cc
diff options
context:
space:
mode:
authorerg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-06 22:12:34 +0000
committererg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-06 22:12:34 +0000
commit449f8d6c9a2ba105405a0ea0625300fec73eaadb (patch)
tree2fa3d3bb10425d32b9b50633d836774809353b44 /chrome/browser/gtk/menu_gtk.cc
parentaf0285648087cda5acfd903a99975a2560556b83 (diff)
downloadchromium_src-449f8d6c9a2ba105405a0ea0625300fec73eaadb.zip
chromium_src-449f8d6c9a2ba105405a0ea0625300fec73eaadb.tar.gz
chromium_src-449f8d6c9a2ba105405a0ea0625300fec73eaadb.tar.bz2
Implement accelerators in the gtk port (try 2).
- Adds accelerators to all the menu items that had them on windows. - Adds accelerators to back (Alt+left), forward (Alt+right), reload (Ctr+R) and focus the URL box (Ctr+L). Review URL: http://codereview.chromium.org/39278 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11166 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/menu_gtk.cc')
-rw-r--r--chrome/browser/gtk/menu_gtk.cc16
1 files changed, 15 insertions, 1 deletions
diff --git a/chrome/browser/gtk/menu_gtk.cc b/chrome/browser/gtk/menu_gtk.cc
index af6c4e9..d9a3860 100644
--- a/chrome/browser/gtk/menu_gtk.cc
+++ b/chrome/browser/gtk/menu_gtk.cc
@@ -73,8 +73,10 @@ GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap* bitmap) {
} // namespace
MenuGtk::MenuGtk(MenuGtk::Delegate* delegate,
- const MenuCreateMaterial* menu_data)
+ const MenuCreateMaterial* menu_data,
+ GtkAccelGroup* accel_group)
: delegate_(delegate),
+ accel_group_(accel_group),
menu_(gtk_menu_new()) {
g_object_ref_sink(menu_);
BuildMenuIn(menu_, menu_data);
@@ -146,6 +148,18 @@ void MenuGtk::BuildMenuIn(GtkWidget* menu,
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), submenu);
}
+ if (accel_group_ && menu_data->accel_key) {
+ // If we ever want to let the user do any key remaping, we'll need to
+ // change the following so we make a gtk_accel_map which keeps the actual
+ // keys.
+ gtk_widget_add_accelerator(menu_item,
+ "activate",
+ accel_group_,
+ menu_data->accel_key,
+ GdkModifierType(menu_data->accel_modifiers),
+ GTK_ACCEL_VISIBLE);
+ }
+
g_object_set_data(G_OBJECT(menu_item), "menu-data",
const_cast<MenuCreateMaterial*>(menu_data));