#!/usr/bin/python3
# -*- coding: UTF-8 -*-
import sys

from gi.repository import Gio, Gtk

class App(Gtk.Application):
    def __init__(self):
        Gtk.Application.__init__(self, application_id="org.testapp",
                  flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE)

        self.connect("command-line", self.on_command_line)
        self.connect("startup", self.on_startup)

        self.run(sys.argv)

    def on_command_line(self, app, command_line):
        print ("command_line", command_line.__grefcount__, command_line.get_arguments())
        command_line.set_exit_status(0)
        return 0

    def on_startup(self, *args):
        self.window = Gtk.Window()
        self.add_window(self.window)
        self.window.show_all()

if __name__ == '__main__':
    App()

