diff options
author | suzhe@chromium.org <suzhe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-18 16:33:55 +0000 |
---|---|---|
committer | suzhe@chromium.org <suzhe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-18 16:33:55 +0000 |
commit | ae272cbc48e7618aac9cd29a0e946777b9f7efcf (patch) | |
tree | 4e44d815fbc14a52e80835b177c591acad126179 /chrome/browser/gtk/slide_animator_gtk.cc | |
parent | 9de65c8b3f17f28ff7edebb63f0922f5734bf55b (diff) | |
download | chromium_src-ae272cbc48e7618aac9cd29a0e946777b9f7efcf.zip chromium_src-ae272cbc48e7618aac9cd29a0e946777b9f7efcf.tar.gz chromium_src-ae272cbc48e7618aac9cd29a0e946777b9f7efcf.tar.bz2 |
Fix issue 11258: Linux: gracefully handle small browser window
TODO: Make location bar to be freely shrinkable. Will be addressed in another CL.
BUG=11258
TEST=See bug report.
Review URL: http://codereview.chromium.org/507022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34954 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/slide_animator_gtk.cc')
-rw-r--r-- | chrome/browser/gtk/slide_animator_gtk.cc | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/chrome/browser/gtk/slide_animator_gtk.cc b/chrome/browser/gtk/slide_animator_gtk.cc index 329aaa4..ba48e46 100644 --- a/chrome/browser/gtk/slide_animator_gtk.cc +++ b/chrome/browser/gtk/slide_animator_gtk.cc @@ -8,14 +8,20 @@ #include "app/slide_animation.h" #include "base/logging.h" +#include "chrome/browser/gtk/gtk_expanded_container.h" + namespace { -void OnFixedSizeAllocate(GtkWidget* fixed, - GtkAllocation* allocation, - GtkWidget* child) { - // The size of the GtkFixed has changed. We want |child_| to match widths, - // but the height should not change. - gtk_widget_set_size_request(child, allocation->width, -1); +void OnChildSizeRequest(GtkWidget* expanded, + GtkWidget* child, + GtkRequisition* requisition, + gpointer control_child_size) { + // If |control_child_size| is true, then we want |child_| to match the width + // of the |widget_|, but the height of |child_| should not change. + if (!GPOINTER_TO_INT(control_child_size)) { + requisition->width = -1; + } + requisition->height = -1; } } // namespace @@ -29,16 +35,16 @@ SlideAnimatorGtk::SlideAnimatorGtk(GtkWidget* child, : child_(child), direction_(direction), delegate_(delegate) { - widget_.Own(gtk_fixed_new()); - gtk_fixed_put(GTK_FIXED(widget_.get()), child, 0, 0); + widget_.Own(gtk_expanded_container_new()); + gtk_container_add(GTK_CONTAINER(widget_.get()), child); gtk_widget_set_size_request(widget_.get(), -1, 0); - if (control_child_size) { - // If the child requests it, we will manually set the size request for - // |child_| every time the GtkFixed changes sizes. This is mainly useful - // for bars, where we want the child to expand to fill all available space. - g_signal_connect(widget_.get(), "size-allocate", - G_CALLBACK(OnFixedSizeAllocate), child_); - } + + // If the child requests it, we will manually set the size request for + // |child_| every time the |widget_| changes sizes. This is mainly useful + // for bars, where we want the child to expand to fill all available space. + g_signal_connect(widget_.get(), "child-size-request", + G_CALLBACK(OnChildSizeRequest), + GINT_TO_POINTER(control_child_size)); // We connect to this signal to set an initial position for our child widget. // The reason we connect to this signal rather than setting the initial @@ -106,8 +112,8 @@ void SlideAnimatorGtk::AnimationProgressed(const Animation* animation) { int showing_height = static_cast<int>(req.height * animation_->GetCurrentValue()); if (direction_ == DOWN) { - gtk_fixed_move(GTK_FIXED(widget_.get()), child_, 0, - showing_height - req.height); + gtk_expanded_container_move(GTK_EXPANDED_CONTAINER(widget_.get()), + child_, 0, showing_height - req.height); child_needs_move_ = false; } gtk_widget_set_size_request(widget_.get(), -1, showing_height); @@ -126,7 +132,8 @@ void SlideAnimatorGtk::OnChildSizeAllocate(GtkWidget* child, GtkAllocation* allocation, SlideAnimatorGtk* slider) { if (slider->child_needs_move_) { - gtk_fixed_move(GTK_FIXED(slider->widget()), child, 0, -allocation->height); + gtk_expanded_container_move(GTK_EXPANDED_CONTAINER(slider->widget()), + child, 0, -allocation->height); slider->child_needs_move_ = false; } } |