#!/usr/bin/env python
# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; indent-offset: 4 -*-

import sys
from gi.repository import Gtk, GObject, Gdk, Gio

class App(Gtk.Application):
    def __init__(self):
        Gtk.Application.__init__(self,application_id="com.foo.test",
                                 flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE)
        self.connect("command-line", self._on_command_line)
        self.connect("startup", self._on_startup)
        self.connect("activate", self._on_activate)
        print "init_node",self

    def _on_command_line(self, app, cmdline):
        print "command_line",self
        return 0

    def _on_startup(self, *args):
        print "startup",self
        if not self.get_windows():
            w = Gtk.Window()
            w.add(Gtk.Label("Test"))
            w.show_all()
            self.add_window(w)

    def _on_activate(self, *args):
        print "activate",self

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

