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 781533 - Disable the print button in the selection toolbar when printing isn't supported
Disable the print button in the selection toolbar when printing isn't supported
Status: RESOLVED FIXED
Product: gnome-documents
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: GNOME documents maintainer(s)
GNOME documents maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2017-04-20 13:26 UTC by Debarshi Ray
Modified: 2018-08-24 12:44 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Optionally load the document when determining if it can be printed (6.59 KB, patch)
2017-04-20 14:12 UTC, Debarshi Ray
none Details | Review
documents: Check whether it is a collection in canPrint (983 bytes, patch)
2017-04-20 14:12 UTC, Debarshi Ray
none Details | Review
selections: Enable printing only for documents handled by EvView (2.04 KB, patch)
2017-04-20 14:13 UTC, Debarshi Ray
none Details | Review
documents: Check whether it is a collection in canPrint (700 bytes, patch)
2017-06-07 12:57 UTC, Debarshi Ray
committed Details | Review
documents: Error out if an attempt was made to load a collection (1.50 KB, patch)
2017-06-07 12:57 UTC, Debarshi Ray
committed Details | Review
selections: Enable printing only for documents handled by EvView (2.00 KB, patch)
2017-06-07 12:57 UTC, Debarshi Ray
committed Details | Review

Description Debarshi Ray 2017-04-20 13:26:53 UTC
Now that we don't convert everything to PDFs, we might not be able to print everything that's not a collection. eg., we can't print EPUBs, ODFs and OOXMLs. Therefore it is not enough to only check for collections.
Comment 1 Debarshi Ray 2017-04-20 14:08:14 UTC
It bothers me that our 'feature testing' logic is getting duplicated. We have the canFoo methods in DocCommon to indicate whether a particular document supports a certain feature, and some of that is implicitly encoded in the list of GActions exported by the Preview sub-classes.

I guess such 'feature tests' are hinged on the DocCommon sub-class, the Preview sub-class which in turn depends on the MIME type. I wonder if we can/should consolidate the logic in one place.
Comment 2 Debarshi Ray 2017-04-20 14:12:34 UTC
Created attachment 350129 [details] [review]
Optionally load the document when determining if it can be printed
Comment 3 Debarshi Ray 2017-04-20 14:12:49 UTC
Created attachment 350130 [details] [review]
documents: Check whether it is a collection in canPrint
Comment 4 Debarshi Ray 2017-04-20 14:13:02 UTC
Created attachment 350131 [details] [review]
selections: Enable printing only for documents handled by EvView
Comment 5 Cosimo Cecchi 2017-04-20 17:20:51 UTC
Review of attachment 350129 [details] [review]:

I'm not really sure I understand why this is needed. canPrint() already takes a docModel, so why do you need to load it again?
Comment 6 Cosimo Cecchi 2017-04-20 17:21:33 UTC
Review of attachment 350130 [details] [review]:

The collection check is OK to add, but you may need to change the code if the previous patch is changed.
Comment 7 Cosimo Cecchi 2017-04-20 17:25:30 UTC
Review of attachment 350131 [details] [review]:

Oh I see now why you need to load the document to determine whether it can be printed.
In this case, since you only need to load the document from this code path, could you not load it here, and keep canPrint() synchronous?
Comment 8 Cosimo Cecchi 2017-04-20 17:25:51 UTC
Review of attachment 350131 [details] [review]:

Err, setting right review status.
Comment 9 Cosimo Cecchi 2017-04-20 17:29:49 UTC
(In reply to Debarshi Ray from comment #1)
> It bothers me that our 'feature testing' logic is getting duplicated. We
> have the canFoo methods in DocCommon to indicate whether a particular
> document supports a certain feature, and some of that is implicitly encoded
> in the list of GActions exported by the Preview sub-classes.
> 
> I guess such 'feature tests' are hinged on the DocCommon sub-class, the
> Preview sub-class which in turn depends on the MIME type. I wonder if we
> can/should consolidate the logic in one place.

Yeah, it would be nice to consolidate the checks; however I think it's fine for the action state to be decoupled from the document state, and have the latter drive the former.
Comment 10 Debarshi Ray 2017-04-20 17:41:12 UTC
(In reply to Cosimo Cecchi from comment #5)
> Review of attachment 350129 [details] [review] [review]:
> 
> I'm not really sure I understand why this is needed. canPrint() already
> takes a docModel, so why do you need to load it again?

(In reply to Cosimo Cecchi from comment #7)
> Review of attachment 350131 [details] [review] [review]:
> 
> Oh I see now why you need to load the document to determine whether it can
> be printed.
> In this case, since you only need to load the document from this code path,
> could you not load it here, and keep canPrint() synchronous?

I wanted to abstract out the details of 'canPrint' because it might be useful when consolidating the logic. Except in some cases the docModel is already available, so letting the caller pass it is an easy way to avoid some extra I/O.

I don't have any strong opinion about this. I am happy to move the 'load' outside 'canPrint' and keep it synchronous as you said.
Comment 11 Debarshi Ray 2017-04-20 17:42:56 UTC
(In reply to Cosimo Cecchi from comment #9)
> (In reply to Debarshi Ray from comment #1)
> > It bothers me that our 'feature testing' logic is getting duplicated. We
> > have the canFoo methods in DocCommon to indicate whether a particular
> > document supports a certain feature, and some of that is implicitly encoded
> > in the list of GActions exported by the Preview sub-classes.
> > 
> > I guess such 'feature tests' are hinged on the DocCommon sub-class, the
> > Preview sub-class which in turn depends on the MIME type. I wonder if we
> > can/should consolidate the logic in one place.
> 
> Yeah, it would be nice to consolidate the checks; however I think it's fine
> for the action state to be decoupled from the document state, and have the
> latter drive the former.

Yes, that's what I have been thinking - to somehow base the presence / sensitivity of the GActions on the DocCommon methods. I haven't completely thought it through to arrive at a concrete solution, yet.
Comment 12 Debarshi Ray 2017-06-07 12:57:05 UTC
Created attachment 353323 [details] [review]
documents: Check whether it is a collection in canPrint

These patches keep the canPrint method synchronous, and one has to load the document model separately.
Comment 13 Debarshi Ray 2017-06-07 12:57:17 UTC
Created attachment 353324 [details] [review]
documents: Error out if an attempt was made to load a collection
Comment 14 Debarshi Ray 2017-06-07 12:57:32 UTC
Created attachment 353325 [details] [review]
selections: Enable printing only for documents handled by EvView
Comment 15 Cosimo Cecchi 2017-06-07 16:27:55 UTC
Review of attachment 353323 [details] [review]:

++
Comment 16 Cosimo Cecchi 2017-06-07 16:28:26 UTC
Review of attachment 353324 [details] [review]:

++
Comment 17 Cosimo Cecchi 2017-06-07 16:29:22 UTC
Review of attachment 353325 [details] [review]:

Looks good
Comment 18 Debarshi Ray 2018-08-24 12:44:02 UTC
There was some fallout from this:
https://gitlab.gnome.org/GNOME/gnome-documents/issues/7