Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1139)

Unified Diff: chrome/browser/ui/gtk/global_menu_bar.cc

Issue 7017028: Revert "Revert 85330 - GTK: Bring global menu out of about:flags." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/gtk/global_menu_bar.h ('k') | chrome/browser/ui/gtk/global_menu_owner.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/gtk/global_menu_bar.cc
diff --git a/chrome/browser/ui/gtk/global_menu_bar.cc b/chrome/browser/ui/gtk/global_menu_bar.cc
index 6e6f9fdc077dd824b45fb202466252ed3548bf70..76ac9ba8611cb2ef55c478e61346e67efc49807f 100644
--- a/chrome/browser/ui/gtk/global_menu_bar.cc
+++ b/chrome/browser/ui/gtk/global_menu_bar.cc
@@ -56,24 +56,13 @@ GlobalMenuBarCommand file_menu[] = {
{ 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 },
@@ -83,8 +72,6 @@ GlobalMenuBarCommand edit_menu[] = {
{ 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 },
@@ -176,15 +163,15 @@ GlobalMenuBar::GlobalMenuBar(Browser* browser)
// Set a nice name so it shows up in gtkparasite and others.
gtk_widget_set_name(menu_bar_.get(), "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);
- history_menu_.Init(BuildGtkMenuFrom(IDS_HISTORY_MENU_LINUX, &id_to_menu_item_,
- history_menu));
- bookmark_menu_.Init(BuildGtkMenuFrom(IDS_BOOKMARKS_MENU_LINUX,
- &id_to_menu_item_, bookmark_menu));
- BuildGtkMenuFrom(IDS_TOOLS_MENU_LINUX, &id_to_menu_item_, tools_menu);
- BuildGtkMenuFrom(IDS_HELP_MENU_LINUX, &id_to_menu_item_, help_menu);
+ BuildGtkMenuFrom(IDS_FILE_MENU_LINUX, &id_to_menu_item_, file_menu, NULL);
+ BuildGtkMenuFrom(IDS_EDIT_MENU_LINUX, &id_to_menu_item_, edit_menu, NULL);
+ BuildGtkMenuFrom(IDS_VIEW_MENU_LINUX, &id_to_menu_item_, view_menu, NULL);
+ BuildGtkMenuFrom(IDS_HISTORY_MENU_LINUX, &id_to_menu_item_,
+ history_menu, &history_menu_);
+ BuildGtkMenuFrom(IDS_BOOKMARKS_MENU_LINUX, &id_to_menu_item_, bookmark_menu,
+ &bookmark_menu_);
+ BuildGtkMenuFrom(IDS_TOOLS_MENU_LINUX, &id_to_menu_item_, tools_menu, NULL);
+ BuildGtkMenuFrom(IDS_HELP_MENU_LINUX, &id_to_menu_item_, help_menu, NULL);
for (CommandIDMenuItemMap::const_iterator it = id_to_menu_item_.begin();
it != id_to_menu_item_.end(); ++it) {
@@ -226,10 +213,11 @@ GlobalMenuBar::~GlobalMenuBar() {
g_object_unref(dummy_accel_group_);
}
-GtkWidget* GlobalMenuBar::BuildGtkMenuFrom(
+void GlobalMenuBar::BuildGtkMenuFrom(
int menu_str_id,
std::map<int, GtkWidget*>* id_to_menu_item,
- GlobalMenuBarCommand* commands) {
+ GlobalMenuBarCommand* commands,
+ GlobalMenuOwner* owner) {
GtkWidget* menu = gtk_menu_new();
for (int i = 0; commands[i].str_id != MENU_END; ++i) {
GtkWidget* menu_item = BuildMenuItem(
@@ -243,11 +231,15 @@ GtkWidget* GlobalMenuBar::BuildGtkMenuFrom(
GtkWidget* menu_item = gtk_menu_item_new_with_mnemonic(
gfx::ConvertAcceleratorsFromWindowsStyle(
l10n_util::GetStringUTF8(menu_str_id)).c_str());
+
+ // Give the owner a chance to sink the reference before we add it to the menu
+ // bar.
+ if (owner)
+ owner->Init(menu, menu_item);
+
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_.get()), menu_item);
-
- return menu;
}
GtkWidget* GlobalMenuBar::BuildMenuItem(
« no previous file with comments | « chrome/browser/ui/gtk/global_menu_bar.h ('k') | chrome/browser/ui/gtk/global_menu_owner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698