forked from cromer/pamac-classic
working tray
This commit is contained in:
parent
fa9c44aec8
commit
39f0eb8b28
@ -5,6 +5,5 @@ Exec=pamac-tray
|
|||||||
Terminal=false
|
Terminal=false
|
||||||
Type=Application
|
Type=Application
|
||||||
Categories=GNOME;GTK;System;
|
Categories=GNOME;GTK;System;
|
||||||
NoDisplay=True
|
NotShowIn=GNOME;XFCE;LXDE;KDE;
|
||||||
StartupNotify=true
|
StartupNotify=true
|
||||||
|
|
||||||
|
@ -6,8 +6,11 @@ from pamac import common, transaction
|
|||||||
if not common.pid_file_exists():
|
if not common.pid_file_exists():
|
||||||
print('checking updates')
|
print('checking updates')
|
||||||
common.write_pid_file()
|
common.write_pid_file()
|
||||||
|
try:
|
||||||
transaction.Refresh()
|
transaction.Refresh()
|
||||||
transaction.TransactionDone()
|
|
||||||
transaction.StopDaemon()
|
transaction.StopDaemon()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
finally:
|
||||||
common.rm_pid_file()
|
common.rm_pid_file()
|
||||||
print('check updates done')
|
print('check updates done')
|
||||||
|
12
pamac-tray
12
pamac-tray
@ -53,7 +53,7 @@ class PeriodicTask(threading.Thread):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
self._finished = threading.Event()
|
self._finished = threading.Event()
|
||||||
self._interval = 30
|
self._interval = 3600*3
|
||||||
|
|
||||||
def setInterval(self, interval):
|
def setInterval(self, interval):
|
||||||
"""Set the number of seconds we sleep between executing our task"""
|
"""Set the number of seconds we sleep between executing our task"""
|
||||||
@ -74,20 +74,20 @@ class PeriodicTask(threading.Thread):
|
|||||||
def task(self):
|
def task(self):
|
||||||
call(['/usr/bin/pamac-check-updates'])
|
call(['/usr/bin/pamac-check-updates'])
|
||||||
|
|
||||||
def set_icon(*arg):
|
def set_icon(updates):
|
||||||
print('set-icon')
|
print('set-icon')
|
||||||
transaction.get_handle()
|
#transaction.get_handle()
|
||||||
do_syncfirst, updates = transaction.get_updates()
|
#do_syncfirst, updates = transaction.get_updates()
|
||||||
if updates:
|
if updates:
|
||||||
icon = '/usr/share/pamac/icons/24x24/status/update-normal.png'
|
icon = '/usr/share/pamac/icons/24x24/status/update-normal.png'
|
||||||
info = str(len(updates))+' update(s) available'
|
info = 'Updates available'
|
||||||
else:
|
else:
|
||||||
icon = '/usr/share/pamac/icons/24x24/status/update-enhancement.png'
|
icon = '/usr/share/pamac/icons/24x24/status/update-enhancement.png'
|
||||||
info = ' No update available'
|
info = ' No update available'
|
||||||
print(info)
|
print(info)
|
||||||
tray.update_icon(icon, 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()
|
tray = Tray()
|
||||||
#set_icon()
|
#set_icon()
|
||||||
|
@ -276,7 +276,6 @@ def handle_reply(reply):
|
|||||||
transaction.t_lock = False
|
transaction.t_lock = False
|
||||||
transaction.Release()
|
transaction.Release()
|
||||||
transaction.ProgressWindow.hide()
|
transaction.ProgressWindow.hide()
|
||||||
transaction.TransactionDone()
|
|
||||||
transaction.to_add = []
|
transaction.to_add = []
|
||||||
transaction.to_remove = []
|
transaction.to_remove = []
|
||||||
transaction_dict.clear()
|
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), '')
|
(is_authorized,is_challenge,details) = policykit_authority.CheckAuthorization(Subject, action, {'': ''}, dbus.UInt32(1), '')
|
||||||
return is_authorized
|
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')
|
@dbus.service.method('org.manjaro.pamac', '', 's')
|
||||||
def Refresh(self):
|
def Refresh(self):
|
||||||
global t
|
global t
|
||||||
@ -173,17 +185,9 @@ class PamacDBusService(dbus.service.Object):
|
|||||||
except pyalpm.error:
|
except pyalpm.error:
|
||||||
error = traceback.format_exc()
|
error = traceback.format_exc()
|
||||||
break
|
break
|
||||||
|
self.CheckUpdates()
|
||||||
return error
|
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')
|
@dbus.service.method('org.manjaro.pamac', 'a{sb}', 's', sender_keyword='sender', connection_keyword='connexion')
|
||||||
def Init(self, options, sender=None, connexion=None):
|
def Init(self, options, sender=None, connexion=None):
|
||||||
global t
|
global t
|
||||||
@ -288,6 +292,7 @@ class PamacDBusService(dbus.service.Object):
|
|||||||
except dbus.exceptions.DBusException:
|
except dbus.exceptions.DBusException:
|
||||||
pass
|
pass
|
||||||
finally:
|
finally:
|
||||||
|
self.CheckUpdates()
|
||||||
return error
|
return error
|
||||||
else :
|
else :
|
||||||
return 'You are not authorized'
|
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')
|
To_Add = proxy.get_dbus_method('To_Add','org.manjaro.pamac')
|
||||||
Commit = proxy.get_dbus_method('Commit','org.manjaro.pamac')
|
Commit = proxy.get_dbus_method('Commit','org.manjaro.pamac')
|
||||||
Release = proxy.get_dbus_method('Release','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')
|
StopDaemon = proxy.get_dbus_method('StopDaemon','org.manjaro.pamac')
|
||||||
|
|
||||||
def action_signal_handler(action):
|
def action_signal_handler(action):
|
||||||
@ -133,8 +132,7 @@ def get_updates():
|
|||||||
do_syncfirst = True
|
do_syncfirst = True
|
||||||
return do_syncfirst, list_first
|
return do_syncfirst, list_first
|
||||||
result = []
|
result = []
|
||||||
installed_pkglist = handle.get_localdb().pkgcache
|
for pkg in localpkgs.values():
|
||||||
for pkg in installed_pkglist:
|
|
||||||
candidate = pyalpm.sync_newversion(pkg, handle.get_syncdbs())
|
candidate = pyalpm.sync_newversion(pkg, handle.get_syncdbs())
|
||||||
if candidate:
|
if candidate:
|
||||||
for repo in handle.get_syncdbs():
|
for repo in handle.get_syncdbs():
|
||||||
|
Loading…
Reference in New Issue
Block a user