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 "views/controls/tabbed_pane/native_tabbed_pane_gtk.h" | 5 #include "views/controls/tabbed_pane/native_tabbed_pane_gtk.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include "app/gfx/canvas.h" | 9 #include "app/gfx/canvas.h" |
10 #include "app/gfx/font.h" | 10 #include "app/gfx/font.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 // Select the next tab. | 53 // Select the next tab. |
54 SelectTabAt(index + 1); | 54 SelectTabAt(index + 1); |
55 } else { | 55 } else { |
56 // We are the last tab, select the previous one. | 56 // We are the last tab, select the previous one. |
57 if (index > 0) { | 57 if (index > 0) { |
58 SelectTabAt(index - 1); | 58 SelectTabAt(index - 1); |
59 } else { | 59 } else { |
60 // last tab. nothing to select. | 60 // last tab. nothing to select. |
61 } | 61 } |
62 } | 62 } |
| 63 |
| 64 GtkWidget* page = |
| 65 gtk_notebook_get_nth_page(GTK_NOTEBOOK(native_view()), index); |
| 66 WidgetGtk* widget = WidgetGtk::GetViewForNative(page); |
| 67 |
| 68 // detach the content view from widget so that we can delete widget |
| 69 // without destroying the content view. |
63 View* removed_tab = GetTabViewAt(index); | 70 View* removed_tab = GetTabViewAt(index); |
| 71 widget->GetRootView()->RemoveChildView(removed_tab); |
64 | 72 |
| 73 // widget delete itself when native_view is deleted. |
65 gtk_notebook_remove_page(GTK_NOTEBOOK(native_view()), index); | 74 gtk_notebook_remove_page(GTK_NOTEBOOK(native_view()), index); |
66 | 75 |
67 return removed_tab; | 76 return removed_tab; |
68 } | 77 } |
69 | 78 |
70 void NativeTabbedPaneGtk::SelectTabAt(int index) { | 79 void NativeTabbedPaneGtk::SelectTabAt(int index) { |
71 DCHECK((index >= 0) && (index < GetTabCount())); | 80 DCHECK((index >= 0) && (index < GetTabCount())); |
72 gtk_notebook_set_current_page(GTK_NOTEBOOK(native_view()), index); | 81 gtk_notebook_set_current_page(GTK_NOTEBOOK(native_view()), index); |
73 } | 82 } |
74 | 83 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 //////////////////////////////////////////////////////////////////////////////// | 175 //////////////////////////////////////////////////////////////////////////////// |
167 // NativeTabbedPaneWrapper, public: | 176 // NativeTabbedPaneWrapper, public: |
168 | 177 |
169 // static | 178 // static |
170 NativeTabbedPaneWrapper* NativeTabbedPaneWrapper::CreateNativeWrapper( | 179 NativeTabbedPaneWrapper* NativeTabbedPaneWrapper::CreateNativeWrapper( |
171 TabbedPane* tabbed_pane) { | 180 TabbedPane* tabbed_pane) { |
172 return new NativeTabbedPaneGtk(tabbed_pane); | 181 return new NativeTabbedPaneGtk(tabbed_pane); |
173 } | 182 } |
174 | 183 |
175 } // namespace views | 184 } // namespace views |
OLD | NEW |