Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(450)

Side by Side Diff: chrome/browser/gtk/browser_titlebar.cc

Issue 150072: Make tabstrip flush with top of titlebar when custom frame is enabled and bro... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/gtk/browser_titlebar.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 54 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
55 otr_avatar = rb.GetRTLEnabledPixbufNamed(IDR_OTR_ICON); 55 otr_avatar = rb.GetRTLEnabledPixbufNamed(IDR_OTR_ICON);
56 } 56 }
57 return otr_avatar; 57 return otr_avatar;
58 } 58 }
59 59
60 } // namespace 60 } // namespace
61 61
62 BrowserTitlebar::BrowserTitlebar(BrowserWindowGtk* browser_window, 62 BrowserTitlebar::BrowserTitlebar(BrowserWindowGtk* browser_window,
63 GtkWindow* window) 63 GtkWindow* window)
64 : browser_window_(browser_window), window_(window) { 64 : browser_window_(browser_window), window_(window),
65 using_custom_frame_(false) {
65 Init(); 66 Init();
66 } 67 }
67 68
68 void BrowserTitlebar::Init() { 69 void BrowserTitlebar::Init() {
69 // The widget hierarchy is shown below. 70 // The widget hierarchy is shown below.
70 // 71 //
71 // +- HBox (container_) -----------------------------------------------------+ 72 // +- HBox (container_) -----------------------------------------------------+
72 // |+- Algn. -++- Alignment --------------++- VBox (titlebar_buttons_box_) -+| 73 // |+- Algn. -++- Alignment --------------++- VBox (titlebar_buttons_box_) -+|
73 // ||+ Image +|| (titlebar_alignment_) ||+- HBox -----------------------+|| 74 // ||+ Image +|| (titlebar_alignment_) ||+- HBox -----------------------+||
74 // |||spy_guy||| |||+- button -++- button -+ ||| 75 // |||spy_guy||| |||+- button -++- button -+ |||
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 g_signal_connect(button->widget(), "motion-notify-event", 140 g_signal_connect(button->widget(), "motion-notify-event",
140 G_CALLBACK(OnMouseMoveEvent), browser_window_); 141 G_CALLBACK(OnMouseMoveEvent), browser_window_);
141 std::string localized_tooltip = l10n_util::GetStringUTF8(tooltip); 142 std::string localized_tooltip = l10n_util::GetStringUTF8(tooltip);
142 gtk_widget_set_tooltip_text(button->widget(), 143 gtk_widget_set_tooltip_text(button->widget(),
143 localized_tooltip.c_str()); 144 localized_tooltip.c_str());
144 gtk_box_pack_end(GTK_BOX(box), button->widget(), FALSE, FALSE, 0); 145 gtk_box_pack_end(GTK_BOX(box), button->widget(), FALSE, FALSE, 0);
145 return button; 146 return button;
146 } 147 }
147 148
148 void BrowserTitlebar::UpdateCustomFrame(bool use_custom_frame) { 149 void BrowserTitlebar::UpdateCustomFrame(bool use_custom_frame) {
149 if (use_custom_frame) { 150 using_custom_frame_ = use_custom_frame;
151 if (use_custom_frame)
152 gtk_widget_show(titlebar_buttons_box_);
153 else
154 gtk_widget_hide(titlebar_buttons_box_);
155 UpdateTitlebarAlignment();
156 }
157
158 void BrowserTitlebar::UpdateTitlebarAlignment() {
159 if (using_custom_frame_ && !browser_window_->IsMaximized()) {
150 gtk_alignment_set_padding(GTK_ALIGNMENT(titlebar_alignment_), 160 gtk_alignment_set_padding(GTK_ALIGNMENT(titlebar_alignment_),
151 kTitlebarHeight, 0, 0, 0); 161 kTitlebarHeight, 0, 0, 0);
152 gtk_widget_show(titlebar_buttons_box_);
153 } else { 162 } else {
154 gtk_alignment_set_padding(GTK_ALIGNMENT(titlebar_alignment_), 0, 0, 0, 0); 163 gtk_alignment_set_padding(GTK_ALIGNMENT(titlebar_alignment_), 0, 0, 0, 0);
155 gtk_widget_hide(titlebar_buttons_box_);
156 } 164 }
157 } 165 }
158 166
167 // static
159 gboolean BrowserTitlebar::OnWindowStateChanged(GtkWindow* window, 168 gboolean BrowserTitlebar::OnWindowStateChanged(GtkWindow* window,
160 GdkEventWindowState* event, BrowserTitlebar* titlebar) { 169 GdkEventWindowState* event, BrowserTitlebar* titlebar) {
161 // Update the maximize/restore button. 170 // Update the maximize/restore button.
162 if (titlebar->browser_window_->IsMaximized()) { 171 if (titlebar->browser_window_->IsMaximized()) {
163 gtk_widget_hide(titlebar->maximize_button_->widget()); 172 gtk_widget_hide(titlebar->maximize_button_->widget());
164 gtk_widget_show(titlebar->restore_button_->widget()); 173 gtk_widget_show(titlebar->restore_button_->widget());
165 } else { 174 } else {
166 gtk_widget_hide(titlebar->restore_button_->widget()); 175 gtk_widget_hide(titlebar->restore_button_->widget());
167 gtk_widget_show(titlebar->maximize_button_->widget()); 176 gtk_widget_show(titlebar->maximize_button_->widget());
168 } 177 }
178 titlebar->UpdateTitlebarAlignment();
169 return FALSE; 179 return FALSE;
170 } 180 }
171 181
182 // static
172 void BrowserTitlebar::OnButtonClicked(GtkWidget* button, 183 void BrowserTitlebar::OnButtonClicked(GtkWidget* button,
173 BrowserTitlebar* titlebar) { 184 BrowserTitlebar* titlebar) {
174 if (titlebar->close_button_->widget() == button) { 185 if (titlebar->close_button_->widget() == button) {
175 titlebar->browser_window_->Close(); 186 titlebar->browser_window_->Close();
176 } else if (titlebar->restore_button_->widget() == button) { 187 } else if (titlebar->restore_button_->widget() == button) {
177 gtk_window_unmaximize(titlebar->window_); 188 gtk_window_unmaximize(titlebar->window_);
178 } else if (titlebar->maximize_button_->widget() == button) { 189 } else if (titlebar->maximize_button_->widget() == button) {
179 gtk_window_maximize(titlebar->window_); 190 gtk_window_maximize(titlebar->window_);
180 } else if (titlebar->minimize_button_->widget() == button) { 191 } else if (titlebar->minimize_button_->widget() == button) {
181 gtk_window_iconify(titlebar->window_); 192 gtk_window_iconify(titlebar->window_);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 PrefService* prefs = browser_window_->browser()->profile()->GetPrefs(); 257 PrefService* prefs = browser_window_->browser()->profile()->GetPrefs();
247 prefs->SetBoolean(prefs::kUseCustomChromeFrame, 258 prefs->SetBoolean(prefs::kUseCustomChromeFrame,
248 !prefs->GetBoolean(prefs::kUseCustomChromeFrame)); 259 !prefs->GetBoolean(prefs::kUseCustomChromeFrame));
249 break; 260 break;
250 } 261 }
251 262
252 default: 263 default:
253 NOTREACHED(); 264 NOTREACHED();
254 } 265 }
255 } 266 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/browser_titlebar.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698