~ubuntu-branches/ubuntu/raring/hplip/raring-proposed

« back to all changes in this revision

Viewing changes to ui/systemtray.py

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2012-05-26 11:20:39 UTC
  • mfrom: (1.5.6) (31.1.3 precise)
  • Revision ID: package-import@ubuntu.com-20120526112039-bevxczegxnbyr5m7
Tags: 3.12.4-1
* New upstream release
* Switch to source/format 3.0 (quilt) - drop dpatch
* Refreshed debian/patches
* dh_autoreconf debian/autogen.sh & set local-options single-debian-patch
* Update to debian/compat -> 9
* Fix "hardened build flags" patch from Moritz - thanks (Closes: #667828)
* Fix "duplex descriptor uninitialized" patch from Matej (Closes: #583273)
* Fix "please migrate to kde-runtime" patch from Pino (Closes: #666544)

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
TrayIcon_Information = 2
71
71
 
72
72
theBalloonTip = None
 
73
UPGRADE_CHECK_DELAY=24*60*60*1000               #1 day
73
74
 
74
75
 
75
76
class BalloonTip(QDialog):
392
393
        self.read_pipe = read_pipe
393
394
        self.fmt = "80s80sI32sI80sf"
394
395
        self.fmt_size = struct.calcsize(self.fmt)
 
396
        
 
397
        self.user_settings = utils.UserSettings()
 
398
        self.user_settings.load()
 
399
        self.user_settings.debug()
395
400
 
396
401
        self.tray_icon = SystrayIcon(load_pixmap("hp_logo", "32x32", (22, 22)))
397
402
        self.menu = QPopupMenu()
423
428
        self.icon_info = load_pixmap('info', '16x16')
424
429
        self.icon_warn = load_pixmap('warning', '16x16')
425
430
        self.icon_error = load_pixmap('error', '16x16')
 
431
        
 
432
        self.handle_hplip_updation()
 
433
        self.timer = QTimer()
 
434
        self.timer.connect(self.timer,SIGNAL("timeout()"),self.handle_hplip_updation)
 
435
        self.timer.start(UPGRADE_CHECK_DELAY)
426
436
 
427
437
        self.ERROR_STATE_TO_ICON = {
428
438
            ERROR_STATE_CLEAR: self.icon_info,
519
529
            else:
520
530
                break
521
531
 
 
532
    def handle_hplip_updation(self):
 
533
        log.debug("handle_hplip_updation upgrade_notify =%d"%(self.user_settings.upgrade_notify))
 
534
        path = utils.which('hp-upgrade')
 
535
        if self.user_settings.upgrade_notify is False:
 
536
            log.debug("upgrade notification is disabled in systray ")
 
537
            if path:
 
538
                path = os.path.join(path, 'hp-upgrade')
 
539
                log.debug("Running hp-upgrade: %s " % (path))
 
540
                # this just updates the available version in conf file. But won't notify
 
541
                os.spawnlp(os.P_NOWAIT, path, 'hp-upgrade', '--check')
 
542
            return
 
543
 
 
544
 
 
545
        current_time = time.time()
 
546
 
 
547
        if int(current_time) > self.user_settings.upgrade_pending_update_time:
 
548
            path = utils.which('hp-upgrade')
 
549
            if path:
 
550
                path = os.path.join(path, 'hp-upgrade')
 
551
                log.debug("Running hp-upgrade: %s " % (path))
 
552
                os.spawnlp(os.P_NOWAIT, path, 'hp-upgrade', '--notify')
 
553
 
 
554
            else:
 
555
                log.error("Unable to find hp-upgrade --notify on PATH.")
 
556
        else:
 
557
            log.debug("upgrade schedule time is not yet completed. schedule time =%d current time =%d " %(self.user_settings.upgrade_pending_update_time, current_time))
 
558
 
 
559
 
522
560
 
523
561
    def __tr(self,s,c = None):
524
562
        return qApp.translate("SystemTrayApp",s,c)