[Commits] (morgen) Hooking up File | Preferences | Accounts menu to
new dialog
commits at osafoundation.org
commits at osafoundation.org
Thu Aug 19 11:27:57 PDT 2004
Commit by: morgen
Modified files:
chandler/application/Application.py 1.260 1.261
chandler/application/tests/TestCollections.py 1.2 1.3
chandler/parcels/osaf/framework/blocks/Events/parcel.xml 1.46 1.47
chandler/parcels/osaf/views/main/Main.py 1.34 1.35
chandler/parcels/osaf/views/main/parcel.xml 1.89 1.90
Log message:
Hooking up File | Preferences | Accounts menu to new dialog
ViewCVS links:
http://cvs.osafoundation.org/index.cgi/chandler/application/Application.py.diff?r1=text&tr1=1.260&r2=text&tr2=1.261
http://cvs.osafoundation.org/index.cgi/chandler/application/tests/TestCollections.py.diff?r1=text&tr1=1.2&r2=text&tr2=1.3
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/framework/blocks/Events/parcel.xml.diff?r1=text&tr1=1.46&r2=text&tr2=1.47
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/views/main/Main.py.diff?r1=text&tr1=1.34&r2=text&tr2=1.35
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/views/main/parcel.xml.diff?r1=text&tr1=1.89&r2=text&tr2=1.90
Index: chandler/application/tests/TestCollections.py
diff -u chandler/application/tests/TestCollections.py:1.2 chandler/application/tests/TestCollections.py:1.3
--- chandler/application/tests/TestCollections.py:1.2 Mon Aug 16 16:49:46 2004
+++ chandler/application/tests/TestCollections.py Thu Aug 19 11:27:54 2004
@@ -1,8 +1,8 @@
"""
Collection tests for Parcel Loader
"""
-__revision__ = "$Revision: 1.2 $"
-__date__ = "$Date: 2004/08/16 23:49:46 $"
+__revision__ = "$Revision: 1.3 $"
+__date__ = "$Date: 2004/08/19 18:27:54 $"
__copyright__ = "Copyright (c) 2003 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -34,5 +34,6 @@
self.assertEqual(child1, parent.getValue('foo', alias='one'))
self.assertEqual(child2, parent.getValue('foo', alias='two'))
+
if __name__ == "__main__":
unittest.main()
Index: chandler/parcels/osaf/views/main/parcel.xml
diff -u chandler/parcels/osaf/views/main/parcel.xml:1.89 chandler/parcels/osaf/views/main/parcel.xml:1.90
--- chandler/parcels/osaf/views/main/parcel.xml:1.89 Sat Aug 14 16:58:06 2004
+++ chandler/parcels/osaf/views/main/parcel.xml Thu Aug 19 11:27:55 2004
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.89 $ -->
-<!-- $Date: 2004/08/14 23:58:06 $ -->
+<!-- $Revision: 1.90 $ -->
+<!-- $Date: 2004/08/19 18:27:55 $ -->
<!-- Copyright (c) 2003 Open Source Applications Foundation -->
<!-- License: http://osafoundation.org/Chandler_0.1_license_terms.htm -->
@@ -321,7 +321,6 @@
<childrenBlocks itemref="doc:ImportContactItem"/>
<childrenBlocks itemref="doc:SharingSubscribeToCollectionItem"/>
<childrenBlocks itemref="doc:ShareCollectionItem"/>
- <childrenBlocks itemref="doc:EditMailAccountItem"/>
<childrenBlocks itemref="doc:GetNewMailItem"/>
<childrenBlocks itemref="doc:CheckRepositoryItem"/>
<childrenBlocks itemref="doc:ShowPyCrustItem"/>
@@ -554,7 +553,7 @@
<blockName>PrefsAccountsItem</blockName>
<title>Accounts...</title>
<helpString>Account Preferences</helpString>
- <event itemref="events:NULL"/>
+ <event itemref="events:EditAccountPreferences"/>
</MenuItem>
<MenuItem itsName="QuitItem">
@@ -846,13 +845,6 @@
<helpString>Subscribe to a published item collection</helpString>
</MenuItem>
- <MenuItem itsName="EditMailAccountItem">
- <blockName>EditMailAccountItem</blockName>
- <title>Edit Mail Account...</title>
- <event itemref="events:EditMailAccount"/>
- <helpString>Edit email account settings</helpString>
- </MenuItem>
-
<MenuItem itsName="GetNewMailItem">
<blockName>GetNewMailItem</blockName>
<title>Get Mail</title>
Index: chandler/parcels/osaf/framework/blocks/Events/parcel.xml
diff -u chandler/parcels/osaf/framework/blocks/Events/parcel.xml:1.46 chandler/parcels/osaf/framework/blocks/Events/parcel.xml:1.47
--- chandler/parcels/osaf/framework/blocks/Events/parcel.xml:1.46 Wed Aug 11 06:33:14 2004
+++ chandler/parcels/osaf/framework/blocks/Events/parcel.xml Thu Aug 19 11:27:55 2004
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.46 $ -->
-<!-- $Date: 2004/08/11 13:33:14 $ -->
+<!-- $Revision: 1.47 $ -->
+<!-- $Date: 2004/08/19 18:27:55 $ -->
<!-- Copyright (c) 2003 Open Source Applications Foundation -->
<!-- License: http://osafoundation.org/Chandler_0.1_license_terms.htm -->
@@ -30,7 +30,7 @@
<subscribeAlwaysEvents itemref="events:Paste"/>
<subscribeAlwaysEvents itemref="events:Preferences"/>
<subscribeAlwaysEvents itemref="events:SharingSubscribeToCollection"/>
- <subscribeAlwaysEvents itemref="events:EditMailAccount"/>
+ <subscribeAlwaysEvents itemref="events:EditAccountPreferences"/>
<subscribeAlwaysEvents itemref="events:GetNewMail"/>
<subscribeAlwaysEvents itemref="events:SelectionChanged"/>
<subscribeAlwaysEvents itemref="events:SelectionChangedSentToSidebar"/>
@@ -104,7 +104,7 @@
<dispatchEnum>ActiveViewBubbleUp</dispatchEnum>
</BlockEvent>
- <BlockEvent itsName="EditMailAccount">
+ <BlockEvent itsName="EditAccountPreferences">
<dispatchEnum>ActiveViewBubbleUp</dispatchEnum>
</BlockEvent>
Index: chandler/application/Application.py
diff -u chandler/application/Application.py:1.260 chandler/application/Application.py:1.261
--- chandler/application/Application.py:1.260 Thu Aug 19 11:06:23 2004
+++ chandler/application/Application.py Thu Aug 19 11:27:54 2004
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.260 $"
-__date__ = "$Date: 2004/08/19 18:06:23 $"
+__version__ = "$Revision: 1.261 $"
+__date__ = "$Date: 2004/08/19 18:27:54 $"
__copyright__ = "Copyright (c) 2003-2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -487,196 +487,3 @@
rootLabel="Chandler")
self.crustFrame.SetSize((700,700))
self.crustFrame.Show(True)
-
-
-# A helper method and class for allowing the user to modify an item's attributes
-
-def promptForItemValues(frame, title, item, attrList):
- """ Given an item and a list of attributes, display a modal dialog with
- a text field per attribute, with each field populated directly from
- the item's attribute values. If the user OK's the dialog, the new
- values are applied to the item's attributes.
-
- @param frame: A wx parent frame
- @type frame: wx frame
- @param title: The title string for the dialog
- @type title: String
- @param item: A chandler item
- @type item: Item
- @param attrList: A list of dictionaries, each one having the following
- keys::
-
- "attr": an attribute name
- "label": a label to display for the field
- "password": an optional key, set to True if you want this field to be displayed like a password (with asterisks)
-
- """
- win = ItemValuesDialog(frame, -1, title, item, attrList)
- win.CenterOnScreen()
- val = win.ShowModal()
-
- if val == wx.ID_OK:
- # Assign the new values
- win.AssignNewValues()
-
- win.Destroy()
- return val == wx.ID_OK
-
-class ItemValuesDialog(wx.Dialog):
- def __init__(self, parent, ID, title, item, attrList, 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)
-
- textControls = []
- for valueDict in attrList:
- box = wx.BoxSizer(wx.HORIZONTAL)
-
- label = wx.StaticText(self, -1, valueDict["label"])
- box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
-
- if valueDict.get("password", False):
- text = wx.TextCtrl(self, -1,
- item.getAttributeValue(valueDict["attr"]), size=(80,-1),
- style=wx.TE_PASSWORD)
- else:
- text = wx.TextCtrl(self, -1,
- item.getAttributeValue(valueDict["attr"]), 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)
- textControls.append(text)
-
- 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.chandlerTextControls = textControls
- self.chandlerItem = item
- self.chandlerAttrs = attrList
-
- def AssignNewValues(self):
- i = 0
- for (valueDict) in self.chandlerAttrs:
- 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/views/main/Main.py
diff -u chandler/parcels/osaf/views/main/Main.py:1.34 chandler/parcels/osaf/views/main/Main.py:1.35
--- chandler/parcels/osaf/views/main/Main.py:1.34 Tue Aug 17 14:46:50 2004
+++ chandler/parcels/osaf/views/main/Main.py Thu Aug 19 11:27:55 2004
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.34 $"
-__date__ = "$Date: 2004/08/17 21:46:50 $"
+__version__ = "$Revision: 1.35 $"
+__date__ = "$Date: 2004/08/19 18:27:55 $"
__copyright__ = "Copyright (c) 2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -8,7 +8,8 @@
from osaf.framework.notifications.Notification import Notification
import wx
import os
-import application.Application
+import application.dialogs.AccountPreferences
+import application.dialogs.Util
import osaf.contentmodel.mail.Mail as Mail
from application.SplashScreen import SplashScreen
from application.Parcel import Manager as ParcelManager
@@ -53,17 +54,22 @@
notification.data ['Enable'] = False
def onSharingSubscribeToCollectionEvent(self, notification):
- url = application.Application.promptUser( \
- Globals.wxApplication.mainFrame, "Subscribe to Collection...",
+ url = application.dialogs.Util.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 onEditAccountPreferencesEvent (self, notification):
+ # Triggered from "File | Prefs | Accounts..."
+ application.dialogs.AccountPreferences.ShowAccountPreferencesDialog(Globals.wxApplication.mainFrame)
def onEditMailAccountEvent (self, notification):
+ # @@@ Deprecated, replaced by onEditAccountPreferencesEvent, above
+
account = \
Globals.repository.findPath('//parcels/osaf/mail/IMAPAccountOne')
- if application.Application.promptForItemValues(
+ if application.dialogs.Util.promptForItemValues(
Globals.wxApplication.mainFrame,
"IMAP Account",
account,
More information about the Commits
mailing list