[gnome-documents] sidebar: remove the sidebar



commit 63506b10ffa87b316aa9d6412cbd733b8affff26
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed Nov 9 11:57:55 2011 -0500

    sidebar: remove the sidebar
    
    As for the latest iterations of the designs, we now want to be
    sidebar-less.
    The sidebar currently controls categories and collections: collections
    will come back in the next commit as regular view items, while
    categories for now have been added to the search bar dropdown, waiting
    for a better place.

 src/Makefile-js.am       |    2 -
 src/application.js       |    6 +-
 src/categories.js        |  103 ----------
 src/documents.js         |    8 +-
 src/embed.js             |   45 +----
 src/global.js            |    3 +-
 src/lib/gd-utils.c       |   34 ----
 src/lib/gd-utils.h       |    9 -
 src/mainToolbar.js       |   22 +-
 src/mainWindow.js        |   33 +---
 src/manager.js           |   10 +
 src/query.js             |    5 +-
 src/searchbar.js         |   76 ++++++++
 src/sidebar.js           |  479 ----------------------------------------------
 src/trackerController.js |    4 +-
 15 files changed, 122 insertions(+), 717 deletions(-)
---
diff --git a/src/Makefile-js.am b/src/Makefile-js.am
index 382511a..a3c2587 100644
--- a/src/Makefile-js.am
+++ b/src/Makefile-js.am
@@ -1,7 +1,6 @@
 jsdir = $(pkgdatadir)/js/
 dist_js_DATA = \
     application.js \
-    categories.js \
     changeMonitor.js \
     collections.js \
     documents.js \
@@ -22,7 +21,6 @@ dist_js_DATA = \
     query.js \
     searchbar.js \
     selections.js \
-    sidebar.js \
     sources.js \
     spinnerBox.js \
     trackerController.js \
diff --git a/src/application.js b/src/application.js
index 196d6eb..28cd5bc 100644
--- a/src/application.js
+++ b/src/application.js
@@ -32,7 +32,6 @@ const Gtk = imports.gi.Gtk;
 const GLib = imports.gi.GLib;
 const Tracker = imports.gi.Tracker;
 
-const Categories = imports.categories;
 const ChangeMonitor = imports.changeMonitor;
 const Collections = imports.collections;
 const Documents = imports.documents;
@@ -41,12 +40,12 @@ const Format = imports.format;
 const Global = imports.global;
 const Main = imports.main;
 const MainWindow = imports.mainWindow;
+const Manager = imports.manager;
 const OffsetController = imports.offsetController;
 const Path = imports.path;
 const Query = imports.query;
 const Searchbar = imports.searchbar;
 const Selections = imports.selections;
-const Sidebar = imports.sidebar;
 const Sources = imports.sources;
 const TrackerController = imports.trackerController;
 const Tweener = imports.util.tweener;
@@ -120,7 +119,6 @@ Application.prototype = {
         Global.settings = new Gio.Settings({ schema: 'org.gnome.documents' });
         Global.offsetController = new OffsetController.OffsetController();
         Global.searchController = new Searchbar.SearchController();
-        Global.categoryManager = new Categories.CategoryManager();
         Global.errorHandler = new Error.ErrorHandler();
 
         // connect to tracker
@@ -144,12 +142,12 @@ Application.prototype = {
 
                         Global.connectionQueue = new TrackerController.TrackerConnectionQueue();
                         Global.sourceManager = new Sources.SourceManager();
+                        Global.searchCategoryManager = new Searchbar.SearchCategoryManager();
                         Global.searchMatchManager = new Searchbar.SearchMatchManager();
                         Global.searchTypeManager = new Searchbar.SearchTypeManager();
                         Global.queryBuilder = new Query.QueryBuilder();
                         Global.changeMonitor = new ChangeMonitor.TrackerChangeMonitor();
                         Global.collectionManager = new Collections.CollectionManager();
-                        Global.sidebarController = new Sidebar.SidebarController();
                         Global.documentManager = new Documents.DocumentManager();
                         Global.trackerController = new TrackerController.TrackerController();
                         Global.selectionController = new Selections.SelectionController();
diff --git a/src/documents.js b/src/documents.js
index f10bee5..526c6de 100644
--- a/src/documents.js
+++ b/src/documents.js
@@ -75,8 +75,8 @@ DocCommon.prototype = {
             Global.settings.connect('changed::list-view',
                                     Lang.bind(this, this.refreshIcon));
         this._filterId =
-            Global.sidebarController.connect('changed',
-                                             Lang.bind(this, this.refreshIcon));
+            Global.searchCategoryManager.connect('active-changed',
+                                                 Lang.bind(this, this.refreshIcon));
     },
 
     refresh: function() {
@@ -182,7 +182,7 @@ DocCommon.prototype = {
         let pixbuf = this.pixbuf;
         let activeItem;
 
-        activeItem = Global.sidebarController.getWhereItem();
+        activeItem = Global.searchCategoryManager.getActiveItem();
 
         if (this.favorite &&
             (!activeItem ||
@@ -229,7 +229,7 @@ DocCommon.prototype = {
 
     destroy: function() {
         Global.settings.disconnect(this._refreshIconId);
-        Global.sidebarController.disconnect(this._filterId);
+        Global.searchCategoryManager.disconnect(this._filterId);
     },
 
     open: function(screen, timestamp) {
diff --git a/src/embed.js b/src/embed.js
index e3e290d..3a1441f 100644
--- a/src/embed.js
+++ b/src/embed.js
@@ -171,50 +171,19 @@ ViewEmbed.prototype  = {
     },
 
     _windowModeChangeFlash: function() {
-        let visible = Global.sidebarController.getSidebarVisible();
-
-        // if the sidebar is visible, wait until it completed fading in before
-        // putting back the view
-        if (visible) {
-            // follow the movement of the sidebar fading the preview to white
-            this._background.raise_top();
-            Tweener.addTween(this._background,
-                { opacity: 255,
-                  time: 0.20,
-                  transition: 'easeOutQuad',
-                  onComplete: function() {
-                      this._moveOutBackground();
-                  },
-                  onCompleteScope: this });
-        } else {
-            // fade from white when returning to the view anyway
-            this._background.raise_top();
-            this._background.opacity = 255;
-            this._moveOutBackground();
-        }
+        // fade from white when returning to the view anyway
+        this._background.raise_top();
+        this._background.opacity = 255;
+        this._moveOutBackground();
     },
 
     _onWindowModeChanged: function() {
         let mode = Global.modeController.getWindowMode();
 
-        if (mode == WindowMode.WindowMode.OVERVIEW) {
-            let visible = Global.sidebarController.getSidebarVisible();
-
-            // if the sidebar is visible, wait until it completed fading in before
-            // putting back the view
-            if (visible) {
-                let sidebarInId =
-                    Global.sidebarController.connect('sidebar-in-changed', Lang.bind(this,
-                        function() {
-                            Global.sidebarController.disconnect(sidebarInId);
-                            this._prepareForOverview();
-                        }));
-            } else {
-                this._prepareForOverview();
-            }
-        } else {
+        if (mode == WindowMode.WindowMode.OVERVIEW)
+            this._prepareForOverview();
+        else
             this._prepareForPreview();
-        }
 
         this._windowModeChangeFlash();
     },
diff --git a/src/global.js b/src/global.js
index 52053dd..b3d2659 100644
--- a/src/global.js
+++ b/src/global.js
@@ -20,7 +20,6 @@
  */
 
 let application = null;
-let categoryManager = null;
 let connection = null;
 let connectionQueue = null;
 let documentManager = null;
@@ -29,10 +28,10 @@ let goaClient = null;
 let modeController = null;
 let offsetController = null;
 let queryBuilder = null;
+let searchCategoryManager = null;
 let searchController = null;
 let searchMatchManager = null;
 let searchTypeManager = null;
-let sidebarController = null;
 let selectionController = null;
 let settings = null;
 let stage = null;
diff --git a/src/lib/gd-utils.c b/src/lib/gd-utils.c
index 9734843..65285e1 100644
--- a/src/lib/gd-utils.c
+++ b/src/lib/gd-utils.c
@@ -92,40 +92,6 @@ gd_item_store_set (GtkListStore *store,
                       -1);
 }
 
-/**
- * gd_create_sidebar_store:
- *
- * Returns: (transfer full):
- */
-GtkListStore *
-gd_create_sidebar_store (void)
-{
-  return gtk_list_store_new (5,
-                             G_TYPE_STRING, // ID
-                             G_TYPE_STRING, // NAME
-                             G_TYPE_STRING, // ICON
-                             G_TYPE_STRING, // HEADING_TEXT
-                             G_TYPE_INT); // SECTION
-}
-
-void
-gd_sidebar_store_set (GtkListStore *store,
-                      GtkTreeIter *iter,
-                      const gchar *id,
-                      const gchar *name,
-                      const gchar *icon_name,
-                      const gchar *heading_text,
-                      gint section)
-{
-  gtk_list_store_set (store, iter,
-                      0, id,
-                      1, name,
-                      2, icon_name,
-                      3, heading_text,
-                      4, section,
-                      -1);
-}
-
 #define ATTRIBUTES_FOR_THUMBNAIL \
   G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE"," \
   G_FILE_ATTRIBUTE_TIME_MODIFIED
diff --git a/src/lib/gd-utils.h b/src/lib/gd-utils.h
index b7f9bd4..df9f89d 100644
--- a/src/lib/gd-utils.h
+++ b/src/lib/gd-utils.h
@@ -40,15 +40,6 @@ void gd_item_store_set (GtkListStore *store,
                         const gchar *name,
                         const gchar *heading_text);
 
-GtkListStore * gd_create_sidebar_store (void);
-void gd_sidebar_store_set (GtkListStore *store,
-                           GtkTreeIter *iter,
-                           const gchar *id,
-                           const gchar *name,
-                           const gchar *icon_name,
-                           const gchar *heading_text,
-                           gint section);
-
 void gd_queue_thumbnail_job_for_file_async (GFile *file,
                                             GAsyncReadyCallback callback,
                                             gpointer user_data);
diff --git a/src/mainToolbar.js b/src/mainToolbar.js
index 56607a3..bc4a741 100644
--- a/src/mainToolbar.js
+++ b/src/mainToolbar.js
@@ -40,7 +40,7 @@ function MainToolbar() {
 MainToolbar.prototype = {
     _init: function() {
         this._model = null;
-        this._whereId = 0;
+        this._collectionId = 0;
         this._selectionChangedId = 0;
 
         this.widget = new Gtk.Toolbar({ icon_size: Gtk.IconSize.MENU });
@@ -62,9 +62,9 @@ MainToolbar.prototype = {
     _clearToolbar: function() {
         this._model = null;
 
-        if (this._whereId != 0) {
-            Global.sidebarController.disconnect(this._whereId);
-            this._whereId = 0;
+        if (this._collectionId != 0) {
+            Global.collectionManager.disconnect(this._collectionId);
+            this._collectionId = 0;
         }
 
         if (this._selectionChangedId != 0) {
@@ -167,11 +167,11 @@ MainToolbar.prototype = {
         // set initial state
         item3.set_active(Global.selectionController.getSelectionMode());
 
-        // connect to sidebar filter changes while in this mode
-        this._whereId =
-            Global.sidebarController.connect('changed',
-                                             Lang.bind(this, this._onSideFilterChanged));
-        this._onSideFilterChanged();
+        // connect to active collection changes while in this mode
+        this._collectionId =
+            Global.collectionManager.connect('active-changed',
+                                             Lang.bind(this, this._onActiveCollection));
+        this._onActiveCollection();
 
         this.widget.show_all();
     },
@@ -239,8 +239,8 @@ MainToolbar.prototype = {
         }
     },
 
-    _onSideFilterChanged: function() {
-        let item = Global.sidebarController.getWhereItem();
+    _onActiveCollection: function() {
+        let item = Global.collectionManager.getActiveItem();
 
         if (!item)
             return;
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 75d1369..2a4eaa4 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -32,7 +32,6 @@ const Embed = imports.embed;
 const Global = imports.global;
 const Searchbar = imports.searchbar;
 const Selections = imports.selections;
-const Sidebar = imports.sidebar;
 const Utils = imports.utils;
 const WindowMode = imports.windowMode;
 
@@ -108,34 +107,18 @@ MainWindow.prototype = {
         this._clutterBox.add_actor(this._searchbar.actor);
         this._clutterBoxLayout.set_fill(this._searchbar.actor, true, false);
 
-        // second child: an horizontal layout box which will
-        // contain the sidebar and the embed
-        this._horizLayout = new Clutter.BoxLayout();
-        this._horizBox = new Clutter.Box({ layout_manager: this._horizLayout });
-        this._clutterBox.add_actor(this._horizBox);
-        this._clutterBoxLayout.set_expand(this._horizBox, true);
-        this._clutterBoxLayout.set_fill(this._horizBox, true, true);
-
-        // create the sidebar and pack it as a first child into the
-        // horizontal box
-        this._sidebar = new Sidebar.Sidebar();
-        this._horizBox.add_actor(this._sidebar.actor);
-        this._horizLayout.set_fill(this._sidebar.actor, false, true);
-
-        // create the embed and pack it as the second child into
-        // the horizontal box
         this._embed = new Embed.ViewEmbed();
-        this._horizBox.add_actor(this._embed.actor);
-        this._horizLayout.set_expand(this._embed.actor, true);
-        this._horizLayout.set_fill(this._embed.actor, true, true);
+        this._clutterBox.add_actor(this._embed.actor);
+        this._clutterBoxLayout.set_expand(this._embed.actor, true);
+        this._clutterBoxLayout.set_fill(this._embed.actor, true, true);
 
         // create the dropdown for the search bar, it's hidden by default
         this._dropdownBox = new Searchbar.Dropdown();
         this._dropdownBox.actor.add_constraint(
-            new Clutter.BindConstraint({ source: this._horizBox,
+            new Clutter.BindConstraint({ source: this._embed.actor,
                                          coordinate: Clutter.BindCoordinate.Y }));
         this._dropdownBox.actor.add_constraint(
-            new Clutter.AlignConstraint({ source: this._horizBox,
+            new Clutter.AlignConstraint({ source: this._embed.actor,
                                           align_axis: Clutter.AlignAxis.X_AXIS,
                                           factor: 0.50 }));
         Global.stage.add_actor(this._dropdownBox.actor);
@@ -255,12 +238,6 @@ MainWindow.prototype = {
     _handleKeyOverview: function(event) {
         let keyval = event.get_keyval()[1];
 
-        if (keyval == Gdk.KEY_F9) {
-            let visible = Global.sidebarController.getSidebarVisible();
-            Global.sidebarController.setSidebarVisible(!visible);
-            return true;
-        }
-
         if (Utils.isSearchEvent(event)) {
             let visible = Global.searchController.getSearchVisible();
             Global.searchController.setSearchVisible(!visible);
diff --git a/src/manager.js b/src/manager.js
index 76450cf..9c84eb0 100644
--- a/src/manager.js
+++ b/src/manager.js
@@ -120,6 +120,16 @@ BaseManager.prototype = {
         return retval;
     },
 
+    getWhere: function() {
+        let item = this.getActiveItem();
+        let retval = '';
+
+        if (item && item.getWhere)
+            retval = item.getWhere();
+
+        return retval;
+    },
+
     _getAllFilter: function() {
         let filter = '';
         let first = true;
diff --git a/src/query.js b/src/query.js
index 0cabe0f..fb44b90 100644
--- a/src/query.js
+++ b/src/query.js
@@ -112,7 +112,7 @@ QueryBuilder.prototype = {
         sparql += ' && ';
         sparql += Global.sourceManager.getFilter();
         sparql += ' && ';
-        sparql += Global.categoryManager.getFilter();
+        sparql += Global.searchCategoryManager.getFilter();
         sparql += ' && ';
         sparql += Global.searchTypeManager.getFilter();
 
@@ -136,7 +136,8 @@ QueryBuilder.prototype = {
 
         if (global) {
             globalSparql +=
-                Global.sidebarController.getWhere() +
+                Global.searchCategoryManager.getWhere() +
+                Global.collectionManager.getWhere() +
                 this._buildFilterString() +
                 ' } ' +
                 'ORDER BY DESC (?mtime)' +
diff --git a/src/searchbar.js b/src/searchbar.js
index 40809ca..2a145d4 100644
--- a/src/searchbar.js
+++ b/src/searchbar.js
@@ -37,6 +37,80 @@ const Utils = imports.utils;
 
 const _SEARCH_ENTRY_TIMEOUT = 200;
 
+const SearchCategoryStock = {
+    ALL: 'all',
+    FAVORITES: 'favorites',
+    SHARED: 'shared',
+    PRIVATE: 'private'
+};
+
+function SearchCategory(params) {
+    this._init(params);
+};
+
+SearchCategory.prototype = {
+    _init: function(params) {
+        this.id = params.id;
+        this.name = params.name;
+        this.icon = params.icon;
+    },
+
+    getWhere: function() {
+        if (this.id == SearchCategoryStock.FAVORITES)
+            return '{ ?urn nao:hasTag nao:predefined-tag-favorite }';
+
+        // require to have a contributor, and creator, and they should be different
+        if (this.id == SearchCategoryStock.SHARED)
+            return '{ ?urn nco:contributor ?contributor . ?urn nco:creator ?creator FILTER (?contributor != ?creator ) }';
+
+        return '';
+    },
+
+    getFilter: function() {
+        // require to be not local
+        if (this.id == SearchCategoryStock.SHARED)
+            return Global.queryBuilder.buildFilterNotLocal();
+
+        return '(true)';
+    }
+};
+
+function SearchCategoryManager() {
+    this._init();
+};
+
+SearchCategoryManager.prototype = {
+    __proto__: Manager.BaseManager.prototype,
+
+    _init: function() {
+        Manager.BaseManager.prototype._init.call(this, _("Category"));
+
+        let category, recent;
+        // Translators: this refers to new and recent documents
+        recent = new SearchCategory({ id: SearchCategoryStock.ALL,
+                                      name: _("All"),
+                                      icon: '' });
+        this.addItem(recent);
+
+        // Translators: this refers to favorite documents
+        category = new SearchCategory({ id: SearchCategoryStock.FAVORITES,
+                                        name: _("Favorites"),
+                                        icon: 'emblem-favorite-symbolic' });
+        this.addItem(category);
+        // Translators: this refers to shared documents
+        category = new SearchCategory({ id: SearchCategoryStock.SHARED,
+                                        name: _("Shared with you"),
+                                        icon: 'emblem-shared-symbolic' });
+        this.addItem(category);
+
+        // Private category: currently unimplemented
+        // category = new SearchCategory(SearchCategoryStock.PRIVATE, _("Private"), 'channel-secure-symbolic');
+        // this._categories[category.id] = category;
+
+        this.setActiveItem(recent);
+    }
+};
+
 function SearchType(params) {
     this._init(params);
 }
@@ -220,6 +294,7 @@ Dropdown.prototype = {
         this._sourceView = new Manager.BaseView(Global.sourceManager);
         this._typeView = new Manager.BaseView(Global.searchTypeManager);
         this._matchView = new Manager.BaseView(Global.searchMatchManager);
+        this._categoryView = new Manager.BaseView(Global.searchCategoryManager);
 
         this.widget = new Gtk.Frame({ shadow_type: Gtk.ShadowType.IN });
         this.actor = new GtkClutter.Actor({ contents: this.widget,
@@ -233,6 +308,7 @@ Dropdown.prototype = {
         this._grid.add(this._sourceView.widget);
         this._grid.add(this._typeView.widget);
         this._grid.add(this._matchView.widget);
+        this._grid.add(this._categoryView.widget);
 
         this.widget.show_all();
 
diff --git a/src/trackerController.js b/src/trackerController.js
index 1549dd1..b9802f5 100644
--- a/src/trackerController.js
+++ b/src/trackerController.js
@@ -99,8 +99,10 @@ TrackerController.prototype = {
         this._offsetController.connect('offset-changed',
                                        Lang.bind(this, this._performCurrentQuery));
 
-        Global.sidebarController.connect('changed',
+        Global.collectionManager.connect('active-changed',
                                          Lang.bind(this, this._refresh));
+        Global.searchCategoryManager.connect('active-changed',
+                                             Lang.bind(this, this._refresh));
         Global.searchController.connect('search-string-changed',
                                         Lang.bind(this, this._onSearchRefresh));
         Global.searchMatchManager.connect('active-changed',



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