progressbar in exportassistant
svn: r8898
This commit is contained in:
parent
824e44f63d
commit
bbcf57edad
@ -1,3 +1,6 @@
|
|||||||
|
2007-08-30 Benny Malengier <benny.malengier@gramps-project.org>
|
||||||
|
* src/ExportAssistant.py: request Don, progressbar in exportassistant.
|
||||||
|
|
||||||
2007-08-30 Benny Malengier <benny.malengier@gramps-project.org>
|
2007-08-30 Benny Malengier <benny.malengier@gramps-project.org>
|
||||||
* src/Editors/_EditPrimary.py : refractoring
|
* src/Editors/_EditPrimary.py : refractoring
|
||||||
* src/Editors/_EditPerson.py : refractoring
|
* src/Editors/_EditPerson.py : refractoring
|
||||||
|
@ -101,6 +101,8 @@ class ExportAssistant(gtk.Assistant, ManagedWindow.ManagedWindow) :
|
|||||||
self.dbstate = dbstate
|
self.dbstate = dbstate
|
||||||
self.uistate = uistate
|
self.uistate = uistate
|
||||||
|
|
||||||
|
self.writestarted = False
|
||||||
|
|
||||||
#set up Assisant
|
#set up Assisant
|
||||||
gtk.Assistant.__init__(self)
|
gtk.Assistant.__init__(self)
|
||||||
|
|
||||||
@ -111,7 +113,7 @@ class ExportAssistant(gtk.Assistant, ManagedWindow.ManagedWindow) :
|
|||||||
self.set_window(self, None, self.top_title, isWindow=True)
|
self.set_window(self, None, self.top_title, isWindow=True)
|
||||||
|
|
||||||
#set up callback method for the export plugins
|
#set up callback method for the export plugins
|
||||||
self.callback = self.uistate.pulse_progressbar
|
self.callback = self.pulse_progressbar
|
||||||
|
|
||||||
if self.dbstate.active:
|
if self.dbstate.active:
|
||||||
self.person = self.dbstate.get_active_person()
|
self.person = self.dbstate.get_active_person()
|
||||||
@ -131,7 +133,7 @@ class ExportAssistant(gtk.Assistant, ManagedWindow.ManagedWindow) :
|
|||||||
self.create_page_options()
|
self.create_page_options()
|
||||||
self.create_page_fileselect()
|
self.create_page_fileselect()
|
||||||
self.create_page_confirm()
|
self.create_page_confirm()
|
||||||
#no progress page, use uistate progressbar
|
#no progress page, looks ugly, and user needs to hit forward at end!
|
||||||
self.create_page_summary()
|
self.create_page_summary()
|
||||||
|
|
||||||
#we need our own forward function as options page must not always be shown
|
#we need our own forward function as options page must not always be shown
|
||||||
@ -314,26 +316,32 @@ class ExportAssistant(gtk.Assistant, ManagedWindow.ManagedWindow) :
|
|||||||
self.set_page_title(page, _('Final confirmation'))
|
self.set_page_title(page, _('Final confirmation'))
|
||||||
self.set_page_type(page, gtk.ASSISTANT_PAGE_CONFIRM)
|
self.set_page_type(page, gtk.ASSISTANT_PAGE_CONFIRM)
|
||||||
self.set_page_complete(page, True)
|
self.set_page_complete(page, True)
|
||||||
|
|
||||||
def create_page_progress(self):
|
|
||||||
''' We use the uistate progress bar to indicate progress
|
|
||||||
'''
|
|
||||||
pass
|
|
||||||
|
|
||||||
def create_page_summary(self):
|
def create_page_summary(self):
|
||||||
# Construct summary page
|
# Construct summary page
|
||||||
# As this is the last page needs to be of page_type
|
# As this is the last page needs to be of page_type
|
||||||
# gtk.ASSISTANT_PAGE_CONFIRM or gtk.ASSISTANT_PAGE_SUMMARY
|
# gtk.ASSISTANT_PAGE_CONFIRM or gtk.ASSISTANT_PAGE_SUMMARY
|
||||||
label = gtk.Label('Thanks for using our Export Assistant!')
|
page = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0,
|
||||||
label.set_line_wrap(True)
|
yscale=0)
|
||||||
label.set_use_markup(True)
|
vbox = gtk.VBox()
|
||||||
label.show()
|
vbox.set_border_width(12)
|
||||||
|
vbox.set_spacing(6)
|
||||||
|
self.labelsum = gtk.Label(_("Please wait while your data is selected and exported"))
|
||||||
|
self.labelsum.set_line_wrap(True)
|
||||||
|
self.labelsum.set_use_markup(True)
|
||||||
|
vbox.pack_start(self.labelsum, expand=True)
|
||||||
|
|
||||||
|
self.progressbar = gtk.ProgressBar()
|
||||||
|
vbox.pack_start(self.progressbar, expand=True)
|
||||||
|
|
||||||
|
page.add(vbox)
|
||||||
|
page.show_all()
|
||||||
|
|
||||||
page = label
|
|
||||||
self.append_page(page)
|
self.append_page(page)
|
||||||
self.set_page_header_image(page, self.logo)
|
self.set_page_header_image(page, self.logo)
|
||||||
self.set_page_title(page, _('Summary'))
|
self.set_page_title(page, _('Summary'))
|
||||||
self.set_page_side_image(page, self.splash)
|
self.set_page_side_image(page, self.splash)
|
||||||
|
self.set_page_complete(page, False)
|
||||||
self.set_page_type(page, gtk.ASSISTANT_PAGE_SUMMARY)
|
self.set_page_type(page, gtk.ASSISTANT_PAGE_SUMMARY)
|
||||||
|
|
||||||
|
|
||||||
@ -341,10 +349,16 @@ class ExportAssistant(gtk.Assistant, ManagedWindow.ManagedWindow) :
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def do_cancel(self):
|
def do_cancel(self):
|
||||||
self.close()
|
if self.writestarted :
|
||||||
|
return True
|
||||||
|
else :
|
||||||
|
self.close()
|
||||||
|
|
||||||
def do_close(self):
|
def do_close(self):
|
||||||
self.close()
|
if self.writestarted :
|
||||||
|
return True
|
||||||
|
else :
|
||||||
|
self.close()
|
||||||
|
|
||||||
def do_prepare(self, page):
|
def do_prepare(self, page):
|
||||||
'''
|
'''
|
||||||
@ -414,14 +428,13 @@ class ExportAssistant(gtk.Assistant, ManagedWindow.ManagedWindow) :
|
|||||||
elif self.get_page_type(page) == gtk.ASSISTANT_PAGE_SUMMARY :
|
elif self.get_page_type(page) == gtk.ASSISTANT_PAGE_SUMMARY :
|
||||||
# The summary page
|
# The summary page
|
||||||
# Lock page, show progress bar
|
# Lock page, show progress bar
|
||||||
self.pre_save()
|
self.pre_save(page)
|
||||||
# save
|
# save
|
||||||
self.save()
|
self.save()
|
||||||
# Unlock page
|
# Unlock page
|
||||||
self.post_save()
|
self.post_save()
|
||||||
|
|
||||||
#update the label and title
|
#update the label and title
|
||||||
|
|
||||||
success = True
|
success = True
|
||||||
if success:
|
if success:
|
||||||
conclusion_title = _('Your data has been saved')
|
conclusion_title = _('Your data has been saved')
|
||||||
@ -443,7 +456,7 @@ class ExportAssistant(gtk.Assistant, ManagedWindow.ManagedWindow) :
|
|||||||
'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.')
|
||||||
page.set_label(conclusion_text)
|
self.labelsum.set_label(conclusion_text)
|
||||||
self.set_page_title(page, conclusion_title)
|
self.set_page_title(page, conclusion_title)
|
||||||
self.set_page_complete(page, True)
|
self.set_page_complete(page, True)
|
||||||
else :
|
else :
|
||||||
@ -455,6 +468,7 @@ class ExportAssistant(gtk.Assistant, ManagedWindow.ManagedWindow) :
|
|||||||
|
|
||||||
def close(self, *obj) :
|
def close(self, *obj) :
|
||||||
#clean up ManagedWindow menu, then destroy window, bring forward parent
|
#clean up ManagedWindow menu, then destroy window, bring forward parent
|
||||||
|
|
||||||
ManagedWindow.ManagedWindow.close(self,*obj)
|
ManagedWindow.ManagedWindow.close(self,*obj)
|
||||||
|
|
||||||
def obtain_export_formats(self):
|
def obtain_export_formats(self):
|
||||||
@ -533,15 +547,21 @@ class ExportAssistant(gtk.Assistant, ManagedWindow.ManagedWindow) :
|
|||||||
self.callback)
|
self.callback)
|
||||||
return success
|
return success
|
||||||
|
|
||||||
def pre_save(self):
|
def pre_save(self,page):
|
||||||
|
#as all is locked, show the page, which assistent normally only does
|
||||||
|
# after prepare signal!
|
||||||
|
self.writestarted = True
|
||||||
|
page.set_child_visible(True)
|
||||||
|
self.show_all()
|
||||||
|
|
||||||
self.uistate.set_busy_cursor(1)
|
self.uistate.set_busy_cursor(1)
|
||||||
self.set_busy_cursor(1)
|
self.set_busy_cursor(1)
|
||||||
self.uistate.progress.show()
|
|
||||||
|
|
||||||
def post_save(self):
|
def post_save(self):
|
||||||
self.uistate.set_busy_cursor(0)
|
self.uistate.set_busy_cursor(0)
|
||||||
self.set_busy_cursor(0)
|
self.set_busy_cursor(0)
|
||||||
self.uistate.progress.hide()
|
self.progressbar.hide()
|
||||||
|
self.writestarted = False
|
||||||
|
|
||||||
def set_busy_cursor(self,value):
|
def set_busy_cursor(self,value):
|
||||||
''' set or unset the busy cursor while saving data
|
''' set or unset the busy cursor while saving data
|
||||||
@ -550,13 +570,19 @@ class ExportAssistant(gtk.Assistant, ManagedWindow.ManagedWindow) :
|
|||||||
'''
|
'''
|
||||||
if value:
|
if value:
|
||||||
self.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
|
self.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
|
||||||
self.set_sensitive(0)
|
#self.set_sensitive(0)
|
||||||
else:
|
else:
|
||||||
self.window.set_cursor(None)
|
self.window.set_cursor(None)
|
||||||
self.set_sensitive(1)
|
#self.set_sensitive(1)
|
||||||
|
|
||||||
while gtk.events_pending():
|
while gtk.events_pending():
|
||||||
gtk.main_iteration()
|
gtk.main_iteration()
|
||||||
|
|
||||||
|
def pulse_progressbar(self, value):
|
||||||
|
self.progressbar.set_fraction(min(value/100.0, 1.0))
|
||||||
|
self.progressbar.set_text("%d%%" % value)
|
||||||
|
while gtk.events_pending():
|
||||||
|
gtk.main_iteration()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user