diff options
-rw-r--r-- | chrome/browser/gtk/browser_titlebar.cc | 19 | ||||
-rw-r--r-- | chrome/browser/gtk/browser_titlebar.h | 6 |
2 files changed, 21 insertions, 4 deletions
diff --git a/chrome/browser/gtk/browser_titlebar.cc b/chrome/browser/gtk/browser_titlebar.cc index 2efc2bf..222f249 100644 --- a/chrome/browser/gtk/browser_titlebar.cc +++ b/chrome/browser/gtk/browser_titlebar.cc @@ -61,7 +61,8 @@ GdkPixbuf* GetOTRAvatar() { BrowserTitlebar::BrowserTitlebar(BrowserWindowGtk* browser_window, GtkWindow* window) - : browser_window_(browser_window), window_(window) { + : browser_window_(browser_window), window_(window), + using_custom_frame_(false) { Init(); } @@ -146,16 +147,24 @@ CustomDrawButton* BrowserTitlebar::BuildTitlebarButton(int image, } void BrowserTitlebar::UpdateCustomFrame(bool use_custom_frame) { - if (use_custom_frame) { + using_custom_frame_ = use_custom_frame; + if (use_custom_frame) + gtk_widget_show(titlebar_buttons_box_); + else + gtk_widget_hide(titlebar_buttons_box_); + UpdateTitlebarAlignment(); +} + +void BrowserTitlebar::UpdateTitlebarAlignment() { + if (using_custom_frame_ && !browser_window_->IsMaximized()) { gtk_alignment_set_padding(GTK_ALIGNMENT(titlebar_alignment_), kTitlebarHeight, 0, 0, 0); - gtk_widget_show(titlebar_buttons_box_); } else { gtk_alignment_set_padding(GTK_ALIGNMENT(titlebar_alignment_), 0, 0, 0, 0); - gtk_widget_hide(titlebar_buttons_box_); } } +// static gboolean BrowserTitlebar::OnWindowStateChanged(GtkWindow* window, GdkEventWindowState* event, BrowserTitlebar* titlebar) { // Update the maximize/restore button. @@ -166,9 +175,11 @@ gboolean BrowserTitlebar::OnWindowStateChanged(GtkWindow* window, gtk_widget_hide(titlebar->restore_button_->widget()); gtk_widget_show(titlebar->maximize_button_->widget()); } + titlebar->UpdateTitlebarAlignment(); return FALSE; } +// static void BrowserTitlebar::OnButtonClicked(GtkWidget* button, BrowserTitlebar* titlebar) { if (titlebar->close_button_->widget() == button) { diff --git a/chrome/browser/gtk/browser_titlebar.h b/chrome/browser/gtk/browser_titlebar.h index 1dc8121..3d141d4 100644 --- a/chrome/browser/gtk/browser_titlebar.h +++ b/chrome/browser/gtk/browser_titlebar.h @@ -50,6 +50,9 @@ class BrowserTitlebar : public MenuGtk::Delegate { int image_hot, GtkWidget* box, int tooltip); + // Update the titlebar spacing based on the custom frame and maximized state. + void UpdateTitlebarAlignment(); + // Callback for changes to window state. This includes // maximizing/restoring/minimizing the window. static gboolean OnWindowStateChanged(GtkWindow* window, @@ -79,6 +82,9 @@ class BrowserTitlebar : public MenuGtk::Delegate { // manager decorations, we draw this taller. GtkWidget* titlebar_alignment_; + // Whether we are using a custom frame. + bool using_custom_frame_; + // Maximize and restore widgets in the titlebar. scoped_ptr<CustomDrawButton> minimize_button_; scoped_ptr<CustomDrawButton> maximize_button_; |