[gnome-documents] view: Update column for sorting when sort-by changes
- From: Alessandro Bono <abono src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] view: Update column for sorting when sort-by changes
- Date: Wed, 25 Nov 2015 20:55:05 +0000 (UTC)
commit b739e1bed52bd3f3dc988e2e975e4c170eaaca15
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.
https://bugzilla.gnome.org/show_bug.cgi?id=683563
src/view.js | 29 +++++++++++++++++++++++++++--
1 files changed, 27 insertions(+), 2 deletions(-)
---
diff --git a/src/view.js b/src/view.js
index 54c7683..9eecde6 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,29 @@ const ViewContainer = new Lang.Class({
this._addListRenderers();
},
+ _updateSortForSettings: function() {
+ let sortBy = Application.settings.get_enum('sort-by');
+ let sortType;
+
+ switch (sortBy) {
+ case Gd.MainColumns.PRIMARY_TEXT:
+ sortType = Gtk.SortType.ASCENDING;
+ break;
+ case Gd.MainColumns.SECONDARY_TEXT:
+ sortType = Gtk.SortType.ASCENDING;
+ break;
+ case Gd.MainColumns.MTIME:
+ sortType = Gtk.SortType.DESCENDING;
+ break;
+ default:
+ sortBy = Gd.MainColumns.MTIME;
+ sortType = Gtk.SortType.DESCENDING;
+ break;
+ }
+
+ this._model.set_sort_column_id(sortBy, sortType);
+ },
+
activateResult: function() {
let doc = this._getFirstDocument();
if (doc)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]