Ejemplo n.º 1
0
class Fuga(Gtk.Application):
    def __init__(self):
        Gtk.Application.__init__(self,
                                 application_id='com.jonnylamb.Fuga',
                                 flags=Gio.ApplicationFlags.FLAGS_NONE)

        GLib.set_application_name('Fuga')

        self.connect('activate', self.activate_cb)

        self.config = self.create_config()

        ui.style.setup()

        if 'FAKE_GARMIN' in os.environ:
            cls = FakeGarmin
        else:
            cls = Garmin

        self.queue = GarminQueue(cls)

    def activate_cb(self, data=None):
        window = Window(self)
        self.add_window(window)
        window.show_all()

        window.connect('destroy', self.window_destroy_cb)
        window.connect('key-press-event', self.key_press_event_cb)

    def window_destroy_cb(self, window):
        self.queue.shutdown()

    def key_press_event_cb(self, window, event):
        if (event.state & Gdk.ModifierType.CONTROL_MASK \
            and event.keyval == Gdk.KEY_q) or \
           event.keyval == Gdk.KEY_Escape:
            window.destroy()

    def create_config(self):
        path = os.path.dirname(CONFIG_PATH)
        if not os.path.exists(path):
            os.mkdir(path)

        config = ConfigParser()

        if os.path.exists(CONFIG_PATH):
            config.read(CONFIG_PATH)

        def save_config():
            with open(CONFIG_PATH, 'w') as configfile:
                config.write(configfile)
            os.chmod(CONFIG_PATH, 0600)

        config.save = save_config

        return config
Ejemplo n.º 2
0
class Fuga(Gtk.Application):
    def __init__(self):
        Gtk.Application.__init__(self, application_id='com.jonnylamb.Fuga',
                                 flags=Gio.ApplicationFlags.FLAGS_NONE)

        GLib.set_application_name('Fuga')

        self.connect('activate', self.activate_cb)

        self.config = self.create_config()

        ui.style.setup()

        if 'FAKE_GARMIN' in os.environ:
            cls = FakeGarmin
        else:
            cls = Garmin

        self.queue = GarminQueue(cls)

    def activate_cb(self, data=None):
        window = Window(self)
        self.add_window(window)
        window.show_all()

        window.connect('destroy', self.window_destroy_cb)
        window.connect('key-press-event', self.key_press_event_cb)

    def window_destroy_cb(self, window):
        self.queue.shutdown()

    def key_press_event_cb(self, window, event):
        if (event.state & Gdk.ModifierType.CONTROL_MASK \
            and event.keyval == Gdk.KEY_q) or \
           event.keyval == Gdk.KEY_Escape:
            window.destroy()

    def create_config(self):
        path = os.path.dirname(CONFIG_PATH)
        if not os.path.exists(path):
            os.mkdir(path)

        config = ConfigParser()

        if os.path.exists(CONFIG_PATH):
            config.read(CONFIG_PATH)

        def save_config():
            with open(CONFIG_PATH, 'w') as configfile:
                config.write(configfile)
            os.chmod(CONFIG_PATH, 0600)
        config.save = save_config

        return config
Ejemplo n.º 3
0
    def __init__(self):
        Gtk.Application.__init__(self,
                                 application_id='com.jonnylamb.Fuga',
                                 flags=Gio.ApplicationFlags.FLAGS_NONE)

        GLib.set_application_name('Fuga')

        self.connect('activate', self.activate_cb)

        self.config = self.create_config()

        ui.style.setup()

        if 'FAKE_GARMIN' in os.environ:
            cls = FakeGarmin
        else:
            cls = Garmin

        self.queue = GarminQueue(cls)
Ejemplo n.º 4
0
    def __init__(self):
        Gtk.Application.__init__(self, application_id='com.jonnylamb.Fuga',
                                 flags=Gio.ApplicationFlags.FLAGS_NONE)

        GLib.set_application_name('Fuga')

        self.connect('activate', self.activate_cb)

        self.config = self.create_config()

        ui.style.setup()

        if 'FAKE_GARMIN' in os.environ:
            cls = FakeGarmin
        else:
            cls = Garmin

        self.queue = GarminQueue(cls)