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

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

Issue 6251001: Move chrome/browser/gtk/ to chrome/browser/ui/gtk/... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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/browser_titlebar.cc ('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) 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_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 "chrome/browser/ui/gtk/browser_toolbar_gtk.h"
10 #include <string> 10 // TODO(msw): remove this file once all includes have been updated.
11
12 #include "app/active_window_watcher_x.h"
13 #include "app/gtk_signal.h"
14 #include "app/gtk_signal_registrar.h"
15 #include "app/menus/accelerator.h"
16 #include "app/menus/simple_menu_model.h"
17 #include "base/scoped_ptr.h"
18 #include "chrome/browser/command_updater.h"
19 #include "chrome/browser/gtk/custom_button.h"
20 #include "chrome/browser/gtk/menu_gtk.h"
21 #include "chrome/browser/gtk/owned_widget_gtk.h"
22 #include "chrome/browser/prefs/pref_member.h"
23 #include "chrome/browser/ui/toolbar/wrench_menu_model.h"
24 #include "chrome/common/notification_observer.h"
25 #include "chrome/common/notification_registrar.h"
26
27 class BackForwardButtonGtk;
28 class Browser;
29 class BrowserActionsToolbarGtk;
30 class BrowserWindowGtk;
31 class CustomDrawButton;
32 class GtkThemeProvider;
33 class LocationBar;
34 class LocationBarViewGtk;
35 class Profile;
36 class ReloadButtonGtk;
37 class TabContents;
38 class ToolbarModel;
39
40 // View class that displays the GTK version of the toolbar and routes gtk
41 // events back to the Browser.
42 class BrowserToolbarGtk : public CommandUpdater::CommandObserver,
43 public menus::AcceleratorProvider,
44 public MenuGtk::Delegate,
45 public NotificationObserver {
46 public:
47 explicit BrowserToolbarGtk(Browser* browser, BrowserWindowGtk* window);
48 virtual ~BrowserToolbarGtk();
49
50 // Create the contents of the toolbar. |top_level_window| is the GtkWindow
51 // to which we attach our accelerators.
52 void Init(Profile* profile, GtkWindow* top_level_window);
53
54 // Set the various widgets' ViewIDs.
55 void SetViewIDs();
56
57 void Show();
58 void Hide();
59
60 // Getter for the containing widget.
61 GtkWidget* widget() {
62 return event_box_;
63 }
64
65 // Getter for associated browser object.
66 Browser* browser() {
67 return browser_;
68 }
69
70 virtual LocationBar* GetLocationBar() const;
71
72 ReloadButtonGtk* GetReloadButton() { return reload_.get(); }
73
74 GtkWidget* GetAppMenuButton() { return wrench_menu_button_->widget(); }
75
76 BrowserActionsToolbarGtk* GetBrowserActionsToolbar() {
77 return actions_toolbar_.get();
78 }
79
80 LocationBarViewGtk* GetLocationBarView() { return location_bar_.get(); }
81
82 // We have to show padding on the bottom of the toolbar when the bookmark
83 // is in floating mode. Otherwise the bookmark bar will paint it for us.
84 void UpdateForBookmarkBarVisibility(bool show_bottom_padding);
85
86 void ShowAppMenu();
87
88 // Overridden from CommandUpdater::CommandObserver:
89 virtual void EnabledStateChangedForCommand(int id, bool enabled);
90
91 // Overridden from MenuGtk::Delegate:
92 virtual void StoppedShowing();
93 virtual GtkIconSet* GetIconSetForId(int idr);
94 virtual bool AlwaysShowIconForCmd(int command_id) const;
95
96 // Overridden from menus::AcceleratorProvider:
97 virtual bool GetAcceleratorForCommandId(int id,
98 menus::Accelerator* accelerator);
99
100 // NotificationObserver implementation.
101 virtual void Observe(NotificationType type,
102 const NotificationSource& source,
103 const NotificationDetails& details);
104
105 Profile* profile() { return profile_; }
106 void SetProfile(Profile* profile);
107
108 // Message that we should react to a state change.
109 void UpdateTabContents(TabContents* contents, bool should_restore_state);
110
111 private:
112 // Connect/Disconnect signals for dragging a url onto the home button.
113 void SetUpDragForHomeButton(bool enable);
114
115 // Sets the top corners of the toolbar to rounded, or sets them to normal,
116 // depending on the state of the browser window. Returns false if no action
117 // was taken (the roundedness was already correct), true otherwise.
118 bool UpdateRoundedness();
119
120 // Gtk callback for the "expose-event" signal.
121 // The alignment contains the toolbar.
122 CHROMEGTK_CALLBACK_1(BrowserToolbarGtk, gboolean, OnAlignmentExpose,
123 GdkEventExpose*);
124 CHROMEGTK_CALLBACK_1(BrowserToolbarGtk, gboolean, OnLocationHboxExpose,
125 GdkEventExpose*);
126
127 // Gtk callback for the "clicked" signal.
128 CHROMEGTK_CALLBACK_0(BrowserToolbarGtk, void, OnButtonClick);
129
130 // Gtk callback to intercept mouse clicks to the menu buttons.
131 CHROMEGTK_CALLBACK_1(BrowserToolbarGtk, gboolean, OnMenuButtonPressEvent,
132 GdkEventButton*);
133
134 // Used for drags onto home button.
135 CHROMEGTK_CALLBACK_6(BrowserToolbarGtk, void, OnDragDataReceived,
136 GdkDragContext*, gint, gint, GtkSelectionData*,
137 guint, guint);
138
139 // Used to draw the upgrade notification badge.
140 CHROMEGTK_CALLBACK_1(BrowserToolbarGtk, gboolean, OnWrenchMenuButtonExpose,
141 GdkEventExpose*);
142
143 // Updates preference-dependent state.
144 void NotifyPrefChanged(const std::string* pref);
145
146 static void SetSyncMenuLabel(GtkWidget* widget, gpointer userdata);
147
148 // Sometimes we only want to show the location w/o the toolbar buttons (e.g.,
149 // in a popup window).
150 bool ShouldOnlyShowLocation() const;
151
152 // An event box that holds |toolbar_|. We need the toolbar to have its own
153 // GdkWindow when we use the GTK drawing because otherwise the color from our
154 // parent GdkWindow will leak through with some theme engines (such as
155 // Clearlooks).
156 GtkWidget* event_box_;
157
158 // This widget handles padding around the outside of the toolbar.
159 GtkWidget* alignment_;
160
161 // Gtk widgets. The toolbar is an hbox with each of the other pieces of the
162 // toolbar placed side by side.
163 GtkWidget* toolbar_;
164
165 // All widgets to the left or right of the |location_hbox_|. We put the
166 // widgets on either side of location_hbox_ in their own toolbar so we can
167 // set their minimum sizes independently of |location_hbox_| which needs to
168 // grow/shrink in GTK+ mode.
169 GtkWidget* toolbar_left_;
170
171 // Contains all the widgets of the location bar.
172 GtkWidget* location_hbox_;
173
174 // The location bar view.
175 scoped_ptr<LocationBarViewGtk> location_bar_;
176
177 // All the buttons in the toolbar.
178 scoped_ptr<BackForwardButtonGtk> back_, forward_;
179 scoped_ptr<CustomDrawButton> home_;
180 scoped_ptr<ReloadButtonGtk> reload_;
181 scoped_ptr<BrowserActionsToolbarGtk> actions_toolbar_;
182 scoped_ptr<CustomDrawButton> wrench_menu_button_;
183
184 // The image shown in GTK+ mode in the wrench button.
185 GtkWidget* wrench_menu_image_;
186
187 // The model that contains the security level, text, icon to display...
188 ToolbarModel* model_;
189
190 GtkThemeProvider* theme_provider_;
191
192 scoped_ptr<MenuGtk> wrench_menu_;
193
194 WrenchMenuModel wrench_menu_model_;
195
196 Browser* browser_;
197 BrowserWindowGtk* window_;
198 Profile* profile_;
199
200 // Controls whether or not a home button should be shown on the toolbar.
201 BooleanPrefMember show_home_button_;
202
203 // Preferences controlling the configured home page.
204 StringPrefMember home_page_;
205 BooleanPrefMember home_page_is_new_tab_page_;
206
207 NotificationRegistrar registrar_;
208
209 // A GtkEntry that isn't part of the hierarchy. We keep this for native
210 // rendering.
211 OwnedWidgetGtk offscreen_entry_;
212
213 // Manages the home button drop signal handler.
214 scoped_ptr<GtkSignalRegistrar> drop_handler_;
215
216 DISALLOW_COPY_AND_ASSIGN(BrowserToolbarGtk);
217 };
218 11
219 #endif // CHROME_BROWSER_GTK_BROWSER_TOOLBAR_GTK_H_ 12 #endif // CHROME_BROWSER_GTK_BROWSER_TOOLBAR_GTK_H_
OLDNEW
« no previous file with comments | « chrome/browser/gtk/browser_titlebar.cc ('k') | chrome/browser/gtk/browser_toolbar_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698