* src/Assistant.py: Many changes.

* src/Exporter.py: Work with new Assistant.
* src/StartupDialog.py: Work with new Assistant.
* src/GrampsLogger/_ErrorReportAssistant.py: Work with new Assistant.
* src/gedcomexport.glade, src/gedcomimport.glade: Move to GrampsDb.


svn: r5725
This commit is contained in:
Alex Roitman
2006-01-12 06:09:14 +00:00
parent 67032ee826
commit 27289bf1ca
7 changed files with 145 additions and 123 deletions

View File

@ -1,3 +1,10 @@
2006-01-11 Alex Roitman <shura@gramps-project.org>
* src/Assistant.py: Many changes.
* src/Exporter.py: Work with new Assistant.
* src/StartupDialog.py: Work with new Assistant.
* src/GrampsLogger/_ErrorReportAssistant.py: Work with new Assistant.
* src/gedcomexport.glade, src/gedcomimport.glade: Move to GrampsDb.
2006-01-11 Don Allingham <don@gramps-project.org> 2006-01-11 Don Allingham <don@gramps-project.org>
* src/FamilyList.py: call family editor * src/FamilyList.py: call family editor
* src/StartupDialog.py: pwm in try/except * src/StartupDialog.py: pwm in try/except

View File

@ -83,7 +83,7 @@ class Assistant(gtk.Object):
()) ())
} }
def __init__(self,title,complete): def __init__(self,complete):
gobject.GObject.__init__(self) gobject.GObject.__init__(self)
self.complete = complete self.complete = complete
@ -92,16 +92,13 @@ class Assistant(gtk.Object):
self.logo = gtk.gdk.pixbuf_new_from_file(_gramps_png) self.logo = gtk.gdk.pixbuf_new_from_file(_gramps_png)
self.splash = gtk.gdk.pixbuf_new_from_file(_splash_jpg) self.splash = gtk.gdk.pixbuf_new_from_file(_splash_jpg)
self.current_page = 0 self.current_page = -1
self.max_page = 1
self.conclusion_set = False
self.window = gtk.Window() self.window = gtk.Window()
titlebox = gtk.HBox() titlebox = gtk.HBox()
self.title_text = [] self.title_text = []
self.title_text.append(_format % title)
self.title = gtk.Label(self.title_text[0]) self.title = gtk.Label('')
self.title.set_alignment(0,0.5) self.title.set_alignment(0,0.5)
self.title.set_use_markup(True) self.title.set_use_markup(True)
@ -150,21 +147,23 @@ class Assistant(gtk.Object):
"""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
def get_number_of_pages(self):
return self.notebook.get_n_pages()
def update_title(self): def update_title(self):
try: self.title.set_label(self.title_text[self.current_page])
self.title.set_label(self.title_text[self.current_page])
except IndexError:
pass
self.title.set_use_markup(True) self.title.set_use_markup(True)
def set_buttons(self): def set_buttons(self):
if self.current_page == self.max_page-1: max_page = self.notebook.get_n_pages()
if self.current_page == max_page-2:
self.next.show() self.next.show()
self.back.show() self.back.show()
self.cancel.show() self.cancel.show()
self.ok.set_sensitive(True) self.ok.set_sensitive(True)
self.next.set_sensitive(False) self.next.set_sensitive(False)
elif self.current_page == self.max_page: self.back.set_sensitive(True)
elif self.current_page == max_page-1:
self.next.hide() self.next.hide()
self.back.hide() self.back.hide()
self.cancel.hide() self.cancel.hide()
@ -195,7 +194,7 @@ class Assistant(gtk.Object):
def next_clicked(self,obj): def next_clicked(self,obj):
self.emit('before-page-next',self.notebook.get_current_page()) self.emit('before-page-next',self.notebook.get_current_page())
if self.current_page == self.max_page: if self.current_page == self.notebook.get_n_pages()-1:
self.emit('complete') self.emit('complete')
self.complete() self.complete()
self.window.destroy() self.window.destroy()
@ -208,17 +207,25 @@ class Assistant(gtk.Object):
self.emit('after-page-next',self.notebook.get_current_page()) self.emit('after-page-next',self.notebook.get_current_page())
self.emit('page-changed',self.notebook.get_current_page()) self.emit('page-changed',self.notebook.get_current_page())
def set_intro(self,text): def add_text_page(self, title, text):
hbox = gtk.HBox(spacing=12) """
image = gtk.Image() Add page with Gramps logo and given text and title.
image.set_from_file(_splash_jpg) Usually, first page (introduction) and last page (conclusion)
hbox.pack_start(image,False) use this method.
label = gtk.Label(text) """
label.set_line_wrap(True) hbox = self.prepare_text_page(text)
hbox.add(label) return self.add_page(title,hbox)
self.notebook.append_page(hbox)
def set_conclusion(self,title,text): def insert_text_page(self, title, text, position):
"""
Add page with Gramps logo and given text and title.
Usually, first page (introduction) and last page (conclusion)
use this method.
"""
hbox = self.prepare_text_page(text)
return self.insert_page(title,hbox,position)
def prepare_text_page(self,text):
hbox = gtk.HBox(spacing=12) hbox = gtk.HBox(spacing=12)
image = gtk.Image() image = gtk.Image()
image.set_from_file(_splash_jpg) image.set_from_file(_splash_jpg)
@ -227,34 +234,37 @@ class Assistant(gtk.Object):
label.set_line_wrap(True) label.set_line_wrap(True)
hbox.add(label) hbox.add(label)
hbox.show_all() hbox.show_all()
if self.conclusion_set: return hbox
self.notebook.remove_page(-1)
self.title_text.pop(-1)
self.notebook.append_page(hbox)
self.title_text.append(_format % title)
self.conclusion_set = True
def add_page(self, title, child): def add_page(self, title, child):
"""
Add page with the title and child widget.
Returns index number of the new page.
"""
self.title_text.append(_format % title) self.title_text.append(_format % title)
self.notebook.append_page(child) return self.notebook.append_page(child)
self.max_page += 1
def insert_page(self, title, child, position=-1): def insert_page(self, title, child, position):
"""
Insert page at a given position.
Returns index number of the new page.
"""
self.title_text.insert(position,_format % title) self.title_text.insert(position,_format % title)
self.notebook.insert_page(child,None,position) return self.notebook.insert_page(child,None,position)
self.max_page += 1
def remove_page(self,position): def remove_page(self,position):
"""
Remove page from a given position.
"""
self.title_text.pop(position) self.title_text.pop(position)
self.notebook.remove_page(position) self.notebook.remove_page(position)
self.max_page -= 1
def get_number_of_pages(self):
return self.max_page
def show(self): def show(self):
self.window.show_all() self.window.show_all()
self.notebook.set_current_page(0) self.current_page = 0
self.notebook.set_current_page(self.current_page)
self.update_title()
self.set_buttons()
self.emit('page-changed',self.notebook.get_current_page()) self.emit('page-changed',self.notebook.get_current_page())
def destroy(self): def destroy(self):
@ -276,13 +286,14 @@ if __name__ == "__main__":
table.attach(text,x3,x4,y,y+1,gtk.EXPAND|gtk.FILL) table.attach(text,x3,x4,y,y+1,gtk.EXPAND|gtk.FILL)
return text return text
a = Assistant('Getting started',complete) a = Assistant(complete)
a.set_intro('Welcome to GRAMPS, the Genealogical Research ' a.add_text_page('Getting started',
'and Analysis Management Programming System.\n' 'Welcome to GRAMPS, the Genealogical Research '
'Several options and information need to be gathered ' 'and Analysis Management Programming System.\n'
'before GRAMPS is ready to be used. Any of this ' 'Several options and information need to be gathered '
'information can be changed in the future in the ' 'before GRAMPS is ready to be used. Any of this '
'Preferences dialog under the Settings menu.') 'information can be changed in the future in the '
'Preferences dialog under the Settings menu.')
box = gtk.VBox() box = gtk.VBox()
box.set_spacing(12) box.set_spacing(12)
@ -301,7 +312,7 @@ if __name__ == "__main__":
box.add(table) box.add(table)
a.add_page('Researcher information',box) a.add_page('Researcher information',box)
a.set_conclusion('aaa','bbb') a.add_text_page('Conclusion title','Very long conclusion text here')
a.show() a.show()
gtk.main() gtk.main()

View File

@ -80,26 +80,25 @@ class Exporter:
self.person = self.dbstate.active self.person = self.dbstate.active
else: else:
pass pass
# FIXME: find_initial_person needs to move into dbstate or db
# and then it will be available here
# self.person = self.parent.find_initial_person() # self.person = self.parent.find_initial_person()
self.build_exports() self.build_exports()
self.confirm_label = gtk.Label()
self.format_option = None self.format_option = None
self.w = Assistant.Assistant(_('Saving your data'),self.complete) self.w = Assistant.Assistant(self.complete)
self.w.set_intro(self.get_intro_text()) self.w.add_text_page(_('Saving your data'),self.get_intro_text())
title1,box1 = self.build_format_page() self.format_page = self.w.add_page(_('Choosing the format to save'),
self.w.add_page(title1,box1) self.build_format_page())
self.format_page = 1
title2,box2 = self.build_file_sel_page() self.file_sel_page = self.w.add_page(_('Selecting the file name'),
self.w.add_page(title2,box2) self.build_file_sel_page())
self.file_sel_page = self.w.get_number_of_pages()
title3,box3 = self.build_confirm_page() self.confirm_page = self.w.add_text_page('','')
self.w.add_page(title3,box3) self.conclusion_page = self.w.add_text_page('','')
self.w.connect('before-page-next',self.on_before_page_next) self.w.connect('before-page-next',self.on_before_page_next)
@ -112,10 +111,11 @@ class Exporter:
if page == self.format_page: if page == self.format_page:
self.build_options() self.build_options()
self.suggest_filename() self.suggest_filename()
elif page == self.file_sel_page-1:
self.build_confirm_label()
elif page == self.file_sel_page: elif page == self.file_sel_page:
self.success = self.save() self.build_confirmation()
elif page == self.confirm_page:
success = self.save()
self.build_conclusion(success)
def help(self,obj): def help(self,obj):
""" """
@ -136,20 +136,7 @@ class Exporter:
'can safely press the Cancel button at any time and your ' 'can safely press the Cancel button at any time and your '
'present database will still be intact.') 'present database will still be intact.')
def build_confirm_page(self): def build_confirmation(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.
"""
page_title = _('Final save confirmation')
box = gtk.VBox()
box.set_spacing(12)
box.add(self.confirm_label)
return (page_title,box)
def build_confirm_label(self):
""" """
Build the text of the confirmation label. This should query Build the text of the confirmation label. This should query
the selected options (format, filename) and present the summary the selected options (format, filename) and present the summary
@ -161,13 +148,15 @@ class Exporter:
ix = self.get_selected_format_index() ix = self.get_selected_format_index()
format = self.exports[ix][1].replace('_','') format = self.exports[ix][1].replace('_','')
self.confirm_label.set_text( confirm_text = _(
_('The data will be saved as follows:\n\n' 'The data will be saved as follows:\n\n'
'Format:\t%s\nName:\t%s\nFolder:\t%s\n\n' 'Format:\t%s\nName:\t%s\nFolder:\t%s\n\n'
'Press OK to proceed, Cancel to abort, or Back to ' 'Press OK to proceed, Cancel to abort, or Back to '
'revisit your options.') % (format, name, folder)) 'revisit your options.') % (format, name, folder)
self.confirm_label.set_line_wrap(True) self.w.remove_page(self.confirm_page)
self.confirm_label.show_all() self.confirm_page = self.w.insert_text_page(_('Final confirmation'),
confirm_text,
self.confirm_page)
def save(self): def save(self):
""" """
@ -184,11 +173,14 @@ class Exporter:
else: else:
success = self.exports[ix][0](self.dbstate.db, success = self.exports[ix][0](self.dbstate.db,
filename,self.person) filename,self.person)
return success
def build_conclusion(self,success):
if success: if success:
conclusion_title = _('Your data has been saved') conclusion_title = _('Your data has been saved')
conclusion_text = _( conclusion_text = _(
'The copy of your data has been ' 'The copy of your data has been '
'successfully saved. You may press Apply button ' 'successfully saved. You may press OK button '
'now to continue.\n\n' 'now to continue.\n\n'
'Note: the database currently opened in your GRAMPS ' 'Note: the database currently opened in your GRAMPS '
'window is NOT the file you have just saved. ' 'window is NOT the file you have just saved. '
@ -202,7 +194,10 @@ class Exporter:
'Note: your currently opened database is safe. ' 'Note: your currently opened database is safe. '
'It was only ' 'It was only '
'a copy of your data that failed to save.') 'a copy of your data that failed to save.')
self.w.set_conclusion(conclusion_title,conclusion_text) self.w.remove_page(self.conclusion_page)
self.conclusion_page = self.w.insert_text_page(conclusion_title,
conclusion_text,
self.conclusion_page)
def build_format_page(self): def build_format_page(self):
""" """
@ -211,8 +206,6 @@ class Exporter:
""" """
self.format_buttons = [] self.format_buttons = []
page_title = _('Choosing the format to save')
box = gtk.VBox() box = gtk.VBox()
box.set_spacing(12) box.set_spacing(12)
@ -235,7 +228,7 @@ class Exporter:
tip.set_tip(button,description) tip.set_tip(button,description)
box.add(table) box.add(table)
return (page_title,box) return box
def build_options(self): def build_options(self):
""" """
@ -252,24 +245,26 @@ class Exporter:
if ix == self.format_option: if ix == self.format_option:
return return
elif self.format_option: elif self.format_option:
self.w.remove_page(self.format_page+1) self.w.remove_page(self.option_page)
self.format_option = None self.format_option = None
title = self.exports[ix][3][0] title = self.exports[ix][3][0]
option_box_class = self.exports[ix][3][1] option_box_class = self.exports[ix][3][1]
self.option_box_instance = option_box_class(self.person) self.option_box_instance = option_box_class(self.person)
box = self.option_box_instance.get_option_box() box = self.option_box_instance.get_option_box()
self.w.insert_page(title,box,self.format_page+1) self.option_page = self.w.insert_page(title,box,
self.format_page+1)
self.confirm_page += 1
self.conclusion_page += 1
self.format_option = ix self.format_option = ix
box.show_all() box.show_all()
elif self.format_option: elif self.format_option:
self.w.remove_page(self.format_page+1) self.w.remove_page(self.option_page)
self.format_option = None self.format_option = None
def build_file_sel_page(self): def build_file_sel_page(self):
""" """
Build a druid page embedding the FileChooserWidget. Build a druid page embedding the FileChooserWidget.
""" """
page_title = _('Selecting the file name')
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)
@ -280,7 +275,7 @@ class Exporter:
# Dirty hack to enable proper EXPAND/FILL properties of the chooser # Dirty hack to enable proper EXPAND/FILL properties of the chooser
box.set_child_packing(self.chooser,1,1,0,gtk.PACK_START) box.set_child_packing(self.chooser,1,1,0,gtk.PACK_START)
return (page_title,box) return box
def suggest_filename(self): def suggest_filename(self):
""" """
@ -324,11 +319,14 @@ class Exporter:
In the future, filter and other options may be added. In the future, filter and other options may be added.
""" """
try: try:
gramps_db_writer_factory(const.app_gramps)(database,filename,person) gramps_db_writer_factory(const.app_gramps)(database,
filename,
person)
return 1 return 1
except IOError, msg: except IOError, msg:
QuestionDialog.ErrorDialog( _("Could not write file: %s") % filename, QuestionDialog.ErrorDialog(
_('System message was: %s') % msg ) _("Could not write file: %s") % filename,
_('System message was: %s') % msg )
return 0 return 0
def build_exports(self): def build_exports(self):

View File

@ -17,19 +17,21 @@ class ErrorReportAssistant:
self._error_details_text_buffer = None self._error_details_text_buffer = None
self._final_report_text_buffer = None self._final_report_text_buffer = None
self.w = Assistant.Assistant(_('Report a bug'),self.complete) self.w = Assistant.Assistant(self.complete)
self.w.set_intro(_("This is the Bug Reporting Assistant. It will "\ self.w.add_text_page(
"help you to make a bug report to the Gramps "\ _('Report a bug'),
"developers that will be as detailed as possible.\n\n"\ _("This is the Bug Reporting Assistant. It will "\
"The assistant will ask you a few questions and will "\ "help you to make a bug report to the Gramps "\
"gather some information about the error that has "\ "developers that will be as detailed as possible.\n\n"\
"occured and the operating environment. "\ "The assistant will ask you a few questions and will "\
"At the end of the assistant you will be asked to "\ "gather some information about the error that has "\
"send an email to the Gramps bug reporting mailing list. "\ "occured and the operating environment. "\
"The assistant will place the bug report on the clip board so "\ "At the end of the assistant you will be asked to "\
"that you can paste it into your email programme and review "\ "send an email to the Gramps bug reporting mailing list. "\
"exactly what information is being sent.")) "The assistant will place the bug report on the clip board so "\
"that you can paste it into your email programme and review "\
"exactly what information is being sent."))
self.w.add_page(_("Report a bug: Step 1 of 5"), self.build_page1()) self.w.add_page(_("Report a bug: Step 1 of 5"), self.build_page1())
@ -41,10 +43,11 @@ class ErrorReportAssistant:
self.cb = {4:self.page4_update} self.cb = {4:self.page4_update}
self.w.add_page(_("Report a bug: Step 5 of 5"), self.build_page5()) self.w.add_page(_("Report a bug: Step 5 of 5"), self.build_page5())
self.w.set_conclusion(_('Complete'), self.w.add_text_page(
_('GRAMPS is an Open Source project. Its success ' _('Complete'),
'depends on its users. User feedback is important. ' _('GRAMPS is an Open Source project. Its success '
'Thank you for taking the time to submit a bug report.')) 'depends on its users. User feedback is important. '
'Thank you for taking the time to submit a bug report.'))
self.w.connect('page-changed',self.on_page_changed) self.w.connect('page-changed',self.on_page_changed)

View File

@ -1,7 +1,7 @@
# #
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2000-2005 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
@ -116,13 +116,15 @@ class StartupDialog:
GrampsKeys.save_startup(const.startup) GrampsKeys.save_startup(const.startup)
self.close(None) self.close(None)
return return
self.w = Assistant.Assistant(_('Getting started'),self.complete) self.w = Assistant.Assistant(self.complete)
self.w.set_intro(_('Welcome to GRAMPS, the Genealogical Research ' self.w.add_text_page(
'and Analysis Management Programming System.\n' _('Getting started'),
'Several options and information need to be gathered ' _('Welcome to GRAMPS, the Genealogical Research '
'before GRAMPS is ready to be used. Any of this ' 'and Analysis Management Programming System.\n'
'information can be changed in the future in the ' 'Several options and information need to be gathered '
'Preferences dialog under the Settings menu.')) 'before GRAMPS is ready to be used. Any of this '
'information can be changed in the future in the '
'Preferences dialog under the Settings menu.'))
try: try:
self.w.add_page(_('Researcher information'),self.build_page2()) self.w.add_page(_('Researcher information'),self.build_page2())
self.w.add_page(_('LDS support'), self.build_page5()) self.w.add_page(_('LDS support'), self.build_page5())
@ -133,12 +135,13 @@ class StartupDialog:
gtk.main_quit() gtk.main_quit()
return return
self.w.set_conclusion(_('Complete'), self.w.add_text_page(
_('GRAMPS is an Open Source project. Its success ' _('Complete'),
'depends on the users. User feedback is important. ' _('GRAMPS is an Open Source project. Its success '
'Please join the mailing lists, submit bug reports, ' 'depends on the users. User feedback is important. '
'suggest improvements, and see how you can ' 'Please join the mailing lists, submit bug reports, '
'contribute.\n\nPlease enjoy using GRAMPS.')) 'suggest improvements, and see how you can '
'contribute.\n\nPlease enjoy using GRAMPS.'))
self.w.show() self.w.show()