From f68ddef4ae5007e7174f34bfb5e64ee66e135c81 Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Fri, 29 Nov 2013 11:36:47 +0100 Subject: [PATCH] [Rigo] add support for basic preserved libraries notification --- rigo/rigo/controllers/daemon.py | 34 +++++++++++++++++++- rigo/rigo/ui/gtk3/widgets/notifications.py | 37 ++++++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/rigo/rigo/controllers/daemon.py b/rigo/rigo/controllers/daemon.py index 09484b4d5..a2f838b6d 100644 --- a/rigo/rigo/controllers/daemon.py +++ b/rigo/rigo/controllers/daemon.py @@ -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): """ diff --git a/rigo/rigo/ui/gtk3/widgets/notifications.py b/rigo/rigo/ui/gtk3/widgets/notifications.py index 509216271..c741b3301 100644 --- a/rigo/rigo/ui/gtk3/widgets/notifications.py +++ b/rigo/rigo/ui/gtk3/widgets/notifications.py @@ -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 %d preserved library on the system", + "There are %d 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")