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

Unified Diff: views/widget/widget_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
« no previous file with comments | « views/widget/widget_gtk.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/widget/widget_gtk.cc
diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc
index 1e73e38e678fa0f5b123185ccc4b1fd627983ac8..c9144d7729008883f1bacccbf7ab1ba815b52eeb 100644
--- a/views/widget/widget_gtk.cc
+++ b/views/widget/widget_gtk.cc
@@ -500,6 +500,8 @@ void WidgetGtk::Init(GtkWidget* parent,
GDK_KEY_RELEASE_MASK);
SetRootViewForWidget(widget_, root_view_.get());
+ g_signal_connect_after(G_OBJECT(window_contents_), "size_request",
+ G_CALLBACK(&OnSizeRequestThunk), this);
g_signal_connect_after(G_OBJECT(window_contents_), "size_allocate",
G_CALLBACK(&OnSizeAllocateThunk), this);
gtk_widget_set_app_paintable(window_contents_, true);
@@ -883,6 +885,18 @@ int WidgetGtk::GetFlagsForEventButton(const GdkEventButton& event) {
return flags;
}
+void WidgetGtk::OnSizeRequest(GtkWidget* widget, GtkRequisition* requisition) {
+ // Do only return the preferred size for child windows. GtkWindow interprets
+ // the requisition as a minimum size for top level windows, returning a
+ // preferred size for these would prevents us from setting smaller window
+ // sizes.
+ if (type_ == TYPE_CHILD) {
+ gfx::Size size(root_view_->GetPreferredSize());
+ requisition->width = size.width();
+ requisition->height = size.height();
+ }
+}
+
void WidgetGtk::OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation) {
// See comment next to size_ as to why we do this. Also note, it's tempting
// to put this in the static method so subclasses don't need to worry about
« no previous file with comments | « views/widget/widget_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698