[Gambas-user] "mutex" applications

Benoît Minisini gambas at ...1...
Wed Jun 6 11:29:55 CEST 2012


Le 06/06/2012 11:18, Bruce a écrit :
> I have been mucking around with this for about a year now and haven't
> found a solution.
>
> We have a few gambas applications that are treated as pop-ups by the
> users.  That is, they click on some type of launcher (be it a desktop
> item, a menu item or in our case a wbar icon) and the application
> starts.
> Then they minimize it, or go to another desktop, or any other way to
> hide the application window.
> Then they relaunch it...
>
> ... and get another instance running.
>
> However, sort of like things like Evolution, we only want to have one
> copy of these applications running.  So we need some sort of "mutex"
> checker that ensures that they can only run one instance of the
> application.
>
> So far, I have found that I can use gb.desktop to detect another
> instance via the window title and just exit gracefully with a "Another
> instance of xxxxxxxxxxx is running" message.
>
> Blah!
>
> That doesn't really do what I want.  What I want (what I really, really
> want) is a way to activate the window found and then exit.
>
> Any clues?
>
> regards
> Bruce
>

AFAIK, this is now done through D-Bus on Linux desktop. But you must 
investigate how exactly, as I didn't look at it yet.

The idea should be the following:

1) Register on the D-Bus with an unique name.

2) If it works, then export a class on the D-Bus with a method that 
activates yourself and eventually opens a specific document.

3) If it does not works, find the application that has registered on the 
bus, and use its method defined in 2) to activate it, and eventually ask 
it to open a new document.

Regards,

-- 
Benoît Minisini




More information about the User mailing list