Exemple #1
0
        def do_show():
            notification = KNotification("Updates")

            # Keep a reference or the callback of the actions added
            # below will never work.
            # See: https://bugzilla.redhat.com/show_bug.cgi?id=241531
            self.__last_notification = notification

            notification.setFlags(KNotification.CloseOnTimeout)
            notification.setText("<b>%s</b><br/>%s" % (title, text,))
            if buttons:
                notification.setActions([x[1] for x in buttons])
                notification.connect(
                    notification,
                    SIGNAL("activated(unsigned int)"), _action_activate_cb)

            icon_name = "okay"
            status = KStatusNotifierItem.Passive
            if urgency == "critical":
                icon_name = "critical"
                status = KStatusNotifierItem.Active

            name = self.icons.get(icon_name)
            icon = KIcon(name)
            self._window.setStatus(status)

            notification.setPixmap(icon.pixmap(48, 48))
            notification.sendEvent()
            self.last_alert = (title, text)
Exemple #2
0
        def do_show():
            notification = KNotification("Updates")

            # Keep a reference or the callback of the actions added
            # below will never work.
            # See: https://bugzilla.redhat.com/show_bug.cgi?id=241531
            self.__last_notification = notification

            notification.setFlags(KNotification.CloseOnTimeout)
            notification.setText("<b>%s</b><br/>%s" % (
                title,
                text,
            ))
            if buttons:
                notification.setActions([x[1] for x in buttons])
                notification.connect(notification,
                                     SIGNAL("activated(unsigned int)"),
                                     _action_activate_cb)

            icon_name = "okay"
            status = KStatusNotifierItem.Passive
            if urgency == "critical":
                icon_name = "critical"
                status = KStatusNotifierItem.Active

            name = self.icons.get(icon_name)
            icon = KIcon(name)
            self._window.setStatus(status)

            notification.setPixmap(icon.pixmap(48, 48))
            notification.sendEvent()
            self.last_alert = (title, text)
Exemple #3
0
    class Tray(KSystemTrayIcon, PTray):
        def __init__(self, parent, iface):
            KSystemTrayIcon.__init__(self, parent)
            self.appWindow = parent
            PTray.__init__(self, iface)

        def initializePopup(self):
            self.setIcon(self.defaultIcon)
            self.actionMenu = KActionMenu(i18n("Update"), self)
            self.populateRepositoryMenu()
            self.contextMenu().addAction(self.actionMenu)
            self.contextMenu().addSeparator()

        def populateRepositoryMenu(self):
            self.actionMenu.menu().clear()
            for name, address in self.iface.getRepositories():
                self._addAction(name, self.actionMenu)
            self._addAction(i18n("All"), self.actionMenu)

        def showPopup(self):
            if self._ready_to_popup():
                if self.notification:
                    del self.notification
                self.notification = KNotification("Updates")
                self.notification.setText(i18n("There are <b>%1</b> updates available!", self.unread))
                self.notification.setActions(QStringList((i18n("Show Updates"), i18n("Ignore"))))
                self.notification.setFlags(KNotification.Persistent)
                self.notification.setComponentData(KComponentData("package-manager","package-manager"))
                self.connect(self.notification, SIGNAL("action1Activated()"), lambda:self.emit(SIGNAL("showUpdatesSelected()")))
                self.notification.sendEvent()
Exemple #4
0
class Tray(KStatusNotifierItem, PTray):
    def __init__(self, parent, iface):
        KSystemTrayIcon.__init__(self, parent)
        self.appWindow = parent
        self.setAssociatedWidget(parent)
        PTray.__init__(self, iface)

    def initializePopup(self):
        self.setIconByPixmap(self.defaultIcon)
        self.actionMenu = KActionMenu(i18n("Update"), self)
        self.populateRepositoryMenu()
        self.contextMenu().addAction(self.actionMenu)
        self.contextMenu().addSeparator()

    def populateRepositoryMenu(self):
        self.actionMenu.menu().clear()
        has_repo = False
        for name, address in self.iface.getRepositories(only_active=True):
            self._addAction(name, self.actionMenu)
            has_repo = True
        if has_repo:
            self._addAction(i18n("All"), self.actionMenu)

    def showPopup(self):
        if self._ready_to_popup():
            if self.notification:
                del self.notification
            self.notification = KNotification("Updates")
            self.notification.setText(
                i18n("There are <b>%1</b> updates available!", self.unread))
            self.notification.setActions(
                QStringList((i18n("Show Updates"), i18n("Ignore"))))
            self.notification.setFlags(KNotification.Persistent)
            self.notification.setComponentData(
                KComponentData("package-manager", "package-manager"))
            self.connect(self.notification, SIGNAL("action1Activated()"),
                         lambda: self.emit(SIGNAL("showUpdatesSelected()")))
            self.notification.sendEvent()