[Gambas-user] DBus.Unique failing on KDE and Cinnamon

Bruce Steers bsteers4 at gmail.com
Sat Aug 14 17:49:28 CEST 2021


On Sat, 14 Aug 2021 at 13:05, Bruce Steers <bsteers4 at gmail.com> wrote:

>
>
> On Sat, 14 Aug 2021 at 12:51, Bruce Steers <bsteers4 at gmail.com> wrote:
>
>>
>>
>> On Sat, 14 Aug 2021 at 11:32, Bruce Steers <bsteers4 at gmail.com> wrote:
>>
>>> I have this application...
>>> https://gitlab.com/bsteers4/glaunch
>>>
>>> It uses DBus so if it is run when already running it opens the running
>>> apps window and not run again.
>>>
>>> It is the same as in my Desktop-ish app
>>> https://gitlab.com/bsteers4/desktop-ish
>>>
>>> For some reason Desktop-ish works as expected and sets up
>>> org.gambas.Desktop_ish.
>>>
>>> But glaunch sets up org.gambas.glaunch and if i run it again it sets up
>>> org.gambas.glaunch-<id-number>
>>> bug is happening on KDE and Cinnamon
>>> it is okay on MATE and Gnome
>>>
>>
>>
>> I'm not sure of the problem but i can report this...
>> I think it has to do with one app using systemtray
>>
>> The 1st instance of glaunch sets up org.gambas.glaunch
>> DBus.Name returns org.gambas.glaunch
>> glaunch dbus application contains the usual introsect, etc and
>> org.command (my interface)
>>
>> The 2nd instance of glaunch sets up org.gambas.glaunch-<ID> (ID is a
>> number)
>> DBus.Name wrongly returns org.gambas.glaunch
>> glaunch dbus application contains the usual introspect, etc and
>> org.command (my interface) and also a kde.statusnotifier
>>
>> aah, result..
>> i just fixed it by adding DBus.Unique = True to the programs _init()
>> function.
>>
>> BruceS
>>
>
> Getting DBus.Unique set at the start then caused the TrayIcon (in the
> Form) to raise an error with name already registered.
>
> I just had to import gb.dbus.trayicon and make it exit cleanly if unable
> to register due to existing name.
>

A better fix than importing gb.gui.trayicon was to remove the TrayIcon from
the form designer and add it manually in Form_Open() (after setting dbus
unique) in _init())

So to summarise....
If you are using an object that uses DBus like TrayIcon and also need
DBus.Unique set true then you need to Set DBus.Unique = True in your
Applications _init() function and add/instance the New Trayicon with code
(not use form designer)

Wishing well
BruceS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20210814/ac27a7cf/attachment-0001.htm>


More information about the User mailing list