import sys
from gi.repository import Gtk, Gio

class Application(Gtk.Application):
    def __init__(self):
        Gtk.Application.__init__(self, 
                                 application_id="org.gtk.TestGtkApplication",
                                 flags=Gio.ApplicationFlags.HANDLES_OPEN,
                                 register_session=True)
                                 
        self.connect("startup", self.startup)
        self.connect("activate", self.startup)
        self.connect("open", self.on_open)

    def activate(self, data=None):
        pass 
    
    def startup(self, data=None):
        pass
    
    def on_open(self, application, files, n_files, hint):
        # ([], 1) for 1 argument, ([], 2) for 2 arguments, etc. 
        # files is always empty.
        print(files, n_files) 

if __name__ == "__main__":
    app = Application()
    r = app.run(sys.argv)
    sys.exit(r)
    
