def notify(self, strType, msg=""): KNotification.event(strType, msg, QPixmap(), #self.icon.pixmap(QSize(22,22)), #KIcon("google-translator").pixmap(QSize(22,22)) None, KNotification.CloseOnTimeout, KComponentData(str(self.applet.metadata.pluginName()), str(self.applet.metadata.pluginName()), KComponentData.SkipMainComponentRegistration) )
def notifyFinished(self): if not self.operation.totalPackages: return KNotification.event("Summary", self.state.getSummaryInfo(self.operation.totalPackages, self.operation.extraPackages), QPixmap(), None, KNotification.CloseOnTimeout, KComponentData("package-manager", "package-manager", KComponentData.SkipMainComponentRegistration))
def __handleReply(self, reply) : self.activeQuery = "" if reply.error() != QNetworkReply.NoError : print(">>>>>>>> ERROR! : Network Error (" + reply.errorString() + ")") self.__notifications = -1 self.queryFailed.emit() return doc = QDomDocument() doc.setContent(reply) root = doc.documentElement() if root.tagName() == "error_response" : print(">>>>>>>> ERROR! : Facebook Server Returned Error ") err = root.firstChildElement("error_code").text() if int(err) == 190 : self.queryFailed.emit() self.__notifications = -1 self.authExpired.emit() print("\tError Code : " + err) print("\tError Message : " + root.firstChildElement("error_msg").text()) elif root.tagName() == "fql_query_response" : notificationList = root.elementsByTagName("notification") print("== Recived Query Result ==") print("\tTotal Notifications : " + str(notificationList.length())) for i in range(notificationList.length()) : notification = notificationList.at(i) print(unicode(notification.namedItem("title_html").toElement().text())) children = notification.namedItem("title_html").toElement().childNodes() print("title has " + str(children.length()) + " children") for j in range(children.length()) : print(notification.nodeType()) print(children.at(j).nodeName()) if (int(notification.namedItem("anon").toElement().text()) - int(notification.namedItem("created_time").toElement().text())) <= self.settings["pollinterval"] : print("\tNotification " + str(i) + " is New! Firing KNotification::event()") icon = QPixmap(self.settings["notification_icon"]) text = self.settings["notification_title"] text.replace("%title_html%", notification.namedItem("title_html").toElement().text()) KNotification.event(KNotification.Notification, "Facebook", text, icon) else : print(">>>>>>>> ERROR! : Facebook Server returned Unexpected Output : ") print(doc.toByteArray()) if notificationList.length() != self.__notifications : self.__notifications = notificationList.length() self.notificationsChanged.emit()
def notify_touchpad_state(self, is_off=None): if is_off is None: is_off = self.touchpad.off # show a notification if is_off: event_id = 'touchpadOff' text = i18nc('touchpad switched notification', 'Touchpad switched off') else: event_id = 'touchpadOn' text = i18nc('touchpad switched notification', 'Touchpad switched on') icon = KIconLoader.global_().loadIcon('synaptiks', KIconLoader.Panel) KNotification.event(event_id, text, icon)
def notifyFinished(self): if not self.operation.totalPackages: return if self.state.silence: Pds.notify(i18n('Package Manager'), self.state.getSummaryInfo(self.operation.totalPackages)) elif Pds.session == pds.Kde4: from PyKDE4.kdeui import KNotification from PyKDE4.kdecore import KComponentData KNotification.event("Summary", self.state.getSummaryInfo(self.operation.totalPackages), QtGui.QPixmap(), None, KNotification.CloseOnTimeout, KComponentData("package-manager", "package-manager", KComponentData.SkipMainComponentRegistration) ) else: Pds.notify(i18n('Package Manager'), self.state.getSummaryInfo(self.operation.totalPackages))
def notification(self, msg): if self.Settings.value('Notify', True).toBool() : saveNotify = KNotification.event(KNotification.Notification, \ QString('<b>ALSA Volume Control</b>'), \ QString(msg), \ self._icon.pixmap(QSize(64, 64)), \ None, \ KNotification.CloseOnTimeout) saveNotify.setActions( QStringList() << "Don't tell anymore" ) saveNotify.activated['unsigned int'].connect(self.dontTellAnymore) saveNotify.sendEvent()
def showAlarm(self, msgs, sounds, cmds): #print msgs, sounds, cmds, 'alarmed' playSounds = [] runCmds = [] for sound in sounds : if not os.path.isfile(sound.toLocal8Bit().data()) : sound = QString('/usr/share/sounds/pop.wav') #print (sound) playSounds.append(QProcess()) playSounds[len(playSounds)-1].startDetached('/usr/bin/play', QStringList() << sound) for cmd in cmds : if cmd.isEmpty() : continue runCmds.append(QProcess()) runCmds[len(runCmds)-1].startDetached('/usr/bin/sh', QStringList() << '-c' << cmd) for msg in msgs : if msg.isEmpty() : continue notify = KNotification.event(\ KNotification.Notification, \ 'Alarm Clock', \ msg, \ QPixmap(self.alarmIconPath))