diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-14 01:39:41 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-14 01:39:41 +0000 |
commit | 3401b00e41731a8816d9aec9592b09efb4bf5eac (patch) | |
tree | 0f267305ddb937ef4b25ad79ccc4e69115bc9cd9 /chrome/browser/gtk | |
parent | e5b2eaa2a2a52c104f038e520b61dcbcf7c835dd (diff) | |
download | chromium_src-3401b00e41731a8816d9aec9592b09efb4bf5eac.zip chromium_src-3401b00e41731a8816d9aec9592b09efb4bf5eac.tar.gz chromium_src-3401b00e41731a8816d9aec9592b09efb4bf5eac.tar.bz2 |
Linux: Ignore certain menu accelerators.
Review URL: http://codereview.chromium.org/73003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13643 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r-- | chrome/browser/gtk/link_button_gtk.cc | 2 | ||||
-rw-r--r-- | chrome/browser/gtk/menu_gtk.cc | 7 | ||||
-rw-r--r-- | chrome/browser/gtk/menu_gtk.h | 5 | ||||
-rw-r--r-- | chrome/browser/gtk/standard_menus.cc | 62 | ||||
-rw-r--r-- | chrome/browser/gtk/standard_menus.h | 5 |
5 files changed, 47 insertions, 34 deletions
diff --git a/chrome/browser/gtk/link_button_gtk.cc b/chrome/browser/gtk/link_button_gtk.cc index 30cea19ff..9c81208 100644 --- a/chrome/browser/gtk/link_button_gtk.cc +++ b/chrome/browser/gtk/link_button_gtk.cc @@ -26,7 +26,7 @@ void SetLinkButtonStyle() { "widget \"*chrome-link-button\" style \"chrome-link-button\""); } -} +} // namespace LinkButtonGtk::LinkButtonGtk(const char* text) : hand_cursor_(gdk_cursor_new(GDK_HAND2)), diff --git a/chrome/browser/gtk/menu_gtk.cc b/chrome/browser/gtk/menu_gtk.cc index 2a804cb..b9062df 100644 --- a/chrome/browser/gtk/menu_gtk.cc +++ b/chrome/browser/gtk/menu_gtk.cc @@ -38,18 +38,22 @@ MenuGtk::MenuGtk(MenuGtk::Delegate* delegate, const MenuCreateMaterial* menu_data, GtkAccelGroup* accel_group) : delegate_(delegate), + dummy_accel_group_(gtk_accel_group_new()), menu_(gtk_menu_new()) { BuildMenuIn(menu_.get(), menu_data, accel_group); } MenuGtk::MenuGtk(MenuGtk::Delegate* delegate) : delegate_(delegate), + dummy_accel_group_(NULL), menu_(gtk_menu_new()) { BuildMenuFromDelegate(); } MenuGtk::~MenuGtk() { menu_.Destroy(); + if (dummy_accel_group_) + g_object_unref(dummy_accel_group_); } void MenuGtk::Popup(GtkWidget* widget, GdkEvent* event) { @@ -133,7 +137,8 @@ void MenuGtk::BuildMenuIn(GtkWidget* menu, // keys. gtk_widget_add_accelerator(menu_item, "activate", - accel_group, + menu_data->only_show ? dummy_accel_group_ : + accel_group, menu_data->accel_key, GdkModifierType(menu_data->accel_modifiers), GTK_ACCEL_VISIBLE); diff --git a/chrome/browser/gtk/menu_gtk.h b/chrome/browser/gtk/menu_gtk.h index 0506ff3..428aae1 100644 --- a/chrome/browser/gtk/menu_gtk.h +++ b/chrome/browser/gtk/menu_gtk.h @@ -96,6 +96,11 @@ class MenuGtk { // Queries this object about the menu state. MenuGtk::Delegate* delegate_; + // For some menu items, we want to show the accelerator, but not actually + // explicitly handle it. To this end we connect those menu items' accelerators + // to this group, but don't attach this group to any top level window. + GtkAccelGroup* dummy_accel_group_; + // gtk_menu_popup() does not appear to take ownership of popup menus, so // MenuGtk explicitly manages the lifetime of the menu. OwnedWidgetGtk menu_; diff --git a/chrome/browser/gtk/standard_menus.cc b/chrome/browser/gtk/standard_menus.cc index 335e275..1ca6ddc 100644 --- a/chrome/browser/gtk/standard_menus.cc +++ b/chrome/browser/gtk/standard_menus.cc @@ -30,13 +30,12 @@ struct MenuCreateMaterial zoom_menu_materials[] = { GDK_minus, GDK_CONTROL_MASK }, { MENU_NORMAL, IDC_ZOOM_MINUS, IDS_ZOOM_MINUS, 0, NULL, GDK_KP_Subtract, GDK_CONTROL_MASK }, - { MENU_END, 0, 0, 0, NULL } + { MENU_END } }; struct MenuCreateMaterial encoding_menu_materials[] = { - { MENU_CHECKBOX, IDC_ENCODING_AUTO_DETECT, IDS_ENCODING_AUTO_DETECT, 0, - NULL }, - { MENU_END, 0, 0, 0, NULL } + { MENU_CHECKBOX, IDC_ENCODING_AUTO_DETECT, IDS_ENCODING_AUTO_DETECT }, + { MENU_END } }; struct MenuCreateMaterial developer_menu_materials[] = { @@ -48,30 +47,30 @@ struct MenuCreateMaterial developer_menu_materials[] = { GDK_j, GDK_CONTROL_MASK | GDK_SHIFT_MASK }, { MENU_NORMAL, IDC_TASK_MANAGER, IDS_TASK_MANAGER, 0, NULL, GDK_Escape, GDK_SHIFT_MASK }, - { MENU_END, 0, 0, 0, NULL } + { MENU_END } }; struct MenuCreateMaterial standard_page_menu_materials[] = { - { MENU_NORMAL, IDC_CREATE_SHORTCUTS, IDS_CREATE_SHORTCUTS, 0, NULL }, - { MENU_SEPARATOR, 0, 0, 0, NULL }, - { MENU_NORMAL, IDC_CUT, IDS_CUT, 0, NULL, GDK_x, GDK_CONTROL_MASK }, - { MENU_NORMAL, IDC_COPY, IDS_COPY, 0, NULL, GDK_c, GDK_CONTROL_MASK }, - { MENU_NORMAL, IDC_PASTE, IDS_PASTE, 0, NULL, GDK_v, GDK_CONTROL_MASK }, - { MENU_SEPARATOR, 0, 0, 0, NULL }, + { MENU_NORMAL, IDC_CREATE_SHORTCUTS, IDS_CREATE_SHORTCUTS }, + { MENU_SEPARATOR }, + { MENU_NORMAL, IDC_CUT, IDS_CUT, 0, NULL, GDK_x, GDK_CONTROL_MASK, true }, + { MENU_NORMAL, IDC_COPY, IDS_COPY, 0, NULL, GDK_c, GDK_CONTROL_MASK, true }, + { MENU_NORMAL, IDC_PASTE, IDS_PASTE, 0, NULL, GDK_v, GDK_CONTROL_MASK, true }, + { MENU_SEPARATOR }, { MENU_NORMAL, IDC_FIND, IDS_FIND, 0, NULL, GDK_f, GDK_CONTROL_MASK }, { MENU_NORMAL, IDC_SAVE_PAGE, IDS_SAVE_PAGE, 0, NULL, GDK_s, GDK_CONTROL_MASK }, { MENU_NORMAL, IDC_PRINT, IDS_PRINT, 0, NULL, GDK_p, GDK_CONTROL_MASK }, - { MENU_SEPARATOR, 0, 0, 0, NULL }, - { MENU_NORMAL, IDC_ZOOM_MENU, IDS_ZOOM_MENU, 0, zoom_menu_materials, 0, 0 }, + { MENU_SEPARATOR }, + { MENU_NORMAL, IDC_ZOOM_MENU, IDS_ZOOM_MENU, 0, zoom_menu_materials }, { MENU_NORMAL, IDC_ENCODING_MENU, IDS_ENCODING_MENU, 0, - encoding_menu_materials, 0, 0 }, - { MENU_SEPARATOR, 0, 0, 0, NULL }, + encoding_menu_materials }, + { MENU_SEPARATOR }, { MENU_NORMAL, IDC_DEVELOPER_MENU, IDS_DEVELOPER_MENU, 0, - developer_menu_materials, 0, 0 }, - { MENU_SEPARATOR, 0, 0, 0, NULL }, - { MENU_NORMAL, IDC_REPORT_BUG, IDS_REPORT_BUG, 0, NULL }, - { MENU_END, 0, 0, 0, NULL } + developer_menu_materials }, + { MENU_SEPARATOR }, + { MENU_NORMAL, IDC_REPORT_BUG, IDS_REPORT_BUG }, + { MENU_END } }; // ----------------------------------------------------------------------- @@ -83,28 +82,27 @@ struct MenuCreateMaterial standard_app_menu_materials[] = { GDK_n, GDK_CONTROL_MASK }, { MENU_NORMAL, IDC_NEW_INCOGNITO_WINDOW, IDS_NEW_INCOGNITO_WINDOW, 0, NULL, GDK_n, GDK_CONTROL_MASK | GDK_SHIFT_MASK}, - { MENU_SEPARATOR, 0, 0, NULL }, + { MENU_SEPARATOR }, { MENU_NORMAL, IDC_SHOW_BOOKMARK_BAR, IDS_SHOW_BOOKMARK_BAR, 0, NULL, GDK_b, GDK_CONTROL_MASK }, - { MENU_SEPARATOR, 0, 0, NULL }, + { MENU_SEPARATOR }, { MENU_NORMAL, IDC_SHOW_HISTORY, IDS_SHOW_HISTORY, 0, NULL, GDK_h, GDK_CONTROL_MASK }, { MENU_NORMAL, IDC_SHOW_BOOKMARK_MANAGER, IDS_BOOKMARK_MANAGER, 0, NULL, GDK_b, GDK_CONTROL_MASK | GDK_SHIFT_MASK }, { MENU_NORMAL, IDC_SHOW_DOWNLOADS, IDS_SHOW_DOWNLOADS, 0, NULL, GDK_j, GDK_CONTROL_MASK }, - { MENU_SEPARATOR, 0, 0, NULL }, + { MENU_SEPARATOR }, // TODO(erg): P13N stuff goes here as soon as they get IDS strings. - { MENU_NORMAL, IDC_CLEAR_BROWSING_DATA, IDS_CLEAR_BROWSING_DATA, 0, NULL }, - { MENU_NORMAL, IDC_IMPORT_SETTINGS, IDS_IMPORT_SETTINGS, 0, NULL }, - { MENU_SEPARATOR, 0, 0, 0, NULL }, - { MENU_NORMAL, IDC_OPTIONS, IDS_OPTIONS, IDS_PRODUCT_NAME, NULL }, - { MENU_NORMAL, IDC_ABOUT, IDS_ABOUT, IDS_PRODUCT_NAME, NULL }, - { MENU_NORMAL, IDC_HELP_PAGE, IDS_HELP_PAGE, 0, NULL, - GDK_F1, 0 }, - { MENU_SEPARATOR, 0, 0, 0, NULL }, - { MENU_NORMAL, IDC_EXIT, IDS_EXIT, 0, NULL }, - { MENU_END, 0, 0, 0, NULL } + { MENU_NORMAL, IDC_CLEAR_BROWSING_DATA, IDS_CLEAR_BROWSING_DATA }, + { MENU_NORMAL, IDC_IMPORT_SETTINGS, IDS_IMPORT_SETTINGS }, + { MENU_SEPARATOR }, + { MENU_NORMAL, IDC_OPTIONS, IDS_OPTIONS, IDS_PRODUCT_NAME }, + { MENU_NORMAL, IDC_ABOUT, IDS_ABOUT, IDS_PRODUCT_NAME }, + { MENU_NORMAL, IDC_HELP_PAGE, IDS_HELP_PAGE, 0, NULL, GDK_F1 }, + { MENU_SEPARATOR }, + { MENU_NORMAL, IDC_EXIT, IDS_EXIT }, + { MENU_END } }; } // namespace diff --git a/chrome/browser/gtk/standard_menus.h b/chrome/browser/gtk/standard_menus.h index e022fa0..e9ea047 100644 --- a/chrome/browser/gtk/standard_menus.h +++ b/chrome/browser/gtk/standard_menus.h @@ -41,6 +41,11 @@ struct MenuCreateMaterial { // GDK modifiers for the menu items (i.e., shift, ctrl, etc). unsigned int accel_modifiers; + + // If true, the accelerator is only for show (does not do anything), although + // the same key combination may be handled by GTK. Windows handles this in + // toolbar_view.cc::GetAcceleratorInfo(). + bool only_show; }; // Returns the menu construction data structure for the page menu. |