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

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

Issue 6840068: GTK: Add Recently Closed tabs to the History menu in the global menu bar. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove current most visited section. will redo with TopSites in a different patch. Created 9 years, 8 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_history_menu.cc ('k') | chrome/browser/ui/gtk/global_menu_bar.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) 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 #ifndef CHROME_BROWSER_UI_GTK_GLOBAL_MENU_BAR_H_ 5 #ifndef CHROME_BROWSER_UI_GTK_GLOBAL_MENU_BAR_H_
6 #define CHROME_BROWSER_UI_GTK_GLOBAL_MENU_BAR_H_ 6 #define CHROME_BROWSER_UI_GTK_GLOBAL_MENU_BAR_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "chrome/browser/command_updater.h" 10 #include "chrome/browser/command_updater.h"
11 #include "chrome/browser/ui/gtk/global_history_menu.h"
12 #include "chrome/browser/ui/gtk/owned_widget_gtk.h"
11 #include "content/common/notification_observer.h" 13 #include "content/common/notification_observer.h"
12 #include "content/common/notification_registrar.h" 14 #include "content/common/notification_registrar.h"
13 #include "ui/base/gtk/gtk_signal.h" 15 #include "ui/base/gtk/gtk_signal.h"
14 16
15 class Browser; 17 class Browser;
16 class BrowserWindowGtk;
17 struct GlobalMenuBarCommand; 18 struct GlobalMenuBarCommand;
18 19
19 typedef struct _GtkAccelGroup GtkAccelGroup; 20 typedef struct _GtkAccelGroup GtkAccelGroup;
20 typedef struct _GtkWidget GtkWidget; 21 typedef struct _GtkWidget GtkWidget;
21 22
22 // Controls the Mac style menu bar on Linux. 23 // Controls the Mac style menu bar on Linux.
23 // 24 //
24 // Unity and some configurations of GNOME have a Apple-like menu bar at the top 25 // Unity and some configurations of GNOME have a Apple-like menu bar at the top
25 // of the screen that changes depending on the active window. These mainly work 26 // of the screen that changes depending on the active window. These mainly work
26 // by inspecting the application's widget hierarchy, and intercepting any 27 // by inspecting the application's widget hierarchy, and intercepting any
27 // GtkMenuBar found. Thankfully, these systems don't check to see if the menu 28 // GtkMenuBar found. Thankfully, these systems don't check to see if the menu
28 // bar itself is visible, so we insert a GtkMenuBar into the window hierarchy 29 // bar itself is visible, so we insert a GtkMenuBar into the window hierarchy
29 // and set it to be invisible. 30 // and set it to be invisible.
30 class GlobalMenuBar : public CommandUpdater::CommandObserver, 31 class GlobalMenuBar : public CommandUpdater::CommandObserver,
31 public NotificationObserver { 32 public NotificationObserver {
32 public: 33 public:
33 GlobalMenuBar(Browser* browser, BrowserWindowGtk* window); 34 static const int TAG_NORMAL = 0;
35 static const int TAG_MOST_VISITED = 1;
36 static const int TAG_RECENTLY_CLOSED = 2;
37 static const int TAG_MOST_VISITED_HEADER = 3;
38 static const int TAG_RECENTLY_CLOSED_HEADER = 4;
39
40 explicit GlobalMenuBar(Browser* browser);
34 virtual ~GlobalMenuBar(); 41 virtual ~GlobalMenuBar();
35 42
36 GtkWidget* widget() { return menu_bar_; } 43 GtkWidget* widget() { return menu_bar_.get(); }
37 44
38 private: 45 private:
39 typedef std::map<int, GtkWidget*> IDMenuItemMap; 46 typedef std::map<int, GtkWidget*> CommandIDMenuItemMap;
40 47
41 // Helper function that builds the data. 48 // Helper function that builds the data.
42 void BuildGtkMenuFrom(int menu_str_id, 49 GtkWidget* BuildGtkMenuFrom(int menu_str_id,
43 std::map<int, GtkWidget*>* id_to_menu_item, 50 std::map<int, GtkWidget*>* id_to_menu_item,
44 GlobalMenuBarCommand* commands); 51 GlobalMenuBarCommand* commands);
52
53 // Builds an individual menu item.
54 GtkWidget* BuildMenuItem(int string_id,
55 int command_id,
56 int tag_id,
57 std::map<int, GtkWidget*>* id_to_menu_item,
58 GtkWidget* menu_to_add_to);
45 59
46 // CommandUpdater::CommandObserver: 60 // CommandUpdater::CommandObserver:
47 virtual void EnabledStateChangedForCommand(int id, bool enabled); 61 virtual void EnabledStateChangedForCommand(int id, bool enabled);
48 62
49 // NotificationObserver: 63 // NotificationObserver:
50 virtual void Observe(NotificationType type, 64 virtual void Observe(NotificationType type,
51 const NotificationSource& source, 65 const NotificationSource& source,
52 const NotificationDetails& details); 66 const NotificationDetails& details);
53 67
54 CHROMEGTK_CALLBACK_0(GlobalMenuBar, void, OnItemActivated); 68 CHROMEGTK_CALLBACK_0(GlobalMenuBar, void, OnItemActivated);
55 69
56 Browser* browser_; 70 Browser* browser_;
57 BrowserWindowGtk* browser_window_; 71 Profile* profile_;
58 72
59 NotificationRegistrar registrar_; 73 NotificationRegistrar registrar_;
60 74
61 // Our menu bar widget. 75 // Our menu bar widget.
62 GtkWidget* menu_bar_; 76 OwnedWidgetGtk menu_bar_;
77
78 // Listens to the TabRestoreService and the HistoryService and keeps the
79 // history menu fresh.
80 GlobalHistoryMenu history_menu_;
63 81
64 // For some menu items, we want to show the accelerator, but not actually 82 // For some menu items, we want to show the accelerator, but not actually
65 // explicitly handle it. To this end we connect those menu items' accelerators 83 // explicitly handle it. To this end we connect those menu items' accelerators
66 // to this group, but don't attach this group to any top level window. 84 // to this group, but don't attach this group to any top level window.
67 GtkAccelGroup* dummy_accel_group_; 85 GtkAccelGroup* dummy_accel_group_;
68 86
69 // A mapping from command ids to GtkMenuItem objects. We use this to update 87 // A mapping from command ids to GtkMenuItem objects. We use this to update
70 // the enable state since we are a . 88 // the command enable state.
71 IDMenuItemMap id_to_menu_item_; 89 CommandIDMenuItemMap id_to_menu_item_;
72 90
73 // gtk_check_menu_item_set_active() will call the "activate" signal. We need 91 // gtk_check_menu_item_set_active() will call the "activate" signal. We need
74 // to block this activation while we change the checked state. 92 // to block this activation while we change the checked state.
75 bool block_activation_; 93 bool block_activation_;
76 }; 94 };
77 95
78 #endif // CHROME_BROWSER_UI_GTK_GLOBAL_MENU_BAR_H_ 96 #endif // CHROME_BROWSER_UI_GTK_GLOBAL_MENU_BAR_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/global_history_menu.cc ('k') | chrome/browser/ui/gtk/global_menu_bar.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698