Menu

#2 Status Bar Icon and Sub Menu are buggy

2.0
closed
nobody
None
2016-08-03
2016-07-25
No

Hey,

As you can see on the image attached the Icon is unable to load and the submenu is completely empty.

My system is a Ubuntu 16.04 64b.

I've had to install libqt4pas ver 5 to have your app to run. It's quite odd I should need it. I've been doing some extensive App coding under Lazarus and never needed that lib.

I'm tempted to svn co your code and try to see what's up with it.

Again, many thanks in advance for any response.

Cheers,
Gus

1 Attachments

Discussion

  • Christopher Hawkins

    Linux applications don't keep an icon in the executable in the same way that Windows does.
    When you install a linux package like a .deb it tends to save an icon in /usr/share/pixmaps (depending on your distro) which it links to.

    Since LazLock is a portable application it doesn't 'register' itself with your system so it doesn't have a default icon.
    A copy of the program icon is included with the binary in the tar file however, so if you want to keep LazLock on your PC you can save the icon somewhere and link to it.

    As for the 'submenu', I've replicated what you're seeing here by running Ubuntu 16.04 in a VM. I'll look into why Ubuntu's WM does this as LazLock has no system tray menu and LXDE and Openbox don't display this.

     

    Last edit: Christopher Hawkins 2016-07-26
    • Gustavo Carreno

      Gustavo Carreno - 2016-07-28

      Hey Christopher,

      Having had a better look at the source I now understand that you only use the notification abilities of TTrayIcon.

      Let me give you some more info on this:

      • On the GTK2 widgets, the TrayIcon does not appear. It does show a notification but it's kinda wrong. The notification is not the one you get when you have some other linux app sending notifications. To be more specific it shows a window on the top left corner that has a white background.

      • On the QT widgets, the TrayIcon is shown on the status bar. It shows what I've sent you on that image. On the console it complains it doesn't have an icon set. When the notification shows up it is the native notification that you can replicate with the command line notify-send (or use the Ubuntu alias alert)

      So, GTK2 will not show the icon on the status bar but FUBARs the notification.
      On the other hand, QT will show something on the status bar, incorrectly, but it gets the native notifications correctly.

      We now have a dilemma, LOL!!
      I would suggest using dbus if you're under Linux. But that's still not a guarranty it will work on all Linux systems. I'll have a look at the source for the TrayIcon and find out how they are doing it. After I have a nice solution I'll send you a code snippet that will work with any Linux and you can ditch the TTrayIcon. In the end you're just using the notification part of it anyway.

      Cheers,
      Gus

       

      Last edit: Gustavo Carreno 2016-07-28
  • Christopher Hawkins

    Hmm, the code in trunk should now show a statusbar icon. Notifications seem to be a Unity issue from reading this http://askubuntu.com/questions/362135/how-to-re-enable-tray-icons-for-applications-in-ubuntu
    Installing libappindicator1 seems to be a workaround but I'd like to avoid LazLock needing a boatload of dependencies.

     
    • Gustavo Carreno

      Gustavo Carreno - 2016-08-01

      I'm sorry I didn't give more info on this.

      After I posted this I went down the rabbit whole and had a look at both implementations for notifications from QT's and GTK2's TTrayIcon.

      The QT implementation, on what regards notifications, somewhere down in it's bowels, passes the notification call into the QT widgets. That's all implemented in one of the libqt<whatever>.so and it manages what to call in terms of a Notification service. In my case it's DBus, since it's Ubuntu's default.

      The GTK2 implementation doesn't even bother to look for such things has a DBus service. Pretty much just instantiates a TPopupNotification object and fires away.

      So to be honest all this boils down to the way the bloody LCL is not coherent in terms of implementation. And only wanting the Notifications out of TTrayIcon really doesn't warrant us fixing TTrayIcon, or go around this bloody mess.

      Due to that fact I began digging into the notion of having a small Notify() procedure you can use to replace the need for TTrayIcon. That way all this TTrayIcon faffing about would go away and we can finally close this issue.

      I'm not quite there, since I had some issues compiling Michaël Van Canneyt's DBus component sources. It's now all resolved and I'm diving into it tomorrow.

      My idea is to use TPopupNotification for Windows ( I could try and find out a similar API like DBus, in the future ) and for Linux, try to connect to DBus to see if it's available. If not, revert to TPopupNotification.

       
  • Christopher Hawkins

    This may be a hack rather than a fix, but since TTrayIcon is trying to display a submenu, I gave it one.
    It wasn't my original intention to use the component for anything more that a notification but I've added a right-click menu and that seems to have removed the empty dropdown menu that it was displaying and tidied it up.
    I tested it in a VM running Ubuntu 16.04, can you let me know what you think?

     

    Last edit: Christopher Hawkins 2016-08-02
    • Gustavo Carreno

      Gustavo Carreno - 2016-08-02

      Hey Christopher,

      Looks great!! I think this will solve it with minimum effort.

      On a side note regarding ticket #5, you're still not using OnSelectItem.
      Every time I compile your code I need to change that to make it work properly.

      Just a reminder :)

      Cheers,
      Gus

       

      Last edit: Gustavo Carreno 2016-08-02
  • Christopher Hawkins

    I'll amend the OnSelectItem event later today.
    For now though, I'll close this ticket as resolved.

     
  • Christopher Hawkins

    • status: open --> closed
     

Log in to post a comment.