* src/DbPrompter.py: handle open dialog in a clean manner
* src/gramps.py: handle open dialog in a clean manner * src/gramps_main.py: handle open dialog in a clean manner * src/gramps.glade: handle open dialog in a clean manner svn: r3143
This commit is contained in:
		| @@ -1,3 +1,9 @@ | ||||
| 2004-05-07  Don Allingham  <donaldallingham@users.sourceforge.net> | ||||
| 	* src/DbPrompter.py: handle open dialog in a clean manner | ||||
| 	* src/gramps.py: handle open dialog in a clean manner | ||||
| 	* src/gramps_main.py: handle open dialog in a clean manner | ||||
| 	* src/gramps.glade: handle open dialog in a clean manner | ||||
|  | ||||
| 2004-05-07  Alex Roitman  <shura@alex.neuro.umn.edu> | ||||
| 	* src/plugins/soundgen.py: Convert to db.  | ||||
| 	* src/plugins/GraphViz.py: Typo. | ||||
|   | ||||
| @@ -27,6 +27,7 @@ | ||||
| #------------------------------------------------------------------------- | ||||
| import gtk | ||||
| import gtk.glade | ||||
| import gobject | ||||
|  | ||||
| #------------------------------------------------------------------------- | ||||
| # | ||||
| @@ -36,6 +37,8 @@ import gtk.glade | ||||
| import Utils | ||||
| import const | ||||
| import GrampsCfg | ||||
| import gnome | ||||
| import QuestionDialog | ||||
| from gettext import gettext as _ | ||||
|  | ||||
| #------------------------------------------------------------------------- | ||||
| @@ -48,91 +51,73 @@ class DbPrompter: | ||||
|      | ||||
|     def __init__(self,db,want_new,parent=None): | ||||
|         self.db = db | ||||
|         self.want_new = want_new | ||||
|         self.parent = parent | ||||
|         self.show() | ||||
|  | ||||
|     def show(self): | ||||
|         opendb = gtk.glade.XML(const.gladeFile, "opendb","gramps") | ||||
|         top = opendb.get_widget('opendb') | ||||
|         if self.parent: | ||||
|             top.set_transient_for(self.parent) | ||||
|         if parent: | ||||
|             top.set_transient_for(parent) | ||||
|         title = opendb.get_widget('title') | ||||
|  | ||||
|         Utils.set_titles(top,title,_('Open a database')) | ||||
|          | ||||
|         opendb.signal_autoconnect({ | ||||
|             "on_open_ok_clicked" : self.open_ok_clicked, | ||||
|             "on_open_help_clicked" : self.open_help_clicked, | ||||
|             "on_open_cancel_clicked" : gtk.main_quit, | ||||
|             "on_opendb_delete_event": gtk.main_quit, | ||||
|             }) | ||||
|  | ||||
|         self.new = opendb.get_widget("new") | ||||
|         if self.want_new: | ||||
|             self.new.set_active(1) | ||||
|         new = opendb.get_widget("new") | ||||
|         new.set_active(want_new) | ||||
|  | ||||
|     def open_ok_clicked(self,obj): | ||||
|         if self.new.get_active(): | ||||
|         while 1: | ||||
|             response = top.run() | ||||
|             if response == gtk.RESPONSE_OK: | ||||
|                 if self.chooser(new.get_active()): | ||||
|                     break | ||||
|             elif response == gtk.RESPONSE_CANCEL: | ||||
|                 break | ||||
|             elif response == gtk.RESPONSE_HELP: | ||||
|                 try: | ||||
|                     gnome.help_display('gramps-manual','choose-db-start') | ||||
|                 except gobject.GError,msg: | ||||
|                     QuestionDialog.ErrorDialog(_('Help not available'),msg) | ||||
|  | ||||
|         top.destroy() | ||||
|         if response == gtk.RESPONSE_CANCEL: | ||||
|             gtk.main_quit() | ||||
|  | ||||
|     def chooser(self,save): | ||||
|         if save: | ||||
|             choose = gtk.FileChooserDialog('Create GRAMPS database', | ||||
|                                            None, | ||||
|                                            gtk.FILE_CHOOSER_ACTION_SAVE, | ||||
|                                            (gtk.STOCK_CANCEL, | ||||
|                                             gtk.RESPONSE_CANCEL, | ||||
|                                             gtk.STOCK_OPEN, | ||||
|                                             gtk.RESPONSE_OK)) | ||||
|             self.db.clear_database() | ||||
|             self.save_as_activate() | ||||
|         else: | ||||
|             self.open_activate() | ||||
|         Utils.destroy_passed_object(obj) | ||||
|  | ||||
|     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): | ||||
|         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): | ||||
|         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) | ||||
|             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 save and 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() | ||||
|      | ||||
|             choose.destroy() | ||||
|             return 1 | ||||
|         else: | ||||
|             choose.destroy() | ||||
|             return 0 | ||||
|  | ||||
|   | ||||
| @@ -6589,7 +6589,7 @@ | ||||
| 	      <property name="use_stock">True</property> | ||||
| 	      <property name="relief">GTK_RELIEF_NORMAL</property> | ||||
| 	      <property name="focus_on_click">True</property> | ||||
| 	      <property name="response_id">0</property> | ||||
| 	      <property name="response_id">-6</property> | ||||
| 	      <signal name="clicked" handler="on_open_cancel_clicked" object="opendb"/> | ||||
| 	    </widget> | ||||
| 	  </child> | ||||
| @@ -6604,7 +6604,7 @@ | ||||
| 	      <property name="use_stock">True</property> | ||||
| 	      <property name="relief">GTK_RELIEF_NORMAL</property> | ||||
| 	      <property name="focus_on_click">True</property> | ||||
| 	      <property name="response_id">0</property> | ||||
| 	      <property name="response_id">-5</property> | ||||
| 	      <signal name="clicked" handler="on_open_ok_clicked" object="opendb"/> | ||||
| 	    </widget> | ||||
| 	  </child> | ||||
|   | ||||
| @@ -78,20 +78,23 @@ gettext.install("gramps",loc,unicode=1) | ||||
| # | ||||
| #------------------------------------------------------------------------- | ||||
| import gramps_main  | ||||
| import gobject | ||||
|  | ||||
| signal.signal(signal.SIGCHLD, signal.SIG_DFL) | ||||
|  | ||||
| args = sys.argv[1:] | ||||
|  | ||||
| try: | ||||
|     import StartupDialog | ||||
|      | ||||
|     if StartupDialog.need_to_run(): | ||||
|         StartupDialog.StartupDialog(gramps_main.Gramps,args) | ||||
|     else: | ||||
|         gramps_main.Gramps(args) | ||||
| except: | ||||
|     import DisplayTrace | ||||
|     DisplayTrace.DisplayTrace() | ||||
| def run(): | ||||
|     try: | ||||
|         import StartupDialog | ||||
|          | ||||
|         if StartupDialog.need_to_run(): | ||||
|             StartupDialog.StartupDialog(gramps_main.Gramps,args) | ||||
|         else: | ||||
|             gramps_main.Gramps(args) | ||||
|     except: | ||||
|         import DisplayTrace | ||||
|         DisplayTrace.DisplayTrace() | ||||
|  | ||||
| gobject.timeout_add(100, run, priority=100) | ||||
| gtk.main() | ||||
|   | ||||
| @@ -59,9 +59,6 @@ import FamilyView | ||||
| import SourceView | ||||
| import PeopleView | ||||
| import GenericFilter | ||||
|  | ||||
| from QuestionDialog import * | ||||
|  | ||||
| import DisplayTrace | ||||
| import const | ||||
| import Plugins | ||||
| @@ -72,9 +69,11 @@ import EditPerson | ||||
| import Find | ||||
| import DbPrompter | ||||
|  | ||||
| try:    # First try python2.3 and later: this is the future | ||||
| from QuestionDialog import * | ||||
|  | ||||
| try:                       # First try python2.3 and later: this is the future | ||||
|     from bsddb import db | ||||
| except ImportError: # try python2.2 | ||||
| except ImportError:        # try python2.2 | ||||
|     from bsddb3 import db | ||||
|  | ||||
| #------------------------------------------------------------------------- | ||||
| @@ -894,7 +893,6 @@ class Gramps: | ||||
|                        self.new_database_response,self.topWindow) | ||||
|                         | ||||
|     def new_database_response(self): | ||||
|         import DbPrompter | ||||
|         DbPrompter.DbPrompter(self,1,self.topWindow) | ||||
|  | ||||
|     def clear_database(self): | ||||
| @@ -1175,7 +1173,6 @@ class Gramps: | ||||
|  | ||||
|         if os.path.exists(filename): | ||||
|             if not os.path.isdir(filename): | ||||
|                 import DbPrompter | ||||
|                 DbPrompter.DbPrompter(self,0,self.topWindow) | ||||
|                 self.displayError(_("Database could not be opened"), | ||||
|                                   _("%s is not a directory.") % filename + ' ' + \ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user