def merge (self, a, b):
if a == (): return self.build_tree (b)
if b == (): return a
if b[0] == a[0]:
if len (a) > 1 and isinstance (a[1], type (())):
return (a[0],) + (self.merge (a[1], b[1:]),) + a[2:]
elif b[1:] == (): return a
else: return (a[0],) + (self.build_tree (b[1:]),) + a[1:]
else:
return (a[0],) + self.merge (a[1:], b)
def select_icon (self, iconList, arg1, event, *args):
if event and event.type != GDK._2BUTTON_PRESS and event.type != GDK.BUTTON_PRESS:
return
icon_data = iconList.get_icon_data (arg1)
if not icon_data: return
if event and iconList.icon_is_visible (arg1) != VISIBILITY_FULL:
allocation = iconList.get_allocation ()
if (event.y - self.iconListAdj.value) < (allocation[3]/2):
self.iconList.moveto (arg1, 0.0)
else:
self.iconList.moveto (arg1, 1.0)
if event == None or event.type == GDK.BUTTON_PRESS:
if icon_data[0] == self.RPM:
header = icon_data[1]
# if we're already displaying the current package, don't redraw
if self.packageName.get () == "%s-%s-%s" % (header[rpm.RPMTAG_NAME],
header[rpm.RPMTAG_VERSION],
header[rpm.RPMTAG_RELEASE]):
return
if icon_data[0] == self.RPM:
active = self.cbutton.get_active ()
if active == TRUE:
self.cbutton.set_active (FALSE)
else:
self.cbutton.set_active (TRUE)
if icon_data[0] == self.DIR_UP:
current_node = icon_data[1].parent
if current_node:
self.ctree.select (current_node)
else:
# handle the imaginary root node
current_node = self.ctree.base_nodes ()[0]
self.ctree.unselect (icon_data[1])
self.draw_root_icons ()
try:
# this code is wrapped in a generic exception handler since we dont
# care if we access a namespace that lacks rpms
# drop the leading slash off the package namespace
for header in self.flat_groups[ctree.node_get_row_data (node)[1:]]:
if header.selected:
packageIcon = self.packageSelectedImage
self.cbutton.set_active (TRUE)
else:
packageIcon = self.packageImage
self.cbutton.set_active (FALSE)
# make sure that the iconList is reset to show the initial files in a dir,
# unless we re rebuilding the icons because one has been selected for install
if not self.updatingIcons:
self.iconListSW.get_vadjustment ().set_value (0.0)
self.iconList.thaw ()
self.iconList.show_all ()
def installButtonToggled (self, cbutton, *args):
if not self.currentPackage: return
oldSelectedStatus = self.currentPackage.selected
if cbutton.get_active ():
self.currentPackage.selected = 1
else:
self.currentPackage.selected = 0
# go through all the headers and grok out the group names, placing
# packages in lists in the groups dictionary.
for key in self.todo.hdList.packages.keys():
header = self.todo.hdList.packages[key]
if not groups.has_key (header[rpm.RPMTAG_GROUP]):
groups[header[rpm.RPMTAG_GROUP]] = []
groups[header[rpm.RPMTAG_GROUP]].append (header)
keys = groups.keys ()
keys.sort ()
self.flat_groups = groups
index = 0
# now insert the groups into the list, then each group s packages
# after sorting the list
def cmpHdrName(first, second):
if first[rpm.RPMTAG_NAME] < second[rpm.RPMTAG_NAME]:
return -1
elif first[rpm.RPMTAG_NAME] == second[rpm.RPMTAG_NAME]:
return 0
return 1
groups = ()
for key in keys:
self.flat_groups[key].sort (cmpHdrName)
groups = self.merge (groups, split (key, "/"))
self.ctree.freeze ()
self.build_ctree (groups)
for base_node in self.ctree.base_nodes ():
self.ctree.expand_recursive (base_node)
self.ctree.columns_autosize ()
for base_node in self.ctree.base_nodes ():
self.ctree.collapse_recursive (base_node)
self.ctree.thaw ()