예제 #1
0
파일: person.py 프로젝트: over2sd/minette
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))
예제 #2
0
파일: person.py 프로젝트: over2sd/minette
def buildGenderRow(scroll,data,fileid,ar,alts,display = 0):
  row = gtk.HBox()
  row.show()
  label = gtk.Label("Gender:")
  label.show()
  label
  row.pack_start(label,False,False,2)
  label.set_width_chars(20)
  label.set_alignment(1,0.5)
  choices = allGenders()
  path = ["info","gender"]
  g = getInf(data,path)
  if display == 1:
    radio = gtk.VBox()
    radio.show()
    row.pack_start(radio,True,True,2)
    group = None
    for key in sorted(choices.keys()):
      rbut = gtk.RadioButton(group,choices[key])
      rbut.connect("clicked",setGender,fileid,key,ar,alts)
      if config['debug'] > 5: print "%s : %s : %s" % (g,key,choices[key])
      if g == key or g == choices[key]:
        rbut.set_active(True)
      rbut.show()
      group = rbut
      radio.pack_start(rbut,False,False,2)
  else:
#    gender = gtk.ComboBoxText()
    gender = gtk.combo_box_new_text()
    gender.show()
    selected = -1
    keys = []
    i = 0
    for key in sorted(choices.keys()):
      gender.append_text(choices[key])
      keys.append(key)
      if g == key or g == choices[key]:
        selected = i
      i += 1
    gender.set_active(selected)
    gender.connect("changed",setGenderCombo,None,fileid,ar,alts) # move-action sends an event, so must fill its place when change sends without one
    gender.connect("move-active",setGenderCombo,fileid,ar,alts)
    gender.connect("focus",scrollOnTab,scroll)
    gender.connect("focus-in-event",scrollOnTab,scroll)
    row.pack_start(gender,True,True,2)
  return row
예제 #3
0
파일: person.py 프로젝트: over2sd/minette
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])