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

Unified Diff: content/shell/shell_gtk.cc

Issue 14496004: Gtk content shell: make the window shrinkable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address issue raised by jochen: nit. please spell out "elms" Created 7 years, 7 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 | « content/shell/shell.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/shell/shell_gtk.cc
diff --git a/content/shell/shell_gtk.cc b/content/shell/shell_gtk.cc
index 227d82b8520355155c2bc26b601044fd3e11b905..6082cf49af11da1aa186dbec3943b25bc6c62122 100644
--- a/content/shell/shell_gtk.cc
+++ b/content/shell/shell_gtk.cc
@@ -101,10 +101,11 @@ void Shell::PlatformSetIsLoading(bool loading) {
}
void Shell::PlatformCreateWindow(int width, int height) {
- SizeTo(width, height);
-
- if (headless_)
+ ui_elements_height_ = 0;
+ if (headless_) {
+ SizeTo(width, height);
return;
+ }
window_ = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
gtk_window_set_title(window_, "Content Shell");
@@ -201,6 +202,25 @@ void Shell::PlatformCreateWindow(int width, int height) {
gtk_box_pack_start(GTK_BOX(vbox_), toolbar, FALSE, FALSE, 0);
gtk_container_add(GTK_CONTAINER(window_), vbox_);
+
+ // Trigger layout of the UI elements, so that we can measure their
+ // heights. The width and height passed to this method are meant for the web
+ // contents view, not the top-level window. Since Gtk only seems to provide a
+ // suitable resizing function for top-level windows, we need to know how to
+ // convert from web contents view size to top-level window size.
+ gtk_widget_show_all(GTK_WIDGET(vbox_));
+
+ // Measure the heights of the UI elements, now that they have been laid out.
+ GtkRequisition elm_size;
+ gtk_widget_size_request(menu_bar, &elm_size);
+ ui_elements_height_ += elm_size.height;
+ gtk_widget_size_request(toolbar, &elm_size);
+ ui_elements_height_ += elm_size.height;
+
+ // We're ready to set an initial window size.
+ SizeTo(width, height);
+
+ // Finally, show the window.
gtk_widget_show_all(GTK_WIDGET(window_));
}
@@ -215,7 +235,13 @@ void Shell::PlatformSetContents() {
void Shell::SizeTo(int width, int height) {
content_width_ = width;
content_height_ = height;
- if (web_contents_) {
+
+ // Prefer setting the top level window's size (if we have one), rather than
+ // setting the inner widget's minimum size (so that the user can shrink the
+ // window if she wants).
+ if (window_) {
+ gtk_window_resize(window_, width, height + ui_elements_height_);
+ } else if (web_contents_) {
gtk_widget_set_size_request(web_contents_->GetView()->GetNativeView(),
width, height);
}
« no previous file with comments | « content/shell/shell.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698