summaryrefslogtreecommitdiff
path: root/portato/gui/windows/update.py
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2008-09-02 13:01:17 +0200
committerRené 'Necoro' Neumann <necoro@necoro.net>2008-09-02 13:01:17 +0200
commitafa1de13f0576ace6dcbb0176490fd20922950cd (patch)
tree056a5fd646f53dfa83f2fe231ec0943747b15ffc /portato/gui/windows/update.py
parent02d96210d9102f0cdec95b4e0f595cbd8fdd1e10 (diff)
downloadportato-afa1de13f0576ace6dcbb0176490fd20922950cd.tar.gz
portato-afa1de13f0576ace6dcbb0176490fd20922950cd.tar.bz2
portato-afa1de13f0576ace6dcbb0176490fd20922950cd.zip
Switch from tabs to 4 spaces
Diffstat (limited to '')
-rw-r--r--portato/gui/windows/update.py188
1 files changed, 94 insertions, 94 deletions
diff --git a/portato/gui/windows/update.py b/portato/gui/windows/update.py
index e369c49..297f666 100644
--- a/portato/gui/windows/update.py
+++ b/portato/gui/windows/update.py
@@ -21,97 +21,97 @@ from ...helper import debug
class UpdateWindow (AbstractDialog):
- def __init__ (self, parent, packages, queue, jump_to):
- AbstractDialog.__init__(self, parent)
-
- self.queue = queue
- self.jump = jump_to
-
- self.packages = system.sort_package_list(packages)
-
- self.build_list()
-
- self.window.show_all()
-
- def build_list (self):
-
- store = gtk.ListStore(bool, str)
- self.view = self.tree.get_widget("packageList")
- self.view.set_model(store)
-
- cell = gtk.CellRendererText()
- tCell = gtk.CellRendererToggle()
- tCell.set_property("activatable", True)
- tCell.connect("toggled", self.cb_check_toggled) # emulate the normal toggle behavior ...
-
- self.view.append_column(gtk.TreeViewColumn(_("Enabled"), tCell, active = 0))
- self.view.append_column(gtk.TreeViewColumn(_("Package"), cell, text = 1))
-
- for p in self.packages:
- store.append([False, p.get_cpv()])
-
- def cb_set_size (self, *args):
- """
- This callback is called shortly before drawing.
- It calculates the optimal size of the window.
- The optimum is defined as: as large as possible w/o scrollbars
- """
-
- bb = self.tree.get_widget("updateBB")
- vals = (self.view.get_vadjustment().upper+bb.size_request()[1]+10, # max size of list + size of BB + constant
- self.parent.get_size()[1]) # size of the parent -> maximum size
- debug("Size values for the list and for the parent: %d / %d", *vals)
- val = int(min(vals))
- debug("Minimum value: %d", val)
- self.window.set_geometry_hints(self.window, min_height = val)
-
- def cb_select_all_clicked (self, btn):
- model = self.view.get_model()
- iter = model.get_iter_first()
-
- while iter:
- model.set_value(iter, 0, True)
- iter = model.iter_next(iter)
-
- return True
-
- def cb_install_clicked (self, btn):
- model = self.view.get_model()
- iter = model.get_iter_first()
- if iter is None: return
-
- items = []
- while iter:
- if model.get_value(iter, 0):
- items.append(model.get_value(iter, 1))
- iter = model.iter_next(iter)
-
- for item in items:
- try:
- try:
- self.queue.append(item, type = "install", oneshot = True)
- except PackageNotFoundException, e:
- if unmask_dialog(e[0]) == gtk.RESPONSE_YES :
- self.queue.append(item, type = "install", unmask = True, oneshot = True)
-
- except BlockedException, e:
- blocked_dialog(e[0], e[1])
-
- self.close()
- return True
-
- def cb_package_selected (self, view):
- sel = view.get_selection()
- store, it = sel.get_selected()
- if it:
- package = system.new_package(store.get_value(it, 1))
-
- self.jump(package.get_cp(), package.get_version())
-
- return True
-
- def cb_check_toggled (self, cell, path):
- # for whatever reason we have to define normal toggle behavior explicitly
- store = self.view.get_model()
- store[path][0] = not store[path][0]
- return True
+ def __init__ (self, parent, packages, queue, jump_to):
+ AbstractDialog.__init__(self, parent)
+
+ self.queue = queue
+ self.jump = jump_to
+
+ self.packages = system.sort_package_list(packages)
+
+ self.build_list()
+
+ self.window.show_all()
+
+ def build_list (self):
+
+ store = gtk.ListStore(bool, str)
+ self.view = self.tree.get_widget("packageList")
+ self.view.set_model(store)
+
+ cell = gtk.CellRendererText()
+ tCell = gtk.CellRendererToggle()
+ tCell.set_property("activatable", True)
+ tCell.connect("toggled", self.cb_check_toggled) # emulate the normal toggle behavior ...
+
+ self.view.append_column(gtk.TreeViewColumn(_("Enabled"), tCell, active = 0))
+ self.view.append_column(gtk.TreeViewColumn(_("Package"), cell, text = 1))
+
+ for p in self.packages:
+ store.append([False, p.get_cpv()])
+
+ def cb_set_size (self, *args):
+ """
+ This callback is called shortly before drawing.
+ It calculates the optimal size of the window.
+ The optimum is defined as: as large as possible w/o scrollbars
+ """
+
+ bb = self.tree.get_widget("updateBB")
+ vals = (self.view.get_vadjustment().upper+bb.size_request()[1]+10, # max size of list + size of BB + constant
+ self.parent.get_size()[1]) # size of the parent -> maximum size
+ debug("Size values for the list and for the parent: %d / %d", *vals)
+ val = int(min(vals))
+ debug("Minimum value: %d", val)
+ self.window.set_geometry_hints(self.window, min_height = val)
+
+ def cb_select_all_clicked (self, btn):
+ model = self.view.get_model()
+ iter = model.get_iter_first()
+
+ while iter:
+ model.set_value(iter, 0, True)
+ iter = model.iter_next(iter)
+
+ return True
+
+ def cb_install_clicked (self, btn):
+ model = self.view.get_model()
+ iter = model.get_iter_first()
+ if iter is None: return
+
+ items = []
+ while iter:
+ if model.get_value(iter, 0):
+ items.append(model.get_value(iter, 1))
+ iter = model.iter_next(iter)
+
+ for item in items:
+ try:
+ try:
+ self.queue.append(item, type = "install", oneshot = True)
+ except PackageNotFoundException, e:
+ if unmask_dialog(e[0]) == gtk.RESPONSE_YES :
+ self.queue.append(item, type = "install", unmask = True, oneshot = True)
+
+ except BlockedException, e:
+ blocked_dialog(e[0], e[1])
+
+ self.close()
+ return True
+
+ def cb_package_selected (self, view):
+ sel = view.get_selection()
+ store, it = sel.get_selected()
+ if it:
+ package = system.new_package(store.get_value(it, 1))
+
+ self.jump(package.get_cp(), package.get_version())
+
+ return True
+
+ def cb_check_toggled (self, cell, path):
+ # for whatever reason we have to define normal toggle behavior explicitly
+ store = self.view.get_model()
+ store[path][0] = not store[path][0]
+ return True