Python gi.repository 模块,AppIndicator3() 实例源码

我们从Python开源项目中,提取了以下11个代码示例,用于说明如何使用gi.repository.AppIndicator3()

项目:sc-controller    作者:kozec    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
        StatusIcon.__init__(self, *args, **kwargs)

        try:
            from gi.repository import AppIndicator3 as appindicator

            self._status_active  = appindicator.IndicatorStatus.ACTIVE
            self._status_passive = appindicator.IndicatorStatus.PASSIVE
        except ImportError:
            log.warning("Failed to import AppIndicator3")
            raise NotImplementedError

        category = appindicator.IndicatorCategory.APPLICATION_STATUS
        # Whatever icon is set here will be used as a tooltip icon during the entire time to icon is shown
        self._tray = appindicator.Indicator.new("syncthing-gtk", self._get_icon(), category)
        self._tray.set_menu(self._get_popupmenu())
        self._tray.set_title(self.TRAY_TITLE)
项目:indicator-keyboard-led    作者:adrianiainlam    | 项目源码 | 文件源码
def __init__(self, short=False, order='NCS', xdotool=None):
        self.validate_order(order)

        self.indicator = AppIndicator3.Indicator.new(
            APP_NAME, ICON_LOCATION,
            AppIndicator3.IndicatorCategory.APPLICATION_STATUS)
        self.indicator.set_status(AppIndicator3.IndicatorStatus.ACTIVE)

        if short:
            self.locks = { 'N': _('N'), 'C': _('C'), 'S': _('S') }
        else:
            self.locks = { 'N': _('Num'), 'C': _('Caps'), 'S': _('Scroll') }

        keymap = Gdk.Keymap.get_default()
        keymap.connect('state-changed', self.update_indicator, order)
        self.update_indicator(keymap, order)
        self.create_menu(xdotool, order)
项目:sc-controller    作者:kozec    | 项目源码 | 文件源码
def is_clickable(self):
        """ Basically, returns False is appindicator is used """
        return True
项目:furi-kura    作者:benjamindean    | 项目源码 | 文件源码
def init_appindicator(self):
        """ Set initial status and attention icon. """
        self.INDICATOR.set_status(AppIndicator3.IndicatorStatus.ACTIVE)
        self.INDICATOR.set_attention_icon(self.ICONS['attention'])
项目:furi-kura    作者:benjamindean    | 项目源码 | 文件源码
def open_inbox(self, widget):
        self.INDICATOR.set_status(AppIndicator3.IndicatorStatus.ACTIVE)
        self.set_inbox(0)
        self.local_data['inbox_count'] = 0
        webbrowser.open('https://www.reddit.com/message/unread/', new=1, autoraise=True)
项目:furi-kura    作者:benjamindean    | 项目源码 | 文件源码
def mail_notify(self, inbox_count):
        """
        If inbox_count is unchanged from last update - exit the function.
        If new inbox_count is smaller - user read the message
        somewhere else (browser, phone app, etc).
        """
        notification_config = self.config.get('notifications')
        local_inbox_count = self.local_data.get('inbox_count', 0)

        if inbox_count == local_inbox_count:
            return
        elif inbox_count < local_inbox_count:
            self.INDICATOR.set_status(AppIndicator3.IndicatorStatus.ACTIVE)
            return

        self.INDICATOR.set_status(AppIndicator3.IndicatorStatus.ATTENTION)

        if not notification_config:
            return

        if not self.services['notification']:
            self.services['notification'] = Notify.init(self.APPINDICATOR_ID)

        if notification_config == 1:
            message_data = self.request.get_last_message()
            header = "reddit mail from <b>{author}</b>".format(author=message_data['author'])
            body = message_data['body']
        else:
            header = "You have a new reddit mail"
            body = ''

        Notify.Notification.new(
            header,
            body,
            self.ICONS['main']
        ).show()
项目:btcwidget    作者:rafalh    | 项目源码 | 文件源码
def __init__(self, main_win):
        self._main_win = main_win

        menu = self._create_menu()
        self._indicator = AppIndicator3.Indicator.new(self.APPINDICATOR_ID, self._ICON_PATH, self._CATEGORY)
        self._indicator.set_title("Bitcoin Indicator")
        self._indicator.set_status(AppIndicator3.IndicatorStatus.ACTIVE)
        self._indicator.set_menu(menu)

        #open_alarm_dialog(self.main_win)
项目:scripts-systems    作者:nomad-fr    | 项目源码 | 文件源码
def main():
    signal.signal(signal.SIGINT, signal.SIG_DFL)
    indicator = appindicator.Indicator.new(APPINDICATOR_ID, \
        os.path.abspath('/usr/share/icons/gnome/24x24/emotes/face-smile-big.png'), \
        appindicator.IndicatorCategory.SYSTEM_SERVICES)
    indicator.set_status(appindicator.IndicatorStatus.ACTIVE)
    menu = gtk.Menu()
    indicator.set_menu(build_menu(menu))
    # GObject.timeout_add(1000, timespent, indicator, menu)
    gtk.main()
项目:emoji-keyboard    作者:OzymandiasTheGreat    | 项目源码 | 文件源码
def __init__(self):

        self.indicator = AppIndicator3.Indicator.new(
            'emoji-keyboard',
            shared.icon,
            AppIndicator3.IndicatorCategory.APPLICATION_STATUS)
        self.indicator.set_status(AppIndicator3.IndicatorStatus.ACTIVE)
        self.indicator.set_menu(self.build_menu())
        self.indicator.set_secondary_activate_target(self.show_keyboard)
项目:ircalendar-indicator    作者:733amir    | 项目源码 | 文件源码
def main():
    day = JalaliDatetime.now().day
    filename = 'Icons/{}.png'.format(day)
    indicator = AppIndicator3.Indicator.new(id, join(dirname(realpath(__file__)), filename), AppIndicator3.IndicatorCategory.SYSTEM_SERVICES)
    indicator.set_status(AppIndicator3.IndicatorStatus.ACTIVE)
    indicator.set_menu(menu())
    Gtk.main()
项目:bcloud    作者:wangYanJava    | 项目源码 | 文件源码
def init_status_icon(self):
        def on_status_icon_popup_menu(status_icon, event_button, event_time):
            menu.popup(None, None,
                    lambda a,b: Gtk.StatusIcon.position_menu(menu, status_icon),
                    None, event_button, event_time)

        def on_status_icon_activate(status_icon):
            if self.window.props.visible:
                self.window.hide()
            else:
                self.window.present()

        if not self.profile or not self.profile['use-status-icon']:
            self.status_icon = None
            return

        menu = Gtk.Menu()
        show_item = Gtk.MenuItem.new_with_label(_('Show App'))
        show_item.connect('activate', lambda item: self.window.present())
        menu.append(show_item)

        sep_item = Gtk.SeparatorMenuItem()
        menu.append(sep_item)

        pause_upload_item = Gtk.MenuItem.new_with_label(
                _('Pause Upload Tasks'))
        pause_upload_item.connect('activate',
                lambda item: self.upload_page.pause_tasks())
        menu.append(pause_upload_item)

        pause_download_item = Gtk.MenuItem.new_with_label(
                _('Pause Download Tasks'))
        pause_download_item.connect('activate',
                lambda item: self.download_page.pause_tasks())
        menu.append(pause_download_item)

        sep_item = Gtk.SeparatorMenuItem()
        menu.append(sep_item)

        quit_item = Gtk.MenuItem.new_with_label(_('Quit'))
        quit_item.connect('activate', lambda item: self.quit())
        menu.append(quit_item)

        menu.show_all()
        self.status_menu = menu

        if 'AppIndicator' in globals():
            self.status_icon = AppIndicator.Indicator.new(Config.NAME,
                    Config.NAME,
                    AppIndicator.IndicatorCategory.APPLICATION_STATUS)
            self.status_icon.set_menu(menu)
            self.status_icon.set_status(AppIndicator.IndicatorStatus.ACTIVE)
        else:
            self.status_icon = Gtk.StatusIcon()
            self.status_icon.set_from_icon_name(Config.NAME)
            # left click
            self.status_icon.connect('activate', on_status_icon_activate)
            # right click
            self.status_icon.connect('popup_menu', on_status_icon_popup_menu)

    # Open API