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

Side by Side Diff: views/controls/menu/native_menu_gtk.cc

Issue 3354005: Re-lands 58186: (Closed)
Patch Set: Created 10 years, 3 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
« no previous file with comments | « views/controls/menu/menu_win.cc ('k') | views/controls/menu/native_menu_win.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "views/controls/menu/native_menu_gtk.h" 5 #include "views/controls/menu/native_menu_gtk.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "app/keyboard_code_conversion_gtk.h"
12 #include "app/keyboard_codes.h"
11 #include "app/menus/menu_model.h" 13 #include "app/menus/menu_model.h"
12 #include "base/gtk_util.h" 14 #include "base/gtk_util.h"
13 #include "base/i18n/rtl.h" 15 #include "base/i18n/rtl.h"
14 #include "base/keyboard_code_conversion_gtk.h"
15 #include "base/keyboard_codes.h"
16 #include "base/message_loop.h" 16 #include "base/message_loop.h"
17 #include "base/time.h" 17 #include "base/time.h"
18 #include "base/utf_string_conversions.h" 18 #include "base/utf_string_conversions.h"
19 #include "gfx/font.h" 19 #include "gfx/font.h"
20 #include "gfx/gtk_util.h" 20 #include "gfx/gtk_util.h"
21 #include "third_party/skia/include/core/SkBitmap.h" 21 #include "third_party/skia/include/core/SkBitmap.h"
22 #include "views/accelerator.h" 22 #include "views/accelerator.h"
23 #include "views/controls/menu/menu_2.h" 23 #include "views/controls/menu/menu_2.h"
24 24
25 namespace { 25 namespace {
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 } 322 }
323 323
324 if (type == menus::MenuModel::TYPE_SUBMENU) { 324 if (type == menus::MenuModel::TYPE_SUBMENU) {
325 Menu2* submenu = new Menu2(model_->GetSubmenuModelAt(index)); 325 Menu2* submenu = new Menu2(model_->GetSubmenuModelAt(index));
326 static_cast<NativeMenuGtk*>(submenu->wrapper_.get())->set_parent(this); 326 static_cast<NativeMenuGtk*>(submenu->wrapper_.get())->set_parent(this);
327 g_object_set_data(G_OBJECT(menu_item), "submenu", submenu); 327 g_object_set_data(G_OBJECT(menu_item), "submenu", submenu);
328 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), 328 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item),
329 submenu->GetNativeMenu()); 329 submenu->GetNativeMenu());
330 } 330 }
331 331
332 views::Accelerator accelerator(base::VKEY_UNKNOWN, false, false, false); 332 views::Accelerator accelerator(app::VKEY_UNKNOWN, false, false, false);
333 if (accel_group && model_->GetAcceleratorAt(index, &accelerator)) { 333 if (accel_group && model_->GetAcceleratorAt(index, &accelerator)) {
334 int gdk_modifiers = 0; 334 int gdk_modifiers = 0;
335 if (accelerator.IsShiftDown()) 335 if (accelerator.IsShiftDown())
336 gdk_modifiers |= GDK_SHIFT_MASK; 336 gdk_modifiers |= GDK_SHIFT_MASK;
337 if (accelerator.IsCtrlDown()) 337 if (accelerator.IsCtrlDown())
338 gdk_modifiers |= GDK_CONTROL_MASK; 338 gdk_modifiers |= GDK_CONTROL_MASK;
339 if (accelerator.IsAltDown()) 339 if (accelerator.IsAltDown())
340 gdk_modifiers |= GDK_MOD1_MASK; 340 gdk_modifiers |= GDK_MOD1_MASK;
341 gtk_widget_add_accelerator(menu_item, "activate", accel_group, 341 gtk_widget_add_accelerator(menu_item, "activate", accel_group,
342 base::GdkKeyCodeForWindowsKeyCode(accelerator.GetKeyCode(), false), 342 app::GdkKeyCodeForWindowsKeyCode(accelerator.GetKeyCode(), false),
343 static_cast<GdkModifierType>(gdk_modifiers), GTK_ACCEL_VISIBLE); 343 static_cast<GdkModifierType>(gdk_modifiers), GTK_ACCEL_VISIBLE);
344 } 344 }
345 345
346 g_object_set_data(G_OBJECT(menu_item), kPositionString, 346 g_object_set_data(G_OBJECT(menu_item), kPositionString,
347 reinterpret_cast<void*>(index)); 347 reinterpret_cast<void*>(index));
348 g_signal_connect(menu_item, "activate", G_CALLBACK(CallActivate), this); 348 g_signal_connect(menu_item, "activate", G_CALLBACK(CallActivate), this);
349 gtk_widget_show(menu_item); 349 gtk_widget_show(menu_item);
350 gtk_menu_append(menu_, menu_item); 350 gtk_menu_append(menu_, menu_item);
351 351
352 return menu_item; 352 return menu_item;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 493
494 //////////////////////////////////////////////////////////////////////////////// 494 ////////////////////////////////////////////////////////////////////////////////
495 // MenuWrapper, public: 495 // MenuWrapper, public:
496 496
497 // static 497 // static
498 MenuWrapper* MenuWrapper::CreateWrapper(Menu2* menu) { 498 MenuWrapper* MenuWrapper::CreateWrapper(Menu2* menu) {
499 return new NativeMenuGtk(menu); 499 return new NativeMenuGtk(menu);
500 } 500 }
501 501
502 } // namespace views 502 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/menu/menu_win.cc ('k') | views/controls/menu/native_menu_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698