def internalize(data): id, root = data[0], internalize(data[1]) projects = filter(lambda x: x._id==id, root.projects) if projects: return projects[0] else: raise LookupError("Projects with id=%s not found" % id)
def _dragDataRecv(self, widget, context, x, y, data, info, timestamp): LOG.debug("GTK DnD data_recv with info=%d"%info) if info==INFO_PROJECTS_ATTRPATH.number: attrpath = pickle.loads(data.data) obj = internalize(attrpath) if obj!=None: # get canvas coordinates m = cairo.Matrix(*widget.matrix) m.invert() cx, cy = m.transform_point(x,y) # add item item = self.add(obj, cx,cy) context.drop_finish(True, timestamp) else: context.drop_finish(False, timestamp) else: context.drop_finish(False, timestamp)
def internalize(data): index, project = data[0], internalize(data[1]) return project.concepts[index]