[Commits] (jeffrey) - Added dialogs for iCalendar import and export

commits at osafoundation.org commits at osafoundation.org
Thu Feb 24 15:12:00 PST 2005


Commit by: jeffrey
Modified files:
chandler/parcels/osaf/views/main/Main.py 1.150 1.151

Log message:
- Added dialogs for iCalendar import and export

ViewCVS links:
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/views/main/Main.py.diff?r1=text&tr1=1.150&r2=text&tr2=1.151

Index: chandler/parcels/osaf/views/main/Main.py
diff -u chandler/parcels/osaf/views/main/Main.py:1.150 chandler/parcels/osaf/views/main/Main.py:1.151
--- chandler/parcels/osaf/views/main/Main.py:1.150	Mon Feb 21 08:44:26 2005
+++ chandler/parcels/osaf/views/main/Main.py	Thu Feb 24 15:11:59 2005
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.150 $"
-__date__ = "$Date: 2005/02/21 16:44:26 $"
+__version__ = "$Revision: 1.151 $"
+__date__ = "$Date: 2005/02/24 23:11:59 $"
 __copyright__ = "Copyright (c) 2004 Open Source Applications Foundation"
 __license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -333,10 +333,22 @@
             self.setStatusMessage(errorMessage)
 
     def onImportIcalendarEvent(self, event):
-        # triggered from "Test | Import iCalendar" Menu
-        self.setStatusMessage ("Importing from import.ics")
+        # triggered from "File | Import/Export" menu
+        wildcard = "iCalendar files|*.ics|All files (*.*)|*.*"
+        dlg = wx.FileDialog(wx.GetApp().mainFrame, "Choose a file to import",
+                              "", "import.ics", wildcard,
+                              wx.OPEN | wx.CHANGE_DIR | wx.HIDE_READONLY)
+        if dlg.ShowModal() == wx.ID_OK:
+            (dir, filename) = os.path.split(dlg.GetPath())
+            dlg.Destroy()
+        else:
+            dlg.Destroy()
+            self.setStatusMessage("Import aborted")
+            return
+            
+        self.setStatusMessage ("Importing from %s" % filename)
         try:
-            share = Sharing.OneTimeFileSystemShare('.', 'import.ics',
+            share = Sharing.OneTimeFileSystemShare(dir, filename,
                             ICalendar.ICalendarFormat, view=self.itsView)
             share.get()
             self.setStatusMessage ("Import completed")
@@ -346,11 +358,24 @@
             self.setStatusMessage("Import failed")
 
     def onExportIcalendarEvent(self, event):
-        # triggered from "Test | Export Events as iCalendar" Menu
+        # triggered from "File | Import/Export" Menu
+
+        wildcard = "iCalendar files|*.ics|All files (*.*)|*.*"
+        dlg = wx.FileDialog(wx.GetApp().mainFrame, "Choose filename to export to",
+                              "", "export.ics", wildcard,
+                              wx.SAVE | wx.CHANGE_DIR | wx.OVERWRITE_PROMPT)
+        if dlg.ShowModal() == wx.ID_OK:
+            (dir, filename) = os.path.split(dlg.GetPath())
+            dlg.Destroy()
+        else:
+            dlg.Destroy()
+            self.setStatusMessage("Export aborted")
+            return
+
         eventKind = Calendar.CalendarEvent.getKind(self.itsView)
-        self.setStatusMessage ("Exporting to export.ics")
+        self.setStatusMessage ("Exporting to %s" % filename)
         try:
-            share = Sharing.OneTimeFileSystemShare('.', 'export.ics',
+            share = Sharing.OneTimeFileSystemShare(dir, filename,
                             ICalendar.ICalendarFormat, view=self.itsView)
             collection = ItemCollection(view=self.itsView)
             events = KindQuery().run([eventKind])



More information about the Commits mailing list