[gnome-documents] preview: Show the navigation bar after pointer movement



commit 487ec071d54b0d33458b908f8f0de31e9d82f869
Author: Debarshi Ray <debarshir gnome org>
Date:   Mon Feb 24 14:17:20 2014 +0100

    preview: Show the navigation bar after pointer movement
    
    Merge NavBar and NavButtons into one NavControls class so that we can
    use the same pointer tracking code, which was the bulk of NavButtons,
    for all the widgets.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=720518

 src/preview.js |  112 ++++++++++++++++++++------------------------------------
 1 files changed, 40 insertions(+), 72 deletions(-)
---
diff --git a/src/preview.js b/src/preview.js
index 685013d..da7de03 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -80,12 +80,8 @@ const PreviewView = new Lang.Class({
         this._previewContextMenu = Gtk.Menu.new_from_model(model);
         this._previewContextMenu.attach_to_widget(this.widget, null);
 
-        // create page nav bar
-        this._navBar = new PreviewNavBar(this._model);
-        this._overlay.add_overlay(this._navBar.widget);
-
-        // create page nav buttons
-        this._navButtons = new PreviewNavButtons(this, this._overlay);
+        // create page nav controls
+        this._navControls = new PreviewNavControls(this, this._overlay);
 
         this.widget.show_all();
 
@@ -161,7 +157,7 @@ const PreviewView = new Lang.Class({
         if (!Application.documentManager.metadata)
             return;
 
-        this._navButtons.show();
+        this._navControls.show();
 
         this._bookmarks = new GdPrivate.Bookmarks({ metadata: Application.documentManager.metadata });
     },
@@ -352,12 +348,9 @@ const PreviewView = new Lang.Class({
         if (this._controlsVisible) {
             if (this._fsToolbar)
                 this._fsToolbar.show();
-            if (!this._loadError)
-                this._navBar.show();
         } else {
             if (this._fsToolbar)
                 this._fsToolbar.hide();
-            this._navBar.hide();
         }
     },
 
@@ -366,7 +359,7 @@ const PreviewView = new Lang.Class({
         if (windowMode != WindowMode.WindowMode.PREVIEW) {
             this.controlsVisible = false;
             this._hidePresentation();
-            this._navButtons.hide();
+            this._navControls.hide();
         }
     },
 
@@ -554,8 +547,7 @@ const PreviewView = new Lang.Class({
 
         if (this._model) {
             this.view.set_model(this._model);
-            this._navBar.setModel(model);
-            this._navButtons.setModel(model);
+            this._navControls.setModel(model);
             this._model.connect('page-changed', Lang.bind(this, this._onPageChanged));
         }
     },
@@ -575,17 +567,32 @@ const PreviewView = new Lang.Class({
 Signals.addSignalMethods(PreviewView.prototype);
 
 const _PREVIEW_NAVBAR_MARGIN = 30;
+const _AUTO_HIDE_TIMEOUT = 2;
 
-const PreviewNavBar = new Lang.Class({
-    Name: 'PreviewNavBar',
+const PreviewNavControls = new Lang.Class({
+    Name: 'PreviewNavControls',
 
-    _init: function(model) {
-        this._model = model;
-        this.widget = new GdPrivate.NavBar({ document_model: model,
-                                             margin: _PREVIEW_NAVBAR_MARGIN,
-                                             valign: Gtk.Align.END,
-                                             opacity: 0 });
-        this.widget.get_style_context().add_class('osd');
+    _init: function(previewView, overlay) {
+        this._previewView = previewView;
+        this._model = previewView.getModel();
+        this._overlay = overlay;
+
+        this._visible = false;
+        this._pageChangedId = 0;
+        this._autoHideId = 0;
+        this._motionId = 0;
+        this._hover = false;
+
+        this.bar_widget = new GdPrivate.NavBar({ document_model: this._model,
+                                                 margin: _PREVIEW_NAVBAR_MARGIN,
+                                                 valign: Gtk.Align.END,
+                                                 opacity: 0 });
+        this.bar_widget.get_style_context().add_class('osd');
+        this._overlay.add_overlay(this.bar_widget);
+        this.bar_widget.connect('enter-notify-event', Lang.bind(this, this._onEnterNotify));
+        this.bar_widget.connect('leave-notify-event', Lang.bind(this, this._onLeaveNotify));
+
+        let buttonArea = this.bar_widget.get_button_area();
 
         let button = new Gtk.Button({ action_name: 'app.places',
                                       child: new Gtk.Image({ icon_name: 'view-list-symbolic',
@@ -593,7 +600,6 @@ const PreviewNavBar = new Lang.Class({
                                       valign: Gtk.Align.CENTER,
                                       tooltip_text: _("Bookmarks")
                                     });
-        let buttonArea = this.widget.get_button_area();
         buttonArea.pack_start(button, false, false, 0);
 
         button = new Gtk.ToggleButton({ action_name: 'app.bookmark-page',
@@ -603,54 +609,6 @@ const PreviewNavBar = new Lang.Class({
                                         tooltip_text: _("Bookmark this page")
                                       });
         buttonArea.pack_start(button, false, false, 0);
-    },
-
-    setModel: function(model) {
-        this._model = model;
-        this.widget.document_model = model;
-        if (!model)
-            this.hide();
-
-        let hasMultiplePages = (model.document.get_n_pages() > 1);
-        Application.application.lookup_action('bookmark-page').enabled = hasMultiplePages;
-        Application.application.lookup_action('places').enabled = hasMultiplePages;
-    },
-
-    show: function() {
-        if (!this._model)
-            return;
-
-        this.widget.show_all();
-        Tweener.addTween(this.widget, { opacity: 1,
-                                        time: 0.30,
-                                        transition: 'easeOutQuad' });
-    },
-
-    hide: function() {
-        Tweener.addTween(this.widget, { opacity: 0,
-                                        time: 0.30,
-                                        transition: 'easeOutQuad',
-                                        onComplete: function() {
-                                            this.widget.hide();
-                                        },
-                                        onCompleteScope: this });
-    }
-});
-
-const _AUTO_HIDE_TIMEOUT = 2;
-const PreviewNavButtons = new Lang.Class({
-    Name: 'PreviewNavButtons',
-
-    _init: function(previewView, overlay) {
-        this._previewView = previewView;
-        this._model = previewView.getModel();
-        this._overlay = overlay;
-
-        this._visible = false;
-        this._pageChangedId = 0;
-        this._autoHideId = 0;
-        this._motionId = 0;
-        this._hover = false;
 
         let isRtl = (this._previewView.widget.get_direction() == Gtk.TextDirection.RTL);
         let prevIconName = isRtl ? 'go-next-symbolic' : 'go-previous-symbolic';
@@ -720,6 +678,7 @@ const PreviewNavButtons = new Lang.Class({
     },
 
     _autoHide: function() {
+        this._fadeOutButton(this.bar_widget);
         this._fadeOutButton(this.prev_widget);
         this._fadeOutButton(this.next_widget);
         this._autoHideId = 0;
@@ -741,11 +700,14 @@ const PreviewNavButtons = new Lang.Class({
 
     _updateVisibility: function() {
         if (!this._model || !this._visible) {
+            this._fadeOutButton(this.bar_widget);
             this._fadeOutButton(this.prev_widget);
             this._fadeOutButton(this.next_widget);
             return;
         }
 
+        this._fadeInButton(this.bar_widget);
+
         if (this._model.page > 0)
             this._fadeInButton(this.prev_widget);
         else
@@ -768,9 +730,15 @@ const PreviewNavButtons = new Lang.Class({
         }
 
         this._model = model;
+        this.bar_widget.document_model = model;
+
+        if (this._model) {
+            let hasMultiplePages = (this._model.document.get_n_pages() > 1);
+            Application.application.lookup_action('bookmark-page').enabled = hasMultiplePages;
+            Application.application.lookup_action('places').enabled = hasMultiplePages;
 
-        if (this._model)
             this._pageChangedId = this._model.connect('page-changed', Lang.bind(this, 
this._updateVisibility));
+        }
 
         this._updateVisibility();
     },


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