[gnome-documents/wip/abono/sort-by: 1/4] application: Add new action sort-by



commit f88ebbab57fc07dcf42d6ccb2c7d6b9343058312
Author: Alessandro Bono <shadow openaliasbox org>
Date:   Thu Oct 15 21:14:43 2015 +0200

    application: Add new action sort-by
    
    Add a new action and setting "sort-by" which changes the column used
    for sorting the documents in the overview.

 data/Makefile.am                     |    3 ++-
 data/org.gnome.books.gschema.xml     |    5 +++++
 data/org.gnome.documents.gschema.xml |    5 +++++
 src/application.js                   |   20 ++++++++++++++++++++
 4 files changed, 32 insertions(+), 1 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index 06d66b9..85f3ae6 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -39,7 +39,8 @@ check-local: org.gnome.Documents.desktop org.gnome.Books.desktop
 
 gsettings_ENUM_NAMESPACE = org.gnome.Documents
 gsettings_ENUM_FILES = \
-    $(top_srcdir)/libgd/libgd/gd-main-view.h
+    $(top_srcdir)/libgd/libgd/gd-main-view.h \
+    $(top_srcdir)/libgd/libgd/gd-main-view-generic.h
 
 gsettings_SCHEMAS = org.gnome.documents.gschema.xml org.gnome.books.gschema.xml
 .PRECIOUS: $(gsettings_SCHEMAS)
diff --git a/data/org.gnome.books.gschema.xml b/data/org.gnome.books.gschema.xml
index d8f071c..6caf0ba 100644
--- a/data/org.gnome.books.gschema.xml
+++ b/data/org.gnome.books.gschema.xml
@@ -5,6 +5,11 @@
       <summary>View as</summary>
       <description>View as type</description>
     </key>
+    <key name="sort-by" enum="org.gnome.Documents.GdMainColumns">
+      <default>'mtime'</default>
+      <summary>Sort by</summary>
+      <description>Sort by type</description>
+    </key>
     <key name="window-size" type="ai">
       <default>[768, 600]</default>
       <summary>Window size</summary>
diff --git a/data/org.gnome.documents.gschema.xml b/data/org.gnome.documents.gschema.xml
index e4c8a72..83f24b6 100644
--- a/data/org.gnome.documents.gschema.xml
+++ b/data/org.gnome.documents.gschema.xml
@@ -5,6 +5,11 @@
       <summary>View as</summary>
       <description>View as type</description>
     </key>
+    <key name="sort-by" enum="org.gnome.Documents.GdMainColumns">
+      <default>'mtime'</default>
+      <summary>Sort by</summary>
+      <description>Sort by type</description>
+    </key>
     <key name="window-size" type="ai">
       <default>[768, 600]</default>
       <summary>Window size</summary>
diff --git a/src/application.js b/src/application.js
index 785fb18..8a792ea 100644
--- a/src/application.js
+++ b/src/application.js
@@ -185,6 +185,15 @@ const Application = new Lang.Class({
             }));
     },
 
+    _sortByCreateHook: function(action) {
+        settings.connect('changed::sort-by', Lang.bind(this,
+            function() {
+                let state = settings.get_value('sort-by');
+                if (state.get_string()[0] != action.state.get_string()[0])
+                    action.state = state;
+            }));
+    },
+
     _nightModeCreateHook: function(action) {
         settings.connect('changed::night-mode', Lang.bind(this,
             function() {
@@ -233,6 +242,11 @@ const Application = new Lang.Class({
             settings.set_value('view-as', parameter);
     },
 
+    _onActionSortBy: function(action, parameter) {
+        if (parameter.get_string()[0] != action.state.get_string()[0])
+            settings.set_value('sort-by', parameter);
+    },
+
     _onActionOpenCurrent: function() {
         let doc = documentManager.getActiveItem();
         if (doc)
@@ -549,6 +563,12 @@ const Application = new Lang.Class({
               window_modes: [WindowMode.WindowMode.COLLECTIONS,
                              WindowMode.WindowMode.DOCUMENTS,
                              WindowMode.WindowMode.SEARCH] },
+            { name: 'sort-by',
+              callback: this._onActionSortBy,
+              create_hook: this._sortByCreateHook,
+              parameter_type: 's',
+              state: settings.get_value('sort-by'),
+              window_mode: WindowMode.WindowMode.OVERVIEW },
             { name: 'open-current',
               callback: this._onActionOpenCurrent,
               window_mode: WindowMode.WindowMode.PREVIEW },


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