OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 | 7 |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
12 #include "chrome/browser/autocomplete/autocomplete_popup_view.h" | 12 #include "chrome/browser/autocomplete/autocomplete_popup_view.h" |
13 #include "chrome/browser/command_updater.h" | 13 #include "chrome/browser/command_updater.h" |
| 14 #include "chrome/browser/gtk/menu_bar_helper.h" |
14 #include "chrome/browser/gtk/menu_gtk.h" | 15 #include "chrome/browser/gtk/menu_gtk.h" |
15 #include "chrome/common/notification_observer.h" | 16 #include "chrome/common/notification_observer.h" |
16 #include "chrome/common/notification_registrar.h" | 17 #include "chrome/common/notification_registrar.h" |
17 #include "chrome/common/pref_member.h" | 18 #include "chrome/common/pref_member.h" |
18 | 19 |
19 class BackForwardButtonGtk; | 20 class BackForwardButtonGtk; |
20 class Browser; | 21 class Browser; |
21 class BrowserWindowGtk; | 22 class BrowserWindowGtk; |
22 class CustomDrawButton; | 23 class CustomDrawButton; |
23 class GtkThemeProvider; | 24 class GtkThemeProvider; |
24 class GoButtonGtk; | 25 class GoButtonGtk; |
25 class LocationBar; | 26 class LocationBar; |
26 class LocationBarViewGtk; | 27 class LocationBarViewGtk; |
27 class Profile; | 28 class Profile; |
28 class TabContents; | 29 class TabContents; |
29 class ToolbarModel; | 30 class ToolbarModel; |
30 class ToolbarStarToggleGtk; | 31 class ToolbarStarToggleGtk; |
31 | 32 |
32 // View class that displays the GTK version of the toolbar and routes gtk | 33 // View class that displays the GTK version of the toolbar and routes gtk |
33 // events back to the Browser. | 34 // events back to the Browser. |
34 class BrowserToolbarGtk : public CommandUpdater::CommandObserver, | 35 class BrowserToolbarGtk : public CommandUpdater::CommandObserver, |
35 public MenuGtk::Delegate, | 36 public MenuGtk::Delegate, |
36 public NotificationObserver, | 37 public NotificationObserver, |
37 public AutocompletePopupPositioner { | 38 public AutocompletePopupPositioner, |
| 39 public MenuBarHelper::Delegate { |
38 public: | 40 public: |
39 explicit BrowserToolbarGtk(Browser* browser, BrowserWindowGtk* window); | 41 explicit BrowserToolbarGtk(Browser* browser, BrowserWindowGtk* window); |
40 virtual ~BrowserToolbarGtk(); | 42 virtual ~BrowserToolbarGtk(); |
41 | 43 |
42 // Create the contents of the toolbar. |top_level_window| is the GtkWindow | 44 // Create the contents of the toolbar. |top_level_window| is the GtkWindow |
43 // to which we attach our accelerators. | 45 // to which we attach our accelerators. |
44 void Init(Profile* profile, GtkWindow* top_level_window); | 46 void Init(Profile* profile, GtkWindow* top_level_window); |
45 | 47 |
46 // Set the various widgets' ViewIDs. | 48 // Set the various widgets' ViewIDs. |
47 void SetViewIDs(); | 49 void SetViewIDs(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 84 |
83 // Message that we should react to a state change. | 85 // Message that we should react to a state change. |
84 void UpdateTabContents(TabContents* contents, bool should_restore_state); | 86 void UpdateTabContents(TabContents* contents, bool should_restore_state); |
85 | 87 |
86 ToolbarStarToggleGtk* star() { return star_.get(); } | 88 ToolbarStarToggleGtk* star() { return star_.get(); } |
87 | 89 |
88 // Implement AutocompletePopupPositioner, return the position of where the | 90 // Implement AutocompletePopupPositioner, return the position of where the |
89 // Omnibox results popup should go (from the star to the go buttons). | 91 // Omnibox results popup should go (from the star to the go buttons). |
90 virtual gfx::Rect GetPopupBounds() const; | 92 virtual gfx::Rect GetPopupBounds() const; |
91 | 93 |
| 94 // MenuBarHelper::Delegate implementation ------------------------------------ |
| 95 virtual void PopupForButton(GtkWidget* button); |
| 96 virtual void PopupForButtonNextTo(GtkWidget* button, |
| 97 GtkMenuDirectionType dir); |
| 98 |
92 private: | 99 private: |
93 // Builds a toolbar button with all the properties set. | 100 // Builds a toolbar button with all the properties set. |
94 // |spacing| is the width of padding (in pixels) on the left and right of the | 101 // |spacing| is the width of padding (in pixels) on the left and right of the |
95 // button. | 102 // button. |
96 CustomDrawButton* BuildToolbarButton(int normal_id, | 103 CustomDrawButton* BuildToolbarButton(int normal_id, |
97 int active_id, | 104 int active_id, |
98 int highlight_id, | 105 int highlight_id, |
99 int depressed_id, | 106 int depressed_id, |
100 const std::string& localized_tooltip, | 107 const std::string& localized_tooltip, |
101 const char* stock_id); | 108 const char* stock_id); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 BrowserToolbarGtk* toolbar); | 143 BrowserToolbarGtk* toolbar); |
137 | 144 |
138 // Used for drags onto home button. | 145 // Used for drags onto home button. |
139 static void OnDragDataReceived(GtkWidget* widget, | 146 static void OnDragDataReceived(GtkWidget* widget, |
140 GdkDragContext* drag_context, | 147 GdkDragContext* drag_context, |
141 gint x, gint y, | 148 gint x, gint y, |
142 GtkSelectionData* data, | 149 GtkSelectionData* data, |
143 guint info, guint time, | 150 guint info, guint time, |
144 BrowserToolbarGtk* toolbar); | 151 BrowserToolbarGtk* toolbar); |
145 | 152 |
146 // These event handlers are used to fake menu-bar behavior in the page and | |
147 // app menus. | |
148 static gboolean OnPageAppMenuMouseMotion(GtkWidget* widget, | |
149 GdkEventMotion* event, | |
150 BrowserToolbarGtk* toolbar); | |
151 static void OnPageAppMenuMoveCurrent(GtkWidget* widget, | |
152 GtkMenuDirectionType dir, | |
153 BrowserToolbarGtk* toolbar); | |
154 | |
155 // Sometimes we only want to show the location w/o the toolbar buttons (e.g., | 153 // Sometimes we only want to show the location w/o the toolbar buttons (e.g., |
156 // in a popup window). | 154 // in a popup window). |
157 bool ShouldOnlyShowLocation() const; | 155 bool ShouldOnlyShowLocation() const; |
158 | 156 |
159 // An event box that holds |toolbar_|. We need the toolbar to have its own | 157 // An event box that holds |toolbar_|. We need the toolbar to have its own |
160 // GdkWindow when we use the GTK drawing because otherwise the color from our | 158 // GdkWindow when we use the GTK drawing because otherwise the color from our |
161 // parent GdkWindow will leak through with some theme engines (such as | 159 // parent GdkWindow will leak through with some theme engines (such as |
162 // Clearlooks). | 160 // Clearlooks). |
163 GtkWidget* event_box_; | 161 GtkWidget* event_box_; |
164 | 162 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 | 198 |
201 // Controls whether or not a home button should be shown on the toolbar. | 199 // Controls whether or not a home button should be shown on the toolbar. |
202 BooleanPrefMember show_home_button_; | 200 BooleanPrefMember show_home_button_; |
203 | 201 |
204 NotificationRegistrar registrar_; | 202 NotificationRegistrar registrar_; |
205 | 203 |
206 // A GtkEntry that isn't part of the hierarchy. We keep this for native | 204 // A GtkEntry that isn't part of the hierarchy. We keep this for native |
207 // rendering. | 205 // rendering. |
208 OwnedWidgetGtk offscreen_entry_; | 206 OwnedWidgetGtk offscreen_entry_; |
209 | 207 |
| 208 MenuBarHelper menu_bar_helper_; |
| 209 |
210 DISALLOW_COPY_AND_ASSIGN(BrowserToolbarGtk); | 210 DISALLOW_COPY_AND_ASSIGN(BrowserToolbarGtk); |
211 }; | 211 }; |
212 | 212 |
213 #endif // CHROME_BROWSER_GTK_BROWSER_TOOLBAR_GTK_H_ | 213 #endif // CHROME_BROWSER_GTK_BROWSER_TOOLBAR_GTK_H_ |
OLD | NEW |