changeset 4615:3ce92d3cd0e1

Use audacious_remote_get_tuple_fields() to get available standard tuple field names in audtool.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 05 Jun 2008 02:04:05 +0300
parents 4ed03078bda9
children 87c1e4da4aad
files src/audtool/audtool.h src/audtool/handlers_playlist.c src/audtool/handlers_vitals.c src/audtool/report.c
diffstat 4 files changed, 36 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/audtool/audtool.h	Thu Jun 05 02:03:37 2008 +0300
+++ b/src/audtool/audtool.h	Thu Jun 05 02:04:05 2008 +0300
@@ -50,6 +50,7 @@
 extern void audtool_report(const gchar *str, ...);
 extern void audtool_whine(const gchar *str, ...);
 extern void audtool_whine_args(const gchar *name, const gchar *str, ...);
+extern void audtool_whine_tuple_fields(void);
 
 extern void get_handlers_list(gint, gchar **);
 extern void get_current_song(gint, gchar **);
--- a/src/audtool/handlers_playlist.c	Thu Jun 05 02:03:37 2008 +0300
+++ b/src/audtool/handlers_playlist.c	Thu Jun 05 02:04:05 2008 +0300
@@ -290,10 +290,7 @@
 	if (argc < 3)
 	{
 		audtool_whine_args(argv[0], "<fieldname> <position>");
-		audtool_whine("  - fieldname example choices include but are not limited to:\n");
-		audtool_whine("      artist, album, title, track-number, year, date,\n");
-		audtool_whine("      genre, comment, file-name, file-ext, file-path,\n");
-		audtool_whine("      length, formatter, custom, mtime\n");
+		audtool_whine_tuple_fields();
 		exit(1);
 	}
 
--- a/src/audtool/handlers_vitals.c	Thu Jun 05 02:03:37 2008 +0300
+++ b/src/audtool/handlers_vitals.c	Thu Jun 05 02:04:05 2008 +0300
@@ -166,10 +166,7 @@
 	if (argc < 2)
 	{
 		audtool_whine_args(argv[0], "<fieldname>");
-		audtool_whine("  - fieldname example choices include but are not limited to:\n");
-		audtool_whine("      artist, album, title, track-number, year, date,\n");
-		audtool_whine("      genre, comment, file-name, file-ext, file-path,\n");
-		audtool_whine("      length, formatter, custom, mtime\n");
+		audtool_whine_tuple_fields();
 		exit(1);
 	}
 
--- a/src/audtool/report.c	Thu Jun 05 02:03:37 2008 +0300
+++ b/src/audtool/report.c	Thu Jun 05 02:04:05 2008 +0300
@@ -76,3 +76,36 @@
 	g_printerr(" syntax: %s %s\n", name, buf);
 	g_free(buf);
 }
+
+void audtool_whine_tuple_fields(void)
+{
+    gint nfields, i;
+    gchar **fields = audacious_remote_get_tuple_fields(dbus_proxy),
+          **tmp = fields;
+    
+    audtool_whine("Field names include, but are not limited to:\n");
+    
+    for (nfields = 0; tmp && *tmp; nfields++, tmp++);
+    
+    tmp = fields;
+    i = 0;
+    g_printerr("         ");
+    while (tmp && *tmp) {
+        i += g_utf8_strlen(*tmp, -1);
+        if (i > 45) {
+            g_printerr("\n         ");
+            i = 0;
+        }
+        g_printerr("%s", *tmp);
+        if (--nfields > 0)
+            g_printerr(", ");
+        
+        g_free(*tmp);
+        tmp++;
+    }
+    
+    g_printerr("\n");
+    
+    g_free(fields);
+}
+