mailr10610 - in /branches/bieri_gui/gui_bieri: paths.py relax_gui.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on February 01, 2010 - 22:28:
Author: bugman
Date: Mon Feb  1 22:28:20 2010
New Revision: 10610

URL: http://svn.gna.org/viewcvs/relax?rev=10610&view=rev
Log:
Added a 'File -> Save' menu entry.

This is to aid debugging, but users will also find it very useful.  Ctrl+S 
will now save the file
for the user without the file selection dialog box appearing (unless it is 
the first time).  The
state_save() method has now been split into 3:
    action_state_save() - for the 'save' actions.
    action_state_save_as() - for the 'save as' actions.
    state_save() - for doing the actual saving.


Modified:
    branches/bieri_gui/gui_bieri/paths.py
    branches/bieri_gui/gui_bieri/relax_gui.py

Modified: branches/bieri_gui/gui_bieri/paths.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/paths.py?rev=10610&r1=10609&r2=10610&view=diff
==============================================================================
--- branches/bieri_gui/gui_bieri/paths.py (original)
+++ branches/bieri_gui/gui_bieri/paths.py Mon Feb  1 22:28:20 2010
@@ -49,6 +49,7 @@
 NEW_ICON = ICON_PATH + '16x16'+sep+'actions'+sep+'document-new.png'
 OPEN_ICON = ICON_PATH + '16x16'+sep+'actions'+sep+'document-open.png'
 REMOVE_ICON = ICON_PATH + '16x16'+sep+'actions'+sep+'list-remove.png'
+SAVE_ICON = ICON_PATH + '16x16'+sep+'actions'+sep+'document-save.png'
 SAVE_AS_ICON = ICON_PATH + '16x16'+sep+'actions'+sep+'document-save-as.png'
 SETTINGS_ICON = ICON_PATH + 
'16x16'+sep+'actions'+sep+'document-properties.png'
 SETTINGS_GLOBAL_ICON = ICON_PATH + 
'16x16'+sep+'categories'+sep+'preferences-system.png'

Modified: branches/bieri_gui/gui_bieri/relax_gui.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/relax_gui.py?rev=10610&r1=10609&r2=10610&view=diff
==============================================================================
--- branches/bieri_gui/gui_bieri/relax_gui.py (original)
+++ branches/bieri_gui/gui_bieri/relax_gui.py Mon Feb  1 22:28:20 2010
@@ -55,7 +55,7 @@
 from derived_wx_classes import StructureTextCtrl
 from filedialog import multi_openfile, opendir, openfile, savefile
 from message import dir_message, exec_relax, missing_data, question, 
relax_run_ok
-from paths import ABOUT_RELAX_ICON, ABOUT_RELAXGUI_ICON, CONTACT_ICON, 
CONTROLLER_ICON, EXIT_ICON, IMAGE_PATH, LOAD_ICON, MANUAL_ICON, NEW_ICON, 
OPEN_ICON, REF_ICON, SAVE_AS_ICON, SETTINGS_ICON, SETTINGS_GLOBAL_ICON, 
SETTINGS_RESET_ICON
+from paths import ABOUT_RELAX_ICON, ABOUT_RELAXGUI_ICON, CONTACT_ICON, 
CONTROLLER_ICON, EXIT_ICON, IMAGE_PATH, LOAD_ICON, MANUAL_ICON, NEW_ICON, 
OPEN_ICON, REF_ICON, SAVE_ICON, SAVE_AS_ICON, SETTINGS_ICON, 
SETTINGS_GLOBAL_ICON, SETTINGS_RESET_ICON
 from settings import import_file_settings, load_sequence, 
relax_global_settings
 
 
@@ -613,6 +613,45 @@
         event.Skip()
 
 
+    def action_state_save(self, event):
+        """Save the program state.
+
+        @param event:   The wx event.
+        @type event:    wx event
+        """
+
+        # Not saved yet, therefore pass execution to state_save_as().
+        if not ds.relax_gui.save_file:
+            self.action_state_save_as(event)
+            return
+
+        # Save.
+        self.state_save()
+
+        # Skip the event.
+        event.Skip()
+
+
+    def action_state_save_as(self, event):
+        """Save the program state with file name selection.
+
+        @param event:   The wx event.
+        @type event:    wx event
+        """
+
+        # Open the dialog.
+        filename = savefile(msg='Select file to save', filetype='state.bz2', 
default='relax save files (*.bz2)|*.bz2|all files (*.*)|*.*')
+
+        # Set the file name.
+        ds.relax_gui.save_file = filename
+
+        # Save.
+        self.state_save()
+
+        # Skip the event.
+        event.Skip()
+
+
     def build_main_window(self):
         """Construct the main relax GUI window."""
 
@@ -658,15 +697,17 @@
         menu = wx.Menu()
         menu.AppendItem(self.build_menu_sub_item(menu, id=0, 
text="&New\tCtrl+N", icon=NEW_ICON))
         menu.AppendItem(self.build_menu_sub_item(menu, id=1, 
text="&Open\tCtrl+O", icon=OPEN_ICON))
-        menu.AppendItem(self.build_menu_sub_item(menu, id=2, text="S&ave 
as...\tCtrl+Shift+S", icon=SAVE_AS_ICON))
-        menu.AppendItem(self.build_menu_sub_item(menu, id=3, 
text="E&xit\tCtrl+Q", icon=EXIT_ICON))
+        menu.AppendItem(self.build_menu_sub_item(menu, id=2, 
text="S&ave\tCtrl+S", icon=SAVE_ICON))
+        menu.AppendItem(self.build_menu_sub_item(menu, id=3, text="Save 
as...\tCtrl+Shift+S", icon=SAVE_AS_ICON))
+        menu.AppendItem(self.build_menu_sub_item(menu, id=4, 
text="E&xit\tCtrl+Q", icon=EXIT_ICON))
         menubar.Append(menu, "&File")
 
         # The 'File' menu actions.
         self.Bind(wx.EVT_MENU, self.newGUI,     id=0)
         self.Bind(wx.EVT_MENU, self.state_load, id=1)
-        self.Bind(wx.EVT_MENU, self.state_save, id=2)
-        self.Bind(wx.EVT_MENU, self.exitGUI,    id=3)
+        self.Bind(wx.EVT_MENU, self.action_state_save, id=2)
+        self.Bind(wx.EVT_MENU, self.action_state_save_as, id=3)
+        self.Bind(wx.EVT_MENU, self.exitGUI,    id=4)
 
         # The 'View' menu entries.
         menu = wx.Menu()
@@ -804,6 +845,9 @@
 
         # Add the GUI object to the data store.
         ds.relax_gui = Gui()
+
+        # The save file.
+        ds.relax_gui.save_file = None
 
         # Define Global Variables
         ds.relax_gui.unresolved = ""
@@ -1198,15 +1242,8 @@
         event.Skip()
 
 
-    def state_save(self, event):
-        """Save the program state.
-
-        @param event:   The wx event.
-        @type event:    wx event
-        """
-
-        # Open the dialog.
-        filename = savefile(msg='Select file to save', filetype='state.bz2', 
default='relax save files (*.bz2)|*.bz2|all files (*.*)|*.*')
+    def state_save(self):
+        """Save the program state."""
 
         # Update the data store to match the GUI.
         self.sync_ds(upload=True)
@@ -1218,10 +1255,7 @@
                 self.analysis_frames[i].sync_ds(upload=True)
 
         # Save the relax state.
-        state.save_state(filename, verbosity=0, force=True)
-
-        # Skip the event.
-        event.Skip()
+        state.save_state(ds.relax_gui.save_file, verbosity=0, force=True)
 
 
     def sync_ds(self, upload=False):




Related Messages


Powered by MHonArc, Updated Mon Feb 01 23:40:01 2010