New EventView
svn: r5053
This commit is contained in:
parent
88dbc3b776
commit
5a68231d1d
@ -1,11 +1,13 @@
|
|||||||
2005-08-11 Don Allingham <don@gramps-project.org>
|
2005-08-11 Don Allingham <don@gramps-project.org>
|
||||||
* src/DbState.py: handle self.index == -1
|
* src/DbState.py: handle self.index == -1
|
||||||
* src/PageView.py: Provide PersonNavPage to handle page views
|
* src/PageView.py: Provide PersonNavPage to handle page views
|
||||||
that to person navigation
|
that to person navigation, add start of a ListView
|
||||||
* src/PedView.py: Derive from PersonNavPage
|
* src/PedView.py: Derive from PersonNavPage
|
||||||
* src/PersonView.py: Derive from PersonNavPage
|
* src/PersonView.py: Derive from PersonNavPage
|
||||||
* src/ViewManager.py: Call new change_page to make sure history
|
* src/ViewManager.py: Call new change_page to make sure history
|
||||||
buttons are correct for the view.
|
buttons are correct for the view.
|
||||||
|
* src/EventView.py: merged in new EventView.
|
||||||
|
* src/gramps_main.py: register EventView
|
||||||
|
|
||||||
2005-08-11 Martin Hawlisch <Martin.Hawlisch@gmx.de>
|
2005-08-11 Martin Hawlisch <Martin.Hawlisch@gmx.de>
|
||||||
* src/PedView.py: More work on it.
|
* src/PedView.py: More work on it.
|
||||||
|
@ -90,27 +90,27 @@ def get_place(field,pmap,db):
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class EventEditor:
|
class EventEditor:
|
||||||
|
|
||||||
def __init__(self,event,db,parent,parent_window):
|
def __init__(self,event,dbstate,uistate):
|
||||||
self.parent = parent
|
#self.parent = parent
|
||||||
self.db = db
|
self.db = dbstate.db
|
||||||
read_only = self.db.readonly
|
read_only = self.db.readonly
|
||||||
noedit = self.db.readonly
|
noedit = self.db.readonly
|
||||||
if event:
|
# if event:
|
||||||
if self.parent.child_windows.has_key(event.get_handle()):
|
# if self.parent.child_windows.has_key(event.get_handle()):
|
||||||
self.parent.child_windows[event.get_handle()].present(None)
|
# self.parent.child_windows[event.get_handle()].present(None)
|
||||||
return
|
# return
|
||||||
else:
|
# else:
|
||||||
self.win_key = event.get_handle()
|
# self.win_key = event.get_handle()
|
||||||
else:
|
# else:
|
||||||
self.win_key = self
|
# self.win_key = self
|
||||||
self.event = event
|
self.event = event
|
||||||
self.child_windows = {}
|
# self.child_windows = {}
|
||||||
self.path = self.db.get_save_path()
|
self.path = self.db.get_save_path()
|
||||||
self.plist = []
|
self.plist = []
|
||||||
self.pmap = {}
|
self.pmap = {}
|
||||||
|
|
||||||
for key in self.parent.db.get_place_handles():
|
for key in self.db.get_place_handles():
|
||||||
title = self.parent.db.get_place_from_handle(key).get_title()
|
title = self.db.get_place_from_handle(key).get_title()
|
||||||
self.pmap[title] = key
|
self.pmap[title] = key
|
||||||
|
|
||||||
if event:
|
if event:
|
||||||
@ -247,11 +247,11 @@ class EventEditor:
|
|||||||
|
|
||||||
Utils.bold_label(self.general_label)
|
Utils.bold_label(self.general_label)
|
||||||
|
|
||||||
try:
|
# try:
|
||||||
self.window.set_transient_for(self.parent.window)
|
# self.window.set_transient_for(self.parent.window)
|
||||||
except AttributeError:
|
# except AttributeError:
|
||||||
pass
|
# pass
|
||||||
self.add_itself_to_menu()
|
# self.add_itself_to_menu()
|
||||||
self.window.show()
|
self.window.show()
|
||||||
|
|
||||||
def on_delete_event(self,obj,b):
|
def on_delete_event(self,obj,b):
|
||||||
@ -266,11 +266,13 @@ class EventEditor:
|
|||||||
self.window.destroy()
|
self.window.destroy()
|
||||||
|
|
||||||
def close_child_windows(self):
|
def close_child_windows(self):
|
||||||
|
return
|
||||||
for child_window in self.child_windows.values():
|
for child_window in self.child_windows.values():
|
||||||
child_window.close(None)
|
child_window.close(None)
|
||||||
self.child_windows = {}
|
self.child_windows = {}
|
||||||
|
|
||||||
def add_itself_to_menu(self):
|
def add_itself_to_menu(self):
|
||||||
|
return
|
||||||
self.parent.child_windows[self.win_key] = self
|
self.parent.child_windows[self.win_key] = self
|
||||||
if not self.event:
|
if not self.event:
|
||||||
label = _("New Event")
|
label = _("New Event")
|
||||||
@ -294,6 +296,7 @@ class EventEditor:
|
|||||||
self.winsmenu.append(self.menu_item)
|
self.winsmenu.append(self.menu_item)
|
||||||
|
|
||||||
def remove_itself_from_menu(self):
|
def remove_itself_from_menu(self):
|
||||||
|
return
|
||||||
if self.window:
|
if self.window:
|
||||||
del self.parent.child_windows[self.win_key]
|
del self.parent.child_windows[self.win_key]
|
||||||
self.menu_item.destroy()
|
self.menu_item.destroy()
|
||||||
@ -301,6 +304,7 @@ class EventEditor:
|
|||||||
self.parent_menu_item.destroy()
|
self.parent_menu_item.destroy()
|
||||||
|
|
||||||
def present(self,obj):
|
def present(self,obj):
|
||||||
|
return
|
||||||
self.window.present()
|
self.window.present()
|
||||||
|
|
||||||
def on_help_clicked(self,obj):
|
def on_help_clicked(self,obj):
|
||||||
@ -425,8 +429,8 @@ class EventRefEditor:
|
|||||||
self.child_windows = {}
|
self.child_windows = {}
|
||||||
|
|
||||||
self.pmap = {}
|
self.pmap = {}
|
||||||
for key in self.parent.db.get_place_handles():
|
for key in self.db.get_place_handles():
|
||||||
title = self.parent.db.get_place_from_handle(key).get_title()
|
title = self.db.get_place_from_handle(key).get_title()
|
||||||
self.pmap[title] = key
|
self.pmap[title] = key
|
||||||
|
|
||||||
self.title = _('Event Reference Editor')
|
self.title = _('Event Reference Editor')
|
||||||
@ -594,6 +598,7 @@ class EventRefEditor:
|
|||||||
self.winsmenu.append(self.menu_item)
|
self.winsmenu.append(self.menu_item)
|
||||||
|
|
||||||
def remove_itself_from_menu(self):
|
def remove_itself_from_menu(self):
|
||||||
|
return
|
||||||
del self.win_parent.child_windows[self.win_key]
|
del self.win_parent.child_windows[self.win_key]
|
||||||
self.menu_item.destroy()
|
self.menu_item.destroy()
|
||||||
self.winsmenu.destroy()
|
self.winsmenu.destroy()
|
||||||
|
@ -33,6 +33,7 @@ import gtk.gdk
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import RelLib
|
import RelLib
|
||||||
|
import PageView
|
||||||
import EventEdit
|
import EventEdit
|
||||||
import DisplayModels
|
import DisplayModels
|
||||||
import const
|
import const
|
||||||
@ -56,122 +57,62 @@ column_names = [
|
|||||||
_('Last Changed'),
|
_('Last Changed'),
|
||||||
]
|
]
|
||||||
|
|
||||||
_HANDLE_COL = len(column_names)
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# EventView
|
# EventView
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class EventView:
|
class EventView(PageView.ListView):
|
||||||
def __init__(self,parent,db,glade):
|
def __init__(self,dbstate,uistate):
|
||||||
self.parent = parent
|
|
||||||
self.parent.connect('database-changed',self.change_db)
|
|
||||||
|
|
||||||
self.glade = glade
|
signal_map = {
|
||||||
self.list = glade.get_widget("event_list")
|
'event-add' : self.row_add,
|
||||||
self.list.connect('button-press-event',self.button_press)
|
'event-update' : self.row_update,
|
||||||
self.list.connect('key-press-event',self.key_press)
|
'event-delete' : self.row_delete,
|
||||||
self.selection = self.list.get_selection()
|
'event-rebuild' : self.build_tree,
|
||||||
self.selection.set_mode(gtk.SELECTION_MULTIPLE)
|
}
|
||||||
self.renderer = gtk.CellRendererText()
|
|
||||||
self.model = DisplayModels.EventModel(self.parent.db,0)
|
|
||||||
self.sort_col = 0
|
|
||||||
|
|
||||||
self.list.set_model(self.model)
|
PageView.ListView.__init__(self,'Event View',dbstate,uistate,
|
||||||
self.list.set_headers_clickable(True)
|
column_names,len(column_names),
|
||||||
self.topWindow = self.glade.get_widget("gramps")
|
DisplayModels.EventModel,
|
||||||
|
signal_map)
|
||||||
|
|
||||||
self.columns = []
|
def get_stock(self):
|
||||||
self.change_db(db)
|
return 'gramps-event'
|
||||||
|
|
||||||
def column_clicked(self,obj,data):
|
def ui_definition(self):
|
||||||
if self.sort_col != data:
|
return '''<ui>
|
||||||
order = gtk.SORT_ASCENDING
|
<menubar name="MenuBar">
|
||||||
else:
|
<menu action="EditMenu">
|
||||||
if (self.columns[data].get_sort_order() == gtk.SORT_DESCENDING
|
<placeholder name="CommonEdit">
|
||||||
or self.columns[data].get_sort_indicator() == False):
|
<menuitem action="Add"/>
|
||||||
order = gtk.SORT_ASCENDING
|
<menuitem action="Edit"/>
|
||||||
else:
|
<menuitem action="Remove"/>
|
||||||
order = gtk.SORT_DESCENDING
|
</placeholder>
|
||||||
self.sort_col = data
|
</menu>
|
||||||
handle = self.first_selected()
|
</menubar>
|
||||||
self.model = DisplayModels.EventModel(self.parent.db,
|
<toolbar name="ToolBar">
|
||||||
self.sort_col,order)
|
<placeholder name="CommonEdit">
|
||||||
self.list.set_model(self.model)
|
<toolitem action="Add"/>
|
||||||
colmap = self.parent.db.get_repository_column_order()
|
<toolitem action="Edit"/>
|
||||||
|
<toolitem action="Remove"/>
|
||||||
if handle:
|
</placeholder>
|
||||||
path = self.model.on_get_path(handle)
|
</toolbar>
|
||||||
self.selection.select_path(path)
|
</ui>'''
|
||||||
self.list.scroll_to_cell(path,None,1,0.5,0)
|
|
||||||
for i in range(0,len(self.columns)):
|
|
||||||
self.columns[i].set_sort_indicator(i==colmap[data][1]-1)
|
|
||||||
self.columns[self.sort_col].set_sort_order(order)
|
|
||||||
|
|
||||||
def build_columns(self):
|
|
||||||
for column in self.columns:
|
|
||||||
self.list.remove_column(column)
|
|
||||||
|
|
||||||
## column = gtk.TreeViewColumn(_('Type'), self.renderer,text=0)
|
|
||||||
## column.set_resizable(True)
|
|
||||||
## column.set_min_width(225)
|
|
||||||
## column.set_clickable(True)
|
|
||||||
## column.connect('clicked',self.column_clicked,0)
|
|
||||||
## self.list.append_column(column)
|
|
||||||
## self.columns = [column]
|
|
||||||
self.columns = []
|
|
||||||
|
|
||||||
index = 0
|
|
||||||
for pair in self.parent.db.get_event_column_order():
|
|
||||||
if not pair[0]:
|
|
||||||
continue
|
|
||||||
name = column_names[pair[1]]
|
|
||||||
column = gtk.TreeViewColumn(name, self.renderer, text=pair[1])
|
|
||||||
column.connect('clicked',self.column_clicked,index)
|
|
||||||
column.set_resizable(True)
|
|
||||||
column.set_min_width(75)
|
|
||||||
column.set_clickable(True)
|
|
||||||
self.columns.append(column)
|
|
||||||
self.list.append_column(column)
|
|
||||||
index += 1
|
|
||||||
|
|
||||||
def change_db(self,db):
|
|
||||||
db.connect('event-add', self.event_add)
|
|
||||||
db.connect('event-update', self.event_update)
|
|
||||||
db.connect('event-delete', self.event_delete)
|
|
||||||
db.connect('event-rebuild',self.build_tree)
|
|
||||||
self.build_columns()
|
|
||||||
self.build_tree()
|
|
||||||
|
|
||||||
def build_tree(self):
|
|
||||||
self.list.set_model(None)
|
|
||||||
self.model = DisplayModels.EventModel(self.parent.db,self.sort_col)
|
|
||||||
self.list.set_model(self.model)
|
|
||||||
self.selection = self.list.get_selection()
|
|
||||||
self.selection.set_mode(gtk.SELECTION_MULTIPLE)
|
|
||||||
|
|
||||||
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:
|
||||||
mlist = []
|
mlist = []
|
||||||
self.selection.selected_foreach(self.blist,mlist)
|
self.selection.selected_foreach(self.blist,mlist)
|
||||||
handle = mlist[0]
|
handle = mlist[0]
|
||||||
the_event = self.parent.db.get_event_from_handle(handle)
|
the_event = self.dbstate.db.get_event_from_handle(handle)
|
||||||
EventEdit.EventEditor(the_event,self.parent.db,self.parent,
|
EventEdit.EventEditor(the_event,self.dbstate, self.uistate)
|
||||||
self.topWindow)
|
|
||||||
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:
|
||||||
self.build_context_menu(event)
|
self.build_context_menu(event)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def key_press(self,obj,event):
|
|
||||||
if event.keyval == gtk.gdk.keyval_from_name("Return") \
|
|
||||||
and not event.state:
|
|
||||||
self.on_edit_clicked(obj)
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
def build_context_menu(self,event):
|
def build_context_menu(self,event):
|
||||||
"""Builds the menu with editing operations on the repository's list"""
|
"""Builds the menu with editing operations on the repository's list"""
|
||||||
|
|
||||||
@ -184,7 +125,7 @@ class EventView:
|
|||||||
|
|
||||||
entries = [
|
entries = [
|
||||||
(gtk.STOCK_ADD, self.on_add_clicked,1),
|
(gtk.STOCK_ADD, self.on_add_clicked,1),
|
||||||
(gtk.STOCK_REMOVE, self.on_delete_clicked,sel_sensitivity),
|
(gtk.STOCK_REMOVE, self.on_deletze_clicked,sel_sensitivity),
|
||||||
(_("Edit"), self.on_edit_clicked,sel_sensitivity),
|
(_("Edit"), self.on_edit_clicked,sel_sensitivity),
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -199,26 +140,25 @@ class EventView:
|
|||||||
menu.append(item)
|
menu.append(item)
|
||||||
menu.popup(None,None,None,event.button,event.time)
|
menu.popup(None,None,None,event.button,event.time)
|
||||||
|
|
||||||
def on_add_clicked(self,obj):
|
def add(self,obj):
|
||||||
EventEdit.EventEditor(RelLib.Event(),self.parent.db,self.parent,
|
EventEdit.EventEditor(RelLib.Event(),self.dbstate, self.uistate)
|
||||||
self.topWindow)
|
|
||||||
|
|
||||||
def on_delete_clicked(self,obj):
|
def remove(self,obj):
|
||||||
mlist = []
|
mlist = []
|
||||||
self.selection.selected_foreach(self.blist,mlist)
|
self.selection.selected_foreach(self.blist,mlist)
|
||||||
|
|
||||||
for event_handle in mlist:
|
for event_handle in mlist:
|
||||||
|
db = self.dbstate.db
|
||||||
person_list = [ handle for handle in
|
person_list = [ handle for handle in
|
||||||
self.parent.db.get_person_handles(False)
|
db.get_person_handles(False)
|
||||||
if self.parent.db.get_person_from_handle(handle).has_handle_reference('Event',event_handle) ]
|
if db.get_person_from_handle(handle).has_handle_reference('Event',event_handle) ]
|
||||||
family_list = [ handle for handle in
|
family_list = [ handle for handle in
|
||||||
self.parent.db.get_family_handles()
|
db.get_family_handles()
|
||||||
if self.parent.db.get_family_from_handle(handle).has_handle_reference('Event',event_handle) ]
|
if db.get_family_from_handle(handle).has_handle_reference('Event',event_handle) ]
|
||||||
|
|
||||||
event = self.parent.db.get_event_from_handle(event_handle)
|
event = db.get_event_from_handle(event_handle)
|
||||||
|
|
||||||
ans = EventEdit.DelEventQuery(event,self.parent.db,
|
ans = EventEdit.DelEventQuery(event,db,
|
||||||
person_list,family_list)
|
person_list,family_list)
|
||||||
|
|
||||||
if len(person_list) + len(family_list) > 0:
|
if len(person_list) + len(family_list) > 0:
|
||||||
@ -233,52 +173,11 @@ class EventView:
|
|||||||
_('_Delete Event'),ans.query_response,
|
_('_Delete Event'),ans.query_response,
|
||||||
self.topWindow)
|
self.topWindow)
|
||||||
|
|
||||||
def on_edit_clicked(self,obj):
|
def edit(self,obj):
|
||||||
mlist = []
|
mlist = []
|
||||||
self.selection.selected_foreach(self.blist,mlist)
|
self.selection.selected_foreach(self.blist,mlist)
|
||||||
|
|
||||||
for handle in mlist:
|
for handle in mlist:
|
||||||
event = self.parent.db.get_event_from_handle(handle)
|
event = self.dbstate.db.get_event_from_handle(handle)
|
||||||
print "0", handle
|
EventEdit.EventEditor(event, self.dbstate, self.uistate)
|
||||||
print "1", event
|
|
||||||
EventEdit.EventEditor(event, self.parent.db, self.parent,
|
|
||||||
self.topWindow)
|
|
||||||
|
|
||||||
def event_add(self,handle_list):
|
|
||||||
for handle in handle_list:
|
|
||||||
self.model.add_row_by_handle(handle)
|
|
||||||
|
|
||||||
def event_update(self,handle_list):
|
|
||||||
for handle in handle_list:
|
|
||||||
self.model.update_row_by_handle(handle)
|
|
||||||
|
|
||||||
def event_delete(self,handle_list):
|
|
||||||
for handle in handle_list:
|
|
||||||
self.model.delete_row_by_handle(handle)
|
|
||||||
|
|
||||||
def first_selected(self):
|
|
||||||
mlist = []
|
|
||||||
self.selection.selected_foreach(self.blist,mlist)
|
|
||||||
if mlist:
|
|
||||||
return mlist[0]
|
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
|
||||||
def blist(self,store,path,iter,sel_list):
|
|
||||||
handle = store.get_value(iter,_HANDLE_COL)
|
|
||||||
sel_list.append(handle)
|
|
||||||
|
|
||||||
## def merge(self):
|
|
||||||
## mlist = []
|
|
||||||
## self.selection.selected_foreach(self.blist,mlist)
|
|
||||||
|
|
||||||
## if len(mlist) != 2:
|
|
||||||
## msg = _("Cannot merge repositorys.")
|
|
||||||
## msg2 = _("Exactly two repositorys must be selected to perform a merge. "
|
|
||||||
## "A second repository can be selected by holding down the "
|
|
||||||
## "control key while clicking on the desired repository.")
|
|
||||||
## ErrorDialog(msg,msg2)
|
|
||||||
## else:
|
|
||||||
## import MergeData
|
|
||||||
## MergeData.MergeRepositorys(self.parent.db,mlist[0],mlist[1],
|
|
||||||
## self.build_tree)
|
|
||||||
|
@ -104,6 +104,13 @@ class PageView:
|
|||||||
def change_page(self):
|
def change_page(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def key_press(self,obj,event):
|
||||||
|
ret_key = gtk.gdk.keyval_from_name("Return")
|
||||||
|
if event.keyval == ret_key and not event.state:
|
||||||
|
self.edit(obj)
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
class PersonNavView(PageView):
|
class PersonNavView(PageView):
|
||||||
def __init__(self,title,dbstate,uistate):
|
def __init__(self,title,dbstate,uistate):
|
||||||
PageView.__init__(self,title,dbstate,uistate)
|
PageView.__init__(self,title,dbstate,uistate)
|
||||||
@ -218,3 +225,146 @@ class PersonNavView(PageView):
|
|||||||
print hobj.at_end(), hobj.at_front()
|
print hobj.at_end(), hobj.at_front()
|
||||||
self.fwd_action.set_sensitive(not hobj.at_end())
|
self.fwd_action.set_sensitive(not hobj.at_end())
|
||||||
self.back_action.set_sensitive(not hobj.at_front())
|
self.back_action.set_sensitive(not hobj.at_front())
|
||||||
|
|
||||||
|
class ListView(PageView):
|
||||||
|
|
||||||
|
def __init__(self, title, dbstate, uistate, columns, handle_col,
|
||||||
|
make_model, signal_map):
|
||||||
|
PageView.__init__(self, title, dbstate, uistate)
|
||||||
|
self.renderer = gtk.CellRendererText()
|
||||||
|
self.sort_col = 0
|
||||||
|
self.columns = []
|
||||||
|
self.colinfo = columns
|
||||||
|
self.handle_col = handle_col
|
||||||
|
self.make_model = make_model
|
||||||
|
self.signal_map = signal_map
|
||||||
|
dbstate.connect('database-changed',self.change_db)
|
||||||
|
|
||||||
|
def build_widget(self):
|
||||||
|
"""
|
||||||
|
Builds the interface and returns a gtk.Container type that
|
||||||
|
contains the interface. This containter will be inserted into
|
||||||
|
a gtk.Notebook page.
|
||||||
|
"""
|
||||||
|
self.list = gtk.TreeView()
|
||||||
|
self.list.set_rules_hint(True)
|
||||||
|
self.list.set_headers_visible(True)
|
||||||
|
self.list.set_headers_clickable(True)
|
||||||
|
#self.list.connect('button-press-event',self.button_press)
|
||||||
|
self.list.connect('key-press-event',self.key_press)
|
||||||
|
|
||||||
|
scrollwindow = gtk.ScrolledWindow()
|
||||||
|
scrollwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||||
|
scrollwindow.set_shadow_type(gtk.SHADOW_ETCHED_IN)
|
||||||
|
scrollwindow.add(self.list)
|
||||||
|
|
||||||
|
self.renderer = gtk.CellRendererText()
|
||||||
|
self.inactive = False
|
||||||
|
|
||||||
|
self.columns = []
|
||||||
|
self.build_columns()
|
||||||
|
self.selection = self.list.get_selection()
|
||||||
|
#self.selection.connect('changed',self.row_changed)
|
||||||
|
|
||||||
|
return scrollwindow
|
||||||
|
|
||||||
|
def column_clicked(self,obj,data):
|
||||||
|
if self.sort_col != data:
|
||||||
|
order = gtk.SORT_ASCENDING
|
||||||
|
else:
|
||||||
|
if (self.columns[data].get_sort_order() == gtk.SORT_DESCENDING
|
||||||
|
or self.columns[data].get_sort_indicator() == False):
|
||||||
|
order = gtk.SORT_ASCENDING
|
||||||
|
else:
|
||||||
|
order = gtk.SORT_DESCENDING
|
||||||
|
self.sort_col = data
|
||||||
|
handle = self.first_selected()
|
||||||
|
self.model = DisplayModels.EventModel(self.dbstate.db,
|
||||||
|
self.sort_col,order)
|
||||||
|
self.list.set_model(self.model)
|
||||||
|
colmap = self.dbstate.db.get_repository_column_order()
|
||||||
|
|
||||||
|
if handle:
|
||||||
|
path = self.model.on_get_path(handle)
|
||||||
|
self.selection.select_path(path)
|
||||||
|
self.list.scroll_to_cell(path,None,1,0.5,0)
|
||||||
|
for i in range(0,len(self.columns)):
|
||||||
|
self.columns[i].set_sort_indicator(i==colmap[data][1]-1)
|
||||||
|
self.columns[self.sort_col].set_sort_order(order)
|
||||||
|
|
||||||
|
def build_columns(self):
|
||||||
|
for column in self.columns:
|
||||||
|
self.list.remove_column(column)
|
||||||
|
|
||||||
|
self.columns = []
|
||||||
|
|
||||||
|
index = 0
|
||||||
|
for pair in self.dbstate.db.get_event_column_order():
|
||||||
|
if not pair[0]:
|
||||||
|
continue
|
||||||
|
name = self.colinfo[pair[1]]
|
||||||
|
column = gtk.TreeViewColumn(name, self.renderer, text=pair[1])
|
||||||
|
column.connect('clicked',self.column_clicked,index)
|
||||||
|
column.set_resizable(True)
|
||||||
|
column.set_min_width(75)
|
||||||
|
column.set_clickable(True)
|
||||||
|
self.columns.append(column)
|
||||||
|
self.list.append_column(column)
|
||||||
|
index += 1
|
||||||
|
|
||||||
|
def blist(self,store,path,iter,sel_list):
|
||||||
|
handle = store.get_value(iter,self.handle_col)
|
||||||
|
sel_list.append(handle)
|
||||||
|
|
||||||
|
def first_selected(self):
|
||||||
|
mlist = []
|
||||||
|
self.selection.selected_foreach(self.blist,mlist)
|
||||||
|
if mlist:
|
||||||
|
return mlist[0]
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
def build_tree(self):
|
||||||
|
self.model = self.make_model(self.dbstate.db,self.sort_col)
|
||||||
|
self.list.set_model(self.model)
|
||||||
|
self.selection = self.list.get_selection()
|
||||||
|
|
||||||
|
def change_db(self,db):
|
||||||
|
for sig in self.signal_map:
|
||||||
|
db.connect(sig, self.signal_map[sig])
|
||||||
|
self.model = self.make_model(self.dbstate.db,0)
|
||||||
|
self.list.set_model(self.model)
|
||||||
|
self.build_columns()
|
||||||
|
self.build_tree()
|
||||||
|
|
||||||
|
def row_add(self,handle_list):
|
||||||
|
for handle in handle_list:
|
||||||
|
self.model.add_row_by_handle(handle)
|
||||||
|
|
||||||
|
def row_update(self,handle_list):
|
||||||
|
for handle in handle_list:
|
||||||
|
self.model.update_row_by_handle(handle)
|
||||||
|
|
||||||
|
def row_delete(self,handle_list):
|
||||||
|
for handle in handle_list:
|
||||||
|
self.model.delete_row_by_handle(handle)
|
||||||
|
|
||||||
|
def define_actions(self):
|
||||||
|
"""
|
||||||
|
Required define_actions function for PageView. Builds the action
|
||||||
|
group information required. We extend beyond the normal here,
|
||||||
|
since we want to have more than one action group for the PersonView.
|
||||||
|
Most PageViews really won't care about this.
|
||||||
|
"""
|
||||||
|
|
||||||
|
self.add_action('Add', gtk.STOCK_ADD, "_Add", callback=self.add)
|
||||||
|
self.add_action('Edit', gtk.STOCK_EDIT, "_Edit", callback=self.edit)
|
||||||
|
self.add_action('Remove', gtk.STOCK_REMOVE,"_Remove",callback=self.remove)
|
||||||
|
|
||||||
|
def key_press(self,obj,event):
|
||||||
|
ret_key = gtk.gdk.keyval_from_name("Return")
|
||||||
|
if event.keyval == ret_key and not event.state:
|
||||||
|
self.edit(obj)
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
@ -136,6 +136,7 @@ class PersonView(PageView.PersonNavView):
|
|||||||
self.person_tree = gtk.TreeView()
|
self.person_tree = gtk.TreeView()
|
||||||
self.person_tree.set_rules_hint(True)
|
self.person_tree.set_rules_hint(True)
|
||||||
self.person_tree.set_headers_visible(True)
|
self.person_tree.set_headers_visible(True)
|
||||||
|
self.person_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)
|
||||||
|
@ -25,6 +25,7 @@ import ViewManager
|
|||||||
import PersonView
|
import PersonView
|
||||||
import PedView
|
import PedView
|
||||||
import MapView
|
import MapView
|
||||||
|
import EventView
|
||||||
import ArgHandler
|
import ArgHandler
|
||||||
import DisplayTrace
|
import DisplayTrace
|
||||||
import GrampsKeys
|
import GrampsKeys
|
||||||
@ -191,6 +192,7 @@ class Gramps:
|
|||||||
a = ViewManager.ViewManager(state)
|
a = ViewManager.ViewManager(state)
|
||||||
a.register_view(PersonView.PersonView)
|
a.register_view(PersonView.PersonView)
|
||||||
a.register_view(PedView.PedView)
|
a.register_view(PedView.PedView)
|
||||||
|
a.register_view(EventView.EventView)
|
||||||
a.register_view(MapView.MapView)
|
a.register_view(MapView.MapView)
|
||||||
a.init_interface()
|
a.init_interface()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user