[pitivi] mediafilespreviewer: Fix transformation of tags into string



commit 9b843c0b4880e762b7ed0fc3e5c66aeffd2bab73
Author: Nicolas Dufresne <nicolas dufresne collabora com>
Date:   Thu Sep 6 13:47:16 2012 -0400

    mediafilespreviewer: Fix transformation of tags into string
    
    In GST 1.0, gst_tag_list_get_string() does not convert the GValue
    to string, so we get assertions when the tag is not a string.

 pitivi/mediafilespreviewer.py |   23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)
---
diff --git a/pitivi/mediafilespreviewer.py b/pitivi/mediafilespreviewer.py
index 3508202..ea82b06 100644
--- a/pitivi/mediafilespreviewer.py
+++ b/pitivi/mediafilespreviewer.py
@@ -230,7 +230,7 @@ class PreviewWidget(Gtk.VBox, Loggable):
                 self.seeker.show()
                 self.b_zoom_in.show()
                 self.b_zoom_out.show()
-                self.description = _(u"<b>Resolution</b>: %dÃ%d") % \
+                self.description = _("<b>Resolution</b>: %dÃ%d") % \
                     ((video.get_par_num() / video.get_par_denom()) * video.get_width(), video.get_height()) +\
                      "\n" + _("<b>Duration</b>: %s") % pretty_duration + "\n"
         else:
@@ -402,13 +402,20 @@ class PreviewWidget(Gtk.VBox, Loggable):
         return Gst.BusSyncReply.PASS
 
     def _appendTag(self, taglist, tag, unused_udata):
-            if tag in acceptable_tags and Gst.tag_get_type(tag) in (GObject.TYPE_STRING,
-                                   GObject.TYPE_DOUBLE,
-                                   GObject.TYPE_FLOAT,
-                                   GObject.TYPE_INT,
-                                   GObject.TYPE_UINT):
-                name = Gst.tag_get_nick(tag)
-                value = unicode(taglist.get_string(tag)[1]).replace('<', ' ').replace('>', ' ')
+        if tag in acceptable_tags:
+            name = Gst.tag_get_nick(tag)
+            type = Gst.tag_get_type(tag)
+            type_getters = {GObject.TYPE_STRING: 'get_string',
+                            GObject.TYPE_DOUBLE: 'get_double',
+                            GObject.TYPE_FLOAT: 'get_float',
+                            GObject.TYPE_INT: 'get_int',
+                            GObject.TYPE_UINT: 'get_uint'}
+            if type in type_getters:
+                if type == GObject.TYPE_STRING:
+                    value = getattr(taglist, type_getters[type])(tag)[1]
+                    value = value.replace('<', ' ').replace('>', ' ')
+                else:
+                    value = str(getattr(taglist, type_getters[type])(tag)[1])
                 self.tags[name] = value
 
     def _tag_found_cb(self, abus, mess):



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