Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: /newedit/src/, /newedit/src/images/, /newedit/src/mixins/, /newedit/src/modules/

newedit
Discussion topic

Back to topic list

CVS update: /newedit/src/, /newedit/src/images/, /newedit/src/mixins/, /newedit/src/modules/

Reply

Author limodou
Full name limodou
Date 2005-03-21 06:54:48 PST
Message User: limodou
Date: 05/03/21 06:54:48

Added:
 /newedit/src/images/
  splash.jpg

Modified:
 /newedit/src/
  NewEdit.py
 /newedit/src/mixins/
  Import.py, MainFrame.py, __init__.py, mDDESupport.py, mMainFrame.py,
  mPreference.py
 /newedit/src/modules/
  Mixin.py

Log:
 adjust structure

File Changes:

Directory: /newedit/src/
========================

File [changed]: NewEdit.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/NewEdit.​py?r1=1.38&r2=1.​39
Delta lines: +170 -151
-----------------------
--- NewEdit.py 16 Mar 2005 15:24:11 -0000 1.38
+++ NewEdit.py 21 Mar 2005 14:54:48 -0000 1.39
@@ -19,7 +19,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
-# $Id: NewEdit.py,v 1.38 2005/03/16 15:24:11 limodou Exp $
+# $Id: NewEdit.py,v 1.39 2005/03/21 14:54:48 limodou Exp $
 
 __appname__ = 'NewEdit'
 __author__ = 'limodou'
@@ -31,8 +31,12 @@
 import locale
 import os.path
 import codecs
+from modules import common
+from modules import Mixin
+from modules import Debug
+from modules import i18n
+from modules import IniFile
 
-#add modules path to sys.path
 workpath = os.path.dirname(os.p​ath.abspath(sys.argv​[0]))
 sys.path.insert(0, workpath)
 sys.path.insert(0, os.path.join(workpath, 'modules'))
@@ -40,158 +44,173 @@
 curpath = os.getcwd()
 os.chdir(workpath)
 
-from modules import common
+#install i18n package
+i18n = i18n.I18n('newedit', './lang', unicode=True, keyfunc='tr')
+ini = IniFile.IniFile()
+if ini.has_option('language', 'default'):
+ language = ini.get('language', 'default', '')
+ i18n.install(language, unicode=True)
 
-def Usage():
- print """Usage %s -u|-v|-n|[-e encoding]|-s|-f|-m files ...
+#import mixins
+try:
+ import mixins
+except:
+ Debug.error.traceback()
+ print "There are some errors as importing mimxins, Please see the error.txt."
+ sys.exit(0)
 
- -u Show this message
- -v Show version information
- -n Disable DDE support
- -e encoding Set default encoding which will be used in NewEdit
- -s Enable psyco speed support
- -f Skip last session files
- -m Multi user mode, data file will be saved in user home directory
-""" % sys.argv[0]
+class wxApp(wx.App):
+ def OnInit(self):
+ return True
 
-def Version():
- from modules import Version
+class App(Mixin.Mixin):
+ __mixinname__ = 'app'
 
- print """%s Copyleft GPL
-Author: %s
-Version: %s""" % (__appname__, __author__, Version.version)
+ def __init__(self):
+ self.initmixin()
 
-#process command line
-try:
+ self.appname = __appname__
+ self.author = __author__
+
+ self.wxApp = wxApp(0)
+ self.frame = self.init()
+ self.frame.Show()
+ self.wxApp.SetTopWin​dow(self.frame)
+ self.wxApp.MainLoop()
+
+ def init(self, showSplash=True, load=True):
+
+ #add modules path to sys.path
+ self.workpath = workpath
+ self.curpath = curpath
+ self.i18n = i18n
+
+ self.processCommandL​ineArguments()
+
+ if self.psycoflag:
+ try:
+ import psyco
+ psyco.full()
+ except:
+ pass
+
+ #change workpath
+ self.userpath = self.workpath
+ if self.multiuser:
+ self.userpath = common.getHomeDir()
+
+ Debug.debug = Debug.Debug(os.path.​join(self.userpath, 'debug.txt'))
+ Debug.error = Debug.Debug(os.path.​join(self.userpath, 'error.txt'))
+
+ #-------------------​--------------------​--------------------​------------------
+
+ self.callplugin('start', self, self.files)
+
+ #-------------------​--------------------​--------------------​------------------
+
+ #before running gui
+ self.callplugin("beforegui", self)
+
+ #-------------------​--------------------​--------------------​------------------
+
+ self.CheckPluginDir()
+
+ try:
+ import plugins
+ except:
+ Debug.error.traceback()
+ Mixin.printMixin()
+
+ return self.execplugin('getmainframe', self, self.files)
+
+ def processCommandLineAr​guments(self):
+ #process command line
+ try:
     opts, args = getopt.getopt(sys.argv[1:], "e:vunsfm", [])
-except getopt.GetoptError:
- Usage()
+ except getopt.GetoptError:
+ self.Usage()
     sys.exit(2)
-encoding = common.defaultencoding #defaultencoding in common.py
+ self.defaultencoding = common.defaultencoding #defaultencoding in common.py
 
-ddeflag = True
-psycoflag = False
-skipsessionfile = False
-multiuser = False
+ self.ddeflag = True
+ self.psycoflag = False
+ self.skipsessionfile = False
+ self.multiuser = False
 
-for o, a in opts:
+ for o, a in opts:
     if o == '-e': #encoding
- encoding = a
+ defaultencoding = a
     elif o == '-v': #version
- Version()
+ self.Version()
         sys.exit()
     elif o == '-u': #usage
- Usage()
+ self.Usage()
         sys.exit()
     elif o == '-n': #no dde
- ddeflag = False
+ self.ddeflag = False
     elif o == '-s':
- psycoflag = True
+ self.psycoflag = True
     elif o == '-f':
- skipsessionfile = True
+ self.skipsessionfile = True
     elif o == '-m':
- multiuser = True
-files = args
-
-files = [common.decode_strin​g(os.path.join(curpa​th, f)) for f in files]
-
-#change workpath
-userpath = workpath
-if multiuser:
- userpath = common.getHomeDir()
-
-#check version
-#from modules import CheckVersion
-
-#if not CheckVersion.check():
-# sys.exit(0)
-#
-from modules import Mixin
-from modules import Debug
-from modules import i18n
-from modules import IniFile
-
-Debug.debug = Debug.Debug(os.path.​join(userpath, 'debug.txt'))
-Debug.error = Debug.Debug(os.path.​join(userpath, 'error.txt'))
+ self.multiuser = True
+ files = args
 
-#install i18n package
-i18n = i18n.I18n('newedit', './lang', unicode=True, keyfunc='tr')
-ini = IniFile.IniFile()
-if ini.has_option('language', 'default'):
- language = ini.get('language', 'default', '')
- i18n.install(language, unicode=True)
-
-if psycoflag:
- try:
- import psyco
- psyco.full()
- except:
- pass
+ self.files = [common.decode_strin​g(os.path.join(self.​curpath, f)) for f in files]
 
-class NewEditApp(wx.App, Mixin.Mixin):
+ def quit(self):
+ self.wxApp.ProcessIdle()
+ self.wxApp.Exit()
 
- __mixinname__ = 'app'
+ def Usage(self):
+ print """Usage %s -u|-v|-n|[-e encoding]|-s|-f|-m files ...
 
- def OnInit(self):
- self.initmixin() #initialize mixin
+ -u Show this message
+ -v Show version information
+ -n Disable DDE support
+ -e encoding Set default encoding which will be used in NewEdit
+ -s Enable psyco speed support
+ -f Skip last session files
+ -m Multi user mode, data file will be saved in user home directory
+ """ % sys.argv[0]
 
- self.appname = __appname__
- self.i18n = i18n
- self.workpath = workpath
- self.userpath = userpath
- self.defaultencoding = encoding
- self.ddeflag = ddeflag
- self.skipsessionfile = skipsessionfile
+ def Version(self):
+ from modules import Version
 
- return self.execplugin('init', self, files)
+ print """%s Copyleft GPL
+Author: %s
+Version: %s""" % (__appname__, __author__, Version.version)
 
-def CheckPluginDir():
- pluginpath = os.path.join(workpath, 'plugins')
+ def CheckPluginDir(self):
+ pluginpath = os.path.join(self.workpath, 'plugins')
     if not os.path.exists(pluginpath):
         os.mkdir(pluginpath)
     if not os.path.exists(os.pa​th.join(pluginpath, '__init__.py')):
         file(os.path.join(pluginpath, '__init__.py'), 'w').write("""# Programmer: limodou
-# E-mail: chatme at 263 dot net
-#
-# Copyleft 2004 limodou
-#
-# Distributed under the terms of the GPL (GNU Public License)
-#
-# NewEdit is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-
-__doc__ = 'Plugins __init__.py'
-
-""")
-
-CheckPluginDir()
-try:
- import mixins
-except:
- Debug.error.traceback()
- print "There are some errors as importing mimxins, Please see the error.txt."
- sys.exit(0)
+ # E-mail: chatme at 263 dot net
+ #
+ # Copyleft 2004 limodou
+ #
+ # Distributed under the terms of the GPL (GNU Public License)
+ #
+ # NewEdit is free software; you can redistribute it and/or modify
+ # it under the terms of the GNU General Public License as published by
+ # the Free Software Foundation; either version 2 of the License, or
+ # (at your option) any later version.
+ #
+ # This program is distributed in the hope that it will be useful,
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ # GNU General Public License for more details.
+ #
+ # You should have received a copy of the GNU General Public License
+ # along with this program; if not, write to the Free Software
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ #
 
-try:
- import plugins
-except:
- Debug.error.traceback()
-Mixin.printMixin()
+ __doc__ = 'Plugins __init__.py'
 
-wx.InitAllImageHandlers()
+ """)
 
-app = NewEditApp(0)
 
-app.MainLoop()
\ No newline at end of file
+App()
\ No newline at end of file

Directory: /newedit/src/images/
===============================

File [added]: splash.jpg
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/images/s​plash.jpg?rev=1.1​&content-type=text/​vnd.viewcvs-markup
Directory: /newedit/src/mixins/
===============================

File [changed]: Import.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/mixins/I​mport.py?r1=1.78​&r2=1.79
Delta lines: +35 -45
---------------------
--- Import.py 16 Mar 2005 15:24:11 -0000 1.78
+++ Import.py 21 Mar 2005 14:54:48 -0000 1.79
@@ -20,7 +20,24 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
-# $Id: Import.py,v 1.78 2005/03/16 15:24:11 limodou Exp $
+# $Id: Import.py,v 1.79 2005/03/21 14:54:48 limodou Exp $
+
+
+#----------------------- mMainframe.py ------------------
+
+from modules import Mixin
+import wx
+
+def getmainframe(app, filenames):
+ from MainFrame import MainFrame
+
+ app.mainframe = frame = MainFrame(app, filenames)
+ frame.afterinit()
+ frame.editctrl.openPage()
+ return frame
+Mixin.setPlugin('app', 'getmainframe', getmainframe)
+
+
 
 
 #----------------------- mPreference.py ------------------
@@ -39,13 +56,13 @@
 ]
 Mixin.setMixin('mainframe', 'menulist', menulist)
 
-def initpreference(win):
+def beforegui(win):
     import Preference
 
     win.pref = Preference.Preference()
     win.pref.load()
     win.pref.printValues()
-Mixin.setPlugin('mainframe', 'start', initpreference, Mixin.HIGH)
+Mixin.setPlugin('app', 'beforegui', beforegui, Mixin.HIGH)
 
 def OnOptionPreference(win, event):
     import PrefDialog
@@ -57,31 +74,6 @@
 
 
 
-#----------------------- mMainFrame.py ------------------
-
-from modules import Mixin
-import wx
-
-def init(app, filenames):
- from MainFrame import MainFrame
-
- app.frame = MainFrame(app, filenames)
- if app.frame:
- app.frame.workpath = app.workpath
- app.frame.afterinit()
- app.frame.editctrl.openPage()
- app.frame.Show(True)
- app.SetTopWindow(app.frame)
-
-
- return True, True
- else:
- return True, False
-Mixin.setPlugin('app', 'init', init)
-
-
-
-
 #----------------------- mMainSubFrame.py ------------------
 
 from modules import Mixin
@@ -3898,6 +3890,7 @@
 
 __doc__ = 'simulate DDE support'
 
+import sys
 from modules import DDE
 from modules import Mixin
 import wx
@@ -3909,18 +3902,14 @@
         port = ini.getint('server', 'port', 0)
         if not DDE.run(app, port):
             DDE.senddata('\n'.j​oin(filenames))
- return True, False
-Mixin.setPlugin('app', 'init', init, Mixin.HIGH, 0)
+ sys.exit(0)
+Mixin.setPlugin('app', 'start', init, Mixin.HIGH, 0)
 
 def afterclosewindow(win):
     if win.app.ddeflag:
         DDE.stop()
 Mixin.setPlugin('mainframe', 'afterclosewindow', afterclosewindow)
 
-def init(win):
- win.readfiles = []
-Mixin.setPlugin('mainframe', 'init', init)
-
 def openfiles(win, files):
     if files:
         for filename in files:
@@ -5531,28 +5520,29 @@
 import wx
 from modules import common
 from modules import Mixin
+import time
 
 preflist = [
     (tr('General'), 190, 'check', 'splash_on_startup', tr('Show splash window on startup'), None),
 ]
 Mixin.setMixin('preference', 'preflist', preflist)
 
-def init(pref):
- pref.splash_on_startup = True
-Mixin.setPlugin('preference', 'init', init)
-
 splashimg = common.unicode_abspa​th('images/splash.jp​g')
 
-def start(mainframe):
- mainframe.splashwin = None
- if mainframe.pref.splas​h_on_startup:
- mainframe.splashwin = wx.SplashScreen(wx.I​mage(splashimg).Conv​ertToBitmap(),
+def beforegui(app):
+ app.splashwin = None
+ if app.pref.splash_on_startup:
+ app.splashwin = wx.SplashScreen(wx.I​mage(splashimg).Conv​ertToBitmap(),
             wx.SPLASH_CENTRE_ON_​SCREEN|wx.SPLASH_NO_​TIMEOUT, 0, None, -1)
-Mixin.setPlugin('mainframe', 'start', start)
+Mixin.setPlugin('app', 'beforegui', beforegui)
+
+def init(pref):
+ pref.splash_on_startup = True
+Mixin.setPlugin('preference', 'init', init)
 
 def show(mainframe):
- if mainframe.splashwin:
- mainframe.splashwin.Destroy()
+ if mainframe.app.splashwin:
+ wx.FutureCall(1000, mainframe.app.splash​win.Destroy)
 Mixin.setPlugin('mainframe', 'show', show)
 
 

File [changed]: MainFrame.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/mixins/M​ainFrame.py?r1=1.20​&r2=1.21
Delta lines: +2 -1
-------------------
--- MainFrame.py 16 Mar 2005 15:24:11 -0000 1.20
+++ MainFrame.py 21 Mar 2005 14:54:48 -0000 1.21
@@ -19,7 +19,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
-# $Id: MainFrame.py,v 1.20 2005/03/16 15:24:11 limodou Exp $
+# $Id: MainFrame.py,v 1.21 2005/03/21 14:54:48 limodou Exp $
 
 from modules import Mixin
 from modules import makemenu
@@ -48,6 +48,7 @@
     def __init__(self, app, filenames):
         self.initmixin()
         self.app = app
+ self.pref = app.pref
         self.filenames = filenames
 
         self.callplugin('start', self)

File [changed]: __init__.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/mixins/_​_init__.py?r1=1.60​&r2=1.61
Delta lines: +2 -2
-------------------
--- __init__.py 16 Mar 2005 15:24:11 -0000 1.60
+++ __init__.py 21 Mar 2005 14:54:48 -0000 1.61
@@ -19,11 +19,11 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
-# $Id: __init__.py,v 1.60 2005/03/16 15:24:11 limodou Exp $
+# $Id: __init__.py,v 1.61 2005/03/21 14:54:48 limodou Exp $
 
 ## 1.0 core
+#import mMainframe
 #import mPreference
-#import mMainFrame
 #import mMainSubFrame
 #import mEditorCtrl
 #import mEditor

File [changed]: mDDESupport.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/mixins/m​DDESupport.py?r1=1.5​&r2=1.6
Delta lines: +4 -7
-------------------
--- mDDESupport.py 6 Feb 2005 11:46:23 -0000 1.5
+++ mDDESupport.py 21 Mar 2005 14:54:48 -0000 1.6
@@ -19,10 +19,11 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
-# $Id: mDDESupport.py,v 1.5 2005/02/06 11:46:23 limodou Exp $
+# $Id: mDDESupport.py,v 1.6 2005/03/21 14:54:48 limodou Exp $
 
 __doc__ = 'simulate DDE support'
 
+import sys
 from modules import DDE
 from modules import Mixin
 import wx
@@ -35,17 +36,13 @@
         if not DDE.run(app, port):
 # print "send data"
             DDE.senddata('\n'.j​oin(filenames))
- return True, False
-Mixin.setPlugin('app', 'init', init, Mixin.HIGH, 0)
+ sys.exit(0)
+Mixin.setPlugin('app', 'start', init, Mixin.HIGH, 0)
 
 def afterclosewindow(win):
     if win.app.ddeflag:
         DDE.stop()
 Mixin.setPlugin('mainframe', 'afterclosewindow', afterclosewindow)
-
-def init(win):
- win.readfiles = []
-Mixin.setPlugin('mainframe', 'init', init)
 
 def openfiles(win, files):
     if files:

File [changed]: mMainFrame.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/mixins/m​MainFrame.py?r1=1.4​&r2=1.5
Delta lines: +9 -18
--------------------
--- mMainFrame.py 30 Jan 2005 13:30:21 -0000 1.4
+++ mMainFrame.py 21 Mar 2005 14:54:48 -0000 1.5
@@ -19,27 +19,18 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
-# $Id: mMainFrame.py,v 1.4 2005/01/30 13:30:21 limodou Exp $
+# $Id: mMainFrame.py,v 1.5 2005/03/21 14:54:48 limodou Exp $
 
 from modules import Mixin
 import wx
 
-def init(app, filenames):
+def getmainframe(app, filenames):
     from MainFrame import MainFrame
 
- app.frame = MainFrame(app, filenames)
- if app.frame:
- app.frame.workpath = app.workpath
- app.frame.afterinit()
- app.frame.editctrl.openPage()
- app.frame.Show(True)
- app.SetTopWindow(app.frame)
-
-# app.frame.afterinit()
-# app.frame.editctrl.openPage()
-
- return True, True
- else:
- return True, False
-Mixin.setPlugin('app', 'init', init)
+ app.mainframe = frame = MainFrame(app, filenames)
+# frame.workpath = app.workpath
+ frame.afterinit()
+ frame.editctrl.openPage()
+ return frame
+Mixin.setPlugin('app', 'getmainframe', getmainframe)
 

File [changed]: mPreference.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/mixins/m​Preference.py?r1=1.3​&r2=1.4
Delta lines: +3 -3
-------------------
--- mPreference.py 16 Mar 2005 15:24:11 -0000 1.3
+++ mPreference.py 21 Mar 2005 14:54:48 -0000 1.4
@@ -19,7 +19,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
-# $Id: mPreference.py,v 1.3 2005/03/16 15:24:11 limodou Exp $
+# $Id: mPreference.py,v 1.4 2005/03/21 14:54:48 limodou Exp $
 
 from modules import Mixin
 import wx
@@ -35,13 +35,13 @@
 ]
 Mixin.setMixin('mainframe', 'menulist', menulist)
 
-def initpreference(win):
+def beforegui(win):
     import Preference
 
     win.pref = Preference.Preference()
     win.pref.load()
     win.pref.printValues()
-Mixin.setPlugin('mainframe', 'start', initpreference, Mixin.HIGH)
+Mixin.setPlugin('app', 'beforegui', beforegui, Mixin.HIGH)
 
 def OnOptionPreference(win, event):
     import PrefDialog

Directory: /newedit/src/modules/
====================​============

File [changed]: Mixin.py
Url: http://newedit.tigri​s.org/source/browse/​newedit/src/modules/​Mixin.py?r1=1.15​&r2=1.16
Delta lines: +2 -2
-------------------
--- Mixin.py 7 Feb 2005 13:15:26 -0000 1.15
+++ Mixin.py 21 Mar 2005 14:54:48 -0000 1.16
@@ -19,7 +19,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
-# $Id: Mixin.py,v 1.15 2005/02/07 13:15:26 limodou Exp $
+# $Id: Mixin.py,v 1.16 2005/03/21 14:54:48 limodou Exp $
 
 import types
 from Debug import debug
@@ -64,7 +64,7 @@
             return
 
         for nice, f in self.__plugins__[name]:
- #debug.error("[Mixin] Call plugin [%s]" % name)
+ #debug.info("[Mixin] Call plugin [%s]" % name)
             f(*args, **kwargs)
 
     def execplugin(self, name, *args, **kwargs):




--------------------​--------------------​--------------------​---------
To unsubscribe, e-mail: cvs-unsubscribe@newe​dit.tigris.org
For additional commands, e-mail: cvs-help at newedit dot tigris dot org

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

CVS update: /newedit/src/, /newedit/src/images/, /newedit/src/mixins/, /newedit/src/modules/ limodou limodou 2005-03-21 06:54:48 PST
Messages per page: