[pitivi] ui.mainwindow, formatters.format: fill in missing high-level functions, adjust UI to match



commit f91534bb2ad1e98e189c174eb29f5190723bf03b
Author: Brandon Lewis <brandon_lewis berkeley edu>
Date:   Tue Apr 7 14:10:39 2009 -0700

    ui.mainwindow, formatters.format: fill in missing high-level functions, adjust UI to match
---
 pitivi/formatters/etree.py  |    4 ++++
 pitivi/formatters/format.py |   16 ++++++++++++----
 pitivi/ui/mainwindow.py     |   10 +++++-----
 3 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/pitivi/formatters/etree.py b/pitivi/formatters/etree.py
index eab7c58..162ad9b 100644
--- a/pitivi/formatters/etree.py
+++ b/pitivi/formatters/etree.py
@@ -417,3 +417,7 @@ class ElementTreeFormatter(Formatter):
                 raise NotImplementedError()
 
         return project
+
+    @classmethod
+    def canHandle(cls, uri):
+        return uri.endswith(".xptv")
diff --git a/pitivi/formatters/format.py b/pitivi/formatters/format.py
index ea4fab6..8dc43f2 100644
--- a/pitivi/formatters/format.py
+++ b/pitivi/formatters/format.py
@@ -87,17 +87,21 @@ def can_handle_location(uri):
     @return: Whether the location contains a valid L{Project}.
     @rtype: L{bool}
     """
-    return False
+
+    for klass, name, exts in list_formats():
+        if klass.canHandle(uri):
+            return True
 
 def list_formats():
     """
     Returns a sequence of available project file formats
 
-    @return: a sequence of 2-tuples (name, extensions) representing available
+    @return: a sequence of 3-tuples (class, name, extensions) representing available
     file formats, where name is a user-readable name, and extensions is a
     sequence of extensions for this format ('.' omitted).
     """
-    return []
+    from pitivi.formatters.etree import ElementTreeFormatter
+    return [(ElementTreeFormatter, "PiTiVi Native (XML)", ('xptv',))]
 
 def get_formatter_for_uri(uri):
     """
@@ -107,4 +111,8 @@ def get_formatter_for_uri(uri):
     @param uri: The location of the project file
     @return: an instance of a Formatter, or None
     """
-    raise NotImplementedError
+    from pitivi.formatters.etree import ElementTreeFormatter
+
+    for klass, name, exts in list_formats():
+        if klass.canHandle(uri):
+            return klass()
diff --git a/pitivi/ui/mainwindow.py b/pitivi/ui/mainwindow.py
index 48906f0..8cb2941 100644
--- a/pitivi/ui/mainwindow.py
+++ b/pitivi/ui/mainwindow.py
@@ -525,8 +525,8 @@ class PitiviMainWindow(gtk.Window, Loggable):
         formats = formatter.list_formats()
         for format in formats:
             filt = gtk.FileFilter()
-            filt.set_name(format[0])
-            for ext in format[1]:
+            filt.set_name(format[1])
+            for ext in format[2]:
                 filt.add_pattern("*%s" % ext)
             chooser.add_filter(filt)
         default = gtk.FileFilter()
@@ -798,14 +798,14 @@ class PitiviMainWindow(gtk.Window, Loggable):
             gtk.STOCK_SAVE, gtk.RESPONSE_OK))
 
         chooser.set_select_multiple(False)
-        chooser.set_current_name(_("Untitled.pptv"))
+        chooser.set_current_name(_("Untitled.xptv"))
         chooser.set_current_folder(self.settings.lastProjectFolder)
         chooser.props.do_overwrite_confirmation = True
         formats = formatter.list_formats()
         for format in formats:
             filt = gtk.FileFilter()
-            filt.set_name(format[0])
-            for ext in format[1]:
+            filt.set_name(format[1])
+            for ext in format[2]:
                 filt.add_pattern("*.%s" % ext)
             chooser.add_filter(filt)
         default = gtk.FileFilter()



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