| 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 #include "chrome/browser/ui/panels/panel_browser_titlebar_gtk.h" | 5 #include "chrome/browser/ui/panels/panel_browser_titlebar_gtk.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/browser/ui/gtk/custom_button.h" | 9 #include "chrome/browser/ui/gtk/custom_button.h" |
| 10 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 10 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| 11 #include "chrome/browser/ui/gtk/gtk_util.h" | 11 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 12 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| 12 #include "chrome/browser/ui/panels/panel.h" | 13 #include "chrome/browser/ui/panels/panel.h" |
| 13 #include "chrome/browser/ui/panels/panel_browser_window_gtk.h" | 14 #include "chrome/browser/ui/panels/panel_browser_window_gtk.h" |
| 15 #include "chrome/common/chrome_notification_types.h" |
| 16 #include "content/public/browser/notification_service.h" |
| 17 #include "content/public/browser/web_contents.h" |
| 14 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
| 15 #include "grit/theme_resources.h" | 19 #include "grit/theme_resources.h" |
| 20 #include "third_party/skia/include/core/SkBitmap.h" |
| 16 #include "ui/base/gtk/gtk_compat.h" | 21 #include "ui/base/gtk/gtk_compat.h" |
| 22 #include "ui/base/l10n/l10n_util.h" |
| 23 #include "ui/base/resource/resource_bundle.h" |
| 17 #include "ui/gfx/skia_utils_gtk.h" | 24 #include "ui/gfx/skia_utils_gtk.h" |
| 18 | 25 |
| 19 namespace { | 26 namespace { |
| 20 | 27 |
| 28 // Padding around the titlebar. |
| 29 const int kPanelTitlebarPaddingTop = 7; |
| 30 const int kPanelTitlebarPaddingBottom = 7; |
| 31 const int kPanelTitlebarPaddingLeft = 4; |
| 32 const int kPanelTitlebarPaddingRight = 9; |
| 33 |
| 21 // Spacing between buttons of panel's titlebar. | 34 // Spacing between buttons of panel's titlebar. |
| 22 const int kPanelButtonSpacing = 7; | 35 const int kPanelButtonSpacing = 9; |
| 23 | 36 |
| 24 // Spacing around outside of panel's titlebar buttons. | 37 // Spacing between the icon and the title text. |
| 25 const int kPanelButtonOuterPadding = 7; | 38 const int kPanelIconTitleSpacing = 9; |
| 26 | 39 |
| 27 // Markup for painting title as bold. | 40 // Color used to draw title text under default theme. |
| 28 const char* const kTitleMarkupPrefix = "<span font_weight='bold'>"; | 41 const SkColor kTitleTextDefaultColor = SkColorSetRGB(0xf9, 0xf9, 0xf9); |
| 42 |
| 43 // Markup used to paint the title with the desired font. |
| 44 const char* const kTitleMarkupPrefix = "<span face='Arial' size='11264'>"; |
| 29 const char* const kTitleMarkupSuffix = "</span>"; | 45 const char* const kTitleMarkupSuffix = "</span>"; |
| 30 | 46 |
| 31 // Colors used to draw title in attention mode. | |
| 32 const SkColor kAttentionTitleTextDefaultColor = SK_ColorWHITE; | |
| 33 | |
| 34 // Alpha value used in drawing inactive titlebar under non-default theme. | |
| 35 const U8CPU kInactiveAlphaBlending = 0x80; | |
| 36 | |
| 37 SkColor BlendSkColorWithAlpha(SkColor fg_color, SkColor bg_color, U8CPU alpha) { | |
| 38 if (alpha == 255) | |
| 39 return fg_color; | |
| 40 double fg_ratio = alpha / 255.0; | |
| 41 double bg_ratio = 1.0 - fg_ratio; | |
| 42 return SkColorSetRGB( | |
| 43 (SkColorGetR(fg_color) * fg_ratio + SkColorGetR(bg_color) * bg_ratio), | |
| 44 (SkColorGetG(fg_color) * fg_ratio + SkColorGetG(bg_color) * bg_ratio), | |
| 45 (SkColorGetB(fg_color) * fg_ratio + SkColorGetB(bg_color) * bg_ratio)); | |
| 46 } | |
| 47 | |
| 48 } // namespace | 47 } // namespace |
| 49 | 48 |
| 50 PanelBrowserTitlebarGtk::PanelBrowserTitlebarGtk( | 49 PanelBrowserTitlebarGtk::PanelBrowserTitlebarGtk( |
| 51 PanelBrowserWindowGtk* browser_window, GtkWindow* window) | 50 PanelBrowserWindowGtk* browser_window, GtkWindow* window) |
| 52 : BrowserTitlebar(browser_window, window), | 51 : browser_window_(browser_window), |
| 53 browser_window_(browser_window) { | 52 window_(window), |
| 53 container_(NULL), |
| 54 titlebar_right_buttons_vbox_(NULL), |
| 55 titlebar_right_buttons_hbox_(NULL), |
| 56 icon_(NULL), |
| 57 title_(NULL), |
| 58 theme_service_(NULL) { |
| 54 } | 59 } |
| 55 | 60 |
| 56 PanelBrowserTitlebarGtk::~PanelBrowserTitlebarGtk() { | 61 PanelBrowserTitlebarGtk::~PanelBrowserTitlebarGtk() { |
| 57 } | 62 } |
| 58 | 63 |
| 64 void PanelBrowserTitlebarGtk::Init() { |
| 65 container_ = gtk_event_box_new(); |
| 66 gtk_widget_set_name(container_, "chrome-panel-titlebar"); |
| 67 gtk_event_box_set_visible_window(GTK_EVENT_BOX(container_), FALSE); |
| 68 |
| 69 // We use an alignment to control the titlebar paddings. |
| 70 GtkWidget* container_alignment = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); |
| 71 gtk_container_add(GTK_CONTAINER(container_), container_alignment); |
| 72 gtk_alignment_set_padding(GTK_ALIGNMENT(container_alignment), |
| 73 kPanelTitlebarPaddingTop, |
| 74 kPanelTitlebarPaddingBottom, |
| 75 kPanelTitlebarPaddingLeft, |
| 76 kPanelTitlebarPaddingRight); |
| 77 |
| 78 // Add a container box. |
| 79 GtkWidget* container_hbox = gtk_hbox_new(FALSE, 0); |
| 80 gtk_container_add(GTK_CONTAINER(container_alignment), container_hbox); |
| 81 |
| 82 g_signal_connect(window_, "window-state-event", |
| 83 G_CALLBACK(OnWindowStateChangedThunk), this); |
| 84 |
| 85 // Add minimize/restore and close buttons. Panel buttons are always placed |
| 86 // on the right part of the titlebar. |
| 87 titlebar_right_buttons_vbox_ = gtk_vbox_new(FALSE, 0); |
| 88 gtk_box_pack_end(GTK_BOX(container_hbox), titlebar_right_buttons_vbox_, |
| 89 FALSE, FALSE, 0); |
| 90 BuildButtons(); |
| 91 |
| 92 // Add hbox for holding icon and title. |
| 93 GtkWidget* icon_title_hbox = gtk_hbox_new(FALSE, kPanelIconTitleSpacing); |
| 94 gtk_box_pack_start(GTK_BOX(container_hbox), icon_title_hbox, TRUE, TRUE, 0); |
| 95 |
| 96 // Add icon. We use the app logo as a placeholder image so the title doesn't |
| 97 // jump around. |
| 98 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 99 icon_ = gtk_image_new_from_pixbuf(rb.GetNativeImageNamed( |
| 100 IDR_PRODUCT_LOGO_16, ui::ResourceBundle::RTL_ENABLED).ToGdkPixbuf()); |
| 101 g_object_set_data(G_OBJECT(icon_), "left-align-popup", |
| 102 reinterpret_cast<void*>(true)); |
| 103 gtk_box_pack_start(GTK_BOX(icon_title_hbox), icon_, FALSE, FALSE, 0); |
| 104 |
| 105 // Add title. |
| 106 title_ = gtk_label_new(NULL); |
| 107 gtk_label_set_ellipsize(GTK_LABEL(title_), PANGO_ELLIPSIZE_END); |
| 108 gtk_misc_set_alignment(GTK_MISC(title_), 0.0, 0.5); |
| 109 gtk_box_pack_start(GTK_BOX(icon_title_hbox), title_, TRUE, TRUE, 0); |
| 110 |
| 111 UpdateTitleAndIcon(); |
| 112 |
| 113 theme_service_ = GtkThemeService::GetFrom( |
| 114 browser_window_->panel()->profile()); |
| 115 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
| 116 content::Source<ThemeService>(theme_service_)); |
| 117 theme_service_->InitThemesFor(this); |
| 118 |
| 119 gtk_widget_show_all(container_); |
| 120 } |
| 121 |
| 59 SkColor PanelBrowserTitlebarGtk::GetTextColor() const { | 122 SkColor PanelBrowserTitlebarGtk::GetTextColor() const { |
| 60 PanelBrowserWindowGtk::PaintState paint_state = | 123 if (browser_window_->UsingDefaultTheme()) |
| 61 browser_window_->GetPaintState(); | 124 return kTitleTextDefaultColor; |
| 62 if (paint_state == PanelBrowserWindowGtk::PAINT_FOR_ATTENTION) | 125 return theme_service_->GetColor(browser_window_->paint_state() == |
| 63 return kAttentionTitleTextDefaultColor; | 126 PanelBrowserWindowGtk::PAINT_AS_ACTIVE ? |
| 64 | 127 ThemeService::COLOR_TAB_TEXT : |
| 65 return paint_state == PanelBrowserWindowGtk::PAINT_AS_ACTIVE ? | 128 ThemeService::COLOR_BACKGROUND_TAB_TEXT); |
| 66 theme_service()->GetColor(ThemeService::COLOR_TAB_TEXT) : | 129 } |
| 67 BlendSkColorWithAlpha( | 130 |
| 68 theme_service()->GetColor(ThemeService::COLOR_BACKGROUND_TAB_TEXT), | 131 void PanelBrowserTitlebarGtk::BuildButtons() { |
| 69 theme_service()->GetColor(ThemeService::COLOR_TOOLBAR), | 132 minimize_button_.reset(CreateButton(panel::MINIMIZE_BUTTON)); |
| 70 kInactiveAlphaBlending); | 133 restore_button_.reset(CreateButton(panel::RESTORE_BUTTON)); |
| 71 } | 134 close_button_.reset(CreateButton(panel::CLOSE_BUTTON)); |
| 72 | 135 |
| 73 void PanelBrowserTitlebarGtk::UpdateButtonBackground(CustomDrawButton* button) { | 136 // We control visibility of minimize and restore buttons. |
| 74 // Don't need to update background since we're using transparent background. | 137 gtk_widget_set_no_show_all(minimize_button_->widget(), TRUE); |
| 138 gtk_widget_set_no_show_all(restore_button_->widget(), TRUE); |
| 139 |
| 140 // Now show the correct widgets in the two hierarchies. |
| 141 UpdateMinimizeRestoreButtonVisibility(); |
| 142 } |
| 143 |
| 144 CustomDrawButton* PanelBrowserTitlebarGtk::CreateButton( |
| 145 panel::TitlebarButtonType button_type) { |
| 146 int normal_image_id; |
| 147 int pressed_image_id; |
| 148 int hover_image_id; |
| 149 int tooltip_id; |
| 150 GetButtonResources(button_type, &normal_image_id, &pressed_image_id, |
| 151 &hover_image_id, &tooltip_id); |
| 152 |
| 153 CustomDrawButton* button = new CustomDrawButton(normal_image_id, |
| 154 pressed_image_id, |
| 155 hover_image_id, |
| 156 0); |
| 157 gtk_widget_add_events(GTK_WIDGET(button->widget()), GDK_POINTER_MOTION_MASK); |
| 158 g_signal_connect(button->widget(), "clicked", |
| 159 G_CALLBACK(OnButtonClickedThunk), this); |
| 160 |
| 161 std::string localized_tooltip = l10n_util::GetStringUTF8(tooltip_id); |
| 162 gtk_widget_set_tooltip_text(button->widget(), |
| 163 localized_tooltip.c_str()); |
| 164 |
| 165 GtkWidget* box = GetButtonHBox(); |
| 166 gtk_box_pack_start(GTK_BOX(box), button->widget(), FALSE, FALSE, 0); |
| 167 return button; |
| 168 } |
| 169 |
| 170 void PanelBrowserTitlebarGtk::GetButtonResources( |
| 171 panel::TitlebarButtonType button_type, |
| 172 int* normal_image_id, |
| 173 int* pressed_image_id, |
| 174 int* hover_image_id, |
| 175 int* tooltip_id) const { |
| 176 switch (button_type) { |
| 177 case panel::CLOSE_BUTTON: |
| 178 *normal_image_id = IDR_PANEL_CLOSE; |
| 179 *pressed_image_id = IDR_PANEL_CLOSE_C; |
| 180 *hover_image_id = IDR_PANEL_CLOSE_H; |
| 181 *tooltip_id = IDS_PANEL_CLOSE_TOOLTIP; |
| 182 break; |
| 183 case panel::MINIMIZE_BUTTON: |
| 184 *normal_image_id = IDR_PANEL_MINIMIZE; |
| 185 *pressed_image_id = IDR_PANEL_MINIMIZE_C; |
| 186 *hover_image_id = IDR_PANEL_MINIMIZE_H; |
| 187 *tooltip_id = IDS_PANEL_MINIMIZE_TOOLTIP; |
| 188 break; |
| 189 case panel::RESTORE_BUTTON: |
| 190 *normal_image_id = IDR_PANEL_RESTORE; |
| 191 *pressed_image_id = IDR_PANEL_RESTORE_C; |
| 192 *hover_image_id = IDR_PANEL_RESTORE_H; |
| 193 *tooltip_id = IDS_PANEL_RESTORE_TOOLTIP; |
| 194 break; |
| 195 } |
| 196 } |
| 197 |
| 198 GtkWidget* PanelBrowserTitlebarGtk::GetButtonHBox() { |
| 199 if (!titlebar_right_buttons_hbox_) { |
| 200 // We put the minimize/restore/close buttons in a vbox so they are top |
| 201 // aligned (up to padding) and don't vertically stretch. |
| 202 titlebar_right_buttons_hbox_ = gtk_hbox_new(FALSE, kPanelButtonSpacing); |
| 203 gtk_box_pack_start(GTK_BOX(titlebar_right_buttons_vbox_), |
| 204 titlebar_right_buttons_hbox_, FALSE, FALSE, 0); |
| 205 } |
| 206 |
| 207 return titlebar_right_buttons_hbox_; |
| 208 } |
| 209 |
| 210 void PanelBrowserTitlebarGtk::UpdateCustomFrame(bool use_custom_frame) { |
| 211 // Nothing to do. |
| 75 } | 212 } |
| 76 | 213 |
| 77 void PanelBrowserTitlebarGtk::UpdateTitleAndIcon() { | 214 void PanelBrowserTitlebarGtk::UpdateTitleAndIcon() { |
| 78 DCHECK(app_mode_title()); | 215 std::string title_text = |
| 79 | 216 UTF16ToUTF8(browser_window_->panel()->GetWindowTitle()); |
| 80 std::string title = UTF16ToUTF8(browser_window_->panel()->GetWindowTitle()); | 217 |
| 81 | 218 // Add the markup to show the title in the desired font. |
| 82 // Add the markup to show the title as bold. | 219 gchar* escaped_title_text = g_markup_escape_text(title_text.c_str(), -1); |
| 83 gchar* escaped_title = g_markup_escape_text(title.c_str(), -1); | 220 gchar* title_text_with_markup = g_strconcat(kTitleMarkupPrefix, |
| 84 gchar* title_with_markup = g_strconcat(kTitleMarkupPrefix, | 221 escaped_title_text, |
| 85 escaped_title, | 222 kTitleMarkupSuffix, |
| 86 kTitleMarkupSuffix, | 223 NULL); |
| 87 NULL); | 224 gtk_label_set_markup(GTK_LABEL(title_), title_text_with_markup); |
| 88 gtk_label_set_markup(GTK_LABEL(app_mode_title()), title_with_markup); | 225 g_free(escaped_title_text); |
| 89 g_free(escaped_title); | 226 g_free(title_text_with_markup); |
| 90 g_free(title_with_markup); | 227 } |
| 91 } | 228 |
| 92 | 229 void PanelBrowserTitlebarGtk::UpdateThrobber( |
| 93 bool PanelBrowserTitlebarGtk::BuildButton(const std::string& button_token, | 230 content::WebContents* web_contents) { |
| 94 bool left_side) { | 231 if (web_contents && web_contents->IsLoading()) { |
| 95 // Panel only shows close and minimize/restore buttons. | 232 GdkPixbuf* icon_pixbuf = |
| 96 if (button_token != "close" && button_token != "minimize") | 233 throbber_.GetNextFrame(web_contents->IsWaitingForResponse()); |
| 97 return false; | 234 gtk_image_set_from_pixbuf(GTK_IMAGE(icon_), icon_pixbuf); |
| 98 | 235 } else { |
| 99 if (!BrowserTitlebar::BuildButton(button_token, left_side)) | 236 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 100 return false; | 237 |
| 101 | 238 SkBitmap icon = browser_window_->panel()->GetCurrentPageIcon(); |
| 102 if (button_token == "minimize") { | 239 if (icon.empty()) { |
| 103 // Create unminimze button, used to expand the minimized panel. | 240 // Fallback to the Chromium icon if the page has no icon. |
| 104 unminimize_button_.reset(CreateTitlebarButton("unminimize", left_side)); | 241 gtk_image_set_from_pixbuf(GTK_IMAGE(icon_), |
| 105 | 242 rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_16).ToGdkPixbuf()); |
| 106 // We control visibility of minimize and unminimize buttons. | 243 } else { |
| 107 gtk_widget_set_no_show_all(minimize_button()->widget(), TRUE); | 244 GdkPixbuf* icon_pixbuf = gfx::GdkPixbufFromSkBitmap(icon); |
| 108 gtk_widget_set_no_show_all(unminimize_button_->widget(), TRUE); | 245 gtk_image_set_from_pixbuf(GTK_IMAGE(icon_), icon_pixbuf); |
| 109 } | 246 g_object_unref(icon_pixbuf); |
| 110 return true; | 247 } |
| 111 } | 248 |
| 112 | 249 throbber_.Reset(); |
| 113 void PanelBrowserTitlebarGtk::GetButtonResources(const std::string& button_name, | 250 } |
| 114 int* normal_image_id, | 251 } |
| 115 int* pressed_image_id, | 252 |
| 116 int* hover_image_id, | 253 void PanelBrowserTitlebarGtk::ShowContextMenu(GdkEventButton* event) { |
| 117 int* tooltip_id) const { | 254 // Panel does not show any context menu. |
| 118 if (button_name == "close") { | 255 } |
| 119 *normal_image_id = IDR_PANEL_CLOSE; | 256 |
| 120 *pressed_image_id = 0; | 257 void PanelBrowserTitlebarGtk::UpdateTextColor() { |
| 121 *hover_image_id = IDR_PANEL_CLOSE_H; | 258 GdkColor text_color = gfx::SkColorToGdkColor(GetTextColor()); |
| 122 *tooltip_id = IDS_PANEL_CLOSE_TOOLTIP; | 259 gtk_util::SetLabelColor(title_, &text_color); |
| 123 } else if (button_name == "minimize") { | |
| 124 *normal_image_id = IDR_PANEL_MINIMIZE; | |
| 125 *pressed_image_id = 0; | |
| 126 *hover_image_id = IDR_PANEL_MINIMIZE_H; | |
| 127 *tooltip_id = IDS_PANEL_MINIMIZE_TOOLTIP; | |
| 128 } else if (button_name == "unminimize") { | |
| 129 *normal_image_id = IDR_PANEL_RESTORE; | |
| 130 *pressed_image_id = 0; | |
| 131 *hover_image_id = IDR_PANEL_RESTORE_H; | |
| 132 *tooltip_id = IDS_PANEL_RESTORE_TOOLTIP; | |
| 133 } | |
| 134 } | |
| 135 | |
| 136 int PanelBrowserTitlebarGtk::GetButtonOuterPadding() const { | |
| 137 return kPanelButtonOuterPadding; | |
| 138 } | |
| 139 | |
| 140 int PanelBrowserTitlebarGtk::GetButtonSpacing() const { | |
| 141 return kPanelButtonSpacing; | |
| 142 } | 260 } |
| 143 | 261 |
| 144 void PanelBrowserTitlebarGtk::UpdateMinimizeRestoreButtonVisibility() { | 262 void PanelBrowserTitlebarGtk::UpdateMinimizeRestoreButtonVisibility() { |
| 145 if (!unminimize_button_.get() || !minimize_button()) | |
| 146 return; | |
| 147 | |
| 148 Panel* panel = browser_window_->panel(); | 263 Panel* panel = browser_window_->panel(); |
| 149 gtk_widget_set_visible(minimize_button()->widget(), panel->CanMinimize()); | 264 gtk_widget_set_visible(minimize_button_->widget(), panel->CanMinimize()); |
| 150 gtk_widget_set_visible(unminimize_button_->widget(), panel->CanRestore()); | 265 gtk_widget_set_visible(restore_button_->widget(), panel->CanRestore()); |
| 151 } | 266 } |
| 152 | 267 |
| 153 void PanelBrowserTitlebarGtk::HandleButtonClick(GtkWidget* button) { | 268 gboolean PanelBrowserTitlebarGtk::OnWindowStateChanged( |
| 154 if (close_button() && close_button()->widget() == button) { | 269 GtkWindow* window, GdkEventWindowState* event) { |
| 270 UpdateTextColor(); |
| 271 return FALSE; |
| 272 } |
| 273 |
| 274 void PanelBrowserTitlebarGtk::OnButtonClicked(GtkWidget* button) { |
| 275 if (close_button_->widget() == button) { |
| 155 browser_window_->panel()->Close(); | 276 browser_window_->panel()->Close(); |
| 156 return; | 277 return; |
| 157 } | 278 } |
| 158 | 279 |
| 159 GdkEvent* event = gtk_get_current_event(); | 280 GdkEvent* event = gtk_get_current_event(); |
| 160 DCHECK(event && event->type == GDK_BUTTON_RELEASE); | 281 DCHECK(event && event->type == GDK_BUTTON_RELEASE); |
| 161 | 282 |
| 162 if (minimize_button() && minimize_button()->widget() == button) { | 283 if (minimize_button_->widget() == button) { |
| 163 browser_window_->panel()->OnMinimizeButtonClicked( | 284 browser_window_->panel()->OnMinimizeButtonClicked( |
| 164 (event->button.state & GDK_CONTROL_MASK) ? | 285 (event->button.state & GDK_CONTROL_MASK) ? |
| 165 panel::APPLY_TO_ALL : panel::NO_MODIFIER); | 286 panel::APPLY_TO_ALL : panel::NO_MODIFIER); |
| 166 } else if (unminimize_button_.get() && | 287 } else if (restore_button_->widget() == button) { |
| 167 unminimize_button_->widget() == button) { | |
| 168 browser_window_->panel()->OnRestoreButtonClicked( | 288 browser_window_->panel()->OnRestoreButtonClicked( |
| 169 (event->button.state & GDK_CONTROL_MASK) ? | 289 (event->button.state & GDK_CONTROL_MASK) ? |
| 170 panel::APPLY_TO_ALL : panel::NO_MODIFIER); | 290 panel::APPLY_TO_ALL : panel::NO_MODIFIER); |
| 171 } | 291 } |
| 172 | 292 |
| 173 gdk_event_free(event); | 293 gdk_event_free(event); |
| 174 } | 294 } |
| 175 | 295 |
| 176 void PanelBrowserTitlebarGtk::ShowFaviconMenu(GdkEventButton* event) { | 296 void PanelBrowserTitlebarGtk::Observe( |
| 177 // Favicon menu is not supported in panels. | 297 int type, |
| 178 } | 298 const content::NotificationSource& source, |
| 179 | 299 const content::NotificationDetails& details) { |
| 180 void PanelBrowserTitlebarGtk::UpdateTextColor() { | 300 switch (type) { |
| 181 DCHECK(app_mode_title()); | 301 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: |
| 182 | 302 UpdateTextColor(); |
| 183 GdkColor text_color = gfx::SkColorToGdkColor(GetTextColor()); | 303 break; |
| 184 gtk_util::SetLabelColor(app_mode_title(), &text_color); | 304 default: |
| 305 NOTREACHED(); |
| 306 } |
| 185 } | 307 } |
| 186 | 308 |
| 187 void PanelBrowserTitlebarGtk::SendEnterNotifyToCloseButtonIfUnderMouse() { | 309 void PanelBrowserTitlebarGtk::SendEnterNotifyToCloseButtonIfUnderMouse() { |
| 188 if (!close_button()) | 310 if (!close_button()) |
| 189 return; | 311 return; |
| 190 | 312 |
| 191 gint x; | 313 gint x; |
| 192 gint y; | 314 gint y; |
| 193 GtkAllocation widget_allocation = close_button()->WidgetAllocation(); | 315 GtkAllocation widget_allocation = close_button()->WidgetAllocation(); |
| 194 gtk_widget_get_pointer(GTK_WIDGET(close_button()->widget()), &x, &y); | 316 gtk_widget_get_pointer(GTK_WIDGET(close_button()->widget()), &x, &y); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 217 event->crossing.y_root = widget_allocation.y; | 339 event->crossing.y_root = widget_allocation.y; |
| 218 event->crossing.mode = GDK_CROSSING_NORMAL; | 340 event->crossing.mode = GDK_CROSSING_NORMAL; |
| 219 event->crossing.detail = GDK_NOTIFY_ANCESTOR; | 341 event->crossing.detail = GDK_NOTIFY_ANCESTOR; |
| 220 event->crossing.focus = true; | 342 event->crossing.focus = true; |
| 221 event->crossing.state = 0; | 343 event->crossing.state = 0; |
| 222 | 344 |
| 223 g_signal_emit_by_name(GTK_OBJECT(close_button()->widget()), | 345 g_signal_emit_by_name(GTK_OBJECT(close_button()->widget()), |
| 224 "enter-notify-event", event, | 346 "enter-notify-event", event, |
| 225 &return_value); | 347 &return_value); |
| 226 } | 348 } |
| 349 |
| 350 GtkWidget* PanelBrowserTitlebarGtk::widget() const { |
| 351 return container_; |
| 352 } |
| 353 |
| 354 void PanelBrowserTitlebarGtk::set_window(GtkWindow* window) { |
| 355 window_ = window; |
| 356 } |
| 357 |
| 358 AvatarMenuButtonGtk* PanelBrowserTitlebarGtk::avatar_button() const { |
| 359 // Not supported in panel. |
| 360 return NULL; |
| 361 } |
| OLD | NEW |