diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index c4800bfea..c577ea720 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,20 @@ +2006-05-15 Alex Roitman + * configure.in: Generate new Makefile. + * src/Makefile.am: adapt to new module. + * src/Selectors: separate selectors in their own module. + * src/Select*.py: move to Selectors. + * src/DataViews/_FamilyView.py: Use new module. + * src/Editors/_EditLdsOrd.py: Use new module. + * src/Editors/_EditPersonRef.py: Use new module. + * src/Editors/_EditFamily.py: Use new module. + * src/DisplayTabs/_SourceEmbedList.py: Use new module. + * src/DisplayTabs/_RepoEmbedList.py: Use new module. + * src/DisplayTabs/_EventEmbedList.py: Use new module. + * src/DisplayTabs/_GalleryTab.py: Use new module. + * src/plugins/FilterEditor.py: Use new module. + * src/plugins/SimpleBookTitle.py: Use new module. + * src/PluginUtils/_Report.py: Use new module. + 2006-05-14 Alex Roitman * src/Makefile.am (gdir_PYTHON): Add new file. * src/SelectRepository.py: Add new file. diff --git a/gramps2/configure.in b/gramps2/configure.in index b49b51b2b..c0f750650 100644 --- a/gramps2/configure.in +++ b/gramps2/configure.in @@ -196,6 +196,7 @@ src/Config/Makefile src/Mime/Makefile src/DisplayTabs/Makefile src/ObjectSelector/Makefile +src/Selectors/Makefile src/GrampsLogger/Makefile src/TreeViews/Makefile src/GrampsDb/Makefile diff --git a/gramps2/po/ChangeLog b/gramps2/po/ChangeLog index 657a0337e..a677c4e3e 100644 --- a/gramps2/po/ChangeLog +++ b/gramps2/po/ChangeLog @@ -1,3 +1,6 @@ +2006-05-15 Alex Roitman + * POTFILES.in: Add new files. + 2006-05-14 Alex Roitman * POTFILES.in: Add new file. * gramps.pot: update. diff --git a/gramps2/po/POTFILES.in b/gramps2/po/POTFILES.in index 5c1de578f..1a447178d 100644 --- a/gramps2/po/POTFILES.in +++ b/gramps2/po/POTFILES.in @@ -39,12 +39,6 @@ src/QuestionDialog.py src/RecentFiles.py src/Relationship.py src/ScratchPad.py -src/SelectEvent.py -src/SelectObject.py -src/SelectPerson.py -src/SelectFamily.py -src/SelectSource.py -src/SelectRepository.py src/Sort.py src/soundex.py src/Spell.py @@ -210,6 +204,16 @@ src/ObjectSelector/_PersonPreviewFrame.py src/ObjectSelector/_PersonTreeFrame.py src/ObjectSelector/_PreviewFrameBase.py src/ObjectSelector/_TreeFrameBase.py +src/Selectors/_SelectEvent.py +src/Selectors/_SelectFamily.py +src/Selectors/_SelectObject.py +src/Selectors/_SelectPerson.py +src/Selectors/_SelectPlace.py +src/Selectors/_SelectRepository.py +src/Selectors/_SelectSource.py +src/Selectors/_SelectorExceptions.py +src/Selectors/_SelectorFactory.py +src/Selectors/__init__.py src/plugins/AncestorChart2.py src/plugins/AncestorChart.py src/plugins/AncestorReport.py diff --git a/gramps2/src/DataViews/_FamilyView.py b/gramps2/src/DataViews/_FamilyView.py index 84b7d12c5..50ccfe6a8 100644 --- a/gramps2/src/DataViews/_FamilyView.py +++ b/gramps2/src/DataViews/_FamilyView.py @@ -712,7 +712,8 @@ class FamilyView(PageView.PersonNavView): def select_family(self, obj, event, handle): if event.type == gtk.gdk.BUTTON_PRESS and event.button == 1: - from SelectFamily import SelectFamily + from Selectors import selector_factory + SelectFamily = selector_factory('Family') dialog = SelectFamily(self.dbstate, self.uistate) family = dialog.run() diff --git a/gramps2/src/DisplayTabs/_EventEmbedList.py b/gramps2/src/DisplayTabs/_EventEmbedList.py index 74aab0ed3..7617689e5 100644 --- a/gramps2/src/DisplayTabs/_EventEmbedList.py +++ b/gramps2/src/DisplayTabs/_EventEmbedList.py @@ -114,9 +114,10 @@ class EventEmbedList(EmbeddedList): pass def share_button_clicked(self, obj): - import SelectEvent + from Selectors import selector_factory + SelectEvent = selector_factory('Event') - sel = SelectEvent.SelectEvent(self.dbstate,self.uistate,self.track, + sel = SelectEvent(self.dbstate,self.uistate,self.track, _("Select event")) event = sel.run() if event: diff --git a/gramps2/src/DisplayTabs/_GalleryTab.py b/gramps2/src/DisplayTabs/_GalleryTab.py index c1e1df39b..4db1af3ec 100644 --- a/gramps2/src/DisplayTabs/_GalleryTab.py +++ b/gramps2/src/DisplayTabs/_GalleryTab.py @@ -217,9 +217,10 @@ class GalleryTab(ButtonTab): Function called with the Add button is clicked. This function should be overridden by the derived class. """ - import SelectObject + from Selectors import selector_factory + SelectObject = selector_factory('MediaObject') - sel = SelectObject.SelectObject(self.dbstate,self.uistate,self.track, + sel = SelectObject(self.dbstate,self.uistate,self.track, _("Select media")) src = sel.run() if src: diff --git a/gramps2/src/DisplayTabs/_RepoEmbedList.py b/gramps2/src/DisplayTabs/_RepoEmbedList.py index fa1cd3ff6..af4577dac 100644 --- a/gramps2/src/DisplayTabs/_RepoEmbedList.py +++ b/gramps2/src/DisplayTabs/_RepoEmbedList.py @@ -102,9 +102,10 @@ class RepoEmbedList(EmbeddedList): pass def share_button_clicked(self, obj): - import SelectRepository + from Selectors import selector_factory + SelectRepository = selector_factory('Repository') - sel = SelectRepository.SelectRepository( + sel = SelectRepository( self.dbstate, self.uistate, self.track, diff --git a/gramps2/src/DisplayTabs/_SourceEmbedList.py b/gramps2/src/DisplayTabs/_SourceEmbedList.py index 53e14108a..8e9cf7d67 100644 --- a/gramps2/src/DisplayTabs/_SourceEmbedList.py +++ b/gramps2/src/DisplayTabs/_SourceEmbedList.py @@ -95,9 +95,10 @@ class SourceEmbedList(EmbeddedList): pass def share_button_clicked(self, obj): - import SelectSource + from Selectors import selector_factory + SelectSource = selector_factory('Source') - sel = SelectSource.SelectSource( + sel = SelectSource( self.dbstate, self.uistate, self.track, diff --git a/gramps2/src/Editors/_EditFamily.py b/gramps2/src/Editors/_EditFamily.py index 25588e762..25c55841b 100644 --- a/gramps2/src/Editors/_EditFamily.py +++ b/gramps2/src/Editors/_EditFamily.py @@ -81,7 +81,8 @@ from GrampsWidgets import * #from ObjectSelector import PersonSelector,PersonFilterSpec -from SelectPerson import SelectPerson +from Selectors import selector_factory +SelectPerson = selector_factory('Person') class ChildEmbedList(EmbeddedList): """ diff --git a/gramps2/src/Editors/_EditLdsOrd.py b/gramps2/src/Editors/_EditLdsOrd.py index 27c409acb..50dd3b693 100644 --- a/gramps2/src/Editors/_EditLdsOrd.py +++ b/gramps2/src/Editors/_EditLdsOrd.py @@ -217,7 +217,8 @@ class EditLdsOrd(EditSecondary): self.top.get_widget('vbox').pack_start(notebook,True) def select_parents_clicked(self, obj): - from SelectFamily import SelectFamily + from Selectors import selector_factory + SelectFamily = selector_factory('Family') dialog = SelectFamily(self.dbstate.db, _('Select Family')) family = dialog.run() diff --git a/gramps2/src/Editors/_EditPersonRef.py b/gramps2/src/Editors/_EditPersonRef.py index a277a62cb..47d707161 100644 --- a/gramps2/src/Editors/_EditPersonRef.py +++ b/gramps2/src/Editors/_EditPersonRef.py @@ -100,7 +100,8 @@ class EditPersonRef(EditSecondary): self.top.get_widget('select').connect('clicked',self._select_person) def _select_person(self, obj): - from SelectPerson import SelectPerson + from Selectors import selector_factory + SelectPerson = selector_factory('Person') sel = SelectPerson(self.dbstate, self.uistate, "Select Person") person = sel.run() diff --git a/gramps2/src/Makefile.am b/gramps2/src/Makefile.am index 385415fd9..2e9a9dd4a 100644 --- a/gramps2/src/Makefile.am +++ b/gramps2/src/Makefile.am @@ -12,6 +12,7 @@ SUBDIRS = \ Mime \ Models \ ObjectSelector \ + Selectors \ RelLib \ TreeViews \ data \ @@ -62,9 +63,6 @@ gdir_PYTHON = \ RecentFiles.py\ Relationship.py\ ScratchPad.py\ - SelectEvent.py\ - SelectObject.py\ - SelectPerson.py\ Sort.py\ soundex.py\ Spell.py\ @@ -76,9 +74,6 @@ gdir_PYTHON = \ TreeTips.py\ Utils.py\ ViewManager.py\ - SelectFamily.py\ - SelectSource.py\ - SelectRepository.py\ UndoHistory.py\ BasicUtils.py diff --git a/gramps2/src/PluginUtils/_Report.py b/gramps2/src/PluginUtils/_Report.py index fd60d1a61..c6aedca7a 100644 --- a/gramps2/src/PluginUtils/_Report.py +++ b/gramps2/src/PluginUtils/_Report.py @@ -2,7 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2001 David R. Hampton -# Copyright (C) 2001-2005 Donald N. Allingham +# Copyright (C) 2001-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 @@ -965,8 +965,9 @@ class BareReportDialog: self.window) def on_center_person_change_clicked(self,*obj): - import SelectPerson - sel_person = SelectPerson.SelectPerson(self.db,_('Select Person')) + from Selectors import selector_factory + SelectPerson = selector_factory('Person') + sel_person = SelectPerson(self.db,_('Select Person')) new_person = sel_person.run() if new_person: self.new_person = new_person diff --git a/gramps2/src/Selectors/Makefile.am b/gramps2/src/Selectors/Makefile.am new file mode 100644 index 000000000..7f83c168b --- /dev/null +++ b/gramps2/src/Selectors/Makefile.am @@ -0,0 +1,30 @@ +# This is the src/Selectors level Makefile for Gramps +# We could use GNU make's ':=' syntax for nice wildcard use, +# but that is not necessarily portable. +# If not using GNU make, then list all .py files individually + +pkgdatadir = $(datadir)/@PACKAGE@/Selectors + +pkgdata_PYTHON = \ + __init__.py \ + _SelectEvent.py \ + _SelectFamily.py \ + _SelectObject.py \ + _SelectPerson.py \ + _SelectRepository.py \ + _SelectSource.py \ + _SelectPlace.py \ + _SelectorExceptions.py \ + _SelectorFactory.py + +pkgpyexecdir = @pkgpyexecdir@/Selectors +pkgpythondir = @pkgpythondir@/Selectors + +# Clean up all the byte-compiled files +MOSTLYCLEANFILES = *pyc *pyo + +GRAMPS_PY_MODPATH = "../" + +pycheck: + (export PYTHONPATH=$(GRAMPS_PY_MODPATH); \ + pychecker $(pkgdata_PYTHON)); diff --git a/gramps2/src/SelectEvent.py b/gramps2/src/Selectors/_SelectEvent.py similarity index 100% rename from gramps2/src/SelectEvent.py rename to gramps2/src/Selectors/_SelectEvent.py diff --git a/gramps2/src/SelectFamily.py b/gramps2/src/Selectors/_SelectFamily.py similarity index 100% rename from gramps2/src/SelectFamily.py rename to gramps2/src/Selectors/_SelectFamily.py diff --git a/gramps2/src/SelectObject.py b/gramps2/src/Selectors/_SelectObject.py similarity index 100% rename from gramps2/src/SelectObject.py rename to gramps2/src/Selectors/_SelectObject.py diff --git a/gramps2/src/SelectPerson.py b/gramps2/src/Selectors/_SelectPerson.py similarity index 100% rename from gramps2/src/SelectPerson.py rename to gramps2/src/Selectors/_SelectPerson.py diff --git a/gramps2/src/Selectors/_SelectPlace.py b/gramps2/src/Selectors/_SelectPlace.py new file mode 100644 index 000000000..fb5471ef9 --- /dev/null +++ b/gramps2/src/Selectors/_SelectPlace.py @@ -0,0 +1,104 @@ +# +# 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 $ + +#------------------------------------------------------------------------- +# +# internationalization +# +#------------------------------------------------------------------------- +from gettext import gettext as _ + +#------------------------------------------------------------------------- +# +# GTK/Gnome modules +# +#------------------------------------------------------------------------- + +import gtk +import gtk.glade + +#------------------------------------------------------------------------- +# +# gramps modules +# +#------------------------------------------------------------------------- +import const +import ListModel +import ManagedWindow + +#------------------------------------------------------------------------- +# +# SelectEvent +# +#------------------------------------------------------------------------- +class SelectPlace(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 = [(_('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 diff --git a/gramps2/src/SelectRepository.py b/gramps2/src/Selectors/_SelectRepository.py similarity index 100% rename from gramps2/src/SelectRepository.py rename to gramps2/src/Selectors/_SelectRepository.py diff --git a/gramps2/src/SelectSource.py b/gramps2/src/Selectors/_SelectSource.py similarity index 100% rename from gramps2/src/SelectSource.py rename to gramps2/src/Selectors/_SelectSource.py diff --git a/gramps2/src/Selectors/_SelectorExceptions.py b/gramps2/src/Selectors/_SelectorExceptions.py new file mode 100644 index 000000000..3371ea468 --- /dev/null +++ b/gramps2/src/Selectors/_SelectorExceptions.py @@ -0,0 +1,29 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2000-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: __init__.py 6392 2006-04-21 18:15:23Z dallingham $ + +class SelectorException(Exception): + + def __init__(self, value): + self.value = value + + def __str__(self): + return repr(self.value) diff --git a/gramps2/src/Selectors/_SelectorFactory.py b/gramps2/src/Selectors/_SelectorFactory.py new file mode 100644 index 000000000..0c02d0703 --- /dev/null +++ b/gramps2/src/Selectors/_SelectorFactory.py @@ -0,0 +1,52 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2000-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: __init__.py 6392 2006-04-21 18:15:23Z dallingham $ + +from _SelectorExceptions import SelectorException + +def selector_factory(classname): + if classname == 'Person': + from _SelectPerson import SelectPerson + cls = SelectPerson + elif classname == 'Family': + from _SelectFamily import SelectFamily + cls = SelectFamily + elif classname == 'Event': + from _SelectEvent import SelectEvent + cls = SelectEvent + elif classname == 'Place': + from _SelectPlace import SelectPlace + cls = SelectPlace + elif classname == 'Source': + from _SelectSource import SelectSource + cls = SelectSource + elif classname == 'MediaObject': + from _SelectObject import SelectObject + cls = SelectObject + elif classname == 'Repository': + from _SelectRepository import SelectRepository + cls = SelectRepository + else: + raise SelectorException("Attempt to create unknown " + "selector class: " + "classname = %s" % (str(classname),)) + + return cls diff --git a/gramps2/src/Selectors/__init__.py b/gramps2/src/Selectors/__init__.py new file mode 100644 index 000000000..8ef119cc8 --- /dev/null +++ b/gramps2/src/Selectors/__init__.py @@ -0,0 +1,24 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2000-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: __init__.py 6392 2006-04-21 18:15:23Z dallingham $ + +from _SelectorFactory import selector_factory + diff --git a/gramps2/src/plugins/FilterEditor.py b/gramps2/src/plugins/FilterEditor.py index ddcec304d..fd29c4921 100644 --- a/gramps2/src/plugins/FilterEditor.py +++ b/gramps2/src/plugins/FilterEditor.py @@ -63,7 +63,8 @@ from Filters import GenericFilter, FilterList, Rules, \ import AutoComp import ListModel import Utils -import SelectPerson +from Selectors import selector_factory +SelectPerson = selector_factory('Person') import ManagedWindow from PluginUtils import Tool, register_tool diff --git a/gramps2/src/plugins/SimpleBookTitle.py b/gramps2/src/plugins/SimpleBookTitle.py index 7dd80e699..ad20f897b 100644 --- a/gramps2/src/plugins/SimpleBookTitle.py +++ b/gramps2/src/plugins/SimpleBookTitle.py @@ -42,7 +42,8 @@ import gtk #------------------------------------------------------------------------ from PluginUtils import Report, ReportOptions, register_report import BaseDoc -import SelectObject +from Selectors import selector_factory +SelectObject = selector_factory('MediaObject') import AddMedia import ImgManip