* src/Assistant.py: Cosmeti c changes.

* src/Exporter.py: Start converting to Assistant.
* src/ViewManager.py: Add handler for Export; add hot keys for
import and export.


svn: r5704
This commit is contained in:
Alex Roitman 2006-01-10 17:09:40 +00:00
parent 9586db0f66
commit edc9e9b881
4 changed files with 154 additions and 128 deletions

View File

@ -1,3 +1,9 @@
2006-01-10 Alex Roitman <shura@gramps-project.org>
* src/Assistant.py: Cosmeti c changes.
* src/Exporter.py: Start converting to Assistant.
* src/ViewManager.py: Add handler for Export; add hot keys for
import and export.
2006-01-09 Don Allingham <don@gramps-project.org> 2006-01-09 Don Allingham <don@gramps-project.org>
* relation.svg: Relationship view icon * relation.svg: Relationship view icon
* media.svg: Relationship view icon * media.svg: Relationship view icon

View File

@ -1,7 +1,7 @@
# #
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2000-2003 Donald N. Allingham # Copyright (C) 2000-2006 Donald N. Allingham
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -18,36 +18,70 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
# $Id$
#-------------------------------------------------------------------------
#
# Standard python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _ from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GTK modules
#
#-------------------------------------------------------------------------
import gtk import gtk
import gtk.gdk import gtk.gdk
import gobject import gobject
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
import const import const
#-------------------------------------------------------------------------
#
# Constants
#
#-------------------------------------------------------------------------
_gramps_png = "%s/gramps.png" % const.rootDir _gramps_png = "%s/gramps.png" % const.rootDir
_splash_jpg = "%s/splash.jpg" % const.rootDir _splash_jpg = "%s/splash.jpg" % const.rootDir
_format = '<span weight="bold" size="xx-large">%s</span>' _format = '<span weight="bold" size="xx-large">%s</span>'
#-------------------------------------------------------------------------
#
# Assistant class
#
#-------------------------------------------------------------------------
class Assistant(gtk.Object): class Assistant(gtk.Object):
""" A tabbed dialog box used to implement Assistant interfaces.""" """ A tabbed dialog box used to implement Assistant interfaces."""
__gproperties__ = {} __gproperties__ = {}
__gsignals__ = { 'page-changed' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, __gsignals__ = {
(gobject.TYPE_INT,)), 'page-changed' : (gobject.SIGNAL_RUN_LAST,
'before-page-next' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, gobject.TYPE_NONE,
(gobject.TYPE_INT,)), (gobject.TYPE_INT,)),
'after-page-next' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, 'before-page-next' : (gobject.SIGNAL_RUN_LAST,
(gobject.TYPE_INT,)), gobject.TYPE_NONE,
'before-page-back' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_INT,)),
(gobject.TYPE_INT,)), 'after-page-next' : (gobject.SIGNAL_RUN_LAST,
'after-page-back' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, gobject.TYPE_NONE,
(gobject.TYPE_INT,)), (gobject.TYPE_INT,)),
'complete' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, 'before-page-back' : (gobject.SIGNAL_RUN_LAST,
()) gobject.TYPE_NONE,
} (gobject.TYPE_INT,)),
'after-page-back' : (gobject.SIGNAL_RUN_LAST,
gobject.TYPE_NONE,
(gobject.TYPE_INT,)),
'complete' : (gobject.SIGNAL_RUN_LAST,
gobject.TYPE_NONE,
())
}
def __init__(self,title,complete): def __init__(self,title,complete):
gobject.GObject.__init__(self) gobject.GObject.__init__(self)
@ -109,11 +143,11 @@ class Assistant(gtk.Object):
self.window.add(vbox) self.window.add(vbox)
def do_get_property(self, prop): def do_get_property(self, prop):
'''Return the gproperty's value.''' """Return the gproperty's value."""
raise AttributeError, 'unknown property %s' % prop.name raise AttributeError, 'unknown property %s' % prop.name
def do_set_property(self, prop, value): def do_set_property(self, prop, value):
'''Set the property of writable properties.''' """Set the property of writable properties."""
raise AttributeError, 'unknown or read only property %s' % prop.name raise AttributeError, 'unknown or read only property %s' % prop.name
@ -227,11 +261,11 @@ if __name__ == "__main__":
a = Assistant('Getting started',complete) a = Assistant('Getting started',complete)
a.set_intro('Welcome to GRAMPS, the Genealogical Research ' a.set_intro('Welcome to GRAMPS, the Genealogical Research '
'and Analysis Management Programming System.\n' 'and Analysis Management Programming System.\n'
'Several options and information need to be gathered ' 'Several options and information need to be gathered '
'before GRAMPS is ready to be used. Any of this ' 'before GRAMPS is ready to be used. Any of this '
'information can be changed in the future in the ' 'information can be changed in the future in the '
'Preferences dialog under the Settings menu.') 'Preferences dialog under the Settings menu.')
box = gtk.VBox() box = gtk.VBox()
box.set_spacing(12) box.set_spacing(12)

View File

@ -1,7 +1,7 @@
# #
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2004-2005 Donald N. Allingham # Copyright (C) 2004-2006 Donald N. Allingham
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -36,7 +36,6 @@ from gettext import gettext as _
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import gtk import gtk
import Assistant
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -49,7 +48,8 @@ import PluginMgr
import QuestionDialog import QuestionDialog
import GrampsKeys import GrampsKeys
import GrampsDisplay import GrampsDisplay
import Assistant
print "0"
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Exporter # Exporter
@ -66,18 +66,20 @@ class Exporter:
name. name.
""" """
def __init__(self,parent,parent_window): def __init__(self,dbstate,uistate):
""" """
Set up the window, the druid, and build all the druid's pages. Set up the window, the druid, and build all the druid's pages.
Some page elements are left empty, since their contents depends Some page elements are left empty, since their contents depends
on the user choices and on the success of the attempted save. on the user choices and on the success of the attempted save.
""" """
self.parent = parent self.dbstate = dbstate
self.parent_window = parent_window self.uistate = uistate
if self.parent.active_person: # self.parent_window = parent_window
self.person = self.parent.active_person if self.dbstate.active:
self.person = self.dbstate.active
else: else:
self.person = self.parent.find_initial_person() pass
# self.person = self.parent.find_initial_person()
self.build_exports() self.build_exports()
self.confirm_label = gtk.Label() self.confirm_label = gtk.Label()
@ -85,26 +87,19 @@ class Exporter:
self.w = Assistant.Assistant(_('Saving your data'),None) self.w = Assistant.Assistant(_('Saving your data'),None)
self.w.set_intro( self.w.set_intro(self.get_intro_text())
_('Under normal circumstances, GRAMPS does not require you '
'to directly save your changes. All changes you make are '
'immediately saved to the database.\n\n'
'This process will help you save a copy of your data '
'in any of the several formats supported by GRAMPS. '
'This can be used to make a copy of your data, backup '
'your data, or convert it to a format that will allow '
'you to transfer it to a different program.\n\n'
'If you change your mind during this process, you '
'can safely press the Cancel button at any time and your '
'present database will still be intact.'))
self.w.add_page(self.build_info_page()) title,box = self.build_format_page()
self.w.add_page(self.build_format_page()) self.w.add_page(title,box)
self.file_sel_page = self.build_file_sel_page()
self.w.add_page(self.file_sel_page) title,box = self.build_file_sel_page()
self.w.add_page(self.build_confirm_page()) self.w.add_page(title,box)
self.last_page = self.build_last_page()
self.w.add_page(self.last_page) title,box = self.build_confirm_page()
self.w.add_page(title,box)
title,text=self.get_conclusion_text()
self.w.set_conclusion(title,text)
self.w.show() self.w.show()
@ -120,42 +115,18 @@ class Exporter:
""" """
GrampsDisplay.help('export-data') GrampsDisplay.help('export-data')
def build_info_page(self): def get_intro_text(self):
""" return _('Under normal circumstances, GRAMPS does not require you '
Build initial druid page with the overall information about the process. 'to directly save your changes. All changes you make are '
This is a static page, nothing fun here :-) 'immediately saved to the database.\n\n'
""" 'This process will help you save a copy of your data '
p = DruidPageEdge(0) 'in any of the several formats supported by GRAMPS. '
p.set_title() 'This can be used to make a copy of your data, backup '
p.set_title_color(self.fg_color) 'your data, or convert it to a format that will allow '
p.set_bg_color(self.bg_color) 'you to transfer it to a different program.\n\n'
p.set_logo(self.logo) 'If you change your mind during this process, you '
p.set_watermark(self.splash) 'can safely press the Cancel button at any time and your '
p.set_text(_('Under normal circumstances, GRAMPS does not require you ' 'present database will still be intact.')
'to directly save your changes. All changes you make are '
'immediately saved to the database.\n\n'
'This process will help you save a copy of your data '
'in any of the several formats supported by GRAMPS. '
'This can be used to make a copy of your data, backup '
'your data, or convert it to a format that will allow '
'you to transfer it to a different program.\n\n'
'If you change your mind during this process, you '
'can safely press the Cancel button at any time and your '
'present database will still be intact.'))
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 = DruidPageEdge(1)
p.set_title_color(self.fg_color)
p.set_bg_color(self.bg_color)
p.set_logo(self.logo)
p.set_watermark(self.splash)
p.connect('finish',self.close)
return p
def build_confirm_page(self): def build_confirm_page(self):
""" """
@ -164,17 +135,13 @@ class Exporter:
is necessary, because no choice is made by the user when this is necessary, because no choice is made by the user when this
page is set up. page is set up.
""" """
p = DruidPageStandard() page_title = _('Final save confirmation')
p.set_title(_('Final save confirmation')) box = gtk.VBox()
p.set_title_foreground(self.fg_color) box.set_spacing(12)
p.set_background(self.bg_color) box.add(self.confirm_label)
p.set_logo(self.logo) #p.connect('prepare',self.build_confirm_label)
#p.connect('next',self.save)
p.append_item("",self.confirm_label,"") return (page_title,box)
p.connect('prepare',self.build_confirm_label)
p.connect('next',self.save)
return p
def build_confirm_label(self,obj,obj2): def build_confirm_label(self,obj,obj2):
""" """
@ -219,10 +186,29 @@ class Exporter:
'not alter the copy you have just made. ')) 'not alter the copy you have just made. '))
else: else:
self.last_page.set_title(_('Saving failed')) self.last_page.set_title(_('Saving failed'))
self.last_page.set_text(_('There was an error ' self.last_page.set_text()
'while saving your data. Please go back and try again.\n\n'
'Note: your currently opened database is safe. It was only ' def get_conclusion_text(self,success=False):
'a copy of your data that failed to save.')) if success:
return (
_('Your data has been saved'),
_('The copy of your data has been '
'successfully saved. You may press Apply button '
'now to continue.\n\n'
'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:
return (
_('Saving failed'),
_('There was an error while saving your data. '
'Please go back and try again.\n\n'
'Note: your currently opened database is safe. '
'It was only '
'a copy of your data that failed to save.')
)
def build_format_page(self): def build_format_page(self):
""" """
@ -231,15 +217,10 @@ class Exporter:
""" """
self.format_buttons = [] self.format_buttons = []
p = DruidPageStandard() page_title = _('Choosing the format to save')
p.set_title(_('Choosing the format to save'))
p.set_title_foreground(self.fg_color)
p.set_background(self.bg_color)
p.set_logo(self.logo)
box = gtk.VBox() box = gtk.VBox()
box.set_spacing(12) box.set_spacing(12)
p.append_item("",box,"")
table = gtk.Table(2*len(self.exports),2) table = gtk.Table(2*len(self.exports),2)
table.set_row_spacings(6) table.set_row_spacings(6)
@ -260,9 +241,9 @@ class Exporter:
tip.set_tip(button,description) tip.set_tip(button,description)
box.add(table) box.add(table)
box.show_all() #box.show_all()
p.connect('next',self.build_options) #p.connect('next',self.build_options)
return p return (page_title,box)
def build_options(self,obj,obj2): def build_options(self,obj,obj2):
""" """
@ -305,22 +286,20 @@ class Exporter:
""" """
Build a druid page embedding the FileChooserWidget. Build a druid page embedding the FileChooserWidget.
""" """
p = DruidPageStandard() page_title = _('Selecting the file name')
p.set_title(_('Selecting the file name'))
p.set_title_foreground(self.fg_color)
p.set_background(self.bg_color)
p.set_logo(self.logo)
self.chooser = gtk.FileChooserWidget(gtk.FILE_CHOOSER_ACTION_SAVE) self.chooser = gtk.FileChooserWidget(gtk.FILE_CHOOSER_ACTION_SAVE)
self.chooser.set_local_only(False) self.chooser.set_local_only(False)
p.append_item("",self.chooser,"") box = gtk.VBox()
box.set_spacing(12)
box.add(self.chooser)
# Dirty hack to enable proper EXPAND and FILL properties of the chooser # Dirty hack to enable proper EXPAND and FILL properties of the chooser
parent = self.chooser.get_parent() box.set_child_packing(self.chooser,1,1,0,gtk.PACK_START)
parent.set_child_packing(self.chooser,1,1,0,gtk.PACK_START) #gradnparent = parent.get_parent()
gradnparent = parent.get_parent() #gradnparent.set_child_packing(parent,1,1,0,gtk.PACK_START)
gradnparent.set_child_packing(parent,1,1,0,gtk.PACK_START) #p.connect('prepare',self.suggest_filename)
p.connect('prepare',self.suggest_filename) return (page_title,box)
return p
def suggest_filename(self,obj,obj2): def suggest_filename(self,obj,obj2):
""" """
@ -386,6 +365,9 @@ class Exporter:
native_ext = 'grdb' native_ext = 'grdb'
native_export = self.native_export native_export = self.native_export
self.exports = [ (native_export,native_title,native_description, self.exports = [(native_export,
native_config,native_ext) ] native_title,
self.exports = self.exports + [ item for item in PluginMgr.export_list ] native_description,
native_config,
native_ext)]
self.exports = self.exports + [item for item in PluginMgr.export_list]

View File

@ -1,7 +1,7 @@
# #
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2005 Donald N. Allingham # Copyright (C) 2005-2006 Donald N. Allingham
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -311,13 +311,13 @@ class ViewManager:
self.actiongroup.add_actions([ self.actiongroup.add_actions([
# Name Stock Icon Label # Name Stock Icon Label
('SaveAs', gtk.STOCK_SAVE_AS, '_Save As'), ('SaveAs', gtk.STOCK_SAVE_AS, '_Save As'),
('Export', gtk.STOCK_SAVE_AS, '_Export'), ('Export', gtk.STOCK_SAVE_AS, '_Export', "<control>e", None, self.export_data),
('Abandon', gtk.STOCK_REVERT_TO_SAVED, '_Abandon changes and quit'), ('Abandon', gtk.STOCK_REVERT_TO_SAVED, '_Abandon changes and quit'),
('Undo', gtk.STOCK_UNDO, '_Undo', '<control>z' ), ('Undo', gtk.STOCK_UNDO, '_Undo', '<control>z' ),
('CmpMerge', None, '_Compare and merge'), ('CmpMerge', None, '_Compare and merge'),
('FastMerge', None, '_Fast merge'), ('FastMerge', None, '_Fast merge'),
('ScratchPad', gtk.STOCK_PASTE, '_ScratchPad', None, None, self.scratchpad), ('ScratchPad', gtk.STOCK_PASTE, '_ScratchPad', None, None, self.scratchpad),
('Import', gtk.STOCK_CONVERT, '_Import', None, None, self.import_data), ('Import', gtk.STOCK_CONVERT, '_Import', "<control>i", None, self.import_data),
('Reports', gtk.STOCK_DND_MULTIPLE, '_Reports', None, None, self.reports_clicked), ('Reports', gtk.STOCK_DND_MULTIPLE, '_Reports', None, None, self.reports_clicked),
('Tools', gtk.STOCK_EXECUTE, '_Tools', None, None, self.tools_clicked), ('Tools', gtk.STOCK_EXECUTE, '_Tools', None, None, self.tools_clicked),
('EditMenu', None, '_Edit'), ('EditMenu', None, '_Edit'),
@ -821,6 +821,10 @@ class ViewManager:
while gtk.events_pending(): while gtk.events_pending():
gtk.main_iteration() gtk.main_iteration()
def export_data(self,obj):
import Exporter
Exporter.Exporter(self.state,self.uistate)
def import_data(self,obj): def import_data(self,obj):
choose = gtk.FileChooserDialog(_('GRAMPS: Import database'), choose = gtk.FileChooserDialog(_('GRAMPS: Import database'),
self.uistate.window, self.uistate.window,