forked from cromer/pamac-classic
finnally got it ;)
This commit is contained in:
parent
76714eedb8
commit
73e1e8d6c0
@ -10,7 +10,6 @@
|
|||||||
<property name="window_position">center-on-parent</property>
|
<property name="window_position">center-on-parent</property>
|
||||||
<property name="type_hint">dialog</property>
|
<property name="type_hint">dialog</property>
|
||||||
<property name="skip_taskbar_hint">True</property>
|
<property name="skip_taskbar_hint">True</property>
|
||||||
<property name="urgency_hint">True</property>
|
|
||||||
<property name="has_resize_grip">False</property>
|
<property name="has_resize_grip">False</property>
|
||||||
<property name="message_type">error</property>
|
<property name="message_type">error</property>
|
||||||
<property name="buttons">ok</property>
|
<property name="buttons">ok</property>
|
||||||
@ -36,6 +35,41 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
<object class="GtkMessageDialog" id="InfoDialog">
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="border_width">5</property>
|
||||||
|
<property name="resizable">False</property>
|
||||||
|
<property name="modal">True</property>
|
||||||
|
<property name="window_position">center-on-parent</property>
|
||||||
|
<property name="type_hint">dialog</property>
|
||||||
|
<property name="skip_taskbar_hint">True</property>
|
||||||
|
<property name="buttons">ok</property>
|
||||||
|
<child internal-child="vbox">
|
||||||
|
<object class="GtkBox" id="messagedialog-vbox9">
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<property name="spacing">2</property>
|
||||||
|
<child internal-child="action_area">
|
||||||
|
<object class="GtkButtonBox" id="messagedialog-action_area9">
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="layout_style">end</property>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="pack_type">end</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
<object class="GtkMessageDialog" id="QuestionDialog">
|
<object class="GtkMessageDialog" id="QuestionDialog">
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="border_width">5</property>
|
<property name="border_width">5</property>
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
<property name="window_position">center-on-parent</property>
|
<property name="window_position">center-on-parent</property>
|
||||||
<property name="type_hint">dialog</property>
|
<property name="type_hint">dialog</property>
|
||||||
<property name="skip_taskbar_hint">True</property>
|
<property name="skip_taskbar_hint">True</property>
|
||||||
<property name="urgency_hint">True</property>
|
|
||||||
<property name="deletable">False</property>
|
<property name="deletable">False</property>
|
||||||
<property name="transient_for">ManagerWindow</property>
|
<property name="transient_for">ManagerWindow</property>
|
||||||
<child internal-child="vbox">
|
<child internal-child="vbox">
|
||||||
@ -121,7 +120,6 @@
|
|||||||
<property name="icon">/usr/share/pamac/icons/22x22/status/package-info.png</property>
|
<property name="icon">/usr/share/pamac/icons/22x22/status/package-info.png</property>
|
||||||
<property name="type_hint">dialog</property>
|
<property name="type_hint">dialog</property>
|
||||||
<property name="skip_taskbar_hint">True</property>
|
<property name="skip_taskbar_hint">True</property>
|
||||||
<property name="urgency_hint">True</property>
|
|
||||||
<property name="deletable">False</property>
|
<property name="deletable">False</property>
|
||||||
<property name="transient_for">ManagerWindow</property>
|
<property name="transient_for">ManagerWindow</property>
|
||||||
<child>
|
<child>
|
||||||
@ -265,6 +263,7 @@
|
|||||||
<property name="height_request">500</property>
|
<property name="height_request">500</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="title" translatable="yes">Pamac</property>
|
<property name="title" translatable="yes">Pamac</property>
|
||||||
|
<property name="window_position">center</property>
|
||||||
<property name="default_width">800</property>
|
<property name="default_width">800</property>
|
||||||
<property name="default_height">500</property>
|
<property name="default_height">500</property>
|
||||||
<property name="icon">/usr/share/pamac/icons/22x22/status/package-sources.png</property>
|
<property name="icon">/usr/share/pamac/icons/22x22/status/package-sources.png</property>
|
||||||
|
177
pamac-daemon
177
pamac-daemon
@ -8,7 +8,7 @@ from gi.repository import GObject
|
|||||||
|
|
||||||
import pyalpm
|
import pyalpm
|
||||||
#import traceback
|
#import traceback
|
||||||
#import threading
|
from multiprocessing import Process
|
||||||
from pamac import config, common
|
from pamac import config, common
|
||||||
|
|
||||||
class PamacDBusService(dbus.service.Object):
|
class PamacDBusService(dbus.service.Object):
|
||||||
@ -17,6 +17,7 @@ class PamacDBusService(dbus.service.Object):
|
|||||||
bus_name = dbus.service.BusName('org.manjaro.pamac', bus)
|
bus_name = dbus.service.BusName('org.manjaro.pamac', bus)
|
||||||
dbus.service.Object.__init__(self, bus_name, '/org/manjaro/pamac')
|
dbus.service.Object.__init__(self, bus_name, '/org/manjaro/pamac')
|
||||||
self.t = None
|
self.t = None
|
||||||
|
self.task = None
|
||||||
self.error = ''
|
self.error = ''
|
||||||
self.warning = ''
|
self.warning = ''
|
||||||
self.action = 'Preparing...'
|
self.action = 'Preparing...'
|
||||||
@ -109,14 +110,13 @@ class PamacDBusService(dbus.service.Object):
|
|||||||
print("conversation", args)
|
print("conversation", args)
|
||||||
|
|
||||||
def cb_log(self, level, line):
|
def cb_log(self, level, line):
|
||||||
#global t
|
|
||||||
_logmask = pyalpm.LOG_ERROR | pyalpm.LOG_WARNING
|
_logmask = pyalpm.LOG_ERROR | pyalpm.LOG_WARNING
|
||||||
if not (level & _logmask):
|
if not (level & _logmask):
|
||||||
return
|
return
|
||||||
if level & pyalpm.LOG_ERROR:
|
if level & pyalpm.LOG_ERROR:
|
||||||
self.error += "ERROR: "+line
|
self.error += "ERROR: "+line
|
||||||
print(self.error)
|
print(self.error)
|
||||||
#t.release()
|
#self.t.release()
|
||||||
elif level & pyalpm.LOG_WARNING:
|
elif level & pyalpm.LOG_WARNING:
|
||||||
self.warning += "WARNING: "+line
|
self.warning += "WARNING: "+line
|
||||||
elif level & pyalpm.LOG_DEBUG:
|
elif level & pyalpm.LOG_DEBUG:
|
||||||
@ -133,25 +133,28 @@ class PamacDBusService(dbus.service.Object):
|
|||||||
if self.total_size > 0:
|
if self.total_size > 0:
|
||||||
fraction = (_transferred+self.already_transferred)/self.total_size
|
fraction = (_transferred+self.already_transferred)/self.total_size
|
||||||
size = 0
|
size = 0
|
||||||
if (t.to_remove or t.to_add):
|
try:
|
||||||
for pkg in t.to_remove+t.to_add:
|
if (self.t.to_remove or self.t.to_add):
|
||||||
if pkg.name+'-'+pkg.version in _target:
|
for pkg in self.t.to_remove+self.t.to_add:
|
||||||
size = pkg.size
|
if pkg.name+'-'+pkg.version in _target:
|
||||||
if _transferred == size:
|
size = pkg.size
|
||||||
self.already_transferred += size
|
if _transferred == size:
|
||||||
self.action = 'Downloading '+common.format_size(self.total_size)
|
self.already_transferred += size
|
||||||
self.target = _target
|
self.action = 'Downloading '+common.format_size(self.total_size)
|
||||||
self.percent = fraction
|
self.target = _target
|
||||||
self.icon = '/usr/share/pamac/icons/24x24/status/package-download.png'
|
self.percent = fraction
|
||||||
else:
|
self.icon = '/usr/share/pamac/icons/24x24/status/package-download.png'
|
||||||
self.action = 'Refreshing...'
|
else:
|
||||||
self.target = _target
|
self.action = 'Refreshing...'
|
||||||
self.percent = 2
|
self.target = _target
|
||||||
self.icon = '/usr/share/pamac/icons/24x24/status/refresh-cache.png'
|
self.percent = 2
|
||||||
self.EmitAction(self.action)
|
self.icon = '/usr/share/pamac/icons/24x24/status/refresh-cache.png'
|
||||||
self.EmitIcon(self.icon)
|
self.EmitAction(self.action)
|
||||||
self.EmitTarget(self.target)
|
self.EmitIcon(self.icon)
|
||||||
self.EmitPercent(str(self.percent))
|
self.EmitTarget(self.target)
|
||||||
|
self.EmitPercent(str(self.percent))
|
||||||
|
except pyalpm.error:
|
||||||
|
pass
|
||||||
|
|
||||||
def cb_progress(self, _target, _percent, n, i):
|
def cb_progress(self, _target, _percent, n, i):
|
||||||
self.target = _target+' ('+str(i)+'/'+str(n)+')'
|
self.target = _target+' ('+str(i)+'/'+str(n)+')'
|
||||||
@ -159,7 +162,7 @@ class PamacDBusService(dbus.service.Object):
|
|||||||
self.EmitTarget(self.target)
|
self.EmitTarget(self.target)
|
||||||
self.EmitPercent(str(self.percent))
|
self.EmitPercent(str(self.percent))
|
||||||
|
|
||||||
def policykit_test(self, sender,connexion, action):
|
def policykit_test(self, sender, connexion, action):
|
||||||
bus = dbus.SystemBus()
|
bus = dbus.SystemBus()
|
||||||
proxy_dbus = connexion.get_object('org.freedesktop.DBus','/org/freedesktop/DBus/Bus', False)
|
proxy_dbus = connexion.get_object('org.freedesktop.DBus','/org/freedesktop/DBus/Bus', False)
|
||||||
dbus_info = dbus.Interface(proxy_dbus,'org.freedesktop.DBus')
|
dbus_info = dbus.Interface(proxy_dbus,'org.freedesktop.DBus')
|
||||||
@ -184,30 +187,35 @@ class PamacDBusService(dbus.service.Object):
|
|||||||
updates = True
|
updates = True
|
||||||
self.EmitAvailableUpdates(updates)
|
self.EmitAvailableUpdates(updates)
|
||||||
|
|
||||||
@dbus.service.method('org.manjaro.pamac', '', 's')
|
@dbus.service.method('org.manjaro.pamac', '', 's', async_callbacks=('success', 'nosuccess'))
|
||||||
def Refresh(self):
|
def Refresh(self, success, nosuccess):
|
||||||
global t
|
def refresh():
|
||||||
self.error = ''
|
self.target = ''
|
||||||
for db in config.handle.get_syncdbs():
|
self.percent = 0
|
||||||
try:
|
self.error = ''
|
||||||
t = config.handle.init_transaction()
|
for db in config.handle.get_syncdbs():
|
||||||
db.update(force=False)
|
try:
|
||||||
t.release()
|
self.t = config.handle.init_transaction()
|
||||||
except pyalpm.error as e:
|
db.update(force=False)
|
||||||
self.error += ' --> '+str(e)+'\n'
|
except pyalpm.error as e:
|
||||||
t.release()
|
self.error += ' --> '+str(e)+'\n'
|
||||||
#break
|
#break
|
||||||
self.CheckUpdates()
|
finally:
|
||||||
return self.error
|
self.t.release()
|
||||||
|
self.CheckUpdates()
|
||||||
|
if self.error:
|
||||||
|
self.EmitTransactionError(self.error)
|
||||||
|
self.task = Process(target=refresh)
|
||||||
|
self.task.start()
|
||||||
|
success('')
|
||||||
|
|
||||||
@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
|
|
||||||
self.error = ''
|
self.error = ''
|
||||||
if self.policykit_test(sender,connexion,'org.manjaro.pamac.init_release'):
|
if self.policykit_test(sender,connexion,'org.manjaro.pamac.init_release'):
|
||||||
try:
|
try:
|
||||||
t = config.handle.init_transaction(**options)
|
self.t = config.handle.init_transaction(**options)
|
||||||
print('Init:',t.flags)
|
print('Init:',self.t.flags)
|
||||||
except pyalpm.error as e:
|
except pyalpm.error as e:
|
||||||
self.error += ' --> '+str(e)+'\n'
|
self.error += ' --> '+str(e)+'\n'
|
||||||
finally:
|
finally:
|
||||||
@ -217,11 +225,10 @@ class PamacDBusService(dbus.service.Object):
|
|||||||
|
|
||||||
@dbus.service.method('org.manjaro.pamac', '', 's')
|
@dbus.service.method('org.manjaro.pamac', '', 's')
|
||||||
def Sysupgrade(self):
|
def Sysupgrade(self):
|
||||||
global t
|
|
||||||
self.error = ''
|
self.error = ''
|
||||||
try:
|
try:
|
||||||
t.sysupgrade(downgrade=False)
|
self.t.sysupgrade(downgrade=False)
|
||||||
print('to_upgrade:',t.to_add)
|
print('to_upgrade:',self.t.to_add)
|
||||||
except pyalpm.error as e:
|
except pyalpm.error as e:
|
||||||
self.error += ' --> '+str(e)+'\n'
|
self.error += ' --> '+str(e)+'\n'
|
||||||
finally:
|
finally:
|
||||||
@ -229,12 +236,11 @@ class PamacDBusService(dbus.service.Object):
|
|||||||
|
|
||||||
@dbus.service.method('org.manjaro.pamac', 's', 's')
|
@dbus.service.method('org.manjaro.pamac', 's', 's')
|
||||||
def Remove(self, pkgname):
|
def Remove(self, pkgname):
|
||||||
global t
|
|
||||||
self.error = ''
|
self.error = ''
|
||||||
try:
|
try:
|
||||||
pkg = config.handle.get_localdb().get_pkg(pkgname)
|
pkg = config.handle.get_localdb().get_pkg(pkgname)
|
||||||
if pkg is not None:
|
if pkg is not None:
|
||||||
t.remove_pkg(pkg)
|
self.t.remove_pkg(pkg)
|
||||||
except pyalpm.error as e:
|
except pyalpm.error as e:
|
||||||
self.error += ' --> '+str(e)+'\n'
|
self.error += ' --> '+str(e)+'\n'
|
||||||
finally:
|
finally:
|
||||||
@ -242,13 +248,12 @@ class PamacDBusService(dbus.service.Object):
|
|||||||
|
|
||||||
@dbus.service.method('org.manjaro.pamac', 's', 's')
|
@dbus.service.method('org.manjaro.pamac', 's', 's')
|
||||||
def Add(self, pkgname):
|
def Add(self, pkgname):
|
||||||
global t
|
|
||||||
self.error = ''
|
self.error = ''
|
||||||
try:
|
try:
|
||||||
for repo in config.handle.get_syncdbs():
|
for repo in config.handle.get_syncdbs():
|
||||||
pkg = repo.get_pkg(pkgname)
|
pkg = repo.get_pkg(pkgname)
|
||||||
if pkg:
|
if pkg:
|
||||||
t.add_pkg(pkg)
|
self.t.add_pkg(pkg)
|
||||||
break
|
break
|
||||||
except pyalpm.error as e:
|
except pyalpm.error as e:
|
||||||
self.error += ' --> '+str(e)+'\n'
|
self.error += ' --> '+str(e)+'\n'
|
||||||
@ -257,12 +262,11 @@ class PamacDBusService(dbus.service.Object):
|
|||||||
|
|
||||||
@dbus.service.method('org.manjaro.pamac', '', 's')
|
@dbus.service.method('org.manjaro.pamac', '', 's')
|
||||||
def Prepare(self):
|
def Prepare(self):
|
||||||
global t
|
|
||||||
self.error = ''
|
self.error = ''
|
||||||
try:
|
try:
|
||||||
t.prepare()
|
self.t.prepare()
|
||||||
print('to_add:',t.to_add)
|
print('to_add:',self.t.to_add)
|
||||||
print('to_remove:',t.to_remove)
|
print('to_remove:',self.t.to_remove)
|
||||||
except pyalpm.error as e:
|
except pyalpm.error as e:
|
||||||
print(e)
|
print(e)
|
||||||
self.error += ' --> '+str(e)+'\n'
|
self.error += ' --> '+str(e)+'\n'
|
||||||
@ -271,48 +275,79 @@ class PamacDBusService(dbus.service.Object):
|
|||||||
|
|
||||||
@dbus.service.method('org.manjaro.pamac', '', 'as')
|
@dbus.service.method('org.manjaro.pamac', '', 'as')
|
||||||
def To_Remove(self):
|
def To_Remove(self):
|
||||||
global t
|
|
||||||
liste = []
|
liste = []
|
||||||
for pkg in t.to_remove:
|
for pkg in self.t.to_remove:
|
||||||
liste.append(pkg.name)
|
liste.append(pkg.name)
|
||||||
return liste
|
return liste
|
||||||
|
|
||||||
@dbus.service.method('org.manjaro.pamac', '', 'as')
|
@dbus.service.method('org.manjaro.pamac', '', 'as')
|
||||||
def To_Add(self):
|
def To_Add(self):
|
||||||
global t
|
|
||||||
liste = []
|
liste = []
|
||||||
for pkg in t.to_add:
|
for pkg in self.t.to_add:
|
||||||
liste.append(pkg.name)
|
liste.append(pkg.name)
|
||||||
return liste
|
return liste
|
||||||
|
|
||||||
@dbus.service.method('org.manjaro.pamac', '', 's', sender_keyword='sender', connection_keyword='connexion')#, async_callbacks=('success', 'nosuccess'))
|
@dbus.service.method('org.manjaro.pamac', '', 's', async_callbacks=('success', 'nosuccess'))
|
||||||
def Commit(self, sender=None, connexion=None):#success, nosuccess, sender=None, connexion=None):
|
def Interrupt(self, success, nosuccess):
|
||||||
global t
|
def interrupt():
|
||||||
self.error = ''
|
self.error = ''
|
||||||
if self.policykit_test(sender,connexion,'org.manjaro.pamac.commit'):
|
#try:
|
||||||
|
# self.t.interrupt()
|
||||||
|
#except pyalpm.error as e:
|
||||||
|
# self.error += ' --> '+str(e)+'\n'
|
||||||
try:
|
try:
|
||||||
t.commit()
|
self.t.release()
|
||||||
#success('')
|
#except pyalpm.error as e:
|
||||||
|
#self.error += ' --> '+str(e)+'\n'
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
finally:
|
||||||
|
self.CheckUpdates()
|
||||||
|
#if self.error:
|
||||||
|
#self.EmitTransactionError(self.error)
|
||||||
|
self.task.terminate()
|
||||||
|
interrupt()
|
||||||
|
success('')
|
||||||
|
|
||||||
|
@dbus.service.method('org.manjaro.pamac', '', 's', sender_keyword='sender', connection_keyword='connexion', async_callbacks=('success', 'nosuccess'))
|
||||||
|
def Commit(self, success, nosuccess, sender=None, connexion=None):
|
||||||
|
def commit():
|
||||||
|
self.error = ''
|
||||||
|
try:
|
||||||
|
self.t.commit()
|
||||||
except pyalpm.error as e:
|
except pyalpm.error as e:
|
||||||
#error = traceback.format_exc()
|
#error = traceback.format_exc()
|
||||||
self.error += ' --> '+str(e)+'\n'
|
self.error += ' --> '+str(e)+'\n'
|
||||||
#nosuccess(self.error)
|
|
||||||
#except dbus.exceptions.DBusException:
|
#except dbus.exceptions.DBusException:
|
||||||
#pass
|
#pass
|
||||||
finally:
|
finally:
|
||||||
self.CheckUpdates()
|
self.CheckUpdates()
|
||||||
return self.error
|
if self.error:
|
||||||
|
self.EmitTransactionError(self.error)
|
||||||
|
else:
|
||||||
|
self.EmitTransactionDone('Transaction successfully finished')
|
||||||
|
if self.policykit_test(sender,connexion,'org.manjaro.pamac.commit'):
|
||||||
|
self.task = Process(target=commit)
|
||||||
|
self.task.start()
|
||||||
else :
|
else :
|
||||||
return 'You are not authorized'
|
self.t.release()
|
||||||
#nosuccess('You are not authorized')
|
self.EmitTransactionError('You are not authorized')
|
||||||
|
success('')
|
||||||
|
|
||||||
|
@dbus.service.signal('org.manjaro.pamac')
|
||||||
|
def EmitTransactionDone(self, message):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@dbus.service.signal('org.manjaro.pamac')
|
||||||
|
def EmitTransactionError(self, message):
|
||||||
|
pass
|
||||||
|
|
||||||
@dbus.service.method('org.manjaro.pamac', '', 's', sender_keyword='sender', connection_keyword='connexion')
|
@dbus.service.method('org.manjaro.pamac', '', 's', sender_keyword='sender', connection_keyword='connexion')
|
||||||
def Release(self, sender=None, connexion=None):
|
def Release(self, sender=None, connexion=None):
|
||||||
global t
|
|
||||||
self.error = ''
|
self.error = ''
|
||||||
if self.policykit_test(sender,connexion,'org.manjaro.pamac.init_release'):
|
if self.policykit_test(sender,connexion,'org.manjaro.pamac.init_release'):
|
||||||
try:
|
try:
|
||||||
t.release()
|
self.t.release()
|
||||||
except pyalpm.error as e:
|
except pyalpm.error as e:
|
||||||
self.error += ' --> '+str(e)+'\n'
|
self.error += ' --> '+str(e)+'\n'
|
||||||
finally:
|
finally:
|
||||||
@ -322,13 +357,13 @@ class PamacDBusService(dbus.service.Object):
|
|||||||
|
|
||||||
@dbus.service.method('org.manjaro.pamac')
|
@dbus.service.method('org.manjaro.pamac')
|
||||||
def StopDaemon(self):
|
def StopDaemon(self):
|
||||||
global t
|
|
||||||
try:
|
try:
|
||||||
t.release()
|
self.t.release()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
mainloop.quit()
|
mainloop.quit()
|
||||||
|
|
||||||
|
GObject.threads_init()
|
||||||
DBusGMainLoop(set_as_default=True)
|
DBusGMainLoop(set_as_default=True)
|
||||||
myservice = PamacDBusService()
|
myservice = PamacDBusService()
|
||||||
mainloop = GObject.MainLoop()
|
mainloop = GObject.MainLoop()
|
||||||
|
@ -12,10 +12,11 @@ from pamac import config, common, transaction
|
|||||||
|
|
||||||
interface = Gtk.Builder()
|
interface = Gtk.Builder()
|
||||||
|
|
||||||
interface.add_from_file('/usr/share/pamac/gui/dialogs.glade')
|
#interface.add_from_file('/usr/share/pamac/gui/dialogs.glade')
|
||||||
ErrorDialog = interface.get_object('ErrorDialog')
|
#ErrorDialog = interface.get_object('ErrorDialog')
|
||||||
WarningDialog = interface.get_object('WarningDialog')
|
#WarningDialog = interface.get_object('WarningDialog')
|
||||||
QuestionDialog = interface.get_object('QuestionDialog')
|
#InfoDialog = interface.get_object('InfoDialog')
|
||||||
|
#QuestionDialog = interface.get_object('QuestionDialog')
|
||||||
|
|
||||||
interface.add_from_file('/usr/share/pamac/gui/manager.glade')
|
interface.add_from_file('/usr/share/pamac/gui/manager.glade')
|
||||||
ManagerWindow = interface.get_object("ManagerWindow")
|
ManagerWindow = interface.get_object("ManagerWindow")
|
||||||
@ -49,12 +50,10 @@ update_label = interface.get_object('update_label')
|
|||||||
def action_signal_handler(action):
|
def action_signal_handler(action):
|
||||||
if action:
|
if action:
|
||||||
progress_label.set_text(action)
|
progress_label.set_text(action)
|
||||||
#if 'Downloading' in action:
|
if ('Refreshing' in action) or ('Preparing' in action) or ('Downloading' in action) or ('Checking' in action) or ('Resolving' in action) or ('Loading' in action):
|
||||||
# print('cancel enabled')
|
ProgressCancelButton.set_visible(True)
|
||||||
# ProgressCancelButton.set_visible(True)
|
else:
|
||||||
#else:
|
ProgressCancelButton.set_visible(False)
|
||||||
ProgressCancelButton.set_visible(False)
|
|
||||||
#print('cancel disabled')
|
|
||||||
|
|
||||||
def icon_signal_handler(icon):
|
def icon_signal_handler(icon):
|
||||||
action_icon.set_from_file(icon)
|
action_icon.set_from_file(icon)
|
||||||
@ -275,6 +274,7 @@ def set_transaction_sum():
|
|||||||
def handle_error(error):
|
def handle_error(error):
|
||||||
global transaction_type
|
global transaction_type
|
||||||
global transaction_dict
|
global transaction_dict
|
||||||
|
ProgressWindow.hide()
|
||||||
if error:
|
if error:
|
||||||
if not 'DBus.Error.NoReply' in str(error):
|
if not 'DBus.Error.NoReply' in str(error):
|
||||||
print('error:', error)
|
print('error:', error)
|
||||||
@ -283,11 +283,7 @@ def handle_error(error):
|
|||||||
if response:
|
if response:
|
||||||
transaction.ErrorDialog.hide()
|
transaction.ErrorDialog.hide()
|
||||||
transaction.t_lock = False
|
transaction.t_lock = False
|
||||||
try:
|
transaction.Release()
|
||||||
transaction.Release()
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
ProgressWindow.hide()
|
|
||||||
if mode == 'manager':
|
if mode == 'manager':
|
||||||
transaction.to_add = []
|
transaction.to_add = []
|
||||||
transaction.to_remove = []
|
transaction.to_remove = []
|
||||||
@ -302,17 +298,17 @@ def handle_error(error):
|
|||||||
def handle_reply(reply):
|
def handle_reply(reply):
|
||||||
global transaction_type
|
global transaction_type
|
||||||
global transaction_dict
|
global transaction_dict
|
||||||
|
ProgressWindow.hide()
|
||||||
if reply:
|
if reply:
|
||||||
transaction.ErrorDialog.format_secondary_text(reply)
|
transaction.InfoDialog.format_secondary_text(reply)
|
||||||
response = transaction.ErrorDialog.run()
|
response = transaction.InfoDialog.run()
|
||||||
if response:
|
if response:
|
||||||
transaction.ErrorDialog.hide()
|
transaction.InfoDialog.hide()
|
||||||
transaction.t_lock = False
|
transaction.t_lock = False
|
||||||
try:
|
try:
|
||||||
transaction.Release()
|
transaction.Release()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
ProgressWindow.hide()
|
|
||||||
transaction.to_add = []
|
transaction.to_add = []
|
||||||
transaction.to_remove = []
|
transaction.to_remove = []
|
||||||
transaction_dict.clear()
|
transaction_dict.clear()
|
||||||
@ -327,6 +323,9 @@ def handle_reply(reply):
|
|||||||
if mode == 'manager':
|
if mode == 'manager':
|
||||||
do_sysupgrade()
|
do_sysupgrade()
|
||||||
|
|
||||||
|
bus.add_signal_receiver(handle_reply, dbus_interface = "org.manjaro.pamac", signal_name = "EmitTransactionDone")
|
||||||
|
bus.add_signal_receiver(handle_error, dbus_interface = "org.manjaro.pamac", signal_name = "EmitTransactionError")
|
||||||
|
|
||||||
def do_refresh():
|
def do_refresh():
|
||||||
"""Sync databases like pacman -Sy"""
|
"""Sync databases like pacman -Sy"""
|
||||||
if transaction.t_lock is False:
|
if transaction.t_lock is False:
|
||||||
@ -336,7 +335,7 @@ def do_refresh():
|
|||||||
ProgressWindow.show_all()
|
ProgressWindow.show_all()
|
||||||
while Gtk.events_pending():
|
while Gtk.events_pending():
|
||||||
Gtk.main_iteration()
|
Gtk.main_iteration()
|
||||||
transaction.Refresh(reply_handler = handle_reply, error_handler = handle_error, timeout = 2000*1000)
|
transaction.Refresh(reply_handler = handle_reply, error_handler = handle_error)#, timeout = 2000*1000)
|
||||||
|
|
||||||
def have_updates():
|
def have_updates():
|
||||||
do_syncfirst, updates = transaction.get_updates()
|
do_syncfirst, updates = transaction.get_updates()
|
||||||
@ -417,7 +416,7 @@ def finalize():
|
|||||||
ProgressWindow.show_all()
|
ProgressWindow.show_all()
|
||||||
while Gtk.events_pending():
|
while Gtk.events_pending():
|
||||||
Gtk.main_iteration()
|
Gtk.main_iteration()
|
||||||
transaction.Commit(reply_handler = handle_reply, error_handler = handle_error, timeout = 2000*1000)
|
transaction.Commit()#reply_handler = handle_reply, error_handler = handle_error, timeout = 2000*1000)
|
||||||
|
|
||||||
def check_conflicts(pkg_list):
|
def check_conflicts(pkg_list):
|
||||||
depends = [pkg_list]
|
depends = [pkg_list]
|
||||||
@ -801,7 +800,11 @@ class Handler:
|
|||||||
|
|
||||||
def on_ProgressCancelButton_clicked(self, *arg):
|
def on_ProgressCancelButton_clicked(self, *arg):
|
||||||
print('cancelled')
|
print('cancelled')
|
||||||
handle_reply('')
|
error = transaction.Interrupt()
|
||||||
|
if error:
|
||||||
|
handle_error(error)
|
||||||
|
else:
|
||||||
|
handle_reply('')
|
||||||
|
|
||||||
def main(_mode):
|
def main(_mode):
|
||||||
if common.pid_file_exists():
|
if common.pid_file_exists():
|
||||||
|
@ -24,7 +24,8 @@ interface = Gtk.Builder()
|
|||||||
interface.add_from_file('/usr/share/pamac/gui/dialogs.glade')
|
interface.add_from_file('/usr/share/pamac/gui/dialogs.glade')
|
||||||
ErrorDialog = interface.get_object('ErrorDialog')
|
ErrorDialog = interface.get_object('ErrorDialog')
|
||||||
WarningDialog = interface.get_object('WarningDialog')
|
WarningDialog = interface.get_object('WarningDialog')
|
||||||
QuestionDialog = interface.get_object('QuestionDialog')
|
#QuestionDialog = interface.get_object('QuestionDialog')
|
||||||
|
InfoDialog = interface.get_object('InfoDialog')
|
||||||
|
|
||||||
def get_handle():
|
def get_handle():
|
||||||
global handle
|
global handle
|
||||||
@ -57,6 +58,7 @@ Prepare = proxy.get_dbus_method('Prepare','org.manjaro.pamac')
|
|||||||
To_Remove = proxy.get_dbus_method('To_Remove','org.manjaro.pamac')
|
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')
|
||||||
|
Interrupt = proxy.get_dbus_method('Interrupt','org.manjaro.pamac')
|
||||||
Release = proxy.get_dbus_method('Release','org.manjaro.pamac')
|
Release = proxy.get_dbus_method('Release','org.manjaro.pamac')
|
||||||
StopDaemon = proxy.get_dbus_method('StopDaemon','org.manjaro.pamac')
|
StopDaemon = proxy.get_dbus_method('StopDaemon','org.manjaro.pamac')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user