diff --git a/gui/dialogs.glade b/gui/dialogs.glade
index 4b71a08..f7bb8d3 100644
--- a/gui/dialogs.glade
+++ b/gui/dialogs.glade
@@ -6,9 +6,12 @@
5
False
+ True
center-on-parent
dialog
True
+ True
+ False
error
ok
@@ -39,12 +42,13 @@
False
Progress
False
- center
+ True
250
60
/usr/share/pamac/icons/22x22/status/setup.png
- True
+ dialog
False
+ False
diff --git a/gui/manager.glade b/gui/manager.glade
index 950f4b3..5f7bda4 100644
--- a/gui/manager.glade
+++ b/gui/manager.glade
@@ -4,11 +4,14 @@
False
- center
+ True
+ center-on-parent
350
250
/usr/share/pamac/icons/22x22/status/package-info.png
+ dialog
True
+ True
False
diff --git a/gui/updater.glade b/gui/updater.glade
index 610df60..401352b 100644
--- a/gui/updater.glade
+++ b/gui/updater.glade
@@ -4,11 +4,14 @@
False
- center
+ True
+ center-on-parent
350
250
/usr/share/pamac/icons/22x22/status/package-info.png
+ dialog
True
+ True
False
@@ -162,6 +165,21 @@
True
5
end
+
+
+ gtk-refresh
+ True
+ True
+ True
+ True
+
+
+
+ False
+ True
+ 0
+
+
gtk-apply
@@ -239,8 +257,8 @@
- 300
- 420
+ 400
+ 450
True
False
True
diff --git a/pamac/__init__.py b/pamac/__init__.py
old mode 100644
new mode 100755
diff --git a/pamac/common.py b/pamac/common.py
old mode 100644
new mode 100755
diff --git a/pamac/config.py b/pamac/config.py
old mode 100644
new mode 100755
diff --git a/pamac/manager.py b/pamac/manager.py
old mode 100644
new mode 100755
index fb6ebaf..02b5b93
--- a/pamac/manager.py
+++ b/pamac/manager.py
@@ -14,7 +14,7 @@ from pamac import config, common, transaction
interface = Gtk.Builder()
interface.add_from_file('/usr/share/pamac/gui/manager.glade')
-interface.add_from_file('/usr/share/pamac/gui/dialogs.glade')
+#interface.add_from_file('/usr/share/pamac/gui/dialogs.glade')
MainWindow = interface.get_object("MainWindow")
@@ -128,6 +128,7 @@ def refresh_packages_list():
def set_packages_list():
global list_dict
+ transaction.get_handle()
if list_dict == "search":
search_strings_list = search_entry.get_text().split()
set_list_dict_search(*search_strings_list)
@@ -246,6 +247,11 @@ def handle_error(error):
def handle_reply(reply):
global transaction_type
global transaction_dict
+ if str(reply):
+ transaction.ErrorDialog.format_secondary_text('Commit Error:\n'+str(reply))
+ response = transaction.ErrorDialog.run()
+ if response:
+ transaction.ErrorDialog.hide()
transaction.t_lock = False
transaction.Release()
transaction.ProgressWindow.hide()
@@ -257,24 +263,20 @@ def handle_reply(reply):
class Handler:
def on_MainWindow_delete_event(self, *arg):
+ transaction.StopDaemon()
if __name__ == "__main__":
Gtk.main_quit()
else:
MainWindow.hide()
def on_QuitButton_clicked(self, *arg):
+ transaction.StopDaemon()
if __name__ == "__main__":
Gtk.main_quit()
else:
MainWindow.hide()
def on_ValidButton_clicked(self, *arg):
- #if not geteuid() == 0:
- #transaction.ErrorDialog.format_secondary_text("You need to be root to run packages transactions")
- #response = transaction.ErrorDialog.run()
- #if response:
- #transaction.ErrorDialog.hide()
- #el
if not transaction_dict:
transaction.ErrorDialog.format_secondary_text("No package is selected")
response = transaction.ErrorDialog.run()
@@ -337,6 +339,8 @@ class Handler:
def on_TransValidButton_clicked(self, *arg):
ConfDialog.hide()
+ progress_label.set_text('Preparing...')
+ action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/setup.png')
while Gtk.events_pending():
Gtk.main_iteration()
if transaction_type is "remove":
diff --git a/pamac/pamac-daemon.py b/pamac/pamac-daemon.py
old mode 100644
new mode 100755
index 81faa5e..08d09c7
--- a/pamac/pamac-daemon.py
+++ b/pamac/pamac-daemon.py
@@ -18,12 +18,18 @@ class PamacDBusService(dbus.service.Object):
self.t = None
self.error = ''
self.warning = ''
- self.action = ''
- self.icon = ''
+ self.action = 'Preparing...'
+ self.icon = '/usr/share/pamac/icons/24x24/status/setup.png'
self.target = ''
self.percent = 0
self.total_size = 0
self.already_transferred = 0
+ config.handle.dlcb = self.cb_dl
+ config.handle.totaldlcb = self.totaldlcb
+ config.handle.eventcb = self.cb_event
+ config.handle.questioncb = self.cb_conv
+ config.handle.progresscb = self.cb_progress
+ config.handle.logcb = self.cb_log
@dbus.service.signal('org.manjaro.pamac')
def EmitAction(self, action):
@@ -116,7 +122,10 @@ class PamacDBusService(dbus.service.Object):
self.already_transferred += size
self.action = 'Downloading '+common.format_size(self.total_size)
self.target = _target
- self.percent = fraction
+ if fraction > 1:
+ self.percent = 0
+ else:
+ self.percent = fraction
self.icon = '/usr/share/pamac/icons/24x24/status/package-download.png'
else:
self.action = 'Refreshing...'
@@ -152,16 +161,10 @@ class PamacDBusService(dbus.service.Object):
global t
global error
error = ''
- config.handle.dlcb = self.cb_dl
- config.handle.totaldlcb = self.totaldlcb
- config.handle.eventcb = self.cb_event
- config.handle.questioncb = self.cb_conv
- config.handle.progresscb = self.cb_progress
- config.handle.logcb = self.cb_log
for db in config.handle.get_syncdbs():
try:
t = config.handle.init_transaction()
- db.update(force=True)
+ db.update(force=False)
print('refresh')
t.release()
except pyalpm.error:
@@ -175,12 +178,6 @@ class PamacDBusService(dbus.service.Object):
global error
if self.policykit_test(sender,connexion,'org.manjaro.pamac.init_release'):
error = ''
- config.handle.dlcb = self.cb_dl
- config.handle.totaldlcb = self.totaldlcb
- config.handle.eventcb = self.cb_event
- config.handle.questioncb = self.cb_conv
- config.handle.progresscb = self.cb_progress
- config.handle.logcb = self.cb_log
try:
t = config.handle.init_transaction(**options)
print('Init:',t.flags)
diff --git a/pamac/transaction.py b/pamac/transaction.py
old mode 100644
new mode 100755
index edf2334..52a8498
--- a/pamac/transaction.py
+++ b/pamac/transaction.py
@@ -19,6 +19,7 @@ ProgressWindow = interface.get_object('ProgressWindow')
progress_bar = interface.get_object('progressbar2')
progress_label = interface.get_object('progresslabel2')
action_icon = interface.get_object('action_icon')
+ProgressCancelButton = interface.get_object('ProgressCancelButton')
t_lock = False
do_syncfirst = False
@@ -26,6 +27,11 @@ list_first = []
to_remove = []
to_add = []
to_update = []
+handle = None
+
+def get_handle():
+ global handle
+ handle = config.pacman_conf.initialize_alpm()
DBusGMainLoop(set_as_default=True)
bus = dbus.SystemBus()
@@ -40,9 +46,16 @@ 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')
+StopDaemon = proxy.get_dbus_method('StopDaemon','org.manjaro.pamac')
def action_signal_handler(action):
progress_label.set_text(action)
+ #~ if 'Downloading' in action:
+ #~ print('cancel enabled')
+ #~ ProgressCancelButton.set_visible(True)
+ #~ else:
+ ProgressCancelButton.set_visible(False)
+ #~ print('cancel disabled')
def icon_signal_handler(icon):
action_icon.set_from_file(icon)
@@ -51,7 +64,10 @@ def target_signal_handler(target):
progress_bar.set_text(target)
def percent_signal_handler(percent):
- progress_bar.set_fraction(float(percent))
+ if percent == '0':
+ progress_bar.pulse()
+ else:
+ progress_bar.set_fraction(float(percent))
bus.add_signal_receiver(action_signal_handler, dbus_interface = "org.manjaro.pamac", signal_name = "EmitAction")
bus.add_signal_receiver(icon_signal_handler, dbus_interface = "org.manjaro.pamac", signal_name = "EmitIcon")
@@ -61,7 +77,7 @@ bus.add_signal_receiver(percent_signal_handler, dbus_interface = "org.manjaro.pa
def init_transaction(**options):
"Transaction initialization"
global t_lock
- error = Init(options)
+ error = Init(dbus.Dictionary(options, signature='sb'))
if not error:
t_lock = True
return True
@@ -78,7 +94,7 @@ def check_conflicts():
to_check = []
warning = ''
for pkgname in to_add:
- for repo in config.pacman_conf.initialize_alpm().get_syncdbs():
+ for repo in handle.get_syncdbs():
pkg = repo.get_pkg(pkgname)
if pkg:
to_check.append(pkg)
@@ -86,7 +102,7 @@ def check_conflicts():
for target in to_check:
if target.replaces:
for name in target.replaces:
- pkg = config.pacman_conf.initialize_alpm().get_localdb().get_pkg(name)
+ pkg = handle.get_localdb().get_pkg(name)
if pkg:
if not pkg.name in to_remove:
to_remove.append(pkg.name)
@@ -95,11 +111,11 @@ def check_conflicts():
warning = warning+pkg.name+' will be replaced by '+target.name
if target.conflicts:
for name in target.conflicts:
- pkg = config.pacman_conf.initialize_alpm().get_localdb().get_pkg(name)
+ pkg = handle.get_localdb().get_pkg(name)
if pkg:
if not pkg.name in to_remove:
to_remove.append(pkg.name)
- for installed_pkg in config.pacman_conf.initialize_alpm().get_localdb().pkgcache:
+ for installed_pkg in handle.get_localdb().pkgcache:
if installed_pkg.conflicts:
for name in installed_pkg.conflicts:
if name == target.name:
@@ -119,83 +135,49 @@ def get_to_add():
global to_add
to_add = To_Add()
-def finalize():
- global t_lock
- error = Prepare()
- if error:
- ErrorDialog.format_secondary_text(error)
- response = ErrorDialog.run()
- if response:
- ErrorDialog.hide()
- Release()
- t_lock = False
- else:
- ProgressWindow.show_all()
- while Gtk.events_pending():
- Gtk.main_iteration()
- Commit(reply_handler = handle_reply, error_handler = handle_error, timeout = 2000*1000)
-
-def handle_error(error):
- global t_lock
- global to_add
- global to_remove
- if not 'DBus.Error.NoReply' in str(error):
- ErrorDialog.format_secondary_text('Commit Error:\n'+str(error))
- response = ErrorDialog.run()
- if response:
- ErrorDialog.hide()
- t_lock = False
- Release()
- ProgressWindow.hide()
- to_add = []
- to_remove = []
-
-def handle_reply(reply):
- global t_lock
- global to_add
- global to_remove
- print('reply',reply)
- t_lock = False
- Release()
- ProgressWindow.hide()
- to_add = []
- to_remove = []
-
def do_refresh():
"""Sync databases like pacman -Sy"""
- global t
global t_lock
+ ProgressWindow.show_all()
+ print('show')
if t_lock is False:
- progress_label.set_text('Refreshing...')
- progress_bar.pulse()
- action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/refresh-cache.png')
- ProgressWindow.show_all()
t_lock = True
- Refresh(reply_handler = handle_reply, error_handler = handle_error, timeout = 2000*1000)
+ ProgressWindow.show_all()
+ error = Refresh(timeout = 2000*1000)
+ if error:
+ ErrorDialog.format_secondary_text(error)
+ response = ErrorDialog.run()
+ if response:
+ ErrorDialog.hide()
+ Release()
+ ProgressWindow.hide()
+ print('hide')
+ t_lock = False
def get_updates():
"""Return a list of package objects in local db which can be updated"""
global do_syncfirst
global list_first
+ get_handle()
if config.syncfirst:
for name in config.syncfirst:
- pkg = config.pacman_conf.initialize_alpm().get_localdb().get_pkg(name)
- candidate = pyalpm.sync_newversion(pkg, config.pacman_conf.initialize_alpm().get_syncdbs())
+ pkg = handle.get_localdb().get_pkg(name)
+ candidate = pyalpm.sync_newversion(pkg, handle.get_syncdbs())
if candidate:
list_first.append(candidate)
if list_first:
do_syncfirst = True
return list_first
result = []
- installed_pkglist = config.pacman_conf.initialize_alpm().get_localdb().pkgcache
+ installed_pkglist = handle.get_localdb().pkgcache
for pkg in installed_pkglist:
- candidate = pyalpm.sync_newversion(pkg, config.pacman_conf.initialize_alpm().get_syncdbs())
+ candidate = pyalpm.sync_newversion(pkg, handle.get_syncdbs())
if candidate:
result.append(candidate)
return result
def get_new_version_available(pkgname):
- for repo in config.pacman_conf.initialize_alpm().get_syncdbs():
+ for repo in handle.get_syncdbs():
pkg = repo.get_pkg(pkgname)
if pkg is not None:
return pkg.version
diff --git a/pamac/tray.py b/pamac/tray.py
old mode 100644
new mode 100755
diff --git a/pamac/updater.py b/pamac/updater.py
old mode 100644
new mode 100755
index 95048b0..d43f5e2
--- a/pamac/updater.py
+++ b/pamac/updater.py
@@ -10,7 +10,7 @@ from pamac import config, common, transaction
interface = Gtk.Builder()
interface.add_from_file('/usr/share/pamac/gui/updater.glade')
-interface.add_from_file('/usr/share/pamac/gui/dialogs.glade')
+#interface.add_from_file('/usr/share/pamac/gui/dialogs.glade')
UpdateWindow = interface.get_object("UpdateWindow")
@@ -49,7 +49,7 @@ def set_transaction_add():
bottom_label.set_markup('')
if transaction.to_add:
installed_name = []
- for pkg_object in config.handle.get_localdb().pkgcache:
+ for pkg_object in transaction.handle.get_localdb().pkgcache:
installed_name.append(pkg_object.name)
transaction.to_update = sorted(set(installed_name).intersection(transaction.to_add))
to_remove_from_add_name = sorted(set(transaction.to_update).intersection(transaction.to_add))
@@ -65,20 +65,59 @@ def set_transaction_add():
#bottom_label.set_markup('Total Download size: '+format_size(totaldlcb))
top_label.set_markup('Additionnal Transaction(s)')
+def finalize():
+ error = transaction.Prepare()
+ if error:
+ ErrorDialog.format_secondary_text(error)
+ response = ErrorDialog.run()
+ if response:
+ ErrorDialog.hide()
+ transaction.Release()
+ transaction.t_lock = False
+ else:
+ transaction.progress_label.set_text('Preparing...')
+ transaction.action_icon.set_from_file('/usr/share/pamac/icons/24x24/status/setup.png')
+ transaction.ProgressWindow.show_all()
+ while Gtk.events_pending():
+ Gtk.main_iteration()
+ transaction.Commit(reply_handler = handle_reply, error_handler = handle_error, timeout = 2000*1000)
+
+def handle_error(error):
+ if not 'DBus.Error.NoReply' in str(error):
+ transaction.ErrorDialog.format_secondary_text('Commit Error:\n'+str(error))
+ response = transaction.ErrorDialog.run()
+ if response:
+ transaction.ErrorDialog.hide()
+ transaction.t_lock = False
+ transaction.Release()
+ transaction.ProgressWindow.hide()
+ have_updates()
+
+def handle_reply(reply):
+ if str(reply):
+ transaction.ErrorDialog.format_secondary_text('Commit Error:\n'+str(reply))
+ response = transaction.ErrorDialog.run()
+ if response:
+ transaction.ErrorDialog.hide()
+ transaction.t_lock = False
+ transaction.Release()
+ transaction.ProgressWindow.hide()
+ have_updates()
+
def do_sysupgrade():
"""Upgrade a system like pacman -Su"""
if transaction.t_lock is False:
if transaction.do_syncfirst is True:
if transaction.init_transaction(recurse = True):
for pkg in transaction.list_first:
- transaction.t.add_pkg(pkg)
- transaction.to_remove = transaction.t.to_remove
- transaction.to_add = transaction.t.to_add
+ transaction.Add(pkg.name)
+ transaction.get_to_remove()
+ transaction.get_to_add()
set_transaction_add()
- if len(transaction_add) != 0:
+ if len(transaction.to_add) != 0:
ConfDialog.show_all()
else:
- transaction.t_finalize()
+ finalize()
transaction.do_syncfirst = False
transaction.list_first = []
else:
@@ -108,16 +147,18 @@ def do_sysupgrade():
if len(transaction_add) != 0:
ConfDialog.show_all()
else:
- transaction.t_finalize()
+ finalize()
class Handler:
def on_UpdateWindow_delete_event(self, *arg):
+ transaction.StopDaemon()
if __name__ == "__main__":
Gtk.main_quit()
else:
UpdateWindow.hide()
def on_QuitButton_clicked(self, *arg):
+ transaction.StopDaemon()
if __name__ == "__main__":
Gtk.main_quit()
else:
@@ -125,7 +166,6 @@ class Handler:
def on_ApplyButton_clicked(self, *arg):
do_sysupgrade()
- have_updates()
def on_RefreshButton_clicked(self, *arg):
transaction.do_refresh()
@@ -134,18 +174,24 @@ class Handler:
def on_TransCancelButton_clicked(self, *arg):
ConfDialog.hide()
transaction.t_lock = False
- transaction.t.release()
+ transaction.Release()
def on_TransValidButton_clicked(self, *arg):
ConfDialog.hide()
- transaction.t_finalize(t)
+ finalize()
+
+ def on_ProgressCancelButton_clicked(self, *arg):
+ transaction.t_lock = False
+ transaction.Release()
+ transaction.ProgressWindow.hide()
+ have_updates()
def main():
+ #transaction.do_refresh()
have_updates()
interface.connect_signals(Handler())
UpdateWindow.show_all()
if __name__ == "__main__":
- transaction.do_refresh()
main()
Gtk.main()