Ejemplo n.º 1
0
def isOrderRev(fileid):
  global config
  norm = "gf"
  if config['familyfirst']: norm = "fg"
  value = getInf(people.get(fileid),["info","nameorder"])
  if value == norm or not value:
    return False
  else:
    return True
Ejemplo n.º 2
0
def saveThisP(caller,fileid):
  global status
  if people.get(fileid):
    if savePerson(fileid,people[fileid]):
      status.push(0,"%s saved successfully." % fileid)
    else:
      status.push(0,"Error encountered saving %s." % fileid)
  else:
    bsay(caller,"saveThisP: Could not find person %s." % fileid)
Ejemplo n.º 3
0
def preClose(caller,fileid,target = None):
  result = -8
  if people.get(fileid):
    if people[fileid].get("changed"):
      result = 0
      caller.set_sensitive(False)
      asker = gtk.MessageDialog(None,gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,gtk.MESSAGE_INFO,gtk.BUTTONS_YES_NO,None)
      asker.set_markup("Are you sure you want to close %s?\nYou will lose all unsaved changes." % fileid)
      asker.connect("destroy",lambda x: caller.set_sensitive(True))
      (x,y,w,h) = caller.get_allocation()
      asker.move(x - 50,y - 50)
      result = asker.run()
      asker.destroy()
  if result == -8: # Yes
    print "Destroying tab %s" % fileid
    kill(caller,target)
    return True
  else: # No
    print "Cancel"
    return False
Ejemplo n.º 4
0
def getCat(fileid):
  cat = None
  x = people.get(fileid,None)
  if x is not None: cat = "person"
  else:
    x = places.get(fileid,None)
    if x is not None: cat = "place"
    else:
      x = cities.get(fileid,None)
      if x is not None: cat = "city"
      else:
        x = states.get(fileid,None)
        if x is not None: cat = "state"
        else:
          x = orgs.get(fileid,None)
          if x is not None: cat = "org"
          else:
            x = items.get(fileid,None)
            if x is not None: cat = "item"
  return [cat,True]
Ejemplo n.º 5
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.º 6
0
def showPerson(caller,fileid):
  if people.get(fileid):
    printPretty(people[fileid])
Ejemplo n.º 7
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)
Ejemplo n.º 8
0
def initPinfo(self, fileid,ar,psalts):
  global people
  global config
  info = {}
  scroll = self.get_parent()
  try:
    info = people[fileid]['info']
  except KeyError as e:
    print "initPinfo: An error occurred accessing %s: %s" % (fileid,e)
    return
  scroll = self.get_parent()
  self.namelabelbox = gtk.HBox()
  self.namelabelbox.show()
  self.l1 = gtk.Label("Name:")
  self.l1.set_alignment(0,0)
  self.namelabelbox.pack_start(self.l1,1,1,2)
  self.nord = gtk.CheckButton("Order reversed")
  self.nord.show()
  self.nord.set_active(isOrderRev(fileid))
  self.nord.unset_flags(gtk.CAN_FOCUS)
  self.nord.connect("clicked",toggleOrder,fileid)
  self.namelabelbox.pack_start(self.nord,0,0,2)
  self.add(self.namelabelbox)
  self.namebox = gtk.HBox()
  self.namebox.set_border_width(2)
  self.add(self.namebox)
  self.namebox.show()
  self.l5 = gtk.Label("Title:")
  self.ctitle = gtk.Entry(5)
  self.l2 = gtk.Label("Family:")
  self.fname = gtk.Entry(25)
  activateInfoEntry(self.fname,ar,psalts,scroll,people.get(fileid),fileid,"fname")
  self.l3 = gtk.Label("Given:")
  self.gname = gtk.Entry(25)
  activateInfoEntry(self.gname,ar,psalts,scroll,people.get(fileid),fileid,"gname")
  self.l4 = gtk.Label("Middle/Maiden:")
  self.mname = gtk.Entry(25)
  activateInfoEntry(self.mname,ar,psalts,scroll,people.get(fileid),fileid,"mname")
  self.namebox.add(self.l5)
  self.namebox.add(self.ctitle)
  self.ctitle.set_width_chars(4)
  self.fname.set_width_chars(10)
  self.gname.set_width_chars(10)
  self.mname.set_width_chars(10)
  self.namebox.set_child_packing(self.ctitle,0,0,2,gtk.PACK_START)
  data = people.get(fileid)
  self.ctitle.set_text(getInf(data,["info","ctitle"]))
  self.ctitle.show()
  activateInfoEntry(self.ctitle,ar,psalts,scroll,people.get(fileid),fileid,"ctitle")
  if config['familyfirst'] == True:
    self.namebox.add(self.l2)
    self.namebox.add(self.fname)
  self.namebox.add(self.l3)
  self.namebox.add(self.gname)
  self.gname.set_text(getInf(data,["info","gname"]))
  self.gname.show()
  self.namebox.add(self.l4)
  self.namebox.add(self.mname)
  self.mname.set_text(getInf(data,["info","mname"]))
  if config['usemiddle'] == True:
    self.mname.show()
  if config['familyfirst'] == False:
    self.namebox.add(self.l2)
    self.namebox.add(self.fname)
  self.fname.set_text(getInf(data,["info","fname"]))
  self.fname.show()
  self.l1.show()
  self.l2.show()
  self.l3.show()
  self.l4.show()
  self.l5.show()
  self.cname = buildarow(scroll,"Common Name:",people.get(fileid),fileid,'commonname',ar,psalts,tooltip="Name commonly used to refer to this character\nShows at the top of the XSL template") # TODO: Some day, maybe move all these labels into a dict and generate these things algorithmically? What about sections?
  self.add(self.cname)
  self.nname = buildarow(scroll,"Nickname:",people.get(fileid),fileid,'nname',ar,psalts,tooltip="Something other characters call this one")
  self.add(self.nname)
  self.gender = buildGenderRow(scroll,people.get(fileid),fileid,ar,psalts)
  self.add(self.gender)
  self.bday = buildarow(scroll,"Birth Date:",people.get(fileid),fileid,'bday',ar,psalts,style=3,tooltip="Date of person's birth")
  self.add(self.bday)
  self.dday = buildarow(scroll,"Death Date:",people.get(fileid),fileid,'dday',ar,psalts,style=3,tooltip="Date of person's death")
  self.add(self.dday)
  self.l6 = gtk.Label("Stories")
  self.l6.set_alignment(0,0)
  self.l6.show()
  self.add(self.l6)
  self.s1 = gtk.HSeparator()
  self.add(self.s1)
  self.s1.show()
  self.stories = buildarow(scroll,"Stories:",people.get(fileid),fileid,'stories',ar,psalts,style=2,tooltip="Stories where this character appears")
  self.add(self.stories)
  storyDefault(self.stories.e,config['realmdir'])
  self.mention = buildarow(scroll,"First Mention:",people.get(fileid),fileid,'mention',ar,psalts,tooltip="In which (story:)scene does someone first mention this person?")
  self.add(self.mention)
  self.appearch = buildarow(scroll,"First appeared (chron):",people.get(fileid),fileid,'appear1ch',ar,psalts,tooltip="First scene where the person appeared, based on the scene's position in the story")
  self.add(self.appearch)
  self.appearwr = buildarow(scroll,"First appeared (writ):",people.get(fileid),fileid,'appear1wr',ar,psalts,tooltip="First scene where the person appeared, based on when the scene was written")
  self.add(self.appearwr)
  self.conflict = buildarow(scroll,"Conflict:",people.get(fileid),fileid,'conflict',ar,psalts,tooltip="What disputes does this person have with the protagonist, or on what issues do they disagree?")
  self.add(self.conflict)
  self.leadrel = buildarow(scroll,"Relation to lead:",people.get(fileid),fileid,'leadrel',ar,psalts,tooltip="What is this person's relationship to the protagonist/lead character?")
  self.add(self.leadrel)
  self.l7 = gtk.Label("Physical Appearance")
  self.l7.set_alignment(0,1)
  self.l7.show()
  self.add(self.l7)
  self.s2 = gtk.HSeparator()
  self.add(self.s2)
  self.s2.show()
  self.bodytyp = buildarow(scroll,"Body Type:",people.get(fileid),fileid,'bodytyp',ar,psalts,tooltip="Description of the person's body or general appearance")
  self.add(self.bodytyp)
  self.age = buildarow(scroll,"Age:",people.get(fileid),fileid,'age',ar,psalts,tooltip="How old is this person?")
  ageText(self.bday.e,self.dday.e,self.age)
  if config['hideage']: self.age.e.hide()
  self.add(self.age)
  self.skin = buildarow(scroll,"Skin:",people.get(fileid),fileid,'skin',ar,psalts,tooltip="Skin tone or type (e.g., light, dark, hairy, scaly)")
  self.add(self.skin)
  self.eyes = buildarow(scroll,"Eyes:",people.get(fileid),fileid,'eyes',ar,psalts,tooltip="Color, type, or attributes of the person's eyes")
  self.add(self.eyes)
  self.hair = buildarow(scroll,"Hair:",people.get(fileid),fileid,'hair',ar,psalts,tooltip="Color, amount, descriptions of the person's hair or fur")
  self.add(self.hair)
  self.dmarks = buildarow(scroll,"Distinguishing Marks:",people.get(fileid),fileid,'dmarks',ar,psalts,tooltip="Any markings that distinguish this person from others (birthmarks, scars, etc.)")
  self.add(self.dmarks)
  self.dress = buildarow(scroll,"Dress:",people.get(fileid),fileid,'dress',ar,psalts,tooltip="How does this person normally dress?")
  self.add(self.dress)
  self.attpos = buildarow(scroll,"Attached Possessions:",people.get(fileid),fileid,'attposs',ar,psalts,tooltip="What does this person usually have at hand?")
  self.add(self.attpos)
  self.asmell = buildarow(scroll,"Associated Smell:",people.get(fileid),fileid,'asmell',ar,psalts,tooltip="What smell(s) would others associate with this person?")
  self.add(self.asmell)
  self.l8 = gtk.Label("Personality Traits")
  self.l8.set_alignment(0,1)
  self.l8.show()
  self.add(self.l8)
  self.s3 = gtk.HSeparator()
  self.add(self.s3)
  self.s3.show()
  self.pers = buildarow(scroll,"Personality:",people.get(fileid),fileid,'personality',ar,psalts,tooltip="General description of personality")
  self.add(self.pers)
  self.speech = buildarow(scroll,"Distinct Speech:",people.get(fileid),fileid,'speech',ar,psalts,tooltip="Speech patterns that set this person apart")
  self.add(self.speech)
  self.formocc = buildarow(scroll,"Former Occupation:",people.get(fileid),fileid,'formocc',ar,psalts,style=1,tooltip="The person's previous job")
  self.add(self.formocc)
  self.curocc = buildarow(scroll,"Current Occupation:",people.get(fileid),fileid,'currocc',ar,psalts,style=1,tooltip="The person's current job or preoccupation")
  self.add(self.curocc)
  self.strength = buildarow(scroll,"Strengths:",people.get(fileid),fileid,'strength',ar,psalts,tooltip="What does this character do well or have as benefits?")
  self.add(self.strength)
  self.weak = buildarow(scroll,"Weakness:",people.get(fileid),fileid,'weak',ar,psalts,tooltip="What does this character do poorly, or what things keep this character from achieving goals easily?")
  self.add(self.weak)
  self.mole = buildarow(scroll,"Mole:",people.get(fileid),fileid,'mole',ar,psalts,)
  self.add(self.mole)
  self.hobby = buildarow(scroll,"Hobby:",people.get(fileid),fileid,'hobby',ar,psalts,tooltip="What does this character like to do with free time?")
  self.add(self.hobby)
  self.aspects = buildaspectrow(scroll,people.get(fileid),fileid,ar,psalts) # ,display = 0)
  self.add(self.aspects)
  self.l9 = gtk.Label("Miscellany")
  self.l9.set_alignment(0,1)
  self.l9.show()
  self.add(self.l9)
  self.s4 = gtk.HSeparator()
  self.add(self.s4)
  self.s4.show()
  self.misc = buildarow(scroll,"Misc:",people.get(fileid),fileid,'misc',ar,psalts,tooltip="Miscellaneous info") # make a textbox
  self.add(self.misc)
  self.ethnic = buildarow(scroll,"Ethnic background:",people.get(fileid),fileid,'ethnic',ar,psalts,tooltip="What kind of people are in this character's ancestry")
  self.add(self.ethnic)
  self.origin = buildarow(scroll,"Origin:",people.get(fileid),fileid,'origin',ar,psalts,tooltip="Where was this character born (or descended from)?")
  addLocButton(self.origin,0,entry=self.origin.e)
  self.add(self.origin)
  self.backs = buildarow(scroll,"Background:",people.get(fileid),fileid,'backstory',ar,psalts,tooltip="Major life events, experiences, training") # make a textbox someday?
  self.add(self.backs)
  self.residence = buildarow(scroll,"Place of residence:",people.get(fileid),fileid,'residence',ar,psalts,tooltip="Where the person lives")
  self.add(self.residence)
  self.minchar = buildarow(scroll,"Minor related characters:",people.get(fileid),fileid,'minchar',ar,psalts,tooltip="Related characters that are too minor to get a record")
  self.add(self.minchar)
  self.talent = buildarow(scroll,"Talents:",people.get(fileid),fileid,'talent',ar,psalts,tooltip="Inate gifts")
  self.add(self.talent)
  self.abil = buildarow(scroll,"Abilities:",people.get(fileid),fileid,'abil',ar,psalts,tooltip="Trained abilities") # textbox someday?
  self.add(self.abil)
  self.sgoal = buildarow(scroll,"Story goal:",people.get(fileid),fileid,'sgoal',ar,psalts,tooltip="What the person is trying to do in the current story")
  self.add(self.sgoal)
  self.other = buildarow(scroll,"Other notes:",people.get(fileid),fileid,'other',ar,psalts) # textbox someday
  self.add(self.other)
  el = gtk.Label("End of record")
  el.show()
  el.set_alignment(1,1)
  self.pack_start(el,0,0,3)
Ejemplo n.º 9
0
def buildaposition(scroll,data,fileid,key,ar,alts): #only applicable to people, but can't put it back in people because of circular import :(
  """Returns a GTK VBox containing the data values of the given position."""
  t = gtk.VBox()
  t.show()
  data2 = {}
  if data.get("info"): data2 = data["info"].get(key,{})
  value = data2.get("pos")
  if value: value = value[0]
  else:
    print "no data"
    return gtk.Label("Error: no data given to function")
  if data2.get("events"):
    rows = len(data2['events'])
#    t.addpos = gtk.Button("Add Position")
    t.addmile = gtk.Button("Add milestone")
    t.addmile.show()
    t.addmile.unset_flags(gtk.CAN_FOCUS)
    r = gtk.HBox()
    r.show()
    r.pack_end(t.addmile,False,False,2)
    if rows > 0:
      t.phead = gtk.Label("Position")
      t.phead.show()
      t.phead.set_width_chars(16)
      r.pack_start(t.phead,0,0,1)
      t.mhead = gtk.Label("Milestone")
      t.mhead.show()
      t.mhead.set_width_chars(18)
      r.pack_start(t.mhead,1,1,2)
      t.pack_start(r,False,False,1)
      r = gtk.HBox()
      r.show()
      rpos = gtk.Entry()
      extraargs = ["pos",]
      activateInfoEntry(rpos,ar,alts,scroll,data,fileid,key,len(extraargs),extraargs)
      rpos.show()
      rpos.set_tooltip_text("Title of position/job")
      rpos.set_text(value)
      rpos.set_width_chars(16)
      r.pack_start(rpos,0,0,2)
      t.dhead = gtk.Label("Date")
      t.dhead.show()
      t.dhead.set_width_chars(8)
      r.pack_start(t.dhead,1,1,2)
      t.ehead = gtk.Label("Event")
      t.ehead.show()
      t.ehead.set_width_chars(18)
      r.pack_start(t.ehead,1,1,2)
      t.pack_start(r,False,False,1)
      for i in range(rows):
        r = gtk.HBox()
        r.show()
        blank = gtk.Label()
        blank.set_width_chars(12)
        blank.show()
        r.pack_start(blank,0,0,2)
        value = data['info'][key]['events'][str(i)].get("date","")
        if value: value = value[0]
        rda = gtk.Entry()
        rda.set_tooltip_text("When did this milestone happen?")
        extraargs = ["events",str(i),"date"]
        activateInfoEntry(rda,ar,alts,scroll,data,fileid,key,len(extraargs),extraargs)
        rda.show()
        rda.set_width_chars(12)
        rda.set_text(value)
        r.pack_start(rda,1,1,2)
        datebut = gtk.Button()
        datebut.show()
        datebut.set_tooltip_text("Click to choose date from calendar")
        datebut.unset_flags(gtk.CAN_FOCUS)
        image = gtk.Image()
        image.set_from_file("img/date.png")
        datebut.set_image(image)
        cat = data.get("cat")
        path = [fileid,"info",key,"events",str(i),"date"]
        datebut.connect("clicked",dateChoose,rda,data,path)
        r.pack_start(datebut,0,0,2)
        value = getInf(data,["info",key,"events",str(i),"event"])
        rev = gtk.Entry()
        extraargs = ["events",str(i),"event"]
        activateInfoEntry(rev,ar,alts,scroll,people.get(fileid),fileid,key,len(extraargs),extraargs)
        rev.show()
        rev.set_width_chars(18)
        rev.set_text(value)
        rda.set_tooltip_text("What happened? (e.g., hired)")
        r.pack_start(rev,1,1,2)
        t.pack_start(r,False,False,1)
#        print str(t.size_request())
    (x,y,width,height) = r.get_allocation()
    t.addmile.connect("clicked",addMilestone,scroll,t,data,fileid,"info",key,width)
  return t