[totem] backend: Turn helper function into a real helper
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [totem] backend: Turn helper function into a real helper
- Date: Tue, 10 Apr 2012 18:38:01 +0000 (UTC)
commit 72d9bf9fff81861f63224ad988f2c094555d351f
Author: Bastien Nocera <hadess hadess net>
Date: Tue Apr 10 18:33:16 2012 +0100
backend: Turn helper function into a real helper
Not a bunch of branches with different paths that weren't helping.
src/backend/bacon-video-widget-gst-0.10.c | 90 +++++++++++------------------
1 files changed, 34 insertions(+), 56 deletions(-)
---
diff --git a/src/backend/bacon-video-widget-gst-0.10.c b/src/backend/bacon-video-widget-gst-0.10.c
index 2949370..fb951a6 100644
--- a/src/backend/bacon-video-widget-gst-0.10.c
+++ b/src/backend/bacon-video-widget-gst-0.10.c
@@ -2890,74 +2890,52 @@ get_lang_list_for_type (BaconVideoWidget * bvw, const gchar * type_name)
{
GList *ret = NULL;
gint num = 1;
+ gint i, n;
+ const char *prop;
+ const char *signal;
+ const char *text;
if (g_str_equal (type_name, "AUDIO")) {
- gint i, n;
-
- g_object_get (G_OBJECT (bvw->priv->play), "n-audio", &n, NULL);
- if (n == 0)
- return NULL;
-
- for (i = 0; i < n; i++) {
- GstTagList *tags = NULL;
-
- g_signal_emit_by_name (G_OBJECT (bvw->priv->play), "get-audio-tags",
- i, &tags);
-
- if (tags) {
- gchar *lc = NULL, *cd = NULL;
-
- gst_tag_list_get_string (tags, GST_TAG_LANGUAGE_CODE, &lc);
- gst_tag_list_get_string (tags, GST_TAG_CODEC, &cd);
-
- if (lc) {
- ret = g_list_prepend (ret, lc);
- g_free (cd);
- } else if (cd) {
- ret = g_list_prepend (ret, cd);
- } else {
- ret = g_list_prepend (ret, g_strdup_printf (_("Audio Track #%d"), num++));
- }
- gst_tag_list_free (tags);
- } else {
- ret = g_list_prepend (ret, g_strdup_printf (_("Audio Track #%d"), num++));
- }
- }
+ prop = "n-audio";
+ signal = "get-audio-tags";
+ text = N_("Audio Track #%d");
} else if (g_str_equal (type_name, "TEXT")) {
- gint i, n = 0;
+ prop = "n-text";
+ signal = "get-text-tags";
+ text = N_("Subtitle #%d");
+ } else {
+ g_critical ("Invalid stream type '%s'", type_name);
+ return NULL;
+ }
- g_object_get (G_OBJECT (bvw->priv->play), "n-text", &n, NULL);
- if (n == 0)
- return NULL;
+ n = 0;
+ g_object_get (G_OBJECT (bvw->priv->play), prop, &n, NULL);
+ if (n == 0)
+ return NULL;
- for (i = 0; i < n; i++) {
- GstTagList *tags = NULL;
+ for (i = 0; i < n; i++) {
+ GstTagList *tags = NULL;
- g_signal_emit_by_name (G_OBJECT (bvw->priv->play), "get-text-tags",
- i, &tags);
+ g_signal_emit_by_name (G_OBJECT (bvw->priv->play), signal, i, &tags);
- if (tags) {
- gchar *lc = NULL, *cd = NULL;
+ if (tags) {
+ gchar *lc = NULL, *cd = NULL;
- gst_tag_list_get_string (tags, GST_TAG_LANGUAGE_CODE, &lc);
- gst_tag_list_get_string (tags, GST_TAG_CODEC, &cd);
+ gst_tag_list_get_string (tags, GST_TAG_LANGUAGE_CODE, &lc);
+ gst_tag_list_get_string (tags, GST_TAG_CODEC, &cd);
- if (lc) {
- ret = g_list_prepend (ret, lc);
- g_free (cd);
- } else if (cd) {
- ret = g_list_prepend (ret, cd);
- } else {
- ret = g_list_prepend (ret, g_strdup_printf (_("Subtitle #%d"), num++));
- }
- gst_tag_list_free (tags);
+ if (lc) {
+ ret = g_list_prepend (ret, lc);
+ g_free (cd);
+ } else if (cd) {
+ ret = g_list_prepend (ret, cd);
} else {
- ret = g_list_prepend (ret, g_strdup_printf (_("Subtitle #%d"), num++));
+ ret = g_list_prepend (ret, g_strdup_printf (_(text), num++));
}
+ gst_tag_list_free (tags);
+ } else {
+ ret = g_list_prepend (ret, g_strdup_printf (_(text), num++));
}
- } else {
- g_critical ("Invalid stream type '%s'", type_name);
- return NULL;
}
return g_list_reverse (ret);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]