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

Side by Side Diff: chrome/browser/gtk/tabs/tab_gtk.cc

Issue 159721: GTK: Show shortcuts in title bar context menu and tab context menu.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 4 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/gtk/menu_gtk.cc ('k') | no next file » | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/gtk/tabs/tab_gtk.h" 5 #include "chrome/browser/gtk/tabs/tab_gtk.h"
6 6
7 #include <gdk/gdkkeysyms.h>
8
7 #include "app/gfx/path.h" 9 #include "app/gfx/path.h"
8 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
9 #include "app/resource_bundle.h" 11 #include "app/resource_bundle.h"
10 #include "chrome/browser/gtk/gtk_dnd_util.h" 12 #include "chrome/browser/gtk/gtk_dnd_util.h"
11 #include "chrome/browser/gtk/menu_gtk.h" 13 #include "chrome/browser/gtk/menu_gtk.h"
14 #include "chrome/browser/gtk/standard_menus.h"
12 #include "grit/generated_resources.h" 15 #include "grit/generated_resources.h"
13 #include "grit/theme_resources.h" 16 #include "grit/theme_resources.h"
14 17
15 namespace { 18 namespace {
16 19
17 void SetEmptyDragIcon(GtkWidget* widget) { 20 void SetEmptyDragIcon(GtkWidget* widget) {
18 GdkPixbuf* pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 1, 1); 21 GdkPixbuf* pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 1, 1);
19 gtk_drag_source_set_icon_pixbuf(widget, pixbuf); 22 gtk_drag_source_set_icon_pixbuf(widget, pixbuf);
20 g_object_unref(pixbuf); 23 g_object_unref(pixbuf);
21 } 24 }
22 25
23 } // namespace 26 } // namespace
24 27
25 class TabGtk::ContextMenuController : public MenuGtk::Delegate { 28 class TabGtk::ContextMenuController : public MenuGtk::Delegate {
26 public: 29 public:
27 explicit ContextMenuController(TabGtk* tab) 30 explicit ContextMenuController(TabGtk* tab)
28 : tab_(tab) { 31 : tab_(tab) {
29 menu_.reset(new MenuGtk(this, false)); 32 static const MenuCreateMaterial context_menu_blueprint[] = {
30 menu_->AppendMenuItemWithLabel( 33 { MENU_NORMAL, TabStripModel::CommandNewTab, IDS_TAB_CXMENU_NEWTAB,
31 TabStripModel::CommandNewTab, 34 0, NULL, GDK_t, GDK_CONTROL_MASK, true },
32 l10n_util::GetStringUTF8(IDS_TAB_CXMENU_NEWTAB)); 35 { MENU_SEPARATOR },
33 menu_->AppendSeparator(); 36 { MENU_NORMAL, TabStripModel::CommandReload, IDS_TAB_CXMENU_RELOAD,
34 menu_->AppendMenuItemWithLabel( 37 0, NULL, GDK_F5, 0, true },
35 TabStripModel::CommandReload, 38 { MENU_NORMAL, TabStripModel::CommandDuplicate,
36 l10n_util::GetStringUTF8(IDS_TAB_CXMENU_RELOAD)); 39 IDS_TAB_CXMENU_DUPLICATE },
37 menu_->AppendMenuItemWithLabel( 40 { MENU_SEPARATOR },
38 TabStripModel::CommandDuplicate, 41 { MENU_NORMAL, TabStripModel::CommandCloseTab, IDS_TAB_CXMENU_CLOSETAB,
39 l10n_util::GetStringUTF8(IDS_TAB_CXMENU_DUPLICATE)); 42 0, NULL, GDK_w, GDK_CONTROL_MASK, true },
40 menu_->AppendSeparator(); 43 { MENU_NORMAL, TabStripModel::CommandCloseOtherTabs,
41 menu_->AppendMenuItemWithLabel( 44 IDS_TAB_CXMENU_CLOSEOTHERTABS },
42 TabStripModel::CommandCloseTab, 45 { MENU_NORMAL, TabStripModel::CommandCloseTabsToRight,
43 l10n_util::GetStringUTF8(IDS_TAB_CXMENU_CLOSETAB)); 46 IDS_TAB_CXMENU_CLOSETABSTORIGHT },
44 menu_->AppendMenuItemWithLabel( 47 { MENU_NORMAL, TabStripModel::CommandCloseTabsOpenedBy,
45 TabStripModel::CommandCloseOtherTabs, 48 IDS_TAB_CXMENU_CLOSETABSOPENEDBY },
46 l10n_util::GetStringUTF8(IDS_TAB_CXMENU_CLOSEOTHERTABS)); 49 { MENU_NORMAL, TabStripModel::CommandRestoreTab, IDS_RESTORE_TAB,
47 menu_->AppendMenuItemWithLabel( 50 0, NULL, GDK_t, GDK_CONTROL_MASK | GDK_SHIFT_MASK, true },
48 TabStripModel::CommandCloseTabsToRight, 51 { MENU_SEPARATOR },
49 l10n_util::GetStringUTF8(IDS_TAB_CXMENU_CLOSETABSTORIGHT)); 52 { MENU_NORMAL, TabStripModel::CommandTogglePinned,
50 menu_->AppendMenuItemWithLabel( 53 IDS_TAB_CXMENU_PIN_TAB },
51 TabStripModel::CommandCloseTabsOpenedBy, 54 { MENU_END },
52 l10n_util::GetStringUTF8(IDS_TAB_CXMENU_CLOSETABSOPENEDBY)); 55 };
53 menu_->AppendMenuItemWithLabel( 56
54 TabStripModel::CommandRestoreTab, 57 menu_.reset(new MenuGtk(this, context_menu_blueprint, NULL));
55 l10n_util::GetStringUTF8(IDS_RESTORE_TAB));
56 menu_->AppendSeparator();
57 menu_->AppendCheckMenuItemWithLabel(
58 TabStripModel::CommandTogglePinned,
59 l10n_util::GetStringUTF8(IDS_TAB_CXMENU_PIN_TAB));
60 } 58 }
61 59
62 virtual ~ContextMenuController() {} 60 virtual ~ContextMenuController() {}
63 61
64 void RunMenu() { 62 void RunMenu() {
65 menu_->PopupAsContext(gtk_get_current_event_time()); 63 menu_->PopupAsContext(gtk_get_current_event_time());
66 } 64 }
67 65
68 void Cancel() { 66 void Cancel() {
69 tab_ = NULL; 67 tab_ = NULL;
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 if (!menu_controller_.get()) 311 if (!menu_controller_.get())
314 menu_controller_.reset(new ContextMenuController(this)); 312 menu_controller_.reset(new ContextMenuController(this));
315 313
316 menu_controller_->RunMenu(); 314 menu_controller_->RunMenu();
317 } 315 }
318 316
319 void TabGtk::ContextMenuClosed() { 317 void TabGtk::ContextMenuClosed() {
320 delegate()->StopAllHighlighting(); 318 delegate()->StopAllHighlighting();
321 menu_controller_.reset(); 319 menu_controller_.reset();
322 } 320 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/menu_gtk.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698