[Commits] (morgen) Added a simple dialog which will get hooked up to collection subscription.

commits at osafoundation.org commits at osafoundation.org
Fri Jul 30 15:47:29 PDT 2004


Commit by: morgen
Modified files:
chandler/application/Application.py 1.256 1.257
chandler/parcels/osaf/framework/blocks/Events/parcel.xml 1.43 1.44
chandler/parcels/osaf/views/main/Main.py 1.22 1.23
chandler/parcels/osaf/views/main/parcel.xml 1.84 1.85

Log message:
Added a simple dialog which will get hooked up to collection subscription.


ViewCVS links:
http://cvs.osafoundation.org/index.cgi/chandler/application/Application.py.diff?r1=text&tr1=1.256&r2=text&tr2=1.257
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/framework/blocks/Events/parcel.xml.diff?r1=text&tr1=1.43&r2=text&tr2=1.44
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/views/main/Main.py.diff?r1=text&tr1=1.22&r2=text&tr2=1.23
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/views/main/parcel.xml.diff?r1=text&tr1=1.84&r2=text&tr2=1.85

Index: chandler/application/Application.py
diff -u chandler/application/Application.py:1.256 chandler/application/Application.py:1.257
--- chandler/application/Application.py:1.256	Tue Jul 27 12:46:44 2004
+++ chandler/application/Application.py	Fri Jul 30 15:47:27 2004
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.256 $"
-__date__ = "$Date: 2004/07/27 19:46:44 $"
+__version__ = "$Revision: 1.257 $"
+__date__ = "$Date: 2004/07/30 22:47:27 $"
 __copyright__ = "Copyright (c) 2003-2004 Open Source Applications Foundation"
 __license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -591,3 +591,92 @@
             self.chandlerItem.setAttributeValue(valueDict["attr"],
              self.chandlerTextControls[i].GetValue())
             i += 1
+
+# A simple "prompt-the-user-for-a-string" dialog
+
+
+def promptUser(frame, title, message, value):
+    """ Prompt the user to enter in a string.  Return None if cancel is hit.
+
+        @param frame: A wx parent frame
+        @type frame: wx frame
+        @param title: The title string for the dialog
+        @type title: String
+        @param message:  A message prompting the user for input
+        @type item:  String
+        @param value:  A value to populate the text field with
+        @type item:  String
+
+    """
+    win = promptUserDialog(frame, -1, title, message, value)
+    win.CenterOnScreen()
+    val = win.ShowModal()
+
+    if val == wx.ID_OK:
+        # Assign the new values
+        value = win.GetValue()
+    else:
+        value = None
+
+    win.Destroy()
+    return value
+
+class promptUserDialog(wx.Dialog):
+    def __init__(self, parent, ID, title, message, value, isPassword=False,
+     size=wx.DefaultSize, pos=wx.DefaultPosition,
+     style=wx.DEFAULT_DIALOG_STYLE):
+
+        # Instead of calling wx.Dialog.__init__ we precreate the dialog
+        # so we can set an extra style that must be set before
+        # creation, and then we create the GUI dialog using the Create
+        # method.
+        pre = wx.PreDialog()
+        pre.Create(parent, ID, title, pos, size, style)
+
+        # This next step is the most important, it turns this Python
+        # object into the real wrapper of the dialog (instead of pre)
+        # as far as the wxPython extension is concerned.
+        self.this = pre.this
+
+        # Now continue with the normal construction of the dialog
+        # contents
+        sizer = wx.BoxSizer(wx.VERTICAL)
+        label = wx.StaticText(self, -1, message)
+        sizer.Add(label, 0, wx.ALIGN_CENTER|wx.ALL, 5)
+
+        box = wx.BoxSizer(wx.HORIZONTAL)
+
+        if isPassword:
+            text = wx.TextCtrl(self, -1, value, size=(80,-1),
+             style=wx.TE_PASSWORD)
+        else:
+            text = wx.TextCtrl(self, -1, value, size=(80,-1))
+
+        box.Add(text, 1, wx.ALIGN_CENTRE|wx.ALL, 5)
+
+        sizer.AddSizer(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
+
+        line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL)
+        sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5)
+
+        box = wx.BoxSizer(wx.HORIZONTAL)
+
+        btn = wx.Button(self, wx.ID_OK, " OK ")
+        btn.SetDefault()
+        box.Add(btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
+
+        btn = wx.Button(self, wx.ID_CANCEL, " Cancel ")
+        box.Add(btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
+
+        sizer.Add(box, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
+
+        self.SetSizer(sizer)
+        self.SetAutoLayout(True)
+        sizer.Fit(self)
+
+        # Store these, using attribute names that hopefully wont collide with
+        # any wx attributes
+        self.textControl = text
+
+    def GetValue(self):
+        return self.textControl.GetValue()

Index: chandler/parcels/osaf/framework/blocks/Events/parcel.xml
diff -u chandler/parcels/osaf/framework/blocks/Events/parcel.xml:1.43 chandler/parcels/osaf/framework/blocks/Events/parcel.xml:1.44
--- chandler/parcels/osaf/framework/blocks/Events/parcel.xml:1.43	Mon Jul 26 16:06:05 2004
+++ chandler/parcels/osaf/framework/blocks/Events/parcel.xml	Fri Jul 30 15:47:27 2004
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
 
-<!-- $Revision: 1.43 $ -->
-<!-- $Date: 2004/07/26 23:06:05 $ -->
+<!-- $Revision: 1.44 $ -->
+<!-- $Date: 2004/07/30 22:47:27 $ -->
 <!-- Copyright (c) 2003 Open Source Applications Foundation -->
 <!-- License: http://osafoundation.org/Chandler_0.1_license_terms.htm -->
 
@@ -28,6 +28,7 @@
     <subscribeAlwaysEvents itemref="events:Copy"/>
     <subscribeAlwaysEvents itemref="events:Paste"/>
     <subscribeAlwaysEvents itemref="events:Preferences"/>
+    <subscribeAlwaysEvents itemref="events:SharingSubscribeToCollection"/>
     <subscribeAlwaysEvents itemref="events:EditMailAccount"/>
     <subscribeAlwaysEvents itemref="events:GetNewMail"/>
     <subscribeAlwaysEvents itemref="events:SelectionChanged"/>
@@ -89,6 +90,10 @@
     <dispatchEnum>ActiveViewBubbleUp</dispatchEnum>
   </BlockEvent>
 
+  <BlockEvent itsName="SharingSubscribeToCollection">
+    <dispatchEnum>ActiveViewBubbleUp</dispatchEnum>
+  </BlockEvent>
+
   <BlockEvent itsName="EditMailAccount">
     <dispatchEnum>ActiveViewBubbleUp</dispatchEnum>
   </BlockEvent>

Index: chandler/parcels/osaf/views/main/Main.py
diff -u chandler/parcels/osaf/views/main/Main.py:1.22 chandler/parcels/osaf/views/main/Main.py:1.23
--- chandler/parcels/osaf/views/main/Main.py:1.22	Tue Jul 27 12:46:45 2004
+++ chandler/parcels/osaf/views/main/Main.py	Fri Jul 30 15:47:28 2004
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.22 $"
-__date__ = "$Date: 2004/07/27 19:46:45 $"
+__version__ = "$Revision: 1.23 $"
+__date__ = "$Date: 2004/07/30 22:47:28 $"
 __copyright__ = "Copyright (c) 2003 Open Source Applications Foundation"
 __license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -38,10 +38,18 @@
 
     def onPasteEventUpdateUI (self, notification):
         notification.data ['Enable'] = False
- 
+
     def onPreferencesEventUpdateUI (self, notification):
         notification.data ['Enable'] = False
 
+    def onSharingSubscribeToCollectionEvent(self, notification):
+        url =  application.Application.promptUser( \
+         Globals.wxApplication.mainFrame, "Subscribe to Collection...", 
+         "Collection URL:", "http://webdav.osafoundation.org/")
+        if url is not None:
+            print "I would be subscribing to %s here" % url
+
+
     def onEditMailAccountEvent (self, notification):
         account = \
          Globals.repository.findPath('//parcels/osaf/mail/IMAPAccount One')
@@ -88,7 +96,6 @@
                 print "Conflict resolved"
 
 
-
     def onGetNewMailEvent (self, notification):
         accountList = [Globals.repository.findPath('//parcels/osaf/mail/IMAPAccount One')]
         account = accountList[0]

Index: chandler/parcels/osaf/views/main/parcel.xml
diff -u chandler/parcels/osaf/views/main/parcel.xml:1.84 chandler/parcels/osaf/views/main/parcel.xml:1.85
--- chandler/parcels/osaf/views/main/parcel.xml:1.84	Mon Jul 26 16:06:05 2004
+++ chandler/parcels/osaf/views/main/parcel.xml	Fri Jul 30 15:47:28 2004
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
 
-<!-- $Revision: 1.84 $ -->
-<!-- $Date: 2004/07/26 23:06:05 $ -->
+<!-- $Revision: 1.85 $ -->
+<!-- $Date: 2004/07/30 22:47:28 $ -->
 <!-- Copyright (c) 2003 Open Source Applications Foundation -->
 <!-- License: http://osafoundation.org/Chandler_0.1_license_terms.htm -->
 
@@ -237,6 +237,7 @@
     <childrenBlocks itemref="doc:GenerateCalendarItem"/>
     <childrenBlocks itemref="doc:GenerateNoteItem"/>
     <childrenBlocks itemref="doc:ImportContactItem"/>
+    <childrenBlocks itemref="doc:SharingSubscribeToCollectionItem"/>
     <childrenBlocks itemref="doc:EditMailAccountItem"/>
     <childrenBlocks itemref="doc:GetNewMailItem"/>
     <childrenBlocks itemref="doc:CheckRepositoryItem"/>
@@ -430,9 +431,17 @@
     <helpString>import Contacts from contacts.csv</helpString>
   </MenuItem>
 
+  <MenuItem itsName="SharingSubscribeToCollectionItem">
+    <blockName>SharingSubscribeToCollection</blockName>
+    <title>Subscribe to Collection...</title>
+    <location>TestMenu</location>
+    <event itemref="events:SharingSubscribeToCollection"/>
+    <helpString>Subscribe to a published item collection</helpString>
+  </MenuItem>
+
   <MenuItem itsName="EditMailAccountItem">
     <blockName>EditMailAccountItem</blockName>
-    <title>Edit Mail Account</title>
+    <title>Edit Mail Account...</title>
     <location>TestMenu</location>
     <event itemref="events:EditMailAccount"/>
     <helpString>Edit email account settings</helpString>
@@ -456,7 +465,7 @@
 
   <MenuItem itsName="ShowPyCrustItem">
     <blockName>ShowPyCrustItem</blockName>
-    <title>Show PyCrust Debugger</title>
+    <title>Show PyCrust Debugger...</title>
     <location>TestMenu</location>
     <event itemref="events:ShowPyCrust"/>
     <helpString>Brings up an interactive Python shell</helpString>



More information about the Commits mailing list