OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/gtk/browser_titlebar.h" | 5 #include "chrome/browser/ui/gtk/browser_titlebar.h" |
6 | 6 |
7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
394 G_CALLBACK(OnPanelSettingsMenuButtonPressedThunk), this); | 394 G_CALLBACK(OnPanelSettingsMenuButtonPressedThunk), this); |
395 gtk_widget_set_no_show_all(panel_wrench_button_->widget(), TRUE); | 395 gtk_widget_set_no_show_all(panel_wrench_button_->widget(), TRUE); |
396 } | 396 } |
397 | 397 |
398 app_mode_title_ = gtk_label_new(NULL); | 398 app_mode_title_ = gtk_label_new(NULL); |
399 gtk_label_set_ellipsize(GTK_LABEL(app_mode_title_), PANGO_ELLIPSIZE_END); | 399 gtk_label_set_ellipsize(GTK_LABEL(app_mode_title_), PANGO_ELLIPSIZE_END); |
400 gtk_misc_set_alignment(GTK_MISC(app_mode_title_), 0.0, 0.5); | 400 gtk_misc_set_alignment(GTK_MISC(app_mode_title_), 0.0, 0.5); |
401 gtk_box_pack_start(GTK_BOX(app_mode_hbox), app_mode_title_, TRUE, TRUE, | 401 gtk_box_pack_start(GTK_BOX(app_mode_hbox), app_mode_title_, TRUE, TRUE, |
402 0); | 402 0); |
403 | 403 |
404 // Register with the theme provider to set the |app_mode_title_| label | |
405 // color. | |
406 theme_service_ = GtkThemeService::GetFrom( | |
407 browser_window_->browser()->profile()); | |
408 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | |
409 content::Source<ThemeService>(theme_service_)); | |
410 theme_service_->InitThemesFor(this); | |
411 UpdateTitleAndIcon(); | 404 UpdateTitleAndIcon(); |
412 } | 405 } |
413 | 406 |
407 theme_service_ = GtkThemeService::GetFrom( | |
408 browser_window_->browser()->profile()); | |
409 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | |
410 content::Source<ThemeService>(theme_service_)); | |
411 theme_service_->InitThemesFor(this); | |
412 | |
414 gtk_widget_show_all(container_); | 413 gtk_widget_show_all(container_); |
415 | 414 |
416 ui::ActiveWindowWatcherX::AddObserver(this); | 415 ui::ActiveWindowWatcherX::AddObserver(this); |
417 } | 416 } |
418 | 417 |
419 BrowserTitlebar::~BrowserTitlebar() { | 418 BrowserTitlebar::~BrowserTitlebar() { |
420 ui::ActiveWindowWatcherX::RemoveObserver(this); | 419 ui::ActiveWindowWatcherX::RemoveObserver(this); |
421 #if defined(USE_GCONF) | 420 #if defined(USE_GCONF) |
422 GConfTitlebarListener::GetInstance()->RemoveObserver(this); | 421 GConfTitlebarListener::GetInstance()->RemoveObserver(this); |
423 #endif | 422 #endif |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
543 std::string localized_tooltip = l10n_util::GetStringUTF8(tooltip); | 542 std::string localized_tooltip = l10n_util::GetStringUTF8(tooltip); |
544 gtk_widget_set_tooltip_text(button->widget(), | 543 gtk_widget_set_tooltip_text(button->widget(), |
545 localized_tooltip.c_str()); | 544 localized_tooltip.c_str()); |
546 if (start) | 545 if (start) |
547 gtk_box_pack_start(GTK_BOX(box), button->widget(), FALSE, FALSE, 0); | 546 gtk_box_pack_start(GTK_BOX(box), button->widget(), FALSE, FALSE, 0); |
548 else | 547 else |
549 gtk_box_pack_end(GTK_BOX(box), button->widget(), FALSE, FALSE, 0); | 548 gtk_box_pack_end(GTK_BOX(box), button->widget(), FALSE, FALSE, 0); |
550 return button; | 549 return button; |
551 } | 550 } |
552 | 551 |
552 void BrowserTitlebar::UpdateButtonBackground(CustomDrawButton* button) { | |
553 SkColor color = theme_service_->GetColor( | |
554 ThemeService::COLOR_BUTTON_BACKGROUND); | |
555 SkBitmap* background = | |
556 theme_service_->GetBitmapNamed(IDR_THEME_WINDOW_CONTROL_BACKGROUND); | |
557 | |
558 // TODO(erg): For now, we just use a completely black mask and we can get | |
559 // aways with this in the short term because our buttons are rectangles. We | |
Evan Stade
2011/11/11 00:09:15
away
| |
560 // should get Glen to make properly hinted masks that match our | |
561 // masks. http://crbug.com/103661 | |
Evan Stade
2011/11/11 00:09:15
"masks that match our masks" -- could you reword t
| |
562 SkBitmap mask; | |
563 mask.setConfig(SkBitmap::kARGB_8888_Config, | |
564 button->SurfaceWidth(), button->SurfaceHeight(), 0); | |
565 mask.allocPixels(); | |
566 mask.eraseColor(SK_ColorBLACK); | |
567 | |
568 button->SetBackground(color, background, &mask); | |
569 } | |
570 | |
553 void BrowserTitlebar::UpdateCustomFrame(bool use_custom_frame) { | 571 void BrowserTitlebar::UpdateCustomFrame(bool use_custom_frame) { |
554 using_custom_frame_ = use_custom_frame; | 572 using_custom_frame_ = use_custom_frame; |
555 if (!use_custom_frame || | 573 if (!use_custom_frame || |
556 (browser_window_->IsMaximized() && unity::IsRunning())) { | 574 (browser_window_->IsMaximized() && unity::IsRunning())) { |
557 if (titlebar_left_buttons_vbox_) | 575 if (titlebar_left_buttons_vbox_) |
558 gtk_widget_hide(titlebar_left_buttons_vbox_); | 576 gtk_widget_hide(titlebar_left_buttons_vbox_); |
559 if (titlebar_right_buttons_vbox_) | 577 if (titlebar_right_buttons_vbox_) |
560 gtk_widget_hide(titlebar_right_buttons_vbox_); | 578 gtk_widget_hide(titlebar_right_buttons_vbox_); |
561 } else { | 579 } else { |
562 if (titlebar_left_buttons_vbox_) | 580 if (titlebar_left_buttons_vbox_) |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
987 command_id); | 1005 command_id); |
988 if (accelerator_gtk) | 1006 if (accelerator_gtk) |
989 *accelerator = *accelerator_gtk; | 1007 *accelerator = *accelerator_gtk; |
990 return accelerator_gtk; | 1008 return accelerator_gtk; |
991 } | 1009 } |
992 | 1010 |
993 void BrowserTitlebar::Observe(int type, | 1011 void BrowserTitlebar::Observe(int type, |
994 const content::NotificationSource& source, | 1012 const content::NotificationSource& source, |
995 const content::NotificationDetails& details) { | 1013 const content::NotificationDetails& details) { |
996 switch (type) { | 1014 switch (type) { |
997 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: | 1015 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: { |
998 UpdateTextColor(); | 1016 UpdateTextColor(); |
1017 | |
1018 if (minimize_button_.get()) | |
1019 UpdateButtonBackground(minimize_button_.get()); | |
1020 if (maximize_button_.get()) | |
1021 UpdateButtonBackground(maximize_button_.get()); | |
1022 if (restore_button_.get()) | |
1023 UpdateButtonBackground(restore_button_.get()); | |
1024 if (close_button_.get()) | |
1025 UpdateButtonBackground(close_button_.get()); | |
999 break; | 1026 break; |
1027 } | |
1000 | 1028 |
1001 case chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED: | 1029 case chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED: |
1002 UpdateAvatar(); | 1030 UpdateAvatar(); |
1003 break; | 1031 break; |
1004 | 1032 |
1005 default: | 1033 default: |
1006 NOTREACHED(); | 1034 NOTREACHED(); |
1007 } | 1035 } |
1008 } | 1036 } |
1009 | 1037 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1096 ui::SimpleMenuModel::Delegate* delegate) | 1124 ui::SimpleMenuModel::Delegate* delegate) |
1097 : SimpleMenuModel(delegate) { | 1125 : SimpleMenuModel(delegate) { |
1098 AddItemWithStringId(IDC_NEW_TAB, IDS_TAB_CXMENU_NEWTAB); | 1126 AddItemWithStringId(IDC_NEW_TAB, IDS_TAB_CXMENU_NEWTAB); |
1099 AddItemWithStringId(IDC_RESTORE_TAB, IDS_RESTORE_TAB); | 1127 AddItemWithStringId(IDC_RESTORE_TAB, IDS_RESTORE_TAB); |
1100 AddSeparator(); | 1128 AddSeparator(); |
1101 AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER); | 1129 AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER); |
1102 AddSeparator(); | 1130 AddSeparator(); |
1103 AddCheckItemWithStringId(kShowWindowDecorationsCommand, | 1131 AddCheckItemWithStringId(kShowWindowDecorationsCommand, |
1104 IDS_SHOW_WINDOW_DECORATIONS_MENU); | 1132 IDS_SHOW_WINDOW_DECORATIONS_MENU); |
1105 } | 1133 } |
OLD | NEW |