Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Unified Diff: views/controls/tabbed_pane/native_tabbed_pane_gtk.cc

Issue 2812026: Auto-size the views version of the options dialog. (Closed)
Patch Set: Fix autosizing issue with gtk pref pages in chromeos options dialog. Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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) {
« no previous file with comments | « views/controls/tabbed_pane/native_tabbed_pane_gtk.h ('k') | views/controls/tabbed_pane/native_tabbed_pane_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698