[Python-checkins] r65429 - in sandbox/trunk/ttk-gsoc/src/idlelib: FileList.py IOBinding.py config-main.def editorpage.py

guilherme.polo python-checkins at python.org
Sun Aug 3 04:24:57 CEST 2008


Author: guilherme.polo
Date: Sun Aug  3 04:24:57 2008
New Revision: 65429

Log:
Adapted some code to work with the new file-in-tab option

Modified:
   sandbox/trunk/ttk-gsoc/src/idlelib/FileList.py
   sandbox/trunk/ttk-gsoc/src/idlelib/IOBinding.py
   sandbox/trunk/ttk-gsoc/src/idlelib/config-main.def
   sandbox/trunk/ttk-gsoc/src/idlelib/editorpage.py

Modified: sandbox/trunk/ttk-gsoc/src/idlelib/FileList.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/src/idlelib/FileList.py	(original)
+++ sandbox/trunk/ttk-gsoc/src/idlelib/FileList.py	Sun Aug  3 04:24:57 2008
@@ -37,9 +37,10 @@
             edit = self.dict[key]
             edit.top.wakeup()
             return edit
+
         if action:
             # Don't create window, perform 'action', e.g. open in same window
-            return action(filename)
+            return action(filename=filename)
         else:
             return self.EditorWindow(self, filename, key)
 
@@ -81,7 +82,7 @@
         if not filename:
             if key:
                 del self.dict[key]
-            self.inversedict[edit] = None
+            self.inversedict[editwin] = None
             return
         filename = _canonize(filename)
         newkey = os.path.normcase(filename)

Modified: sandbox/trunk/ttk-gsoc/src/idlelib/IOBinding.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/src/idlelib/IOBinding.py	(original)
+++ sandbox/trunk/ttk-gsoc/src/idlelib/IOBinding.py	Sun Aug  3 04:24:57 2008
@@ -206,18 +206,25 @@
                 filename = editFile
             if filename:
                 # If the current window has no filename and hasn't been
-                # modified, we replace its contents (no loss).  Otherwise
-                # we open a new window.  But we won't replace the
-                # shell window (which has an interp(reter) attribute), which
-                # gets set to "not modified" at every new prompt.
+                # modified, we replace its contents (no loss). Otherwise
+                # we open a new window, or maybe open in a tab.
+                # But we won't replace the shell window (which has an
+                # interp(reter) attribute), which gets set to "not modified"
+                # at every new prompt.
                 try:
                     interp = self.editwin.interp
                 except AttributeError:
                     interp = None
+
                 if not self.filename and self.get_saved() and not interp:
                     self.editwin.flist.open(filename, self.loadfile)
                 else:
-                    self.editwin.flist.open(filename)
+                    if idleConf.GetOption('main', 'EditorWindow',
+                        'file-in-tab', default=1, type='bool'):
+                        action = self.editwin.new_tab
+                    else:
+                        action = None
+                    self.editwin.flist.open(filename, action)
             else:
                 self.text.focus_set()
             return "break"

Modified: sandbox/trunk/ttk-gsoc/src/idlelib/config-main.def
==============================================================================
--- sandbox/trunk/ttk-gsoc/src/idlelib/config-main.def	(original)
+++ sandbox/trunk/ttk-gsoc/src/idlelib/config-main.def	Sun Aug  3 04:24:57 2008
@@ -54,6 +54,7 @@
 [EditorWindow]
 width = 80
 height = 40
+file-in-tab = 1
 
 [EditorPage]
 width= 80

Modified: sandbox/trunk/ttk-gsoc/src/idlelib/editorpage.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/src/idlelib/editorpage.py	(original)
+++ sandbox/trunk/ttk-gsoc/src/idlelib/editorpage.py	Sun Aug  3 04:24:57 2008
@@ -452,9 +452,13 @@
             return
         if f:
             f.close()
-        if self.editwin.flist: # XXX
-            # XXX change this to create a new tab instead
-            self.editwin.flist.open(file)
+        if self.editwin.flist:
+            if idleConf.GetOption('main', 'EditorWindow', 'file-in-tab',
+                default=1, type='bool'):
+                action = self.editwin.new_tab
+            else:
+                action = None
+            self.editwin.flist.open(file, action)
         else:
             self.io.loadfile(file)
 


More information about the Python-checkins mailing list