Exemplo n.º 1
0
def addNote(caller,scroll,ar,plalts,target,fileid,dval = None,cval = None,i = 0):
  path = [fileid,"info","notes"]
  if not preRead(True,'l',path,3):
    return
  data = places.get(fileid)
  if i == 0:
    i = str(len(data['info'].get("notes")))
    path.append(i)
    if not preRead(True,'l',path,4):
      return
    else:
      places[path[0]][path[1]][path[2]][path[3]]['content'] = ["",False]
      places[path[0]][path[1]][path[2]][path[3]]['date'] = [skrTimeStamp(config['datestyle']),False]
  row = gtk.HBox()
  row.show()
  if not dval: dval = skrTimeStamp(config['datestyle'])
  date = gtk.Label(dval)
  date.show()
  date.set_width_chars(10)
  row.pack_end(date,0,0,2)
  content = gtk.Entry(500)
  content.show()
  if cval: content.set_text(cval)
  row.pack_end(content,1,1,2)
  target.pack_start(row,False,False,2)
  activateNoteEntry(content,ar,plalts, scroll, data, fileid,i,date)
Exemplo n.º 2
0
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
Exemplo n.º 3
0
def setGender(caller,fileid,key,ar,alts):
  global people
  if key != None and len(key) > 1:
    genderkeys = allGenders(1)
    key = genderkeys.get(key,'N')
    if config['debug'] > 3: print "new key: %s" % key
  if preRead(False,'p',[fileid,"info","gender"],2):
    people[fileid]['info']['gender'] = [key,True]
    people[fileid]['changed'] = True
    if config['debug'] > 2: print "New Gender: %s" % key
  else:
    bsay(None,"setGender: Could not set gender for %s." % fileid)
  if caller not in alts: alts.append(caller)
  caller.modify_base(gtk.STATE_NORMAL,gtk.gdk.color_parse(config['altcolor']))
  setRuletext(ar,len(alts))
Exemplo n.º 4
0
def setLoc(caller,fileid,key):
  global places
  lockeys = {}
  if len(key) > 1:
    lockeys = getCityList(1)
    key = lockeys.get(key,'N')
    lockeys = getCityList()
    if config['debug'] > 3: print "new key: %s" % key
    print "%s (%s), %s (%s)" % (lockeys[key][0],key,lockeys[key][2],lockeys[key][1])
    if preRead(False,'l',[fileid,"info"],2):
      places[fileid]['info']['locfile'] = [key,True]
      places[fileid]['info']['loc'] = [lockeys[key][0],True]
      places[fileid]['info']['statefile'] = [lockeys[key][1],True]
      places[fileid]['info']['state'] = [lockeys[key][2],True]
      places[fileid]['changed'] = True
      if config['debug'] > 0: print "New Loc: %s" % key
  else:
    bsay(None,"setLoc: Could not set loc for %s." % fileid)
Exemplo n.º 5
0
def toggleOrder(caller,fileid):
  global people
  global config
  rev = "fg"
  norm = "gf"
  if config['familyfirst']:
    norm = rev
    rev = "gf"
  if not preRead(True,'p',[fileid,"info"],2):
    return
  if caller.get_active():
    print "Name is now reversed!"
    people[fileid]['info']['nameorder'] = [rev,True]
    people[fileid]['changed'] = True
  else:
    print "Name is now normal!"
    people[fileid]['info']['nameorder'] = [norm,True]
    people[fileid]['changed'] = True
Exemplo n.º 6
0
def setState(caller, fileid, key):
    global cities
    statekeys = {}
    if len(key) > 1:
        statekeys = getStateList(1)
        key = statekeys.get(key, "N")
        statekeys = getStateList(0)
        if config["debug"] > 3:
            print "new key: %s" % key
        print "%s (%s)" % (statekeys[key], key)
        if preRead(False, "c", [fileid, "info"], 2):
            cities[fileid]["info"]["statefile"] = [key, True]
            cities[fileid]["info"]["state"] = [statekeys[key], True]
            cities[fileid]["changed"] = True
            #      if config['debug'] > 0: print "New State: %s" % key
            cityname = cities[fileid]["info"].get("name", None)
            if cityname:
                updateLocs(cityname[0], fileid, key)
    else:
        bsay(None, "setState: Could not set state for %s." % fileid)
Exemplo n.º 7
0
def selectConnectionL(caller,relation,fileid,relid,nameR,cat):
  global places
  nameL = ""
  try:
    name = [places[fileid]['info']['commonname'][0],places[fileid]['info']['name'][0]]
  except KeyError as e:
    print "selectConnectionL: An error occurred accessing %s: %s" % (fileid,e)
    return
  if len(name[0]) > 2:
    nameL = name[0]
  else:
    nameL = name[1]
  askbox = gtk.Dialog("Choose connection",None,gtk.DIALOG_DESTROY_WITH_PARENT,("Cancel",86))
  answers = {}
  options = getPlaceConnections(cat)
  for i in options.keys():
    answers[i] = options[i][0]
  optlist = []
  for key, value in sorted(answers.iteritems(), key=lambda (k,v): (v,k)):
    optlist.append(key)
  row = gtk.HBox()
  row.show()
  label = gtk.Label(nameL)
  label.show()
  label.set_width_chars(20)
  row.pack_start(label,True,True,1)
  label = gtk.Label(nameR)
  label.show()
  label.set_width_chars(20)
  row.pack_start(label,True,True,1)
  askbox.vbox.pack_start(row,True,True,1)
  sw = gtk.ScrolledWindow()
  sw.set_policy(gtk.POLICY_NEVER,gtk.POLICY_ALWAYS)
  sw.set_size_request(400,150)
  sw.show()
  box = gtk.VBox()
  box.show()
  askbox.vbox.pack_start(sw,True,True,1)
  sw.add_with_viewport(box)
  for key in optlist:
    if len(answers[key]) > 0:
      rid = len(answers)
      row = gtk.HBox()
      row.show()
      label = gtk.Label(options[key][1])
      label.show()
      label.set_width_chars(25)
      row.pack_start(label,True,True,1)
      button = gtk.Button(options[key][0])
      button.show()
      button.set_size_request(150,-1)
      button.connect("clicked",askBoxProcessor,askbox,int(key))
      row.pack_start(button,True,True,1)
      box.pack_start(row,True,True,1)
  width, height = askbox.get_size()
  askbox.move((gtk.gdk.screen_width() / 2) - (width / 2),(gtk.gdk.screen_height() / 2) - (height / 2))
  answers['86'] = ""
  answer = askbox.run()
  askbox.destroy()
  if answer < 0: answer = 86
  value = str(answer)
  if len(value) < 2: # Expect 2
    return
  if not preRead(True,'l',[fileid,'relat',relid],3): # This should have been here already.
    return
  if value == "86": return # Cancel
  places[fileid]['relat'][relid]['rtype'] = [options[value][2],True]
  places[fileid]['relat'][relid]['relation'] = [options[value][0],True]
  places[fileid]['relat'][relid]['cat'] = [cat,True]
  relation.set_text(places[fileid]['relat'][relid]['relation'][0])
Exemplo n.º 8
0
def selectConnectionP(caller,relation,fileid,relid,nameR,cat,genderR = 'N',genderP = 'N'):
  global people
  rl = len(str(genderR))
  pl = len(str(genderP))
  if rl > 1 or pl > 1:
    if config['debug'] > 5: print "Received R: %s P: %s" % (genderR,genderP)
    print "Gender must be a single character: Attempting to convert."
    choices = allGenders(1)
    if rl > 1:
      genderR = choices.get(genderR,'N')
    if pl > 1:
      genderP = choices.get(genderP,'N')
  nameP = ""
  try:
    name = [people[fileid]['info']['commonname'][0],people[fileid]['info']['gname'][0],people[fileid]['info']['fname'][0]]
  except KeyError as e:
    print "selectConnectionP: An error occurred accessing %s: %s" % (fileid,e)
    return
  if len(name[0]) > 2:
    nameP = name[0]
  elif config['familyfirst']:
    nameP = name[2] + " " + name[1]
  else:
    nameP = name[1] + " " + name[2]
  askbox = gtk.Dialog("Choose connection",None,gtk.DIALOG_DESTROY_WITH_PARENT,("Cancel",86))
  answers = {}
  options = getPersonConnections(cat,str(genderR),str(genderP))
  for i in options.keys():
    answers[i] = options[i][0]
  optlist = []
  for key, value in sorted(answers.iteritems(), key=lambda (k,v): (v,k)):
    optlist.append(key)
  row = gtk.HBox()
  row.show()
  label = gtk.Label(nameP)
  label.show()
  label.set_width_chars(20)
  row.pack_start(label,True,True,1)
  label = gtk.Label(nameR)
  label.show()
  label.set_width_chars(20)
  row.pack_start(label,True,True,1)
  askbox.vbox.pack_start(row,True,True,1)
  sw = gtk.ScrolledWindow()
  sw.set_policy(gtk.POLICY_NEVER,gtk.POLICY_ALWAYS)
  sw.set_size_request(400,150)
  sw.show()
  box = gtk.VBox()
  box.show()
  askbox.vbox.pack_start(sw,True,True,1)
  sw.add_with_viewport(box)
  for key in optlist:
    if len(answers[key]) > 0:
      rid = len(answers)
      row = gtk.HBox()
      row.show()
      label = gtk.Label(options[key][1])
      label.show()
      label.set_width_chars(25)
      row.pack_start(label,True,True,1)
      button = gtk.Button(options[key][0])
      button.show()
      button.set_size_request(150,-1)
      button.connect("clicked",askBoxProcessor,askbox,int(key))
      row.pack_start(button,True,True,1)
      box.pack_start(row,True,True,1)
  width, height = askbox.get_size()
  askbox.move((gtk.gdk.screen_width() / 2) - (width / 2),(gtk.gdk.screen_height() / 2) - (height / 2))
  answers['86'] = ""
  answer = askbox.run()
  askbox.destroy()
  if answer < 0: answer = 86
  value = str(answer)
  if len(value) < 2: # Expect 2
    return
  if not preRead(True,'p',[fileid,'relat',relid],3): # This should have been here already.
    return
  if value == "86": return # Cancel
  people[fileid]['relat'][relid]['rtype'] = [options[value][2],True]
  people[fileid]['relat'][relid]['relation'] = [options[value][0],True]
  people[fileid]['relat'][relid]['cat'] = [cat,True]
  relation.set_text(people[fileid]['relat'][relid]['relation'][0])
Exemplo n.º 9
0
def preReadc(force,path,depth = 0,retries = 0):
  printStack(1)
  print "\t!!!\tUsing deprecated function\t!!!"
  return preRead(force,'c',path,depth,retries)