[Rigo] make possible to disable the updates notification box
This commit is contained in:
@@ -921,12 +921,13 @@ class RigoServiceController(GObject.Object):
|
||||
if self._avc is not None:
|
||||
self._avc.set_many(update)
|
||||
|
||||
box = UpdatesNotificationBox(
|
||||
self._entropy, self._avc,
|
||||
len(update), 0)
|
||||
box.connect("upgrade-request", _on_upgrade)
|
||||
box.connect("show-request", _on_update_show)
|
||||
self._nc.append(box)
|
||||
if not UpdatesNotificationBox.snoozed():
|
||||
box = UpdatesNotificationBox(
|
||||
self._entropy, self._avc,
|
||||
len(update), 0)
|
||||
box.connect("upgrade-request", _on_upgrade)
|
||||
box.connect("show-request", _on_update_show)
|
||||
self._nc.append(box)
|
||||
|
||||
def _unavailable_repositories_signal(self, repositories):
|
||||
const_debug_write(
|
||||
@@ -1503,6 +1504,10 @@ class RigoServiceController(GObject.Object):
|
||||
"""
|
||||
Start Entropy Repositories Update
|
||||
"""
|
||||
# Un-snooze repositories update notification box.
|
||||
# We will be back nagging the user about possible
|
||||
# package updates.
|
||||
UpdatesNotificationBox.unsnooze()
|
||||
task = ParallelTask(self._update_repositories,
|
||||
repositories, force)
|
||||
task.name = "UpdateRepositoriesThread"
|
||||
|
||||
@@ -79,11 +79,15 @@ class NotificationBox(Gtk.HBox):
|
||||
"""
|
||||
self._widgets.append(widget)
|
||||
|
||||
def add_destroy_button(self, text):
|
||||
def add_destroy_button(self, text, callback=None):
|
||||
"""
|
||||
Add button that destroys the whole Notification object.
|
||||
It is possible to provide a callback function that will be called
|
||||
without arguments before destroying the notification box.
|
||||
"""
|
||||
def _destroy(*args):
|
||||
if callback is not None:
|
||||
callback()
|
||||
self.destroy()
|
||||
self.add_button(text, _destroy)
|
||||
|
||||
@@ -153,6 +157,11 @@ class NotificationBox(Gtk.HBox):
|
||||
|
||||
class UpdatesNotificationBox(NotificationBox):
|
||||
|
||||
# class level variable that makes possible to turn
|
||||
# off the updates notification for the whole process
|
||||
# lifecycle.
|
||||
_snoozed = False
|
||||
|
||||
__gsignals__ = {
|
||||
# Update button clicked
|
||||
"upgrade-request" : (GObject.SignalFlags.RUN_LAST,
|
||||
@@ -189,9 +198,11 @@ class UpdatesNotificationBox(NotificationBox):
|
||||
_("Updates available, how about installing them?")),
|
||||
message_type=Gtk.MessageType.WARNING,
|
||||
context_id="UpdatesNotificationBox")
|
||||
self.add_button(_("_Update System"), self._update)
|
||||
self.add_button(_("_Update"), self._update)
|
||||
self.add_button(_("_Show"), self._show)
|
||||
self.add_destroy_button(_("_Ignore"))
|
||||
self.add_destroy_button(_("Srsly, ignore!"),
|
||||
callback=UpdatesNotificationBox.snooze)
|
||||
|
||||
def _update(self, button):
|
||||
"""
|
||||
@@ -205,6 +216,27 @@ class UpdatesNotificationBox(NotificationBox):
|
||||
"""
|
||||
self.emit("show-request")
|
||||
|
||||
@classmethod
|
||||
def snooze(cls):
|
||||
"""
|
||||
Turn off this notification for the whole process lifetime.
|
||||
"""
|
||||
cls._snoozed = True
|
||||
|
||||
@classmethod
|
||||
def unsnooze(cls):
|
||||
"""
|
||||
Turn back on this notification.
|
||||
"""
|
||||
cls._snoozed = False
|
||||
|
||||
@classmethod
|
||||
def snoozed(cls):
|
||||
"""
|
||||
Return whether the notification is currently "snoozed".
|
||||
"""
|
||||
return cls._snoozed
|
||||
|
||||
|
||||
class RepositoriesUpdateNotificationBox(NotificationBox):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user