pamac-classic/pamac-update

61 lines
1.5 KiB
Plaintext
Raw Normal View History

2012-12-12 13:12:27 -03:00
#! /usr/bin/python
# -*-coding:utf-8 -*-
2012-12-12 13:12:27 -03:00
from gi.repository import Gtk, GdkPixbuf, Gdk
import pyalpm
from time import strftime, localtime
from os import geteuid
2012-12-24 11:42:49 -03:00
from backend import transaction
2012-12-12 13:12:27 -03:00
interface = Gtk.Builder()
interface.add_from_file('gui/pamac_update.glade')
interface.add_from_file('gui/dialogs.glade')
update_listore = interface.get_object('update_list')
top_label = interface.get_object('top_label')
def have_updates():
available_updates = transaction.get_updates()
2012-12-15 13:27:36 -03:00
update_listore.clear()
2012-12-24 11:42:49 -03:00
top_label.set_justify(Gtk.Justification.CENTER)
2012-12-12 13:12:27 -03:00
if not available_updates:
update_listore.append(["", ""])
2012-12-24 11:42:49 -03:00
top_label.set_markup("<big><b>No update available</b></big>")
2012-12-12 13:12:27 -03:00
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)])
2012-12-24 11:42:49 -03:00
top_label.set_markup("<big><b>Available updates</b></big>")
2012-12-12 13:12:27 -03:00
return True
class Handler:
2012-12-15 13:27:36 -03:00
def on_UpdateWindow_delete_event(self, *arg):
2012-12-12 13:12:27 -03:00
Gtk.main_quit()
def on_QuitButton_clicked(self, *arg):
Gtk.main_quit()
def on_ApplyButton_clicked(self, *arg):
2012-12-15 13:27:36 -03:00
transaction.do_sysupgrade()
have_updates()
2012-12-12 13:12:27 -03:00
def on_RefreshButton_clicked(self, *arg):
transaction.do_refresh()
have_updates()
def main():
2012-12-24 11:42:49 -03:00
have_updates()
2012-12-12 13:12:27 -03:00
interface.connect_signals(Handler())
2012-12-15 13:27:36 -03:00
UpdateWindow = interface.get_object("UpdateWindow")
UpdateWindow.show_all()
2012-12-12 13:12:27 -03:00
Gtk.main()
if __name__ == "__main__":
2012-12-15 13:27:36 -03:00
if geteuid() == 0:
transaction.do_refresh()
2012-12-12 13:12:27 -03:00
main()