use backend package

This commit is contained in:
guinux 2012-12-24 15:42:49 +01:00
parent faf0065468
commit 520648ac58
6 changed files with 12 additions and 19 deletions

0
backend/__init__.py Executable file
View File

View File

@ -6,7 +6,7 @@ from gi.repository import Gtk
import pyalpm import pyalpm
import traceback import traceback
import sys import sys
import config from backend import config
interface = Gtk.Builder() interface = Gtk.Builder()
interface.add_from_file('gui/dialogs.glade') interface.add_from_file('gui/dialogs.glade')
@ -299,6 +299,9 @@ def cb_event(ID, event, tupel):
if ID is 27: if ID is 27:
progress_label.set_text('Downloading '+format_size(total_size)) progress_label.set_text('Downloading '+format_size(total_size))
print('Downloading a file') print('Downloading a file')
if ID is 17:
progress_label.set_text('Checking signatures')
print('Checking signatures')
progress_bar.set_fraction(0.0) progress_bar.set_fraction(0.0)
progress_bar.set_text('') progress_bar.set_text('')
print(ID,event) print(ID,event)

View File

@ -142,12 +142,12 @@
<property name="width_request">250</property> <property name="width_request">250</property>
<property name="height_request">60</property> <property name="height_request">60</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="title" translatable="yes">Transaction progress</property> <property name="title" translatable="yes">Progress</property>
<property name="resizable">False</property> <property name="resizable">False</property>
<property name="window_position">center-on-parent</property> <property name="window_position">center-on-parent</property>
<property name="default_width">250</property> <property name="default_width">250</property>
<property name="default_height">60</property> <property name="default_height">60</property>
<signal name="delete-event" handler="on_ProgressWindow_delete_event" swapped="no"/> <property name="deletable">False</property>
<child> <child>
<object class="GtkBox" id="box7"> <object class="GtkBox" id="box7">
<property name="visible">True</property> <property name="visible">True</property>

View File

@ -8,9 +8,8 @@ import math
import sys import sys
from time import strftime, localtime from time import strftime, localtime
from os import geteuid from os import geteuid
import config
import transaction
import traceback import traceback
from backend import transaction, config
interface = Gtk.Builder() interface = Gtk.Builder()
interface.add_from_file('gui/pamac.glade') interface.add_from_file('gui/pamac.glade')
@ -187,9 +186,6 @@ def set_desc(pkg, style):
package_desc.append(['Backup files:', '\n'.join(["%s %s" % (md5, file) for (file, md5) in pkg.backup])]) package_desc.append(['Backup files:', '\n'.join(["%s %s" % (md5, file) for (file, md5) in pkg.backup])])
class Handler: class Handler:
def on_ProgressWindow_delete_event(self, *arg):
pass
def on_MainWindow_delete_event(self, *arg): def on_MainWindow_delete_event(self, *arg):
Gtk.main_quit() Gtk.main_quit()

View File

@ -6,8 +6,7 @@ from gi.repository import Gtk, GdkPixbuf, Gdk
import pyalpm import pyalpm
from time import strftime, localtime from time import strftime, localtime
from os import geteuid from os import geteuid
import config from backend import transaction
import transaction
interface = Gtk.Builder() interface = Gtk.Builder()
interface.add_from_file('gui/pamac_update.glade') interface.add_from_file('gui/pamac_update.glade')
@ -19,8 +18,10 @@ top_label = interface.get_object('top_label')
def have_updates(): def have_updates():
available_updates = transaction.get_updates() available_updates = transaction.get_updates()
update_listore.clear() update_listore.clear()
top_label.set_justify(Gtk.Justification.CENTER)
if not available_updates: if not available_updates:
update_listore.append(["", ""]) update_listore.append(["", ""])
top_label.set_markup("<big><b>No update available</b></big>")
return False return False
else: else:
for pkg in available_updates: for pkg in available_updates:
@ -28,6 +29,7 @@ def have_updates():
newversion = transaction.get_new_version_available(pkgname) newversion = transaction.get_new_version_available(pkgname)
pkgname = pkg.name+" "+newversion pkgname = pkg.name+" "+newversion
update_listore.append([pkgname, transaction.format_size(pkg.size)]) update_listore.append([pkgname, transaction.format_size(pkg.size)])
top_label.set_markup("<big><b>Available updates</b></big>")
return True return True
class Handler: class Handler:
@ -45,16 +47,8 @@ class Handler:
transaction.do_refresh() transaction.do_refresh()
have_updates() have_updates()
def on_ProgressWindow_delete_event(self, *arg):
pass
def main(): def main():
update = have_updates() have_updates()
top_label.set_justify(Gtk.Justification.CENTER)
if update is False:
top_label.set_markup("<big><b>No update available</b></big>")
else:
top_label.set_markup("<big><b>Available updates</b></big>")
interface.connect_signals(Handler()) interface.connect_signals(Handler())
UpdateWindow = interface.get_object("UpdateWindow") UpdateWindow = interface.get_object("UpdateWindow")
UpdateWindow.show_all() UpdateWindow.show_all()