On Thu, Mar 31, 2011 at 12:35 AM, Johannes Sasongko <[email protected]>wrote:

> > so far I've allowed a single instance only for simplicity but now I would
> > like to introduce the opportunity to open more instances
> > of different documents, but avoid to open twice the same document for
> > mistake and instead put the running window to toplevel
> > in case there's already an instance of that document opened.
>
> If I understand the problem correctly, you can easily do this using
> D-Bus. (If you're on GTK+ 3, GtkApplication makes it even easier; see
> its example code [1]. I assume you're on GTK+ 2, which doesn't have
> this.)
>
> [1] http://library.gnome.org/devel/gtk/unstable/GtkApplication.html
>
> To do this with D-Bus, in pseudocode:
>
> On app run:
>    Try to reserve a service address ("bus name", in D-Bus terminology)
>    If succeeded:
>        Act as service provider, open windows when requested, etc.
>        // This is your main app process, the only one that ever lives
>        // for more than 1 second. Thus, it contains your GUI code as
>        // well as the D-Bus service.
>    else:
>        Send "open file" message to the existing service through D-Bus
>        Die
>
> On receiving "open file" message: // In main app
>    If file is already open:
>        Bring up the window
>    else:
>        Open file
>

The problem with dbus is that as far as I've read on the internet it is not
supported on windows (my app is mainly for linux but should work fine on
windows as well).
Thank you and best regards,
Giuseppe.
_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to