changeset 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 4829dd0c8975 22c940e0d2dc
files src/audacious/main.c src/audacious/main.h
diffstat 2 files changed, 13 insertions(+), 5 deletions(-) [+]
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
--- a/src/audacious/main.h	Thu Jun 28 01:42:49 2007 -0500
+++ b/src/audacious/main.h	Thu Jun 28 02:25:55 2007 -0500
@@ -168,7 +168,7 @@
 void bmp_config_load(void);
 void bmp_config_free(void);
 void make_directory(const gchar * path, mode_t mode);
-void report_error(const gchar *error_text);
+void report_error(const gchar *error_message, ...);
 
 extern GCond *cond_scan;
 extern GMutex *mutex_scan;