From fa4693f2e0624d9e34ea4bfce4c32f2307c188d0 Mon Sep 17 00:00:00 2001 From: Stefan Sauer Date: Mon, 8 Nov 2010 11:40:06 +0200 Subject: [PATCH] info: redo tag list formatting Loop over tags and serialize items. Skip some already shown info. --- mediainfo/src/mi-info.vala | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/mediainfo/src/mi-info.vala b/mediainfo/src/mi-info.vala index 4f9e301099..63aa40f13d 100644 --- a/mediainfo/src/mi-info.vala +++ b/mediainfo/src/mi-info.vala @@ -50,6 +50,7 @@ public class MediaInfo.Info : VBox private bool have_video = false; private HashMap resolutions; + private HashSet tag_black_list; public Info () { @@ -92,6 +93,12 @@ public class MediaInfo.Info : VBox resolutions["1280 x 720"] = "HD 720"; resolutions["1920 x 1080"] = "HD 1080"; + // tags to skip (already extraced to specific discoverer fields) + tag_black_list = new HashSet (); + tag_black_list.add ("bitrate"); + tag_black_list.add ("maximum-bitrate"); + tag_black_list.add ("container-format"); + // add widgets // FIXME: handle aspect ratio (AspectFrame.ratio) drawing_area = new DrawingArea (); @@ -527,10 +534,23 @@ public class MediaInfo.Info : VBox private string build_taglist_info (Structure s) { - // FIXME: properly loop over taglist items and serialize them - // this allows to properly newline them and to avoid the types in the result - string str = s.to_string (); - str = str[8:-1].compress().replace(",","\n"); + uint i; + string str, fn, vstr; + Gst.Value v; + + // TODO: remove some binary tags + + str = ""; + for (i = 0; i < s.n_fields(); i++) { + fn = s.nth_field_name (i); + if (tag_black_list.contains (fn)) + continue; + if (str.length > 0) + str += "\n"; + v = s.get_value (fn); + vstr = v.serialize ().compress (); + str += fn + " = " + vstr; + } return str; }