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

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

Issue 10316013: linux: Move linux_util.h from gfx/ to ui/base/gtk. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: LinuxUtilTest -> MenuLabelAcceleratorTest Created 8 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/certificate_viewer_gtk.cc ('k') | chrome/browser/ui/gtk/gtk_util.cc » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/command_line.h"
10 #include "chrome/app/chrome_command_ids.h" 10 #include "chrome/app/chrome_command_ids.h"
11 #include "chrome/browser/prefs/pref_service.h" 11 #include "chrome/browser/prefs/pref_service.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/gtk/accelerators_gtk.h" 14 #include "chrome/browser/ui/gtk/accelerators_gtk.h"
15 #include "chrome/browser/ui/gtk/gtk_theme_service.h" 15 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
16 #include "chrome/browser/ui/gtk/gtk_util.h" 16 #include "chrome/browser/ui/gtk/gtk_util.h"
17 #include "chrome/common/chrome_notification_types.h" 17 #include "chrome/common/chrome_notification_types.h"
18 #include "chrome/common/chrome_switches.h" 18 #include "chrome/common/chrome_switches.h"
19 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
20 #include "content/public/browser/notification_details.h" 20 #include "content/public/browser/notification_details.h"
21 #include "content/public/browser/notification_source.h" 21 #include "content/public/browser/notification_source.h"
22 #include "grit/generated_resources.h" 22 #include "grit/generated_resources.h"
23 #include "ui/base/gtk/menu_label_accelerator_util.h"
23 #include "ui/base/l10n/l10n_util.h" 24 #include "ui/base/l10n/l10n_util.h"
24 #include "ui/gfx/linux_util.h"
25 25
26 struct GlobalMenuBarCommand { 26 struct GlobalMenuBarCommand {
27 int str_id; 27 int str_id;
28 int command; 28 int command;
29 int tag; 29 int tag;
30 }; 30 };
31 31
32 namespace { 32 namespace {
33 33
34 const int MENU_SEPARATOR =-1; 34 const int MENU_SEPARATOR =-1;
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 for (int i = 0; commands[i].str_id != MENU_END; ++i) { 218 for (int i = 0; commands[i].str_id != MENU_END; ++i) {
219 GtkWidget* menu_item = BuildMenuItem( 219 GtkWidget* menu_item = BuildMenuItem(
220 commands[i].str_id, commands[i].command, commands[i].tag, 220 commands[i].str_id, commands[i].command, commands[i].tag,
221 id_to_menu_item, menu); 221 id_to_menu_item, menu);
222 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item); 222 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
223 } 223 }
224 224
225 gtk_widget_show(menu); 225 gtk_widget_show(menu);
226 226
227 GtkWidget* menu_item = gtk_menu_item_new_with_mnemonic( 227 GtkWidget* menu_item = gtk_menu_item_new_with_mnemonic(
228 gfx::RemoveWindowsStyleAccelerators( 228 ui::RemoveWindowsStyleAccelerators(
229 l10n_util::GetStringUTF8(menu_str_id)).c_str()); 229 l10n_util::GetStringUTF8(menu_str_id)).c_str());
230 230
231 // Give the owner a chance to sink the reference before we add it to the menu 231 // Give the owner a chance to sink the reference before we add it to the menu
232 // bar. 232 // bar.
233 if (owner) 233 if (owner)
234 owner->Init(menu, menu_item); 234 owner->Init(menu, menu_item);
235 235
236 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), menu); 236 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), menu);
237 gtk_widget_show(menu_item); 237 gtk_widget_show(menu_item);
238 gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar_.get()), menu_item); 238 gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar_.get()), menu_item);
239 } 239 }
240 240
241 GtkWidget* GlobalMenuBar::BuildMenuItem( 241 GtkWidget* GlobalMenuBar::BuildMenuItem(
242 int string_id, 242 int string_id,
243 int command_id, 243 int command_id,
244 int tag_id, 244 int tag_id,
245 std::map<int, GtkWidget*>* id_to_menu_item, 245 std::map<int, GtkWidget*>* id_to_menu_item,
246 GtkWidget* menu_to_add_to) { 246 GtkWidget* menu_to_add_to) {
247 GtkWidget* menu_item = NULL; 247 GtkWidget* menu_item = NULL;
248 if (string_id == MENU_SEPARATOR) { 248 if (string_id == MENU_SEPARATOR) {
249 menu_item = gtk_separator_menu_item_new(); 249 menu_item = gtk_separator_menu_item_new();
250 } else { 250 } else {
251 std::string label = 251 std::string label = ui::ConvertAcceleratorsFromWindowsStyle(
252 gfx::ConvertAcceleratorsFromWindowsStyle( 252 l10n_util::GetStringUTF8(string_id));
253 l10n_util::GetStringUTF8(string_id));
254 253
255 if (command_id == IDC_SHOW_BOOKMARK_BAR) 254 if (command_id == IDC_SHOW_BOOKMARK_BAR)
256 menu_item = gtk_check_menu_item_new_with_mnemonic(label.c_str()); 255 menu_item = gtk_check_menu_item_new_with_mnemonic(label.c_str());
257 else 256 else
258 menu_item = gtk_menu_item_new_with_mnemonic(label.c_str()); 257 menu_item = gtk_menu_item_new_with_mnemonic(label.c_str());
259 258
260 if (tag_id) { 259 if (tag_id) {
261 g_object_set_data(G_OBJECT(menu_item), "type-tag", 260 g_object_set_data(G_OBJECT(menu_item), "type-tag",
262 GINT_TO_POINTER(tag_id)); 261 GINT_TO_POINTER(tag_id));
263 } 262 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 } 303 }
305 } 304 }
306 305
307 void GlobalMenuBar::OnItemActivated(GtkWidget* sender) { 306 void GlobalMenuBar::OnItemActivated(GtkWidget* sender) {
308 if (block_activation_) 307 if (block_activation_)
309 return; 308 return;
310 309
311 int id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(sender), "command-id")); 310 int id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(sender), "command-id"));
312 browser_->ExecuteCommandIfEnabled(id); 311 browser_->ExecuteCommandIfEnabled(id);
313 } 312 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/certificate_viewer_gtk.cc ('k') | chrome/browser/ui/gtk/gtk_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698