| 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/tabs/tab_strip_gtk.h" | 5 #include "chrome/browser/ui/gtk/tabs/tab_strip_gtk.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/browser/autocomplete/autocomplete.h" | 13 #include "chrome/browser/autocomplete/autocomplete.h" |
| 14 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 14 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
| 15 #include "chrome/browser/autocomplete/autocomplete_match.h" | 15 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/tabs/tab_strip_model_delegate.h" | 17 #include "chrome/browser/tabs/tab_strip_model_delegate.h" |
| 18 #include "chrome/browser/themes/theme_service.h" | 18 #include "chrome/browser/themes/theme_service.h" |
| 19 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 20 #include "chrome/browser/ui/browser_navigator.h" | 20 #include "chrome/browser/ui/browser_navigator.h" |
| 21 #include "chrome/browser/ui/gtk/browser_window_gtk.h" | 21 #include "chrome/browser/ui/gtk/browser_window_gtk.h" |
| 22 #include "chrome/browser/ui/gtk/custom_button.h" | 22 #include "chrome/browser/ui/gtk/custom_button.h" |
| 23 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 23 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| 24 #include "chrome/browser/ui/gtk/gtk_util.h" | 24 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 25 #include "chrome/browser/ui/gtk/tabs/dragged_tab_controller_gtk.h" | 25 #include "chrome/browser/ui/gtk/tabs/dragged_tab_controller_gtk.h" |
| 26 #include "chrome/browser/ui/gtk/tabs/tab_strip_menu_controller.h" | 26 #include "chrome/browser/ui/gtk/tabs/tab_strip_menu_controller.h" |
| 27 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 27 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 28 #include "chrome/common/chrome_notification_types.h" |
| 28 #include "content/browser/tab_contents/tab_contents.h" | 29 #include "content/browser/tab_contents/tab_contents.h" |
| 29 #include "content/public/browser/notification_source.h" | 30 #include "content/public/browser/notification_source.h" |
| 30 #include "grit/theme_resources.h" | 31 #include "grit/theme_resources.h" |
| 31 #include "grit/theme_resources_standard.h" | 32 #include "grit/theme_resources_standard.h" |
| 32 #include "grit/ui_resources.h" | 33 #include "grit/ui_resources.h" |
| 33 #include "ui/base/animation/animation_delegate.h" | 34 #include "ui/base/animation/animation_delegate.h" |
| 34 #include "ui/base/animation/slide_animation.h" | 35 #include "ui/base/animation/slide_animation.h" |
| 35 #include "ui/base/dragdrop/gtk_dnd_util.h" | 36 #include "ui/base/dragdrop/gtk_dnd_util.h" |
| 36 #include "ui/base/gtk/gtk_screen_utils.h" | 37 #include "ui/base/gtk/gtk_screen_utils.h" |
| 37 #include "ui/base/resource/resource_bundle.h" | 38 #include "ui/base/resource/resource_bundle.h" |
| (...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 | 772 |
| 772 bounds_ = GetInitialWidgetBounds(tabstrip_.get()); | 773 bounds_ = GetInitialWidgetBounds(tabstrip_.get()); |
| 773 | 774 |
| 774 if (drop_indicator_width == 0) { | 775 if (drop_indicator_width == 0) { |
| 775 // Direction doesn't matter, both images are the same size. | 776 // Direction doesn't matter, both images are the same size. |
| 776 GdkPixbuf* drop_image = GetDropArrowImage(true); | 777 GdkPixbuf* drop_image = GetDropArrowImage(true); |
| 777 drop_indicator_width = gdk_pixbuf_get_width(drop_image); | 778 drop_indicator_width = gdk_pixbuf_get_width(drop_image); |
| 778 drop_indicator_height = gdk_pixbuf_get_height(drop_image); | 779 drop_indicator_height = gdk_pixbuf_get_height(drop_image); |
| 779 } | 780 } |
| 780 | 781 |
| 782 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
| 783 content::Source<ThemeService>(theme_service_)); |
| 784 theme_service_->InitThemesFor(this); |
| 785 |
| 781 ViewIDUtil::SetDelegateForWidget(widget(), this); | 786 ViewIDUtil::SetDelegateForWidget(widget(), this); |
| 782 } | 787 } |
| 783 | 788 |
| 784 void TabStripGtk::Show() { | 789 void TabStripGtk::Show() { |
| 785 gtk_widget_show(tabstrip_.get()); | 790 gtk_widget_show(tabstrip_.get()); |
| 786 } | 791 } |
| 787 | 792 |
| 788 void TabStripGtk::Hide() { | 793 void TabStripGtk::Hide() { |
| 789 gtk_widget_hide(tabstrip_.get()); | 794 gtk_widget_hide(tabstrip_.get()); |
| 790 } | 795 } |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1295 switch (event->type) { | 1300 switch (event->type) { |
| 1296 case GDK_MOTION_NOTIFY: | 1301 case GDK_MOTION_NOTIFY: |
| 1297 case GDK_LEAVE_NOTIFY: | 1302 case GDK_LEAVE_NOTIFY: |
| 1298 HandleGlobalMouseMoveEvent(); | 1303 HandleGlobalMouseMoveEvent(); |
| 1299 break; | 1304 break; |
| 1300 default: | 1305 default: |
| 1301 break; | 1306 break; |
| 1302 } | 1307 } |
| 1303 } | 1308 } |
| 1304 | 1309 |
| 1310 /////////////////////////////////////////////////////////////////////////////// |
| 1311 // TabStripGtk, content::NotificationObserver implementation: |
| 1312 |
| 1313 void TabStripGtk::Observe(int type, |
| 1314 const content::NotificationSource& source, |
| 1315 const content::NotificationDetails& details) { |
| 1316 DCHECK_EQ(type, chrome::NOTIFICATION_BROWSER_THEME_CHANGED); |
| 1317 SetNewTabButtonBackground(); |
| 1318 } |
| 1319 |
| 1305 //////////////////////////////////////////////////////////////////////////////// | 1320 //////////////////////////////////////////////////////////////////////////////// |
| 1306 // TabStripGtk, private: | 1321 // TabStripGtk, private: |
| 1307 | 1322 |
| 1308 int TabStripGtk::GetTabCount() const { | 1323 int TabStripGtk::GetTabCount() const { |
| 1309 return static_cast<int>(tab_data_.size()); | 1324 return static_cast<int>(tab_data_.size()); |
| 1310 } | 1325 } |
| 1311 | 1326 |
| 1312 int TabStripGtk::GetMiniTabCount() const { | 1327 int TabStripGtk::GetMiniTabCount() const { |
| 1313 int mini_count = 0; | 1328 int mini_count = 0; |
| 1314 for (size_t i = 0; i < tab_data_.size(); ++i) { | 1329 for (size_t i = 0; i < tab_data_.size(); ++i) { |
| (...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2194 | 2209 |
| 2195 // Let the middle mouse button initiate clicks as well. | 2210 // Let the middle mouse button initiate clicks as well. |
| 2196 gtk_util::SetButtonTriggersNavigation(button->widget()); | 2211 gtk_util::SetButtonTriggersNavigation(button->widget()); |
| 2197 g_signal_connect(button->widget(), "clicked", | 2212 g_signal_connect(button->widget(), "clicked", |
| 2198 G_CALLBACK(OnNewTabClickedThunk), this); | 2213 G_CALLBACK(OnNewTabClickedThunk), this); |
| 2199 gtk_widget_set_can_focus(button->widget(), FALSE); | 2214 gtk_widget_set_can_focus(button->widget(), FALSE); |
| 2200 gtk_fixed_put(GTK_FIXED(tabstrip_.get()), button->widget(), 0, 0); | 2215 gtk_fixed_put(GTK_FIXED(tabstrip_.get()), button->widget(), 0, 0); |
| 2201 | 2216 |
| 2202 return button; | 2217 return button; |
| 2203 } | 2218 } |
| 2219 |
| 2220 void TabStripGtk::SetNewTabButtonBackground() { |
| 2221 SkColor color = theme_service_->GetColor( |
| 2222 ThemeService::COLOR_BUTTON_BACKGROUND); |
| 2223 SkBitmap* background = theme_service_->GetBitmapNamed( |
| 2224 IDR_THEME_WINDOW_CONTROL_BACKGROUND); |
| 2225 SkBitmap* mask = theme_service_->GetBitmapNamed(IDR_NEWTAB_BUTTON_MASK); |
| 2226 newtab_button_->SetBackground(color, background, mask); |
| 2227 } |
| OLD | NEW |