| 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 <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 const int kOTRBottomSpacing = 2; | 42 const int kOTRBottomSpacing = 2; |
| 43 // There are 2 px on each side of the OTR avatar (between the frame border and | 43 // There are 2 px on each side of the OTR avatar (between the frame border and |
| 44 // it on the left, and between it and the tabstrip on the right). | 44 // it on the left, and between it and the tabstrip on the right). |
| 45 const int kOTRSideSpacing = 2; | 45 const int kOTRSideSpacing = 2; |
| 46 | 46 |
| 47 // The thickness of the custom frame border; we need it here to enlarge the | 47 // The thickness of the custom frame border; we need it here to enlarge the |
| 48 // close button whent the custom frame border isn't showing but the custom | 48 // close button whent the custom frame border isn't showing but the custom |
| 49 // titlebar is showing. | 49 // titlebar is showing. |
| 50 const int kFrameBorderThickness = 4; | 50 const int kFrameBorderThickness = 4; |
| 51 | 51 |
| 52 // The left padding of the tab strip. In Views, the tab strip has a left |
| 53 // margin of FrameBorderThickness + kClientEdgeThickness. This offset is to |
| 54 // account for kClientEdgeThickness. |
| 55 const int kTabStripLeftPadding = 1; |
| 56 |
| 52 gboolean OnMouseMoveEvent(GtkWidget* widget, GdkEventMotion* event, | 57 gboolean OnMouseMoveEvent(GtkWidget* widget, GdkEventMotion* event, |
| 53 BrowserWindowGtk* browser_window) { | 58 BrowserWindowGtk* browser_window) { |
| 54 // Reset to the default mouse cursor. | 59 // Reset to the default mouse cursor. |
| 55 browser_window->ResetCustomFrameCursor(); | 60 browser_window->ResetCustomFrameCursor(); |
| 56 return TRUE; | 61 return TRUE; |
| 57 } | 62 } |
| 58 | 63 |
| 59 GdkPixbuf* GetOTRAvatar() { | 64 GdkPixbuf* GetOTRAvatar() { |
| 60 static GdkPixbuf* otr_avatar = NULL; | 65 static GdkPixbuf* otr_avatar = NULL; |
| 61 if (!otr_avatar) { | 66 if (!otr_avatar) { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 if (use_custom_frame) | 176 if (use_custom_frame) |
| 172 gtk_widget_show(titlebar_buttons_box_); | 177 gtk_widget_show(titlebar_buttons_box_); |
| 173 else | 178 else |
| 174 gtk_widget_hide(titlebar_buttons_box_); | 179 gtk_widget_hide(titlebar_buttons_box_); |
| 175 UpdateTitlebarAlignment(); | 180 UpdateTitlebarAlignment(); |
| 176 } | 181 } |
| 177 | 182 |
| 178 void BrowserTitlebar::UpdateTitlebarAlignment() { | 183 void BrowserTitlebar::UpdateTitlebarAlignment() { |
| 179 if (using_custom_frame_ && !browser_window_->IsMaximized()) { | 184 if (using_custom_frame_ && !browser_window_->IsMaximized()) { |
| 180 gtk_alignment_set_padding(GTK_ALIGNMENT(titlebar_alignment_), | 185 gtk_alignment_set_padding(GTK_ALIGNMENT(titlebar_alignment_), |
| 181 kTitlebarHeight, 0, 0, 0); | 186 kTitlebarHeight, 0, kTabStripLeftPadding, 0); |
| 182 } else { | 187 } else { |
| 183 gtk_alignment_set_padding(GTK_ALIGNMENT(titlebar_alignment_), 0, 0, 0, 0); | 188 gtk_alignment_set_padding(GTK_ALIGNMENT(titlebar_alignment_), 0, 0, |
| 189 kTabStripLeftPadding, 0); |
| 184 } | 190 } |
| 185 | 191 |
| 186 int close_button_width = close_button_default_width_; | 192 int close_button_width = close_button_default_width_; |
| 187 if (using_custom_frame_ && browser_window_->IsMaximized()) | 193 if (using_custom_frame_ && browser_window_->IsMaximized()) |
| 188 close_button_width += kFrameBorderThickness; | 194 close_button_width += kFrameBorderThickness; |
| 189 gtk_widget_set_size_request(close_button_->widget(), close_button_width, -1); | 195 gtk_widget_set_size_request(close_button_->widget(), close_button_width, -1); |
| 190 } | 196 } |
| 191 | 197 |
| 192 // static | 198 // static |
| 193 gboolean BrowserTitlebar::OnWindowStateChanged(GtkWindow* window, | 199 gboolean BrowserTitlebar::OnWindowStateChanged(GtkWindow* window, |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 PrefService* prefs = browser_window_->browser()->profile()->GetPrefs(); | 301 PrefService* prefs = browser_window_->browser()->profile()->GetPrefs(); |
| 296 prefs->SetBoolean(prefs::kUseCustomChromeFrame, | 302 prefs->SetBoolean(prefs::kUseCustomChromeFrame, |
| 297 !prefs->GetBoolean(prefs::kUseCustomChromeFrame)); | 303 !prefs->GetBoolean(prefs::kUseCustomChromeFrame)); |
| 298 break; | 304 break; |
| 299 } | 305 } |
| 300 | 306 |
| 301 default: | 307 default: |
| 302 NOTREACHED(); | 308 NOTREACHED(); |
| 303 } | 309 } |
| 304 } | 310 } |
| OLD | NEW |