void playlist_song (int argc, char * * argv) { int pos = check_args_playlist_pos (argc, argv); char * title = get_entry_title (pos - 1); fauxdtool_report ("%s", title); g_free (title); }
void playlist_display (int argc, char * * argv) { int entries = get_playlist_length (); fauxdtool_report ("%d track%s.", entries, entries != 1 ? "s" : ""); int total = 0; for (int entry = 0; entry < entries; entry ++) { char * title = get_entry_title (entry); int length = get_entry_length (entry) / 1000; total += length; /* adjust width for multi byte characters */ int column = 60; for (const char * p = title; * p; p = g_utf8_next_char (p)) { int stride = g_utf8_next_char (p) - p; if (g_unichar_iswide (g_utf8_get_char (p)) || g_unichar_iswide_cjk (g_utf8_get_char (p))) column += (stride - 2); else column += (stride - 1); } char * fmt = g_strdup_printf ("%%4d | %%-%ds | %%d:%%.2d", column); fauxdtool_report (fmt, entry + 1, title, length / 60, length % 60); g_free (fmt); g_free (title); } fauxdtool_report ("Total length: %d:%.2d", total / 60, total % 60); }
void playqueue_display (int argc, char * * argv) { int qlength = get_queue_length (); audtool_report ("%d queued tracks.", qlength); int total = 0; for (int qpos = 0; qpos < qlength; qpos ++) { int pos = get_queue_entry (qpos); char * title = get_entry_title (pos); int length = get_entry_length (pos) / 1000; total += length; /* adjust width for multi byte characters */ int column = 60; for (const char * p = title; * p; p = g_utf8_next_char (p)) { int stride = g_utf8_next_char (p) - p; if (g_unichar_iswide (g_utf8_get_char (p)) || g_unichar_iswide_cjk (g_utf8_get_char (p))) column += (stride - 2); else column += (stride - 1); } char * fmt = g_strdup_printf ("%%4d | %%4d | %%-%ds | %%d:%%.2d", column); audtool_report (fmt, qpos + 1, pos + 1, title, length / 60, length % 60); g_free (fmt); } audtool_report ("Total length: %d:%.2d", total / 60, total % 60); }