~ubuntuone-control-tower/ubuntuone-client/trunk

« back to all changes in this revision

Viewing changes to ubuntuone/status/aggregator.py

  • Committer: Tarmac
  • Author(s): eric.casteleijn at canonical
  • Date: 2011-03-07 16:10:46 UTC
  • mfrom: (905.1.3 use-single-notification)
  • Revision ID: tarmac-20110307161046-c11qkdrs96lxoqyp
use a single pynotify.Notification instance

Show diffs side-by-side

added added

removed removed

Lines of Context:
112
112
        if self.notification_switch.enabled:
113
113
            return self.notification.send_notification(*args)
114
114
 
115
 
    def update_notification(self, notification_id, *args):
116
 
        """Passthru the update."""
117
 
        if notification_id is not None and self.notification_switch.enabled:
118
 
            return self.notification.update_notification(notification_id,
119
 
                                                         *args)
120
 
 
121
115
 
122
116
class NotificationSwitch(object):
123
117
    """A switch that turns notifications on and off."""
400
394
    """
401
395
 
402
396
    state = None
403
 
    last_notification_id = 0
404
397
 
405
398
    def __init__(self, status_aggregator, clock=reactor):
406
399
        """Initialize this instance."""
426
419
    def _popup(self):
427
420
        """Display the notification."""
428
421
        text = self.status_aggregator.get_discovery_message()
429
 
        self.last_notification_id = self.notification.send_notification(
430
 
                                                        UBUNTUONE_TITLE, text)
 
422
        self.notification.send_notification(UBUNTUONE_TITLE, text)
431
423
        self.status_aggregator.restart_progress_bubble()
432
424
        logger.debug("notification shown: %s", text)
433
425
        self._change_state(FileDiscoveryUpdateState)
437
429
        text = self.status_aggregator.get_discovery_message()
438
430
        logger.debug("notification updated: %s", text)
439
431
        self.status_aggregator.restart_progress_bubble()
440
 
        self.notification.update_notification(self.last_notification_id,
441
 
                                              UBUNTUONE_TITLE, text)
 
432
        self.notification.send_notification(UBUNTUONE_TITLE, text)
442
433
 
443
434
    def start_sleeping(self):
444
435
        """Wait for 10 minutes before annoying again."""