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

Side by Side Diff: chrome/browser/ui/gtk/global_bookmarks_menu.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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_GTK_GLOBAL_BOOKMARKS_MENU_H_
6 #define CHROME_BROWSER_UI_GTK_GLOBAL_BOOKMARKS_MENU_H_
7
8 #include <map>
9
10 #include "base/time.h"
11 #include "base/timer.h"
12 #include "chrome/browser/bookmarks/bookmark_model_observer.h"
13 #include "content/common/notification_observer.h"
14 #include "content/common/notification_registrar.h"
15 #include "ui/base/gtk/gtk_signal.h"
16
17 class Browser;
18 class Profile;
19
20 typedef struct _GdkPixbuf GdkPixbuf;
21 typedef struct _GtkWidget GtkWidget;
22
23 // Manages the global Bookmarks menu.
Evan Stade 2011/05/10 17:09:18 odd to capitalize bookmarks here
24 //
25 // There are a few subtilties here: we can't rely on accurate event
Evan Stade 2011/05/10 17:09:18 subtleties
26 // dispositions being sent back, right click menus on menu items were placed
Evan Stade 2011/05/10 17:09:18 confusing change of tense here ("were" -- when?)
27 // relative to the main chrome window instead of the global menu bar, and we
28 // need to update the menu in the background (instead of building it on showing
Evan Stade 2011/05/10 17:09:18 can you separate some of these comments into a TOD
Elliot Glaysher 2011/05/10 18:29:28 I put these here to document the limitations. I do
29 // and not updating it if the model changes). I'm not even thinking about
30 // making these dragable since these items aren't displayed in our process.
Evan Stade 2011/05/10 17:09:18 draggable
31 class GlobalBookmarksMenu : public NotificationObserver,
Evan Stade 2011/05/10 17:09:18 this should be GlobalBookmarkMenu (the only class
Elliot Glaysher 2011/05/10 18:29:28 The class implements a menu that whose title is th
Evan Stade 2011/05/10 18:50:34 I think consistency with other code is more import
32 public BookmarkModelObserver {
33 public:
34 explicit GlobalBookmarksMenu(Browser* browser);
35 virtual ~GlobalBookmarksMenu();
36
37 // Takes the bookmark menu we need to modify based on bookmark state.
38 void Init(GtkWidget* bookmark_menu);
39
40 private:
41 // Schedules the menu to be rebuilt. The mac version sets a boolean and
42 // rebuilds the menu during their pre-show callback. We don't have that
Evan Stade 2011/05/10 17:09:18 s/that//
43 // anything like that: by the time we get a "show" signal from GTK+, the menu
44 // has already been displayed and its multiple dbus calls to add the menu
Evan Stade 2011/05/10 17:09:18 s/its/it takes/ (?)
45 // items.
46 //
47 // Since the bookmark model works by sending us BookmarkNodeEvent
48 // notifications one by one, we use a timer to batch up calls.
49 void RebuildMenuInFuture();
50
51 // Rebuilds the menu now. Called on initial Load() and from
52 // RebuildMenuInFuture().
53 void RebuildMenu();
54
55 // Adds |item| to |menu| and marks it as a dynamic item.
56 void AddBookmarkMenuItem(GtkWidget* menu, GtkWidget* menu_item);
57
58 // Adds an menu item representing |node| to |menu|.
59 void AddNodeToMenu(const BookmarkNode* node, GtkWidget* menu);
60
61 // This configures a GtkWidget with all the data from a BookmarkNode. This is
62 // used to update existing menu items, as well as to configure newly created
63 // ones, like in AddNodeToMenu().
64 void ConfigureMenuItem(const BookmarkNode* node, GtkWidget* menu_item);
65
66 // Returns the GtkMenuItem for |node|.
67 GtkWidget* MenuItemForNode(const BookmarkNode* node);
68
69 // Removes all bookmark entries from the bookmark menu in anticipation that
70 // we're about to do a rebuild.
71 void ClearBookmarkMenu();
72
73 // Callback used in ClearBookmarkMenu().
74 static void ClearBookmarkItemCallback(GtkWidget* menu_item,
75 void* /*unused*/);
76
77 // NotificationObserver:
78 virtual void Observe(NotificationType type,
79 const NotificationSource& source,
80 const NotificationDetails& details);
81
82 // BookmarkModelObserver:
83 virtual void Loaded(BookmarkModel* model);
84 virtual void BookmarkModelBeingDeleted(BookmarkModel* model);
85 virtual void BookmarkNodeMoved(BookmarkModel* model,
86 const BookmarkNode* old_parent,
87 int old_index,
88 const BookmarkNode* new_parent,
89 int new_index);
90 virtual void BookmarkNodeAdded(BookmarkModel* model,
91 const BookmarkNode* parent,
92 int index);
93 virtual void BookmarkNodeRemoved(BookmarkModel* model,
94 const BookmarkNode* parent,
95 int old_index,
96 const BookmarkNode* node);
97 virtual void BookmarkNodeChanged(BookmarkModel* model,
98 const BookmarkNode* node);
99 virtual void BookmarkNodeFaviconLoaded(BookmarkModel* model,
100 const BookmarkNode* node);
101 virtual void BookmarkNodeChildrenReordered(BookmarkModel* model,
102 const BookmarkNode* node);
103
104 CHROMEGTK_CALLBACK_0(GlobalBookmarksMenu, void, OnBookmarkItemActivated);
105
106 Browser* browser_;
107 Profile* profile_;
108
109 NotificationRegistrar registrar_;
110
111 GdkPixbuf* default_favicon_;
112 GdkPixbuf* default_folder_;
113
114 GtkWidget* bookmark_menu_;
115
116 // A timer set/reset by RebuildMenuInFuture() to group menu mutating events
117 // together.
118 base::OneShotTimer<GlobalBookmarksMenu> menu_build_timer_;
119
120 // In order to appropriately update items in the bookmark menu, without
121 // forcing a rebuild, map the model's nodes to menu items.
122 std::map<const BookmarkNode*, GtkWidget*> bookmark_nodes_;
123 };
124
125 #endif // CHROME_BROWSER_UI_GTK_GLOBAL_BOOKMARKS_MENU_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/gtk/global_bookmarks_menu.cc » ('j') | chrome/browser/ui/gtk/global_bookmarks_menu.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698