Index: views/controls/tabbed_pane/native_tabbed_pane_gtk.cc |
diff --git a/views/controls/tabbed_pane/native_tabbed_pane_gtk.cc b/views/controls/tabbed_pane/native_tabbed_pane_gtk.cc |
index 8900de35d7fec11ab6c910cf7c92f9b8fe0116d6..25705fcbd5765222cf2b62bf8e45f338348e1dbc 100644 |
--- a/views/controls/tabbed_pane/native_tabbed_pane_gtk.cc |
+++ b/views/controls/tabbed_pane/native_tabbed_pane_gtk.cc |
@@ -75,6 +75,11 @@ View* NativeTabbedPaneGtk::RemoveTabAtIndex(int index) { |
// widget delete itself when native_view is deleted. |
gtk_notebook_remove_page(GTK_NOTEBOOK(native_view()), index); |
+ // Removing a tab might change the size of the tabbed pane. |
+ RootView* root_view = GetRootView(); |
+ if (root_view) |
+ GetRootView()->Layout(); |
+ |
return removed_tab; |
} |
@@ -103,6 +108,19 @@ void NativeTabbedPaneGtk::SetFocus() { |
Focus(); |
} |
+gfx::Size NativeTabbedPaneGtk::GetPreferredSize() { |
+ if (!native_view()) |
+ return gfx::Size(); |
+ |
+ // For some strange reason (or maybe it's a bug), the requisition is not |
+ // returned in the passed requisition parameter, but instead written to the |
+ // widget's requisition field. |
+ GtkRequisition requisition = { 0, 0 }; |
+ gtk_widget_size_request(GTK_WIDGET(native_view()), &requisition); |
+ GtkRequisition& size(GTK_WIDGET(native_view())->requisition); |
+ return gfx::Size(size.width, size.height); |
+} |
+ |
gfx::NativeView NativeTabbedPaneGtk::GetTestingHandle() const { |
return native_view(); |
} |
@@ -166,6 +184,11 @@ void NativeTabbedPaneGtk::DoAddTabAtIndex(int index, const std::wstring& title, |
if (tab_count == 0 && select_if_first_tab) |
gtk_notebook_set_current_page(GTK_NOTEBOOK(native_view()), 0); |
+ |
+ // Relayout the hierarchy, since the added tab might require more space. |
+ RootView* root_view = GetRootView(); |
+ if (root_view) |
+ GetRootView()->Layout(); |
} |
WidgetGtk* NativeTabbedPaneGtk::GetWidgetAt(int index) { |