[gnome-documents] window: update the constraint offset when the scrollbar visibility flips



commit 2c37e4499f4b9ec2c8b6b1ecb04959845ba9ce83
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Thu Sep 1 10:05:47 2011 -0400

    window: update the constraint offset when the scrollbar visibility flips
    
    So we get a full-width toolbar if we don't have any vscrollbar.

 src/mainWindow.js |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 181e311..20e624f 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -246,12 +246,24 @@ MainWindow.prototype = {
         this._fsToolbar.connect('back-clicked',
                                 Lang.bind(this, this._onToolbarBackClicked));
 
+        let vScrollbar = this._scrolledWin.get_vscrollbar();
+
+        let sizeConstraint = new Clutter.BindConstraint
+            ({ coordinate: Clutter.BindCoordinate.WIDTH,
+               source: this.window.get_stage(),
+               offset: (vScrollbar.get_visible() ?
+                        (- (vScrollbar.get_preferred_width()[1])) : 0 ) });
+        // update the constraint size when the scrollbar changes visibility
+        vScrollbar.connect('notify::visible',
+            function() {
+                sizeConstraint.offset = (vScrollbar.get_visible() ?
+                                         (- (vScrollbar.get_preferred_width()[1])) : 0 );
+            });
+
         this._fsToolbarActor = new GtkClutter.Actor({ contents: this._fsToolbar.widget,
                                                       opacity: 0 });
-        this._fsToolbarActor.add_constraint(
-            new Clutter.BindConstraint({ coordinate: Clutter.BindCoordinate.WIDTH,
-                                         source: this.window.get_stage(),
-                                         offset: - (this._scrolledWin.get_vscrollbar().get_preferred_width()[1]) }));
+        this._fsToolbarActor.add_constraint(sizeConstraint);
+
         this.window.get_stage().add_actor(this._fsToolbarActor);
     },
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]