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

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

Issue 6980011: GTK: Implement the global bookmarks menu. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 'GlobalBookmarkMenu' 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/gtk/global_menu_bar.h ('k') | chrome/chrome_browser.gypi » ('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 "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/browser/prefs/pref_service.h" 10 #include "chrome/browser/prefs/pref_service.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 { IDS_SHOWFULLHISTORY_LINK, IDC_SHOW_HISTORY }, 123 { IDS_SHOWFULLHISTORY_LINK, IDC_SHOW_HISTORY },
124 124
125 { MENU_END, MENU_END } 125 { MENU_END, MENU_END }
126 }; 126 };
127 127
128 GlobalMenuBarCommand bookmark_menu[] = { 128 GlobalMenuBarCommand bookmark_menu[] = {
129 { IDS_BOOKMARK_MANAGER, IDC_SHOW_BOOKMARK_MANAGER }, 129 { IDS_BOOKMARK_MANAGER, IDC_SHOW_BOOKMARK_MANAGER },
130 { IDS_BOOKMARK_CURRENT_PAGE_LINUX, IDC_BOOKMARK_PAGE }, 130 { IDS_BOOKMARK_CURRENT_PAGE_LINUX, IDC_BOOKMARK_PAGE },
131 { IDS_BOOKMARK_ALL_TABS_LINUX, IDC_BOOKMARK_ALL_TABS }, 131 { IDS_BOOKMARK_ALL_TABS_LINUX, IDC_BOOKMARK_ALL_TABS },
132 132
133 { MENU_SEPARATOR, MENU_SEPARATOR },
134 // TODO(erg): Real implementation of bookmark bar bookmarks!
135 { MENU_SEPARATOR, MENU_SEPARATOR },
136
137 { IDS_BOOMARK_BAR_OPEN_ALL, IDC_BOOKMARK_BAR_OPEN_ALL },
138 { IDS_BOOMARK_BAR_OPEN_ALL_NEW_WINDOW, IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW },
139 { IDS_BOOMARK_BAR_OPEN_ALL_INCOGNITO, IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO },
140
141 { MENU_SEPARATOR, MENU_SEPARATOR },
142 // TODO(erg): "Other bookmarks" bookmarks
143
144 { MENU_END, MENU_END } 133 { MENU_END, MENU_END }
145 }; 134 };
146 135
147 GlobalMenuBarCommand tools_menu[] = { 136 GlobalMenuBarCommand tools_menu[] = {
148 { IDS_SHOW_DOWNLOADS, IDC_SHOW_DOWNLOADS }, 137 { IDS_SHOW_DOWNLOADS, IDC_SHOW_DOWNLOADS },
149 { IDS_SHOW_HISTORY, IDC_SHOW_HISTORY }, 138 { IDS_SHOW_HISTORY, IDC_SHOW_HISTORY },
150 { IDS_SHOW_EXTENSIONS, IDC_MANAGE_EXTENSIONS }, 139 { IDS_SHOW_EXTENSIONS, IDC_MANAGE_EXTENSIONS },
151 140
152 { MENU_SEPARATOR, MENU_SEPARATOR }, 141 { MENU_SEPARATOR, MENU_SEPARATOR },
153 142
(...skipping 15 matching lines...) Expand all
169 { MENU_END, MENU_END } 158 { MENU_END, MENU_END }
170 }; 159 };
171 160
172 } // namespace 161 } // namespace
173 162
174 GlobalMenuBar::GlobalMenuBar(Browser* browser) 163 GlobalMenuBar::GlobalMenuBar(Browser* browser)
175 : browser_(browser), 164 : browser_(browser),
176 profile_(browser_->profile()), 165 profile_(browser_->profile()),
177 menu_bar_(gtk_menu_bar_new()), 166 menu_bar_(gtk_menu_bar_new()),
178 history_menu_(browser_), 167 history_menu_(browser_),
168 bookmark_menu_(browser_),
179 dummy_accel_group_(gtk_accel_group_new()), 169 dummy_accel_group_(gtk_accel_group_new()),
180 block_activation_(false) { 170 block_activation_(false) {
181 // The global menu bar should never actually be shown in the app; it should 171 // The global menu bar should never actually be shown in the app; it should
182 // instead remain in our widget hierarchy simply to be noticed by third party 172 // instead remain in our widget hierarchy simply to be noticed by third party
183 // components. 173 // components.
184 gtk_widget_set_no_show_all(menu_bar_.get(), TRUE); 174 gtk_widget_set_no_show_all(menu_bar_.get(), TRUE);
185 175
186 // Set a nice name so it shows up in gtkparasite and others. 176 // Set a nice name so it shows up in gtkparasite and others.
187 gtk_widget_set_name(menu_bar_.get(), "chrome-hidden-global-menubar"); 177 gtk_widget_set_name(menu_bar_.get(), "chrome-hidden-global-menubar");
188 178
189 BuildGtkMenuFrom(IDS_FILE_MENU_LINUX, &id_to_menu_item_, file_menu); 179 BuildGtkMenuFrom(IDS_FILE_MENU_LINUX, &id_to_menu_item_, file_menu);
190 BuildGtkMenuFrom(IDS_EDIT_MENU_LINUX, &id_to_menu_item_, edit_menu); 180 BuildGtkMenuFrom(IDS_EDIT_MENU_LINUX, &id_to_menu_item_, edit_menu);
191 BuildGtkMenuFrom(IDS_VIEW_MENU_LINUX, &id_to_menu_item_, view_menu); 181 BuildGtkMenuFrom(IDS_VIEW_MENU_LINUX, &id_to_menu_item_, view_menu);
192 history_menu_.Init(BuildGtkMenuFrom(IDS_HISTORY_MENU_LINUX, &id_to_menu_item_, 182 history_menu_.Init(BuildGtkMenuFrom(IDS_HISTORY_MENU_LINUX, &id_to_menu_item_,
193 history_menu)); 183 history_menu));
194 BuildGtkMenuFrom(IDS_BOOKMARKS_MENU_LINUX, &id_to_menu_item_, bookmark_menu); 184 bookmark_menu_.Init(BuildGtkMenuFrom(IDS_BOOKMARKS_MENU_LINUX,
185 &id_to_menu_item_, bookmark_menu));
195 BuildGtkMenuFrom(IDS_TOOLS_MENU_LINUX, &id_to_menu_item_, tools_menu); 186 BuildGtkMenuFrom(IDS_TOOLS_MENU_LINUX, &id_to_menu_item_, tools_menu);
196 BuildGtkMenuFrom(IDS_HELP_MENU_LINUX, &id_to_menu_item_, help_menu); 187 BuildGtkMenuFrom(IDS_HELP_MENU_LINUX, &id_to_menu_item_, help_menu);
197 188
198 for (CommandIDMenuItemMap::const_iterator it = id_to_menu_item_.begin(); 189 for (CommandIDMenuItemMap::const_iterator it = id_to_menu_item_.begin();
199 it != id_to_menu_item_.end(); ++it) { 190 it != id_to_menu_item_.end(); ++it) {
200 // Get the starting enabled state. 191 // Get the starting enabled state.
201 gtk_widget_set_sensitive( 192 gtk_widget_set_sensitive(
202 it->second, 193 it->second,
203 browser_->command_updater()->IsCommandEnabled(it->first)); 194 browser_->command_updater()->IsCommandEnabled(it->first));
204 195
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 } 312 }
322 } 313 }
323 314
324 void GlobalMenuBar::OnItemActivated(GtkWidget* sender) { 315 void GlobalMenuBar::OnItemActivated(GtkWidget* sender) {
325 if (block_activation_) 316 if (block_activation_)
326 return; 317 return;
327 318
328 int id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(sender), "command-id")); 319 int id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(sender), "command-id"));
329 browser_->ExecuteCommandIfEnabled(id); 320 browser_->ExecuteCommandIfEnabled(id);
330 } 321 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/global_menu_bar.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698