Example #1
0
def storyPicker(parent,name,value):
  global picklist
  global stories
  picklist = common.csplit(str(value))
  title = "Stories involving %s" % name
  if not len(stories):
    stories = myStories(config.get("realmdir"))
  askbox = gtk.Dialog(title,parent,gtk.DIALOG_DESTROY_WITH_PARENT,None)
  askbox.add_button("Cancel",1)
  askbox.add_button("Set",0)
  for key in sorted(stories.keys()):
    title = stories.get(key,"")
    if title and len(title) > 0:
      button = gtk.CheckButton(title)
      button.show()
      button.unset_flags(gtk.CAN_FOCUS)
      button.connect("toggled",updatePicklist,key)
      if not picklist: picklist = []
      if key in picklist:
        button.set_active(True)
      askbox.vbox.pack_start(button,True,True,2)
# OK button closes dialog, turns keys into a csv string and returns it (nondefined values, plus defined that are checked)
  askbox.move(config['pos'][0] + 50,config['pos'][1] + 50)
  value = askbox.run()
  askbox.destroy()
  if value == 0:
    output = ""
    for k in range(len(picklist)):
      if k > 0:
        output += ", "
      output += picklist[k]
    return output
  else:
    status.push(0,"Cancel: Stories not modified.")
  return None
Example #2
0
def storyEditor(caller,parent):
  global stories
  myStories(config['realmdir'])
#  print "Story editor"
  ed = gtk.Window(gtk.WINDOW_TOPLEVEL)
  ed.show()
  ed.set_transient_for(parent)
  ed.set_destroy_with_parent(True)
  ed.set_border_width(5)
  ed.vbox = gtk.VBox()
  ed.vbox.show()
  ed.add(ed.vbox)
  bar = gtk.HBox()
  bar.show()
  button = gtk.Button("Save List")
  button.show()
  button.connect("clicked",saveList,config['realmdir'])
  bar.pack_start(button,False,False,2)
  button = gtk.Button("Add Story")
  button.show()
  button.connect("clicked",addStoryRowNew,parent,ed,ed.vbox)
  bar.pack_start(button,True,True,2)
  button = gtk.Button("Close Editor")
  button.show()
  button.connect("clicked",common.kill,ed)
  bar.pack_start(button,False,False,2)
  ed.vbox.pack_start(bar,False,False,1)
  for key in sorted(stories.keys()):
    addStoryRow(parent,ed,ed.vbox,key,stories[key])
  refreshEd(parent,ed)