[gnome-documents/wip/ui-changes] preview: make the thumbbar show on click



commit 14609afb1c203237cf3d717b11e85d83aeffbded
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed Nov 28 18:22:32 2012 -0500

    preview: make the thumbbar show on click
    
    And disappear when you click either on the document or on a scrollbar
    itself.

 src/preview.js |   22 ++++++++++++++++++++--
 1 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/src/preview.js b/src/preview.js
index 67acb7a..f058678 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -46,11 +46,14 @@ const PreviewView = new Lang.Class({
     _init: function(overlayLayout) {
         this._model = null;
         this._jobFind = null;
+        this._controlsVisible = false;
 
         this.widget = new Gtk.ScrolledWindow({ hexpand: true,
                                                vexpand: true,
                                                shadow_type: Gtk.ShadowType.IN });
         this.widget.get_style_context().add_class('documents-scrolledwin');
+        this.widget.get_hscrollbar().connect('button-press-event', Lang.bind(this, this._onScrollbarClick));
+        this.widget.get_vscrollbar().connect('button-press-event', Lang.bind(this, this._onScrollbarClick));
 
         // create thumb bar
         this._thumbBar = new PreviewThumbnails(this._model);
@@ -108,6 +111,14 @@ const PreviewView = new Lang.Class({
                             Lang.bind(this, this._onKeyPressEvent));
     },
 
+    _flipControlsState: function() {
+        this._controlsVisible = !this._controlsVisible;
+        if (this._controlsVisible)
+            this._thumbBar.show();
+        else
+            this._thumbBar.hide();
+    },
+
     _onKeyPressEvent: function(widget, event) {
         let keyval = event.get_keyval()[1];
         let state = event.get_state()[1];
@@ -147,6 +158,15 @@ const PreviewView = new Lang.Class({
             return true;
         }
 
+        this._flipControlsState();
+
+        return false;
+    },
+
+    _onScrollbarClick: function() {
+        if (this._controlsVisible)
+            this._flipControlsState();
+
         return false;
     },
 
@@ -199,7 +219,6 @@ const PreviewView = new Lang.Class({
             this._createView();
             this.view.set_model(this._model);
             this._thumbBar.view.model = model;
-            this._thumbBar.show();
         }
     },
 
@@ -225,7 +244,6 @@ const PreviewThumbnails = new Lang.Class({
 
     show: function() {
         this.actor.show();
-        log('show');
 
         Tweener.addTween(this.actor,
             { opacity: 255,



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