| OLD | NEW |
| 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 // A helper class that contains the gtk widgets that make up the titlebar. The | 5 // A helper class that contains the gtk widgets that make up the titlebar. The |
| 6 // titlebar consists of the tabstrip and if the custom chrome frame is turned | 6 // titlebar consists of the tabstrip and if the custom chrome frame is turned |
| 7 // on, it includes the taller titlebar and minimize, restore, maximize, and | 7 // on, it includes the taller titlebar and minimize, restore, maximize, and |
| 8 // close buttons. | 8 // close buttons. |
| 9 | 9 |
| 10 #ifndef CHROME_BROWSER_UI_GTK_BROWSER_TITLEBAR_H_ | 10 #ifndef CHROME_BROWSER_UI_GTK_BROWSER_TITLEBAR_H_ |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 // Lazily builds and returns |titlebar_{left,right}_buttons_vbox_| and their | 102 // Lazily builds and returns |titlebar_{left,right}_buttons_vbox_| and their |
| 103 // subtrees. We do this lazily because in most situations, only one of them | 103 // subtrees. We do this lazily because in most situations, only one of them |
| 104 // is allocated (though the user can (and do) manually mess with their gconf | 104 // is allocated (though the user can (and do) manually mess with their gconf |
| 105 // settings to get absolutely horrid combinations of buttons on both sides. | 105 // settings to get absolutely horrid combinations of buttons on both sides. |
| 106 GtkWidget* GetButtonHBox(bool left_side); | 106 GtkWidget* GetButtonHBox(bool left_side); |
| 107 | 107 |
| 108 // Constructs a CustomDraw button given 3 image ids (IDR_), the box to place | 108 // Constructs a CustomDraw button given 3 image ids (IDR_), the box to place |
| 109 // the button into, and a tooltip id (IDS_). | 109 // the button into, and a tooltip id (IDS_). |
| 110 CustomDrawButton* BuildTitlebarButton(int image, int image_pressed, | 110 CustomDrawButton* BuildTitlebarButton(int image, int image_pressed, |
| 111 int image_hot, GtkWidget* box, | 111 int image_hot, GtkWidget* box, |
| 112 int tooltip); | 112 bool start, int tooltip); |
| 113 | 113 |
| 114 // Update the titlebar spacing based on the custom frame and maximized state. | 114 // Update the titlebar spacing based on the custom frame and maximized state. |
| 115 void UpdateTitlebarAlignment(); | 115 void UpdateTitlebarAlignment(); |
| 116 | 116 |
| 117 // Updates the color of the title bar. Called whenever we have a state | 117 // Updates the color of the title bar. Called whenever we have a state |
| 118 // change in the window. | 118 // change in the window. |
| 119 void UpdateTextColor(); | 119 void UpdateTextColor(); |
| 120 | 120 |
| 121 // Show the menu that the user gets from left-clicking the favicon. | 121 // Show the menu that the user gets from left-clicking the favicon. |
| 122 void ShowFaviconMenu(GdkEventButton* event); | 122 void ShowFaviconMenu(GdkEventButton* event); |
| 123 | 123 |
| 124 // The maximize button was clicked, take an action depending on which mouse | 124 // The maximize button was clicked, take an action depending on which mouse |
| 125 // button the user pressed. | 125 // button the user pressed. |
| 126 void MaximizeButtonClicked(); | 126 void MaximizeButtonClicked(); |
| 127 | 127 |
| 128 // Updates the visibility of the maximize and restore buttons; only one can | 128 // Updates the visibility of the maximize and restore buttons; only one can |
| 129 // be visible at a time. | 129 // be visible at a time. |
| 130 void UpdateMaximizeRestoreVisibility(); | 130 void UpdateMaximizeRestoreVisibility(); |
| 131 | 131 |
| 132 // Callback for changes to window state. This includes | 132 // Callback for changes to window state. This includes |
| 133 // maximizing/restoring/minimizing the window. | 133 // maximizing/restoring/minimizing the window. |
| 134 CHROMEG_CALLBACK_1(BrowserTitlebar, gboolean, OnWindowStateChanged, | 134 CHROMEG_CALLBACK_1(BrowserTitlebar, gboolean, OnWindowStateChanged, |
| 135 GtkWindow*, GdkEventWindowState*); | 135 GtkWindow*, GdkEventWindowState*); |
| 136 | 136 |
| 137 // Callback for mousewheel events. | 137 // Callback for mousewheel events. |
| 138 CHROMEGTK_CALLBACK_1(BrowserTitlebar, gboolean, OnScroll, | 138 CHROMEGTK_CALLBACK_1(BrowserTitlebar, gboolean, OnScroll, |
| 139 GdkEventScroll*); | 139 GdkEventScroll*); |
| 140 | 140 |
| 141 // Callbacks for mouse enter leave events. |
| 142 CHROMEGTK_CALLBACK_1(BrowserTitlebar, gboolean, OnEnterNotify, |
| 143 GdkEventCrossing*); |
| 144 CHROMEGTK_CALLBACK_1(BrowserTitlebar, gboolean, OnLeaveNotify, |
| 145 GdkEventCrossing*); |
| 146 |
| 141 // Callback for min/max/close buttons. | 147 // Callback for min/max/close buttons. |
| 142 CHROMEGTK_CALLBACK_0(BrowserTitlebar, void, OnButtonClicked); | 148 CHROMEGTK_CALLBACK_0(BrowserTitlebar, void, OnButtonClicked); |
| 143 | 149 |
| 144 // Callback for favicon. | 150 // Callback for favicon. |
| 145 CHROMEGTK_CALLBACK_1(BrowserTitlebar, gboolean, OnButtonPressed, | 151 CHROMEGTK_CALLBACK_1(BrowserTitlebar, gboolean, OnButtonPressed, |
| 146 GdkEventButton*); | 152 GdkEventButton*); |
| 147 | 153 |
| 148 // -- Context Menu ----------------------------------------------------------- | 154 // -- Context Menu ----------------------------------------------------------- |
| 149 | 155 |
| 150 // SimpleMenuModel::Delegate implementation: | 156 // SimpleMenuModel::Delegate implementation: |
| 151 virtual bool IsCommandIdEnabled(int command_id) const; | 157 virtual bool IsCommandIdEnabled(int command_id) const; |
| 152 virtual bool IsCommandIdChecked(int command_id) const; | 158 virtual bool IsCommandIdChecked(int command_id) const; |
| 153 virtual void ExecuteCommand(int command_id); | 159 virtual void ExecuteCommand(int command_id); |
| 154 virtual bool GetAcceleratorForCommandId(int command_id, | 160 virtual bool GetAcceleratorForCommandId(int command_id, |
| 155 ui::Accelerator* accelerator); | 161 ui::Accelerator* accelerator); |
| 156 | 162 |
| 157 // Overridden from NotificationObserver: | 163 // Overridden from NotificationObserver: |
| 158 virtual void Observe(NotificationType type, | 164 virtual void Observe(NotificationType type, |
| 159 const NotificationSource& source, | 165 const NotificationSource& source, |
| 160 const NotificationDetails& details); | 166 const NotificationDetails& details); |
| 161 | 167 |
| 162 // Overriden from ActiveWindowWatcher::Observer. | 168 // Overriden from ActiveWindowWatcher::Observer. |
| 163 virtual void ActiveWindowChanged(GdkWindow* active_window); | 169 virtual void ActiveWindowChanged(GdkWindow* active_window); |
| 164 | 170 |
| 171 bool IsTypePanel(); |
| 172 |
| 165 // Pointers to the browser window that owns us and it's GtkWindow. | 173 // Pointers to the browser window that owns us and it's GtkWindow. |
| 166 BrowserWindowGtk* browser_window_; | 174 BrowserWindowGtk* browser_window_; |
| 167 GtkWindow* window_; | 175 GtkWindow* window_; |
| 168 | 176 |
| 169 // The container widget the holds the hbox which contains the whole titlebar. | 177 // The container widget the holds the hbox which contains the whole titlebar. |
| 170 GtkWidget* container_; | 178 GtkWidget* container_; |
| 171 | 179 |
| 172 // The hbox that contains the whole titlebar. | 180 // The hbox that contains the whole titlebar. |
| 173 GtkWidget* container_hbox_; | 181 GtkWidget* container_hbox_; |
| 174 | 182 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 195 GtkWidget* top_padding_right_; | 203 GtkWidget* top_padding_right_; |
| 196 | 204 |
| 197 // Gtk alignment that contains the tab strip. If the user turns off window | 205 // Gtk alignment that contains the tab strip. If the user turns off window |
| 198 // manager decorations, we draw this taller. | 206 // manager decorations, we draw this taller. |
| 199 GtkWidget* titlebar_alignment_; | 207 GtkWidget* titlebar_alignment_; |
| 200 | 208 |
| 201 // The favicon and page title used when in app mode or popup mode. | 209 // The favicon and page title used when in app mode or popup mode. |
| 202 GtkWidget* app_mode_favicon_; | 210 GtkWidget* app_mode_favicon_; |
| 203 GtkWidget* app_mode_title_; | 211 GtkWidget* app_mode_title_; |
| 204 | 212 |
| 213 // Wrench icon for panels. This'll only appear when a panel window has focus |
| 214 // or mouse is in a panel window. |
| 215 scoped_ptr<CustomDrawButton> panel_wrench_button_; |
| 216 |
| 205 // Whether we are using a custom frame. | 217 // Whether we are using a custom frame. |
| 206 bool using_custom_frame_; | 218 bool using_custom_frame_; |
| 207 | 219 |
| 208 // Whether we have focus (gtk_window_is_active() sometimes returns the wrong | 220 // Whether we have focus (gtk_window_is_active() sometimes returns the wrong |
| 209 // value, so manually track the focus-in and focus-out events.) | 221 // value, so manually track the focus-in and focus-out events.) |
| 210 bool window_has_focus_; | 222 bool window_has_focus_; |
| 211 | 223 |
| 224 // Whether mouse is in the window. We show the wrench icon when a panel |
| 225 // window has focus or mouse is in a panel window. |
| 226 bool window_has_mouse_; |
| 227 |
| 212 // We change the size of these three buttons when the window is maximized, so | 228 // We change the size of these three buttons when the window is maximized, so |
| 213 // we use these structs to keep track of their original size. | 229 // we use these structs to keep track of their original size. |
| 214 GtkRequisition close_button_req_; | 230 GtkRequisition close_button_req_; |
| 215 GtkRequisition minimize_button_req_; | 231 GtkRequisition minimize_button_req_; |
| 216 GtkRequisition restore_button_req_; | 232 GtkRequisition restore_button_req_; |
| 217 | 233 |
| 218 // Maximize and restore widgets in the titlebar. | 234 // Maximize and restore widgets in the titlebar. |
| 219 scoped_ptr<CustomDrawButton> minimize_button_; | 235 scoped_ptr<CustomDrawButton> minimize_button_; |
| 220 scoped_ptr<CustomDrawButton> maximize_button_; | 236 scoped_ptr<CustomDrawButton> maximize_button_; |
| 221 scoped_ptr<CustomDrawButton> restore_button_; | 237 scoped_ptr<CustomDrawButton> restore_button_; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 241 // Shown in the profile button. Only used to register a notification observer. | 257 // Shown in the profile button. Only used to register a notification observer. |
| 242 StringPrefMember usernamePref_; | 258 StringPrefMember usernamePref_; |
| 243 | 259 |
| 244 // Theme provider for building buttons. | 260 // Theme provider for building buttons. |
| 245 GtkThemeService* theme_service_; | 261 GtkThemeService* theme_service_; |
| 246 | 262 |
| 247 NotificationRegistrar registrar_; | 263 NotificationRegistrar registrar_; |
| 248 }; | 264 }; |
| 249 | 265 |
| 250 #endif // CHROME_BROWSER_UI_GTK_BROWSER_TITLEBAR_H_ | 266 #endif // CHROME_BROWSER_UI_GTK_BROWSER_TITLEBAR_H_ |
| OLD | NEW |