diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 4ea14eef8..f206df29e 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,9 @@ +2004-05-02 Don Allingham + * src/DbPrompter.py: 2.4 filechooser + * src/gramps_main.py: 2.4 filechooser + * src/ReadXML.py: 2.4 filechooser + * src/Pluginsd.py: tooltip deprecation fix + 2004-05-01 Don Allingham * src/gramps.glade: rearranged filter apply * src/gramps.py: update to gtk.main() diff --git a/gramps2/src/DbPrompter.py b/gramps2/src/DbPrompter.py index d28381f43..a054eba61 100644 --- a/gramps2/src/DbPrompter.py +++ b/gramps2/src/DbPrompter.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2000-2003 Donald N. Allingham +# Copyright (C) 2000-2004 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 @@ -27,7 +27,6 @@ #------------------------------------------------------------------------- import gtk import gtk.glade -import gnome #------------------------------------------------------------------------- # @@ -65,8 +64,8 @@ class DbPrompter: opendb.signal_autoconnect({ "on_open_ok_clicked" : self.open_ok_clicked, "on_open_help_clicked" : self.open_help_clicked, - "on_open_cancel_clicked" : self.open_cancel_clicked, - "on_opendb_delete_event": self.open_delete_event, + "on_open_cancel_clicked" : gtk.main_quit, + "on_opendb_delete_event": gtk.main_quit, }) self.new = opendb.get_widget("new") @@ -83,101 +82,57 @@ class DbPrompter: def open_help_clicked(self,obj): """Display the GRAMPS manual""" + import gnome gnome.help_display('gramps-manual','choose-db-start') def save_as_activate(self): - if gtk.pygtk_version[1] >= 3: - choose = gtk.FileChooserDialog('Create GRAMPS database', - None, - gtk.FILE_CHOOSER_ACTION_SAVE, - (gtk.STOCK_CANCEL, - gtk.RESPONSE_CANCEL, - gtk.STOCK_OPEN, - gtk.RESPONSE_OK)) - filter = gtk.FileFilter() - filter.set_name(_('GRAMPS databases')) - filter.add_pattern('*.grdb') - choose.add_filter(filter) - - filter = gtk.FileFilter() - filter.set_name(_('All files')) - filter.add_pattern('*') - choose.add_filter(filter) - - response = choose.run() - if response == gtk.RESPONSE_OK: - filename = choose.get_filename() - self.db.read_file(filename) - choose.destroy() - else: - wFs = gtk.glade.XML (const.gladeFile, "fileselection","gramps") - wFs.signal_autoconnect({ - "on_ok_button1_clicked": self.save_ok_button_clicked, - "destroy_passed_object": self.cancel_button_clicked, - }) - filesel = wFs.get_widget('fileselection') - filesel.set_title('%s - GRAMPS' % _('Create database')) - - def save_ok_button_clicked(self,obj): - filename = obj.get_filename().encode('iso8859-1') - if filename: - if self.db.read_file(filename) == 1: - Utils.destroy_passed_object(obj) + choose = gtk.FileChooserDialog('Create GRAMPS database', + None, + gtk.FILE_CHOOSER_ACTION_SAVE, + (gtk.STOCK_CANCEL, + gtk.RESPONSE_CANCEL, + gtk.STOCK_OPEN, + gtk.RESPONSE_OK)) + filter = gtk.FileFilter() + filter.set_name(_('GRAMPS databases')) + filter.add_pattern('*.grdb') + choose.add_filter(filter) + + filter = gtk.FileFilter() + filter.set_name(_('All files')) + filter.add_pattern('*') + choose.add_filter(filter) + + response = choose.run() + if response == gtk.RESPONSE_OK: + filename = choose.get_filename() + self.db.read_file(filename) + choose.destroy() def open_activate(self): - if gtk.pygtk_version[1] >= 3: - choose = gtk.FileChooserDialog('Open GRAMPS database', - None, - gtk.FILE_CHOOSER_ACTION_OPEN, - (gtk.STOCK_CANCEL, - gtk.RESPONSE_CANCEL, - gtk.STOCK_OPEN, - gtk.RESPONSE_OK)) - filter = gtk.FileFilter() - filter.set_name(_('GRAMPS databases')) - filter.add_pattern('*.grdb') - choose.add_filter(filter) - - filter = gtk.FileFilter() - filter.set_name(_('All files')) - filter.add_pattern('*') - choose.add_filter(filter) - - if GrampsCfg.lastfile: - choose.set_filename(GrampsCfg.lastfile) - - response = choose.run() - if response == gtk.RESPONSE_OK: - filename = choose.get_filename() - self.db.read_file(filename) - choose.destroy() - else: - wFs = gtk.glade.XML (const.gladeFile, "fileselection","gramps") - wFs.signal_autoconnect({ - "on_ok_button1_clicked": self.ok_button_clicked, - "destroy_passed_object": self.cancel_button_clicked, - }) - self.filesel = wFs.get_widget('fileselection') - self.filesel.set_title('%s - GRAMPS' % _('Open database')) - if GrampsCfg.lastfile: - self.filesel.set_filename(GrampsCfg.lastfile) - return - - def cancel_button_clicked(self,obj): - Utils.destroy_passed_object(obj) - self.show() + choose = gtk.FileChooserDialog('Open GRAMPS database', + None, + gtk.FILE_CHOOSER_ACTION_OPEN, + (gtk.STOCK_CANCEL, + gtk.RESPONSE_CANCEL, + gtk.STOCK_OPEN, + gtk.RESPONSE_OK)) + filter = gtk.FileFilter() + filter.set_name(_('GRAMPS databases')) + filter.add_pattern('*.grdb') + choose.add_filter(filter) - def ok_button_clicked(self,obj): - filename = self.filesel.get_filename() - - if not filename: - return - if self.db.read_file(filename) == 1: - Utils.destroy_passed_object(obj) - - def open_delete_event(self,obj,event): - gtk.main_quit() - - def open_cancel_clicked(self,obj): - gtk.main_quit() - + filter = gtk.FileFilter() + filter.set_name(_('All files')) + filter.add_pattern('*') + choose.add_filter(filter) + + if GrampsCfg.lastfile: + choose.set_filename(GrampsCfg.lastfile) + + response = choose.run() + if response == gtk.RESPONSE_OK: + filename = choose.get_filename() + self.db.read_file(filename) + choose.destroy() + diff --git a/gramps2/src/Plugins.py b/gramps2/src/Plugins.py index b3ef8da5b..7ee8aef12 100644 --- a/gramps2/src/Plugins.py +++ b/gramps2/src/Plugins.py @@ -171,7 +171,7 @@ class PluginDialog: self.apply_button.set_use_underline(gtk.TRUE) if tool_tip: try: - tt = gtk.gtk_tooltips_data_get(self.apply_button) + tt = gtk.tooltips_data_get(self.apply_button) if tt: tt[0].set_tip(self.apply_button,tool_tip) except AttributeError: diff --git a/gramps2/src/ReadXML.py b/gramps2/src/ReadXML.py index 55c25413c..8d7115a52 100644 --- a/gramps2/src/ReadXML.py +++ b/gramps2/src/ReadXML.py @@ -197,12 +197,29 @@ def importData(database, filename, callback,cl=0): except: pass - fs_top = gtk.FileSelection("%s - GRAMPS" % _("Select file")) - fs_top.hide_fileop_buttons() - fs_top.ok_button.connect('clicked',fs_ok_clicked) - fs_top.cancel_button.connect('clicked',fs_close_window) - fs_top.run() - fs_top.destroy() + choose = gtk.FileChooserDialog('Select file', + None, + gtk.FILE_CHOOSER_ACTION_OPEN, + (gtk.STOCK_CANCEL, + gtk.RESPONSE_CANCEL, + gtk.STOCK_OPEN, + gtk.RESPONSE_OK)) + + filter = gtk.FileFilter() + filter.set_name(_('All files')) + filter.add_pattern('*') + choose.add_filter(filter) + + response = choose.run() + if response == gtk.RESPONSE_OK: + name = fs_top.get_filename() + if os.path.isfile(name): + shutil.copyfile(name,newfile) + try: + shutil.copystat(name,newfile) + except: + pass + choose.destroy() del parser return 1 diff --git a/gramps2/src/acconfig.h b/gramps2/src/acconfig.h deleted file mode 100644 index 0a76fa0dd..000000000 --- a/gramps2/src/acconfig.h +++ /dev/null @@ -1,7 +0,0 @@ -#undef ENABLE_NLS -#undef HAVE_CATGETS -#undef HAVE_GETTEXT -#undef GETTEXT_PACKAGE -#undef HAVE_LC_MESSAGES -#undef HAVE_STPCPY -#undef HAVE_LIBSM diff --git a/gramps2/src/gramps_main.py b/gramps2/src/gramps_main.py index 148000f97..93231a46d 100755 --- a/gramps2/src/gramps_main.py +++ b/gramps2/src/gramps_main.py @@ -1114,25 +1114,28 @@ class Gramps: pass def select_clicked(): - # File is lost => select a file to replace the lost one - def fs_close_window(obj): - fs_top.destroy() - - def fs_ok_clicked(obj): - name = fs_top.get_filename() + choose = gtk.FileChooserDialog('Open GRAMPS database', + None, + gtk.FILE_CHOOSER_ACTION_OPEN, + (gtk.STOCK_CANCEL, + gtk.RESPONSE_CANCEL, + gtk.STOCK_OPEN, + gtk.RESPONSE_OK)) + + filter = gtk.FileFilter() + filter.set_name(_('All files')) + filter.add_pattern('*') + choose.add_filter(filter) + + response = choose.run() + if response == gtk.RESPONSE_OK: + name = choose.get_filename() if os.path.isfile(name): RelImage.import_media_object(name,filename,base) object = self.db.find_object_from_id(ObjectId) object.set_path(newfile) - Utils.destroy_passed_object(fs_top) + choose.destroy() - fs_top = gtk.FileSelection("%s - GRAMPS" % _("Select file")) - fs_top.hide_fileop_buttons() - fs_top.ok_button.connect('clicked',fs_ok_clicked) - fs_top.cancel_button.connect('clicked',fs_close_window) - fs_top.show() - fs_top.run() - #------------------------------------------------------------------------- for ObjectId in self.db.get_object_keys(): object = self.db.find_object_from_id(ObjectId) @@ -1392,15 +1395,36 @@ class Gramps: def on_open_activate(self,obj): - top = gtk.glade.XML (const.gladeFile, "fileselection","gramps") - top.signal_autoconnect({ - "on_ok_button1_clicked": self.on_ok_button1_clicked, - "destroy_passed_object": self.fs_close_window, - }) - self.filesel = top.get_widget('fileselection') - if GrampsCfg.lastfile: - self.filesel.set_filename(GrampsCfg.lastfile) + choose = gtk.FileChooserDialog('Open GRAMPS database', + None, + gtk.FILE_CHOOSER_ACTION_OPEN, + (gtk.STOCK_CANCEL, + gtk.RESPONSE_CANCEL, + gtk.STOCK_OPEN, + gtk.RESPONSE_OK)) + filter = gtk.FileFilter() + filter.set_name(_('GRAMPS databases')) + filter.add_pattern('*.grdb') + choose.add_filter(filter) + + filter = gtk.FileFilter() + filter.set_name(_('All files')) + filter.add_pattern('*') + choose.add_filter(filter) + + if GrampsCfg.lastfile: + choose.set_filename(GrampsCfg.lastfile) + + response = choose.run() + if response == gtk.RESPONSE_OK: + filename = choose.get_filename() + filename = os.path.normpath(os.path.abspath(filename)) + self.clear_database() + if self.auto_save_load(filename) == 0: + DbPrompter.DbPrompter(self,0,self.topWindow) + choose.destroy() + def on_revert_activate(self,obj): pass