Getting ready for surname double-clicks

svn: r9632
This commit is contained in:
Doug Blank 2007-12-30 01:24:33 +00:00
parent f7da658104
commit bca91ffad0
2 changed files with 28 additions and 21 deletions

View File

@ -205,14 +205,14 @@ class Gadget(object):
if debug: print "%s is connecting" % self.gui.title
pass
def link(self, text, data):
def link(self, text, link_type, data):
buffer = self.gui.buffer
iter = buffer.get_end_iter()
offset = buffer.get_char_count()
self.append_text(text)
start = buffer.get_iter_at_offset(offset)
end = buffer.get_end_iter()
self._tags.append((LinkTag(buffer),data))
self._tags.append((LinkTag(buffer), link_type, data))
buffer.apply_tag(self._tags[-1][0], start, end)
def get_text(self):
@ -307,7 +307,7 @@ class Gadget(object):
int(event.y))
iter = view.get_iter_at_location(*buffer_location)
cursor = self.standard_cursor
for (tag, person_handle) in self._tags:
for (tag, link_type, handle) in self._tags:
if iter.has_tag(tag):
tag.set_property('underline', pango.UNDERLINE_SINGLE)
cursor = self.link_cursor
@ -322,20 +322,25 @@ class Gadget(object):
int(event.x),
int(event.y))
iter = view.get_iter_at_location(*buffer_location)
for (tag, person_handle) in self._tags:
for (tag, link_type, handle) in self._tags:
if iter.has_tag(tag):
person = self.dbstate.db.get_person_from_handle(person_handle)
if person == None:
pass
elif event.button == 1:
if event.type == gtk.gdk._2BUTTON_PRESS:
try:
EditPerson(self.gui.dbstate, self.gui.uistate, [], person)
except Errors.WindowActiveError:
pass
else:
self.gui.dbstate.change_active_person(person)
return True # handled event
if link_type == 'Person':
person = self.dbstate.db.get_person_from_handle(handle)
if person != None:
if event.button == 1: # left mouse
if event.type == gtk.gdk._2BUTTON_PRESS: # double
try:
EditPerson(self.gui.dbstate,
self.gui.uistate,
[], person)
return True # handled event
except Errors.WindowActiveError:
pass
else: # single click
self.gui.dbstate.change_active_person(person)
return True # handled event
elif link_type == 'Surname':
return True
return False # did not handle event
def logical_true(value):

View File

@ -153,9 +153,10 @@ class LogGadget(Gadget):
self.history[ltype + ": " + person_handle] = 1
person = self.dbstate.db.get_person_from_handle(person_handle)
if person:
self.link(name_displayer.display(person), person_handle)
self.link(name_displayer.display(person), 'Person',
person_handle)
else:
self.link("Unknown", person_handle)
self.link("Unknown", 'Person', person_handle)
self.append_text("\n")
class TopSurnamesGadget(Gadget):
@ -204,9 +205,10 @@ class TopSurnamesGadget(Gadget):
### All done!
self.set_text("")
for (count, surname) in surname_sort:
self.append_text(" %d. %s, %d%% (%d)\n" %
(line + 1, surname,
int((float(count)/total) * 100), count))
self.append_text(" %d. " % (line + 1))
self.link(surname, 'Surname', surname)
self.append_text(", %d%% (%d)\n" %
(int((float(count)/total) * 100), count))
line += 1
if line >= self.top_size:
break