diff src/audacious/main.c @ 2908:6a474a7954a0 trunk

Allow for printf-style format strings to be passed to report_error() via g_strdup_vprintf().
author William Pitcock <nenolod@atheme.org>
date Thu, 28 Jun 2007 02:25:55 -0500
parents 21b27e97bfb9
children 22c940e0d2dc
line wrap: on
line diff
--- a/src/audacious/main.c	Thu Jun 28 01:42:49 2007 -0500
+++ b/src/audacious/main.c	Thu Jun 28 02:25:55 2007 -0500
@@ -1069,18 +1069,26 @@
     gtk_widget_destroy(dialog);
 }
 
-// use a format string?
-void report_error(const gchar *error_text)
+void report_error(const gchar *error_message, ...)
 {
-    fprintf(stderr, error_text);
+    gchar *buf;
+    va_list va;
+
+    va_start(va, error_message);
+    buf = g_strdup_vprintf(error_message, va);
+    va_end(va);
+
+    fprintf(stderr, buf);
 
     if (options.headless != 1)
     {
         gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(err),
-                                                 error_text);
+                                                 buf);
         gtk_dialog_run(GTK_DIALOG(err));
         gtk_widget_hide(err);
     }
+
+    g_free(buf);
 }
 
 static gboolean