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

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

Issue 6980011: GTK: Implement the global bookmarks menu. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove show 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
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_bookmarks_menu.h"
11 #include "chrome/browser/ui/gtk/global_history_menu.h" 12 #include "chrome/browser/ui/gtk/global_history_menu.h"
12 #include "chrome/browser/ui/gtk/owned_widget_gtk.h" 13 #include "chrome/browser/ui/gtk/owned_widget_gtk.h"
13 #include "content/common/notification_observer.h" 14 #include "content/common/notification_observer.h"
14 #include "content/common/notification_registrar.h" 15 #include "content/common/notification_registrar.h"
15 #include "ui/base/gtk/gtk_signal.h" 16 #include "ui/base/gtk/gtk_signal.h"
16 17
17 class Browser; 18 class Browser;
18 struct GlobalMenuBarCommand; 19 struct GlobalMenuBarCommand;
19 20
20 typedef struct _GtkAccelGroup GtkAccelGroup; 21 typedef struct _GtkAccelGroup GtkAccelGroup;
21 typedef struct _GtkWidget GtkWidget; 22 typedef struct _GtkWidget GtkWidget;
22 23
23 // Controls the Mac style menu bar on Linux. 24 // Controls the Mac style menu bar on Linux.
24 // 25 //
25 // Unity and some configurations of GNOME have a Apple-like menu bar at the top 26 // Unity and some configurations of GNOME have a Apple-like menu bar at the top
26 // of the screen that changes depending on the active window. These mainly work 27 // of the screen that changes depending on the active window. These mainly work
27 // by inspecting the application's widget hierarchy, and intercepting any 28 // by inspecting the application's widget hierarchy, and intercepting any
28 // GtkMenuBar found. Thankfully, these systems don't check to see if the menu 29 // GtkMenuBar found. Thankfully, these systems don't check to see if the menu
29 // bar itself is visible, so we insert a GtkMenuBar into the window hierarchy 30 // bar itself is visible, so we insert a GtkMenuBar into the window hierarchy
30 // and set it to be invisible. 31 // and set it to be invisible.
31 class GlobalMenuBar : public CommandUpdater::CommandObserver, 32 class GlobalMenuBar : public CommandUpdater::CommandObserver,
32 public NotificationObserver { 33 public NotificationObserver {
33 public: 34 public:
34 static const int TAG_NORMAL = 0; 35 static const int TAG_NORMAL = 0;
35 static const int TAG_MOST_VISITED = 1; 36 static const int TAG_MOST_VISITED = 1;
36 static const int TAG_RECENTLY_CLOSED = 2; 37 static const int TAG_RECENTLY_CLOSED = 2;
37 static const int TAG_MOST_VISITED_HEADER = 3; 38 static const int TAG_MOST_VISITED_HEADER = 3;
38 static const int TAG_RECENTLY_CLOSED_HEADER = 4; 39 static const int TAG_RECENTLY_CLOSED_HEADER = 4;
40 static const int TAG_BOOKMARK_CLEARABLE = 5;
39 41
40 explicit GlobalMenuBar(Browser* browser); 42 explicit GlobalMenuBar(Browser* browser);
41 virtual ~GlobalMenuBar(); 43 virtual ~GlobalMenuBar();
42 44
43 GtkWidget* widget() { return menu_bar_.get(); } 45 GtkWidget* widget() { return menu_bar_.get(); }
44 46
45 private: 47 private:
46 typedef std::map<int, GtkWidget*> CommandIDMenuItemMap; 48 typedef std::map<int, GtkWidget*> CommandIDMenuItemMap;
47 49
48 // Helper function that builds the data. 50 // Helper function that builds the data.
(...skipping 23 matching lines...) Expand all
72 74
73 NotificationRegistrar registrar_; 75 NotificationRegistrar registrar_;
74 76
75 // Our menu bar widget. 77 // Our menu bar widget.
76 OwnedWidgetGtk menu_bar_; 78 OwnedWidgetGtk menu_bar_;
77 79
78 // Listens to the TabRestoreService and the HistoryService and keeps the 80 // Listens to the TabRestoreService and the HistoryService and keeps the
79 // history menu fresh. 81 // history menu fresh.
80 GlobalHistoryMenu history_menu_; 82 GlobalHistoryMenu history_menu_;
81 83
84 // Listens to the bookmark model and updates the menu.
85 GlobalBookmarksMenu bookmarks_menu_;
86
82 // For some menu items, we want to show the accelerator, but not actually 87 // For some menu items, we want to show the accelerator, but not actually
83 // explicitly handle it. To this end we connect those menu items' accelerators 88 // explicitly handle it. To this end we connect those menu items' accelerators
84 // to this group, but don't attach this group to any top level window. 89 // to this group, but don't attach this group to any top level window.
85 GtkAccelGroup* dummy_accel_group_; 90 GtkAccelGroup* dummy_accel_group_;
86 91
87 // A mapping from command ids to GtkMenuItem objects. We use this to update 92 // A mapping from command ids to GtkMenuItem objects. We use this to update
88 // the command enable state. 93 // the command enable state.
89 CommandIDMenuItemMap id_to_menu_item_; 94 CommandIDMenuItemMap id_to_menu_item_;
90 95
91 // gtk_check_menu_item_set_active() will call the "activate" signal. We need 96 // gtk_check_menu_item_set_active() will call the "activate" signal. We need
92 // to block this activation while we change the checked state. 97 // to block this activation while we change the checked state.
93 bool block_activation_; 98 bool block_activation_;
94 }; 99 };
95 100
96 #endif // CHROME_BROWSER_UI_GTK_GLOBAL_MENU_BAR_H_ 101 #endif // CHROME_BROWSER_UI_GTK_GLOBAL_MENU_BAR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698