diff --git a/backend/__init__.py b/backend/__init__.py
old mode 100755
new mode 100644
diff --git a/backend/config.py b/backend/config.py
old mode 100644
new mode 100755
diff --git a/backend/transaction.py b/backend/transaction.py
index 5c9945e..08aa98a 100755
--- a/backend/transaction.py
+++ b/backend/transaction.py
@@ -5,7 +5,7 @@ from gi.repository import Gtk
import pyalpm
import traceback
-import sys
+
from backend import config
interface = Gtk.Builder()
@@ -55,43 +55,30 @@ def init_transaction(handle, **options):
def check_conflicts():
global conflict_to_remove
conflict_to_remove = {}
- installed_conflicts = {}
- for pkg in config.handle.get_localdb().pkgcache:
- if pkg.conflicts:
- installed_conflicts[pkg.name] = pkg.conflicts
- targets_conflicts = {}
- targets_replaces = {}
- for pkg in t.to_add:
- if pkg.replaces:
- targets_replaces[pkg.name] = pkg.replaces
- if pkg.conflicts:
- targets_conflicts[pkg.name] = pkg.conflicts
warning = ''
- if targets_replaces:
- for key, value in targets_replaces.items():
- for name in value:
+ for target in t.to_add:
+ if target.replaces:
+ for name in target.replaces:
pkg = config.handle.get_localdb().get_pkg(name)
if pkg:
if not pkg.name in conflict_to_remove.keys():
conflict_to_remove[pkg.name] = pkg
if warning:
warning = warning+'\n'
- warning = warning+pkg.name+' will be replaced by '+key
- if targets_conflicts:
- for key, value in targets_conflicts.items():
- for name in value:
+ warning = warning+pkg.name+' will be replaced by '+target.name
+ if target.conflicts:
+ for name in target.conflicts:
pkg = config.handle.get_localdb().get_pkg(name)
if pkg:
if not pkg.name in conflict_to_remove.keys():
conflict_to_remove[pkg.name] = pkg
- if installed_conflicts:
- for key, value in installed_conflicts.items():
- for name in value:
- for pkg in t.to_add:
- if pkg.name == name:
- if not pkg.name in conflict_to_remove.keys():
- conflict_to_remove[pkg.name] = pkg
- if conflict_to_remove:
+ for installed_pkg in config.handle.get_localdb().pkgcache:
+ if installed_pkg.conflicts:
+ for name in installed_pkg.conflicts:
+ if name == target.name:
+ if not name in conflict_to_remove.keys():
+ conflict_to_remove[installed_pkg.name] = installed_pkg
+ if warning:
WarningDialog.format_secondary_text(warning)
response = WarningDialog.run()
if response:
@@ -101,7 +88,6 @@ def do_refresh():
"""Sync databases like pacman -Sy"""
global t
global t_lock
- ProgressWindow.show_all()
for db in config.handle.get_syncdbs():
if t_lock is False:
t = init_transaction(config.handle)
@@ -116,7 +102,6 @@ def do_refresh():
ErrorDialog.hide()
t_lock = False
break
- ProgressWindow.hide()
progress_label.set_text('')
progress_bar.set_text('')
@@ -164,7 +149,7 @@ def do_sysupgrade():
print("Nothing to update")
else:
t.release()
- t = init_transaction(config.handle, noconflicts = True, nodeps = True, nodepversion = True)
+ t = init_transaction(config.handle, noconflicts = True, nodeps = True)
for pkg in to_add:
t.add_pkg(pkg)
for pkg in conflict_to_remove.values():
@@ -188,6 +173,7 @@ def do_sysupgrade():
def t_finalize(t):
ConfDialog.hide()
+ ProgressWindow.show_all()
try:
t.prepare()
except pyalpm.error:
@@ -288,7 +274,6 @@ def set_transaction_desc(mode):
event_text = ' '
def cb_event(ID, event, tupel):
global event_text
- ProgressWindow.show_all()
while Gtk.events_pending():
Gtk.main_iteration()
if ID is 1:
@@ -334,10 +319,6 @@ _logmask = pyalpm.LOG_ERROR | pyalpm.LOG_WARNING
def cb_log(level, line):
#global t
- #try:
- # _line = str(_line, encoding='utf-8').strip("\n")
- #except:
- # _line = str(_line, encoding='latin-1').strip("\n")
if not (level & _logmask):
return
if level & pyalpm.LOG_ERROR:
@@ -357,7 +338,6 @@ def cb_log(level, line):
elif level & pyalpm.LOG_FUNCTION:
line = "FUNC: " + line
print(line)
- #sys.stderr.write(line)
total_size = 0
def totaldlcb(_total_size):
diff --git a/backend/tray.py b/backend/tray.py
new file mode 100755
index 0000000..828f855
--- /dev/null
+++ b/backend/tray.py
@@ -0,0 +1,51 @@
+#! /usr/bin/python
+# -*-coding:utf-8-*-
+
+from gi.repository import Gtk
+
+import transaction, update
+
+class Tray:
+ def __init__(self, icon, info):
+ self.icon = icon
+ self.info = info
+ self.statusIcon = Gtk.StatusIcon()
+ self.statusIcon.set_from_file(icon)
+ self.statusIcon.set_visible(True)
+ self.statusIcon.set_tooltip_markup(info)
+
+ self.menu = Gtk.Menu()
+ self.menuItem = Gtk.ImageMenuItem()
+ self.menuItem.seet_image('/usr/share/icons/hicolor/24x24/status/package-update.png')
+ self.menuItem.connect('activate', self.execute_cb, self.statusIcon)
+ self.menu.append(self.menuItem)
+ self.menuItem = Gtk.ImageMenuItem(Gtk.STOCK_QUIT)
+ self.menuItem.connect('activate', self.quit_cb, self.statusIcon)
+ self.menu.append(self.menuItem)
+
+ self.statusIcon.connect('popup-menu', self.popup_menu_cb, self.menu)
+ self.statusIcon.set_visible(1)
+
+ Gtk.main()
+
+ def execute_cb(self, widget, event, data = None):
+ update.main()
+
+ def quit_cb(self, widget, data = None):
+ Gtk.main_quit()
+
+ def popup_menu_cb(self, widget, button, time, data = None):
+ if button == 3:
+ if data:
+ data.show_all()
+ data.popup(None, None, Gtk.StatusIcon.position_menu, self.statusIcon, 3, time)
+
+if __name__ == "__main__":
+ updates = transaction.get_updates()
+ if updates:
+ icon = '/usr/share/icons/hicolor/24x24/status/update-normal.png'
+ info = str(len(updates))+' update(s) available'
+ else:
+ icon = '/usr/share/icons/hicolor/24x24/status/update-enhancement.png'
+ info = ' No update available'
+ tray = Tray(icon, info)
diff --git a/backend/update.py b/backend/update.py
new file mode 100755
index 0000000..5321bb8
--- /dev/null
+++ b/backend/update.py
@@ -0,0 +1,60 @@
+#! /usr/bin/python
+# -*-coding:utf-8 -*-
+
+from gi.repository import Gtk
+
+import pyalpm
+from os import geteuid
+
+from backend import transaction
+
+interface = Gtk.Builder()
+interface.add_from_file('/usr/share/pamac/pamac_update.glade')
+interface.add_from_file('/usr/share/pamac/dialogs.glade')
+
+update_listore = interface.get_object('update_list')
+top_label = interface.get_object('top_label')
+
+def have_updates():
+ available_updates = transaction.get_updates()
+ update_listore.clear()
+ top_label.set_justify(Gtk.Justification.CENTER)
+ if not available_updates:
+ update_listore.append(["", ""])
+ top_label.set_markup("No update available")
+ return False
+ else:
+ for pkg in available_updates:
+ pkgname = pkg.name
+ newversion = transaction.get_new_version_available(pkgname)
+ pkgname = pkg.name+" "+newversion
+ update_listore.append([pkgname, transaction.format_size(pkg.size)])
+ top_label.set_markup("Available updates")
+ return True
+
+class Handler:
+ def on_UpdateWindow_delete_event(self, *arg):
+ Gtk.main_quit()
+
+ def on_QuitButton_clicked(self, *arg):
+ Gtk.main_quit()
+
+ def on_ApplyButton_clicked(self, *arg):
+ transaction.do_sysupgrade()
+ have_updates()
+
+ def on_RefreshButton_clicked(self, *arg):
+ transaction.do_refresh()
+ have_updates()
+
+def main():
+ have_updates()
+ interface.connect_signals(Handler())
+ UpdateWindow = interface.get_object("UpdateWindow")
+ UpdateWindow.show_all()
+ Gtk.main()
+
+if __name__ == "__main__":
+ if geteuid() == 0:
+ transaction.do_refresh()
+ main()
diff --git a/gui/dialogs.glade b/gui/dialogs.glade
index 95526fa..955e61f 100644
--- a/gui/dialogs.glade
+++ b/gui/dialogs.glade
@@ -49,6 +49,7 @@