After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 683563 - Add the ability to change the sort order of the view
Add the ability to change the sort order of the view
Status: RESOLVED FIXED
Product: gnome-documents
Classification: Core
Component: general
unspecified
Other All
: Normal enhancement
: ---
Assigned To: GNOME documents maintainer(s)
GNOME documents maintainer(s)
ready
Depends on:
Blocks:
 
 
Reported: 2012-09-07 11:08 UTC by Giovanni Campagna
Modified: 2015-12-16 18:31 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
mockup (6.06 KB, image/png)
2014-03-28 13:51 UTC, Allan Day
  Details
application: Add new action sort-by (3.35 KB, patch)
2014-04-03 10:16 UTC, Arnel Borja
committed Details | Review
mainToolbar: Move "view as" buttons into a popover (6.86 KB, patch)
2014-04-03 10:17 UTC, Arnel Borja
none Details | Review
mainToolbar: Add sort buttons to view popover (5.12 KB, patch)
2014-04-03 10:18 UTC, Arnel Borja
none Details | Review
view: Update column for sorting when sort-by changes (2.00 KB, patch)
2014-04-03 10:19 UTC, Arnel Borja
none Details | Review
mainToolbar: Move "view as" buttons into a popover (6.86 KB, patch)
2014-04-03 10:59 UTC, Arnel Borja
none Details | Review
application: Add new action sort-by (940 bytes, patch)
2015-11-02 18:11 UTC, Debarshi Ray
none Details | Review
application: Add new action sort-by (3.62 KB, patch)
2015-11-02 18:16 UTC, Debarshi Ray
committed Details | Review
Update gschema for Books (949 bytes, patch)
2015-11-11 10:45 UTC, Alessandro Bono
committed Details | Review
mainToolbar: Move "view as" buttons into a popover (8.11 KB, patch)
2015-11-11 10:47 UTC, Alessandro Bono
none Details | Review
view: Update column for sorting when sort-by changes (1.94 KB, patch)
2015-11-11 10:47 UTC, Alessandro Bono
none Details | Review
query, view: Change the ORDER BY clause (6.01 KB, patch)
2015-11-11 10:49 UTC, Alessandro Bono
none Details | Review
view-menu: Add sort options in the popover (3.07 KB, patch)
2015-11-11 10:49 UTC, Alessandro Bono
none Details | Review
mainToolbar: Move "view as" buttons into a popover (8.54 KB, patch)
2015-11-17 14:50 UTC, Alessandro Bono
committed Details | Review
view: Update column for sorting when sort-by changes (2.31 KB, patch)
2015-11-17 14:50 UTC, Alessandro Bono
none Details | Review
query, view: Change the ORDER BY clause (6.01 KB, patch)
2015-11-17 14:51 UTC, Alessandro Bono
none Details | Review
view-menu: Add sort options in the popover (3.74 KB, patch)
2015-11-17 14:51 UTC, Alessandro Bono
committed Details | Review
view: Update column for sorting when sort-by changes (2.34 KB, patch)
2015-11-25 20:51 UTC, Alessandro Bono
committed Details | Review
query, view: Change the ORDER BY clause (7.01 KB, patch)
2015-11-25 22:14 UTC, Alessandro Bono
committed Details | Review

Description Giovanni Campagna 2012-09-07 11:08:20 UTC
In some occasion, in particular when dealing with sets of documents like course slides, the documents in a collection are in a strict logical order, and the name usually reflects that.
On the other hand, in documents by default they're sorted by modified date, so the order is apparently random. Even if the order is consistent, it's very likely to be reversed: in the example case of course slides, documents from the last lesson are shown on the top.

I'm not sure what the best UI for this would be. It could be a button like in Files, or a submenu of the app menu, together with View As.
Comment 1 Allan Day 2014-03-28 13:51:36 UTC
Created attachment 273172 [details]
mockup

I think we could extend the existing view button to display a popover. This would contain controls for changing between list/grid, and for changing the sort order.

A mockup is attached.
Comment 2 Arnel Borja 2014-03-31 17:08:16 UTC
Does this require that the sort order to be persistent? Or it should be by modified date by default at startup?
Comment 3 Debarshi Ray 2014-03-31 17:34:08 UTC
Need not be persistent in the first attempt. We can make it persistent after some iterations, if need be.
Comment 4 Arnel Borja 2014-04-03 10:15:13 UTC
I tried working on this by adding a sort-by action like how view-as is implemented. I used GdMainColumns as the enum, which contains more elements than the three sort orders, and added a setting for that.

I'll attach the patches that I made.
Comment 5 Arnel Borja 2014-04-03 10:16:50 UTC
Created attachment 273511 [details] [review]
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.
Comment 6 Arnel Borja 2014-04-03 10:17:33 UTC
Created attachment 273512 [details] [review]
mainToolbar: Move "view as" buttons into a popover
Comment 7 Arnel Borja 2014-04-03 10:18:08 UTC
Created attachment 273513 [details] [review]
mainToolbar: Add sort buttons to view popover

Add the buttons for sorting the documents in the overview, and update them when the sort-by setting changes.
Comment 8 Arnel Borja 2014-04-03 10:19:47 UTC
Created attachment 273514 [details] [review]
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.
Comment 9 Arnel Borja 2014-04-03 10:59:33 UTC
Created attachment 273518 [details] [review]
mainToolbar: Move "view as" buttons into a popover

There's a typo in the second patch. Here's the replacement.
Comment 10 Debarshi Ray 2014-04-03 13:00:35 UTC
Review of attachment 273514 [details] [review]:

I think we should also change the ORDER BY clause in the SPARQL query. Otherwise the order in which the items are loaded in batches will still be in the descending order of their mtime.
Comment 11 Arnel Borja 2014-05-02 10:42:39 UTC
I'm busy during the GNOME 3.14 cycle, so if someone wants to take over fixing the bug, please do so :)
Comment 12 Debarshi Ray 2015-11-02 18:11:56 UTC
Created attachment 314677 [details] [review]
application: Add new action sort-by

Pushed, after Alessandro rebased it on top of current master.
Comment 13 Debarshi Ray 2015-11-02 18:16:34 UTC
Created attachment 314678 [details] [review]
application: Add new action sort-by

Sorry, wrong patch.
Comment 14 Alessandro Bono 2015-11-11 10:45:58 UTC
Created attachment 315241 [details] [review]
Update gschema for Books
Comment 15 Alessandro Bono 2015-11-11 10:47:05 UTC
Created attachment 315242 [details] [review]
mainToolbar: Move "view as" buttons into a popover
Comment 16 Alessandro Bono 2015-11-11 10:47:31 UTC
Created attachment 315243 [details] [review]
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.
Comment 17 Alessandro Bono 2015-11-11 10:49:07 UTC
Created attachment 315245 [details] [review]
query, view: Change the ORDER BY clause
Comment 18 Alessandro Bono 2015-11-11 10:49:39 UTC
Created attachment 315246 [details] [review]
view-menu: Add sort options in the popover
Comment 19 Debarshi Ray 2015-11-13 15:23:28 UTC
Review of attachment 315241 [details] [review]:

Good catch.
Comment 20 Debarshi Ray 2015-11-13 16:23:30 UTC
Review of attachment 315242 [details] [review]:

Thanks, Alessandro. Please push after making this minor change.

::: src/mainToolbar.js
@@ +151,3 @@
+        let viewMenu = builder.get_object('viewMenu');
+
+        this._viewMenuButton = new Gtk.MenuButton({ tooltip_text: _("View items as a list or a grid"), popover: viewMenu });

Wrap the "popover: ..." to the next line, as we do elsewhere.
Comment 21 Debarshi Ray 2015-11-13 16:32:14 UTC
Review of attachment 315243 [details] [review]:

::: src/view.js
@@ +426,3 @@
+            Gtk.SortType.ASCENDING : Gtk.SortType.DESCENDING;
+
+        this._model.set_sort_column_id(sortColumn, sortType);

While the UI only allows sorting by PRIMARY_TEXT, SECONDARY_TEXT and MTIME, GdMainColumns has values other than those three. Therefore, I think we shouldn't pass those values directly to set_sort_column_id. We should handle them the same as MTIME, like you did in the SPARQL query patch.
Comment 22 Debarshi Ray 2015-11-13 16:48:01 UTC
Review of attachment 315246 [details] [review]:

::: data/ui/view-menu.ui
@@ +69,3 @@
+                <property name="can_focus">False</property>
+                <property name="halign">start</property>
+                <property name="label" translatable="yes">Sort</property>

Once we start adding the sort options here, the MenuButton's tooltip can't just be: "View items as a list or a grid". Nautilus calls it the "View Menu". 

Similarly the buttons to change the view should be "View items as a list" and "View items as a grid of icons", because just calling them "Grid" or "List" won't be enough.
Comment 23 Debarshi Ray 2015-11-16 15:28:04 UTC
(In reply to Debarshi Ray from comment #22)
> Review of attachment 315246 [details] [review] [review]:
> 
> ::: data/ui/view-menu.ui
> @@ +69,3 @@
> +                <property name="can_focus">False</property>
> +                <property name="halign">start</property>
> +                <property name="label" translatable="yes">Sort</property>
> 
> Once we start adding the sort options here, the MenuButton's tooltip can't
> just be: "View items as a list or a grid". Nautilus calls it the "View
> Menu". 
> 
> Similarly the buttons to change the view should be "View items as a list"
> and "View items as a grid of icons", because just calling them "Grid" or
> "List" won't be enough.

One quick comment.

Nautilus is a bit buggy in this regard, since it doesn't have a tool tip for the view menu and directly sets the ATK label/description. According to the HIG, we should have tooltips [1].

[1] https://developer.gnome.org/hig-book/unstable/toolbars-labels-tooltips.html.en
Comment 24 Alessandro Bono 2015-11-17 14:50:39 UTC
Created attachment 315752 [details] [review]
mainToolbar: Move "view as" buttons into a popover
Comment 25 Alessandro Bono 2015-11-17 14:50:57 UTC
Created attachment 315753 [details] [review]
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.
Comment 26 Alessandro Bono 2015-11-17 14:51:18 UTC
Created attachment 315754 [details] [review]
query, view: Change the ORDER BY clause
Comment 27 Alessandro Bono 2015-11-17 14:51:40 UTC
Created attachment 315755 [details] [review]
view-menu: Add sort options in the popover
Comment 28 Alessandro Bono 2015-11-17 14:53:26 UTC
Attachment 315241 [details] pushed as d19b4b6 - Update gschema for Books
Attachment 315752 [details] pushed as 90a0466 - mainToolbar: Move "view as" buttons into a popover
Comment 29 Debarshi Ray 2015-11-25 11:42:34 UTC
Review of attachment 315753 [details] [review]:

Thanks, Alessandro. Looks good.
Comment 30 Debarshi Ray 2015-11-25 11:57:04 UTC
Review of attachment 315753 [details] [review]:

One minor issue:

::: src/view.js
@@ +423,3 @@
+    _updateSortForSettings: function() {
+        let sortBy = Application.settings.get_enum('sort-by');
+

sortType should be defined here, otherwise one gets:
  JS WARNING: [resource:///org/gnome/Documents/js/view.js 434]: assignment to undeclared variable sortType
Comment 31 Debarshi Ray 2015-11-25 12:02:04 UTC
Review of attachment 315754 [details] [review]:

::: src/query.js
@@ +126,3 @@
     },
 
+    _buildQueryInternal: function(global, flags, offsetController, sortBy) {

There is one more use of _buildQueryInternal where the sortBy is useless. Maybe consider passing 'null' to make it more obvious?

@@ +183,3 @@
     },
 
+    buildGlobalQuery: function(flags, offsetController, sortBy) {

buildGlobalQuery is also used in shellSearchProvider.js. In that case, it might make sense to actually pass the setting.

::: src/trackerController.js
@@ +327,3 @@
         return Application.queryBuilder.buildGlobalQuery(flags,
+                                                         Application.offsetCollectionsController,
+                                                         this._sortBy);

Underscored prefixed names are supposed to be 'private', so I am a little uncomfortable using it as 'protected'. In cases like this, we have just dropped the underscore.
Comment 32 Alessandro Bono 2015-11-25 20:51:24 UTC
Created attachment 316269 [details] [review]
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.
Comment 33 Alessandro Bono 2015-11-25 20:55:56 UTC
Comment on attachment 316269 [details] [review]
view: Update column for sorting when sort-by changes

Attachment 316269 [details] pushed as b739e1b - view: Update column for sorting when sort-by changes
Comment 34 Alessandro Bono 2015-11-25 22:14:18 UTC
Created attachment 316274 [details] [review]
query, view: Change the ORDER BY clause
Comment 35 Debarshi Ray 2015-11-28 18:41:34 UTC
Review of attachment 316274 [details] [review]:

Looks great. Pushed.
Comment 36 Debarshi Ray 2015-11-28 18:54:05 UTC
Review of attachment 315755 [details] [review]:

Works like a charm! Pushed.
Comment 37 Debarshi Ray 2015-11-28 18:55:25 UTC
Thanks Arnel & Alessandro for all the patches.