Ejemplo n.º 1
0
def mkPerson(callingWidget,fileid,tabs):
  global people
  if idExists(fileid,'p'):
    say("Existing fileid! Loading instead...")
  else:
    p = loadPerson(fileid)
    people[fileid] = {}
    people[fileid]['info'] = p[0]
    people[fileid]['relat'] = p[1]
    people[fileid]['changed'] = False
    people[fileid]['cat'] = 'p'
    saveThisP(callingWidget,fileid)
  displayPerson(callingWidget,fileid,tabs)
Ejemplo n.º 2
0
def addRelToBox(self,target,relid,fileid,tabs,scroll):
  global people
  cat = relid[1]
  relid = relid[0]
  if preRead(True,'p',[fileid,"relat"],2):
    name = []
    rels = {}
    nameperson = ""
    if not preRead(False,'p',[fileid,"relat",relid],3):
      if not preRead(False,'p',fileid,1):
        p = loadPerson(relid)
        inf = p[0]
        try:
          inf.get("foo",None)
        except AttributeError:
          print "addRelToBox: Load Error"
          return
        try:
          name = [inf['commonname'][0],inf['gname'][0],inf['fname'][0]]
        except KeyError as e:
          print "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 "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]
      people[fileid]['relat'][relid] = {}
      people[fileid]['relat'][relid]['related'] = [nameperson,True]
      people[fileid]['relat'][relid]['relation'] = ["",False] # Add a dialog here
      people[fileid]['relat'][relid]['cat'] = [cat,True]
      people[fileid]['relat'][relid]['rtype'] = ["",False] # Perhaps all these things in one dialog
      people[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])
      people[fileid]['relat'][relid]['events'] = {}
      listRel(target,people[fileid]['relat'][relid],fileid,relid,scroll,psalts,tabs)
    else:
      bsay(self,"Not clobbering existing connection to %s!" % relid)
      return
Ejemplo n.º 3
0
def displayPerson(callingWidget,fileid, tabrow):
  global people
  psalts = []
  ar = gtk.Label()
  warnme = False
  if people.get(fileid,None):
    tab = people[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:
    p = loadPerson(fileid)
    people[fileid] = {}
    people[fileid]['info'] = p[0]
    people[fileid]['relat'] = p[1]
    people[fileid]['changed'] = False
    people[fileid]['cat'] = 'p'
  displayStage1(tabrow,fileid,'p',saveThisP,showPerson,preClose,displayPerson,ar,psalts)
  tabrow.vbox.connect("destroy",tabdestroyed,fileid)
  tabrow.labeli = gtk.Label("Information")
  tabrow.labelr = gtk.Label("Relationships")
  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(psalts))
  tabrow.vbox.pack_end(ar,0,0,2)
  initPinfo(tabrow.vbox.ftabs.infpage, fileid,ar,psalts)
  initPrels(tabrow.vbox.ftabs.relpage, fileid,tabrow,ar,psalts)
  tabrow.set_current_page(tabrow.page_num(tabrow.vbox))
  people[fileid]["tab"] = tabrow.page_num(tabrow.vbox)
Ejemplo n.º 4
0
def listRel(self,r,fileid,relid,scroll,psalts,target = None):
  if not r.get("related"): return
  name = r['related'][0]
  if not r.get("cat"):
    print "empty category! Attempting to find...",
    x = getCat(relid)
    if x is not None:
      r['cat'] = x
      print r
    else:
      print "Not found!\nTo repair, open %s manually, and then reload %s." % (relid,fileid)
      return
    print '\n',
  cat = r['cat'][0]
  displayFunc = None
  if cat == "person":  displayFunc = displayPerson
  elif cat == "place": displayFunc = place.displayPlace
  else:
    print "Invalid category '%s' at listRel:%d!" % (cat,lineno())
    return
  if not target: target = self.get_parent().get_parent().get_parent().get_parent() #Which is better?
  namebutton = gtk.Button(relid)
  namebutton.connect("clicked",displayFunc,relid,target) # passing the target or figuring it from parentage?
  ### TODO: displayPerson? what about places/orgs?
  row1 = gtk.HBox()
  self.pack_start(row1,0,0,2)
  row1.pack_start(namebutton,1,1,2)
  row1.show()
  namebutton.show()
  namebutton.set_alignment(0.75,0.05)
  namebutton.set_size_request(int(self.size_request()[0] * 0.20),10)
  namelabel = gtk.Label("Name: ")
  namelabel.show()
  row1.pack_start(namelabel,0,0,2)
  namelabel.set_width_chars(6)
  nameentry = gtk.Entry()
  nameentry.show()
  nameentry.set_text(name)
  activateRelEntry(nameentry,psalts,scroll,people.get(fileid),fileid,relid,"related")
  row1.pack_start(nameentry,1,1)
  txt = r.get("relation")
  if txt is None:
    r['relation'] = ["",False]
    txt = ["",False]
  relation = gtk.Label(txt[0])
  relation.show()
  relation.set_width_chars(8)
  row1.pack_start(relation,1,1)
  relset = gtk.Button("Set")
  relset.show()
  relset.set_alignment(0.5,0.5)
  relset.set_size_request(36,24)
  data = people.get(relid,None)
  genderR = ""
  if data: genderR = getInf(data,["info","gender"])
  if not genderR or genderR == "":
    p = loadPerson(relid)
    genderR = p[0].get("gender",['N',False])
    genderR = genderR[0]
  genderP = getInf(people.get(fileid),["info","gender"])
  relset.connect("clicked",selectConnectionP,relation,fileid,relid,name,cat,genderR,genderP)
  row1.pack_start(relset,0,0,5)
  row2 = gtk.HBox()
  self.pack_start(row2,0,0,2)
  row2.show()
  mileadd = gtk.Button("New Milestone")
  mileadd.show()
  mileadd.set_alignment(0.75,0.05)
#  mileadd.set_size_request(int(self.size_request()[0] * 0.30),24)
  row2.pack_start(mileadd,0,0,5)
  dhead = gtk.Label("Date")
  dhead.show()
  dhead.set_width_chars(8)
  row2.pack_start(dhead,1,1,2)
  ehead = gtk.Label("Event")
  ehead.show()
  ehead.set_width_chars(18)
  row2.pack_start(ehead,1,1,2)
  row2.show_all()
  row3 = gtk.VBox()
  row3.show()
  self.pack_start(row3,0,0,2)
  boxwidth = self.size_request()[0]
  mileadd.connect("clicked",addMilestone,scroll,row3,people.get(fileid),fileid,"relat",relid,boxwidth)
  if r.get("events"):
    for i in r['events']:
#      showMile(row3,r,i,fileid,relid)

#def showMile(row3,r,i,fileid,relid):
      events = r['events'][i]
#  print str(events)
      if events.get("date") and events.get("event"):
        rowmile = gtk.HBox()
        rowmile.show()
        blank = gtk.Label()
        blank.show()
        blank.set_width_chars(12)
        rowmile.pack_start(blank,0,0,2)
        d = gtk.Entry()
        d.show()
        d.set_width_chars(12)
        d.set_text(events['date'][0])
        data = people.get(fileid)
        activateRelEntry(d,psalts,scroll,data,fileid,relid,"date",i)
        rowmile.pack_start(d,1,1,2)
        placeCalendarButton(data,rowmile,d,[fileid,"relat",relid,"events",i,"date"],psalts,counter=ar)
        e = gtk.Entry()
        e.show()
        e.set_width_chars(18)
        e.set_text(events['event'][0])
        activateRelEntry(e,psalts,scroll,data,fileid,relid,"event",i)
        rowmile.pack_start(e,1,1,2)
        row3.add(rowmile)