| 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 #include "chrome/browser/gtk/browser_titlebar.h" | 5 #include "chrome/browser/gtk/browser_titlebar.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
| 10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // that it doesn't extend into the "3D edge" portion of the titlebar. | 34 // that it doesn't extend into the "3D edge" portion of the titlebar. |
| 35 const int kOTRMaximizedTopSpacing = 2; | 35 const int kOTRMaximizedTopSpacing = 2; |
| 36 // The OTR avatar ends 2 px above the bottom of the tabstrip (which, given the | 36 // The OTR avatar ends 2 px above the bottom of the tabstrip (which, given the |
| 37 // way the tabstrip draws its bottom edge, will appear like a 1 px gap to the | 37 // way the tabstrip draws its bottom edge, will appear like a 1 px gap to the |
| 38 // user). | 38 // user). |
| 39 const int kOTRBottomSpacing = 2; | 39 const int kOTRBottomSpacing = 2; |
| 40 // There are 2 px on each side of the OTR avatar (between the frame border and | 40 // There are 2 px on each side of the OTR avatar (between the frame border and |
| 41 // it on the left, and between it and the tabstrip on the right). | 41 // it on the left, and between it and the tabstrip on the right). |
| 42 const int kOTRSideSpacing = 2; | 42 const int kOTRSideSpacing = 2; |
| 43 | 43 |
| 44 // The thickness of the custom frame border; we need it here to enlarge the |
| 45 // close button whent the custom frame border isn't showing but the custom |
| 46 // titlebar is showing. |
| 47 const int kFrameBorderThickness = 4; |
| 48 |
| 44 gboolean OnMouseMoveEvent(GtkWidget* widget, GdkEventMotion* event, | 49 gboolean OnMouseMoveEvent(GtkWidget* widget, GdkEventMotion* event, |
| 45 BrowserWindowGtk* browser_window) { | 50 BrowserWindowGtk* browser_window) { |
| 46 // Reset to the default mouse cursor. | 51 // Reset to the default mouse cursor. |
| 47 browser_window->ResetCustomFrameCursor(); | 52 browser_window->ResetCustomFrameCursor(); |
| 48 return TRUE; | 53 return TRUE; |
| 49 } | 54 } |
| 50 | 55 |
| 51 GdkPixbuf* GetOTRAvatar() { | 56 GdkPixbuf* GetOTRAvatar() { |
| 52 static GdkPixbuf* otr_avatar = NULL; | 57 static GdkPixbuf* otr_avatar = NULL; |
| 53 if (!otr_avatar) { | 58 if (!otr_avatar) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 restore_button_.reset(BuildTitlebarButton(IDR_RESTORE, IDR_RESTORE_P, | 122 restore_button_.reset(BuildTitlebarButton(IDR_RESTORE, IDR_RESTORE_P, |
| 118 IDR_RESTORE_H, buttons_hbox, | 123 IDR_RESTORE_H, buttons_hbox, |
| 119 IDS_XPFRAME_RESTORE_TOOLTIP)); | 124 IDS_XPFRAME_RESTORE_TOOLTIP)); |
| 120 maximize_button_.reset(BuildTitlebarButton(IDR_MAXIMIZE, IDR_MAXIMIZE_P, | 125 maximize_button_.reset(BuildTitlebarButton(IDR_MAXIMIZE, IDR_MAXIMIZE_P, |
| 121 IDR_MAXIMIZE_H, buttons_hbox, | 126 IDR_MAXIMIZE_H, buttons_hbox, |
| 122 IDS_XPFRAME_MAXIMIZE_TOOLTIP)); | 127 IDS_XPFRAME_MAXIMIZE_TOOLTIP)); |
| 123 minimize_button_.reset(BuildTitlebarButton(IDR_MINIMIZE, IDR_MINIMIZE_P, | 128 minimize_button_.reset(BuildTitlebarButton(IDR_MINIMIZE, IDR_MINIMIZE_P, |
| 124 IDR_MINIMIZE_H, buttons_hbox, | 129 IDR_MINIMIZE_H, buttons_hbox, |
| 125 IDS_XPFRAME_MINIMIZE_TOOLTIP)); | 130 IDS_XPFRAME_MINIMIZE_TOOLTIP)); |
| 126 | 131 |
| 132 GtkRequisition req; |
| 133 gtk_widget_size_request(close_button_->widget(), &req); |
| 134 close_button_default_width_ = req.width; |
| 135 |
| 127 gtk_box_pack_end(GTK_BOX(container_), titlebar_buttons_box_, FALSE, | 136 gtk_box_pack_end(GTK_BOX(container_), titlebar_buttons_box_, FALSE, |
| 128 FALSE, 0); | 137 FALSE, 0); |
| 129 | 138 |
| 130 gtk_widget_show_all(container_); | 139 gtk_widget_show_all(container_); |
| 131 } | 140 } |
| 132 | 141 |
| 133 CustomDrawButton* BrowserTitlebar::BuildTitlebarButton(int image, | 142 CustomDrawButton* BrowserTitlebar::BuildTitlebarButton(int image, |
| 134 int image_pressed, int image_hot, GtkWidget* box, int tooltip) { | 143 int image_pressed, int image_hot, GtkWidget* box, int tooltip) { |
| 135 CustomDrawButton* button = new CustomDrawButton(image, image_pressed, | 144 CustomDrawButton* button = new CustomDrawButton(image, image_pressed, |
| 136 image_hot, 0); | 145 image_hot, 0); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 155 UpdateTitlebarAlignment(); | 164 UpdateTitlebarAlignment(); |
| 156 } | 165 } |
| 157 | 166 |
| 158 void BrowserTitlebar::UpdateTitlebarAlignment() { | 167 void BrowserTitlebar::UpdateTitlebarAlignment() { |
| 159 if (using_custom_frame_ && !browser_window_->IsMaximized()) { | 168 if (using_custom_frame_ && !browser_window_->IsMaximized()) { |
| 160 gtk_alignment_set_padding(GTK_ALIGNMENT(titlebar_alignment_), | 169 gtk_alignment_set_padding(GTK_ALIGNMENT(titlebar_alignment_), |
| 161 kTitlebarHeight, 0, 0, 0); | 170 kTitlebarHeight, 0, 0, 0); |
| 162 } else { | 171 } else { |
| 163 gtk_alignment_set_padding(GTK_ALIGNMENT(titlebar_alignment_), 0, 0, 0, 0); | 172 gtk_alignment_set_padding(GTK_ALIGNMENT(titlebar_alignment_), 0, 0, 0, 0); |
| 164 } | 173 } |
| 174 |
| 175 int close_button_width = close_button_default_width_; |
| 176 if (using_custom_frame_ && browser_window_->IsMaximized()) |
| 177 close_button_width += kFrameBorderThickness; |
| 178 gtk_widget_set_size_request(close_button_->widget(), close_button_width, -1); |
| 165 } | 179 } |
| 166 | 180 |
| 167 // static | 181 // static |
| 168 gboolean BrowserTitlebar::OnWindowStateChanged(GtkWindow* window, | 182 gboolean BrowserTitlebar::OnWindowStateChanged(GtkWindow* window, |
| 169 GdkEventWindowState* event, BrowserTitlebar* titlebar) { | 183 GdkEventWindowState* event, BrowserTitlebar* titlebar) { |
| 170 // Update the maximize/restore button. | 184 // Update the maximize/restore button. |
| 171 if (titlebar->browser_window_->IsMaximized()) { | 185 if (titlebar->browser_window_->IsMaximized()) { |
| 172 gtk_widget_hide(titlebar->maximize_button_->widget()); | 186 gtk_widget_hide(titlebar->maximize_button_->widget()); |
| 173 gtk_widget_show(titlebar->restore_button_->widget()); | 187 gtk_widget_show(titlebar->restore_button_->widget()); |
| 174 } else { | 188 } else { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 PrefService* prefs = browser_window_->browser()->profile()->GetPrefs(); | 271 PrefService* prefs = browser_window_->browser()->profile()->GetPrefs(); |
| 258 prefs->SetBoolean(prefs::kUseCustomChromeFrame, | 272 prefs->SetBoolean(prefs::kUseCustomChromeFrame, |
| 259 !prefs->GetBoolean(prefs::kUseCustomChromeFrame)); | 273 !prefs->GetBoolean(prefs::kUseCustomChromeFrame)); |
| 260 break; | 274 break; |
| 261 } | 275 } |
| 262 | 276 |
| 263 default: | 277 default: |
| 264 NOTREACHED(); | 278 NOTREACHED(); |
| 265 } | 279 } |
| 266 } | 280 } |
| OLD | NEW |