/[ascend]/trunk/pygtk/interface/gtkbrowser.py
ViewVC logotype

Diff of /trunk/pygtk/interface/gtkbrowser.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 480 by johnpye, Mon Apr 17 10:45:23 2006 UTC revision 482 by johnpye, Mon Apr 17 12:22:31 2006 UTC
# Line 105  class Browser: Line 105  class Browser:
105          parser.add_option("--library"          parser.add_option("--library"
106              ,action="store", type="string", dest="library_path"              ,action="store", type="string", dest="library_path"
107              ,help="overried the configuration value for the library path"              ,help="overried the configuration value for the library path"
108              ,default=config.LIBRARY_PATH              ,default=None
109          )          )
110    
111          (options, args) = parser.parse_args()          (options, args) = parser.parse_args()
112    
113          #print "OPTIONS_______________:",options          #print "OPTIONS_______________:",options
114    
115            self.assets_dir = options.assets_dir
116                    
117          self.observers = []          self.observers = []
118          self.clip = None          self.clip = None
# Line 122  class Browser: Line 124  class Browser:
124    
125          self.prefs = Preferences()          self.prefs = Preferences()
126    
         #--------  
         # initialise ASCEND  
   
         self.assets_dir = options.assets_dir  
           
127          _prefpath = self.prefs.getStringPref("Directories","librarypath",None)          _prefpath = self.prefs.getStringPref("Directories","librarypath",None)
128            _preffileopenpath = self.prefs.getStringPref("Directories","loadfileopenpath",None)
129    
130            #--------
131            # set up library path and the path to use for File->Open dialogs
132                    
133          if _prefpath:          if options.library_path != None:
             _path = _prefpath  
             _pathsrc = "user preferences"  
         else:  
134              _path = options.library_path              _path = options.library_path
135              if options.library_path==config.LIBRARY_PATH:              _pathsrc = "commandline"
136                  _pathsrc = "default (config.py)"              # when a special path is specified, use that as the file-open location
137                self.fileopenpath = options.library_path
138            else:
139                if _prefpath:
140                    _path = _prefpath
141                    _pathsrc = "user preferences"
142              else:              else:
143                  _pathsrc = "commandline"                  _path = config.LIBRARY_PATH
144                    _pathsrc = "default (config.py)"
145                            
146                if _preffileopenpath:
147                    self.fileopenpath = _preffileopenpath
148                else:
149                    self.fileopenpath = _path
150                        
151            #--------
152            # Create the ASCXX 'Library' object
153            
154          print_loading_status("Creating ASCEND 'Library' object",          print_loading_status("Creating ASCEND 'Library' object",
155              "From %s, using ASCENDLIBRARY = %s" % (_pathsrc,_path)              "From %s, using ASCENDLIBRARY = %s" % (_pathsrc,_path)
156    
157          )          )
158          try:          self.library = ascpy.Library(_path)
             self.library = ascpy.Library(_path)  
         except:  
             print "FAILED TO EXECUTE ascpy.Library("+_path+")"  
             exit(1)  
159    
160          self.sim = None          self.sim = None
161                
162          #--------          #--------
163          # Prepare the ASCEND icon          # Prepare the ASCEND icon
164    
# Line 633  class Browser: Line 641  class Browser:
641          self.refreshtree()          self.refreshtree()
642    
643      def do_quit(self):      def do_quit(self):
644            print_loading_status("Saving window location")      
645          self.reporter.clearPythonErrorCallback()          self.reporter.clearPythonErrorCallback()
646    
647          _w,_h = self.window.get_size()          _w,_h = self.window.get_size()
648          _t,_l = self.window.get_position()          _t,_l = self.window.get_position()
649          _display = self.window.get_screen().get_display().get_name()          _display = self.window.get_screen().get_display().get_name()
# Line 642  class Browser: Line 652  class Browser:
652          _p = self.browserpaned.get_position()          _p = self.browserpaned.get_position()
653          self.prefs.setGeometryValue(_display,"browserpaned",_p);          self.prefs.setGeometryValue(_display,"browserpaned",_p);
654    
655            print_loading_status("Saving current directory")            
656            self.prefs.setStringPref("Directories","fileopenpath",self.fileopenpath)
657    
658            print_loading_status("Saving preferences")
659          # causes prefs to be saved unless they are still being used elsewher          # causes prefs to be saved unless they are still being used elsewher
660          del(self.prefs)          del(self.prefs)
661    
662            print_loading_status("Closing down GTK")
663          gtk.main_quit()          gtk.main_quit()
664          print "GTK QUIT"  
665            print_loading_status("Clearing error callback")    
666            self.reporter.clearPythonErrorCallback()
667            
668            print_loading_status("Quitting")
669          return False          return False
670    
671      def on_tools_sparsity_click(self,*args):      def on_tools_sparsity_click(self,*args):
# Line 938  class Browser: Line 957  class Browser:
957  #   BUTTON METHODS  #   BUTTON METHODS
958    
959      def open_click(self,*args):      def open_click(self,*args):
960          dialog = gtk.FileChooserDialog("Open file...",          print_loading_status("CURRENT FILEOPENPATH is",self.fileopenpath)
961              None,          dialog = gtk.FileChooserDialog("Open ASCEND model...",
962              gtk.FILE_CHOOSER_ACTION_OPEN,              self.window,
963              (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,              gtk.FILE_CHOOSER_ACTION_OPEN,
964              gtk.STOCK_OPEN, gtk.RESPONSE_OK))              (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK)
965            )
966            dialog.set_current_folder(self.fileopenpath)
967          dialog.set_default_response(gtk.RESPONSE_OK)          dialog.set_default_response(gtk.RESPONSE_OK)
968          dialog.set_transient_for(self.window)          dialog.set_transient_for(self.window)
969          dialog.set_modal(True)          dialog.set_modal(True)
# Line 961  class Browser: Line 982  class Browser:
982          response = dialog.run()          response = dialog.run()
983          _filename = dialog.get_filename()          _filename = dialog.get_filename()
984          print "FILENAME SELECTED:",_filename          print "FILENAME SELECTED:",_filename
985            
986            _path = dialog.get_current_folder()
987            if _path:
988                self.fileopenpath = _path
989            
990          dialog.hide()          dialog.hide()
991    
992          if response == gtk.RESPONSE_OK:          if response == gtk.RESPONSE_OK:

Legend:
Removed from v.480  
changed lines
  Added in v.482

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22