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 "app/gtk_dnd_util.h" | |
10 #include "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
11 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
12 #include "base/string_util.h" | 11 #include "base/string_util.h" |
13 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
14 #include "chrome/browser/autocomplete/autocomplete.h" | 13 #include "chrome/browser/autocomplete/autocomplete.h" |
15 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 14 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
16 #include "chrome/browser/autocomplete/autocomplete_match.h" | 15 #include "chrome/browser/autocomplete/autocomplete_match.h" |
17 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/tab_contents/tab_contents.h" | 17 #include "chrome/browser/tab_contents/tab_contents.h" |
19 #include "chrome/browser/tabs/tab_strip_model_delegate.h" | 18 #include "chrome/browser/tabs/tab_strip_model_delegate.h" |
20 #include "chrome/browser/themes/browser_theme_provider.h" | 19 #include "chrome/browser/themes/browser_theme_provider.h" |
21 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
22 #include "chrome/browser/ui/browser_navigator.h" | 21 #include "chrome/browser/ui/browser_navigator.h" |
23 #include "chrome/browser/ui/gtk/browser_window_gtk.h" | 22 #include "chrome/browser/ui/gtk/browser_window_gtk.h" |
24 #include "chrome/browser/ui/gtk/custom_button.h" | 23 #include "chrome/browser/ui/gtk/custom_button.h" |
25 #include "chrome/browser/ui/gtk/gtk_theme_provider.h" | 24 #include "chrome/browser/ui/gtk/gtk_theme_provider.h" |
26 #include "chrome/browser/ui/gtk/gtk_util.h" | 25 #include "chrome/browser/ui/gtk/gtk_util.h" |
27 #include "chrome/browser/ui/gtk/tabs/dragged_tab_controller_gtk.h" | 26 #include "chrome/browser/ui/gtk/tabs/dragged_tab_controller_gtk.h" |
28 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 27 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
29 #include "chrome/common/notification_service.h" | 28 #include "chrome/common/notification_service.h" |
30 #include "chrome/common/notification_type.h" | 29 #include "chrome/common/notification_type.h" |
31 #include "gfx/gtk_util.h" | 30 #include "gfx/gtk_util.h" |
32 #include "gfx/point.h" | 31 #include "gfx/point.h" |
33 #include "grit/app_resources.h" | 32 #include "grit/app_resources.h" |
34 #include "grit/theme_resources.h" | 33 #include "grit/theme_resources.h" |
35 #include "ui/base/animation/animation_delegate.h" | 34 #include "ui/base/animation/animation_delegate.h" |
36 #include "ui/base/animation/slide_animation.h" | 35 #include "ui/base/animation/slide_animation.h" |
| 36 #include "ui/base/dragdrop/gtk_dnd_util.h" |
37 | 37 |
38 namespace { | 38 namespace { |
39 | 39 |
40 const int kDefaultAnimationDurationMs = 100; | 40 const int kDefaultAnimationDurationMs = 100; |
41 const int kResizeLayoutAnimationDurationMs = 166; | 41 const int kResizeLayoutAnimationDurationMs = 166; |
42 const int kReorderAnimationDurationMs = 166; | 42 const int kReorderAnimationDurationMs = 166; |
43 const int kAnimateToBoundsDurationMs = 150; | 43 const int kAnimateToBoundsDurationMs = 150; |
44 const int kMiniTabAnimationDurationMs = 150; | 44 const int kMiniTabAnimationDurationMs = 150; |
45 | 45 |
46 const int kNewTabButtonHOffset = -5; | 46 const int kNewTabButtonHOffset = -5; |
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 ViewIDUtil::SetID(tabstrip_.get(), VIEW_ID_TAB_STRIP); | 731 ViewIDUtil::SetID(tabstrip_.get(), VIEW_ID_TAB_STRIP); |
732 // We want the tab strip to be horizontally shrinkable, so that the Chrome | 732 // We want the tab strip to be horizontally shrinkable, so that the Chrome |
733 // window can be resized freely. | 733 // window can be resized freely. |
734 gtk_widget_set_size_request(tabstrip_.get(), 0, | 734 gtk_widget_set_size_request(tabstrip_.get(), 0, |
735 TabGtk::GetMinimumUnselectedSize().height()); | 735 TabGtk::GetMinimumUnselectedSize().height()); |
736 gtk_widget_set_app_paintable(tabstrip_.get(), TRUE); | 736 gtk_widget_set_app_paintable(tabstrip_.get(), TRUE); |
737 gtk_drag_dest_set(tabstrip_.get(), GTK_DEST_DEFAULT_ALL, | 737 gtk_drag_dest_set(tabstrip_.get(), GTK_DEST_DEFAULT_ALL, |
738 NULL, 0, | 738 NULL, 0, |
739 static_cast<GdkDragAction>( | 739 static_cast<GdkDragAction>( |
740 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK)); | 740 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK)); |
741 static const int targets[] = { gtk_dnd_util::TEXT_URI_LIST, | 741 static const int targets[] = { ui::TEXT_URI_LIST, |
742 gtk_dnd_util::NETSCAPE_URL, | 742 ui::NETSCAPE_URL, |
743 gtk_dnd_util::TEXT_PLAIN, | 743 ui::TEXT_PLAIN, |
744 -1 }; | 744 -1 }; |
745 gtk_dnd_util::SetDestTargetList(tabstrip_.get(), targets); | 745 ui::SetDestTargetList(tabstrip_.get(), targets); |
746 | 746 |
747 g_signal_connect(tabstrip_.get(), "expose-event", | 747 g_signal_connect(tabstrip_.get(), "expose-event", |
748 G_CALLBACK(OnExposeThunk), this); | 748 G_CALLBACK(OnExposeThunk), this); |
749 g_signal_connect(tabstrip_.get(), "size-allocate", | 749 g_signal_connect(tabstrip_.get(), "size-allocate", |
750 G_CALLBACK(OnSizeAllocateThunk), this); | 750 G_CALLBACK(OnSizeAllocateThunk), this); |
751 g_signal_connect(tabstrip_.get(), "drag-motion", | 751 g_signal_connect(tabstrip_.get(), "drag-motion", |
752 G_CALLBACK(OnDragMotionThunk), this); | 752 G_CALLBACK(OnDragMotionThunk), this); |
753 g_signal_connect(tabstrip_.get(), "drag-drop", | 753 g_signal_connect(tabstrip_.get(), "drag-drop", |
754 G_CALLBACK(OnDragDropThunk), this); | 754 G_CALLBACK(OnDragDropThunk), this); |
755 g_signal_connect(tabstrip_.get(), "drag-leave", | 755 g_signal_connect(tabstrip_.get(), "drag-leave", |
(...skipping 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1969 return FALSE; | 1969 return FALSE; |
1970 } | 1970 } |
1971 | 1971 |
1972 gboolean TabStripGtk::OnDragDataReceived(GtkWidget* widget, | 1972 gboolean TabStripGtk::OnDragDataReceived(GtkWidget* widget, |
1973 GdkDragContext* context, | 1973 GdkDragContext* context, |
1974 gint x, gint y, | 1974 gint x, gint y, |
1975 GtkSelectionData* data, | 1975 GtkSelectionData* data, |
1976 guint info, guint time) { | 1976 guint info, guint time) { |
1977 bool success = false; | 1977 bool success = false; |
1978 | 1978 |
1979 if (info == gtk_dnd_util::TEXT_URI_LIST || | 1979 if (info == ui::TEXT_URI_LIST || |
1980 info == gtk_dnd_util::NETSCAPE_URL || | 1980 info == ui::NETSCAPE_URL || |
1981 info == gtk_dnd_util::TEXT_PLAIN) { | 1981 info == ui::TEXT_PLAIN) { |
1982 success = CompleteDrop(data->data, info == gtk_dnd_util::TEXT_PLAIN); | 1982 success = CompleteDrop(data->data, info == ui::TEXT_PLAIN); |
1983 } | 1983 } |
1984 | 1984 |
1985 gtk_drag_finish(context, success, success, time); | 1985 gtk_drag_finish(context, success, success, time); |
1986 return TRUE; | 1986 return TRUE; |
1987 } | 1987 } |
1988 | 1988 |
1989 void TabStripGtk::OnNewTabClicked(GtkWidget* widget) { | 1989 void TabStripGtk::OnNewTabClicked(GtkWidget* widget) { |
1990 GdkEvent* event = gtk_get_current_event(); | 1990 GdkEvent* event = gtk_get_current_event(); |
1991 DCHECK_EQ(event->type, GDK_BUTTON_RELEASE); | 1991 DCHECK_EQ(event->type, GDK_BUTTON_RELEASE); |
1992 int mouse_button = event->button.button; | 1992 int mouse_button = event->button.button; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2054 | 2054 |
2055 // Let the middle mouse button initiate clicks as well. | 2055 // Let the middle mouse button initiate clicks as well. |
2056 gtk_util::SetButtonTriggersNavigation(button->widget()); | 2056 gtk_util::SetButtonTriggersNavigation(button->widget()); |
2057 g_signal_connect(button->widget(), "clicked", | 2057 g_signal_connect(button->widget(), "clicked", |
2058 G_CALLBACK(OnNewTabClickedThunk), this); | 2058 G_CALLBACK(OnNewTabClickedThunk), this); |
2059 GTK_WIDGET_UNSET_FLAGS(button->widget(), GTK_CAN_FOCUS); | 2059 GTK_WIDGET_UNSET_FLAGS(button->widget(), GTK_CAN_FOCUS); |
2060 gtk_fixed_put(GTK_FIXED(tabstrip_.get()), button->widget(), 0, 0); | 2060 gtk_fixed_put(GTK_FIXED(tabstrip_.get()), button->widget(), 0, 0); |
2061 | 2061 |
2062 return button; | 2062 return button; |
2063 } | 2063 } |
OLD | NEW |