diff --git a/src/mambatray b/src/mambatray index 6da0541..9b9ea04 100755 --- a/src/mambatray +++ b/src/mambatray @@ -17,6 +17,13 @@ class SystemTrayIcon(QtGui.QSystemTrayIcon): QtGui.QSystemTrayIcon.__init__(self, icon, parent) menu = QtGui.QMenu(parent) + # refresh packages cache timer + global refreshPackagesTimer, refreshPackagesCacheProcess + refreshPackagesTimer = QtCore.QTimer(self) + refreshPackagesCacheProcess = QtCore.QProcess(self) + self.connect(refreshPackagesTimer, SIGNAL("timeout()"), self.refreshPackagesCache) + self.connect(refreshPackagesCacheProcess, SIGNAL("finished(int,QProcess::ExitStatus)"), self.restartRefreshPackagesTimer) + # software menu global softwareManagerProcess, softwareCheckUpgradesProcess, softwareBaseInstallsProcess, dcopServerProcess softwareManagerProcess = QtCore.QProcess(self) @@ -62,7 +69,10 @@ class SystemTrayIcon(QtGui.QSystemTrayIcon): self.setContextMenu(menu) self.setToolTip(_("openmamba control center")) self.activated.connect(self.iconActivated) - + + # the first time refresh packages cache after 5 minutes + refreshPackagesTimer.start( 5 * 60000 ) + def iconActivated(self, reason): if reason in (QtGui.QSystemTrayIcon.Trigger, QtGui.QSystemTrayIcon.DoubleClick): menu.popup(self.geometry().center()) @@ -77,7 +87,15 @@ class SystemTrayIcon(QtGui.QSystemTrayIcon): softwareManagerProcess.execute("/opt/kde/bin/kpackagekit") def softwareCheckUpgrades(self): - softwareCheckUpgradesProcess.execute("/opt/kde/bin/kpackagekit", QtCore.QStringList(list(set(['--updates'])))) + softwareCheckUpgradesProcess.start("/opt/kde/bin/kpackagekit", ['--updates']) + + def refreshPackagesCache(self): + refreshPackagesTimer.stop() + refreshPackagesCacheProcess.start("/usr/bin/pkcon", ['refresh']) + + def restartRefreshPackagesTimer(self,status): + # check every 4 hours and 31 minutes */ + refreshPackagesTimer.start( (4 * 60 + 31) * 60000) def softwareBaseInstalls(self): dcopServerProcess.startDetached("/opt/kde3/bin/dcopserver")