[Gambas-user] Single instance application, anyone else done it?

Bruce Steers bsteers4 at gmail.com
Wed Jul 7 20:20:16 CEST 2021


Sorry Ben i missed a bit.
Yes if i set unique and remove the Exist() check it still works okay as the
Error equals the condition.

BruceS

On Wed, 7 Jul 2021 at 19:15, Bruce Steers <bsteers4 at gmail.com> wrote:

> It's working a treat here..
> Thank you
> I'm attaching a test app, it just adds args to the listview
> works for multiple file drops
> the ArgAdded event remains active while running so further launches/drops
> add to list too.
>
> BruceS
>
>
> On Wed, 7 Jul 2021 at 19:06, Benoît Minisini <g4mba5 at gmail.com> wrote:
>
>> Le 07/07/2021 à 15:18, Bruce Steers a écrit :
>> >
>> > Excellent thank you Tony :)
>> > I was so close lol, things are working now though thanks to your help.
>> >
>> > Much appreciated :)
>> > BruceS
>> >
>>
>> Actually doing that:
>>
>> If DBus.Session.Applications.Exist(TEXTEDITOR_DBUS_NAME) Then
>>
>> to know if you are already on the bus is wrong, because it's not atomic.
>>
>> You must instead set the DBus.Unique property to TRUE before
>> registering, so that a unique name is used.
>>
>> That way, if you register on the DBus bus again, you will get an error,
>> and it will be atomic.
>>
>> So you should do instead:
>>
>> DBus.Unique = TRUE
>>
>> hDbusObj = New DbusObj
>>
>> ' Registering the first object automatically registers the application.
>>
>> Try DBus.Session.Register(hDbusObj, TEXTEDITOR_PATH,
>> TEXTEDITOR_DBUS_INTERFACE])
>>
>> If Error Then
>>
>>    ' We suppose we are already registered.
>>
>>    If Files.Count > 0 Then
>>      For Each $file In Files
>>        DBus[DBus.Name][TEXTEDITOR_PATH,
>> TEXTEDITOR_DBUS_INTERFACE].Open($file.Name, $file.ReadOnly,
>> $file.LineNumber, $file.ColumnNumber)
>>      Next
>>    Endif
>>
>>    Try DBus[DBus.Name][TEXTEDITOR_PATH, TEXTEDITOR_DBUS_INTERFACE].Show()
>>
>> Endif
>>
>> Tell me if it actually works!
>>
>> --
>> Benoît Minisini
>>
>> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20210707/078a079a/attachment.htm>


More information about the User mailing list