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

Side by Side Diff: chrome/browser/ui/gtk/global_menu_bar.cc

Issue 7252001: GTK: Remove the global bookmarks menu. It can't be implemented efficiently. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove debugging code Created 9 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/gtk/global_menu_bar.h ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/gtk/global_menu_bar.h" 5 #include "chrome/browser/ui/gtk/global_menu_bar.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include "base/command_line.h"
9 #include "chrome/app/chrome_command_ids.h" 10 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/browser/prefs/pref_service.h" 11 #include "chrome/browser/prefs/pref_service.h"
11 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/gtk/accelerators_gtk.h" 14 #include "chrome/browser/ui/gtk/accelerators_gtk.h"
14 #include "chrome/browser/ui/gtk/gtk_theme_service.h" 15 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
15 #include "chrome/browser/ui/gtk/gtk_util.h" 16 #include "chrome/browser/ui/gtk/gtk_util.h"
17 #include "chrome/common/chrome_switches.h"
16 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
17 #include "content/common/notification_service.h" 19 #include "content/common/notification_service.h"
18 #include "grit/generated_resources.h" 20 #include "grit/generated_resources.h"
19 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
20 #include "ui/gfx/gtk_util.h" 22 #include "ui/gfx/gtk_util.h"
21 23
22 struct GlobalMenuBarCommand { 24 struct GlobalMenuBarCommand {
23 int str_id; 25 int str_id;
24 int command; 26 int command;
25 int tag; 27 int tag;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 { MENU_END, MENU_END } 147 { MENU_END, MENU_END }
146 }; 148 };
147 149
148 } // namespace 150 } // namespace
149 151
150 GlobalMenuBar::GlobalMenuBar(Browser* browser) 152 GlobalMenuBar::GlobalMenuBar(Browser* browser)
151 : browser_(browser), 153 : browser_(browser),
152 profile_(browser_->profile()), 154 profile_(browser_->profile()),
153 menu_bar_(gtk_menu_bar_new()), 155 menu_bar_(gtk_menu_bar_new()),
154 history_menu_(browser_), 156 history_menu_(browser_),
155 bookmark_menu_(browser_),
156 dummy_accel_group_(gtk_accel_group_new()), 157 dummy_accel_group_(gtk_accel_group_new()),
157 block_activation_(false) { 158 block_activation_(false) {
158 // The global menu bar should never actually be shown in the app; it should 159 // The global menu bar should never actually be shown in the app; it should
159 // instead remain in our widget hierarchy simply to be noticed by third party 160 // instead remain in our widget hierarchy simply to be noticed by third party
160 // components. 161 // components.
161 gtk_widget_set_no_show_all(menu_bar_.get(), TRUE); 162 gtk_widget_set_no_show_all(menu_bar_.get(), TRUE);
162 163
163 // Set a nice name so it shows up in gtkparasite and others. 164 // Set a nice name so it shows up in gtkparasite and others.
164 gtk_widget_set_name(menu_bar_.get(), "chrome-hidden-global-menubar"); 165 gtk_widget_set_name(menu_bar_.get(), "chrome-hidden-global-menubar");
165 166
166 BuildGtkMenuFrom(IDS_FILE_MENU_LINUX, &id_to_menu_item_, file_menu, NULL); 167 BuildGtkMenuFrom(IDS_FILE_MENU_LINUX, &id_to_menu_item_, file_menu, NULL);
167 BuildGtkMenuFrom(IDS_EDIT_MENU_LINUX, &id_to_menu_item_, edit_menu, NULL); 168 BuildGtkMenuFrom(IDS_EDIT_MENU_LINUX, &id_to_menu_item_, edit_menu, NULL);
168 BuildGtkMenuFrom(IDS_VIEW_MENU_LINUX, &id_to_menu_item_, view_menu, NULL); 169 BuildGtkMenuFrom(IDS_VIEW_MENU_LINUX, &id_to_menu_item_, view_menu, NULL);
169 BuildGtkMenuFrom(IDS_HISTORY_MENU_LINUX, &id_to_menu_item_, 170 BuildGtkMenuFrom(IDS_HISTORY_MENU_LINUX, &id_to_menu_item_,
170 history_menu, &history_menu_); 171 history_menu, &history_menu_);
171 BuildGtkMenuFrom(IDS_BOOKMARKS_MENU_LINUX, &id_to_menu_item_, bookmark_menu, 172
172 &bookmark_menu_); 173 if (CommandLine::ForCurrentProcess()->HasSwitch(
174 switches::kEnableGlobalBookmarkMenu)) {
175 // TODO(erg): dbusmenu-glib in Ubuntu Natty does not like it when we shove
176 // 100k or more of favicon data over it. Users have reported that the
177 // browser hangs on startup for over a minute and breaking during this time
178 // shows a stack entirely of dbus/glib code (See #86715). For now, just
179 // hide the menu until appmenu-gtk catches up and doesn't hang if we throw
180 // (potentially) megs of icon data at it. (Some of our users have thousands
181 // of bookmarks and we're already unacceptably laggy at 100.)
182 //
183 // http://crbug.com/86715, http://crbug.com/85466
184 bookmark_menu_.reset(new GlobalBookmarkMenu(browser_));
185 BuildGtkMenuFrom(IDS_BOOKMARKS_MENU_LINUX, &id_to_menu_item_, bookmark_menu,
186 bookmark_menu_.get());
187 }
188
173 BuildGtkMenuFrom(IDS_TOOLS_MENU_LINUX, &id_to_menu_item_, tools_menu, NULL); 189 BuildGtkMenuFrom(IDS_TOOLS_MENU_LINUX, &id_to_menu_item_, tools_menu, NULL);
174 BuildGtkMenuFrom(IDS_HELP_MENU_LINUX, &id_to_menu_item_, help_menu, NULL); 190 BuildGtkMenuFrom(IDS_HELP_MENU_LINUX, &id_to_menu_item_, help_menu, NULL);
175 191
176 for (CommandIDMenuItemMap::const_iterator it = id_to_menu_item_.begin(); 192 for (CommandIDMenuItemMap::const_iterator it = id_to_menu_item_.begin();
177 it != id_to_menu_item_.end(); ++it) { 193 it != id_to_menu_item_.end(); ++it) {
178 // Get the starting enabled state. 194 // Get the starting enabled state.
179 gtk_widget_set_sensitive( 195 gtk_widget_set_sensitive(
180 it->second, 196 it->second,
181 browser_->command_updater()->IsCommandEnabled(it->first)); 197 browser_->command_updater()->IsCommandEnabled(it->first));
182 198
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 } 320 }
305 } 321 }
306 322
307 void GlobalMenuBar::OnItemActivated(GtkWidget* sender) { 323 void GlobalMenuBar::OnItemActivated(GtkWidget* sender) {
308 if (block_activation_) 324 if (block_activation_)
309 return; 325 return;
310 326
311 int id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(sender), "command-id")); 327 int id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(sender), "command-id"));
312 browser_->ExecuteCommandIfEnabled(id); 328 browser_->ExecuteCommandIfEnabled(id);
313 } 329 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/global_menu_bar.h ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698