[gnome-documents/wip/abono/sort-by: 2/4] view: Update column for sorting when sort-by changes



commit af60fdcb4111e93f68d246a957437d7a23c69361
Author: Arnel A. Borja <arnelborja src gnome org>
Date:   Thu Oct 15 22:45:38 2015 +0200

    view: Update column for sorting when sort-by changes
    
    Update the column of the overview's model for sorting when
    the state of the sort-by action changes.

 src/view.js |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/src/view.js b/src/view.js
index 54c7683..969ee8e 100644
--- a/src/view.js
+++ b/src/view.js
@@ -81,8 +81,6 @@ const ViewModel = new Lang.Class({
               GObject.TYPE_LONG,
               GObject.TYPE_BOOLEAN,
               GObject.TYPE_UINT ]);
-        this.set_sort_column_id(Gd.MainColumns.MTIME,
-                                Gtk.SortType.DESCENDING);
 
         this._infoUpdatedIds = {};
         this._resetCountId = 0;
@@ -360,6 +358,10 @@ const ViewContainer = new Lang.Class({
             Lang.bind(this, this._updateTypeForSettings));
         this._updateTypeForSettings();
 
+        this._sortSettingsId = Application.application.connect('action-state-changed::sort-by',
+            Lang.bind(this, this._updateSortForSettings));
+        this._updateSortForSettings();
+
         // setup selection controller => view
         Application.selectionController.connect('selection-mode-changed',
             Lang.bind(this, this._onSelectionModeChanged));
@@ -418,6 +420,14 @@ const ViewContainer = new Lang.Class({
             this._addListRenderers();
     },
 
+    _updateSortForSettings: function() {
+        let sortColumn = Application.settings.get_enum('sort-by');
+        let sortType = sortColumn != Gd.MainColumns.MTIME ?
+            Gtk.SortType.ASCENDING : Gtk.SortType.DESCENDING;
+
+        this._model.set_sort_column_id(sortColumn, sortType);
+    },
+
     activateResult: function() {
         let doc = this._getFirstDocument();
         if (doc)


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