[rhythmbox] podcast: display language names rather than language codes (bug #559849)



commit 2c92cc5cf6244c636a6b673ac0d2622e5d9753cd
Author: Jonathan Matthew <jonathan d14n org>
Date:   Mon Apr 12 07:33:43 2010 +1000

    podcast: display language names rather than language codes (bug #559849)
    
    Uses GStreamer language tag functions added in 0.10.26.

 podcast/rb-feed-podcast-properties-dialog.c |   27 ++++++++++++++++++++++++++-
 shell/Makefile.am                           |    3 ++-
 2 files changed, 28 insertions(+), 2 deletions(-)
---
diff --git a/podcast/rb-feed-podcast-properties-dialog.c b/podcast/rb-feed-podcast-properties-dialog.c
index 9ec420b..ed269a8 100644
--- a/podcast/rb-feed-podcast-properties-dialog.c
+++ b/podcast/rb-feed-podcast-properties-dialog.c
@@ -34,6 +34,9 @@
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 #include <glib.h>
+/* GStreamer happens to have some language name functions */
+#include <gst/gst.h>
+#include <gst/tag/tag.h>
 
 #include "rb-feed-podcast-properties-dialog.h"
 #include "rb-file-helpers.h"
@@ -41,6 +44,7 @@
 #include "rb-dialog.h"
 #include "rb-cut-and-paste-code.h"
 #include "rhythmdb.h"
+#include "rb-debug.h"
 
 static void rb_feed_podcast_properties_dialog_class_init (RBFeedPodcastPropertiesDialogClass *klass);
 static void rb_feed_podcast_properties_dialog_init (RBFeedPodcastPropertiesDialog *dialog);
@@ -259,8 +263,29 @@ static void
 rb_feed_podcast_properties_dialog_update_language (RBFeedPodcastPropertiesDialog *dialog)
 {
 	const char *language;
-
+#if GST_CHECK_VERSION(0,10,26)
+	char *separator;
+	char *iso636lang;
+	const char *langname;
+#endif
 	language = rhythmdb_entry_get_string (dialog->priv->current_entry, RHYTHMDB_PROP_LANG);
+#if GST_CHECK_VERSION(0,10,26)
+	/* language tag is language[-subcode]; we only care about the language bit */
+	iso636lang = g_strdup (language);
+	separator = strchr (iso636lang, '-');
+	if (separator != NULL) {
+		*separator = '\0';
+	}
+
+	/* map the language code to a language name */
+	langname = gst_tag_get_language_name (iso636lang);
+	g_free (iso636lang);
+	if (langname != NULL) {
+		rb_debug ("mapped language code %s to %s", language, langname);
+		gtk_label_set_text (GTK_LABEL (dialog->priv->language), langname);
+		return;
+	}
+#endif
 	gtk_label_set_text (GTK_LABEL (dialog->priv->language), language);
 }
 
diff --git a/shell/Makefile.am b/shell/Makefile.am
index 8f200bd..86b501e 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -116,7 +116,8 @@ librhythmbox_core_la_LIBADD =				\
 	$(WEBKIT_LIBS)				\
 	$(RHYTHMBOX_LIBS)				\
 	-lgstpbutils-0.10				\
-	-lgstcontroller-0.10
+	-lgstcontroller-0.10				\
+	-lgsttag-0.10
 
 librhythmbox_core_la_LDFLAGS = 				\
 	-version-info $(RHYTHMBOX_CORE_CURRENT):$(RHYTHMBOX_CORE_REVISION):$(RHYTHMBOX_CORE_AGE)	\



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