From: Thomas V. S. <tho...@pd...> - 2004-03-02 11:42:08
|
CVS Root: /home/cvs/gstreamer Module: gst-editor Changes by: thomasvs Date: Tue Mar 02 2004 03:37:16 PST Log message: add error handling Modified files: . : ChangeLog libs/gst/editor : gsteditor.c Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-editor/ChangeLog.diff?r1=1.9&r2=1.10 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-editor/libs/gst/editor/gsteditor.c.diff?r1=1.39&r2=1.40 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /home/cvs/gstreamer/gst-editor/ChangeLog,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- a/ChangeLog 11 Feb 2004 19:30:46 -0000 1.9 +++ b/ChangeLog 2 Mar 2004 11:37:04 -0000 1.10 @@ -1,3 +1,11 @@ +2004-03-02 Thomas Vander Stichele <thomas at apestaart dot org> + + * libs/gst/editor/gsteditor.c: (gst_editor_error_quark), + (gst_editor_dialog_gerror), (gst_editor_dialog_error), + (gst_editor_pipeline_deep_notify), (gst_editor_pipeline_error), + (gst_editor_element_connect), (gst_editor_new), (gst_editor_load): + adding error handling 2004-02-11 David Schleef <ds...@sc...> * src/editor.c: (main): gst_parse_launch() returns a non-bin Index: gsteditor.c RCS file: /home/cvs/gstreamer/gst-editor/libs/gst/editor/gsteditor.c,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- a/gsteditor.c 2 Jan 2004 16:19:06 -0000 1.39 +++ b/gsteditor.c 2 Mar 2004 11:37:04 -0000 1.40 @@ -74,6 +74,21 @@ static gint _num_editor_windows = 0; +/* GST_EDITOR_ERROR quark - FIXME: maybe move this to a more generic part */ +#define GST_EDITOR_ERROR (gst_editor_error_quark ()) +GQuark +gst_editor_error_quark (void) +{ + static GQuark quark = 0; + if (quark == 0) + quark = g_quark_from_static_string ("gst-editor-error-quark"); + return quark; +} +/* error dialog response - FIXME: we can use positive values since the + GTK_RESPONSE ones are negative ? */ +#define GST_EDITOR_RESPONSE_DEBUG 1 GType gst_editor_get_type (void) @@ -237,6 +252,92 @@ gtk_main_quit (); } +/* + * helper functions + */ +/* show an error dialog with a gerror and debug string */ +static void +gst_editor_dialog_gerror (GtkWindow *window, GError *error, const gchar *debug) + GtkWidget *error_dialog; + gint response; + g_return_if_fail (error); + error_dialog = gtk_message_dialog_new (window, GTK_DIALOG_MODAL, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_NONE, error->message); + /* add a debug button if there is debug info */ + if (debug) + { + gtk_dialog_add_button (GTK_DIALOG (error_dialog), GTK_STOCK_DIALOG_INFO, + GST_EDITOR_RESPONSE_DEBUG); + } + /* make sure OK is on the right and default action to be HIG-compliant */ + gtk_dialog_add_button (GTK_DIALOG (error_dialog), GTK_STOCK_OK, + GTK_RESPONSE_OK); + gtk_dialog_set_default_response (GTK_DIALOG (error_dialog), + GTK_RESPONSE_OK); + response = gtk_dialog_run (GTK_DIALOG (error_dialog)); + if (response == GST_EDITOR_RESPONSE_DEBUG) + gtk_widget_destroy (error_dialog); + error_dialog = gtk_message_dialog_new (GTK_WINDOW (window), + GTK_DIALOG_MODAL, + GTK_MESSAGE_INFO, GTK_BUTTONS_OK, + "%s\n\nAdditional debug info: %s\n", error->message, + debug); + gtk_dialog_run (GTK_DIALOG (error_dialog)); + gtk_widget_destroy (error_dialog); +/* show an error dialog given just an error string (for internal use) */ +gst_editor_dialog_error (GtkWindow *window, const gchar *message) + GError *error; + error = g_error_new (GST_EDITOR_ERROR, 0, message); + gst_editor_dialog_gerror (window, error, NULL); + g_error_free (error); +/* GStreamer callbacks */ +gst_editor_pipeline_deep_notify (GstObject *object, GstObject *orig, + GParamSpec *pspec, gchar **excluded_props) +gst_editor_pipeline_error (GObject *object, GstObject *source, + GError *error, gchar *debug, GstEditor *editor) + gchar *name = gst_object_get_path_string (source); + GError *my_error; + my_error = g_error_copy (error); + g_free (my_error->message); + my_error->message = g_strdup_printf ("%s: %s", name, error->message); + gst_editor_dialog_gerror (GTK_WINDOW (editor->window), my_error, debug); + g_error_free (my_error); + g_free (name); +/* connect useful GStreamer signals to pipeline */ +gst_editor_element_connect (GstEditor *editor, GstElement *pipeline) + g_signal_connect (pipeline, "deep_notify", + G_CALLBACK (gst_editor_pipeline_deep_notify), editor); + g_signal_connect (pipeline, "error", + G_CALLBACK (gst_editor_pipeline_error), editor); /* we need more control here so... */ static void gst_editor_connect_func (const gchar *handler_name, @@ -268,8 +369,11 @@ GtkWidget *ret = g_object_new (gst_editor_get_type (), NULL); if (element) g_object_set (GST_EDITOR (ret)->canvas, "bin", element, NULL); + gst_editor_element_connect (GST_EDITOR (ret), element); return ret; @@ -418,6 +522,7 @@ message = g_strdup_printf ("Pipeline loaded from %s.", editor->filename); gnome_appbar_set_status (GNOME_APPBAR (GNOME_APP (editor->window)->statusbar), message); + gst_editor_element_connect (editor, pipeline); g_free (message); |