[Rigo] add support for basic preserved libraries notification

This commit is contained in:
Fabio Erculiani
2013-11-29 11:36:47 +01:00
parent ae9707d39e
commit f68ddef4ae
2 changed files with 70 additions and 1 deletions
+33 -1
View File
@@ -37,7 +37,8 @@ from rigo.ui.gtk3.widgets.notifications import NotificationBox, \
PleaseWaitNotificationBox, LicensesNotificationBox, \
OrphanedAppsNotificationBox, InstallNotificationBox, \
RemovalNotificationBox, QueueActionNotificationBox, \
UpdatesNotificationBox, RepositoriesUpdateNotificationBox
UpdatesNotificationBox, RepositoriesUpdateNotificationBox, \
PreservedLibsNotificationBox
from rigo.utils import prepare_markup
@@ -188,6 +189,7 @@ class RigoServiceController(GObject.Object):
_NOTICEBOARDS_AVAILABLE_SIGNAL = "noticeboards_available"
_REPOS_SETTINGS_CHANGED_SIGNAL = "repositories_settings_changed"
_MIRRORS_OPTIMIZED_SIGNAL = "mirrors_optimized"
_PRESERVED_LIBS_AVAILABLE_SIGNAL = "preserved_libraries_available"
_SUPPORTED_APIS = [6, 7, 8]
def __init__(self, rigo_app, activity_rwsem,
@@ -572,6 +574,21 @@ class RigoServiceController(GObject.Object):
self._mirrors_optimized_signal,
dbus_interface=self.DBUS_INTERFACE)
# RigoDaemon talls us that there are preserved libraries
# on the system
try:
self.__entropy_bus.connect_to_signal(
self._PRESERVED_LIBS_AVAILABLE_SIGNAL,
self._preserved_libraries_signal,
dbus_interface=self.DBUS_INTERFACE)
except dbus.exceptions.DBusException as exc:
# signal may not be available, ignore.
const_debug_write(
__name__,
"_entropy_bus: %s signal not available: %s" % (
self._PRESERVED_LIBS_AVAILABLE_SIGNAL,
exc,))
self._execute_mainloop(_init)
return self.__entropy_bus
@@ -1153,6 +1170,21 @@ class RigoServiceController(GObject.Object):
context_id=self.OPTIMIZE_MIRRORS_CONTEXT_ID)
self._nc.append(box, timeout=30)
def _preserved_libraries_signal(self, preserved):
"""
RigoDaemon is signaling that there are preserved libraries on the
system.
"""
if self._nc is not None:
def _on_upgrade(box):
self._nc.remove(box)
self.upgrade_system()
box = PreservedLibsNotificationBox(preserved)
box.connect("upgrade-request", _on_upgrade)
self._nc.append(box)
def _output_signal(self, text, header, footer, back, importance, level,
count_c, count_t, percent, raw):
"""
@@ -1194,3 +1194,40 @@ class RenameRepositoryNotificationBox(NotificationBox):
self.destroy()
self.emit("renamed")
class PreservedLibsNotificationBox(NotificationBox):
__gsignals__ = {
# Update button clicked
"upgrade-request" : (GObject.SignalFlags.RUN_LAST,
None,
tuple(),
),
}
def __init__(self, preserved):
preserved_len = len(preserved)
msg = ngettext("There is <b>%d</b> preserved library on the system",
"There are <b>%d</b> preserved libraries on the system",
preserved_len)
msg = msg % (preserved_len,)
msg += ". " + _("What to do?")
NotificationBox.__init__(
self, prepare_markup(msg),
tooltip=prepare_markup(
_("Preserved libraries detected on the system.")),
message_type=Gtk.MessageType.WARNING,
context_id="PreservedLibsNotificationBox")
self.add_button(_("_Update system now"), self._update)
self.add_destroy_button(_("_Ignore"))
def _update(self, button):
"""
Update button callback from the updates notification box.
"""
self.emit("upgrade-request")