Exemplo n.º 1
0
def get(conf, text):
    if text == None:
        try:
            Notification.new(conf.app_name, _("No text selected."),
                             conf.icon_path).show()
        except:
            print('paf')
            pass
        return
    try:
        Notification.new(conf.app_name,
                         _("I'm reading the text. One moment please."),
                         conf.icon_path).show()
    except:
        print('pif')
        pass
Exemplo n.º 2
0
def show_gnome_notification(title_text: str, sub_text: str):
    ''' got gnome notification '''
    import gi
    gi.require_version('Notify', '0.7')
    from gi.repository.Notify import init as notify_init, Notification
    notify_init("Instagram Notification")
    gnome_notification = Notification.new(title_text, sub_text)
    gnome_notification.show()
Exemplo n.º 3
0
def get(conf, text):
    if text is None:
        try:
            Notification.new(
                conf.app_name,
                _no_text_selected,
                conf.icon_path
            ).show()
        except Exception:
            pass
        return
    try:
        Notification.new(
            conf.app_name,
            _reading_text_loading,
            conf.icon_path
        ).show()
    except Exception:
        pass
Exemplo n.º 4
0
    def __init__(self, show_preferences=False):
        # object to manage processes to activate for.
        self.__process_manager = ProcManager()

        self.__core = Caffeine(self.__process_manager)

        self.__core.connect("activation-toggled", self.on_activation_toggled)
        self.ProcAdd = ProcAdd()

        # XXX: Do we want to change this to caffeine-ng?
        settings = Gio.Settings.new("net.launchpad.caffeine")

        builder = Gtk.Builder()
        builder.add_from_file(get_glade_file("GUI.glade"))

        # It can be tiresome to have to type builder.get_object
        # again and again
        get = builder.get_object

        about = get("aboutdialog")
        about.set_version(__version__)

        show_tray_icon = settings.get_boolean("show-tray-icon")
        show_notification = settings.get_boolean("show-notification")

        if appindicator_avail:
            self.AppInd = \
                AppIndicator3.Indicator.new("caffeine",
                                            "caffeine-cup-empty",
                                            AppIndicator3.IndicatorCategory.
                                            APPLICATION_STATUS)

            self.AppInd.set_status([
                AppIndicator3.IndicatorStatus.PASSIVE,
                AppIndicator3.IndicatorStatus.ACTIVE
            ][show_tray_icon])
        else:
            # IMPORTANT:
            # status icon must be a instance variable  (ie self.)or else it
            # gets thrown out with the garbage, and won't be seen.

            self.status_icon = get("statusicon")
            self.status_icon.set_visible(show_tray_icon)

        if show_tray_icon is False and show_notification is True and \
           show_preferences is False:
            notify_init("caffeine-ng")
            note = Notification.new(
                _("Caffeine is running"),
                _("To show the tray icon, \nrun ") + "'caffeine -p' " +
                _("or open Caffeine Preferences from your system menu."),
                "caffeine",
            )

            note.show()

        self.activate_menuitem = get("activate_menuitem")

        self.set_icon_is_activated(self.__core.get_activated())

        tooltip = self.__core.status_string
        if not tooltip:
            tooltip = _("Caffeine is dormant; powersaving is enabled")
        # self.status_icon.set_tooltip(tooltip)

        # popup menu
        self.menu = get("popup_menu")
        self.menu.show()

        if appindicator_avail:

            self.AppInd.set_menu(self.menu)

        #
        # configuration window widgets
        #
        proc_treeview = get("treeview")
        self.selection = proc_treeview.get_selection()
        self.selection.set_mode(Gtk.SelectionMode.MULTIPLE)

        self.proc_liststore = get("proc_liststore")
        for name in self.__process_manager.get_process_list():
            self.proc_liststore.append([get_icon_for_process(name), name])

        # time_menuitem = get("time_menuitem")

        # time_menuitem.set_submenu(submenu)

        # Preferences editor.
        self.window = get("window")

        # set the icons for the window border.
        self.window.set_default_icon_list([
            get_icon_pixbuf(16),
            get_icon_pixbuf(24),
            get_icon_pixbuf(32),
            get_icon_pixbuf(48)
        ])

        self.trayicon_cb = get("trayicon_cbutton")
        self.notification_cb = get("notification_cbutton")

        self.notification_cb.set_sensitive(not show_tray_icon)

        settings.connect("changed::show-tray-icon", self.on_trayicon_changed)
        settings.connect("changed::show-notification",
                         self.on_notification_changed)

        settings.bind("show-tray-icon", self.trayicon_cb, "active",
                      Gio.SettingsBindFlags.DEFAULT)
        settings.bind("show-notification", self.notification_cb, "active",
                      Gio.SettingsBindFlags.DEFAULT)

        # about dialog
        self.about_dialog = get("aboutdialog")
        self.about_dialog.set_translator_credits(_("translator-credits"))

        # other time selector
        self.othertime_dialog = get("othertime_dialog")
        self.othertime_hours = get("hours_spin")
        self.othertime_minutes = get("minutes_spin")

        if appindicator_avail is False:
            # Handle mouse clicks on status_icon
            # left click
            self.status_icon.connect("activate", self.on_L_click)
            # right click
            self.status_icon.connect("popup-menu", self.on_R_click)

        builder.connect_signals(self)
Exemplo n.º 5
0
    def __init__(self, show_preferences=False):
        # object to manage processes to activate for.
        self.__process_manager = ProcManager()

        self.__core = Caffeine(self.__process_manager)

        self.__core.connect("activation-toggled",
                            self.on_activation_toggled)
        self.ProcAdd = ProcAdd()

        # XXX: Do we want to change this to caffeine-ng?
        settings = Gio.Settings.new("net.launchpad.caffeine")

        builder = Gtk.Builder()
        builder.add_from_file(get_glade_file("GUI.glade"))

        # It can be tiresome to have to type builder.get_object
        # again and again
        get = builder.get_object

        about = get("aboutdialog")
        about.set_version(__version__)

        show_tray_icon = settings.get_boolean("show-tray-icon")
        show_notification = settings.get_boolean("show-notification")

        if appindicator_avail:
            self.AppInd = \
                AppIndicator3.Indicator.new("caffeine",
                                            "caffeine-cup-empty",
                                            AppIndicator3.IndicatorCategory.
                                            APPLICATION_STATUS)

            self.AppInd.set_status([AppIndicator3.IndicatorStatus.PASSIVE,
                                   AppIndicator3.IndicatorStatus.ACTIVE]
                                   [show_tray_icon])
        else:
            # IMPORTANT:
            # status icon must be a instance variable  (ie self.)or else it
            # gets thrown out with the garbage, and won't be seen.

            self.status_icon = get("statusicon")
            self.status_icon.set_visible(show_tray_icon)

        if show_tray_icon is False and show_notification is True and \
           show_preferences is False:
            note = \
                Notification(_("Caffeine is running"),
                             _("To show the tray icon, \nrun ") +
                             "'caffeine -p' " +
                             _("or open Caffeine Preferences from " +
                               "your system menu."), "caffeine")

            note.show()

        self.activate_menuitem = get("activate_menuitem")

        self.set_icon_is_activated(self.__core.get_activated())

        tooltip = self.__core.status_string
        if not tooltip:
            tooltip = _("Caffeine is dormant; powersaving is enabled")
        # self.status_icon.set_tooltip(tooltip)

        # popup menu
        self.menu = get("popup_menu")
        self.menu.show()

        if appindicator_avail:

            self.AppInd.set_menu(self.menu)

        #
        # configuration window widgets
        #
        proc_treeview = get("treeview")
        self.selection = proc_treeview.get_selection()
        self.selection.set_mode(Gtk.SelectionMode.MULTIPLE)

        self.proc_liststore = get("proc_liststore")
        for name in self.__process_manager.get_process_list():
            self.proc_liststore.append([get_icon_for_process(name), name])

        # time_menuitem = get("time_menuitem")

        # time_menuitem.set_submenu(submenu)

        # Preferences editor.
        self.window = get("window")

        # set the icons for the window border.
        self.window.set_default_icon_list([get_icon_pixbuf(16),
                                           get_icon_pixbuf(24),
                                           get_icon_pixbuf(32),
                                           get_icon_pixbuf(48)])

        self.trayicon_cb = get("trayicon_cbutton")
        self.notification_cb = get("notification_cbutton")

        self.notification_cb.set_sensitive(not show_tray_icon)

        settings.connect("changed::show-tray-icon", self.on_trayicon_changed)
        settings.connect("changed::show-notification",
                         self.on_notification_changed)

        settings.bind("show-tray-icon", self.trayicon_cb, "active",
                      Gio.SettingsBindFlags.DEFAULT)
        settings.bind("show-notification", self.notification_cb, "active",
                      Gio.SettingsBindFlags.DEFAULT)

        # about dialog
        self.about_dialog = get("aboutdialog")
        self.about_dialog.set_translator_credits(_("translator-credits"))

        # other time selector
        self.othertime_dialog = get("othertime_dialog")
        self.othertime_hours = get("hours_spin")
        self.othertime_minutes = get("minutes_spin")

        if appindicator_avail is False:
            # Handle mouse clicks on status_icon
            # left click
            self.status_icon.connect("activate", self.on_L_click)
            # right click
            self.status_icon.connect("popup-menu", self.on_R_click)

        builder.connect_signals(self)