From 4d0e990880433e8e0509207b9972a4a56dbca232 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Tue, 13 Jul 2004 13:47:37 +0000 Subject: [PATCH] * src/Exporter.py: Fix EXPAND/FILL state of the chooser widget. * src/DbPrompter.py (SaveAsDbPrompter): Remove class. svn: r3271 --- ChangeLog | 4 ++ src/DbPrompter.py | 111 ---------------------------------------------- src/Exporter.py | 5 +++ 3 files changed, 9 insertions(+), 111 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5d8b504ad..4fa424dbc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2004-07-13 Alex Roitman + * src/Exporter.py: Fix EXPAND/FILL state of the chooser widget. + * src/DbPrompter.py (SaveAsDbPrompter): Remove class. + 2004-07-12 Don Allingham * src/plugins/WriteGedcom.py: use the correct id value diff --git a/src/DbPrompter.py b/src/DbPrompter.py index f58d89ff0..bddd32493 100644 --- a/src/DbPrompter.py +++ b/src/DbPrompter.py @@ -309,114 +309,3 @@ class NewNativeDbPrompter: else: choose.destroy() return 0 - -#------------------------------------------------------------------------- -# -# SaveAsDbPrompter -# -#------------------------------------------------------------------------- -class SaveAsDbPrompter: - """ - This class allows to save (export) an existing database. - - Any data format is allowed. The available formats are obtained - from the plugins. If the selected format is non-native (non-grdb) - then corresponding export routine is called. Native save as just - copies file to another name. - - """ - - def __init__(self,parent,parent_window=None): - self.parent = parent - self.parent_window = parent_window - - def chooser(self): - """ - Select the new file. - Return 1 when selection is made and 0 otherwise. - """ - self.choose = gtk.FileChooserDialog(_('GRAMPS: Export database'), - self.parent_window, - gtk.FILE_CHOOSER_ACTION_SAVE, - (gtk.STOCK_CANCEL, - gtk.RESPONSE_CANCEL, - gtk.STOCK_OPEN, - gtk.RESPONSE_OK)) - self.choose.set_local_only(gtk.FALSE) - # Always add automatic (macth all files) filter - all_filter = gtk.FileFilter() - all_filter.set_name(_('By extension')) - all_filter.add_pattern('*') - self.choose.add_filter(all_filter) - - # Always add native format filter - native_filter = gtk.FileFilter() - native_filter.set_name(_('GRAMPS databases')) - native_filter.add_mime_type('application/x-gramps') - self.choose.add_filter(native_filter) - - chooser_default = self.choose.get_children()[0].get_children()[0].get_children()[0] - chooser_default.connect('notify::filter',self.change_suggested_name) - - # Add more data type selections from export plugins - for (exportData,filter,pattern_list) in Plugins._exports: - self.choose.add_filter(filter) - - new_filename = Utils.get_new_filename('grdb') - self.choose.set_filename(new_filename) - self.choose.set_current_name(os.path.split(new_filename)[1]) - - response = self.choose.run() - if response == gtk.RESPONSE_OK: - filename = self.choose.get_filename() - filename = os.path.normpath(os.path.abspath(filename)) - (junk,the_file) = os.path.split(filename) - the_ext = os.path.splitext(filename)[1] - the_filter = self.choose.get_filter() - - # Save as grdb if either explictly selected by the filter - # or the filter is ALL and the extension is grdb - if the_filter.get_name() == native_filter.get_name() \ - or (the_filter.get_name() == all_filter.get_name() - and the_ext in ('.grdb', '.GRDB')): - self.choose.destroy() - try: - shutil.copyfile(self.parent.db.get_save_path(),filename) - return 1 - except IOError, msg: - QuestionDialog.ErrorDialog( _("Could not write file: %s") % filename, - _('System message was: %s') % msg ) - return 0 - - for (exportData,filter,pattern_list) in Plugins._exports: - # Save as this type if either explictly selected by the filter - # or the filter is ALL and the extension is in this type's list - if the_filter.get_name() == filter.get_name() \ - or (the_filter.get_name() == all_filter.get_name() - and the_ext in pattern_list): - self.choose.destroy() - exportData(self.parent.db,filename) - return 1 - else: - QuestionDialog.ErrorDialog( _("Could not write file: %s") % filename, - _('The type is not in the list of known file types') ) - return 0 - else: - self.choose.destroy() - return 0 - - def change_suggested_name(self,*args): - """ - This is the callback of the filter change handler. The suggested - file name is set according to the selected filter. - """ - the_filter = self.choose.get_filter() - if the_filter.get_name().find('XML') + 1: - new_filename = 'data.gramps' - elif the_filter.get_name() == _('GRAMPS packages'): - new_filename = Utils.get_new_filename('gpkg') - new_filename = os.path.split(new_filename)[1] - else: - new_filename = Utils.get_new_filename('grdb') - new_filename = os.path.split(new_filename)[1] - self.choose.set_current_name() diff --git a/src/Exporter.py b/src/Exporter.py index fecb164c2..07cce1d85 100644 --- a/src/Exporter.py +++ b/src/Exporter.py @@ -315,6 +315,11 @@ class Exporter: self.chooser = gtk.FileChooserWidget(gtk.FILE_CHOOSER_ACTION_SAVE) p.append_item("",self.chooser,"") + # Dirty hack to enable proper EXPAND and FILL properties of the chooser + parent = self.chooser.get_parent() + parent.set_child_packing(self.chooser,1,1,0,gtk.PACK_START) + gradnparent = parent.get_parent() + gradnparent.set_child_packing(parent,1,1,0,gtk.PACK_START) p.connect('prepare',self.suggest_filename) return p