diff options
author | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-11 22:53:36 +0000 |
---|---|---|
committer | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-11 22:53:36 +0000 |
commit | 360d2ec2b1baa71f82f99cba96e4e97e74f6f941 (patch) | |
tree | dd04736de67bb0f322cadd99e36a13fb8aaf5335 | |
parent | 5f89b6570b214565e89301b652b95175fdf5b1c2 (diff) | |
download | chromium_src-360d2ec2b1baa71f82f99cba96e4e97e74f6f941.zip chromium_src-360d2ec2b1baa71f82f99cba96e4e97e74f6f941.tar.gz chromium_src-360d2ec2b1baa71f82f99cba96e4e97e74f6f941.tar.bz2 |
GTK: Implement rough global menu support behind an about:flags flag.
This is a super early first cut of global menu support. It works by creating a GtkMenuBar inside chrome, attaching it to the widget hierarchy and then never showing it. This is sufficient for global menu support to detect the menu, at least on the Natty betas.
There's a lot to do before this is considered done. I haven't added Bookmark and History menus, which will need custom handling to keep state up to date with the main window. Some items may need to be moved from one menu to another to fit with Linux conventions.
Contains a bunch of new strings for global menu support. These need to go in before the M12 branch point. (I can iterate on the design afterwards; strings need translation.)
BUG=30213
TEST=Open a window on Unity. A minimal menu is in the menu bar.
Review URL: http://codereview.chromium.org/6812037
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81170 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/generated_resources.grd | 77 | ||||
-rw-r--r-- | chrome/browser/about_flags.cc | 9 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/browser_window_gtk.cc | 10 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/browser_window_gtk.h | 5 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/global_menu_bar.cc | 258 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/global_menu_bar.h | 78 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 2 | ||||
-rw-r--r-- | chrome/common/chrome_switches.cc | 5 | ||||
-rw-r--r-- | chrome/common/chrome_switches.h | 4 | ||||
-rw-r--r-- | ui/base/models/accelerator_gtk.h | 2 |
10 files changed, 449 insertions, 1 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index f24a64ce..f113de8 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -4201,6 +4201,12 @@ Keep your key file in a safe place. You will need it to create new versions of y <message name="IDS_FLAGS_PPAPI_FLASH_IN_PROCESS_DESCRIPTION" desc="Description for the flag to run the custom flash in-process"> If the PPAPI version of Flash is in use, run it in each renderer process rather than in a dedicated plugin process. </message> + <message name="IDS_FLAGS_LINUX_GLOBAL_MENUBAR_NAME" desc="Title for the flag to show a global menu bar on linux."> + Experimental GNOME menu bar support. + </message> + <message name="IDS_FLAGS_LINUX_GLOBAL_MENUBAR_DESCRIPTION" desc="Description for the flag to show a global menu bar on linux."> + Newer versions of Unity and GNOME (including the upcoming Ubuntu Natty Narwhal) show an OSX style menubar across the top of the screen. + </message> <!-- Crashes --> <message name="IDS_CRASHES_TITLE" desc="Title for the chrome://crashes page."> @@ -9212,6 +9218,77 @@ Keep your key file in a safe place. You will need it to create new versions of y </message> </if> <!-- os == 'darwin' --> + <!-- Linux Global Menubar Menus --> + <if expr="os == 'linux2'"> + <!-- Unity and some other GNOME configurations now have a permanent, + Mac-like menu bar that lives outside the window at the top of the + screen. The following strings should be in Linux style, not Mac + style (i.e. have ampersand accelerators, be title cased, etc.) + + In general, the Linux UI will try to reuse other menu strings + since they are otherwise appropriate, but we do need a few + additional ones with different formatting. --> + + <!-- Menubar Menu Titles --> + <!-- NOTE: Some of these exist in context menus with Title Case support, but we use different IDs in case we need slightly different strings in some language due to the different context. --> + <message name="IDS_FILE_MENU_LINUX" desc="The menu title of the Linux file menu."> + &File + </message> + <message name="IDS_EDIT_MENU_LINUX" desc="The menu title of the Linux edit menu."> + &Edit + </message> + <message name="IDS_VIEW_MENU_LINUX" desc="The menu title of the Linux view menu."> + &View + </message> + <message name="IDS_HISTORY_MENU_LINUX" desc="The menu title of the Linux history menu."> + Hi&story + </message> + <message name="IDS_BOOKMARKS_MENU_LINUX" desc="The menu title of the Linux bookmarks menu."> + &Bookmarks + </message> + <message name="IDS_TOOLS_MENU_LINUX" desc="The menu title of the Linux tools menu."> + &Tools + </message> + <message name="IDS_HELP_MENU_LINUX" desc="The menu title of the Linux help menu."> + &Help + </message> + + <!-- File menu items that we can't reuse. --> + <message name="IDS_REOPEN_CLOSED_TABS_LINUX" desc="The Linux menu item reopen recently closed tabs in the file menu."> + Reopen Closed Tab + </message> + <message name="IDS_OPEN_FILE_LINUX" desc="The Linux menu item to open a file in the file menu."> + Open &File... + </message> + <message name="IDS_OPEN_LOCATION_LINUX" desc="The Linux menu item to open a location in the file menu (puts cursor in the url bar)."> + Open &Location... + </message> + <message name="IDS_CLOSE_WINDOW_LINUX" desc="The Linux menu item to close a window in the file menu."> + Close Win&dow + </message> + <message name="IDS_CLOSE_TAB_LINUX" desc="The Linux menu item to close a browser tab in the file menu."> + &Close Tab + </message> + + <!-- View menu items that we can't reuse. --> + <message name="IDS_STOP_MENU_LINUX" desc="The Linux menu item stop in the view menu."> + &Stop + </message> + <message name="IDS_RELOAD_MENU_LINUX" desc="The Linux menu item to reload the current page in the view menu."> + &Reload This Page + </message> + <message name="IDS_TEXT_DEFAULT_LINUX" desc="The Linux menu item to make the page actual size in the view menu."> + A&ctual Size + </message> + <message name="IDS_TEXT_BIGGER_LINUX" desc="The Linux menu item to zoom in on the page in the view menu."> + Zoom &In + </message> + <message name="IDS_TEXT_SMALLER_LINUX" desc="The Linux menu item to zoom out on the in the view menu."> + Zoom &Out + </message> + + </if> + <!-- File chooser dialog default titles (only used on Linux) --> <message name="IDS_SELECT_FOLDER_DIALOG_TITLE" desc="The default title for the Select Folder file chooser dialog."> Select Folder diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index 504b1b4..477896b 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -288,6 +288,15 @@ const Experiment kExperiments[] = { kOsAll, SINGLE_VALUE_TYPE(switches::kPpapiFlashInProcess) }, +#if defined(TOOLKIT_GTK) + { + "global-gnome-menu", + IDS_FLAGS_LINUX_GLOBAL_MENUBAR_NAME, + IDS_FLAGS_LINUX_GLOBAL_MENUBAR_DESCRIPTION, + kOsLinux, + SINGLE_VALUE_TYPE(switches::kGlobalGnomeMenu) + }, +#endif }; const Experiment* experiments = kExperiments; diff --git a/chrome/browser/ui/gtk/browser_window_gtk.cc b/chrome/browser/ui/gtk/browser_window_gtk.cc index 4a65ade..b003bc6 100644 --- a/chrome/browser/ui/gtk/browser_window_gtk.cc +++ b/chrome/browser/ui/gtk/browser_window_gtk.cc @@ -52,6 +52,7 @@ #include "chrome/browser/ui/gtk/edit_search_engine_dialog.h" #include "chrome/browser/ui/gtk/find_bar_gtk.h" #include "chrome/browser/ui/gtk/fullscreen_exit_bubble_gtk.h" +#include "chrome/browser/ui/gtk/global_menu_bar.h" #include "chrome/browser/ui/gtk/gtk_floating_container.h" #include "chrome/browser/ui/gtk/gtk_theme_service.h" #include "chrome/browser/ui/gtk/gtk_util.h" @@ -1580,6 +1581,15 @@ void BrowserWindowGtk::InitWidgets() { window_vbox_ = gtk_vbox_new(FALSE, 0); gtk_widget_show(window_vbox_); + // We hold an always hidden GtkMenuBar inside our browser window simply to + // fool the Unity desktop, which will mirror the contents of the first + // GtkMenuBar it sees into the global menu bar. (It doesn't seem to check the + // visibility of the GtkMenuBar, so we can just permanently hide it.) + if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGlobalGnomeMenu)) { + global_menu_bar_.reset(new GlobalMenuBar(browser_.get(), this)); + gtk_container_add(GTK_CONTAINER(window_vbox_), global_menu_bar_->widget()); + } + // The window container draws the custom browser frame. window_container_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); gtk_widget_set_name(window_container_, "chrome-custom-frame-border"); diff --git a/chrome/browser/ui/gtk/browser_window_gtk.h b/chrome/browser/ui/gtk/browser_window_gtk.h index d7509bb..8c8ef49 100644 --- a/chrome/browser/ui/gtk/browser_window_gtk.h +++ b/chrome/browser/ui/gtk/browser_window_gtk.h @@ -31,6 +31,7 @@ class CustomDrawButton; class DownloadShelfGtk; class FindBarGtk; class FullscreenExitBubbleGtk; +class GlobalMenuBar; class InfoBarContainerGtk; class LocationBar; class StatusBubbleGtk; @@ -428,6 +429,10 @@ class BrowserWindowGtk : public BrowserWindow, GdkWindowState state_; + // Controls a hidden GtkMenuBar that we keep updated so GNOME can take a look + // inside "our menu bar" and present it in the top panel, akin to Mac OS. + scoped_ptr<GlobalMenuBar> global_menu_bar_; + // The container for the titlebar + tab strip. scoped_ptr<BrowserTitlebar> titlebar_; diff --git a/chrome/browser/ui/gtk/global_menu_bar.cc b/chrome/browser/ui/gtk/global_menu_bar.cc new file mode 100644 index 0000000..6442e41 --- /dev/null +++ b/chrome/browser/ui/gtk/global_menu_bar.cc @@ -0,0 +1,258 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/ui/gtk/global_menu_bar.h" + +#include <gtk/gtk.h> + +#include "chrome/app/chrome_command_ids.h" +#include "chrome/browser/prefs/pref_service.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/gtk/accelerators_gtk.h" +#include "chrome/common/pref_names.h" +#include "content/common/notification_service.h" +#include "grit/generated_resources.h" +#include "ui/base/l10n/l10n_util.h" +#include "ui/gfx/gtk_util.h" + +struct GlobalMenuBarCommand { + int str_id; + int command; +}; + +namespace { + +const int MENU_SEPARATOR =-1; +const int MENU_END = -2; + +GlobalMenuBarCommand file_menu[] = { + { IDS_NEW_TAB, IDC_NEW_TAB }, + { IDS_NEW_WINDOW, IDC_NEW_WINDOW }, + { IDS_NEW_INCOGNITO_WINDOW, IDC_NEW_INCOGNITO_WINDOW }, + { IDS_REOPEN_CLOSED_TABS_LINUX, IDC_RESTORE_TAB }, + { IDS_OPEN_FILE_LINUX, IDC_OPEN_FILE }, + { IDS_OPEN_LOCATION_LINUX, IDC_FOCUS_LOCATION }, + + { MENU_SEPARATOR, MENU_SEPARATOR }, + + { IDS_CREATE_SHORTCUTS, IDC_CREATE_SHORTCUTS }, + + { MENU_SEPARATOR, MENU_SEPARATOR }, + + { IDS_CLOSE_WINDOW_LINUX, IDC_CLOSE_WINDOW }, + { IDS_CLOSE_TAB_LINUX, IDC_CLOSE_TAB }, + { IDS_SAVE_PAGE, IDC_SAVE_PAGE }, + + { MENU_SEPARATOR, MENU_SEPARATOR }, + + { IDS_PRINT, IDC_PRINT }, + + { MENU_END, MENU_END } +}; + +// TODO(erg): Need to add support for undo/redo/other editing commands that +// don't go through the command id framework. +GlobalMenuBarCommand edit_menu[] = { + // TODO(erg): Undo + // TODO(erg): Redo + + // TODO(erg): Separator + + { IDS_CUT, IDC_CUT }, + { IDS_COPY, IDC_COPY }, + { IDS_PASTE, IDC_PASTE }, + // TODO(erg): Delete + + { MENU_SEPARATOR, MENU_SEPARATOR }, + + // TODO(erg): Select All + // TODO(erg): Another separator + + { IDS_FIND, IDC_FIND }, + + { MENU_SEPARATOR, MENU_SEPARATOR }, + + { IDS_PREFERENCES, IDC_OPTIONS }, + + { MENU_END, MENU_END } +}; + +// TODO(erg): The View menu should be overhauled and based on the Firefox view +// menu. +GlobalMenuBarCommand view_menu[] = { + { IDS_SHOW_BOOKMARK_BAR, IDC_SHOW_BOOKMARK_BAR }, + + { MENU_SEPARATOR, MENU_SEPARATOR }, + + { IDS_STOP_MENU_LINUX, IDC_STOP }, + { IDS_RELOAD_MENU_LINUX, IDC_RELOAD }, + + { MENU_SEPARATOR, MENU_SEPARATOR }, + + { IDS_FULLSCREEN, IDC_FULLSCREEN }, + { IDS_TEXT_DEFAULT_LINUX, IDC_ZOOM_NORMAL }, + { IDS_TEXT_BIGGER_LINUX, IDC_ZOOM_PLUS }, + { IDS_TEXT_SMALLER_LINUX, IDC_ZOOM_MINUS }, + + { MENU_END, MENU_END } +}; + +GlobalMenuBarCommand tools_menu[] = { + { IDS_SHOW_DOWNLOADS, IDC_SHOW_DOWNLOADS }, + { IDS_SHOW_HISTORY, IDC_SHOW_HISTORY }, + { IDS_SHOW_EXTENSIONS, IDC_MANAGE_EXTENSIONS }, + + { MENU_SEPARATOR, MENU_SEPARATOR }, + + { IDS_TASK_MANAGER, IDC_TASK_MANAGER }, + { IDS_CLEAR_BROWSING_DATA, IDC_CLEAR_BROWSING_DATA }, + + { MENU_SEPARATOR, MENU_SEPARATOR }, + + { IDS_VIEW_SOURCE, IDC_VIEW_SOURCE }, + { IDS_DEV_TOOLS, IDC_DEV_TOOLS }, + { IDS_DEV_TOOLS_CONSOLE, IDC_DEV_TOOLS_CONSOLE }, + + { MENU_END, MENU_END } +}; + +GlobalMenuBarCommand help_menu[] = { + { IDS_FEEDBACK, IDC_FEEDBACK }, + { IDS_HELP_PAGE , IDC_HELP_PAGE }, + { MENU_END, MENU_END } +}; + +} // namespace + +GlobalMenuBar::GlobalMenuBar(Browser* browser, + BrowserWindowGtk* window) + : browser_(browser), + browser_window_(window), + menu_bar_(gtk_menu_bar_new()), + dummy_accel_group_(gtk_accel_group_new()), + block_activation_(false) { + // The global menu bar should never actually be shown in the app; it should + // instead remain in our widget hierarchy simply to be noticed by third party + // components. + gtk_widget_set_no_show_all(menu_bar_, TRUE); + + // Set a nice name so it shows up in gtkparasite and others. + gtk_widget_set_name(menu_bar_, "chrome-hidden-global-menubar"); + + BuildGtkMenuFrom(IDS_FILE_MENU_LINUX, &id_to_menu_item_, file_menu); + BuildGtkMenuFrom(IDS_EDIT_MENU_LINUX, &id_to_menu_item_, edit_menu); + BuildGtkMenuFrom(IDS_VIEW_MENU_LINUX, &id_to_menu_item_, view_menu); + BuildGtkMenuFrom(IDS_TOOLS_MENU_LINUX, &id_to_menu_item_, tools_menu); + BuildGtkMenuFrom(IDS_HELP_MENU_LINUX, &id_to_menu_item_, help_menu); + + for (IDMenuItemMap::const_iterator it = id_to_menu_item_.begin(); + it != id_to_menu_item_.end(); ++it) { + // Get the starting enabled state. + gtk_widget_set_sensitive( + it->second, + browser_->command_updater()->IsCommandEnabled(it->first)); + + // Set the accelerator for each menu item. + const ui::AcceleratorGtk* accelerator_gtk = + AcceleratorsGtk::GetInstance()->GetPrimaryAcceleratorForCommand( + it->first); + if (accelerator_gtk) { + gtk_widget_add_accelerator(it->second, + "activate", + dummy_accel_group_, + accelerator_gtk->GetGdkKeyCode(), + accelerator_gtk->gdk_modifier_type(), + GTK_ACCEL_VISIBLE); + } + + browser_->command_updater()->AddCommandObserver(it->first, this); + } + + // Listen for bookmark bar visibility changes and set the initial state. + registrar_.Add(this, NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED, + NotificationService::AllSources()); + Observe(NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED, + NotificationService::AllSources(), + NotificationService::NoDetails()); +} + +GlobalMenuBar::~GlobalMenuBar() { + for (IDMenuItemMap::const_iterator it = id_to_menu_item_.begin(); + it != id_to_menu_item_.end(); ++it) { + browser_->command_updater()->RemoveCommandObserver(it->first, this); + } + + g_object_unref(dummy_accel_group_); +} + +void GlobalMenuBar::BuildGtkMenuFrom(int menu_str_id, + std::map<int, GtkWidget*>* id_to_menu_item, + GlobalMenuBarCommand* commands) { + GtkWidget* menu = gtk_menu_new(); + for (int i = 0; commands[i].str_id != MENU_END; ++i) { + GtkWidget* menu_item = NULL; + if (commands[i].str_id == MENU_SEPARATOR) { + menu_item = gtk_separator_menu_item_new(); + } else { + int command_id = commands[i].command; + std::string label = + gfx::ConvertAcceleratorsFromWindowsStyle( + l10n_util::GetStringUTF8(commands[i].str_id)); + + if (command_id == IDC_SHOW_BOOKMARK_BAR) + menu_item = gtk_check_menu_item_new_with_mnemonic(label.c_str()); + else + menu_item = gtk_menu_item_new_with_mnemonic(label.c_str()); + + id_to_menu_item->insert(std::make_pair(command_id, menu_item)); + g_object_set_data(G_OBJECT(menu_item), "command-id", + GINT_TO_POINTER(command_id)); + g_signal_connect(menu_item, "activate", + G_CALLBACK(OnItemActivatedThunk), this); + } + gtk_widget_show(menu_item); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item); + } + + gtk_widget_show(menu); + + GtkWidget* menu_item = gtk_menu_item_new_with_mnemonic( + gfx::ConvertAcceleratorsFromWindowsStyle( + l10n_util::GetStringUTF8(menu_str_id)).c_str()); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), menu); + gtk_widget_show(menu_item); + + gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar_), menu_item); +} + +void GlobalMenuBar::EnabledStateChangedForCommand(int id, bool enabled) { + IDMenuItemMap::iterator it = id_to_menu_item_.find(id); + if (it != id_to_menu_item_.end()) + gtk_widget_set_sensitive(it->second, enabled); +} + +void GlobalMenuBar::Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details) { + DCHECK(type.value == NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED); + + IDMenuItemMap::iterator it = id_to_menu_item_.find(IDC_SHOW_BOOKMARK_BAR); + if (it != id_to_menu_item_.end()) { + PrefService* prefs = browser_->profile()->GetPrefs(); + + block_activation_ = true; + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(it->second), + prefs->GetBoolean(prefs::kShowBookmarkBar)); + block_activation_ = false; + } +} + +void GlobalMenuBar::OnItemActivated(GtkWidget* sender) { + if (block_activation_) + return; + + int id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(sender), "command-id")); + browser_->ExecuteCommandIfEnabled(id); +} diff --git a/chrome/browser/ui/gtk/global_menu_bar.h b/chrome/browser/ui/gtk/global_menu_bar.h new file mode 100644 index 0000000..5ff88e7 --- /dev/null +++ b/chrome/browser/ui/gtk/global_menu_bar.h @@ -0,0 +1,78 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_GTK_GLOBAL_MENU_BAR_H_ +#define CHROME_BROWSER_UI_GTK_GLOBAL_MENU_BAR_H_ + +#include <map> + +#include "chrome/browser/command_updater.h" +#include "content/common/notification_observer.h" +#include "content/common/notification_registrar.h" +#include "ui/base/gtk/gtk_signal.h" + +class Browser; +class BrowserWindowGtk; +struct GlobalMenuBarCommand; + +typedef struct _GtkAccelGroup GtkAccelGroup; +typedef struct _GtkWidget GtkWidget; + +// Controls the Mac style menu bar on Linux. +// +// Unity and some configurations of GNOME have a Apple-like menu bar at the top +// of the screen that changes depending on the active window. These mainly work +// by inspecting the application's widget hierarchy, and intercepting any +// GtkMenuBar found. Thankfully, these systems don't check to see if the menu +// bar itself is visible, so we insert a GtkMenuBar into the window hierarchy +// and set it to be invisible. +class GlobalMenuBar : public CommandUpdater::CommandObserver, + public NotificationObserver { + public: + GlobalMenuBar(Browser* browser, BrowserWindowGtk* window); + virtual ~GlobalMenuBar(); + + GtkWidget* widget() { return menu_bar_; } + + private: + typedef std::map<int, GtkWidget*> IDMenuItemMap; + + // Helper function that builds the data. + void BuildGtkMenuFrom(int menu_str_id, + std::map<int, GtkWidget*>* id_to_menu_item, + GlobalMenuBarCommand* commands); + + // CommandUpdater::CommandObserver: + virtual void EnabledStateChangedForCommand(int id, bool enabled); + + // NotificationObserver: + virtual void Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details); + + CHROMEGTK_CALLBACK_0(GlobalMenuBar, void, OnItemActivated); + + Browser* browser_; + BrowserWindowGtk* browser_window_; + + NotificationRegistrar registrar_; + + // Our menu bar widget. + GtkWidget* menu_bar_; + + // 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_; + + // A mapping from command ids to GtkMenuItem objects. We use this to update + // the enable state since we are a . + IDMenuItemMap id_to_menu_item_; + + // gtk_check_menu_item_set_active() will call the "activate" signal. We need + // to block this activation while we change the checked state. + bool block_activation_; +}; + +#endif // CHROME_BROWSER_UI_GTK_GLOBAL_MENU_BAR_H_ diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 656731f..281227f1 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -2583,6 +2583,8 @@ 'browser/ui/gtk/fullscreen_exit_bubble_gtk.h', 'browser/ui/gtk/gconf_titlebar_listener.cc', 'browser/ui/gtk/gconf_titlebar_listener.h', + 'browser/ui/gtk/global_menu_bar.cc', + 'browser/ui/gtk/global_menu_bar.h', 'browser/ui/gtk/gtk_chrome_button.cc', 'browser/ui/gtk/gtk_chrome_button.h', 'browser/ui/gtk/gtk_chrome_cookie_view.cc', diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index 7b19051..82a4ab9 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -1185,6 +1185,11 @@ const char kEnableExposeForTabs[] = "enable-expose-for-tabs"; const char kKioskMode[] = "kiosk"; #endif +// Enables the experimental global gnome menu. +#if defined(TOOLKIT_GTK) +extern const char kGlobalGnomeMenu[] = "global-gnome-menu"; +#endif + // Enables debug paint in views framework. Enabling this causes the damaged // region being painted to flash in red. #if defined(TOOLKIT_VIEWS) diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 1c6de1f..582c41d 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -346,6 +346,10 @@ extern const char kEnableExposeForTabs[]; extern const char kKioskMode[]; #endif +#if defined(TOOLKIT_GTK) +extern const char kGlobalGnomeMenu[]; +#endif + #if defined(TOOLKIT_VIEWS) extern const char kDebugViewsPaint[]; #endif diff --git a/ui/base/models/accelerator_gtk.h b/ui/base/models/accelerator_gtk.h index c38abb2..720e291 100644 --- a/ui/base/models/accelerator_gtk.h +++ b/ui/base/models/accelerator_gtk.h @@ -45,7 +45,7 @@ class AcceleratorGtk : public Accelerator { gdk_keyval_ : ui::GdkKeyCodeForWindowsKeyCode(key_code_, false); } - GdkModifierType gdk_modifier_type() { + GdkModifierType gdk_modifier_type() const { return static_cast<GdkModifierType>(modifiers()); } |