--- puplet.py 12 Jul 2006 18:54:38 -0000 1.8 +++ puplet.py 16 Aug 2006 00:20:07 -0000 @@ -28,6 +28,7 @@ import gobject import gconf import egg.trayicon +import pynotify import dbus import dbus.glib @@ -64,6 +65,10 @@ self.client.notify_add(ALWAYS_SHOW_KEY, self._alwaysShowChange) self.connectionfailures = 0 + self.security = False + + if not pynotify.init("puplet"): + print >> sys.stderr, "Error: unable to initialize pynotify" def _setAvailablePixbuf(self): if os.path.exists("data/puplet-available.png"): @@ -142,12 +147,16 @@ # we want to count the same way as pup. # FIXME: we should actually _SHARE_ code here :) upds = {} + security = False for (new, old) in uplst: srpm = new["sourcerpm"] if upds.has_key(srpm): upds[srpm].append( (new, old) ) else: upds[srpm] = [ (new, old) ] + if new.has_key('type') and new['type'] == 'security': + security = True + self.security = security return len(upds.keys()) @@ -166,14 +175,31 @@ self.updatesObject = self.bus.get_object("edu.duke.linux.yum", "/Updatesd") - # FIXME: need some notify bubble love through here... - def updates_avail_handler(str): num = self._countUpdates(self.updatesObject.GetUpdateInfo(dbus_interface="edu.duke.linux.yum")) + def updates_avail_notify(): + title = "Updates Available" + text = "There are %s package updates available." % num + urgency = pynotify.URGENCY_NORMAL + + if self.security: + title = 'Critical ' + title + urgency = pynotify.URGENCY_CRITICAL + + n = pynotify.Notification(_(title), _(text)) + n.attach_to_status_icon(self.trayicon) + n.add_action("update", "Apply Updates", self._applyUpdates) + n.set_urgency(urgency) + n.set_timeout(0) + + if not n.show(): + print >> sys.stderr, "Failed to send notification" + self.trayicon.set_tooltip(_("%s updates available") %(num,)) self._setAvailablePixbuf() self.trayicon.set_visible(True) + gobject.idle_add(updates_avail_notify) def updates_installed_handler(updinfo): def hidetrayicon(*args): @@ -183,6 +209,13 @@ self._setUpdatedPixbuf() self.trayicon.set_tooltip(_("%d updates successfully installed.") %(num,)) + + n = pynotify.Notification(_("Update Successful"), + _("%d updates successfully installed.") % (num)) + + if not n.show(): + print >> sys.stderr, "Failed to send notification" + if not self.client.get_bool(ALWAYS_SHOW_KEY): gobject.timeout_add(15 * 1000, hidetrayicon)