Пример #1
0
def unlinkCity(caller,row,statef,cityf):
  global states
  caller.set_sensitive(False)
  path = [statef,"info","cities",cityf]
  if states.get(path[0]) is not None and states[path[0]].get(path[1]) is not None and states[path[0]][path[1]].get(path[2]) is not None and states[path[0]][path[1]][path[2]].get(path[3]) is not None:
    del states[path[0]][path[1]][path[2]][path[3]]
    states[path[0]]["changed"] = True
  # TODO: Also unlink from place record, if it's loaded
  kill(caller,row)
Пример #2
0
def saveThisS(caller,fileid):
  global status
  if states.get(fileid):
    pushLoc(fileid,states[fileid].get('name'))
    if saveState(fileid,states[fileid]):
      status.push(0,"%s saved successfully." % fileid)
    else:
      status.push(0,"Error encountered saving %s." % fileid)
  else:
    bsay(caller,"saveThisS: Could not find state %s." % fileid)
Пример #3
0
def pushCity(state,fi,name):
  global states
  if not states.get(state) or not states[state].get("info"):
    return False
  if not states[state]["info"].get("cities"):
    states[state]["info"]["cities"] = {}
  if not states[state]["info"]["cities"].get(fi):
    states[state]["info"]["cities"][fi] = {}
  states[state]["info"]["cities"][fi]["name"] = [name,True]
  return True
Пример #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]
Пример #5
0
def preClose(caller,fileid,target = None):
  result = -8
  if states.get(fileid):
    if states[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
Пример #6
0
def displayState(callingWidget,fileid, tabrow):
  global states
  stalts = []
  ar = gtk.Label()
  warnme = False
  if states.get(fileid,None):
    tab = states[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:
    states[fileid] = {}
    states[fileid]['info'] = loadState(fileid)
    states[fileid]['changed'] = False
    states[fileid]['cat'] = 's'
  displayStage1(tabrow,fileid,'s',saveThisS,showState,preClose,displayState,ar,stalts) # creates tabrow.vbox and tabrow.vbox.ftabs, et al
  tabrow.vbox.connect("destroy",tabdestroyed,fileid)
  tabrow.labeli = gtk.Label("Information")
  tabrow.vbox.ftabs.infpage = displayStage2(tabrow.vbox.ftabs,tabrow.labeli)
  tabrow.labelm = gtk.Label("Milestones")
  tabrow.vbox.ftabs.milepage = displayStage2(tabrow.vbox.ftabs,tabrow.labelm)
  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(stalts))
  tabrow.vbox.pack_end(ar,0,0,2)
  initSinfo(tabrow.vbox.ftabs.infpage, fileid,tabrow,ar,stalts)
  initSmile(tabrow.vbox.ftabs.milepage, fileid,tabrow,ar,stalts)
  tabrow.set_current_page(tabrow.page_num(tabrow.vbox))
  states[fileid]["tab"] = tabrow.page_num(tabrow.vbox)
Пример #7
0
def showState(caller,fileid):
  if states.get(fileid):
    printPretty(states[fileid])
Пример #8
0
def initSmile(self,fileid,tabs,ar,stalts):
  global states
  data = {}
  scroll = self.get_parent()
  try:
    data = states.get(fileid)
  except KeyError as e:
    print "initSmile: An error occurred accessing %s: %s" % (fileid,e)
    return
  row = gtk.HBox()
  row.show()
  self.pack_start(row,False,False,2)
  mileadd = gtk.Button("New Milestone")
  mileadd.show()
  mileadd.set_alignment(0.75,0.05)
  row.pack_start(mileadd,0,0,5)
  dhead = gtk.Label("Date")
  dhead.show()
  dhead.set_width_chars(8)
  row.pack_start(dhead,1,1,2)
  ehead = gtk.Label("Event")
  ehead.show()
  ehead.set_width_chars(18)
  row.pack_start(ehead,1,1,2)
  row.show_all()
  row2 = gtk.VBox()
  row2.show()
  self.pack_start(row2,1,1,2)
  boxwidth = self.size_request()[0]
  if not states[fileid]['info'].get("m"): states[fileid]['info']['m'] = {}
  r = states[fileid]['info'].get('m')
  if not states[fileid]['info']['m'].get("events"): states[fileid]['info']['m']['events'] = {}
  mileadd.connect("clicked",addMilestone,scroll,row2,states.get(fileid),fileid,"info","m",boxwidth)
  if r.get("events"):
    for i in sorted(r['events']):
#      showMile(row2,r,i,fileid,relid)

#def showMile(row2,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 = states.get(fileid)
        activateInfoEntry(d,ar,stalts,scroll,data,fileid,"m",3,["events",i,"date"])
        rowmile.pack_start(d,1,1,2)
        placeCalendarButton(data,rowmile,d,[fileid,"m","events",i,"date"],stalts,counter=ar)
        e = gtk.Entry()
        e.show()
        e.set_width_chars(18)
        e.set_text(events['event'][0])
        activateInfoEntry(e,scroll,data,fileid,"m",3,["events",i,"event"])
        rowmile.pack_start(e,1,1,2)
        row2.pack_start(rowmile,0,0,2)
  pass
# """
  el = gtk.Label("End of record")
  el.show()
  el.set_alignment(1,1)
  self.pack_start(el,0,0,3)
Пример #9
0
def initSinfo(self, fileid,tabs,ar,stalts):
  global states
  data = {}
  scroll = self.get_parent()
  try:
    data = states.get(fileid)
  except KeyError as e:
    print "initSinfo: An error occurred accessing %s: %s" % (fileid,e)
    return
  label = gtk.Label("General")
  label.set_alignment(0,0)
  label.show()
  self.pack_start(label,0,0,1)
  self.s1 = gtk.HSeparator()
  self.pack_start(self.s1,False,False,2)
  self.s1.show()
  name = buildarow(scroll,"Name:",data,fileid,'name',ar,stalts)
  self.pack_start(name,0,0,2)
  row = gtk.HBox()
  row.show()
  path = ["info","start"]
  label = gtk.Label("Start Date:")
  label.show()
  row.pack_start(label,False,False,2)
  start = gtk.Entry(25)
  start.show()
  start.set_text(getInf(data,path))
  activateInfoEntry(start,ar,stalts,scroll,data,fileid,"start")
  row.pack_start(start,True,True,2)
  path2 = [fileid,"info"]
  path2.append(path[-1])
  placeCalendarButton(data,row,start,path2,stalts,counter=ar)
  label = gtk.Label("Cue:")
  label.show()
  row.pack_start(label,False,False,2)
  scue = gtk.Entry(25)
  scue.show()
  path[1] = "scue"
  scue.set_text(getInf(data,path))
  activateInfoEntry(scue,ar,stalts,scroll,data,fileid,"scue")
  row.pack_start(scue,True,True,2)
  self.pack_start(row,False,False,2)
  row = gtk.HBox()
  row.show()
  label = gtk.Label("End Date:")
  label.show()
  row.pack_start(label,False,False,2)
  end = gtk.Entry(25)
  end.show()
  path[1] = "end"
  end.set_text(getInf(data,path))
  activateInfoEntry(end,ar,stalts,scroll,data,fileid,"end")
  row.pack_start(end,True,True,2)
  path2 = [fileid,"info"]
  path2.append(path[-1])
  placeCalendarButton(data,row,end,path2,stalts,counter=ar)
  label = gtk.Label("Cue:")
  label.show()
  row.pack_start(label,False,False,2)
  ecue = gtk.Entry(25)
  ecue.show()
  path[1] = "ecue"
  ecue.set_text(getInf(data,path))
  activateInfoEntry(ecue,ar,stalts,scroll,data,fileid,"ecue")
  row.pack_start(ecue,True,True,2)
  self.pack_start(row,False,False,2)
  '''
	Vitals:
		State (i.e., empire, kingdom, republic, grand tribe)
		Adjective (Florida businesses)
		People (Floridians)
		Head of state (Governor)
		Capital (Tallahassee)
		Population
		Major resources
	Politics:
		Capital governance
		Foreign relations
		Organization (general)
	Culture
		Expected behaviors
		Rumors
	History
	Geography
	Economy
	Demographics
'''
  self.aspects = buildaspectrow(scroll,states.get(fileid),fileid,ar,stalts) # ,display = 0)
  self.add(self.aspects)
  self.notebox = gtk.VBox()
  self.notebox.show()
  self.pack_start(self.notebox,True,False,2)
  label = gtk.Label("Cities")
  label.set_alignment(0,0)
  label.show()
  self.notebox.pack_start(label,0,0,1)
  s1 = gtk.HSeparator()
  self.notebox.pack_start(s1,False,False,2)
  s1.show()
  box = gtk.HBox()
  box.show()
  addbut = gtk.Button("Register City")
  image = gtk.Image()
  image.set_from_file("img/add.png")
  image.show()
  addbut.set_image(image)
  addbut.show()
  path = ["info","cities"]
  statename = getInf(data,["info","name"],"")
  statecities = getInf(data,path,{})
  for c in statecities.keys():
    fi = c
    cityname = getInf(statecities,[fi,"name"],"")
    pushLoc(fileid,statename,fi,cityname)
  cbook = getCitiesIn(fileid)
  addbut.connect("clicked",chooseCity,self.notebox,tabs,scroll,data,fileid,ar,stalts,"Register in %s..." % statename)
  box.pack_end(addbut,False,False,1)
  self.notebox.pack_start(box,False,False,1)
  for c in sorted(cbook.keys()):
    if c != "_name":
      newcity = False
      cityname = cbook[c].get('_name',cbook.get(c,None))
      if c not in statecities.keys():
        newcity = True
        pushCity(fileid,c,cityname)
      if cityname is not None:
        packCity(self.notebox,scroll,data,fileid,c,cityname,tabs,newcity,ar,stalts)
      else:
        common.say("Error getting cityname.")
  el = gtk.Label("End of record")
  el.show()
  el.set_alignment(1,1)
  self.pack_start(el,0,0,3)