[gnome-documents] Use GdRevealer



commit fec7f7d1015f043f8dd7d7c0a32b017b68202155
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Fri Feb 8 11:30:33 2013 -0500

    Use GdRevealer

 configure.ac       |    1 +
 src/mainToolbar.js |   51 ++++++++++++++++++++++-----------------------------
 src/preview.js     |   15 ++++++---------
 src/searchbar.js   |   39 +++++++++++++--------------------------
 4 files changed, 42 insertions(+), 64 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 6e06897..3863e5b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -93,6 +93,7 @@ LIBGD_INIT([
   main-toolbar
   margin-container
   notification
+  revealer
   tagged-entry
   gir
 ])
diff --git a/src/mainToolbar.js b/src/mainToolbar.js
index f2ec8b3..531ab4a 100644
--- a/src/mainToolbar.js
+++ b/src/mainToolbar.js
@@ -43,20 +43,16 @@ const MainToolbar = new Lang.Class({
     _init: function() {
         this._model = null;
 
-        this.widget = new Gd.MainToolbar({ icon_size: Gtk.IconSize.MENU });
-        this.widget.get_style_context().add_class(Gtk.STYLE_CLASS_MENUBAR);
-        this.widget.show();
+        this.widget = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL });
+        this.actor = new GtkClutter.Actor({ contents: this.widget });
 
-        this.layout = new Clutter.BoxLayout({ vertical: true });
-        this.actor = new Clutter.Actor({ layout_manager: this.layout });
+        this.toolbar = new Gd.MainToolbar({ icon_size: Gtk.IconSize.MENU });
+        this.toolbar.get_style_context().add_class(Gtk.STYLE_CLASS_MENUBAR);
+        this.widget.add(this.toolbar);
+        this.toolbar.show();
 
-        this.toolbarActor = new GtkClutter.Actor({ contents: this.widget });
-
-        this.layout.pack(this.toolbarActor,
-                         false, true, false,
-                         Clutter.BoxAlignment.CENTER, Clutter.BoxAlignment.START);
-
-        this.createSearchbar();
+        this._searchbar = this.createSearchbar();
+        this.widget.add(this._searchbar.widget);
     },
 
     createSearchbar: function() {
@@ -70,7 +66,7 @@ const MainToolbar = new Lang.Class({
 
     addSearchButton: function() {
         let searchButton =
-            this.widget.add_toggle('edit-find-symbolic', _("Search"), false);
+            this.toolbar.add_toggle('edit-find-symbolic', _("Search"), false);
         searchButton.action_name = 'app.search';
     }
 });
@@ -183,22 +179,22 @@ const OverviewToolbar = new Lang.Class({
         if (detail)
             detail = '(' + detail + ')';
 
-        this.widget.set_labels(primary, detail);
+        this.toolbar.set_labels(primary, detail);
     },
 
     _populateForSelectionMode: function() {
-        this.widget.get_style_context().add_class('selection-mode');
-        this.widget.reset_style();
+        this.toolbar.get_style_context().add_class('selection-mode');
+        this.toolbar.reset_style();
 
         this.addSearchButton();
 
         let builder = new Gtk.Builder();
         builder.add_from_resource('/org/gnome/documents/selection-menu.ui');
         let selectionMenu = builder.get_object('selection-menu');
-        this.widget.set_labels_menu(selectionMenu);
+        this.toolbar.set_labels_menu(selectionMenu);
 
         let selectionButton =
-            this.widget.add_button(null, _("Done"), false);
+            this.toolbar.add_button(null, _("Done"), false);
         selectionButton.get_style_context().add_class('suggested-action');
         selectionButton.connect('clicked', Lang.bind(this,
             function() {
@@ -216,7 +212,7 @@ const OverviewToolbar = new Lang.Class({
 
         if (item && !this._collBackButton) {
             this._collBackButton =
-                this.widget.add_button('go-previous-symbolic', _("Back"), true);
+                this.toolbar.add_button('go-previous-symbolic', _("Back"), true);
             this._collBackButton.connect('clicked', Lang.bind(this,
                 function() {
                     Application.documentManager.activatePreviousCollection();
@@ -238,7 +234,7 @@ const OverviewToolbar = new Lang.Class({
         this.addSearchButton();
 
         let selectionButton =
-            this.widget.add_button('object-select-symbolic', _("Select Items"), false);
+            this.toolbar.add_button('object-select-symbolic', _("Select Items"), false);
         selectionButton.connect('clicked', Lang.bind(this,
             function() {
                 Application.selectionController.setSelectionMode(true);
@@ -252,7 +248,7 @@ const OverviewToolbar = new Lang.Class({
 
     _clearStateData: function() {
         this._collBackButton = null;
-        this.widget.set_labels_menu(null);
+        this.toolbar.set_labels_menu(null);
 
         if (this._collectionId != 0) {
             Application.collectionManager.disconnect(this._collectionId);
@@ -268,9 +264,9 @@ const OverviewToolbar = new Lang.Class({
     _clearToolbar: function() {
         this._clearStateData();
 
-        this.widget.get_style_context().remove_class('selection-mode');
-        this.widget.reset_style();
-        this.widget.clear();
+        this.toolbar.get_style_context().remove_class('selection-mode');
+        this.toolbar.reset_style();
+        this.toolbar.clear();
     },
 
     _resetToolbarMode: function() {
@@ -283,7 +279,7 @@ const OverviewToolbar = new Lang.Class({
             this._populateForOverview();
 
         this._setToolbarTitle();
-        this.widget.show_all();
+        this.toolbar.show_all();
 
         if (Application.searchController.getString() != '')
             Application.application.change_action_state('search', GLib.Variant.new('b', true));
@@ -295,9 +291,6 @@ const OverviewToolbar = new Lang.Class({
         this._viewLayout.add(dropdown.actor,
             Clutter.BinAlignment.CENTER, Clutter.BinAlignment.FIXED);
 
-        this._searchbar = new Searchbar.OverviewSearchbar(dropdown);
-        this.layout.pack_start = false;
-        this.layout.pack(this._searchbar.actor, false, true, false,
-                         Clutter.BoxAlignment.CENTER, Clutter.BoxAlignment.START);
+        return new Searchbar.OverviewSearchbar(dropdown);
     }
 });
diff --git a/src/preview.js b/src/preview.js
index f4246c8..bed45cb 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -498,10 +498,10 @@ const PreviewToolbar = new Lang.Class({
 
         // back button, on the left of the toolbar
         let iconName =
-            (this.widget.get_direction() == Gtk.TextDirection.RTL) ?
+            (this.toolbar.get_direction() == Gtk.TextDirection.RTL) ?
             'go-next-symbolic' : 'go-previous-symbolic';
         let backButton =
-            this.widget.add_button(iconName, _("Back"), true);
+            this.toolbar.add_button(iconName, _("Back"), true);
         backButton.connect('clicked', Lang.bind(this,
             function() {
                 Application.documentManager.setActiveItem(null);
@@ -512,12 +512,12 @@ const PreviewToolbar = new Lang.Class({
 
         // menu button, on the right of the toolbar
         let previewMenu = this._getPreviewMenu();
-        let menuButton = this.widget.add_menu('emblem-system-symbolic', null, false);
+        let menuButton = this.toolbar.add_menu('emblem-system-symbolic', null, false);
         menuButton.set_menu_model(previewMenu);
         menuButton.set_action_name('app.gear-menu');
 
         this._setToolbarTitle();
-        this.widget.show_all();
+        this.toolbar.show_all();
     },
 
     _getPreviewMenu: function() {
@@ -536,10 +536,7 @@ const PreviewToolbar = new Lang.Class({
     },
 
     createSearchbar: function() {
-        this._searchbar = new PreviewSearchbar(this._previewView);
-        this.layout.pack_start = false;
-        this.layout.pack(this._searchbar.actor, false, true, false,
-                         Clutter.BoxAlignment.CENTER, Clutter.BoxAlignment.START);
+        return new PreviewSearchbar(this._previewView);
     },
 
     _setToolbarTitle: function() {
@@ -549,7 +546,7 @@ const PreviewToolbar = new Lang.Class({
         if (doc)
             primary = doc.name;
 
-        this.widget.set_labels(primary, null);
+        this.toolbar.set_labels(primary, null);
     },
 
     setModel: function(model) {
diff --git a/src/searchbar.js b/src/searchbar.js
index ba7ad33..0625216 100644
--- a/src/searchbar.js
+++ b/src/searchbar.js
@@ -48,11 +48,11 @@ const Searchbar = new Lang.Class({
 
         this._in = false;
 
-        this.widget = new Gtk.Toolbar();
-        this.widget.get_style_context().add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR);
+        this.widget = new Gd.Revealer();
 
-        this.actor = new GtkClutter.Actor({ contents: this.widget,
-                                            height: 0 });
+        let toolbar = new Gtk.Toolbar();
+        toolbar.get_style_context().add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR);
+        this.widget.add(toolbar);
 
         // subclasses will create this._searchEntry and this._searchContainer
         // GtkWidgets
@@ -61,7 +61,7 @@ const Searchbar = new Lang.Class({
         let item = new Gtk.ToolItem();
         item.set_expand(true);
         item.add(this._searchContainer);
-        this.widget.insert(item, 0);
+        toolbar.insert(item, 0);
 
         this._searchEntry.connect('key-press-event', Lang.bind(this,
             function(widget, event) {
@@ -196,31 +196,18 @@ const Searchbar = new Lang.Class({
 
     show: function() {
         let eventDevice = Gtk.get_current_event_device();
-        this.widget.show_all();
+        this.widget.set_revealed(true);
+        this._in = true;
 
-        Tweener.addTween(this.actor, { height: this.widget.get_preferred_height()[1],
-                                       time: 0.20,
-                                       transition: 'easeOutQuad',
-                                       onComplete: function() {
-                                           this._in = true;
-                                           if (eventDevice)
-                                               Gd.entry_focus_hack(this._searchEntry, eventDevice);
-                                       },
-                                       onCompleteScope: this });
+        if (eventDevice)
+            Gd.entry_focus_hack(this._searchEntry, eventDevice);
     },
 
     hide: function() {
-        Tweener.addTween(this.actor, { height: 0,
-                                       time: 0.20,
-                                       transition: 'easeOutQuad',
-                                       onComplete: function() {
-                                           this.widget.hide();
-                                           this._in = false;
-
-                                           // clear all the search properties when hiding the entry
-                                           this._searchEntry.set_text('');
-                                       },
-                                       onCompleteScope: this });
+        this._in = false;
+        this.widget.set_revealed(false);
+        // clear all the search properties when hiding the entry
+        this._searchEntry.set_text('');
     }
 });
 


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