[gnome-documents/wip/ui-changes] preview: make the fullscreen toolbar follow the same visibility logic



commit 65a35e37fbf3567f957dd4958edeb273134edb29
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed Nov 28 18:43:18 2012 -0500

    preview: make the fullscreen toolbar follow the same visibility logic

 src/embed.js   |    7 ------
 src/preview.js |   61 +++++++++++++++++++++++++++++++------------------------
 2 files changed, 34 insertions(+), 34 deletions(-)
---
diff --git a/src/embed.js b/src/embed.js
index 2b54f67..50e5706 100644
--- a/src/embed.js
+++ b/src/embed.js
@@ -444,13 +444,6 @@ const Embed = new Lang.Class({
     },
 
     _onFullscreenChanged: function(controller, fullscreen) {
-        if (fullscreen) {
-            this._previewFullscreen = new Preview.PreviewFullscreen(this._preview, this._overlayLayout, this._contentsActor);
-        } else {
-            this._previewFullscreen.destroy();
-            this._previewFullscreen = null;
-        }
-
         Gtk.Settings.get_default().gtk_application_prefer_dark_theme = fullscreen;
         this._toolbar.widget.visible = !fullscreen;
     },
diff --git a/src/preview.js b/src/preview.js
index f058678..86ec440 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -48,6 +48,9 @@ const PreviewView = new Lang.Class({
         this._jobFind = null;
         this._controlsVisible = false;
 
+        Global.modeController.connect('fullscreen-changed',
+                                      Lang.bind(this, this._onFullscreenChanged));
+
         this.widget = new Gtk.ScrolledWindow({ hexpand: true,
                                                vexpand: true,
                                                shadow_type: Gtk.ShadowType.IN });
@@ -60,6 +63,12 @@ const PreviewView = new Lang.Class({
         overlayLayout.add(this._thumbBar.actor,
             Clutter.BinAlignment.FILL, Clutter.BinAlignment.END);
 
+        // create fullscreen toolbar (hidden by default)
+        this._fsToolbar = new PreviewFullscreenToolbar(this);
+        this._fsToolbar.setModel(this._model);
+        overlayLayout.add(this._fsToolbar.actor,
+            Clutter.BinAlignment.FILL, Clutter.BinAlignment.START);
+
         this._createView();
         this.widget.show_all();
 
@@ -113,10 +122,23 @@ const PreviewView = new Lang.Class({
 
     _flipControlsState: function() {
         this._controlsVisible = !this._controlsVisible;
-        if (this._controlsVisible)
+        if (this._controlsVisible) {
+            if (Global.modeController.getFullscreen())
+                this._fsToolbar.show();
             this._thumbBar.show();
-        else
+        } else {
+            this._fsToolbar.hide();
             this._thumbBar.hide();
+        }
+    },
+
+    _onFullscreenChanged: function() {
+        let fullscreen = Global.modeController.getFullscreen();
+
+        if (fullscreen && this._controlsVisible)
+            this._fsToolbar.show();
+        else if (!fullscreen)
+            this._fsToolbar.hide();
     },
 
     _onKeyPressEvent: function(widget, event) {
@@ -211,6 +233,7 @@ const PreviewView = new Lang.Class({
         if (this.view) {
             this.view.destroy();
             this._thumbBar.hide();
+            this._fsToolbar.hide();
         }
 
         this._model = model;
@@ -219,6 +242,7 @@ const PreviewView = new Lang.Class({
             this._createView();
             this.view.set_model(this._model);
             this._thumbBar.view.model = model;
+            this._fsToolbar.setModel(model);
         }
     },
 
@@ -236,6 +260,7 @@ const PreviewThumbnails = new Lang.Class({
                                                show_buttons: false });
         this.widget.get_style_context().add_class('osd');
         this.actor = new GtkClutter.Actor({ contents: this.widget,
+                                            visible: false,
                                             opacity: 0 });
         Utils.alphaGtkWidget(this.actor.get_widget());
 
@@ -274,30 +299,6 @@ const PreviewFullscreen = new Lang.Class({
         this._filter = new GdPrivate.FullscreenFilter();
         this._filter.connect('motion-event', Lang.bind(this, this._fullscreenMotionHandler));
         this._filter.start();
-
-        // create toolbar
-        this._fsToolbar = new PreviewFullscreenToolbar(previewView);
-        this._fsToolbar.setModel(model);
-
-        layout.add(this._fsToolbar.actor,
-            Clutter.BinAlignment.FIXED, Clutter.BinAlignment.FIXED);
-
-        let vScrollbar = previewView.widget.get_vscrollbar();
-
-        let sizeConstraint = new Clutter.BindConstraint
-            ({ coordinate: Clutter.BindCoordinate.WIDTH,
-               source: parentActor,
-               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._fsToolbar.actor.add_constraint(sizeConstraint);
     },
 
     destroy: function() {
@@ -485,10 +486,12 @@ const PreviewFullscreenToolbar = new Lang.Class({
     _init: function(previewView) {
         this.parent(previewView);
 
+        this.actor.visible = false;
         this.actor.y = -(this.widget.get_preferred_height()[1]);
     },
 
     show: function() {
+        this.actor.show();
         Tweener.addTween(this.actor,
                          { y: 0,
                            time: 0.20,
@@ -499,6 +502,10 @@ const PreviewFullscreenToolbar = new Lang.Class({
         Tweener.addTween(this.actor,
                          { y: -(this.widget.get_preferred_height()[1]),
                            time: 0.20,
-                           transition: 'easeOutQuad' });
+                           transition: 'easeOutQuad',
+                           onComplete: function() {
+                               this.actor.hide();
+                           },
+                           onCompleteScope: this });
     }
 });



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