Printer Applet and KStatusNotifierItem

In 30 minutes of hacking after lunch I came up with this:

The printer-applet has been ported to KStatusNotifierItem in all its glory. I like KStatusNotifierItem. Besides the obvious presentation improvements, I was even able to remove a few custom functions for hiding/restoring the main menu and the tray icon for free.  The less cruft, the better!

Unfortunately this is way too late for KDE 4.4. I probably would have tackled this earlier, except that the python bindings haven’t been in a working state this whole cycle, only starting to compile with 4.4 RC2.😦

I committed the patch to svn and only moments later realized I had made an i18n mistake. As long as you grab both revisions, the patch should be fairly safe to backport to distro packages. I’ve done a bit of testing to make sure nothing obvious broke, but it’s a new feature and as such may not be perfect. It’ll probably be OK since most distros aren’t releasing 4.4-based distros for another few months, which should be plenty of time to test. The Kubuntu packages for RC3 will have this patch, for the record.

Also in printer-applet trunkland, I did a few optimizations in regards to QStrings. (Using QLatin1String with QString.startsWith, using remove() rather than replace()-ing a char with an empty string, etc) Between switching to KStatusNotifierItem and this my unscientific testing shows that the printer-applet in 4.5 uses ~200 kilobytes less RAM than in 4.3.98. Not much considering it still takes up 19.1 MB of RAM on startup with my machine, but it’s still a bit better. It would be nice if somebody could port over the “don’t-start-the-gui-until-needed” code from the GTK+ printer-applet, as that would really help the situation a lot. Oh well, until either that or a C++ equivalent turn up, at least printer-applet integrates well with the systray in the meantime.

Edit: Include the fixes from r1084373 too, sorry ’bout that.

24 Responses to Printer Applet and KStatusNotifierItem

  1. Stefan says:

    Is there any chance to find out when will RC3 be available?

  2. saLOUt says:

    Hi,

    why does your python program need to be compiled?
    I dont think we need a c++ version of your program. It is time for the bindings to be used (and optimized).

    Best Regards

    • echidnaman says:

      It’s not the application that needs compiled, but the python bindings for the KDE4 libraries. Without the new bindings I couldn’t use the new API, and without that I couldn’t run my python program.

      In regards to C++ vs. python, python may be good for some things, but one thing it’s not too great at is memory efficiency. Taking 20 MB of RAM to show a tiny tray icon is way too much. Python has its niche, but status icons aren’t that niche.

  3. Alejandro Nova says:

    Can you request a freeze exemption? Your case is fairly justified (non-working bindings until KDE 4.4 RC2) and that functionality is sorely needed, specially when the Printer Configuration applet in System Setting is dead (4.4 RC2 here).

    • echidnaman says:

      I think you’re confusing the printing applet with the printing config applet. (Both of which work here in 10.04) I think there might be a problem with the sip4 backport to the Karmic PPAs, so that may be what you’re talking about.

      Anyways, this is way, way, way to close to the release to port to a new API with a mere several day or so of testing. I think this might introduce a new string, though I am not sure.

  4. Jesper says:

    In line with all other efforts to make KDE less hacker oriented and more useable for normal people: Why does it have to say “Printer Applet”? Why not just “Printer”?

  5. cumulus007 says:

    Why does the title read “Printer *Applet*”? Applet is such a confusion term for some users, especially novice users from MS Windows. Just leave it to “Printer” or the name of the printer, such as “PhotoSmart 2570”.

  6. @Alejandro Nova – There was a bug in the Printer Configuration program (system-config-printer-kde) that made it unable to start, if you refer it as being “dead”. I committed a fix to it a while ago, so it should be in RC3 or final.

  7. nhasan says:

    I agree with the poster above. It should use the name of the printer as the title instead of the useless “Printer Applet.”

  8. gskbyte says:

    This is one of the parts of KDE that need more love (beside NetworkManager applet). Nice work🙂.

    BTW, what is the font you’re using?

    • echidnaman says:

      That’s Droid Sans, at 8 point, with full RGB hinting. Normally full hinting is too much for me, but I’ve found it necessary to make the fonts look good on my LCD screen laptop.

  9. dantti says:

    Hey dude nice work,
    I’ve been talking to Ridell cause I’m working on a C++ version of these things, it adds less than 1mb to kded process and is quite nice, as soon as kded 4.4 is out I want to create the systray icon with the new notification icon, I’ll put this code on playground and if you are interested in porting your changes to there it will be very nice😀
    Here you can see the queue that is almost 100% functional

    Best

  10. […] be an option, also just to monitor the jobs it eats 19mb which also makes your startup slower, in Jonathan’s blog you can see I’m not the only one thinking this […]

  11. Astreek says:

    Nice work, thank you!

    Is it possible to only start this applet when I print something? Because every time I login, this applet loads and it uses ~20 MB memory. With Karmic and KDE 4.3 it only started when I printed something.

  12. […] I had posted that this was completed. (And even users of Kubuntu 9.10 + KDE 4.4 get this!) Unfortunately it […]

  13. […] print-manager progress On the heels of my wish for a C++ version of printer-applet, Dantti announced just such a project. He invited me to […]

  14. David says:

    I hope this is the proper place for my comment.

    The printer applet in Kubuntu 11.04 has columns for showing User, Document, and Printer.

    On my systems it shows “Unknown” for user and “Document.”

    The Printer column is blank, (empty).

    I wish to set it so that jobs are kept and I can view the completed ones and re-print when needed.

    But unless I can at least get the Document name to dismay, the printer-applet isn’t gonna cut the mustard. It would be nice if is showed the user and printer names.

    I have Kubuntu in a small office I am expanding at home on 5 machines.

    I will be doing print shop type printing, anticipating lots of reprinting.

    I have come from a Windows/Corel Draw/Illustrator type world with Roland Cutters and printers.

    Can’t afford Windows….Adobe….Illustator….Roland.

    So its gonna be inkscape, sk1 gimp, tc cutters and Chinese printers.

    But goodness what a leap.

    Suggestions? Words of Wisdom? Curse words?

    Suggestions for a WYSIWYP type app, or something with side by side previews in the KDE world or just some make like easier printer tools?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: