remove empty families

svn: r6293
This commit is contained in:
Don Allingham 2006-04-08 05:56:31 +00:00
parent 6ddcf8b7bc
commit ffae52385f
6 changed files with 711 additions and 600 deletions

View File

@ -1,3 +1,6 @@
2006-04-07 Don Allingham <don@gramps-project.org>
* src/Editors/_EditFamily.py: remove empty families
2006-04-07 Brian Matherly <pez4brian@users.sourceforge.net>
* src/docgen/PdfDoc.py: fix columns, error check images
* src/docgen/RTFDoc.py: error check images

View File

@ -82,6 +82,7 @@ class AttachList:
class FamilyView(PageView.PersonNavView):
def __init__(self, dbstate, uistate):
PageView.PersonNavView.__init__(self, 'Relationship View', dbstate, uistate)
dbstate.connect('database-changed', self.change_db)
dbstate.connect('active-changed', self.change_person)

View File

@ -336,6 +336,7 @@ class FastFemaleFilter:
class EditFamily(EditPrimary):
def __init__(self,dbstate, uistate, track, family):
EditPrimary.__init__(self, dbstate, uistate, track,
family, dbstate.db.get_family_from_handle)
@ -765,7 +766,13 @@ class EditFamily(EditPrimary):
person.family_list.append(self.obj.handle)
self.db.commit_person(person,trans)
def object_is_empty(self):
return self.obj.get_father_handle() == None and \
self.obj.get_mother_handle() == None and \
len(self.obj.get_child_handle_list()) == 0
def save(self,*obj):
if not self.added:
original = self.db.get_family_from_handle(self.obj.handle)
else:
@ -806,6 +813,10 @@ class EditFamily(EditPrimary):
_("No data exists for this family. Please "
"enter data or cancel the edit."))
return
elif original and self.object_is_empty():
trans = self.db.transaction_begin()
self.db.remove_family(self.obj.handle,trans)
self.db.transaction_commit(trans,_("Remove Family"))
elif cmp(original.serialize(),self.obj.serialize()):
trans = self.db.transaction_begin()
@ -838,5 +849,6 @@ class EditFamily(EditPrimary):
else:
self.db.commit_family(self.obj,trans)
self.db.transaction_commit(trans,_("Edit Family"))
self.close_window()

View File

@ -20,6 +20,13 @@
# $Id$
"""
TreeModel for the GRAMPS Person tree.
"""
__author__ = "Donald N. Allingham"
__revision__ = "$Revision:$"
#-------------------------------------------------------------------------
#
# Standard python modules
@ -98,11 +105,17 @@ _MARKER_COL= 20
if sys.version_info[0:2] == (2, 3):
def locale_sort(mylist):
mylist = map(lambda x: x + "\x00",mylist)
"""
Sort version to get around a python2.3 bug with unicode strings
"""
mylist = [ value + "\x00" for value in mylist ]
mylist.sort(locale.strcoll)
return map(lambda x: x[:-1],mylist)
return [ value[:-1] for value in mylist ]
else:
def locale_sort(mylist):
"""
Normal sort routine
"""
mylist.sort(locale.strcoll)
return mylist
@ -112,8 +125,15 @@ else:
#
#-------------------------------------------------------------------------
class PeopleModel(gtk.GenericTreeModel):
"""
Basic GenericTreeModel interface to handle the Tree interface for
the PersonView
"""
def __init__(self, db, data_filter=None, invert_result=False, skip=[]):
"""
Initialize the model building the initial data
"""
gtk.GenericTreeModel.__init__(self)
self.db = db
@ -128,10 +148,16 @@ class PeopleModel(gtk.GenericTreeModel):
self.rebuild_data(data_filter, skip)
def rebuild_data(self, data_filter=None, skip=[]):
"""
Convience function that calculates the new data and assigns it.
"""
self.calculate_data(data_filter, skip)
self.assign_data()
def calculate_data(self, dfilter=None, skip=[]):
"""
Calculates the new path to node values for the model.
"""
if dfilter:
self.dfilter = dfilter
self.temp_iter2path = {}
@ -330,7 +356,8 @@ class PeopleModel(gtk.GenericTreeModel):
return data[_ID_COL]
def column_change(self, data, node):
return unicode(time.strftime('%x %X', time.localtime(data[_CHANGE_COL])),
return unicode(
time.strftime('%x %X', time.localtime(data[_CHANGE_COL])),
_codeset)
def column_gender(self, data, node):
@ -422,7 +449,8 @@ class PeopleModel(gtk.GenericTreeModel):
if event:
place_handle = event.get_place_handle()
if place_handle:
place_title = self.db.get_place_from_handle(place_handle).get_title()
place = self.db.get_place_from_handle(place_handle)
place_title = place.get_title()
if place_title != "":
return cgi.escape(place_title)
@ -434,7 +462,8 @@ class PeopleModel(gtk.GenericTreeModel):
if etype in [Event.BURIAL, Event.CREMATION]:
place_handle = event.get_place_handle()
if place_handle:
place_title = self.db.get_place_from_handle(place_handle).get_title()
place = self.db.get_place_from_handle(place_handle)
place_title = place.get_title()
if place_title != "":
return "<i>" + cgi.escape(place_title) + "</i>"
@ -466,7 +495,10 @@ class PeopleModel(gtk.GenericTreeModel):
def column_tooltip(self, data, node):
if const.use_tips:
return ToolTips.TipFromFunction(self.db,lambda: self.db.get_person_from_handle(data[0]))
return ToolTips.TipFromFunction(
self.db,
lambda: self.db.get_person_from_handle(data[0])
)
else:
return u''
@ -484,8 +516,8 @@ _GENDER = [ _(u'female'),_(u'male'),_(u'unknown') ]
# table of column definitions
# (unless this is declared after the PeopleModel class, an error is thrown)
COLUMN_DEFS = [
# data column (method) header column (method) column data type
(PeopleModel.column_name, PeopleModel.column_header, str),
(PeopleModel.column_id, None, str),
(PeopleModel.column_gender, None, str),

View File

@ -23,7 +23,7 @@
"Support for dates"
__author__ = "Donald N. Allingham"
__version__ = "$Revision$"
__revision__ = "$Revision$"
from gettext import gettext as _
from _CalSdn import *
@ -136,10 +136,16 @@ class Date:
self.sortval = 0
def serialize(self):
"""
Convert to a series of tuples for data storage
"""
return (self.calendar, self.modifier, self.quality,
self.dateval, self.text, self.sortval)
def unserialize(self, data):
"""
Load from the format created by serialize
"""
(self.calendar, self.modifier, self.quality,
self.dateval, self.text, self.sortval) = data
return self
@ -332,6 +338,9 @@ class Date:
return val
def _get_low_item(self, index):
"""
Returns the item specified
"""
if self.modifier == Date.MOD_TEXTONLY:
val = 0
else:
@ -339,6 +348,9 @@ class Date:
return val
def _get_low_item_valid(self, index):
"""
Determines if the item specified is valid
"""
if self.modifier == Date.MOD_TEXTONLY:
val = False
else:
@ -346,6 +358,9 @@ class Date:
return val
def _get_high_item(self, index):
"""
Returns the item specified
"""
if self.modifier == Date.MOD_SPAN or self.modifier == Date.MOD_RANGE:
val = self.dateval[index]
else:
@ -362,11 +377,15 @@ class Date:
def set_year(self, year):
"""
Sets the year value
"""
self.dateval = self.dateval[0:2] + (year, ) + self.dateval[3:]
self.calc_sort_value()
self._calc_sort_value()
def get_year_valid(self):
"""
Returns true if the year is valid
"""
return self._get_low_item_valid(Date._POS_YR)
def get_month(self):
@ -378,6 +397,9 @@ class Date:
return self._get_low_item(Date._POS_MON)
def get_month_valid(self):
"""
Returns true if the month is valid
"""
return self._get_low_item_valid(Date._POS_MON)
def get_day(self):
@ -389,15 +411,15 @@ class Date:
return self._get_low_item(Date._POS_DAY)
def get_day_valid(self):
"""
Returns true if the day is valid
"""
return self._get_low_item_valid(Date._POS_DAY)
def get_valid(self):
""" Returns true if any part of the date is valid"""
return self.modifier != Date.MOD_TEXTONLY
def get_incomplete(self):
pass
def get_stop_year(self):
"""
Returns the day of the year associated with the second
@ -465,8 +487,8 @@ class Date:
Date.MOD_AFTER, Date.MOD_ABOUT) and len(value) < 4:
raise DateError("Invalid value. Should be: (DD, MM, YY, slash)")
if modifier in (Date.MOD_RANGE, Date.MOD_SPAN) and len(value) < 8:
raise DateError(
"Invalid value. Should be: (DD,MM,YY,slash1,DD,MM,YY,slash2)")
raise DateError("Invalid value. Should be: (DD, MM, "
"YY, slash1, DD, MM, YY, slash2)")
if modifier not in (Date.MOD_NONE, Date.MOD_BEFORE, Date.MOD_AFTER,
Date.MOD_ABOUT, Date.MOD_RANGE, Date.MOD_SPAN,
Date.MOD_TEXTONLY):
@ -474,8 +496,9 @@ class Date:
if quality not in (Date.QUAL_NONE, Date.QUAL_ESTIMATED,
Date.QUAL_CALCULATED):
raise DateError("Invalid quality")
if calendar not in (Date.CAL_GREGORIAN,Date.CAL_JULIAN,Date.CAL_HEBREW,
Date.CAL_FRENCH,Date.CAL_PERSIAN,Date.CAL_ISLAMIC):
if calendar not in (Date.CAL_GREGORIAN, Date.CAL_JULIAN,
Date.CAL_HEBREW, Date.CAL_FRENCH,
Date.CAL_PERSIAN, Date.CAL_ISLAMIC):
raise DateError("Invalid calendar")
self.quality = quality
@ -488,18 +511,23 @@ class Date:
if year == 0 and month == 0 and day == 0:
self.sortval = 0
else:
self.sortval = Date._calendar_convert[calendar](year,month,day)
func = Date._calendar_convert[calendar]
self.sortval = func(year, month, day)
if text:
self.text = text
def calc_sort_value(self):
def _calc_sort_value(self):
"""
Calculates the numerical sort value associated with the date
"""
year = max(self.dateval[Date._POS_YR], 1)
month = max(self.dateval[Date._POS_MON], 1)
day = max(self.dateval[Date._POS_DAY], 1)
if year == 0 and month == 0 and day == 0:
self.sortval = 0
else:
self.sortval = Date._calendar_convert[self.calendar](year,month,day)
func = Date._calendar_convert[self.calendar]
self.sortval = func(year, month, day)
def convert_calendar(self, calendar):
"""
@ -508,17 +536,17 @@ class Date:
"""
if calendar == self.calendar:
return
(y,m,d) = Date._calendar_change[calendar](self.sortval)
(year, month, day) = Date._calendar_change[calendar](self.sortval)
if self.is_compound():
ry = max(self.dateval[Date._POS_RYR],1)
rm = max(self.dateval[Date._POS_RMON],1)
rd = max(self.dateval[Date._POS_RDAY],1)
sdn = Date._calendar_convert[self.calendar](ry,rm,rd)
(ny,nm,nd) = Date._calendar_change[calendar](sdn)
self.dateval = (d,m,y,self.dateval[Date._POS_SL],
nd,nm,ny,self.dateval[Date._POS_RSL])
ryear = max(self.dateval[Date._POS_RYR], 1)
rmonth = max(self.dateval[Date._POS_RMON], 1)
rday = max(self.dateval[Date._POS_RDAY], 1)
sdn = Date._calendar_convert[self.calendar](ryear, rmonth, rday)
(nyear, nmonth, nday) = Date._calendar_change[calendar](sdn)
self.dateval = (day, month, year, self.dateval[Date._POS_SL],
nday, nmonth, nyear, self.dateval[Date._POS_RSL])
else:
self.dateval = (d,m,y,self.dateval[Date._POS_SL])
self.dateval = (day, month, year, self.dateval[Date._POS_SL])
self.calendar = calendar
def set_as_text(self, text):

View File

@ -20,14 +20,22 @@
# $Id$
"""
Manages the main window and the pluggable views
"""
__author__ = "Donald N. Allingham"
__revision__ = "$Revision:$"
#-------------------------------------------------------------------------
#
# Standard python modules
#
#-------------------------------------------------------------------------
import os
from gettext import gettext as _
from bsddb import db
import os
from cStringIO import StringIO
#-------------------------------------------------------------------------
@ -159,27 +167,31 @@ uidefault = '''<ui>
class ViewManager:
def __init__(self, state):
self.navigation_type = {
PageView.NAVIGATION_NONE: (None, None),
PageView.NAVIGATION_PERSON: (None,None),
}
"""
Initialize the ViewManager
"""
self.state = state
self.active_page = None
self.views = []
self.pages = []
self.window = gtk.Window()
self.window.set_icon_from_file(const.icon)
self.window.connect('destroy', self.quit)
self.file_loaded = False
self._build_main_window()
self._connect_signals()
def _build_main_window(self):
"""
Builds the GTK interface
"""
try:
width = Config.get_width()
height = Config.get_height()
self.window.set_default_size(width,height)
except:
self.window.set_default_size(775,500)
width = 775
height = 500
self.window = gtk.Window()
self.window.set_icon_from_file(const.icon)
self.window.set_default_size(width, height)
self.statusbar = gtk.Statusbar()
@ -204,7 +216,8 @@ class ViewManager:
self.notebook = gtk.Notebook()
self.notebook.set_show_tabs(False)
self.notebook.show()
self.build_ui_manager()
self._init_lists()
self._build_ui_manager()
hbox.pack_start(self.notebook, True)
self.menubar = self.uimanager.get_widget('/MenuBar')
@ -227,9 +240,8 @@ class ViewManager:
vbox.pack_end(hbox2, False)
vbox.show()
self.notebook.connect('switch-page',self.change_page)
self.uistate = DisplayState.DisplayState(self.window, self.statusbar,
self.progress, self.warnbtn,
self.uistate = DisplayState.DisplayState(
self.window, self.statusbar, self.progress, self.warnbtn,
self.uimanager, self.state)
toolbar = self.uimanager.get_widget('/ToolBar')
@ -241,8 +253,10 @@ class ViewManager:
toolbar.insert(openbtn, 1)
self.person_nav = Navigation.PersonNavigation(self.uistate)
self.navigation_type[PageView.NAVIGATION_PERSON] = (self.person_nav,None)
self.recent_manager = DisplayState.RecentDocsMenu(self.uistate,self.state,
self._navigation_type[PageView.NAVIGATION_PERSON] = (self.person_nav,
None)
self.recent_manager = DisplayState.RecentDocsMenu(self.uistate,
self.state,
self.read_file)
self.recent_manager.build()
@ -260,7 +274,95 @@ class ViewManager:
else:
self.toolbar.hide()
def _connect_signals(self):
"""
connects the signals needed
"""
self.window.connect('destroy', self.quit)
self.notebook.connect('switch-page', self.change_page)
def _init_lists(self):
self._file_action_list = [
('FileMenu', None, '_File'),
('New', gtk.STOCK_NEW, '_New', "<control>n", None,
self.new_activate),
('Open', gtk.STOCK_OPEN, '_Open', "<control>o", None,
self.open_activate),
('OpenRecent', None, 'Open _Recent'),
('Quit', gtk.STOCK_QUIT, '_Quit', "<control>q", None, self.quit),
('ViewMenu', None, '_View'),
('Preferences', gtk.STOCK_PREFERENCES, '_Preferences', None, None,
self.preferences_activate),
('HelpMenu', None, '_Help'),
('HomePage', None, _('GRAMPS _home page'), None, None,
self.home_page_activate),
('MailingLists', None, _('GRAMPS _mailing lists'), None, None,
self.mailing_lists_activate),
('ReportBug', None, _('_Report a bug'), None, None,
self.report_bug_activate),
('About', gtk.STOCK_ABOUT, '_About', None, None, self.about),
('PluginStatus', None, '_Plugin status', None, None,
self.plugin_status),
('FAQ', None, '_FAQ', None, None, self.faq_activate),
('UserManual', gtk.STOCK_HELP, '_User Manual', 'F1', None,
self.manual_activate),
('TipOfDay', None, 'Tip of the day', None, None,
self.tip_of_day_activate),
]
self._action_action_list = [
('SaveAs', gtk.STOCK_SAVE_AS, '_Save As'),
('Export', gtk.STOCK_SAVE_AS, '_Export', "<control>e", None,
self.export_data),
('Abandon', gtk.STOCK_REVERT_TO_SAVED, '_Abandon changes and quit'),
('CmpMerge', None, '_Compare and merge'),
('FastMerge', None, '_Fast merge'),
('ScratchPad', gtk.STOCK_PASTE, '_ScratchPad', None, None,
self.scratchpad),
('Import', gtk.STOCK_CONVERT, '_Import', "<control>i", None,
self.import_data),
('Reports', gtk.STOCK_DND_MULTIPLE, '_Reports', None, None,
self.reports_clicked),
('Tools', gtk.STOCK_EXECUTE, '_Tools', None, None,
self.tools_clicked),
('EditMenu', None, '_Edit'),
('ColumnEdit', gtk.STOCK_PROPERTIES, '_Column Editor'),
('GoMenu', None, '_Go'),
('BookMenu', None, '_Bookmarks'),
('AddBook', gtk.STOCK_INDEX, '_Add bookmark', '<control>d', None,
self.add_bookmark),
('EditBook', None, '_Edit bookmarks', '<control>b', None,
self.edit_bookmarks),
('GoToBook', gtk.STOCK_JUMP_TO, '_Go to bookmark'),
('ReportsMenu', None, '_Reports'),
('ToolsMenu', None, '_Tools'),
('WindowsMenu', None, '_Windows'),
]
self._file_toggle_action_list = [
('Sidebar', None, '_Sidebar', None, None, self.sidebar_toggle,
self.show_sidebar ),
('Toolbar', None, '_Toolbar', None, None, self.toolbar_toggle,
self.show_toolbar ),
]
self._undo_action_list = [
('Undo', gtk.STOCK_UNDO, '_Undo', '<control>z', None, self.undo),
]
self._redo_action_list = [
('Redo', gtk.STOCK_REDO, '_Redo', '<shift><control>z', None,
self.redo),
]
self._navigation_type = {
PageView.NAVIGATION_NONE: (None, None),
PageView.NAVIGATION_PERSON: (None, None),
}
def init_interface(self):
self._init_lists()
self.create_pages()
self.change_page(None, None)
if not self.file_loaded:
@ -291,7 +393,7 @@ class ViewManager:
Config.sync()
gtk.main_quit()
def build_ui_manager(self):
def _build_ui_manager(self):
self.merge_ids = []
self.uimanager = gtk.UIManager()
@ -303,64 +405,14 @@ class ViewManager:
self.undoactions = gtk.ActionGroup('Undo')
self.redoactions = gtk.ActionGroup('Redo')
self.fileactions.add_actions([
('FileMenu', None, '_File'),
('New', gtk.STOCK_NEW, '_New', "<control>n", None, self.new_activate),
('Open', gtk.STOCK_OPEN, '_Open', "<control>o", None, self.open_activate),
('OpenRecent', None, 'Open _Recent'),
('Quit', gtk.STOCK_QUIT, '_Quit', "<control>q", None, self.quit),
('ViewMenu', None, '_View'),
('Preferences', gtk.STOCK_PREFERENCES, '_Preferences', None, None, self.preferences_activate),
('HelpMenu', None, '_Help'),
('HomePage', None, _('GRAMPS _home page'), None, None, self.home_page_activate),
('MailingLists', None, _('GRAMPS _mailing lists'), None, None, self.mailing_lists_activate),
('ReportBug', None, _('_Report a bug'), None, None, self.report_bug_activate),
('About', gtk.STOCK_ABOUT, '_About', None, None, self.about),
('PluginStatus', None, '_Plugin status', None, None, self.plugin_status),
('FAQ', None, '_FAQ', None, None, self.faq_activate),
('UserManual', gtk.STOCK_HELP, '_User Manual', 'F1', None, self.manual_activate),
('TipOfDay', None, 'Tip of the day', None, None, self.tip_of_day_activate),
])
self.fileactions.add_actions(self._file_action_list)
self.actiongroup.add_actions(self._action_action_list)
self.fileactions.add_toggle_actions(self._file_toggle_action_list)
self.actiongroup.add_actions([
# Name Stock Icon Label
('SaveAs', gtk.STOCK_SAVE_AS, '_Save As'),
('Export', gtk.STOCK_SAVE_AS, '_Export', "<control>e", None, self.export_data),
('Abandon', gtk.STOCK_REVERT_TO_SAVED, '_Abandon changes and quit'),
('CmpMerge', None, '_Compare and merge'),
('FastMerge', None, '_Fast merge'),
('ScratchPad', gtk.STOCK_PASTE, '_ScratchPad', None, None, self.scratchpad),
('Import', gtk.STOCK_CONVERT, '_Import', "<control>i", None, self.import_data),
('Reports', gtk.STOCK_DND_MULTIPLE, '_Reports', None, None, self.reports_clicked),
('Tools', gtk.STOCK_EXECUTE, '_Tools', None, None, self.tools_clicked),
('EditMenu', None, '_Edit'),
('ColumnEdit', gtk.STOCK_PROPERTIES, '_Column Editor'),
('GoMenu', None, '_Go'),
('BookMenu', None, '_Bookmarks'),
('AddBook', gtk.STOCK_INDEX, '_Add bookmark', '<control>d', None, self.add_bookmark),
('EditBook', None, '_Edit bookmarks', '<control>b', None, self.edit_bookmarks),
('GoToBook', gtk.STOCK_JUMP_TO, '_Go to bookmark'),
('ReportsMenu', None, '_Reports'),
('ToolsMenu', None, '_Tools'),
('WindowsMenu', None, '_Windows'),
])
self.fileactions.add_toggle_actions([
('Sidebar', None, '_Sidebar', None, None, self.sidebar_toggle,
self.show_sidebar
),
('Toolbar', None, '_Toolbar', None, None, self.toolbar_toggle,
self.show_toolbar
),
])
self.undoactions.add_actions([
('Undo',gtk.STOCK_UNDO,'_Undo','<control>z',None,self.undo)])
self.undoactions.add_actions(self._undo_action_list)
self.undoactions.set_sensitive(False)
self.redoactions.add_actions([
('Redo',gtk.STOCK_REDO,'_Redo','<shift><control>z',None,self.redo)
])
self.redoactions.add_actions(self._redo_action_list)
self.redoactions.set_sensitive(False)
merge_id = self.uimanager.add_ui_from_string(uidefault)
@ -510,11 +562,11 @@ class ViewManager:
self.active_page = self.pages[num]
self.active_page.set_active()
old_nav = self.navigation_type[self.prev_nav]
old_nav = self._navigation_type[self.prev_nav]
if old_nav[0] != None:
old_nav[0].disable()
nav_type = self.navigation_type[self.active_page.navigation_type()]
nav_type = self._navigation_type[self.active_page.navigation_type()]
if nav_type[0] != None:
nav_type[0].enable()
@ -536,13 +588,12 @@ class ViewManager:
def open_activate(self, obj):
choose = gtk.FileChooserDialog(_('GRAMPS: Open database'),
choose = gtk.FileChooserDialog(
_('GRAMPS: Open database'),
self.uistate.window,
gtk.FILE_CHOOSER_ACTION_OPEN,
(gtk.STOCK_CANCEL,
gtk.RESPONSE_CANCEL,
gtk.STOCK_OPEN,
gtk.RESPONSE_OK))
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
gtk.STOCK_OPEN, gtk.RESPONSE_OK))
# Always add automatic (macth all files) filter
add_all_files_filter(choose)
@ -601,40 +652,22 @@ class ViewManager:
log.error("Failed to open native.", exc_info=True)
return False
# The above native formats did not work, so we need to
# look up the importer for this format
# and create an empty native database to import data in
# for (importData,mime_filter,mime_type,native_format,format_name) in import_list:
# if filetype == mime_type or the_file == mime_type:
# QuestionDialog.OkDialog(
# _("Opening non-native format"),
# _("New GRAMPS database has to be set up "
# "when opening non-native formats. The "
# "following dialog will let you select "
# "the new database."),
# self.state.window)
# prompter = NewNativeDbPrompter(self.parent,self.parent_window)
# if prompter.chooser():
# importData(self.state.db,filename)
# #self.parent.import_tool_callback()
# return True
# else:
# return False
QuestionDialog.ErrorDialog(
_("Could not open file: %s") % filename,
_('File type "%s" is unknown to GRAMPS.\n\nValid types are: GRAMPS database, GRAMPS XML, GRAMPS package, and GEDCOM.') % filetype)
_('File type "%s" is unknown to GRAMPS.\n\n'
'Valid types are: GRAMPS database, GRAMPS XML, '
'GRAMPS package, and GEDCOM.') % filetype)
choose.destroy()
return False
def new_activate(self, obj):
choose = gtk.FileChooserDialog(_('GRAMPS: Create GRAMPS database'),
choose = gtk.FileChooserDialog(
_('GRAMPS: Create GRAMPS database'),
self.uistate.window,
gtk.FILE_CHOOSER_ACTION_SAVE,
(gtk.STOCK_CANCEL,
gtk.RESPONSE_CANCEL,
gtk.STOCK_OPEN,
gtk.RESPONSE_OK))
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
gtk.STOCK_OPEN, gtk.RESPONSE_OK))
# Always add automatic (macth all files) filter
add_all_files_filter(choose)
@ -668,7 +701,8 @@ class ViewManager:
self.state.db.close()
except:
pass
self.state.change_database(GrampsDb.gramps_db_factory(const.app_gramps)())
factory = GrampsDb.gramps_db_factory
self.state.change_database(factory(const.app_gramps)())
self.uistate.clear_history()
self.read_file(filename)
self.state.signal_change()
@ -691,19 +725,20 @@ class ViewManager:
(the_path, the_file) = os.path.split(filename)
Config.save_last_import_dir(the_path)
factory = GrampsDb.gramps_db_factory
success = False
if filetype == const.app_gramps:
self.state.change_database(GrampsDb.gramps_db_factory(db_type = const.app_gramps)())
self.state.change_database(factory(db_type = const.app_gramps)())
success = self.read_file(filename) #, update_msg)
self.state.signal_change()
self.change_page(None, None)
elif filetype == const.app_gramps_xml:
self.state.change_database(GrampsDb.gramps_db_factory(db_type = const.app_gramps_xml)())
self.state.change_database(factory(db_type = const.app_gramps_xml)())
success = self.read_file(filename)
self.state.signal_change()
self.change_page(None, None)
elif filetype == const.app_gedcom:
self.state.change_database(GrampsDb.gramps_db_factory(db_type = const.app_gedcom)())
self.state.change_database(factory(db_type = const.app_gedcom)())
success = self.read_file(filename)
self.state.signal_change()
self.change_page(None, None)