| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 // Called by the browser asking us to update the loading throbber. | 67 // Called by the browser asking us to update the loading throbber. |
| 68 // |web_contents| is the tab that is associated with the window throbber. | 68 // |web_contents| is the tab that is associated with the window throbber. |
| 69 // |web_contents| can be null. | 69 // |web_contents| can be null. |
| 70 void UpdateThrobber(content::WebContents* web_contents); | 70 void UpdateThrobber(content::WebContents* web_contents); |
| 71 | 71 |
| 72 // On Windows, right clicking in the titlebar background brings up the system | 72 // On Windows, right clicking in the titlebar background brings up the system |
| 73 // menu. There's no such thing on linux, so we just show the menu items we | 73 // menu. There's no such thing on linux, so we just show the menu items we |
| 74 // add to the menu. | 74 // add to the menu. |
| 75 void ShowContextMenu(GdkEventButton* event); | 75 void ShowContextMenu(GdkEventButton* event); |
| 76 | 76 |
| 77 // When a panel slides into a new position and the cursor is on the close | 77 // When a panel appears in the same position as the one of the panel being |
| 78 // button, the close button does not become clickable. The gtk_widget_show() | 78 // closed and the cursor stays in the close button, the close button appears |
| 79 // call on panel_wrench_button_ in OnEnterNotify on window_ prevents the | 79 // not to be clickable. This is because neither "enter-notify-event" nor |
| 80 // close_button_ from getting the enter-notify-event, making it unclickable. | 80 // "clicked" event for the new panel gets fired if the mouse does not move. |
| 81 // This creates a bad experience when a user has multiple panels of the same | 81 // This creates a bad experience when a user has multiple panels of the same |
| 82 // size (which is typical) and tries closing them all by repeatedly clicking | 82 // size (which is typical) and tries closing them all by repeatedly clicking |
| 83 // in the same place on the screen. | 83 // in the same place on the screen. |
| 84 // | 84 // |
| 85 // Opened a gtk bug for this - | 85 // Opened a gtk bug for this - |
| 86 // https://bugzilla.gnome.org/show_bug.cgi?id=667841 | 86 // https://bugzilla.gnome.org/show_bug.cgi?id=667841 |
| 87 void SendEnterNotifyToCloseButtonIfUnderMouse(); | 87 void SendEnterNotifyToCloseButtonIfUnderMouse(); |
| 88 | 88 |
| 89 // Returns the window width to display just the icon. | 89 // Returns the window width to display just the icon. |
| 90 int IconOnlyWidth(); | 90 int IconOnlyWidth(); |
| 91 | 91 |
| 92 void ShowPanelWrenchButton(); | |
| 93 void HidePanelWrenchButton(); | |
| 94 | |
| 95 AvatarMenuButtonGtk* avatar_button() { return avatar_button_.get(); } | 92 AvatarMenuButtonGtk* avatar_button() { return avatar_button_.get(); } |
| 96 | 93 |
| 97 private: | 94 private: |
| 98 // A helper class to keep track of which frame of the throbber animation | 95 // A helper class to keep track of which frame of the throbber animation |
| 99 // we're showing. | 96 // we're showing. |
| 100 class Throbber { | 97 class Throbber { |
| 101 public: | 98 public: |
| 102 Throbber() : current_frame_(0), current_waiting_frame_(0) {} | 99 Throbber() : current_frame_(0), current_waiting_frame_(0) {} |
| 103 | 100 |
| 104 // Get the next frame in the animation. The image is owned by the throbber | 101 // Get the next frame in the animation. The image is owned by the throbber |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 // Callback for mousewheel events. | 165 // Callback for mousewheel events. |
| 169 CHROMEGTK_CALLBACK_1(BrowserTitlebar, gboolean, OnScroll, | 166 CHROMEGTK_CALLBACK_1(BrowserTitlebar, gboolean, OnScroll, |
| 170 GdkEventScroll*); | 167 GdkEventScroll*); |
| 171 | 168 |
| 172 // Callback for min/max/close buttons. | 169 // Callback for min/max/close buttons. |
| 173 CHROMEGTK_CALLBACK_0(BrowserTitlebar, void, OnButtonClicked); | 170 CHROMEGTK_CALLBACK_0(BrowserTitlebar, void, OnButtonClicked); |
| 174 | 171 |
| 175 // Callback for favicon/settings buttons. | 172 // Callback for favicon/settings buttons. |
| 176 CHROMEGTK_CALLBACK_1(BrowserTitlebar, gboolean, | 173 CHROMEGTK_CALLBACK_1(BrowserTitlebar, gboolean, |
| 177 OnFaviconMenuButtonPressed, GdkEventButton*); | 174 OnFaviconMenuButtonPressed, GdkEventButton*); |
| 178 CHROMEGTK_CALLBACK_1(BrowserTitlebar, gboolean, | |
| 179 OnPanelSettingsMenuButtonPressed, GdkEventButton*); | |
| 180 | 175 |
| 181 // -- Context Menu ----------------------------------------------------------- | 176 // -- Context Menu ----------------------------------------------------------- |
| 182 | 177 |
| 183 // SimpleMenuModel::Delegate implementation: | 178 // SimpleMenuModel::Delegate implementation: |
| 184 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; | 179 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; |
| 185 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; | 180 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; |
| 186 virtual void ExecuteCommand(int command_id) OVERRIDE; | 181 virtual void ExecuteCommand(int command_id) OVERRIDE; |
| 187 virtual bool GetAcceleratorForCommandId( | 182 virtual bool GetAcceleratorForCommandId( |
| 188 int command_id, | 183 int command_id, |
| 189 ui::Accelerator* accelerator) OVERRIDE; | 184 ui::Accelerator* accelerator) OVERRIDE; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 GtkWidget* top_padding_right_; | 237 GtkWidget* top_padding_right_; |
| 243 | 238 |
| 244 // Gtk alignment that contains the tab strip. If the user turns off window | 239 // Gtk alignment that contains the tab strip. If the user turns off window |
| 245 // manager decorations, we draw this taller. | 240 // manager decorations, we draw this taller. |
| 246 GtkWidget* titlebar_alignment_; | 241 GtkWidget* titlebar_alignment_; |
| 247 | 242 |
| 248 // The favicon and page title used when in app mode or popup mode. | 243 // The favicon and page title used when in app mode or popup mode. |
| 249 GtkWidget* app_mode_favicon_; | 244 GtkWidget* app_mode_favicon_; |
| 250 GtkWidget* app_mode_title_; | 245 GtkWidget* app_mode_title_; |
| 251 | 246 |
| 252 // Wrench icon for panels. This'll only appear when a panel window has focus | |
| 253 // or mouse is in a panel window. | |
| 254 scoped_ptr<CustomDrawButton> panel_wrench_button_; | |
| 255 | |
| 256 // Whether we are using a custom frame. | 247 // Whether we are using a custom frame. |
| 257 bool using_custom_frame_; | 248 bool using_custom_frame_; |
| 258 | 249 |
| 259 // Whether we have focus (gtk_window_is_active() sometimes returns the wrong | 250 // Whether we have focus (gtk_window_is_active() sometimes returns the wrong |
| 260 // value, so manually track the focus-in and focus-out events.) | 251 // value, so manually track the focus-in and focus-out events.) |
| 261 bool window_has_focus_; | 252 bool window_has_focus_; |
| 262 | 253 |
| 263 // Whether to display the avatar image on the left or right of the titlebar. | 254 // Whether to display the avatar image on the left or right of the titlebar. |
| 264 bool display_avatar_on_left_; | 255 bool display_avatar_on_left_; |
| 265 | 256 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 289 // The avatar button. | 280 // The avatar button. |
| 290 scoped_ptr<AvatarMenuButtonGtk> avatar_button_; | 281 scoped_ptr<AvatarMenuButtonGtk> avatar_button_; |
| 291 | 282 |
| 292 // Theme provider for building buttons. | 283 // Theme provider for building buttons. |
| 293 ThemeServiceGtk* theme_service_; | 284 ThemeServiceGtk* theme_service_; |
| 294 | 285 |
| 295 content::NotificationRegistrar registrar_; | 286 content::NotificationRegistrar registrar_; |
| 296 }; | 287 }; |
| 297 | 288 |
| 298 #endif // CHROME_BROWSER_UI_GTK_BROWSER_TITLEBAR_H_ | 289 #endif // CHROME_BROWSER_UI_GTK_BROWSER_TITLEBAR_H_ |
| OLD | NEW |