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 781552 - Exit selection mode only after printing has begun
Exit selection mode only after printing has begun
Status: RESOLVED FIXED
Product: gnome-documents
Classification: Core
Component: general
3.24.x
Other All
: Normal normal
: ---
Assigned To: GNOME documents maintainer(s)
GNOME documents maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2017-04-20 17:46 UTC by Debarshi Ray
Modified: 2017-05-11 21:44 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
documents, selections: Exit selection only after printing has begun (2.05 KB, patch)
2017-04-20 17:47 UTC, Debarshi Ray
none Details | Review
documents, selections: Exit selection only after printing has begun (3.35 KB, patch)
2017-05-11 17:50 UTC, Debarshi Ray
committed Details | Review

Description Debarshi Ray 2017-04-20 17:46:26 UTC
Ever since the selection-mode state was converted into a GAction (commit e8b2d3431e44d30e4f8edb2c67c600784b81d567), merely clicking the 'print' button on the selection toolbar exists the selection mode. eg., we don't want to leave the selection mode if the print dialog was cancelled.

We should only leave it if an affirmative action has been taken. This matches the behaviour of the other modal dialogs - OrganizeCollectionDialog, PropertiesDialog and SharingDialog.
Comment 1 Debarshi Ray 2017-04-20 17:47:49 UTC
Created attachment 350156 [details] [review]
documents, selections: Exit selection only after printing has begun
Comment 2 Debarshi Ray 2017-04-20 17:48:33 UTC
(In reply to Debarshi Ray from comment #0)
> commit
> e8b2d3431e44d30e4f8edb2c67c600784b81d567),

Looks like the regular expression doesn't work across line breaks. :)

commit e8b2d3431e44d30e4f8edb2c67c600784b81d567
Author: Cosimo Cecchi <cosimoc@gnome.org>
Date:   Sun Oct 30 21:33:15 2016 -0700

    Move selection-mode state to a GAction
    
    The action is owned by the view. This allows us to clean up things quite
    a bit, and use the action accelerators instead of a custom event
    listener.
Comment 3 Cosimo Cecchi 2017-04-23 18:17:08 UTC
Review of attachment 350156 [details] [review]:

::: src/selections.js
@@ +1053,3 @@
+            function(doc) {
+                this._overview.getAction('selection-mode').change_state(GLib.Variant.new('b', false));
+                doc.disconnect(beginPrintId);

Should the signal also not be disconnected when exiting selection mode?
Otherwise since the document may outlive the toolbar, we may end up connecting to this signal twice.
Comment 4 Debarshi Ray 2017-05-11 17:49:27 UTC
(In reply to Cosimo Cecchi from comment #3)
> Review of attachment 350156 [details] [review] [review]:
> 
> ::: src/selections.js
> @@ +1053,3 @@
> +            function(doc) {
> +               
> this._overview.getAction('selection-mode').change_state(GLib.Variant.new('b',
> false));
> +                doc.disconnect(beginPrintId);
> 
> Should the signal also not be disconnected when exiting selection mode?
> Otherwise since the document may outlive the toolbar, we may end up
> connecting to this signal twice.

Good point.

I think that we should disconnect when SelectionToolbar is hidden or destroyed. Otherwise, it will get tricky if, for some reason, SelectionToolbar is hidden or destroyed before the state of the selection-mode GAction changes.
Comment 5 Debarshi Ray 2017-05-11 17:50:36 UTC
Created attachment 351657 [details] [review]
documents, selections: Exit selection only after printing has begun
Comment 6 Cosimo Cecchi 2017-05-11 19:05:56 UTC
Review of attachment 351657 [details] [review]:

It's a bit unfortunate that we have to do this state bookkeeping, but solving that would require a larger refactor, so let's go for this now.