* NEWS: Update.

* src/Exporter.py: Clean up, add doc strings.
* src/plugins/WriteGedcom.py: Change registration.
Use command-line export for the time being (all defaults).


svn: r3259
This commit is contained in:
Alex Roitman 2004-07-10 23:31:28 +00:00
parent c5787e9e4e
commit 15a80062ea
4 changed files with 130 additions and 23 deletions

View File

@ -1,3 +1,9 @@
2004-07-10 Alex Roitman <shura@alex.neuro.umn.edu>
* NEWS: Update.
* src/Exporter.py: Clean up, add doc strings.
* src/plugins/WriteGedcom.py: Change registration.
Use command-line export for the time being (all defaults).
2004-07-09 Don Allingham <dallingham@users.sourceforge.net>
* src/AddMedia.py: Handle the new file selector
* src/MediaView.py: redraw list properly

View File

@ -1,9 +1,18 @@
Version 1.1.1 -- the "Rat cake, rat sorbet, rat pudding, or strawberry tart" release
* New "Save as" wizard interface: replaces old Export and Save as options.
Note: this is still unfinished at the 1.1.1 release time, please be patient.
* New Find interface for People View.
* Switch to internal IDs. These are universally unique and not user-visible.
The user-visible GRAMPS IDs are kept and are editable now.
* Re-design of Open and Import options. Both will take any format now.
Open will start a new database with the specified data. Import will
incorporate new data into the currently opened database.
* Mime types and icons for gramps package and GEDCOM files.
* Pedigree View has person-dependent submenus in the context menu:
Spouses, Siblings, Children, and Parents.
* Command line arguments handling is back on track.
* Sorting improvements.
* Bug fixes.
* Numerous bug fixes.
Version 1.1.0 -- the "And now for something completely different" release
* Berkeley database backend!!! Many thanks to Billy Earney for db expertise!

View File

@ -68,8 +68,17 @@ class Exporter:
"""
def __init__(self,parent,parent_window):
"""
Set up the window, the druid, and build all the druid's pages.
Some page elements are left empty, since their contents depends
on the user choices and on the success of the attempted save.
"""
self.parent = parent
self.parent_window = parent_window
if self.parent.active_person:
self.active_person = self.parent.active_person
else:
self.active_person = self.parent.find_initial_person()
self.build_exports()
self.confirm_label = gtk.Label()
@ -99,13 +108,23 @@ class Exporter:
self.w.show_all()
def close(self,obj,obj2=None):
"""
Close and delete handler.
"""
self.w.destroy()
def help(self,obj):
"""
Help handler.
"""
#FIXME: point to the correct section when it exists
gnome.help_display('gramps-manual','index')
def build_info_page(self):
"""
Build initial druid page with the overall information about the process.
This is a static page, nothing fun here :-)
"""
p = gnome.ui.DruidPageEdge(0)
p.set_title(_('Saving your data'))
p.set_title_color(self.fg_color)
@ -126,6 +145,10 @@ class Exporter:
return p
def build_last_page(self):
"""
Build the last druid page. The actual text will be added after the
save is performed and the success status us known.
"""
p = gnome.ui.DruidPageEdge(1)
p.set_title_color(self.fg_color)
p.set_bg_color(self.bg_color)
@ -135,6 +158,12 @@ class Exporter:
return p
def build_confirm_page(self):
"""
Build a save confirmation page. Setting up the actual label
text is deferred until the page is being prepared. This
is necessary, because no choice is made by the user when this
page is set up.
"""
p = gnome.ui.DruidPageStandard()
p.set_title(_('Final save confirmation'))
p.set_title_foreground(self.fg_color)
@ -148,10 +177,16 @@ class Exporter:
return p
def build_confirm_label(self,obj,obj2):
"""
Build the text of the confirmation label. This should query
the selected options (format, filename) and present the summary
of the proposed action.
"""
filename = self.chooser.get_filename()
name = os.path.split(filename)[1]
folder = os.path.split(filename)[0]
format = self.exports[self.ix][1].replace('_','')
ix = self.get_selected_format_index()
format = self.exports[ix][1].replace('_','')
self.confirm_label.set_text(
_('The data will be saved as follows:\n\n'
@ -161,16 +196,22 @@ class Exporter:
self.confirm_label.set_line_wrap(gtk.TRUE)
def save(self,obj,obj2):
"""
Perform the actual Save As/Export operation.
Depending on the success status, set the text for the final page.
"""
filename = self.chooser.get_filename()
success = self.exports[self.ix][0](self.parent.db,filename)
ix = self.get_selected_format_index()
success = self.exports[ix][0](self.parent.db,filename)
if success:
self.last_page.set_title(_('Your data has been saved'))
self.last_page.set_text(_('You may press Apply button '
self.last_page.set_text(_('The copy of your data has been '
'successfully saved. You may press Apply button '
'now to continue.\n\n'
'Note: the database opened in your GRAMPS window '
'is NOT the file you have just saved. Future editing '
'of the currently opened database will not alter the '
'copy you have just made. '))
'Note: the database currently opened in your GRAMPS '
'window is NOT the file you have just saved. '
'Future editing of the currently opened database will '
'not alter the copy you have just made. '))
else:
self.last_page.set_title(_('Saving failed'))
self.last_page.set_text(_('There was an error '
@ -179,6 +220,10 @@ class Exporter:
'of your data that failed to save.'))
def build_format_page(self):
"""
Build a page with the table of format radio buttons and
their descriptions.
"""
self.format_buttons = []
p = gnome.ui.DruidPageStandard()
@ -203,7 +248,6 @@ class Exporter:
button = gtk.RadioButton(group,title)
if not group:
group = button
button.connect('toggled',self.on_format_toggled)
self.format_buttons.append(button)
table.attach(button,0,2,2*ix,2*ix+1)
label = gtk.Label(description)
@ -212,10 +256,12 @@ class Exporter:
box.add(table)
box.show_all()
return p
def build_file_sel_page(self):
"""
Build a druid page embedding the FileChooserWidget.
"""
p = gnome.ui.DruidPageStandard()
p.set_title(_('Selecting the file name'))
p.set_title_foreground(self.fg_color)
@ -223,12 +269,41 @@ class Exporter:
p.set_logo(self.logo)
self.chooser = gtk.FileChooserWidget(gtk.FILE_CHOOSER_ACTION_SAVE)
self.on_format_toggled(self.format_buttons[0])
p.append_item("",self.chooser,"")
p.connect('prepare',self.suggest_filename)
return p
def suggest_filename(self,obj,obj2):
"""
Prepare suggested filename and set it in the file chooser.
"""
ix = self.get_selected_format_index()
ext = self.exports[ix][4]
if ext == 'gramps':
new_filename = os.path.expanduser('~/data.gramps')
else:
new_filename = Utils.get_new_filename(ext)
self.chooser.set_filename(new_filename)
self.chooser.set_current_name(os.path.split(new_filename)[1])
def get_selected_format_index(self):
"""
Query the format radiobuttons and return the index number
of the selected one.
"""
for ix in range(len(self.format_buttons)):
button = self.format_buttons[ix]
if button.get_active():
return ix
else:
return 0
def native_export(self,database,filename):
"""
Native database export. For now, just stupid copying of the present
grdb file under another name. In the future, filter and other
options may be added.
"""
try:
shutil.copyfile(database.get_save_path(),filename)
return 1
@ -237,16 +312,12 @@ class Exporter:
_('System message was: %s') % msg )
return 0
def on_format_toggled(self,obj):
if not obj.get_active():
return
self.ix = self.format_buttons.index(obj)
ext = self.exports[self.ix][4]
new_filename = Utils.get_new_filename(ext)
self.chooser.set_filename(new_filename)
self.chooser.set_current_name(os.path.split(new_filename)[1])
def build_exports(self):
"""
This method builds its own list of available exports.
The list is built from the Plugins._exports list
and from the locally defined exports (i.e. native export defined here).
"""
native_title = _('GRAMPS _GRDB database')
native_description =_('The GRAMPS GRDB database is a format '
'that GRAMPS uses to store information. '

View File

@ -538,6 +538,7 @@ class GedcomWriter:
self.restrict = 0
self.private = 0
self.copy = 0
self.images = 0
for p in self.db.get_person_keys():
self.plist[p] = 1
@ -1230,6 +1231,26 @@ class GedcomWriter:
#
#
#-------------------------------------------------------------------------
from Plugins import register_export
def exportData(database,filename):
ret = 0
try:
GedcomWriter(database,None,1,filename)
ret = 1
except:
import DisplayTrace
DisplayTrace.DisplayTrace()
return ret
register_export(writeData,_title_string)
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
_title = _('GE_DCOM 5.5')
_description = _('GEDCOM is used to transfer data between genealogy programs. '
'Nearly all genealogy software will accept a GEDCOM file as input. ')
_config = None
_filename = 'ged'
from Plugins import register_export
register_export(exportData,_title,_description,_config,_filename)