* src/Selectors/_Select*.py: Subclass from BaseSelector.
* src/Selectors/Makefile.am: Ship new file. * src/Selectors/_BaseSelector.py: Add new file. svn: r6673
This commit is contained in:
parent
67475a87cd
commit
dc7053df55
@ -8,6 +8,10 @@
|
||||
* src/Selectors/_SelectPerson.py: cleaner interface to filters
|
||||
|
||||
2006-05-15 Alex Roitman <shura@gramps-project.org>
|
||||
* src/Selectors/_Select*.py: Subclass from BaseSelector.
|
||||
* src/Selectors/Makefile.am: Ship new file.
|
||||
* src/Selectors/_BaseSelector.py: Add new file.
|
||||
|
||||
* src/DataViews/_SourceView.py (edit,on_double_click): Catch exception.
|
||||
* configure.in: Generate new Makefile.
|
||||
* src/Makefile.am: adapt to new module.
|
||||
|
@ -204,6 +204,7 @@ src/ObjectSelector/_PersonPreviewFrame.py
|
||||
src/ObjectSelector/_PersonTreeFrame.py
|
||||
src/ObjectSelector/_PreviewFrameBase.py
|
||||
src/ObjectSelector/_TreeFrameBase.py
|
||||
src/Selectors/_BaseSelector.py
|
||||
src/Selectors/_SelectEvent.py
|
||||
src/Selectors/_SelectFamily.py
|
||||
src/Selectors/_SelectObject.py
|
||||
|
@ -7,6 +7,7 @@ pkgdatadir = $(datadir)/@PACKAGE@/Selectors
|
||||
|
||||
pkgdata_PYTHON = \
|
||||
__init__.py \
|
||||
_BaseSelector.py \
|
||||
_SelectEvent.py \
|
||||
_SelectFamily.py \
|
||||
_SelectObject.py \
|
||||
|
127
src/Selectors/_BaseSelector.py
Normal file
127
src/Selectors/_BaseSelector.py
Normal file
@ -0,0 +1,127 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2003-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id: SelectEvent.py 6155 2006-03-16 20:24:27Z rshura $
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GTK/Gnome modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
import gtk
|
||||
import gtk.glade
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import const
|
||||
import ListModel
|
||||
import ManagedWindow
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# SelectEvent
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class BaseSelector(ManagedWindow.ManagedWindow):
|
||||
|
||||
def __init__(self, dbstate, uistate, track, title):
|
||||
self.title = title
|
||||
ManagedWindow.ManagedWindow.__init__(self, uistate, track, self)
|
||||
|
||||
self.db = dbstate.db
|
||||
self.glade = gtk.glade.XML(const.gladeFile,"select_person","gramps")
|
||||
window = self.glade.get_widget('select_person')
|
||||
title_label = self.glade.get_widget('title')
|
||||
self.elist = self.glade.get_widget('plist')
|
||||
|
||||
self.set_window(window,title_label,self.title)
|
||||
|
||||
titles = self.get_column_titles() + [('',0,0)]
|
||||
self.ncols = len(titles)
|
||||
|
||||
self.model = ListModel.ListModel(self.elist,titles)
|
||||
|
||||
self.redraw()
|
||||
self.show()
|
||||
|
||||
def build_menu_names(self,obj):
|
||||
return (self.title, None)
|
||||
|
||||
def redraw(self):
|
||||
self.model.clear()
|
||||
self.model.new_model()
|
||||
|
||||
cursor_func = self.get_cursor_func()
|
||||
class_func = self.get_class_func()
|
||||
|
||||
cursor = cursor_func()
|
||||
item = cursor.first()
|
||||
while item:
|
||||
(handle,data) = item
|
||||
obj = class_func()
|
||||
obj.unserialize(data)
|
||||
model_row_data = self.get_model_row_data(obj)
|
||||
self.model.add(model_row_data,handle)
|
||||
item = cursor.next()
|
||||
cursor.close()
|
||||
self.model.connect_model()
|
||||
|
||||
def run(self):
|
||||
val = self.window.run()
|
||||
|
||||
if val == gtk.RESPONSE_OK:
|
||||
store,node = self.model.get_selected()
|
||||
if node:
|
||||
data = self.model.get_data(node,range(self.ncols))
|
||||
handle = data[-1]
|
||||
return_value = self.get_from_handle_func()(handle)
|
||||
else:
|
||||
return_value = None
|
||||
self.close()
|
||||
return return_value
|
||||
else:
|
||||
self.close()
|
||||
return None
|
||||
|
||||
def get_column_titles(self):
|
||||
# return [(_('Title'),4,350), (_('ID'),1,50)]
|
||||
assert False, "Must be defined in the subclass"
|
||||
|
||||
def get_from_handle_func(self):
|
||||
# return self.db.get_source_from_handle
|
||||
assert False, "Must be defined in the subclass"
|
||||
|
||||
def get_cursor_func(self):
|
||||
# return self.db.get_source_cursor
|
||||
assert False, "Must be defined in the subclass"
|
||||
|
||||
def get_class_func(self):
|
||||
# return RelLib.Source
|
||||
assert False, "Must be defined in the subclass"
|
||||
|
||||
def get_model_row_data(self,obj):
|
||||
# name = obj.get_title()
|
||||
# the_id = obj.get_gramps_id()
|
||||
# return [name,the_id]
|
||||
assert False, "Must be defined in the subclass"
|
@ -32,99 +32,38 @@ __revision__ = "$Revision$"
|
||||
#-------------------------------------------------------------------------
|
||||
from gettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GTK/Gnome modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
import gtk
|
||||
import gtk.glade
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import const
|
||||
import ListModel
|
||||
import DateHandler
|
||||
import ManagedWindow
|
||||
from RelLib import Event
|
||||
from _BaseSelector import BaseSelector
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# SelectEvent
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class SelectEvent(ManagedWindow.ManagedWindow):
|
||||
"""
|
||||
Selects an event from the list of available events
|
||||
"""
|
||||
class SelectEvent(BaseSelector):
|
||||
|
||||
def __init__(self, dbstate, uistate, track, title):
|
||||
"""
|
||||
Create an Event Selector, allowing the user to select on of the
|
||||
events in the event list.
|
||||
"""
|
||||
def get_column_titles(self):
|
||||
return [(_('Description'), 4, 250), (_('ID'), 1, 75),
|
||||
(_('Type'), 2, 75), (_('Date'), 3, 150) ]
|
||||
|
||||
self.title = title
|
||||
ManagedWindow.ManagedWindow.__init__(self, uistate, track, self)
|
||||
|
||||
self.db = dbstate.db
|
||||
self.glade = gtk.glade.XML(const.gladeFile, "select_person", "gramps")
|
||||
window = self.glade.get_widget('select_person')
|
||||
title_label = self.glade.get_widget('title')
|
||||
self.elist = self.glade.get_widget('plist')
|
||||
|
||||
self.set_window(window, title_label, self.title)
|
||||
|
||||
titles = [(_('Description'), 4, 250), (_('ID'), 1, 75),
|
||||
(_('Type'), 2, 75), (_('Date'), 3, 150), ('', 4, 0) ]
|
||||
self.ncols = len(titles)
|
||||
|
||||
self.model = ListModel.ListModel(self.elist, titles)
|
||||
|
||||
self.redraw()
|
||||
self.show()
|
||||
|
||||
def build_menu_names(self,obj):
|
||||
return (self.title, None)
|
||||
|
||||
def redraw(self):
|
||||
"""
|
||||
Redraws the event list
|
||||
"""
|
||||
def get_from_handle_func(self):
|
||||
return self.db.get_event_from_handle
|
||||
|
||||
self.model.clear()
|
||||
self.model.new_model()
|
||||
def get_cursor_func(self):
|
||||
return self.db.get_event_cursor
|
||||
|
||||
for handle in self.db.get_event_handles():
|
||||
event = self.db.get_event_from_handle(handle)
|
||||
desc = event.get_description()
|
||||
name = str(event.get_type())
|
||||
the_id = event.get_gramps_id()
|
||||
date = DateHandler.get_date(event)
|
||||
self.model.add([desc, the_id, name, date], handle)
|
||||
def get_class_func(self):
|
||||
return Event
|
||||
|
||||
self.model.connect_model()
|
||||
|
||||
def run(self):
|
||||
"""
|
||||
Runs te dialog, returning None if the event was not selected,
|
||||
or the event that was selected.
|
||||
"""
|
||||
val = self.window.run()
|
||||
|
||||
if val == gtk.RESPONSE_OK:
|
||||
store, node = self.model.get_selected()
|
||||
if node:
|
||||
data = self.model.get_data(node, range(self.ncols))
|
||||
handle = data[4]
|
||||
return_value = self.db.get_event_from_handle(handle)
|
||||
else:
|
||||
return_value = None
|
||||
self.close()
|
||||
return return_value
|
||||
else:
|
||||
self.close()
|
||||
return None
|
||||
def get_model_row_data(self,obj):
|
||||
desc = obj.get_description()
|
||||
the_id = obj.get_gramps_id()
|
||||
name = str(obj.get_type())
|
||||
date = DateHandler.get_date(obj)
|
||||
return [desc, the_id, name, date]
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2003-2004 Donald N. Allingham
|
||||
# Copyright (C) 2003-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
@ -44,90 +44,51 @@ from gettext import gettext as _
|
||||
# GTK/Gnome modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
import gtk
|
||||
import gtk.glade
|
||||
import gtk.gdk
|
||||
from gtk.gdk import INTERP_BILINEAR
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import const
|
||||
import ListModel
|
||||
import ImgManip
|
||||
import Mime
|
||||
import ManagedWindow
|
||||
from ImgManip import get_thumb_from_obj
|
||||
from Mime import get_description
|
||||
from ListModel import IMAGE
|
||||
from RelLib import MediaObject
|
||||
from _BaseSelector import BaseSelector
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# SelectPerson
|
||||
# SelectObject
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class SelectObject(ManagedWindow.ManagedWindow):
|
||||
class SelectObject(BaseSelector):
|
||||
|
||||
def __init__(self, dbstate, uistate, track, title):
|
||||
self.title = title
|
||||
ManagedWindow.ManagedWindow.__init__(self, uistate, track, self)
|
||||
def get_column_titles(self):
|
||||
return [(_('Preview'),0,50,IMAGE),
|
||||
(_('Title'),1,150),
|
||||
(_('ID'),2,50),
|
||||
(_('Type'),3,70)]
|
||||
|
||||
self.db = dbstate.db
|
||||
self.glade = gtk.glade.XML(const.gladeFile,"select_person","gramps")
|
||||
window = self.glade.get_widget('select_person')
|
||||
title_label = self.glade.get_widget('object_title')
|
||||
self.object_tree = self.glade.get_widget('plist')
|
||||
|
||||
self.set_window(window,title_label,self.title)
|
||||
|
||||
titles = [
|
||||
(_('Preview'),0,50,ListModel.IMAGE),
|
||||
(_('Title'),1,150),
|
||||
(_('ID'),2,50),
|
||||
(_('Type'),3,70),
|
||||
('',4,0)
|
||||
]
|
||||
def get_from_handle_func(self):
|
||||
return self.db.get_object_from_handle
|
||||
|
||||
self.ncols = len(titles)
|
||||
def get_cursor_func(self):
|
||||
return self.db.get_media_cursor
|
||||
|
||||
self.object_model = ListModel.ListModel(self.object_tree,titles)
|
||||
self.selection = self.object_tree.get_selection()
|
||||
def get_class_func(self):
|
||||
return MediaObject
|
||||
|
||||
self.redraw()
|
||||
self.show()
|
||||
def get_model_row_data(self,obj):
|
||||
title = obj.get_description()
|
||||
the_type = get_description(obj.get_mime_type())
|
||||
pixbuf = get_thumb_from_obj(obj)
|
||||
pixbuf = pixbuf.scale_simple(pixbuf.get_width()/2,
|
||||
pixbuf.get_height()/2,
|
||||
INTERP_BILINEAR)
|
||||
return [pixbuf,title,obj.get_gramps_id(),the_type]
|
||||
|
||||
def build_menu_names(self,obj):
|
||||
return (self.title, None)
|
||||
|
||||
def redraw(self):
|
||||
self.object_model.clear()
|
||||
self.object_model.new_model()
|
||||
|
||||
for key in self.db.get_media_object_handles():
|
||||
obj = self.db.get_object_from_handle(key)
|
||||
title = obj.get_description()
|
||||
the_type = Mime.get_description(obj.get_mime_type())
|
||||
pixbuf = ImgManip.get_thumb_from_obj(obj)
|
||||
pixbuf = pixbuf.scale_simple(pixbuf.get_width()/2,
|
||||
pixbuf.get_height()/2,
|
||||
gtk.gdk.INTERP_BILINEAR)
|
||||
self.object_model.add([pixbuf,title,obj.get_gramps_id(),the_type],key)
|
||||
self.object_model.connect_model()
|
||||
|
||||
def run(self):
|
||||
val = self.window.run()
|
||||
|
||||
if val == gtk.RESPONSE_OK:
|
||||
store,node = self.object_model.get_selected()
|
||||
if node:
|
||||
data = self.object_model.get_data(node,range(self.ncols))
|
||||
handle = data[4]
|
||||
return_value = self.db.get_object_from_handle(handle)
|
||||
else:
|
||||
return_value = None
|
||||
self.close()
|
||||
gc.collect()
|
||||
return return_value
|
||||
else:
|
||||
self.close()
|
||||
gc.collect()
|
||||
return None
|
||||
def close(self,*obj):
|
||||
# needed to collect garbage on closing
|
||||
BaseSelector.close(self,*obj)
|
||||
gc.collect()
|
||||
|
@ -27,78 +27,34 @@
|
||||
#-------------------------------------------------------------------------
|
||||
from gettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GTK/Gnome modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
import gtk
|
||||
import gtk.glade
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import const
|
||||
import ListModel
|
||||
import ManagedWindow
|
||||
from RelLib import Place
|
||||
from _BaseSelector import BaseSelector
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# SelectEvent
|
||||
# SelectPlace
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class SelectPlace(ManagedWindow.ManagedWindow):
|
||||
class SelectPlace(BaseSelector):
|
||||
|
||||
def __init__(self, dbstate, uistate, track, title):
|
||||
self.title = title
|
||||
ManagedWindow.ManagedWindow.__init__(self, uistate, track, self)
|
||||
def get_column_titles(self):
|
||||
return [(_('Title'),4,350), (_('ID'),1,50)]
|
||||
|
||||
self.db = dbstate.db
|
||||
self.glade = gtk.glade.XML(const.gladeFile,"select_person","gramps")
|
||||
window = self.glade.get_widget('select_person')
|
||||
title_label = self.glade.get_widget('title')
|
||||
self.elist = self.glade.get_widget('plist')
|
||||
def get_from_handle_func(self):
|
||||
return self.db.get_place_from_handle
|
||||
|
||||
def get_cursor_func(self):
|
||||
return self.db.get_place_cursor
|
||||
|
||||
self.set_window(window,title_label,self.title)
|
||||
def get_class_func(self):
|
||||
return Place
|
||||
|
||||
titles = [(_('Title'),4,350), (_('ID'),1,50), ('',0,0)]
|
||||
self.ncols = len(titles)
|
||||
|
||||
self.model = ListModel.ListModel(self.elist,titles)
|
||||
|
||||
self.redraw()
|
||||
self.show()
|
||||
|
||||
def build_menu_names(self,obj):
|
||||
return (self.title, None)
|
||||
|
||||
def redraw(self):
|
||||
self.model.clear()
|
||||
self.model.new_model()
|
||||
|
||||
for handle in self.db.get_place_handles():
|
||||
place = self.db.get_place_from_handle(handle)
|
||||
desc = place.get_title()
|
||||
the_id = place.get_gramps_id()
|
||||
self.model.add([desc,the_id,handle])
|
||||
self.model.connect_model()
|
||||
|
||||
def run(self):
|
||||
val = self.window.run()
|
||||
|
||||
if val == gtk.RESPONSE_OK:
|
||||
store,node = self.model.get_selected()
|
||||
if node:
|
||||
data = self.model.get_data(node,range(self.ncols))
|
||||
handle = data[2]
|
||||
return_value = self.db.get_place_from_handle(handle)
|
||||
else:
|
||||
return_value = None
|
||||
self.close()
|
||||
return return_value
|
||||
else:
|
||||
self.close()
|
||||
return None
|
||||
def get_model_row_data(self,obj):
|
||||
name = obj.get_title()
|
||||
the_id = obj.get_gramps_id()
|
||||
return [name,the_id]
|
||||
|
@ -27,78 +27,34 @@
|
||||
#-------------------------------------------------------------------------
|
||||
from gettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GTK/Gnome modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
import gtk
|
||||
import gtk.glade
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import const
|
||||
import ListModel
|
||||
import ManagedWindow
|
||||
from RelLib import Repository
|
||||
from _BaseSelector import BaseSelector
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# SelectRepository
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class SelectRepository(ManagedWindow.ManagedWindow):
|
||||
class SelectRepository(BaseSelector):
|
||||
|
||||
def __init__(self, dbstate, uistate, track, title):
|
||||
self.title = title
|
||||
ManagedWindow.ManagedWindow.__init__(self, uistate, track, self)
|
||||
def get_column_titles(self):
|
||||
return [(_('Title'),4,350), (_('ID'),1,50)]
|
||||
|
||||
self.db = dbstate.db
|
||||
self.glade = gtk.glade.XML(const.gladeFile,"select_person","gramps")
|
||||
window = self.glade.get_widget('select_person')
|
||||
title_label = self.glade.get_widget('title')
|
||||
self.elist = self.glade.get_widget('plist')
|
||||
def get_from_handle_func(self):
|
||||
return self.db.get_repository_from_handle
|
||||
|
||||
def get_cursor_func(self):
|
||||
return self.db.get_repository_cursor
|
||||
|
||||
self.set_window(window,title_label,self.title)
|
||||
def get_class_func(self):
|
||||
return Repository
|
||||
|
||||
titles = [(_('Title'),4,350), (_('ID'),1,50), ('',0,0)]
|
||||
self.ncols = len(titles)
|
||||
|
||||
self.model = ListModel.ListModel(self.elist,titles)
|
||||
|
||||
self.redraw()
|
||||
self.show()
|
||||
|
||||
def build_menu_names(self,obj):
|
||||
return (self.title, None)
|
||||
|
||||
def redraw(self):
|
||||
self.model.clear()
|
||||
self.model.new_model()
|
||||
|
||||
for handle in self.db.get_repository_handles():
|
||||
repository = self.db.get_repository_from_handle(handle)
|
||||
desc = repository.get_name()
|
||||
the_id = repository.get_gramps_id()
|
||||
self.model.add([desc,the_id,handle])
|
||||
self.model.connect_model()
|
||||
|
||||
def run(self):
|
||||
val = self.window.run()
|
||||
|
||||
if val == gtk.RESPONSE_OK:
|
||||
store,node = self.model.get_selected()
|
||||
if node:
|
||||
data = self.model.get_data(node,range(self.ncols))
|
||||
handle = data[2]
|
||||
return_value = self.db.get_repository_from_handle(handle)
|
||||
else:
|
||||
return_value = None
|
||||
self.close()
|
||||
return return_value
|
||||
else:
|
||||
self.close()
|
||||
return None
|
||||
def get_model_row_data(self,obj):
|
||||
name = obj.get_name()
|
||||
the_id = obj.get_gramps_id()
|
||||
return [name,the_id]
|
||||
|
@ -27,78 +27,34 @@
|
||||
#-------------------------------------------------------------------------
|
||||
from gettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GTK/Gnome modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
import gtk
|
||||
import gtk.glade
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import const
|
||||
import ListModel
|
||||
import ManagedWindow
|
||||
from RelLib import Source
|
||||
from _BaseSelector import BaseSelector
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# SelectEvent
|
||||
# SelectSource
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class SelectSource(ManagedWindow.ManagedWindow):
|
||||
class SelectSource(BaseSelector):
|
||||
|
||||
def __init__(self, dbstate, uistate, track, title):
|
||||
self.title = title
|
||||
ManagedWindow.ManagedWindow.__init__(self, uistate, track, self)
|
||||
def get_column_titles(self):
|
||||
return [(_('Title'),4,350), (_('ID'),1,50)]
|
||||
|
||||
self.db = dbstate.db
|
||||
self.glade = gtk.glade.XML(const.gladeFile,"select_person","gramps")
|
||||
window = self.glade.get_widget('select_person')
|
||||
title_label = self.glade.get_widget('title')
|
||||
self.elist = self.glade.get_widget('plist')
|
||||
def get_from_handle_func(self):
|
||||
return self.db.get_source_from_handle
|
||||
|
||||
def get_cursor_func(self):
|
||||
return self.db.get_source_cursor
|
||||
|
||||
self.set_window(window,title_label,self.title)
|
||||
def get_class_func(self):
|
||||
return Source
|
||||
|
||||
titles = [(_('Title'),4,350), (_('ID'),1,50), ('',0,0)]
|
||||
self.ncols = len(titles)
|
||||
|
||||
self.model = ListModel.ListModel(self.elist,titles)
|
||||
|
||||
self.redraw()
|
||||
self.show()
|
||||
|
||||
def build_menu_names(self,obj):
|
||||
return (self.title, None)
|
||||
|
||||
def redraw(self):
|
||||
self.model.clear()
|
||||
self.model.new_model()
|
||||
|
||||
for handle in self.db.get_source_handles():
|
||||
source = self.db.get_source_from_handle(handle)
|
||||
desc = source.get_title()
|
||||
the_id = source.get_gramps_id()
|
||||
self.model.add([desc,the_id,handle])
|
||||
self.model.connect_model()
|
||||
|
||||
def run(self):
|
||||
val = self.window.run()
|
||||
|
||||
if val == gtk.RESPONSE_OK:
|
||||
store,node = self.model.get_selected()
|
||||
if node:
|
||||
data = self.model.get_data(node,range(self.ncols))
|
||||
handle = data[2]
|
||||
return_value = self.db.get_source_from_handle(handle)
|
||||
else:
|
||||
return_value = None
|
||||
self.close()
|
||||
return return_value
|
||||
else:
|
||||
self.close()
|
||||
return None
|
||||
def get_model_row_data(self,obj):
|
||||
name = obj.get_title()
|
||||
the_id = obj.get_gramps_id()
|
||||
return [name,the_id]
|
||||
|
Loading…
Reference in New Issue
Block a user