[Python-checkins] r65408 - sandbox/trunk/ttk-gsoc/src/idlelib/IOBinding.py

guilherme.polo python-checkins at python.org
Sat Aug 2 15:34:41 CEST 2008


Author: guilherme.polo
Date: Sat Aug  2 15:34:41 2008
New Revision: 65408

Log:
Added a reference to the editor window, looks more correct now

Modified:
   sandbox/trunk/ttk-gsoc/src/idlelib/IOBinding.py

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	Sat Aug  2 15:34:41 2008
@@ -145,13 +145,13 @@
 
 
 class IOBinding:
-    # XXX will need to change this too
+    filename_change_hook = None
+    filename = None
+    dirname = None
 
-    #def __init__(self, editwin):
     def __init__(self, editpage):
-        #self.editwin = editwin
-        #self.text = editwin.text
         self.editpage = editpage
+        self.editwin = editpage.editwin
         self.text = editpage.text
         self.__id_open = self.text.bind("<<open-window-from-file>>", self.open)
         self.__id_save = self.text.bind("<<save-window>>", self.save)
@@ -170,31 +170,23 @@
         self.text.unbind("<<save-copy-of-window-as-file>>", self.__id_savecopy)
         self.text.unbind("<<print-window>>", self.__id_print)
         # Break cycles
-        #self.editwin = None
-        self.editpage = None
         self.text = None
+        self.editpage = None
+        self.editwin = None
         self.filename_change_hook = None
 
     def get_saved(self):
-        #return self.editwin.get_saved()
         return self.editpage.get_saved()
 
     def set_saved(self, flag):
-        #self.editwin.set_saved(flag)
         self.editpage.set_saved(flag)
 
     def reset_undo(self):
-        #self.editwin.reset_undo()
         self.editpage.reset_undo()
 
-    filename_change_hook = None
-
     def set_filename_change_hook(self, hook):
         self.filename_change_hook = hook
 
-    filename = None
-    dirname = None
-
     def set_filename(self, filename):
         if filename and os.path.isdir(filename):
             self.filename = None
@@ -211,7 +203,7 @@
             if not editFile:
                 filename = self.askopenfile()
             else:
-                filename=editFile
+                filename = editFile
             if filename:
                 # If the current window has no filename and hasn't been
                 # modified, we replace its contents (no loss).  Otherwise
@@ -352,8 +344,8 @@
             if self.writefile(self.filename):
                 self.set_saved(1)
                 try:
-                    self.editpage.editwin.store_file_breaks(self.editpage)
-                except AttributeError:  # may be a PyShell
+                    self.editwin.store_file_breaks(self.editpage)
+                except AttributeError:  # may not be a PyShell
                     pass
         self.text.focus_set()
         return "break"
@@ -365,7 +357,7 @@
                 self.set_filename(filename)
                 self.set_saved(1)
                 try:
-                    self.editpage.editwin.store_file_breaks(self.editpage)
+                    self.editwin.store_file_breaks(self.editpage)
                 except AttributeError:
                     pass
         self.text.focus_set()
@@ -392,8 +384,7 @@
             f.close()
             return True
         except IOError, msg:
-            tkMessageBox.showerror("I/O Error", str(msg),
-                                   master=self.text)
+            tkMessageBox.showerror("I/O Error", str(msg), master=self.text)
             return False
 
     def encode(self, chars):
@@ -455,8 +446,7 @@
             enc = "utf-8"
         if not ask_user:
             return chars
-        #dialog = EncodingMessage(self.editwin.top, enc)
-        dialog = EncodingMessage(self.editpage.editwin.top, enc)
+        dialog = EncodingMessage(self.editwin.top, enc)
         dialog.go()
         if dialog.num == 1:
             # User asked us to edit the file
@@ -571,8 +561,7 @@
 
     def updaterecentfileslist(self,filename):
         "Update recent file list on all editor windows"
-        #self.editwin.update_recent_files_list(filename)
-        self.editpage.editwin.update_recent_files_list(filename)
+        self.editwin.update_recent_files_list(filename)
 
 def test():
     from Tkinter import Tk, Text


More information about the Python-checkins mailing list