[Avida-SVN] r2707 - branches/developers/avida-edward/source/python/AvidaGui2

kaben at myxo.css.msu.edu kaben at myxo.css.msu.edu
Fri Jul 4 00:16:42 PDT 2008


Author: kaben
Date: 2008-07-04 03:16:42 -0400 (Fri, 04 Jul 2008)
New Revision: 2707

Modified:
   branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceCtrl.py
   branches/developers/avida-edward/source/python/AvidaGui2/pyRightClickDialogCtrl.py
   branches/developers/avida-edward/source/python/AvidaGui2/pySessionCtrl.py
Log:
Avida-ED File Dialogs: Bugfix: Switch the default export location from inside of the application bundle or workspace directory to the desktop.
Application will try, in order, the last directory chosen if there is one, then the Desktop if it exists, then the Documents directory if it exists, then "My Documents" if it exists, and finally default to the original behavior.


Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceCtrl.py	2008-07-04 05:17:19 UTC (rev 2706)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceCtrl.py	2008-07-04 07:16:42 UTC (rev 2707)
@@ -561,15 +561,19 @@
   def fileExportItemSlot(self):
     files2process = self.curr_sel_files.split("\t")
     file_name = files2process[1]
+    user_dir = os.path.expanduser("~")
     abs_dir = os.path.abspath(os.path.dirname(file_name));
-    if (os.path.exists(abs_dir) == False):
-      initial_dir = os.path.expanduser("~")
-      if os.path.exists(os.path.join(initial_dir,"Documents")):
-        initial_dir = os.path.join(initial_dir,"Documents")
-      elif os.path.exists(os.path.join(initial_dir,"My Documents")):
-        initial_dir = os.path.join(initial_dir,"My Documents")
+    if self.m_session_mdl.export_directory is not None and os.path.exists(self.m_session_mdl.export_directory):
+      initial_dir = self.m_session_mdl.export_directory
     else:
-      initial_dir = abs_dir
+      if os.path.exists(os.path.join(user_dir,"Desktop")):
+        initial_dir = os.path.join(user_dir,"Desktop")
+      elif os.path.exists(os.path.join(user_dir,"Documents")):
+        initial_dir = os.path.join(user_dir,"Documents")
+      elif os.path.exists(os.path.join(user_dir,"My Documents")):
+        initial_dir = os.path.join(user_dir,"My Documents")
+      else:
+        initial_dir = abs_dir
     no_ext_name, file_ext = os.path.splitext(os.path.basename(file_name))
     initial_file_name = os.path.join(initial_dir,no_ext_name + ".aex")
   
@@ -579,6 +583,9 @@
       None,
       "Export Item",
       "Export dish or organism")
+
+    self.m_session_mdl.export_directory = os.path.dirname(str(export_file_name))
+    #descr("self.m_session_mdl.export_directory:", self.m_session_mdl.export_directory)
     export_file = open(str(export_file_name), "w")
     if (file_ext == '.full'):
       files_in_full = os.listdir(file_name)

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyRightClickDialogCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyRightClickDialogCtrl.py	2008-07-04 05:17:19 UTC (rev 2706)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyRightClickDialogCtrl.py	2008-07-04 07:16:42 UTC (rev 2707)
@@ -109,17 +109,21 @@
 
       # If the directory has not been chosen self.file_dir is not
       # correct (at least on the Mac).  It is a relative path where
-      # QFileDialog.getSaveFileName seems to require an absolut path
+      # QFileDialog.getSaveFileName seems to require an absolute path
 
       abs_dir = os.path.abspath(self.file_dir);
-      if (os.path.exists(abs_dir) == False):
-        initial_dir = os.path.expanduser("~")
-        if os.path.exists(os.path.join(initial_dir,"Documents")):
-          initial_dir = os.path.join(initial_dir,"Documents")
-        elif os.path.exists(os.path.join(initial_dir,"My Documents")):
-          initial_dir = os.path.join(initial_dir,"My Documents")
+      user_dir = os.path.expanduser("~")
+      if self.session_mdl.export_directory is not None and os.path.exists(self.session_mdl.export_directory):
+        initial_dir = self.session_mdl.export_directory
       else:
-        initial_dir = abs_dir
+        if os.path.exists(os.path.join(user_dir,"Desktop")):
+          initial_dir = os.path.join(user_dir,"Desktop")
+        elif os.path.exists(os.path.join(user_dir,"Documents")):
+          initial_dir = os.path.join(user_dir,"Documents")
+        elif os.path.exists(os.path.join(user_dir,"My Documents")):
+          initial_dir = os.path.join(user_dir,"My Documents")
+        else:
+          initial_dir = abs_dir
       no_ext_name, ext = os.path.splitext(self.file_core_name)
       initial_file_name = os.path.join(initial_dir,no_ext_name + ".aex")
 
@@ -129,6 +133,9 @@
         None,
         "Export Item",
         "Export dish or organism")
+
+      self.session_mdl.export_directory = os.path.dirname(str(export_file_name))
+      #descr("self.session_mdl.export_directory:", self.session_mdl.export_directory)
       export_file = open(str(export_file_name), "w")
       if (self.file_ext == '.full'):
         files_in_full = os.listdir(self.file_name)

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pySessionCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pySessionCtrl.py	2008-07-04 05:17:19 UTC (rev 2706)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pySessionCtrl.py	2008-07-04 07:16:42 UTC (rev 2707)
@@ -58,6 +58,7 @@
     # flag to see if user has chosen a workspace for this session
 
     self.m_session_mdl.directory_chosen = False
+    self.m_session_mdl.export_directory = None
 
     # flag to see if the program should check that there are ancestors
 




More information about the Avida-cvs mailing list