changeset 781:12c47704b4b5 trunk

[svn] Add error reporting for many places, patch by external contributor Derek Pomery (nemo @ #audacious). Additional cleanups too.
author nenolod
date Thu, 02 Mar 2006 08:14:36 -0800
parents 18b54ee82c24
children 4c7ee8f64d9b
files audacious/equalizer.c audacious/main.c audacious/main.h audacious/mainwin.c audacious/mainwin.h audacious/pluginenum.c
diffstat 6 files changed, 48 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/audacious/equalizer.c	Thu Mar 02 08:00:29 2006 -0800
+++ b/audacious/equalizer.c	Thu Mar 02 08:14:36 2006 -0800
@@ -1251,10 +1251,14 @@
 load_winamp_file(const gchar * filename)
 {
     VFSFile *file;
+    gchar *tmp;
 
-    /* FIXME: show error dialog */
-    if (!(file = vfs_fopen(filename, "rb")))
+    if (!(file = vfs_fopen(filename, "rb"))) {
+        tmp = g_strconcat("Failed to load WinAmp file: ",filename,"\n",NULL);
+        report_error(tmp);
+        g_free(tmp);
         return;
+    }
 
     equalizerwin_read_winamp_eqf(file);
     vfs_fclose(file);
@@ -1264,10 +1268,14 @@
 import_winamp_file(const gchar * filename)
 {
     VFSFile *file;
+    gchar *tmp;
 
-    /* FIXME: show error dialog */
-    if (!(file = vfs_fopen(filename, "rb")))
+    if (!(file = vfs_fopen(filename, "rb"))) {
+        tmp = g_strconcat("Failed to import WinAmp file: ",filename,"\n",NULL);
+        report_error(tmp);
+        g_free(tmp);
         return;
+    }
 
     equalizer_presets = g_list_concat(equalizer_presets,
                                       import_winamp_eqf(file));
@@ -1305,10 +1313,14 @@
     gchar name[257];
     gint i;
     guchar bands[11];
+    gchar *tmp;
 
-    /* FIXME: show error dialog */
-    if (!(file = vfs_fopen(filename, "wb")))
+    if (!(file = vfs_fopen(filename, "wb"))) {
+        tmp = g_strconcat("Failed to save WinAmp file: ",filename,"\n",NULL);
+        report_error(tmp);
+        g_free(tmp);
         return;
+    }
 
     vfs_fwrite("Winamp EQ library file v1.1\x1a!--", 1, 31, file);
 
--- a/audacious/main.c	Thu Mar 02 08:00:29 2006 -0800
+++ b/audacious/main.c	Thu Mar 02 08:14:36 2006 -0800
@@ -98,6 +98,7 @@
 
 typedef struct _BmpCmdLineOpt BmpCmdLineOpt;
 
+BmpCmdLineOpt options;
 
 BmpConfig cfg;
 
@@ -901,10 +902,20 @@
     gtk_widget_destroy(dialog);
 }
 
+// use a format string?
+void report_error(const gchar *error_text)
+{
+    fprintf(stderr,error_text);
+	if (options.headless!=1) {
+        gtk_message_dialog_format_secondary_text(err,error_text);
+        gtk_dialog_run(GTK_DIALOG(err));
+        gtk_widget_hide(GTK_WIDGET(err));
+    }
+}
+
 gint
 main(gint argc, gchar ** argv)
 {
-    BmpCmdLineOpt options;
     gboolean gtk_init_check_ok;
 
     /* Setup l10n early so we can print localized error messages */
@@ -977,11 +988,13 @@
 
     if (options.headless != 1)
     {
+
         bmp_set_default_icon();
 
         gtk_accel_map_load(bmp_paths[BMP_PATH_ACCEL_FILE]);
 
         mainwin_create();
+
         playlistwin_create();
         equalizerwin_create();
 
--- a/audacious/main.h	Thu Mar 02 08:00:29 2006 -0800
+++ b/audacious/main.h	Thu Mar 02 08:14:36 2006 -0800
@@ -140,5 +140,6 @@
 
 void bmp_config_save(void);
 void bmp_config_load(void);
+void report_error(const gchar *error_text);
 
 #endif
--- a/audacious/mainwin.c	Thu Mar 02 08:00:29 2006 -0800
+++ b/audacious/mainwin.c	Thu Mar 02 08:14:36 2006 -0800
@@ -28,6 +28,7 @@
 #include <glib/gi18n.h>
 #include <glib/gprintf.h>
 #include <gtk/gtk.h>
+#include <gtk/gtkmessagedialog.h>
 #include <gdk/gdkx.h>
 #include <gdk/gdkkeysyms.h>
 
@@ -160,6 +161,7 @@
 
 
 GtkWidget *mainwin = NULL;
+GtkMessageDialog *err = NULL; /* an error dialog for miscellaneous error messages */
 
 static GdkBitmap *nullmask;
 static gint balance;
@@ -1275,9 +1277,7 @@
     gchar time_str[10];
 
     if (!bmp_playback_get_playing()) {
-        /* FIXME: pop an error dialog and/or disable menu option to
-           indicate JTT can't be launched when no track is being
-           played */
+        report_error("JIT can't be launched when no track is being played.\n");
         return;
     }
 
@@ -3145,6 +3145,15 @@
         widget_hide(WIDGET(mainwin_stime_sec));
     }
 
+    err = gtk_message_dialog_new(GTK_WINDOW(mainwin), GTK_DIALOG_DESTROY_WITH_PARENT|GTK_DIALOG_MODAL,
+                                 GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,"Error in Audacious.");
+
+
+    gtk_window_set_position(GTK_WINDOW(err), GTK_WIN_POS_CENTER);
+    gtk_label_set_line_wrap(GTK_LABEL(err->label), TRUE);
+    /* Dang well better set an error message or you'll see this */
+    gtk_message_dialog_format_secondary_text(err,"Boo! Bad stuff! Booga Booga!");
+
 }
 
 static void
--- a/audacious/mainwin.h	Thu Mar 02 08:00:29 2006 -0800
+++ b/audacious/mainwin.h	Thu Mar 02 08:14:36 2006 -0800
@@ -93,6 +93,7 @@
 };
 
 extern GtkWidget *mainwin;
+extern GtkMessageDialog *err;
 extern GdkGC *mainwin_gc;
 
 extern GtkAccelGroup *mainwin_accel;
--- a/audacious/pluginenum.c	Thu Mar 02 08:00:29 2006 -0800
+++ b/audacious/pluginenum.c	Thu Mar 02 08:14:36 2006 -0800
@@ -32,6 +32,7 @@
 
 #include "controlsocket.h"
 #include "main.h"
+#include "mainwin.h"
 #include "playback.h"
 #include "playlist.h"
 #include "util.h"
@@ -251,9 +252,7 @@
     gint dirsel = 0, i = 0;
 
     if (!g_module_supported()) {
-        /* FIXME: We should open an error dialog for this. BMP is
-           practically useless without plugins */
-        g_warning("Module loading not supported! Plugins will not be loaded.");
+        report_error("Module loading not supported! Plugins will not be loaded.\n");
         return;
     }