commit-gnue
[Top][All Lists]
Advanced

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

gnue/gnuef/designer/src GFDesigner.py


From: Jason Cater
Subject: gnue/gnuef/designer/src GFDesigner.py
Date: Sun, 10 Jun 2001 14:57:52 -0700

CVSROOT:        /home/cvs
Module name:    gnue
Changes by:     Jason Cater <address@hidden>    01/06/10 14:57:52

Modified files:
        gnuef/designer/src: GFDesigner.py 

Log message:
        Implemented an insignificant feature few will use: The ability to save. 
 :)

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnuef/designer/src/GFDesigner.py.diff?cvsroot=OldCVS&tr1=1.4&tr2=1.5&r1=text&r2=text

Patches:
Index: gnue/gnuef/designer/src/GFDesigner.py
diff -u gnue/gnuef/designer/src/GFDesigner.py:1.4 
gnue/gnuef/designer/src/GFDesigner.py:1.5
--- gnue/gnuef/designer/src/GFDesigner.py:1.4   Wed Jun  6 12:02:13 2001
+++ gnue/gnuef/designer/src/GFDesigner.py       Sun Jun 10 14:57:52 2001
@@ -25,7 +25,7 @@
 #
 # NOTES:
 
-import sys, os
+import sys, os, time
 from wxPython.wx import *
 from gnue.common import GDebug
 from gnue.common.GClientApp import GClientApp
@@ -42,21 +42,21 @@
 ID_RUN = 108
 
 TITLE = "GNUe Forms Designer"
+VERSION = "pre0.0.1"
 
 class GFDesigner(GClientApp, wxApp):
 
   # GClientApp stuff...
   NAME = TITLE
-  VERSION = "0.0.0"
+  VERSION = VERSION
   COMMAND = "gfdesign"
   NAME = "A graphical tool for the creation of GNUe Forms."
   USAGE = "gfdesign [options] [files]"
 
   def __init__(self): 
-    GClientApp.__init__(self)
+    GClientApp.__init__(self, application="forms")
     self._instances = []
-    wxApp.__init__(self,0)
-   
+    wxApp.__init__(self,0)   
 
   def run(self):
     self.MainLoop()
@@ -155,6 +155,8 @@
     wxFrame.__init__(self, NULL, -1, "")
 
     self._app = app
+    self._lastGenericNameSeq = {}
+    self.nameMappings = {}
     app.addInstance(self) 
 
     if location == None: 
@@ -210,8 +212,53 @@
 
   def inventoryLoadedItems (self, object): 
     if object != self._form: 
+      
+      if hasattr(object, 'name') and \
+         (object.name == None or (
+          object.name[:3] == "__<" and \
+          object.name[-3:] == ">__")): 
+        object.name = self.getNextGenericName(object.getObjectType()[2:])
       object._treeItem = self.tree.AppendItem(object._parent._treeItem, 
           "%s" % object.getDescription())
+
+  def getNextGenericName (self, type): 
+    while 1: 
+      if self._lastGenericNameSeq.has_key(string.lower(type)): 
+        self._lastGenericNameSeq[string.lower(type)] = \
+           self._lastGenericNameSeq[string.lower(type)] + 1
+      else: 
+        self._lastGenericNameSeq[string.lower(type)] = 1
+      name = "%s%s_%s" % (string.upper(type[0]), \
+          string.lower(type[1:]), self._lastGenericNameSeq[string.lower(type)])
+      if not self.nameMappings.has_key(name): 
+        break
+
+    return name
+  
+  def saveForm(self): 
+    location = self._path
+    fileHandle = None
+    fileHandle2 = None
+    try: 
+      fileHandle = open(location,'r')
+      fileHandle2 = open(location + "~",'w')
+      fileHandle2.writelines(fileHandle.readlines())
+#    except:
+#      pass
+    finally: 
+      if fileHandle != None: 
+        fileHandle.close()
+      if fileHandle2 != None: 
+        fileHandle.close()
+
+    fileHandle = open(location,'w')
+    fileHandle.write('<?xml version="1.0"?>\n\n')
+    fileHandle.write('<!--  %s [version %s]\n      Form saved on: %s  -->\n\n' 
\
+       % (TITLE, VERSION, \
+          time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(time.time()))))
+    fileHandle.write(self._form.dumpXML(treeDump=1))
+    fileHandle.close()
+    
 
   def OnTreeLabelEdit(self, event): 
     pass



reply via email to

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