aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2012-06-07 19:24:50 +0200
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2012-06-07 19:24:50 +0200
commitd3ffe1e4a1b7a26e88ee7979dee9f1e698fa8a53 (patch)
tree998b1457c4128299a5168944bced005bc4097f23
parent0ecc46297c9a69a68f0d57ce5ae9212e3b5ed726 (diff)
downloadgtk-vlc-player-d3ffe1e4a1b7a26e88ee7979dee9f1e698fa8a53.tar.gz
cleanup error handling when trying to open URL
-rw-r--r--src/experiment-player.h12
-rw-r--r--src/main.c26
2 files changed, 29 insertions, 9 deletions
diff --git a/src/experiment-player.h b/src/experiment-player.h
index 2aa3fb3..35b815f 100644
--- a/src/experiment-player.h
+++ b/src/experiment-player.h
@@ -30,9 +30,21 @@
#include <gtk/gtk.h>
+/** Main program error domain */
+#define EXPERIMENT_PLAYER_ERROR \
+ (experiment_player_error_quark())
+
+/** Main program error codes */
+typedef enum {
+ EXPERIMENT_PLAYER_ERROR_OPEN /**< Error opening file/URI */
+} ExperimentPlayerError;
+
/*
* main.c
*/
+/** @private */
+GQuark experiment_player_error_quark(void);
+
gboolean load_media_file(const gchar *file);
gboolean load_transcript_file(const gchar *file);
diff --git a/src/main.c b/src/main.c
index d18717d..1fa852e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -74,6 +74,13 @@ gchar *current_filename = NULL;
#define SPEAKER_WIZARD "Wizard"
#define SPEAKER_PROBAND "Proband"
+/** @private */
+GQuark
+experiment_player_error_quark(void)
+{
+ return g_quark_from_static_string("experiment-player-error-quark");
+}
+
/*
* GtkBuilder signal callbacks
* NOTE: for some strange reason the parameters are switched
@@ -172,22 +179,23 @@ void
help_menu_manual_item_activate_cb(GtkWidget *widget __attribute__((unused)),
gpointer data __attribute__((unused)))
{
- GError *err = NULL;
+ GError *error = NULL;
gboolean res;
#ifdef HAVE_WINDOWS_H
res = (int)ShellExecute(NULL, "open", HELP_URI,
- NULL, NULL, SW_SHOWNORMAL) <= 32;
- if (res)
- err = g_error_new(g_quark_from_static_string("Cannot open!"), 0,
- "Cannot open '%s'!", HELP_URI);
+ NULL, NULL, SW_SHOWNORMAL) > 32;
+ if (!res)
+ error = g_error_new(EXPERIMENT_PLAYER_ERROR,
+ EXPERIMENT_PLAYER_ERROR_OPEN,
+ "Cannot open \"%s\"!", HELP_URI);
#else
- res = !gtk_show_uri(NULL, HELP_URI, GDK_CURRENT_TIME, &err);
+ res = gtk_show_uri(NULL, HELP_URI, GDK_CURRENT_TIME, &error);
#endif
- if (res) {
- show_message_dialog_gerror(err);
- g_error_free(err);
+ if (!res) {
+ show_message_dialog_gerror(error);
+ g_error_free(error);
}
}