GtkApplicationCommandLine throws GDBus.Error:org.freedesktop.DBus.Error.NoReply



Hi all!

I use python primarily and was trying to use GtkApplication for one of
my applications. However, the simplest one fails. The following code
shows a window when run, when a different instance is started, the
existing window gets focus, but when the window is closed, the second
instance throws

GDBus.Error:org.freedesktop.DBus.Error.NoReply

I have been scratching my head since the past week to find its cause.
Any amount of Googlefu did not help.

I finally figured that command line is a method call message that is
sent over Dbus and the second instance expects a reply. (looks like all
method call messages expect a reply) When I monitor dbus I see that
there is no reply indeed. Please assist me with this.

Also, I would like the client instance to quit after printing a message
if there is a primary instance. I can print the message but couldn't
find a way to quit only the second instance. Any thoughts?

# Python3 code

import sys
from gi.repository import Gio, Gtk

def on_command_line(application, command_line):
    windows = application.get_windows()
    if len(windows):
        windows[0].present()
    else:
        window = Gtk.ApplicationWindow(application=application)
        window.show()
# Print a message.
    if command_line.get_is_remote():
        command_line.do_print_literal("Another instance is running.")
# Gtk complains if I don't return a value.
    return 0

application = Gtk.Application(
                        application_id='org.gnome.test',
                        flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE
                        )

application.connect('command-line', on_command_line)
application.run(sys.argv)
-- 
J Phani Mahesh
( http://phanimahesh.wordpress.com )

You deserve something amazing and free from restriction, you
deserve free software.(free not as in free beer but as in free speech)

This mail is digitally signed with Open PGP key id 0x62E2A632



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]