working tray
This commit is contained in:
parent
fa9c44aec8
commit
39f0eb8b28
@ -5,6 +5,5 @@ Exec=pamac-tray
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Categories=GNOME;GTK;System;
|
||||
NoDisplay=True
|
||||
NotShowIn=GNOME;XFCE;LXDE;KDE;
|
||||
StartupNotify=true
|
||||
|
||||
|
@ -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')
|
||||
|
12
pamac-tray
12
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()
|
||||
|
@ -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()
|
||||
|
@ -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'
|
||||
|
@ -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():
|
||||
|
Loading…
Reference in New Issue
Block a user