Skip to content

Fixes in "printers@cinnamon.org"#13524

Open
hans-fritz-pommes wants to merge 14 commits intolinuxmint:masterfrom
hans-fritz-pommes:patch-1
Open

Fixes in "printers@cinnamon.org"#13524
hans-fritz-pommes wants to merge 14 commits intolinuxmint:masterfrom
hans-fritz-pommes:patch-1

Conversation

@hans-fritz-pommes
Copy link

@hans-fritz-pommes hans-fritz-pommes commented Feb 1, 2026

I encountered several small issues with the printers applet.
I modified the applet.js in /usr/share/cinnamon/applets/printers@cinnamon.org and tested printing documents.
The things I did correct:

  • The "Cancel all jobs" command didn't work for an user who had no permisisons to run cancel -a for a specific printer, even if all of the jobs on this printer belonged to him.
    -> Now the "Cancel all jobs" command tries to cancel every single job, not cancel -a for every printer
  • The appearance of the listed jobs was really bad: e.g. when you had more than one job, the description for every job was "<desc. first job><desc. second job><desc..." and so on.
  • The job description consisted of: (job number) lpstat -o (lpstat several times, if there was more than one job - see point before)
    -> The description is now: (job number) 'document_name' on <printer_name> (<size in Bytes/MB/KB>) by <user> (using lpq -a).

The following problem could occur:
If a job has the same number as byte-size like the job-id of the following one, the username and the filesize of the first one will be strange (job-id and functions stay working).
I would say this will happen that seldom - we should ignore it.
Which user will open the menu exactly in that minute and have a problem with a strange username or filesize?

EDIT: fixed in new commit

@hans-fritz-pommes
Copy link
Author

Oh and I changed icons. If you think they're ugly, just revert it

@hans-fritz-pommes hans-fritz-pommes marked this pull request as draft February 1, 2026 19:18
@hans-fritz-pommes
Copy link
Author

I have an idea how to fix this mini-problem (identical bytes & job-number). But later

Fix mini-problem (See linuxmint#13524)
@hans-fritz-pommes hans-fritz-pommes marked this pull request as ready for review February 1, 2026 20:54
@hans-fritz-pommes
Copy link
Author

Ok, now the identical bytes/document-name & job-number-problem is fixed.

@hans-fritz-pommes hans-fritz-pommes marked this pull request as draft February 2, 2026 12:36
@hans-fritz-pommes
Copy link
Author

Sorry that I'm so chaotic
I forgot to take care of document names with whitespaces

Support filenames with whitespaces
@hans-fritz-pommes hans-fritz-pommes marked this pull request as ready for review February 2, 2026 14:11
@claudiux claudiux requested a review from clefebvre February 2, 2026 14:13
@github-actions
Copy link

github-actions bot commented Mar 5, 2026

Best-practices scanner

This is a regex-based check for API usage that can pose security, performance or
maintainability issues, or that may already be provided by Cinnamon. Having code flagged
by it doesn't automatically disqualify a pull request.

This check is not perfect will not replace a normal review.


Found 1 potential issue(s):

⚠️ lang_bind

files/usr/share/cinnamon/applets/printers@cinnamon.org/applet.js:218

Util.spawn_async(['/usr/bin/lpq', '-a'], Lang.bind(this, function(out2) {

Lang.bind() is deprecated. Use arrow functions (() => {}) or Function.prototype.bind() instead.


Automated pattern check.

Improved with mtwebsters ideas
(linuxmint#13524)
@github-actions
Copy link

github-actions bot commented Mar 5, 2026

Best-practices scanner

This is a regex-based check for API usage that can pose security, performance or
maintainability issues, or that may already be provided by Cinnamon. Having code flagged
by it doesn't automatically disqualify a pull request.

This check is not perfect will not replace a normal review.


Found 1 potential issue(s):

⚠️ lang_bind

files/usr/share/cinnamon/applets/printers@cinnamon.org/applet.js:203

Util.spawn_async(['/usr/bin/lpq', '-a'], Lang.bind(this, function(out2) {

Lang.bind() is deprecated. Use arrow functions (() => {}) or Function.prototype.bind() instead.


Automated pattern check.

@hans-fritz-pommes
Copy link
Author

Best-practices scanner

This is a regex-based check for API usage that can pose security, performance or maintainability issues, or that may already be provided by Cinnamon. Having code flagged by it doesn't automatically disqualify a pull request.

This check is not perfect will not replace a normal review.

Found 1 potential issue(s):

⚠️ lang_bind

files/usr/share/cinnamon/applets/printers@cinnamon.org/applet.js:218

Util.spawn_async(['/usr/bin/lpq', '-a'], Lang.bind(this, function(out2) {

Lang.bind() is deprecated. Use arrow functions (() => {}) or Function.prototype.bind() instead.

Automated pattern check.

What should be done with that?

@leigh123linux
Copy link
Member

Please squash the commits into one.

@mtwebster
Copy link
Member

mtwebster commented Mar 5, 2026

What should be done with that?

What it suggests - use an arrow function instead of using Lang.bind(). Look at other applets, it's a pretty straightforward change.

removed deprecated lang.bind
@hans-fritz-pommes
Copy link
Author

By the way:
I was wondering why ever lpstat was used for gathering the job-data.
This pull request removed lpq. I thought every system having lpstat also has lpq since it's a part of cups?

Adressing linuxmint#9265
Necessary update to catch the error reason
@hans-fritz-pommes
Copy link
Author

Those new commits intend to make it compatible with a turned-off CUPS-service

@hans-fritz-pommes
Copy link
Author

Please squash the commits into one.

I will do that when merging

improved error handling
improved error handling
added this.removed
removed unnecessary timeout
@hans-fritz-pommes
Copy link
Author

hans-fritz-pommes commented Mar 10, 2026

Now the guy from #13039 shouldn't have problems anymore with missing lpq and there shouldn't be a problem with missing / not running cups (#9265).

improved looking of error-handling
sendJobs.push(new PopupMenu.PopupIconMenuItem(text, 'xsi-go-up', St.IconType.SYMBOLIC));
sendJobs[sendJobs.length - 1].job = job;
sendJobs[sendJobs.length - 1].connect('activate', Lang.bind(sendJobs[sendJobs.length - 1], this.onSendToFrontClicked));
sendJobs[sendJobs.length - 1].connect('activate', () => this.onSendToFrontClicked(sendJobs[sendJobs.length - 1]));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might not do what you expect:

The callback will evaluate sendJobs[sendJobs.length - 1] at the time of activation, not when you created the callback. You should probably just do something less clever like:

let sendjob = new PopupMenu.PopupIconMenuuItem.....
sendJobs.push(sendjob)
...
...

then reference sendJob as the callback argument.

@mtwebster
Copy link
Member

Can we drop the python script? util.spawnCommandLineAsyncIO() should work fine in this case - they're all fixed arguments. Sorry I should have caught this earlier...

if (lpq_present) {
doc = jobInfo[job][2];
user = jobInfo[job][1];
size = GLib.format_size_for_display(jobInfo[job][3]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

format_size_for_display() is deprecated - use format_size() instead (same arguments).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants