def __init__(self, token=None):
        self.indicator = AppIndicator3.Indicator.new(
            'digitalocean-indicator',
            '',
            AppIndicator3.IndicatorCategory.APPLICATION_STATUS)
        self.indicator.set_status(AppIndicator3.IndicatorStatus.ACTIVE)
        icon_uri = get_media_file("digitalocean-indicator.svg")
        icon_path = icon_uri.replace("file:///", '')
        self.indicator.set_icon(icon_path)

        Notify.init('DigitalOcean Indicator')

        self.PreferencesDialog = DoPreferencesDialog
        self.settings = Gio.Settings(
            "com.andrewsomething.digitalocean-indicator")
        self.settings.connect('changed', self.on_preferences_changed)
        self.preferences_dialog = None
        self.preferences_changed = False

        if token:
            self.do_api_token = token
        else:
            self.do_api_token = self.settings.get_string("do-api-token")

        self.menu = Gtk.Menu()

        # Add items to Menu and connect signals.
        self.build_menu()
        # Refresh menu every 10 min by default
        self.change_timeout = False
        self.interval = self.settings.get_int("refresh-interval")
        GLib.timeout_add_seconds(self.interval * 60, self.timeout_set)
    def __init__(self, token=None):
        self.indicator = AppIndicator3.Indicator.new(
            'digitalocean-indicator', '',
            AppIndicator3.IndicatorCategory.APPLICATION_STATUS)
        self.indicator.set_status(AppIndicator3.IndicatorStatus.ACTIVE)
        icon_uri = get_media_file("digitalocean-indicator.svg")
        icon_path = icon_uri.replace("file:///", '')
        self.indicator.set_icon(icon_path)

        Notify.init('DigitalOcean Indicator')

        self.PreferencesDialog = DoPreferencesDialog
        self.settings = Gio.Settings(
            "com.andrewsomething.digitalocean-indicator")
        self.settings.connect('changed', self.on_preferences_changed)
        self.preferences_dialog = None
        self.preferences_changed = False

        if token:
            self.do_api_token = token
        else:
            self.do_api_token = self.settings.get_string("do-api-token")

        self.menu = Gtk.Menu()

        # Add items to Menu and connect signals.
        self.build_menu()
        # Refresh menu every 10 min by default
        self.change_timeout = False
        self.interval = self.settings.get_int("refresh-interval")
        GLib.timeout_add_seconds(self.interval * 60, self.timeout_set)
    def __init__(self):
        self.indicator = AppIndicator3.Indicator.new('digitalocean-indicator',
                         '',
                         AppIndicator3.IndicatorCategory.APPLICATION_STATUS)
        self.indicator.set_status(AppIndicator3.IndicatorStatus.ACTIVE)
        icon_uri = get_media_file("digitalocean-indicator.svg")
        icon_path = icon_uri.replace("file:///", '')
        self.indicator.set_icon(icon_path)

        Notify.init('DigitalOcean Indicator')

        self.PreferencesDialog = DoPreferencesDialog
        self.settings = Gio.Settings(
            "com.andrewsomething.digitalocean-indicator")
        self.settings.connect('changed', self.on_preferences_changed)
        self.preferences_dialog = None
        self.preferences_changed = False

        # If the key/id aren't set, take them from the environment.
        self.do_api_key = self.settings.get_string("do-api-key")
        if not self.do_api_key:
            try:
                self.settings.set_string("do-api-key",
                                         os.environ["DO_API_KEY"])
            except KeyError:
                pass

        self.do_client_id = self.settings.get_string("do-client-id")
        if not self.do_client_id:
            try:
                self.settings.set_string("do-client-id",
                                         os.environ["DO_CLIENT_ID"])
            except KeyError:
                pass

        self.menu = Gtk.Menu()

        # Add items to Menu and connect signals.
        self.build_menu()
        # Refresh menu every 10 min by default
        self.change_timeout = False
        self.interval = self.settings.get_int("refresh-interval")
        GLib.timeout_add_seconds(self.interval*60, self.timeout_set)
Beispiel #4
0
    def __init__(self):
        self.indicator = AppIndicator3.Indicator.new(
            'digitalocean-indicator', '',
            AppIndicator3.IndicatorCategory.APPLICATION_STATUS)
        self.indicator.set_status(AppIndicator3.IndicatorStatus.ACTIVE)
        icon_uri = get_media_file("digitalocean-indicator.svg")
        icon_path = icon_uri.replace("file:///", '')
        self.indicator.set_icon(icon_path)

        Notify.init('DigitalOcean Indicator')

        self.PreferencesDialog = DoPreferencesDialog
        self.settings = Gio.Settings(
            "com.andrewsomething.digitalocean-indicator")
        self.settings.connect('changed', self.on_preferences_changed)
        self.preferences_dialog = None
        self.preferences_changed = False

        # If the key/id aren't set, take them from the environment.
        self.do_api_key = self.settings.get_string("do-api-key")
        if not self.do_api_key:
            try:
                self.settings.set_string("do-api-key",
                                         os.environ["DO_API_KEY"])
            except KeyError:
                pass

        self.do_client_id = self.settings.get_string("do-client-id")
        if not self.do_client_id:
            try:
                self.settings.set_string("do-client-id",
                                         os.environ["DO_CLIENT_ID"])
            except KeyError:
                pass

        self.menu = Gtk.Menu()

        # Add items to Menu and connect signals.
        self.build_menu()
        # Refresh menu every 10 min by default
        self.change_timeout = False
        self.interval = self.settings.get_int("refresh-interval")
        GLib.timeout_add_seconds(self.interval * 60, self.timeout_set)
from gi.repository import GLib, Gio  # pylint: disable=E0611

from locale import gettext as _

import os
import logging
import requests
logger = logging.getLogger('digitalocean_indicator')

from digitalocean_indicator_lib.PreferencesDialog import PreferencesDialog
from digitalocean_indicator_lib.helpers import get_media_file
from digitalocean_indicator.OAuthWindow import AuthWin

autostart_dir = os.path.join(GLib.get_user_config_dir(), "autostart/")
autostart_template = "digitalocean-indicator-autostart.desktop"
autostart_file = get_media_file(autostart_template)
autostart_file = autostart_file.replace("file:///", '')
installed_file = os.path.join(autostart_dir, autostart_template)


class DoPreferencesDialog(PreferencesDialog):
    __gtype_name__ = "PreferencesDigitaloceanIndicatorDialog"

    def finish_initializing(self, builder):  # pylint: disable=E1002
        """Set up the preferences dialog"""
        super(DoPreferencesDialog, self).finish_initializing(builder)

        self.settings = Gio.Settings("com.andrewsomething.digitalocean-indicator")
        self.token = self.settings.get_string("do-api-token")
        self.auth_btn = builder.get_object("auth_btn")
        if self.token == "" or None:
Beispiel #6
0
# See http://developer.gnome.org/gio/stable/GSettings.html for more info.

from gi.repository import GLib, Gio  # pylint: disable=E0611

from locale import gettext as _

import os
import logging
logger = logging.getLogger('digitalocean_indicator')

from digitalocean_indicator_lib.PreferencesDialog import PreferencesDialog
from digitalocean_indicator_lib.helpers import get_media_file

autostart_dir = os.path.join(GLib.get_user_config_dir(), "autostart/")
autostart_template = "digitalocean-indicator-autostart.desktop"
autostart_file = get_media_file(autostart_template)
autostart_file = autostart_file.replace("file:///", '')
installed_file = os.path.join(autostart_dir, autostart_template)


class DoPreferencesDialog(PreferencesDialog):
    __gtype_name__ = "PreferencesDigitaloceanIndicatorDialog"

    def finish_initializing(self, builder):  # pylint: disable=E1002
        """Set up the preferences dialog"""
        super(DoPreferencesDialog, self).finish_initializing(builder)

        # Bind each preference widget to gsettings
        settings = Gio.Settings("com.andrewsomething.digitalocean-indicator")
        do_api_key = self.builder.get_object('do_api_key_entry')
        settings.bind("do-api-key", do_api_key,