[gnome-documents] Use GtkRevealer for faders instead of Tweener



commit de8b10a7bb1b9e1c633437588cfe51b79a66cfbe
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed Apr 24 16:49:21 2013 -0400

    Use GtkRevealer for faders instead of Tweener
    
    Now that GtkRevealer supports it.

 src/preview.js    |  124 +++++++++++++++++++++++++---------------------------
 src/searchbar.js  |    1 -
 src/selections.js |   45 ++++++++-----------
 3 files changed, 78 insertions(+), 92 deletions(-)
---
diff --git a/src/preview.js b/src/preview.js
index 13354c7..f7110ec 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -32,7 +32,6 @@ const _ = imports.gettext.gettext;
 const Lang = imports.lang;
 const Mainloop = imports.mainloop;
 const Signals = imports.signals;
-const Tweener = imports.tweener.tweener;
 
 const Application = imports.application;
 const MainToolbar = imports.mainToolbar;
@@ -578,18 +577,21 @@ const PreviewNavBar = new Lang.Class({
 
     _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');
+
+        this._navbar = new GdPrivate.NavBar({ document_model: model });
+        this._navbar.get_style_context().add_class('osd');
+
+        this.widget = new Gtk.Revealer({ transition_type: Gtk.RevealerTransitionType.CROSSFADE,
+                                         child: this._navbar,
+                                         valign: Gtk.Align.END,
+                                         margin: _PREVIEW_NAVBAR_MARGIN });
 
         let button = new Gtk.Button({ action_name: 'app.places',
                                       child: new Gtk.Image({ icon_name: 'view-list-symbolic',
                                                              pixel_size: 16 }),
                                       valign: Gtk.Align.CENTER
                                     });
-        let buttonArea = this.widget.get_button_area();
+        let buttonArea = this._navbar.get_button_area();
         buttonArea.pack_start(button, false, false, 0);
 
         button = new Gtk.ToggleButton({ action_name: 'app.bookmark-page',
@@ -598,11 +600,13 @@ const PreviewNavBar = new Lang.Class({
                                         valign: Gtk.Align.CENTER
                                       });
         buttonArea.pack_start(button, false, false, 0);
+
+        this.widget.show_all();
     },
 
     setModel: function(model) {
         this._model = model;
-        this.widget.document_model = model;
+        this._navbar.document_model = model;
         if (!model)
             this.hide();
 
@@ -615,20 +619,11 @@ const PreviewNavBar = new Lang.Class({
         if (!this._model)
             return;
 
-        this.widget.show_all();
-        Tweener.addTween(this.widget, { opacity: 1,
-                                        time: 0.30,
-                                        transition: 'easeOutQuad' });
+        this.widget.reveal_child = true;
     },
 
     hide: function() {
-        Tweener.addTween(this.widget, { opacity: 0,
-                                        time: 0.30,
-                                        transition: 'easeOutQuad',
-                                        onComplete: function() {
-                                            this.widget.hide();
-                                        },
-                                        onCompleteScope: this });
+        this.widget.reveal_child = false;
     }
 });
 
@@ -640,36 +635,45 @@ const PreviewNavButtons = new Lang.Class({
         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.prev_widget = new Gtk.Button({ child: new Gtk.Image ({ icon_name: 'go-previous-symbolic',
-                                                                    pixel_size: 16 }),
-                                            margin_left: _PREVIEW_NAVBAR_MARGIN,
-                                            halign: Gtk.Align.START,
-                                            valign: Gtk.Align.CENTER });
-        this.prev_widget.get_style_context().add_class('osd');
-        this._overlay.add_overlay(this.prev_widget);
-        this.prev_widget.connect('clicked', Lang.bind(this, this._onPrevClicked));
-        this.prev_widget.connect('enter-notify-event', Lang.bind(this, this._onEnterNotify));
-        this.prev_widget.connect('leave-notify-event', Lang.bind(this, this._onLeaveNotify));
-
-        this.next_widget = new Gtk.Button({ child: new Gtk.Image ({ icon_name: 'go-next-symbolic',
-                                                                    pixel_size: 16 }),
-                                            margin_right: _PREVIEW_NAVBAR_MARGIN,
-                                            halign: Gtk.Align.END,
-                                            valign: Gtk.Align.CENTER });
-        this.next_widget.get_style_context().add_class('osd');
-        this._overlay.add_overlay(this.next_widget);
-        this.next_widget.connect('clicked', Lang.bind(this, this._onNextClicked));
-        this.next_widget.connect('enter-notify-event', Lang.bind(this, this._onEnterNotify));
-        this.next_widget.connect('leave-notify-event', Lang.bind(this, this._onLeaveNotify));
+        let prevButton = new Gtk.Button({ child: new Gtk.Image ({ icon_name: 'go-previous-symbolic',
+                                                                  pixel_size: 16 }) });
+        prevButton.get_style_context().add_class('osd');
+        prevButton.connect('clicked', Lang.bind(this, this._onPrevClicked));
+        prevButton.connect('enter-notify-event', Lang.bind(this, this._onEnterNotify));
+        prevButton.connect('leave-notify-event', Lang.bind(this, this._onLeaveNotify));
+
+        this._prev = new Gtk.Revealer({ transition_type: Gtk.RevealerTransitionType.CROSSFADE,
+                                        margin_left: _PREVIEW_NAVBAR_MARGIN,
+                                        halign: Gtk.Align.START,
+                                        valign: Gtk.Align.CENTER,
+                                        child: prevButton });
+        this._overlay.add_overlay(this._prev);
+
+        let nextButton = new Gtk.Button({ child: new Gtk.Image ({ icon_name: 'go-next-symbolic',
+                                                                  pixel_size: 16 }) });
+        nextButton.get_style_context().add_class('osd');
+        nextButton.connect('clicked', Lang.bind(this, this._onNextClicked));
+        nextButton.connect('enter-notify-event', Lang.bind(this, this._onEnterNotify));
+        nextButton.connect('leave-notify-event', Lang.bind(this, this._onLeaveNotify));
+
+        this._next = new Gtk.Revealer({ transition_type: Gtk.RevealerTransitionType.CROSSFADE,
+                                        margin_right: _PREVIEW_NAVBAR_MARGIN,
+                                        halign: Gtk.Align.END,
+                                        valign: Gtk.Align.CENTER,
+                                        child: nextButton });
+        this._overlay.add_overlay(this._next);
+
+        this._prev.show_all();
+        this._next.show_all();
 
         this._overlay.connect('motion-notify-event', Lang.bind(this, this._onMotion));
-
     },
 
     _onEnterNotify: function() {
@@ -708,8 +712,8 @@ const PreviewNavButtons = new Lang.Class({
     },
 
     _autoHide: function() {
-        this._fadeOutButton(this.prev_widget);
-        this._fadeOutButton(this.next_widget);
+        this._fadeOutButton(this._prev);
+        this._fadeOutButton(this._next);
         this._autoHideId = 0;
         return false;
     },
@@ -729,21 +733,21 @@ const PreviewNavButtons = new Lang.Class({
 
     _updateVisibility: function() {
         if (!this._model || !this._visible) {
-            this._fadeOutButton(this.prev_widget);
-            this._fadeOutButton(this.next_widget);
+            this._fadeOutButton(this._prev);
+            this._fadeOutButton(this._next);
             return;
         }
 
         if (this._model.page > 0)
-            this._fadeInButton(this.prev_widget);
+            this._fadeInButton(this._prev);
         else
-            this._fadeOutButton(this.prev_widget);
+            this._fadeOutButton(this._prev);
 
         let doc = this._model.document;
         if (doc.get_n_pages() > this._model.page + 1)
-            this._fadeInButton(this.next_widget);
+            this._fadeInButton(this._next);
         else
-            this._fadeOutButton(this.next_widget);
+            this._fadeOutButton(this._next);
 
         if (!this._hover)
             this._queueAutoHide();
@@ -766,32 +770,24 @@ const PreviewNavButtons = new Lang.Class({
     _fadeInButton: function(widget) {
         if (!this._model)
             return;
-        widget.show_all();
-        Tweener.addTween(widget, { opacity: 1,
-                                   time: 0.30,
-                                   transition: 'easeOutQuad' });
+
+        widget.reveal_child = true;
     },
 
     _fadeOutButton: function(widget) {
-        Tweener.addTween(widget, { opacity: 0,
-                                   time: 0.30,
-                                   transition: 'easeOutQuad',
-                                   onComplete: function() {
-                                       widget.hide();
-                                   },
-                                   onCompleteScope: this });
+        widget.reveal_child = false;
     },
 
     show: function() {
         this._visible = true;
-        this._fadeInButton(this.prev_widget);
-        this._fadeInButton(this.next_widget);
+        this._fadeInButton(this._prev);
+        this._fadeInButton(this._next);
     },
 
     hide: function() {
         this._visible = false;
-        this._fadeOutButton(this.prev_widget);
-        this._fadeOutButton(this.next_widget);
+        this._fadeOutButton(this._prev);
+        this._fadeOutButton(this._next);
     }
 });
 
diff --git a/src/searchbar.js b/src/searchbar.js
index 6417e37..533e0b5 100644
--- a/src/searchbar.js
+++ b/src/searchbar.js
@@ -32,7 +32,6 @@ const Signals = imports.signals;
 
 const Application = imports.application;
 const Manager = imports.manager;
-const Tweener = imports.tweener.tweener;
 const Utils = imports.utils;
 
 const _SEARCH_ENTRY_TIMEOUT = 200;
diff --git a/src/selections.js b/src/selections.js
index 0dc0a5d..ff811ad 100644
--- a/src/selections.js
+++ b/src/selections.js
@@ -36,7 +36,6 @@ const Notifications = imports.notifications;
 const Properties = imports.properties;
 const Query = imports.query;
 const Sharing = imports.sharing;
-const Tweener = imports.tweener.tweener;
 const Utils = imports.utils;
 
 const Lang = imports.lang;
@@ -725,18 +724,14 @@ const SelectionToolbar = new Lang.Class({
         this._itemListeners = {};
         this._insideRefresh = false;
 
-        this.widget = new Gtk.Toolbar({ show_arrow: false,
-                                        halign: Gtk.Align.CENTER,
-                                        valign: Gtk.Align.END,
-                                        margin_bottom: 40,
-                                        icon_size: Gtk.IconSize.LARGE_TOOLBAR,
-                                        opacity: 0 });
-        this.widget.get_style_context().add_class('osd');
-        this.widget.set_size_request(_SELECTION_TOOLBAR_DEFAULT_WIDTH, -1);
+        this._toolbar = new Gtk.Toolbar({ show_arrow: false,
+                                          icon_size: Gtk.IconSize.LARGE_TOOLBAR });
+        this._toolbar.get_style_context().add_class('osd');
+        this._toolbar.set_size_request(_SELECTION_TOOLBAR_DEFAULT_WIDTH, -1);
 
         this._leftBox = new Gtk.Box({ orientation: Gtk.Orientation.HORIZONTAL });
         this._leftGroup = new Gtk.ToolItem({ child: this._leftBox });
-        this.widget.insert(this._leftGroup, -1);
+        this._toolbar.insert(this._leftGroup, -1);
 
         // open button
         this._toolbarOpen = new Gtk.Button({ child: new Gtk.Image ({ icon_name: 'folder-symbolic',
@@ -761,11 +756,11 @@ const SelectionToolbar = new Lang.Class({
         this._separator = new Gtk.SeparatorToolItem({ draw: false,
                                                       visible: true });
         this._separator.set_expand(true);
-        this.widget.insert(this._separator, -1);
+        this._toolbar.insert(this._separator, -1);
 
         this._rightBox = new Gtk.Box({ orientation: Gtk.Orientation.HORIZONTAL });
         this._rightGroup = new Gtk.ToolItem({ child: this._rightBox });
-        this.widget.insert(this._rightGroup, -1);
+        this._toolbar.insert(this._rightGroup, -1);
 
         // organize button
         this._toolbarCollection = new Gtk.Button({ child: new Gtk.Image ({ icon_name: 'list-add-symbolic',
@@ -785,11 +780,16 @@ const SelectionToolbar = new Lang.Class({
 
         // share button
            this._toolbarShare = new Gtk.Button({ child: new Gtk.Image ({ icon_name: 'emblem-shared-symbolic',
-                                                                      pixel_size: 16 })});
+                                                                          pixel_size: 16 })});
         this._toolbarShare.set_tooltip_text(_("Share"));
         this._rightBox.add(this._toolbarShare);
         this._toolbarShare.connect('clicked', Lang.bind(this, this._onToolbarShare));
 
+        this.widget = new Gtk.Revealer({ transition_type: Gtk.RevealerTransitionType.CROSSFADE,
+                                         halign: Gtk.Align.CENTER,
+                                         valign: Gtk.Align.END,
+                                         margin_bottom: 40,
+                                         child: this._toolbar });
         this.widget.show_all();
 
         Application.selectionController.connect('selection-mode-changed',
@@ -821,7 +821,7 @@ const SelectionToolbar = new Lang.Class({
     },
 
     _setItemListeners: function(selection) {
-        for (idx in this._itemListeners) {
+        for (let idx in this._itemListeners) {
             let doc = this._itemListeners[idx];
             doc.disconnect(idx);
             delete this._itemListeners[idx];
@@ -889,7 +889,7 @@ const SelectionToolbar = new Lang.Class({
     },
 
     _onToolbarCollection: function() {
-        let toplevel = this.widget.get_toplevel();
+        let toplevel = this._toolbar.get_toplevel();
         if (!toplevel.is_toplevel())
             return;
 
@@ -957,23 +957,14 @@ const SelectionToolbar = new Lang.Class({
             return;
 
         let doc = Application.documentManager.getItemById(selection[0]);
-        doc.print(this.widget.get_toplevel());
+        doc.print(this._toolbar.get_toplevel());
     },
 
     _fadeIn: function() {
-        this.widget.show();
-        Tweener.addTween(this.widget, { opacity: 1,
-                                        time: 0.30,
-                                        transition: 'easeOutQuad' });
+        this.widget.reveal_child = true;
     },
 
     _fadeOut: function() {
-        Tweener.addTween(this.widget, { opacity: 0,
-                                        time: 0.30,
-                                        transition: 'easeOutQuad',
-                                        onComplete: function() {
-                                            this.widget.hide();
-                                        },
-                                        onCompleteScope: this });
+        this.widget.reveal_child = false;
     }
 });


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