* src/DisplayState.py: fixe some window management syntax errros
* src/PageView.py: enable double click to edit * src/EditPerson.py: tried to enable window management * src/PersonView.py: make more compatible with base class svn: r5114
This commit is contained in:
parent
85985313eb
commit
b0ff013e19
@ -1,3 +1,9 @@
|
|||||||
|
2005-08-19 Don Allingham <don@gramps-project.org>
|
||||||
|
* src/DisplayState.py: fixe some window management syntax errros
|
||||||
|
* src/PageView.py: enable double click to edit
|
||||||
|
* src/EditPerson.py: tried to enable window management
|
||||||
|
* src/PersonView.py: make more compatible with base class
|
||||||
|
|
||||||
2005-08-19 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
|
2005-08-19 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
|
||||||
* src/EventEditor.py: hacked about to make add work at least.
|
* src/EventEditor.py: hacked about to make add work at least.
|
||||||
|
|
||||||
|
@ -93,8 +93,11 @@ class History(GrampsDBCallback.GrampsDBCallback):
|
|||||||
self.history.append(person_handle)
|
self.history.append(person_handle)
|
||||||
if person_handle not in self.mhistory:
|
if person_handle not in self.mhistory:
|
||||||
self.mhistory.append(person_handle)
|
self.mhistory.append(person_handle)
|
||||||
self.emit('menu-changed',(self.mhistory,))
|
else:
|
||||||
|
self.mhistory.remove(person_handle)
|
||||||
|
self.mhistory.push(person_handle)
|
||||||
self.index += 1
|
self.index += 1
|
||||||
|
self.emit('menu-changed',(self.mhistory,))
|
||||||
self.emit('changed',(self.history,))
|
self.emit('changed',(self.history,))
|
||||||
|
|
||||||
def forward(self,step=1):
|
def forward(self,step=1):
|
||||||
@ -154,12 +157,12 @@ class GrampsWindowManager:
|
|||||||
self.close_item_recursively(sub_item)
|
self.close_item_recursively(sub_item)
|
||||||
else:
|
else:
|
||||||
if item.window_id:
|
if item.window_id:
|
||||||
del self.id2item[window_id]
|
del self.id2item[item.window_id]
|
||||||
item.window.destroy()
|
item.window.destroy()
|
||||||
|
|
||||||
def add_item(self,node,item):
|
def add_item(self,node,item):
|
||||||
if item.window_id:
|
if item.window_id:
|
||||||
self.id2item[window_id] = item
|
self.id2item[item.window_id] = item
|
||||||
|
|
||||||
parent_item = self.get_item_from_node(node)
|
parent_item = self.get_item_from_node(node)
|
||||||
assert type(parent_item) == list or node == [], \
|
assert type(parent_item) == list or node == [], \
|
||||||
@ -172,6 +175,7 @@ class GrampsWindowManager:
|
|||||||
new_item = item
|
new_item = item
|
||||||
parent_item.append(new_item)
|
parent_item.append(new_item)
|
||||||
new_node = node + [len(parent_item) + 1]
|
new_node = node + [len(parent_item) + 1]
|
||||||
|
self.build_windows_menu()
|
||||||
return new_node
|
return new_node
|
||||||
|
|
||||||
def remove_node(self,node):
|
def remove_node(self,node):
|
||||||
@ -179,18 +183,21 @@ class GrampsWindowManager:
|
|||||||
child_in_parent = node[-1:][0]
|
child_in_parent = node[-1:][0]
|
||||||
item = self.get_item_from_node(parent_node)
|
item = self.get_item_from_node(parent_node)
|
||||||
item.pop(child_in_parent)
|
item.pop(child_in_parent)
|
||||||
|
self.build_windows_menu()
|
||||||
|
|
||||||
def call_back_factory(self,item):
|
def call_back_factory(self,item):
|
||||||
if type(item) != list:
|
if type(item) != list:
|
||||||
def f(obj):
|
def f(obj):
|
||||||
if item.window_id and self.get_window_from_id(window_id):
|
if item.window_id and self.get_window_from_id(item.window_id):
|
||||||
self.get_window_from_id(window__id).present()
|
self.get_window_from_id(item.window_id).present()
|
||||||
else:
|
else:
|
||||||
def f(obj):
|
def f(obj):
|
||||||
pass
|
pass
|
||||||
return f
|
return f
|
||||||
|
|
||||||
def built_windows_menu(self):
|
def build_windows_menu(self):
|
||||||
|
print self.window_tree
|
||||||
|
print self.id2item
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -235,12 +242,12 @@ class ManagedWindow:
|
|||||||
...
|
...
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if uistate.gwm.get_window_from_id(window_id):
|
if uistate.gwm.get_window_from_id(window_key):
|
||||||
uistate.gwm.get_window_from_id(window_id).present()
|
uistate.gwm.get_window_from_id(window_key).present()
|
||||||
self.already_exist = True
|
self.already_exist = True
|
||||||
else:
|
else:
|
||||||
self.already_exist = False
|
self.already_exist = False
|
||||||
self.window_id = window_id
|
self.window_id = window_key
|
||||||
self.submenu_label = submenu_label
|
self.submenu_label = submenu_label
|
||||||
self.menu_label = menu_label
|
self.menu_label = menu_label
|
||||||
self.uistate = uistate
|
self.uistate = uistate
|
||||||
|
@ -62,6 +62,7 @@ import NameDisplay
|
|||||||
import NameEdit
|
import NameEdit
|
||||||
import NoteEdit
|
import NoteEdit
|
||||||
import Spell
|
import Spell
|
||||||
|
import DisplayState
|
||||||
|
|
||||||
from QuestionDialog import WarningDialog, ErrorDialog, SaveDialog, QuestionDialog2
|
from QuestionDialog import WarningDialog, ErrorDialog, SaveDialog, QuestionDialog2
|
||||||
|
|
||||||
@ -86,21 +87,36 @@ _use_patronymic = [
|
|||||||
# EditPerson class
|
# EditPerson class
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class EditPerson:
|
class EditPerson(DisplayState.ManagedWindow):
|
||||||
|
|
||||||
use_patronymic = locale.getlocale(locale.LC_TIME)[0] in _use_patronymic
|
use_patronymic = locale.getlocale(locale.LC_TIME)[0] in _use_patronymic
|
||||||
|
|
||||||
def __init__(self,state,uistate,person,callback=None):
|
def __init__(self,state,uistate,person,callback=None):
|
||||||
"""Creates an edit window. Associates a person with the window."""
|
"""Creates an edit window. Associates a person with the window."""
|
||||||
|
|
||||||
|
self.dp = DateHandler.parser
|
||||||
|
self.dd = DateHandler.displayer
|
||||||
|
self.nd = NameDisplay.displayer
|
||||||
|
|
||||||
|
win_menu_label = self.nd.display(person)
|
||||||
|
if not win_menu_label.strip():
|
||||||
|
win_menu_label = _("New Person")
|
||||||
|
|
||||||
|
DisplayState.ManagedWindow.__init__(
|
||||||
|
self, uistate, [], self, win_menu_label, _('Edit Person'))
|
||||||
|
|
||||||
|
if self.already_exist:
|
||||||
|
return
|
||||||
|
|
||||||
self.state = state
|
self.state = state
|
||||||
self.uistate = uistate
|
self.uistate = uistate
|
||||||
self.retval = const.UPDATE_PERSON
|
self.retval = const.UPDATE_PERSON
|
||||||
|
|
||||||
self.dp = DateHandler.parser
|
if person:
|
||||||
self.dd = DateHandler.displayer
|
self.orig_handle = person.get_handle()
|
||||||
self.nd = NameDisplay.displayer
|
else:
|
||||||
self.orig_handle = person.get_handle()
|
self.orig_handle = ""
|
||||||
|
|
||||||
# UGLY HACK to refresh person object from handle if that exists
|
# UGLY HACK to refresh person object from handle if that exists
|
||||||
# done to ensure that the person object is not stale, as it could
|
# done to ensure that the person object is not stale, as it could
|
||||||
# have been changed by something external (merge, tool, etc).
|
# have been changed by something external (merge, tool, etc).
|
||||||
@ -336,7 +352,6 @@ class EditPerson:
|
|||||||
self.url_box.redraw()
|
self.url_box.redraw()
|
||||||
self.get_widget("notebook").set_current_page(0)
|
self.get_widget("notebook").set_current_page(0)
|
||||||
self.surname.grab_focus()
|
self.surname.grab_focus()
|
||||||
self.add_itself_to_winsmenu()
|
|
||||||
|
|
||||||
if self.db.readonly:
|
if self.db.readonly:
|
||||||
for i in ["ok", "aka_add", "aka_del", "event_add", "event_del",
|
for i in ["ok", "aka_add", "aka_del", "event_add", "event_del",
|
||||||
@ -446,43 +461,6 @@ class EditPerson:
|
|||||||
ImageSelect.LocalMediaProperties(ph,obj.get_path(),self,
|
ImageSelect.LocalMediaProperties(ph,obj.get_path(),self,
|
||||||
self.window)
|
self.window)
|
||||||
|
|
||||||
def close_child_windows(self):
|
|
||||||
for child_window in self.child_windows.values():
|
|
||||||
child_window.close(None)
|
|
||||||
self.child_windows = {}
|
|
||||||
|
|
||||||
def close(self):
|
|
||||||
#self.gallery.close()
|
|
||||||
self.close_child_windows()
|
|
||||||
self.remove_itself_from_winsmenu()
|
|
||||||
self.window.destroy()
|
|
||||||
|
|
||||||
def add_itself_to_winsmenu(self):
|
|
||||||
## self.parent_window.child_windows[self.orig_handle] = self
|
|
||||||
## win_menu_label = self.name_display.display(self.person)
|
|
||||||
## if not win_menu_label.strip():
|
|
||||||
## win_menu_label = _("New Person")
|
|
||||||
## self.win_menu_item = gtk.MenuItem(win_menu_label)
|
|
||||||
## self.win_menu_item.set_submenu(gtk.Menu())
|
|
||||||
## self.win_menu_item.show()
|
|
||||||
## self.uistate.winsmenu.append(self.win_menu_item)
|
|
||||||
## self.winsmenu = self.win_menu_item.get_submenu()
|
|
||||||
## self.menu_item = gtk.MenuItem(_('Edit Person'))
|
|
||||||
## self.menu_item.connect("activate",self.present)
|
|
||||||
## self.menu_item.show()
|
|
||||||
## self.winsmenu.append(self.menu_item)
|
|
||||||
return
|
|
||||||
|
|
||||||
def remove_itself_from_winsmenu(self):
|
|
||||||
return
|
|
||||||
del self.parent_window.child_windows[self.orig_handle]
|
|
||||||
self.menu_item.destroy()
|
|
||||||
self.winsmenu.destroy()
|
|
||||||
self.win_menu_item.destroy()
|
|
||||||
|
|
||||||
def present(self,obj):
|
|
||||||
self.window.present()
|
|
||||||
|
|
||||||
def on_help_clicked(self,obj):
|
def on_help_clicked(self,obj):
|
||||||
"""Display the relevant portion of GRAMPS manual"""
|
"""Display the relevant portion of GRAMPS manual"""
|
||||||
gnome.help_display('gramps-manual','gramps-edit-complete')
|
gnome.help_display('gramps-manual','gramps-edit-complete')
|
||||||
|
@ -398,7 +398,7 @@ class ListView(PageView):
|
|||||||
|
|
||||||
def button_press(self,obj,event):
|
def button_press(self,obj,event):
|
||||||
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
|
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
|
||||||
self.double_click(obj,event)
|
self.edit(obj)
|
||||||
return True
|
return True
|
||||||
elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
|
elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
|
||||||
menu = self.uistate.uimanager.get_widget('/Popup')
|
menu = self.uistate.uimanager.get_widget('/Popup')
|
||||||
|
@ -75,6 +75,7 @@ class PersonView(PageView.PersonNavView):
|
|||||||
self.inactive = False
|
self.inactive = False
|
||||||
dbstate.connect('database-changed',self.change_db)
|
dbstate.connect('database-changed',self.change_db)
|
||||||
dbstate.connect('active-changed',self.goto_active_person)
|
dbstate.connect('active-changed',self.goto_active_person)
|
||||||
|
self.handle_col = len(column_names)+2
|
||||||
|
|
||||||
def change_page(self):
|
def change_page(self):
|
||||||
self.on_filter_name_changed(None)
|
self.on_filter_name_changed(None)
|
||||||
@ -140,15 +141,15 @@ class PersonView(PageView.PersonNavView):
|
|||||||
|
|
||||||
self.filter_text.set_sensitive(False)
|
self.filter_text.set_sensitive(False)
|
||||||
|
|
||||||
self.person_tree = gtk.TreeView()
|
self.tree = gtk.TreeView()
|
||||||
self.person_tree.set_rules_hint(True)
|
self.tree.set_rules_hint(True)
|
||||||
self.person_tree.set_headers_visible(True)
|
self.tree.set_headers_visible(True)
|
||||||
self.person_tree.connect('key-press-event',self.key_press)
|
self.tree.connect('key-press-event',self.key_press)
|
||||||
|
|
||||||
scrollwindow = gtk.ScrolledWindow()
|
scrollwindow = gtk.ScrolledWindow()
|
||||||
scrollwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
scrollwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||||
scrollwindow.set_shadow_type(gtk.SHADOW_ETCHED_IN)
|
scrollwindow.set_shadow_type(gtk.SHADOW_ETCHED_IN)
|
||||||
scrollwindow.add(self.person_tree)
|
scrollwindow.add(self.tree)
|
||||||
|
|
||||||
self.vbox.pack_start(self.filterbar,False)
|
self.vbox.pack_start(self.filterbar,False)
|
||||||
self.vbox.pack_start(scrollwindow,True)
|
self.vbox.pack_start(scrollwindow,True)
|
||||||
@ -158,15 +159,15 @@ class PersonView(PageView.PersonNavView):
|
|||||||
|
|
||||||
self.columns = []
|
self.columns = []
|
||||||
self.build_columns()
|
self.build_columns()
|
||||||
self.person_tree.connect('button-press-event', self.on_button_press)
|
self.tree.connect('button-press-event', self.button_press)
|
||||||
self.person_tree.connect('drag_data_get', self.person_drag_data_get)
|
self.tree.connect('drag_data_get', self.drag_data_get)
|
||||||
|
|
||||||
|
|
||||||
self.person_selection = self.person_tree.get_selection()
|
self.selection = self.tree.get_selection()
|
||||||
self.person_selection.set_mode(gtk.SELECTION_MULTIPLE)
|
self.selection.set_mode(gtk.SELECTION_MULTIPLE)
|
||||||
self.person_selection.connect('changed',self.row_changed)
|
self.selection.connect('changed',self.row_changed)
|
||||||
|
|
||||||
self.vbox.set_focus_chain([self.person_tree, self.filter_list,
|
self.vbox.set_focus_chain([self.tree, self.filter_list,
|
||||||
self.filter_text, self.filter_invert,
|
self.filter_text, self.filter_invert,
|
||||||
self.filter_button])
|
self.filter_button])
|
||||||
|
|
||||||
@ -268,20 +269,20 @@ class PersonView(PageView.PersonNavView):
|
|||||||
# select the active person in the person view
|
# select the active person in the person view
|
||||||
p = self.dbstate.active
|
p = self.dbstate.active
|
||||||
try:
|
try:
|
||||||
path = self.person_model.on_get_path(p.get_handle())
|
path = self.model.on_get_path(p.get_handle())
|
||||||
group_name = p.get_primary_name().get_group_name()
|
group_name = p.get_primary_name().get_group_name()
|
||||||
top_name = self.dbstate.db.get_name_group_mapping(group_name)
|
top_name = self.dbstate.db.get_name_group_mapping(group_name)
|
||||||
top_path = self.person_model.on_get_path(top_name)
|
top_path = self.model.on_get_path(top_name)
|
||||||
self.person_tree.expand_row(top_path,0)
|
self.tree.expand_row(top_path,0)
|
||||||
|
|
||||||
current = self.person_model.on_get_iter(path)
|
current = self.model.on_get_iter(path)
|
||||||
selected = self.person_selection.path_is_selected(path)
|
selected = self.selection.path_is_selected(path)
|
||||||
if current != p.get_handle() or not selected:
|
if current != p.get_handle() or not selected:
|
||||||
self.person_selection.unselect_all()
|
self.selection.unselect_all()
|
||||||
self.person_selection.select_path(path)
|
self.selection.select_path(path)
|
||||||
self.person_tree.scroll_to_cell(path,None,1,0.5,0)
|
self.tree.scroll_to_cell(path,None,1,0.5,0)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
self.person_selection.unselect_all()
|
self.selection.unselect_all()
|
||||||
print "Person not currently available due to filter"
|
print "Person not currently available due to filter"
|
||||||
self.dbstate.active = p
|
self.dbstate.active = p
|
||||||
|
|
||||||
@ -430,12 +431,12 @@ class PersonView(PageView.PersonNavView):
|
|||||||
Creates a new PeopleModel instance. Essentially creates a complete
|
Creates a new PeopleModel instance. Essentially creates a complete
|
||||||
rebuild of the data.
|
rebuild of the data.
|
||||||
"""
|
"""
|
||||||
self.person_model = PeopleModel.PeopleModel(
|
self.model = PeopleModel.PeopleModel(
|
||||||
self.dbstate.db, self.DataFilter, self.filter_invert.get_active())
|
self.dbstate.db, self.DataFilter, self.filter_invert.get_active())
|
||||||
self.person_tree.set_model(self.person_model)
|
self.tree.set_model(self.model)
|
||||||
|
|
||||||
if self.person_model.tooltip_column != None:
|
if self.model.tooltip_column != None:
|
||||||
self.tooltips = TreeTips.TreeTips(self.person_tree,self.person_model.tooltip_column,True)
|
self.tooltips = TreeTips.TreeTips(self.tree,self.model.tooltip_column,True)
|
||||||
|
|
||||||
|
|
||||||
def filter_toggle(self,obj):
|
def filter_toggle(self,obj):
|
||||||
@ -525,7 +526,7 @@ class PersonView(PageView.PersonNavView):
|
|||||||
|
|
||||||
def build_columns(self):
|
def build_columns(self):
|
||||||
for column in self.columns:
|
for column in self.columns:
|
||||||
self.person_tree.remove_column(column)
|
self.tree.remove_column(column)
|
||||||
|
|
||||||
column = gtk.TreeViewColumn(_('Name'), self.renderer,text=0)
|
column = gtk.TreeViewColumn(_('Name'), self.renderer,text=0)
|
||||||
column.set_resizable(True)
|
column.set_resizable(True)
|
||||||
@ -533,7 +534,7 @@ class PersonView(PageView.PersonNavView):
|
|||||||
#column.connect('clicked',self.sort_clicked)
|
#column.connect('clicked',self.sort_clicked)
|
||||||
column.set_min_width(225)
|
column.set_min_width(225)
|
||||||
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
|
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
|
||||||
self.person_tree.append_column(column)
|
self.tree.append_column(column)
|
||||||
self.columns = [column]
|
self.columns = [column]
|
||||||
|
|
||||||
for pair in self.dbstate.db.get_person_column_order():
|
for pair in self.dbstate.db.get_person_column_order():
|
||||||
@ -545,7 +546,7 @@ class PersonView(PageView.PersonNavView):
|
|||||||
column.set_min_width(60)
|
column.set_min_width(60)
|
||||||
column.set_sizing(gtk.TREE_VIEW_COLUMN_GROW_ONLY)
|
column.set_sizing(gtk.TREE_VIEW_COLUMN_GROW_ONLY)
|
||||||
self.columns.append(column)
|
self.columns.append(column)
|
||||||
self.person_tree.append_column(column)
|
self.tree.append_column(column)
|
||||||
|
|
||||||
def row_changed(self,obj):
|
def row_changed(self,obj):
|
||||||
"""Called with a row is changed. Check the selected objects from
|
"""Called with a row is changed. Check the selected objects from
|
||||||
@ -562,23 +563,16 @@ class PersonView(PageView.PersonNavView):
|
|||||||
self.dbstate.change_active_person(None)
|
self.dbstate.change_active_person(None)
|
||||||
|
|
||||||
if len(selected_ids) == 1:
|
if len(selected_ids) == 1:
|
||||||
self.person_tree.drag_source_set(BUTTON1_MASK,
|
self.tree.drag_source_set(BUTTON1_MASK,
|
||||||
[DdTargets.PERSON_LINK.target()],
|
[DdTargets.PERSON_LINK.target()],
|
||||||
ACTION_COPY)
|
ACTION_COPY)
|
||||||
elif len(selected_ids) > 1:
|
elif len(selected_ids) > 1:
|
||||||
self.person_tree.drag_source_set(BUTTON1_MASK,
|
self.tree.drag_source_set(BUTTON1_MASK,
|
||||||
[DdTargets.PERSON_LINK_LIST.target()],
|
[DdTargets.PERSON_LINK_LIST.target()],
|
||||||
ACTION_COPY)
|
ACTION_COPY)
|
||||||
self.uistate.modify_statusbar()
|
self.uistate.modify_statusbar()
|
||||||
|
|
||||||
def on_button_press(self,obj,event):
|
def drag_data_get(self, widget, context, sel_data, info, time):
|
||||||
if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
|
|
||||||
menu = self.uistate.uimanager.get_widget('/Popup')
|
|
||||||
menu.popup(None,None,None,event.button,event.time)
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
def person_drag_data_get(self, widget, context, sel_data, info, time):
|
|
||||||
selected_ids = self.get_selected_objects()
|
selected_ids = self.get_selected_objects()
|
||||||
|
|
||||||
if len(selected_ids) == 1:
|
if len(selected_ids) == 1:
|
||||||
@ -600,45 +594,45 @@ class PersonView(PageView.PersonNavView):
|
|||||||
for node in handle_list:
|
for node in handle_list:
|
||||||
person = self.dbstate.db.get_person_from_handle(node)
|
person = self.dbstate.db.get_person_from_handle(node)
|
||||||
top = person.get_primary_name().get_group_name()
|
top = person.get_primary_name().get_group_name()
|
||||||
self.person_model.rebuild_data(self.DataFilter)
|
self.model.rebuild_data(self.DataFilter)
|
||||||
if not self.person_model.is_visable(node):
|
if not self.model.is_visable(node):
|
||||||
continue
|
continue
|
||||||
if (not self.person_model.sname_sub.has_key(top) or
|
if (not self.model.sname_sub.has_key(top) or
|
||||||
len(self.person_model.sname_sub[top]) == 1):
|
len(self.model.sname_sub[top]) == 1):
|
||||||
path = self.person_model.on_get_path(top)
|
path = self.model.on_get_path(top)
|
||||||
pnode = self.person_model.get_iter(path)
|
pnode = self.model.get_iter(path)
|
||||||
self.person_model.row_inserted(path,pnode)
|
self.model.row_inserted(path,pnode)
|
||||||
path = self.person_model.on_get_path(node)
|
path = self.model.on_get_path(node)
|
||||||
pnode = self.person_model.get_iter(path)
|
pnode = self.model.get_iter(path)
|
||||||
self.person_model.row_inserted(path,pnode)
|
self.model.row_inserted(path,pnode)
|
||||||
|
|
||||||
def person_removed(self,handle_list):
|
def person_removed(self,handle_list):
|
||||||
for node in handle_list:
|
for node in handle_list:
|
||||||
person = self.dbstate.db.get_person_from_handle(node)
|
person = self.dbstate.db.get_person_from_handle(node)
|
||||||
if not self.person_model.is_visable(node):
|
if not self.model.is_visable(node):
|
||||||
continue
|
continue
|
||||||
top = person.get_primary_name().get_group_name()
|
top = person.get_primary_name().get_group_name()
|
||||||
mylist = self.person_model.sname_sub.get(top,[])
|
mylist = self.model.sname_sub.get(top,[])
|
||||||
if mylist:
|
if mylist:
|
||||||
try:
|
try:
|
||||||
path = self.person_model.on_get_path(node)
|
path = self.model.on_get_path(node)
|
||||||
self.person_model.row_deleted(path)
|
self.model.row_deleted(path)
|
||||||
if len(mylist) == 1:
|
if len(mylist) == 1:
|
||||||
path = self.person_model.on_get_path(top)
|
path = self.model.on_get_path(top)
|
||||||
self.person_model.row_deleted(path)
|
self.model.row_deleted(path)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
self.person_model.rebuild_data(self.DataFilter,skip=node)
|
self.model.rebuild_data(self.DataFilter,skip=node)
|
||||||
|
|
||||||
def person_updated(self,handle_list):
|
def person_updated(self,handle_list):
|
||||||
for node in handle_list:
|
for node in handle_list:
|
||||||
person = self.dbstate.db.get_person_from_handle(node)
|
person = self.dbstate.db.get_person_from_handle(node)
|
||||||
try:
|
try:
|
||||||
oldpath = self.person_model.iter2path[node]
|
oldpath = self.model.iter2path[node]
|
||||||
except:
|
except:
|
||||||
return
|
return
|
||||||
pathval = self.person_model.on_get_path(node)
|
pathval = self.model.on_get_path(node)
|
||||||
pnode = self.person_model.get_iter(pathval)
|
pnode = self.model.get_iter(pathval)
|
||||||
|
|
||||||
# calculate the new data
|
# calculate the new data
|
||||||
|
|
||||||
@ -649,46 +643,46 @@ class PersonView(PageView.PersonNavView):
|
|||||||
surname = self.dbstate.db.get_name_group_mapping(base)
|
surname = self.dbstate.db.get_name_group_mapping(base)
|
||||||
|
|
||||||
if oldpath[0] == surname:
|
if oldpath[0] == surname:
|
||||||
self.person_model.build_sub_entry(surname)
|
self.model.build_sub_entry(surname)
|
||||||
else:
|
else:
|
||||||
self.person_model.calculate_data(self.DataFilter)
|
self.model.calculate_data(self.DataFilter)
|
||||||
|
|
||||||
# find the path of the person in the new data build
|
# find the path of the person in the new data build
|
||||||
newpath = self.person_model.temp_iter2path[node]
|
newpath = self.model.temp_iter2path[node]
|
||||||
|
|
||||||
# if paths same, just issue row changed signal
|
# if paths same, just issue row changed signal
|
||||||
|
|
||||||
if oldpath == newpath:
|
if oldpath == newpath:
|
||||||
self.person_model.row_changed(pathval,pnode)
|
self.model.row_changed(pathval,pnode)
|
||||||
else:
|
else:
|
||||||
# paths different, get the new surname list
|
# paths different, get the new surname list
|
||||||
|
|
||||||
mylist = self.person_model.temp_sname_sub.get(oldpath[0],[])
|
mylist = self.model.temp_sname_sub.get(oldpath[0],[])
|
||||||
path = self.person_model.on_get_path(node)
|
path = self.model.on_get_path(node)
|
||||||
|
|
||||||
# delete original
|
# delete original
|
||||||
self.person_model.row_deleted(pathval)
|
self.model.row_deleted(pathval)
|
||||||
|
|
||||||
# delete top node of original if necessar
|
# delete top node of original if necessar
|
||||||
if len(mylist)==0:
|
if len(mylist)==0:
|
||||||
self.person_model.row_deleted(pathval[0])
|
self.model.row_deleted(pathval[0])
|
||||||
|
|
||||||
# determine if we need to insert a new top node',
|
# determine if we need to insert a new top node',
|
||||||
insert = not self.person_model.sname_sub.has_key(newpath[0])
|
insert = not self.model.sname_sub.has_key(newpath[0])
|
||||||
|
|
||||||
# assign new data
|
# assign new data
|
||||||
self.person_model.assign_data()
|
self.model.assign_data()
|
||||||
|
|
||||||
# insert new row if needed
|
# insert new row if needed
|
||||||
if insert:
|
if insert:
|
||||||
path = self.person_model.on_get_path(newpath[0])
|
path = self.model.on_get_path(newpath[0])
|
||||||
pnode = self.person_model.get_iter(path)
|
pnode = self.model.get_iter(path)
|
||||||
self.person_model.row_inserted(path,pnode)
|
self.model.row_inserted(path,pnode)
|
||||||
|
|
||||||
# insert new person
|
# insert new person
|
||||||
path = self.person_model.on_get_path(node)
|
path = self.model.on_get_path(node)
|
||||||
pnode = self.person_model.get_iter(path)
|
pnode = self.model.get_iter(path)
|
||||||
self.person_model.row_inserted(path,pnode)
|
self.model.row_inserted(path,pnode)
|
||||||
|
|
||||||
self.goto_active_person()
|
self.goto_active_person()
|
||||||
|
|
||||||
@ -712,22 +706,22 @@ class PersonView(PageView.PersonNavView):
|
|||||||
self.uistate.modify_statusbar()
|
self.uistate.modify_statusbar()
|
||||||
|
|
||||||
def get_selected_objects(self):
|
def get_selected_objects(self):
|
||||||
(mode,paths) = self.person_selection.get_selected_rows()
|
(mode,paths) = self.selection.get_selected_rows()
|
||||||
mlist = []
|
mlist = []
|
||||||
for path in paths:
|
for path in paths:
|
||||||
node = self.person_model.on_get_iter(path)
|
node = self.model.on_get_iter(path)
|
||||||
mlist.append(self.person_model.on_get_value(node, PeopleModel.COLUMN_INT_ID))
|
mlist.append(self.model.on_get_value(node, PeopleModel.COLUMN_INT_ID))
|
||||||
return mlist
|
return mlist
|
||||||
|
|
||||||
def remove_from_person_list(self,person):
|
def remove_from_person_list(self,person):
|
||||||
"""Remove the selected person from the list. A person object is
|
"""Remove the selected person from the list. A person object is
|
||||||
expected, not an ID"""
|
expected, not an ID"""
|
||||||
path = self.person_model.on_get_path(person.get_handle())
|
path = self.model.on_get_path(person.get_handle())
|
||||||
(col,row) = path
|
(col,row) = path
|
||||||
if row > 0:
|
if row > 0:
|
||||||
self.person_selection.select_path((col,row-1))
|
self.selection.select_path((col,row-1))
|
||||||
elif row == 0 and self.person_model.on_get_iter(path):
|
elif row == 0 and self.model.on_get_iter(path):
|
||||||
self.person_selection.select_path(path)
|
self.selection.select_path(path)
|
||||||
|
|
||||||
def button_press(self,obj,event):
|
def button_press(self,obj,event):
|
||||||
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
|
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
|
||||||
|
Loading…
Reference in New Issue
Block a user