| 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/tabs/tab_strip_gtk.h" | 5 #include "chrome/browser/gtk/tabs/tab_strip_gtk.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "app/gfx/canvas_paint.h" | 9 #include "app/gfx/canvas_paint.h" |
| 10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| 11 #include "app/resource_bundle.h" | 11 #include "app/resource_bundle.h" |
| 12 #include "app/slide_animation.h" | 12 #include "app/slide_animation.h" |
| 13 #include "base/gfx/gtk_util.h" | 13 #include "base/gfx/gtk_util.h" |
| 14 #include "base/gfx/point.h" | 14 #include "base/gfx/point.h" |
| 15 #include "chrome/browser/browser_theme_provider.h" | 15 #include "chrome/browser/browser_theme_provider.h" |
| 16 #include "chrome/browser/gtk/custom_button.h" | 16 #include "chrome/browser/gtk/custom_button.h" |
| 17 #include "chrome/browser/gtk/gtk_dnd_util.h" | 17 #include "chrome/browser/gtk/gtk_dnd_util.h" |
| 18 #include "chrome/browser/gtk/gtk_theme_provider.h" |
| 18 #include "chrome/browser/gtk/tabs/dragged_tab_controller_gtk.h" | 19 #include "chrome/browser/gtk/tabs/dragged_tab_controller_gtk.h" |
| 19 #include "chrome/browser/profile.h" | 20 #include "chrome/browser/profile.h" |
| 20 #include "chrome/browser/tab_contents/tab_contents.h" | 21 #include "chrome/browser/tab_contents/tab_contents.h" |
| 21 #include "chrome/common/gtk_util.h" | 22 #include "chrome/common/gtk_util.h" |
| 22 #include "grit/app_resources.h" | 23 #include "grit/app_resources.h" |
| 23 #include "grit/theme_resources.h" | 24 #include "grit/theme_resources.h" |
| 24 | 25 |
| 25 #if defined(LINUX2) | 26 #if defined(LINUX2) |
| 26 #include "chrome/browser/browser.h" | 27 #include "chrome/browser/browser.h" |
| 27 #include "chrome/browser/browser_list.h" | 28 #include "chrome/browser/browser_list.h" |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 // TabStripGtk, public: | 436 // TabStripGtk, public: |
| 436 | 437 |
| 437 TabStripGtk::TabStripGtk(TabStripModel* model) | 438 TabStripGtk::TabStripGtk(TabStripModel* model) |
| 438 : current_unselected_width_(TabGtk::GetStandardSize().width()), | 439 : current_unselected_width_(TabGtk::GetStandardSize().width()), |
| 439 current_selected_width_(TabGtk::GetStandardSize().width()), | 440 current_selected_width_(TabGtk::GetStandardSize().width()), |
| 440 available_width_for_tabs_(-1), | 441 available_width_for_tabs_(-1), |
| 441 resize_layout_scheduled_(false), | 442 resize_layout_scheduled_(false), |
| 442 model_(model), | 443 model_(model), |
| 443 resize_layout_factory_(this), | 444 resize_layout_factory_(this), |
| 444 added_as_message_loop_observer_(false) { | 445 added_as_message_loop_observer_(false) { |
| 446 ThemeProvider* theme_provider = model->profile()->GetThemeProvider(); |
| 447 TabRendererGtk::SetSelectedTitleColor(theme_provider->GetColor( |
| 448 BrowserThemeProvider::COLOR_TAB_TEXT)); |
| 449 TabRendererGtk::SetUnselectedTitleColor(theme_provider->GetColor( |
| 450 BrowserThemeProvider::COLOR_BACKGROUND_TAB_TEXT)); |
| 445 } | 451 } |
| 446 | 452 |
| 447 TabStripGtk::~TabStripGtk() { | 453 TabStripGtk::~TabStripGtk() { |
| 448 model_->RemoveObserver(this); | 454 model_->RemoveObserver(this); |
| 449 tabstrip_.Destroy(); | 455 tabstrip_.Destroy(); |
| 450 | 456 |
| 451 // Free any remaining tabs. This is needed to free the very last tab, | 457 // Free any remaining tabs. This is needed to free the very last tab, |
| 452 // because it is not animated on close. This also happens when all of the | 458 // because it is not animated on close. This also happens when all of the |
| 453 // tabs are closed at once. | 459 // tabs are closed at once. |
| 454 std::vector<TabData>::iterator iterator = tab_data_.begin(); | 460 std::vector<TabData>::iterator iterator = tab_data_.begin(); |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 gtk_widget_translate_coordinates( | 632 gtk_widget_translate_coordinates( |
| 627 gtk_widget_get_toplevel(widget()), target, 0, 0, &x, &y); | 633 gtk_widget_get_toplevel(widget()), target, 0, 0, &x, &y); |
| 628 } | 634 } |
| 629 if (GTK_WIDGET_NO_WINDOW(target)) { | 635 if (GTK_WIDGET_NO_WINDOW(target)) { |
| 630 x += target->allocation.x; | 636 x += target->allocation.x; |
| 631 y += target->allocation.y; | 637 y += target->allocation.y; |
| 632 } | 638 } |
| 633 return gfx::Point(x, y); | 639 return gfx::Point(x, y); |
| 634 } | 640 } |
| 635 | 641 |
| 642 void TabStripGtk::UserChangedTheme(GtkThemeProperties* properties) { |
| 643 ThemeProvider* theme_provider = properties->provider; |
| 644 TabRendererGtk::SetSelectedTitleColor(theme_provider->GetColor( |
| 645 BrowserThemeProvider::COLOR_TAB_TEXT)); |
| 646 TabRendererGtk::SetUnselectedTitleColor(theme_provider->GetColor( |
| 647 BrowserThemeProvider::COLOR_BACKGROUND_TAB_TEXT)); |
| 648 } |
| 649 |
| 636 //////////////////////////////////////////////////////////////////////////////// | 650 //////////////////////////////////////////////////////////////////////////////// |
| 637 // TabStripGtk, TabStripModelObserver implementation: | 651 // TabStripGtk, TabStripModelObserver implementation: |
| 638 | 652 |
| 639 void TabStripGtk::TabInsertedAt(TabContents* contents, | 653 void TabStripGtk::TabInsertedAt(TabContents* contents, |
| 640 int index, | 654 int index, |
| 641 bool foreground) { | 655 bool foreground) { |
| 642 DCHECK(contents); | 656 DCHECK(contents); |
| 643 DCHECK(index == TabStripModel::kNoTab || model_->ContainsIndex(index)); | 657 DCHECK(index == TabStripModel::kNoTab || model_->ContainsIndex(index)); |
| 644 | 658 |
| 645 if (active_animation_.get()) | 659 if (active_animation_.get()) |
| (...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1604 message.set_type(TabOverviewTypes::Message::WM_SWITCH_TO_OVERVIEW_MODE); | 1618 message.set_type(TabOverviewTypes::Message::WM_SWITCH_TO_OVERVIEW_MODE); |
| 1605 GtkWidget* browser_widget = GTK_WIDGET( | 1619 GtkWidget* browser_widget = GTK_WIDGET( |
| 1606 static_cast<BrowserWindowGtk*>(browser->window())->GetNativeHandle()); | 1620 static_cast<BrowserWindowGtk*>(browser->window())->GetNativeHandle()); |
| 1607 message.set_param(0, x11_util::GetX11WindowFromGtkWidget(browser_widget)); | 1621 message.set_param(0, x11_util::GetX11WindowFromGtkWidget(browser_widget)); |
| 1608 TabOverviewTypes::instance()->SendMessage(message); | 1622 TabOverviewTypes::instance()->SendMessage(message); |
| 1609 | 1623 |
| 1610 UserMetrics::RecordAction(L"TabOverview_PressedTabOverviewButton", | 1624 UserMetrics::RecordAction(L"TabOverview_PressedTabOverviewButton", |
| 1611 tabstrip->model_->profile()); | 1625 tabstrip->model_->profile()); |
| 1612 } | 1626 } |
| 1613 #endif | 1627 #endif |
| OLD | NEW |