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

Side by Side Diff: chrome/browser/gtk/browser_toolbar_gtk.h

Issue 5182004: [gtk] use new update badge on wrench menu (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: move to top right Created 10 years, 1 month 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/app/theme/upgrade_dot_inactive.png ('k') | chrome/browser/gtk/browser_toolbar_gtk.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 #ifndef CHROME_BROWSER_GTK_BROWSER_TOOLBAR_GTK_H_ 5 #ifndef CHROME_BROWSER_GTK_BROWSER_TOOLBAR_GTK_H_
6 #define CHROME_BROWSER_GTK_BROWSER_TOOLBAR_GTK_H_ 6 #define CHROME_BROWSER_GTK_BROWSER_TOOLBAR_GTK_H_
7 #pragma once 7 #pragma once
8 8
9 #include <gtk/gtk.h> 9 #include <gtk/gtk.h>
10 #include <string> 10 #include <string>
11 11
12 #include "app/active_window_watcher_x.h" 12 #include "app/active_window_watcher_x.h"
13 #include "app/animation_delegate.h" 13 #include "app/animation_delegate.h"
Finnur 2010/11/18 20:54:52 nit: Was this needed?
Evan Stade 2010/11/18 21:25:47 good catch. will fix.
14 #include "app/gtk_signal.h" 14 #include "app/gtk_signal.h"
15 #include "app/gtk_signal_registrar.h" 15 #include "app/gtk_signal_registrar.h"
16 #include "app/menus/accelerator.h" 16 #include "app/menus/accelerator.h"
17 #include "app/menus/simple_menu_model.h" 17 #include "app/menus/simple_menu_model.h"
18 #include "app/throb_animation.h"
19 #include "base/scoped_ptr.h" 18 #include "base/scoped_ptr.h"
20 #include "chrome/browser/command_updater.h" 19 #include "chrome/browser/command_updater.h"
21 #include "chrome/browser/gtk/custom_button.h" 20 #include "chrome/browser/gtk/custom_button.h"
22 #include "chrome/browser/gtk/menu_gtk.h" 21 #include "chrome/browser/gtk/menu_gtk.h"
23 #include "chrome/browser/gtk/owned_widget_gtk.h" 22 #include "chrome/browser/gtk/owned_widget_gtk.h"
24 #include "chrome/browser/prefs/pref_member.h" 23 #include "chrome/browser/prefs/pref_member.h"
25 #include "chrome/browser/wrench_menu_model.h" 24 #include "chrome/browser/wrench_menu_model.h"
26 #include "chrome/common/notification_observer.h" 25 #include "chrome/common/notification_observer.h"
27 #include "chrome/common/notification_registrar.h" 26 #include "chrome/common/notification_registrar.h"
28 27
29 class BackForwardButtonGtk; 28 class BackForwardButtonGtk;
30 class Browser; 29 class Browser;
31 class BrowserActionsToolbarGtk; 30 class BrowserActionsToolbarGtk;
32 class BrowserWindowGtk; 31 class BrowserWindowGtk;
33 class CustomDrawButton; 32 class CustomDrawButton;
34 class GtkThemeProvider; 33 class GtkThemeProvider;
35 class LocationBar; 34 class LocationBar;
36 class LocationBarViewGtk; 35 class LocationBarViewGtk;
37 class Profile; 36 class Profile;
38 class ReloadButtonGtk; 37 class ReloadButtonGtk;
39 class TabContents; 38 class TabContents;
40 class ToolbarModel; 39 class ToolbarModel;
41 40
42 // View class that displays the GTK version of the toolbar and routes gtk 41 // View class that displays the GTK version of the toolbar and routes gtk
43 // events back to the Browser. 42 // events back to the Browser.
44 class BrowserToolbarGtk : public CommandUpdater::CommandObserver, 43 class BrowserToolbarGtk : public CommandUpdater::CommandObserver,
45 public menus::AcceleratorProvider, 44 public menus::AcceleratorProvider,
46 public MenuGtk::Delegate, 45 public MenuGtk::Delegate,
47 public NotificationObserver, 46 public NotificationObserver {
48 public AnimationDelegate,
49 public ActiveWindowWatcherX::Observer {
50 public: 47 public:
51 explicit BrowserToolbarGtk(Browser* browser, BrowserWindowGtk* window); 48 explicit BrowserToolbarGtk(Browser* browser, BrowserWindowGtk* window);
52 virtual ~BrowserToolbarGtk(); 49 virtual ~BrowserToolbarGtk();
53 50
54 // Create the contents of the toolbar. |top_level_window| is the GtkWindow 51 // Create the contents of the toolbar. |top_level_window| is the GtkWindow
55 // to which we attach our accelerators. 52 // to which we attach our accelerators.
56 void Init(Profile* profile, GtkWindow* top_level_window); 53 void Init(Profile* profile, GtkWindow* top_level_window);
57 54
58 // Set the various widgets' ViewIDs. 55 // Set the various widgets' ViewIDs.
59 void SetViewIDs(); 56 void SetViewIDs();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 void Observe(NotificationType type, 102 void Observe(NotificationType type,
106 const NotificationSource& source, 103 const NotificationSource& source,
107 const NotificationDetails& details); 104 const NotificationDetails& details);
108 105
109 Profile* profile() { return profile_; } 106 Profile* profile() { return profile_; }
110 void SetProfile(Profile* profile); 107 void SetProfile(Profile* profile);
111 108
112 // Message that we should react to a state change. 109 // Message that we should react to a state change.
113 void UpdateTabContents(TabContents* contents, bool should_restore_state); 110 void UpdateTabContents(TabContents* contents, bool should_restore_state);
114 111
115 // AnimationDelegate implementation ------------------------------------------
116 virtual void AnimationEnded(const Animation* animation);
117 virtual void AnimationProgressed(const Animation* animation);
118 virtual void AnimationCanceled(const Animation* animation);
119
120 // ActiveWindowWatcher::Observer implementation ------------------------------
121 virtual void ActiveWindowChanged(GdkWindow* active_window);
122
123 private: 112 private:
124 // Connect/Disconnect signals for dragging a url onto the home button. 113 // Connect/Disconnect signals for dragging a url onto the home button.
125 void SetUpDragForHomeButton(bool enable); 114 void SetUpDragForHomeButton(bool enable);
126 115
127 // Sets the top corners of the toolbar to rounded, or sets them to normal, 116 // Sets the top corners of the toolbar to rounded, or sets them to normal,
128 // depending on the state of the browser window. Returns false if no action 117 // depending on the state of the browser window. Returns false if no action
129 // was taken (the roundedness was already correct), true otherwise. 118 // was taken (the roundedness was already correct), true otherwise.
130 bool UpdateRoundedness(); 119 bool UpdateRoundedness();
131 120
132 // Calculates whether the upgrade notification dot should be faded at all
133 // (as opposed to solid).
134 bool UpgradeAnimationIsFaded();
135
136 // Gtk callback for the "expose-event" signal. 121 // Gtk callback for the "expose-event" signal.
137 // The alignment contains the toolbar. 122 // The alignment contains the toolbar.
138 CHROMEGTK_CALLBACK_1(BrowserToolbarGtk, gboolean, OnAlignmentExpose, 123 CHROMEGTK_CALLBACK_1(BrowserToolbarGtk, gboolean, OnAlignmentExpose,
139 GdkEventExpose*); 124 GdkEventExpose*);
140 CHROMEGTK_CALLBACK_1(BrowserToolbarGtk, gboolean, OnLocationHboxExpose, 125 CHROMEGTK_CALLBACK_1(BrowserToolbarGtk, gboolean, OnLocationHboxExpose,
141 GdkEventExpose*); 126 GdkEventExpose*);
142 127
143 // Gtk callback for the "clicked" signal. 128 // Gtk callback for the "clicked" signal.
144 CHROMEGTK_CALLBACK_0(BrowserToolbarGtk, void, OnButtonClick); 129 CHROMEGTK_CALLBACK_0(BrowserToolbarGtk, void, OnButtonClick);
145 130
146 // Gtk callback to intercept mouse clicks to the menu buttons. 131 // Gtk callback to intercept mouse clicks to the menu buttons.
147 CHROMEGTK_CALLBACK_1(BrowserToolbarGtk, gboolean, OnMenuButtonPressEvent, 132 CHROMEGTK_CALLBACK_1(BrowserToolbarGtk, gboolean, OnMenuButtonPressEvent,
148 GdkEventButton*); 133 GdkEventButton*);
149 134
150 // Used for drags onto home button. 135 // Used for drags onto home button.
151 CHROMEGTK_CALLBACK_6(BrowserToolbarGtk, void, OnDragDataReceived, 136 CHROMEGTK_CALLBACK_6(BrowserToolbarGtk, void, OnDragDataReceived,
152 GdkDragContext*, gint, gint, GtkSelectionData*, 137 GdkDragContext*, gint, gint, GtkSelectionData*,
153 guint, guint); 138 guint, guint);
154 139
155 // Used to stop the upgrade notification animation.
156 CHROMEGTK_CALLBACK_0(BrowserToolbarGtk, void, OnWrenchMenuShow);
157
158 // Used to draw the upgrade notification badge. 140 // Used to draw the upgrade notification badge.
159 CHROMEGTK_CALLBACK_1(BrowserToolbarGtk, gboolean, OnWrenchMenuButtonExpose, 141 CHROMEGTK_CALLBACK_1(BrowserToolbarGtk, gboolean, OnWrenchMenuButtonExpose,
160 GdkEventExpose*); 142 GdkEventExpose*);
161 143
162 // Updates preference-dependent state. 144 // Updates preference-dependent state.
163 void NotifyPrefChanged(const std::string* pref); 145 void NotifyPrefChanged(const std::string* pref);
164 146
165 // Start the upgrade notification animation if we have detected an upgrade
166 // and the current toolbar is focused.
167 void MaybeShowUpgradeReminder();
168
169 static void SetSyncMenuLabel(GtkWidget* widget, gpointer userdata); 147 static void SetSyncMenuLabel(GtkWidget* widget, gpointer userdata);
170 148
171 // Sometimes we only want to show the location w/o the toolbar buttons (e.g., 149 // Sometimes we only want to show the location w/o the toolbar buttons (e.g.,
172 // in a popup window). 150 // in a popup window).
173 bool ShouldOnlyShowLocation() const; 151 bool ShouldOnlyShowLocation() const;
174 152
175 // An event box that holds |toolbar_|. We need the toolbar to have its own 153 // An event box that holds |toolbar_|. We need the toolbar to have its own
176 // GdkWindow when we use the GTK drawing because otherwise the color from our 154 // GdkWindow when we use the GTK drawing because otherwise the color from our
177 // parent GdkWindow will leak through with some theme engines (such as 155 // parent GdkWindow will leak through with some theme engines (such as
178 // Clearlooks). 156 // Clearlooks).
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 207
230 NotificationRegistrar registrar_; 208 NotificationRegistrar registrar_;
231 209
232 // A GtkEntry that isn't part of the hierarchy. We keep this for native 210 // A GtkEntry that isn't part of the hierarchy. We keep this for native
233 // rendering. 211 // rendering.
234 OwnedWidgetGtk offscreen_entry_; 212 OwnedWidgetGtk offscreen_entry_;
235 213
236 // Manages the home button drop signal handler. 214 // Manages the home button drop signal handler.
237 scoped_ptr<GtkSignalRegistrar> drop_handler_; 215 scoped_ptr<GtkSignalRegistrar> drop_handler_;
238 216
239 ThrobAnimation upgrade_reminder_animation_;
240
241 // We have already shown and dismissed the upgrade reminder animation.
242 bool upgrade_reminder_canceled_;
243
244 DISALLOW_COPY_AND_ASSIGN(BrowserToolbarGtk); 217 DISALLOW_COPY_AND_ASSIGN(BrowserToolbarGtk);
245 }; 218 };
246 219
247 #endif // CHROME_BROWSER_GTK_BROWSER_TOOLBAR_GTK_H_ 220 #endif // CHROME_BROWSER_GTK_BROWSER_TOOLBAR_GTK_H_
OLDNEW
« no previous file with comments | « chrome/app/theme/upgrade_dot_inactive.png ('k') | chrome/browser/gtk/browser_toolbar_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698