From 39f0eb8b2886475f2dc35849e5330ff913378a59 Mon Sep 17 00:00:00 2001 From: guinux Date: Sat, 23 Feb 2013 17:02:53 +0100 Subject: [PATCH] working tray --- data/applications/pamac-tray.desktop | 3 +-- pamac-check-updates | 13 ++++++++----- pamac-tray | 12 ++++++------ pamac/main.py | 1 - pamac/pamac-daemon.py | 23 ++++++++++++++--------- pamac/transaction.py | 4 +--- 6 files changed, 30 insertions(+), 26 deletions(-) diff --git a/data/applications/pamac-tray.desktop b/data/applications/pamac-tray.desktop index 0ca6a75..e94c572 100644 --- a/data/applications/pamac-tray.desktop +++ b/data/applications/pamac-tray.desktop @@ -5,6 +5,5 @@ Exec=pamac-tray Terminal=false Type=Application Categories=GNOME;GTK;System; -NoDisplay=True +NotShowIn=GNOME;XFCE;LXDE;KDE; StartupNotify=true - diff --git a/pamac-check-updates b/pamac-check-updates index eadb429..2028bbb 100755 --- a/pamac-check-updates +++ b/pamac-check-updates @@ -6,8 +6,11 @@ from pamac import common, transaction if not common.pid_file_exists(): print('checking updates') common.write_pid_file() - transaction.Refresh() - transaction.TransactionDone() - transaction.StopDaemon() - common.rm_pid_file() - print('check updates done') + try: + transaction.Refresh() + transaction.StopDaemon() + except: + pass + finally: + common.rm_pid_file() + print('check updates done') diff --git a/pamac-tray b/pamac-tray index 9c64eaf..e9c8fff 100755 --- a/pamac-tray +++ b/pamac-tray @@ -53,7 +53,7 @@ class PeriodicTask(threading.Thread): def __init__(self): threading.Thread.__init__(self) self._finished = threading.Event() - self._interval = 30 + self._interval = 3600*3 def setInterval(self, interval): """Set the number of seconds we sleep between executing our task""" @@ -74,20 +74,20 @@ class PeriodicTask(threading.Thread): def task(self): call(['/usr/bin/pamac-check-updates']) -def set_icon(*arg): +def set_icon(updates): print('set-icon') - transaction.get_handle() - do_syncfirst, updates = transaction.get_updates() + #transaction.get_handle() + #do_syncfirst, updates = transaction.get_updates() if updates: icon = '/usr/share/pamac/icons/24x24/status/update-normal.png' - info = str(len(updates))+' update(s) available' + info = 'Updates available' else: icon = '/usr/share/pamac/icons/24x24/status/update-enhancement.png' info = ' No update available' print(info) tray.update_icon(icon, info) -bus.add_signal_receiver(set_icon, dbus_interface = "org.manjaro.pamac", signal_name = "EmitTransactionDone") +bus.add_signal_receiver(set_icon, dbus_interface = "org.manjaro.pamac", signal_name = "EmitAvailableUpdates") tray = Tray() #set_icon() diff --git a/pamac/main.py b/pamac/main.py index f4dd15c..10545eb 100644 --- a/pamac/main.py +++ b/pamac/main.py @@ -276,7 +276,6 @@ def handle_reply(reply): transaction.t_lock = False transaction.Release() transaction.ProgressWindow.hide() - transaction.TransactionDone() transaction.to_add = [] transaction.to_remove = [] transaction_dict.clear() diff --git a/pamac/pamac-daemon.py b/pamac/pamac-daemon.py index 364ecca..f738233 100644 --- a/pamac/pamac-daemon.py +++ b/pamac/pamac-daemon.py @@ -160,6 +160,18 @@ class PamacDBusService(dbus.service.Object): (is_authorized,is_challenge,details) = policykit_authority.CheckAuthorization(Subject, action, {'': ''}, dbus.UInt32(1), '') return is_authorized + @dbus.service.signal('org.manjaro.pamac') + def EmitAvailableUpdates(self, updates_nb): + pass + + def CheckUpdates(self): + updates = False + for pkg in config.handle.get_localdb().pkgcache: + candidate = pyalpm.sync_newversion(pkg, config.handle.get_syncdbs()) + if candidate: + updates = True + self.EmitAvailableUpdates(updates) + @dbus.service.method('org.manjaro.pamac', '', 's') def Refresh(self): global t @@ -173,17 +185,9 @@ class PamacDBusService(dbus.service.Object): except pyalpm.error: error = traceback.format_exc() break + self.CheckUpdates() return error - @dbus.service.signal('org.manjaro.pamac') - def EmitTransactionDone(self, done): - pass - - @dbus.service.method('org.manjaro.pamac', '', '') - def TransactionDone(self): - self.EmitTransactionDone(True) - return - @dbus.service.method('org.manjaro.pamac', 'a{sb}', 's', sender_keyword='sender', connection_keyword='connexion') def Init(self, options, sender=None, connexion=None): global t @@ -288,6 +292,7 @@ class PamacDBusService(dbus.service.Object): except dbus.exceptions.DBusException: pass finally: + self.CheckUpdates() return error else : return 'You are not authorized' diff --git a/pamac/transaction.py b/pamac/transaction.py index 987dfc3..b93b095 100644 --- a/pamac/transaction.py +++ b/pamac/transaction.py @@ -63,7 +63,6 @@ To_Remove = proxy.get_dbus_method('To_Remove','org.manjaro.pamac') To_Add = proxy.get_dbus_method('To_Add','org.manjaro.pamac') Commit = proxy.get_dbus_method('Commit','org.manjaro.pamac') Release = proxy.get_dbus_method('Release','org.manjaro.pamac') -TransactionDone = proxy.get_dbus_method('TransactionDone','org.manjaro.pamac') StopDaemon = proxy.get_dbus_method('StopDaemon','org.manjaro.pamac') def action_signal_handler(action): @@ -133,8 +132,7 @@ def get_updates(): do_syncfirst = True return do_syncfirst, list_first result = [] - installed_pkglist = handle.get_localdb().pkgcache - for pkg in installed_pkglist: + for pkg in localpkgs.values(): candidate = pyalpm.sync_newversion(pkg, handle.get_syncdbs()) if candidate: for repo in handle.get_syncdbs():