1
votes

Using Gtk Application we can prevent multiple instance of the program.

It is possible to send the command parameters to primary instance from the remote instance when Gio.ApplicationFlags.HANDLES_COMMAND_LINE is enabled while creating The Gtk Application.

By this we we send the Arguments same Gtk Application from command line, which is pretty awesome.

But there is the problem, is there any way to get the information back to the remote/normal instance so that while doing the query from commandline it can display back. Since the remote instance exit right after it finds the primary instance.

I'm using python.

1
You're asking if the second application can send data to the first before dying?oldtechaa
@oldtechaa any new instance checks for the primary instance and sends the command line parameters to primary instance. The problem it dies after that and task is handled by primary instance. I need some feedback message from the primary instance back to remote/normal instance so user don't get puzzled.rho

1 Answers

0
votes

Yes, but probably not in the way you want, so it'll be tricky. This approach should work, but I have not tried it.

You should expose the method that you want to call from the remote instance, as a DBus method. Then override the do_local_command_line() vfunc. This will get called in the remote instance when it's started from the command line, and you'll get to process the command line arguments before they get passed to the primary instance. Instead of passing them to the primary instance, remove them from the array of arguments. Then call your DBus method on the primary instance and wait for a response before returning from the do_local_command_line() function.