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/gtk_dnd_util.h" | 9 #include "app/gtk_dnd_util.h" |
10 #include "app/gfx/canvas_paint.h" | 10 #include "app/gfx/canvas_paint.h" |
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1008 } else { | 1008 } else { |
1009 GenerateIdealBounds(); | 1009 GenerateIdealBounds(); |
1010 StartMoveTabAnimation(from_index, to_index); | 1010 StartMoveTabAnimation(from_index, to_index); |
1011 } | 1011 } |
1012 } | 1012 } |
1013 | 1013 |
1014 void TabStripGtk::TabChangedAt(TabContents* contents, int index, | 1014 void TabStripGtk::TabChangedAt(TabContents* contents, int index, |
1015 bool loading_only) { | 1015 bool loading_only) { |
1016 // Index is in terms of the model. Need to make sure we adjust that index in | 1016 // Index is in terms of the model. Need to make sure we adjust that index in |
1017 // case we have an animation going. | 1017 // case we have an animation going. |
1018 TabGtk* tab = GetTabAt(index); | 1018 TabGtk* tab = GetTabAtAdjustForAnimation(index); |
1019 tab->UpdateData(contents, loading_only); | 1019 tab->UpdateData(contents, loading_only); |
1020 tab->UpdateFromModel(); | 1020 tab->UpdateFromModel(); |
1021 } | 1021 } |
1022 | 1022 |
1023 void TabStripGtk::TabPinnedStateChanged(TabContents* contents, int index) { | 1023 void TabStripGtk::TabPinnedStateChanged(TabContents* contents, int index) { |
1024 GetTabAt(index)->set_pinned(model_->IsTabPinned(index)); | 1024 GetTabAt(index)->set_pinned(model_->IsTabPinned(index)); |
1025 StartPinnedTabAnimation(index); | 1025 StartPinnedTabAnimation(index); |
1026 } | 1026 } |
1027 | 1027 |
1028 //////////////////////////////////////////////////////////////////////////////// | 1028 //////////////////////////////////////////////////////////////////////////////// |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1206 } | 1206 } |
1207 return -1; | 1207 return -1; |
1208 } | 1208 } |
1209 | 1209 |
1210 TabGtk* TabStripGtk::GetTabAt(int index) const { | 1210 TabGtk* TabStripGtk::GetTabAt(int index) const { |
1211 DCHECK_GE(index, 0); | 1211 DCHECK_GE(index, 0); |
1212 DCHECK_LT(index, GetTabCount()); | 1212 DCHECK_LT(index, GetTabCount()); |
1213 return tab_data_.at(index).tab; | 1213 return tab_data_.at(index).tab; |
1214 } | 1214 } |
1215 | 1215 |
| 1216 TabGtk* TabStripGtk::GetTabAtAdjustForAnimation(int index) const { |
| 1217 if (active_animation_.get() && |
| 1218 active_animation_->type() == TabAnimation::REMOVE && |
| 1219 index >= |
| 1220 static_cast<RemoveTabAnimation*>(active_animation_.get())->index()) { |
| 1221 index++; |
| 1222 } |
| 1223 return GetTabAt(index); |
| 1224 } |
| 1225 |
1216 void TabStripGtk::RemoveTabAt(int index) { | 1226 void TabStripGtk::RemoveTabAt(int index) { |
1217 TabGtk* removed = tab_data_.at(index).tab; | 1227 TabGtk* removed = tab_data_.at(index).tab; |
1218 | 1228 |
1219 // Remove the Tab from the TabStrip's list. | 1229 // Remove the Tab from the TabStrip's list. |
1220 tab_data_.erase(tab_data_.begin() + index); | 1230 tab_data_.erase(tab_data_.begin() + index); |
1221 | 1231 |
1222 if (!IsDragSessionActive() || !drag_controller_->IsDragSourceTab(removed)) { | 1232 if (!IsDragSessionActive() || !drag_controller_->IsDragSourceTab(removed)) { |
1223 gtk_container_remove(GTK_CONTAINER(tabstrip_.get()), removed->widget()); | 1233 gtk_container_remove(GTK_CONTAINER(tabstrip_.get()), removed->widget()); |
1224 delete removed; | 1234 delete removed; |
1225 } | 1235 } |
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2020 | 2030 |
2021 // Let the middle mouse button initiate clicks as well. | 2031 // Let the middle mouse button initiate clicks as well. |
2022 gtk_util::SetButtonTriggersNavigation(button->widget()); | 2032 gtk_util::SetButtonTriggersNavigation(button->widget()); |
2023 g_signal_connect(G_OBJECT(button->widget()), "clicked", | 2033 g_signal_connect(G_OBJECT(button->widget()), "clicked", |
2024 G_CALLBACK(OnNewTabClicked), this); | 2034 G_CALLBACK(OnNewTabClicked), this); |
2025 GTK_WIDGET_UNSET_FLAGS(button->widget(), GTK_CAN_FOCUS); | 2035 GTK_WIDGET_UNSET_FLAGS(button->widget(), GTK_CAN_FOCUS); |
2026 gtk_fixed_put(GTK_FIXED(tabstrip_.get()), button->widget(), 0, 0); | 2036 gtk_fixed_put(GTK_FIXED(tabstrip_.get()), button->widget(), 0, 0); |
2027 | 2037 |
2028 return button; | 2038 return button; |
2029 } | 2039 } |
OLD | NEW |