commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnue common/src/GObjects.py common/src/GParser....


From: James Thompson
Subject: gnue common/src/GObjects.py common/src/GParser....
Date: Tue, 03 Dec 2002 13:06:32 -0500

CVSROOT:        /cvsroot/gnue
Module name:    gnue
Changes by:     James Thompson <address@hidden> 02/12/03 13:06:32

Modified files:
        common/src     : GObjects.py GParser.py 
        forms/samples/dialog: dialog.gfd 
        forms/src      : GFForm.py GFInstance.py 

Log message:
        more changes for <dialog> support

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/GObjects.py.diff?tr1=1.47&tr2=1.48&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/GParser.py.diff?tr1=1.54&tr2=1.55&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/samples/dialog/dialog.gfd.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/GFForm.py.diff?tr1=1.216&tr2=1.217&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/GFInstance.py.diff?tr1=1.72&tr2=1.73&r1=text&r2=text

Patches:
Index: gnue/common/src/GObjects.py
diff -c gnue/common/src/GObjects.py:1.47 gnue/common/src/GObjects.py:1.48
*** gnue/common/src/GObjects.py:1.47    Fri Nov 29 02:06:59 2002
--- gnue/common/src/GObjects.py Tue Dec  3 13:06:32 2002
***************
*** 73,79 ****
    #
    # phaseInit
    #
!   def phaseInit(self, iterations=5):
      for phase in range(iterations):
        self._phaseInit(phase)
  
--- 73,81 ----
    #
    # phaseInit
    #
!   def phaseInit(self, iterations=0):
!     if iterations == 0:
!       iterations = self.maxInits()
      for phase in range(iterations):
        self._phaseInit(phase)
  
***************
*** 114,119 ****
--- 116,137 ----
    #
    def _buildObject(self):
      return len(self._inits)
+ 
+   #
+   # maxInits functions
+   #
+   # maxInits returns the maximum size of all the _inits
+   # list from this object or it's children
+   #
+   def maxInits(self):
+     self._initCount = 0
+     self.walk(self._maxInitsWalker)
+     return self._initCount
+ 
+   def _maxInitsWalker(self, object):
+     if hasattr(object,'_inits'):
+       self._initCount = max(self._initCount,len(object._inits))
+ 
  
    def getChildrenAsContent(self):
      content = ""
Index: gnue/common/src/GParser.py
diff -c gnue/common/src/GParser.py:1.54 gnue/common/src/GParser.py:1.55
*** gnue/common/src/GParser.py:1.54     Wed Nov 27 21:24:38 2002
--- gnue/common/src/GParser.py  Tue Dec  3 13:06:32 2002
***************
*** 29,34 ****
--- 29,35 ----
  
  import sys, copy, types
  from gnue.common.GObjects import GObj
+ from gnue.common.GRootObj import GRootObj
  from gnue.common.GTrigger import GTrigger
  from gnue.common.FileUtils import openResource
  
***************
*** 116,123 ****
    dh.finalValidation()
  
    # Set the root object's attributes
!   object.__dict__.update(attributes)
  
  
    if initialize:
      GDebug.printMesg(10,"Initializing the object tree starting at %s" 
%(object))
--- 117,130 ----
    dh.finalValidation()
  
    # Set the root object's attributes
!   #
!   # There should only be 1 root object but GNUe Forms
!   # allows for nested forms so we have to walk the tree
!   #
!   #
!   #object.__dict__.update(attributes)
  
+   object.walk(addAttributesWalker,attributes=attributes)
  
    if initialize:
      GDebug.printMesg(10,"Initializing the object tree starting at %s" 
%(object))
***************
*** 126,131 ****
--- 133,147 ----
  
  
    return object
+ #######################################################
+ #
+ # addAttributesWalker
+ #
+ #######################################################
+ def addAttributesWalker(object, attributes={}):
+   if isinstance(object,GRootObj):
+     object.__dict__.update(attributes)
+           
  
  
  #######################################################
Index: gnue/forms/samples/dialog/dialog.gfd
diff -c gnue/forms/samples/dialog/dialog.gfd:1.3 
gnue/forms/samples/dialog/dialog.gfd:1.4
*** gnue/forms/samples/dialog/dialog.gfd:1.3    Wed Nov 27 22:35:53 2002
--- gnue/forms/samples/dialog/dialog.gfd        Tue Dec  3 13:06:32 2002
***************
*** 26,32 ****
      </page>
    </layout>
  
!   <dialog xmlns:c="GNUe:Layout:Char" name="selector">
      <options/>
      <datasource name="dtsDrpStaticdrop1" type="static">
        <staticset fields="key,descr">
--- 26,32 ----
      </page>
    </layout>
  
!   <form style="dialog" xmlns:c="GNUe:Layout:Char" name="selector">
      <options/>
      <datasource name="dtsDrpStaticdrop1" type="static">
        <staticset fields="key,descr">
***************
*** 57,62 ****
                 c:x="1" c:y="2"/>
        </page>
      </layout>
!   </dialog>
  
  </form>
--- 57,62 ----
                 c:x="1" c:y="2"/>
        </page>
      </layout>
!   </form>
  
  </form>
Index: gnue/forms/src/GFForm.py
diff -c gnue/forms/src/GFForm.py:1.216 gnue/forms/src/GFForm.py:1.217
*** gnue/forms/src/GFForm.py:1.216      Tue Dec  3 10:51:15 2002
--- gnue/forms/src/GFForm.py    Tue Dec  3 13:06:32 2002
***************
*** 148,170 ****
      }
  
  
!   #
!   # Modify the base phaseInit to only process
!   #
!   def phaseInit(self, iterations=5, dialogInit=0):
!     if self.style != 'dialog' or dialogInit:
!       for phase in range(iterations):
!         self._phaseInit(phase, dialogInit=dialogInit)
                    
!   def _phaseInit(self,phase,dialogInit=0):
!     if self.style != 'dialog' or dialogInit:
!       if (len(self._inits) > phase) and self._inits[phase]:
!         GDebug.printMesg(6,"%s: Init Phase %s" % (self._type, phase+1))
!         self._inits[phase]()
  
!       for child in self._children:
!         if isinstance(child, GObj):
!           child._phaseInit(phase)
            
    #
    # Convert some deprecated options to new style
--- 148,170 ----
      }
  
  
! ##   #
! ##   # Modify the base phaseInit to only process
! ##   #
! ##   def phaseInit(self, iterations=5, dialogInit=0):
! ##     if self.style != 'dialog' or dialogInit:
! ##       for phase in range(iterations):
! ##         self._phaseInit(phase, dialogInit=dialogInit)
                    
! ##   def _phaseInit(self,phase,dialogInit=0):
! ##     if self.style != 'dialog' or dialogInit:
! ##       if (len(self._inits) > phase) and self._inits[phase]:
! ##         GDebug.printMesg(6,"%s: Init Phase %s" % (self._type, phase+1))
! ##         self._inits[phase]()
  
! ##       for child in self._children:
! ##         if isinstance(child, GObj):
! ##           child._phaseInit(phase)
            
    #
    # Convert some deprecated options to new style
Index: gnue/forms/src/GFInstance.py
diff -c gnue/forms/src/GFInstance.py:1.72 gnue/forms/src/GFInstance.py:1.73
*** gnue/forms/src/GFInstance.py:1.72   Tue Dec  3 10:51:15 2002
--- gnue/forms/src/GFInstance.py        Tue Dec  3 13:06:32 2002
***************
*** 37,43 ****
  from gnue.forms.GFParser import loadFile
  from gnue.forms import VERSION
  from gnue.forms import GFKeyMapper
! from gnue.common import GDebug, GDataObjects
  from gnue.common import events
  from gnue.common.FileUtils import openResource
  
--- 37,43 ----
  from gnue.forms.GFParser import loadFile
  from gnue.forms import VERSION
  from gnue.forms import GFKeyMapper
! from gnue.common import GDebug, GDataObjects, GConnections
  from gnue.common import events
  from gnue.common.FileUtils import openResource
  
***************
*** 47,53 ****
    #
    # Initialize the class
    #
- #  def __init__(self, manager, serial, connections, ui, disableSplash=0,
    def __init__(self, manager, connections, ui, disableSplash=0,
                 parameters={}):
      #
--- 47,52 ----
***************
*** 125,134 ****
      self._disableSplash = disableSplash  # Disable splashscreen
      self._parameters = parameters        # The parameters passed to the
                                           # GBaseApp instance
!     self._dialogDictionary = {}          # A dictionary containing all the
!                                          # dialog forms that were originally
!                                          # in the loaded form
! 
      #
      # Load user customized key mappings
      #
--- 124,132 ----
      self._disableSplash = disableSplash  # Disable splashscreen
      self._parameters = parameters        # The parameters passed to the
                                           # GBaseApp instance
!     self._formsDictionary = {}           # A dictionary containing all the
!                                          # forms loaded from a file
!   
      #
      # Load user customized key mappings
      #
***************
*** 158,218 ****
      #
      try:
        fileHandle=openResource(fileName)
!       self._form = loadFile (fileHandle, self, initialize=0)
        fileHandle.close()
      except IOError, mesg:
        self.manager.handleStartupError(_("Unable to open file\n\n     
%s")%mesg)
  
  
      #
      # Extract the child <dialog>s from the main form tree
      #
!     self.reapDialogs(self._form)
  
      #
!     # Initialize the main form then the dialogs
      #
!     self._form.phaseInit(self.countInits(self._form))
!     print 'main', self._form._currentEntry
!     
!     for dialog in self._dialogDictionary.keys():
!       
self._dialogDictionary[dialog].phaseInit(self.countInits(self._dialogDictionary[dialog]))
!       print "Inited to ", self._dialogDictionary[dialog]._currentEntry
!       
!   #
!   # countInits functions
!   #
!   # Since we are bypassing the GParser call to phaseInit we
!   # need to figure out how many passes phaseInit must make
!   #
!   def countInits(self,form):
!     self.initCount = 0
!     form.walk(self._countInitsWalker)
!     return self.initCount
!   def _countInitsWalker(self, object):
!     if hasattr(object,'_inits'):
!       self.initCount = max(self.initCount,len(object._inits))
!       
    #
!   # removes the dialog forms from the main tree before
    # any UI stuff is constructed
    #
!   def reapDialogs(self,formTree):
      for child in formTree._children:
        if isinstance(child, GFForm):
          child._parent = None
!         self._dialogDictionary[child.name] = child
          formTree._children.remove(child)
!                                                               
    #
!   #  Activate the instance
    #
!   #  Builds the UI and turns control over to it
    #
    def activate(self):
!     ui = self._uiinstance =  
self._uimodule.GFUserInterface(self.eventController, self._disableSplash)
      try:
!       ui.buildForm(self._form)
      except GConnections.Error, mesg:
        self.handleStartupError(mesg)
  
--- 156,224 ----
      #
      try:
        fileHandle=openResource(fileName)
!       form = loadFile (fileHandle, self, initialize=0)
        fileHandle.close()
      except IOError, mesg:
        self.manager.handleStartupError(_("Unable to open file\n\n     
%s")%mesg)
  
+     #
+     # Add the main form into the dictionary
+     #
+     self._formsDictionary['__main__'] = form
  
      #
      # Extract the child <dialog>s from the main form tree
      #
!     self.reapSubforms(form)    
  
      #
!     # Initialize all the forms
      #
!     for dialog in self._formsDictionary.keys():
!       object = self._formsDictionary[dialog]
!       object.phaseInit()
! 
!     self._form = form # TODO: temp hack to keep it working
! 
    #
!   # removes the subforms from the main tree before
    # any UI stuff is constructed
    #
!   def reapSubforms(self,formTree):
      for child in formTree._children:
        if isinstance(child, GFForm):
          child._parent = None
!         self._formsDictionary[child.name] = child
          formTree._children.remove(child)
! 
    #
!   # activate
    #
!   # Tells the instance to bring up it's UI, activate the __main__ form,
!   # and pass control to the UI
    #
    def activate(self):
!     #
!     # Construct the 
!     self._uiinstance =  self._uimodule.GFUserInterface(self.eventController, 
self._disableSplash)
! 
!     self.activateForm('__main__')
! 
!     self._uiinstance.mainLoop()
!         
!   #
!   #  Builds a UI based upon a specific form and 
!   #  sets that form to active status
!   #
!   def activateForm(self,formName='__main__'):
!     form = self._formsDictionary[formName]
! 
!     if not form._currentEntry:
!       raise  _('There are no navigable widgets in this form.  Unable to 
display.')
! 
      try:
!       self._uiinstance.buildForm(form)
! 
      except GConnections.Error, mesg:
        self.handleStartupError(mesg)
  
***************
*** 226,266 ****
        
      except GDataObjects.Error, mesg:
        self.handleStartupError(mesg)
-                                     
-     ui.activateForm(self._form)
- 
-     currentEntry = self._form._currentEntry
  
!     if not currentEntry:
!       raise  _('There are no navigable widgets in this form.  Unable to 
display.')
  
!     self.dispatchEvent('gotoENTRY',{'object':currentEntry})
!     self.dispatchEvent('updateENTRY',currentEntry)
!     self._form.refreshDisplay(self._form)
      self.updateStatus()
-     self._ui = ui
  
-     # pass control to UI
-     ui.mainLoop()
-     
    #
-   # Associate a form object with this instance
    #
!   def setForm(self, form):
!     self._form = form
! 
!   #
!   # _entryUpdated
!   #
!   # Common code snipped called when something has changed with an
!   # entry and it has to update the stat bar.  Used to cut down on
!   # repeated code.
!   #
!   def _entryUpdated(self):
!     self.dispatchEvent('gotoENTRY',{'object':self._form._currentEntry})
!     self.updateRecordCounter()
!     self.updateRecordStatus()
! 
    #
    # Routines to update parts of the UI's status bar
    #
--- 232,248 ----
        
      except GDataObjects.Error, mesg:
        self.handleStartupError(mesg)
  
!     self._uiinstance.activateForm(form)
  
!     self.dispatchEvent('gotoENTRY',{'object':form._currentEntry})
!     self.dispatchEvent('updateENTRY',form._currentEntry)
!     self._form.refreshDisplay(form)
      self.updateStatus()
  
    #
    #
!   # UI FUNCTIONS 
    #
    # Routines to update parts of the UI's status bar
    #
***************
*** 316,321 ****
--- 298,317 ----
    # From here down should be nothing but eventListeners listed
    # in the __init__ above.
    #
+ 
+   #
+   # _entryUpdated
+   #
+   # Common code snipped called when something has changed with an
+   # entry and it has to update the stat bar.  Used to cut down on
+   # repeated code.
+   #
+   def _entryUpdated(self):
+     self.dispatchEvent('gotoENTRY',{'object':self._form._currentEntry})
+     self.updateRecordCounter()
+     self.updateRecordStatus()
+ 
+ 
    #
    # proxyEntryEvent
    #
***************
*** 528,534 ****
        method()
  
      self._entryUpdated()
- 
  
    #
    # executeExit
--- 524,529 ----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]