def mkPlace(callingWidget,fileid,tabs): global places if idExists(fileid,'l'): say("Existing fileid! Loading instead...") else: L = loadPlace(fileid) places[fileid] = {} places[fileid]['info'] = L[0] places[fileid]['relat'] = L[1] places[fileid]['changed'] = False places[fileid]['cat'] = 'l' saveThisL(callingWidget,fileid) displayPlace(callingWidget,fileid,tabs)
def addRelToBox(self,target,relid,fileid,tabs,scroll,ar,plalts): global places cat = relid[1] relid = relid[0] if cat == 'p': global people if preRead(True,'l',[fileid,"relat"],2): name = [] rels = {} nameperson = "" if not preRead(False,'l',[fileid,"relat",relid],3): if not preRead(False,'l',relid,1): pl = loadPlace(relid) inf = pl[0] try: inf.get("foo",None) except AttributeError: print "(l)addRelToBox: Load Error" return try: name = [inf['commonname'][0],inf["name"][0]] except KeyError as e: print "(l)addRelToBox: An error occurred accessing relation %s: %s" % (relid,e) return else: try: name = [people[relid]['info']['commonname'][0],people[relid]['info']['gname'][0],people[relid]['info']['fname'][0]] except KeyError as e: print "(l)addRelToBox: An error occurred accessing person %s: %s" % (relid,e) return if len(name[0]) > 2: nameperson = name[0] elif config['familyfirst']: nameperson = name[2] + " " + name[1] else: nameperson = name[1] + " " + name[2] places[fileid]['relat'][relid] = {} places[fileid]['relat'][relid]['file'] = [relid,True] places[fileid]['relat'][relid]['related'] = [nameperson,True] places[fileid]['relat'][relid]['relation'] = ["",False] # Add a dialog here places[fileid]['relat'][relid]['cat'] = [cat,True] places[fileid]['relat'][relid]['rtype'] = ["",False] # Perhaps all these things in one dialog places[fileid]['relat'][relid]['realm'] = ["",False] # Only write this one if user chooses a realm # Realm needs to be addressed in the DTD for XML files... not sure if it's hierarchically higher than relat or not, or if realm should just reference connections, rather than be part of their tree (people[fileid]['realm'][realm] = [list,of,relids]) places[fileid]['relat'][relid]['events'] = {} places[fileid]['changed'] = True listRel(target,ar,plalts,places[fileid]['relat'][relid],fileid,relid,scroll,tabs) else: bsay(self,"Not clobbering existing connection to %s!" % relid) return
def displayPlace(callingWidget,fileid, tabrow): global places plalts = [] ar = gtk.Label() warnme = False if places.get(fileid,None): tab = places[fileid].get("tab") if tab is not None: warnme = True if not config['duplicatetabs']: status.push(0,"'" + fileid + "' is Already open. Switching to existing tab instead of loading...") tabrow.set_current_page(tab) for i in range(len(tabrow)): if fileid == tabrow.get_tab_label_text(tabrow.get_nth_page(i)): tabrow.set_current_page(i) return # No need to load again. If revert needed, use a different function else: L = loadPlace(fileid) places[fileid] = {} places[fileid]['info'] = L[0] places[fileid]['relat'] = L[1] places[fileid]['changed'] = False places[fileid]['cat'] = 'l' displayStage1(tabrow,fileid,'l',saveThisL,showPlace,preClose,displayPlace,ar,plalts) tabrow.vbox.connect("destroy",tabdestroyed,fileid) tabrow.labeli = gtk.Label("Information") tabrow.labelr = gtk.Label("Connections") tabrow.vbox.ftabs.infpage = displayStage2(tabrow.vbox.ftabs,tabrow.labeli) tabrow.vbox.ftabs.relpage = displayStage2(tabrow.vbox.ftabs,tabrow.labelr) if config['debug'] > 2: print "Loading " + tabrow.get_tab_label_text(tabrow.vbox) ar.show() ar.set_alignment(0.5,0.5) setRuletext(ar,len(plalts)) tabrow.vbox.pack_end(ar,0,0,2) initLinfo(tabrow.vbox.ftabs.infpage, fileid,ar,plalts) initLrels(tabrow.vbox.ftabs.relpage, fileid,tabrow,ar,plalts) tabrow.set_current_page(tabrow.page_num(tabrow.vbox)) places[fileid]["tab"] = tabrow.page_num(tabrow.vbox)