diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index d3d68d50a..bb6a7be19 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,10 @@ +2006-01-11 Alex Roitman + * 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 * src/FamilyList.py: call family editor * src/StartupDialog.py: pwm in try/except diff --git a/gramps2/src/Assistant.py b/gramps2/src/Assistant.py index ecd7064b0..9aaa04b17 100644 --- a/gramps2/src/Assistant.py +++ b/gramps2/src/Assistant.py @@ -83,7 +83,7 @@ class Assistant(gtk.Object): ()) } - def __init__(self,title,complete): + def __init__(self,complete): gobject.GObject.__init__(self) self.complete = complete @@ -92,16 +92,13 @@ class Assistant(gtk.Object): self.logo = gtk.gdk.pixbuf_new_from_file(_gramps_png) self.splash = gtk.gdk.pixbuf_new_from_file(_splash_jpg) - self.current_page = 0 - self.max_page = 1 - self.conclusion_set = False + self.current_page = -1 self.window = gtk.Window() titlebox = gtk.HBox() 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_use_markup(True) @@ -150,21 +147,23 @@ class Assistant(gtk.Object): """Set the property of writable properties.""" 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): - try: - self.title.set_label(self.title_text[self.current_page]) - except IndexError: - pass + self.title.set_label(self.title_text[self.current_page]) self.title.set_use_markup(True) 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.back.show() self.cancel.show() self.ok.set_sensitive(True) 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.back.hide() self.cancel.hide() @@ -195,7 +194,7 @@ class Assistant(gtk.Object): def next_clicked(self,obj): 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.complete() self.window.destroy() @@ -208,17 +207,25 @@ class Assistant(gtk.Object): self.emit('after-page-next',self.notebook.get_current_page()) self.emit('page-changed',self.notebook.get_current_page()) - def set_intro(self,text): - hbox = gtk.HBox(spacing=12) - image = gtk.Image() - image.set_from_file(_splash_jpg) - hbox.pack_start(image,False) - label = gtk.Label(text) - label.set_line_wrap(True) - hbox.add(label) - self.notebook.append_page(hbox) + def add_text_page(self, title, text): + """ + 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.add_page(title,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) image = gtk.Image() image.set_from_file(_splash_jpg) @@ -227,34 +234,37 @@ class Assistant(gtk.Object): label.set_line_wrap(True) hbox.add(label) hbox.show_all() - if self.conclusion_set: - 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 + return hbox 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.notebook.append_page(child) - self.max_page += 1 + return self.notebook.append_page(child) - 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.notebook.insert_page(child,None,position) - self.max_page += 1 + return self.notebook.insert_page(child,None,position) def remove_page(self,position): + """ + Remove page from a given position. + """ self.title_text.pop(position) self.notebook.remove_page(position) - self.max_page -= 1 - - def get_number_of_pages(self): - return self.max_page def show(self): 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()) def destroy(self): @@ -276,13 +286,14 @@ if __name__ == "__main__": table.attach(text,x3,x4,y,y+1,gtk.EXPAND|gtk.FILL) return text - a = Assistant('Getting started',complete) - a.set_intro('Welcome to GRAMPS, the Genealogical Research ' - 'and Analysis Management Programming System.\n' - 'Several options and information need to be gathered ' - '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.') + a = Assistant(complete) + a.add_text_page('Getting started', + 'Welcome to GRAMPS, the Genealogical Research ' + 'and Analysis Management Programming System.\n' + 'Several options and information need to be gathered ' + '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.') box = gtk.VBox() box.set_spacing(12) @@ -301,7 +312,7 @@ if __name__ == "__main__": box.add(table) a.add_page('Researcher information',box) - a.set_conclusion('aaa','bbb') + a.add_text_page('Conclusion title','Very long conclusion text here') a.show() gtk.main() diff --git a/gramps2/src/Exporter.py b/gramps2/src/Exporter.py index ec904aaca..2f68057f7 100644 --- a/gramps2/src/Exporter.py +++ b/gramps2/src/Exporter.py @@ -80,26 +80,25 @@ class Exporter: self.person = self.dbstate.active else: 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.build_exports() - self.confirm_label = gtk.Label() 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.w.add_page(title1,box1) - self.format_page = 1 + self.format_page = self.w.add_page(_('Choosing the format to save'), + self.build_format_page()) - title2,box2 = self.build_file_sel_page() - self.w.add_page(title2,box2) - self.file_sel_page = self.w.get_number_of_pages() + self.file_sel_page = self.w.add_page(_('Selecting the file name'), + self.build_file_sel_page()) - title3,box3 = self.build_confirm_page() - self.w.add_page(title3,box3) + self.confirm_page = self.w.add_text_page('','') + self.conclusion_page = self.w.add_text_page('','') self.w.connect('before-page-next',self.on_before_page_next) @@ -112,10 +111,11 @@ class Exporter: if page == self.format_page: self.build_options() self.suggest_filename() - elif page == self.file_sel_page-1: - self.build_confirm_label() 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): """ @@ -136,20 +136,7 @@ class Exporter: 'can safely press the Cancel button at any time and your ' 'present database will still be intact.') - 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. - """ - 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): + def build_confirmation(self): """ Build the text of the confirmation label. This should query the selected options (format, filename) and present the summary @@ -161,13 +148,15 @@ class Exporter: 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' + confirm_text = _( + 'The data will be saved as follows:\n\n' 'Format:\t%s\nName:\t%s\nFolder:\t%s\n\n' 'Press OK to proceed, Cancel to abort, or Back to ' - 'revisit your options.') % (format, name, folder)) - self.confirm_label.set_line_wrap(True) - self.confirm_label.show_all() + 'revisit your options.') % (format, name, folder) + self.w.remove_page(self.confirm_page) + self.confirm_page = self.w.insert_text_page(_('Final confirmation'), + confirm_text, + self.confirm_page) def save(self): """ @@ -184,11 +173,14 @@ class Exporter: else: success = self.exports[ix][0](self.dbstate.db, filename,self.person) + return success + + def build_conclusion(self,success): if success: conclusion_title = _('Your data has been saved') conclusion_text = _( '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' 'Note: the database currently opened in your GRAMPS ' 'window is NOT the file you have just saved. ' @@ -202,7 +194,10 @@ class Exporter: 'Note: your currently opened database is safe. ' 'It was only ' '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): """ @@ -211,8 +206,6 @@ class Exporter: """ self.format_buttons = [] - page_title = _('Choosing the format to save') - box = gtk.VBox() box.set_spacing(12) @@ -235,7 +228,7 @@ class Exporter: tip.set_tip(button,description) box.add(table) - return (page_title,box) + return box def build_options(self): """ @@ -252,24 +245,26 @@ class Exporter: if ix == self.format_option: return elif self.format_option: - self.w.remove_page(self.format_page+1) + self.w.remove_page(self.option_page) self.format_option = None title = self.exports[ix][3][0] option_box_class = self.exports[ix][3][1] self.option_box_instance = option_box_class(self.person) 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 box.show_all() elif self.format_option: - self.w.remove_page(self.format_page+1) + self.w.remove_page(self.option_page) self.format_option = None def build_file_sel_page(self): """ Build a druid page embedding the FileChooserWidget. """ - page_title = _('Selecting the file name') self.chooser = gtk.FileChooserWidget(gtk.FILE_CHOOSER_ACTION_SAVE) self.chooser.set_local_only(False) @@ -280,7 +275,7 @@ class Exporter: # Dirty hack to enable proper EXPAND/FILL properties of the chooser box.set_child_packing(self.chooser,1,1,0,gtk.PACK_START) - return (page_title,box) + return box def suggest_filename(self): """ @@ -324,11 +319,14 @@ class Exporter: In the future, filter and other options may be added. """ try: - gramps_db_writer_factory(const.app_gramps)(database,filename,person) + gramps_db_writer_factory(const.app_gramps)(database, + filename, + person) return 1 except IOError, msg: - QuestionDialog.ErrorDialog( _("Could not write file: %s") % filename, - _('System message was: %s') % msg ) + QuestionDialog.ErrorDialog( + _("Could not write file: %s") % filename, + _('System message was: %s') % msg ) return 0 def build_exports(self): diff --git a/gramps2/src/gedcomexport.glade b/gramps2/src/GrampsDb/gedcomexport.glade similarity index 100% rename from gramps2/src/gedcomexport.glade rename to gramps2/src/GrampsDb/gedcomexport.glade diff --git a/gramps2/src/gedcomimport.glade b/gramps2/src/GrampsDb/gedcomimport.glade similarity index 100% rename from gramps2/src/gedcomimport.glade rename to gramps2/src/GrampsDb/gedcomimport.glade diff --git a/gramps2/src/GrampsLogger/_ErrorReportAssistant.py b/gramps2/src/GrampsLogger/_ErrorReportAssistant.py index e73b15963..099448ca9 100644 --- a/gramps2/src/GrampsLogger/_ErrorReportAssistant.py +++ b/gramps2/src/GrampsLogger/_ErrorReportAssistant.py @@ -17,19 +17,21 @@ class ErrorReportAssistant: self._error_details_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 "\ - "help you to make a bug report to the Gramps "\ - "developers that will be as detailed as possible.\n\n"\ - "The assistant will ask you a few questions and will "\ - "gather some information about the error that has "\ - "occured and the operating environment. "\ - "At the end of the assistant you will be asked to "\ - "send an email to the Gramps bug reporting mailing list. "\ - "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_text_page( + _('Report a bug'), + _("This is the Bug Reporting Assistant. It will "\ + "help you to make a bug report to the Gramps "\ + "developers that will be as detailed as possible.\n\n"\ + "The assistant will ask you a few questions and will "\ + "gather some information about the error that has "\ + "occured and the operating environment. "\ + "At the end of the assistant you will be asked to "\ + "send an email to the Gramps bug reporting mailing list. "\ + "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()) @@ -41,10 +43,11 @@ class ErrorReportAssistant: self.cb = {4:self.page4_update} self.w.add_page(_("Report a bug: Step 5 of 5"), self.build_page5()) - self.w.set_conclusion(_('Complete'), - _('GRAMPS is an Open Source project. Its success ' - 'depends on its users. User feedback is important. ' - 'Thank you for taking the time to submit a bug report.')) + self.w.add_text_page( + _('Complete'), + _('GRAMPS is an Open Source project. Its success ' + '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) diff --git a/gramps2/src/StartupDialog.py b/gramps2/src/StartupDialog.py index f905831c3..d69731ad0 100644 --- a/gramps2/src/StartupDialog.py +++ b/gramps2/src/StartupDialog.py @@ -1,7 +1,7 @@ # # 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 # it under the terms of the GNU General Public License as published by @@ -116,13 +116,15 @@ class StartupDialog: GrampsKeys.save_startup(const.startup) self.close(None) return - self.w = Assistant.Assistant(_('Getting started'),self.complete) - self.w.set_intro(_('Welcome to GRAMPS, the Genealogical Research ' - 'and Analysis Management Programming System.\n' - 'Several options and information need to be gathered ' - '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.')) + self.w = Assistant.Assistant(self.complete) + self.w.add_text_page( + _('Getting started'), + _('Welcome to GRAMPS, the Genealogical Research ' + 'and Analysis Management Programming System.\n' + 'Several options and information need to be gathered ' + '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: self.w.add_page(_('Researcher information'),self.build_page2()) self.w.add_page(_('LDS support'), self.build_page5()) @@ -133,12 +135,13 @@ class StartupDialog: gtk.main_quit() return - self.w.set_conclusion(_('Complete'), - _('GRAMPS is an Open Source project. Its success ' - 'depends on the users. User feedback is important. ' - 'Please join the mailing lists, submit bug reports, ' - 'suggest improvements, and see how you can ' - 'contribute.\n\nPlease enjoy using GRAMPS.')) + self.w.add_text_page( + _('Complete'), + _('GRAMPS is an Open Source project. Its success ' + 'depends on the users. User feedback is important. ' + 'Please join the mailing lists, submit bug reports, ' + 'suggest improvements, and see how you can ' + 'contribute.\n\nPlease enjoy using GRAMPS.')) self.w.show()