[totem/wip/hadess/mpris-artist-type] mpris: Fix artist not showing in gnome-shell




commit e16f4e1085f1db3dad86ddd77253950cd37e7e84
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Oct 17 14:41:04 2022 +0200

    mpris: Fix artist not showing in gnome-shell
    
    https://www.freedesktop.org/wiki/Specifications/mpris-spec/metadata/#xesam:artist
    defines xesam:artist as a string list, rather than a string.
    
    Fix this so the artist appears correctly when set.
    
    Closes: #542

 src/plugins/mpris/totem-mpris.c | 31 ++++++++++++++++++++++---------
 1 file changed, 22 insertions(+), 9 deletions(-)
---
diff --git a/src/plugins/mpris/totem-mpris.c b/src/plugins/mpris/totem-mpris.c
index e454590d8..df9396bb1 100644
--- a/src/plugins/mpris/totem-mpris.c
+++ b/src/plugins/mpris/totem-mpris.c
@@ -251,10 +251,13 @@ static const GDBusInterfaceVTable root_vtable =
 
 /* MPRIS player interface */
 
-const char *str_metadata[] = {
-       "xesam:title",
-       "xesam:artist",
-       "xesam:album",
+struct {
+       const char *property;
+       gboolean is_strv;
+} str_metadata[] = {
+       { "xesam:title", FALSE },
+       { "xesam:artist", TRUE },
+       { "xesam:album", FALSE }
 };
 
 static void
@@ -277,13 +280,23 @@ calculate_metadata (TotemMprisPlugin *pi,
        for (i = 0; i < G_N_ELEMENTS (str_metadata); i++) {
                const char *str;
 
-               str = g_hash_table_lookup (pi->metadata, str_metadata[i]);
+               str = g_hash_table_lookup (pi->metadata, str_metadata[i].property);
                if (!str)
                        continue;
-               g_variant_builder_add (builder,
-                                      "{sv}",
-                                      str_metadata[i],
-                                      g_variant_new_string (str));
+               if (!str_metadata[i].is_strv) {
+                       g_variant_builder_add (builder,
+                                              "{sv}",
+                                              str_metadata[i].property,
+                                              g_variant_new_string (str));
+               } else {
+                       const char *strv[] = { NULL };
+
+                       strv[0] = str;
+                       g_variant_builder_add (builder,
+                                              "{sv}",
+                                              str_metadata[i].property,
+                                              g_variant_new_strv (strv, 1));
+               }
        }
 }
 


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