diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | src/totem-interface.c | 62 | ||||
-rw-r--r-- | src/totem-interface.h | 7 | ||||
-rw-r--r-- | src/totem.c | 9 |
4 files changed, 85 insertions, 2 deletions
@@ -1,3 +1,12 @@ +2007-08-19 Bastien Nocera <hadess@hadess.net> + + * src/totem-interface.c: (link_button_clicked_cb), + (totem_interface_error_with_link): + * src/totem-interface.h: + * src/totem.c: (totem_action_load_media): Patch from Philip Withnall + <pwithnall@svn.gnome.org> to enhance the "DVD plugin missing" error + messages, and link to the website for help (Closes: #439550) + 2007-08-19 Jens Granseuer <jensgr@gmx.net> * src/totem-interface.c: (totem_interface_boldify_label), diff --git a/src/totem-interface.c b/src/totem-interface.c index e24e3138b..4650df818 100644 --- a/src/totem-interface.c +++ b/src/totem-interface.c @@ -35,8 +35,10 @@ #include <glib/gi18n.h> #include <gtk/gtk.h> #include <gdk/gdkx.h> +#include <gconf/gconf-client.h> #include "totem-interface.h" +#include "totem-private.h" static GtkWidget * totem_interface_error_dialog (const char *title, const char *reason, @@ -96,6 +98,66 @@ totem_interface_error_blocking (const char *title, const char *reason, gtk_widget_destroy (error_dialog); } +static void +link_button_clicked_cb (GtkWidget *widget, Totem *totem) +{ + const char *uri; + char *command, *browser; + GError *error = NULL; + + uri = gtk_link_button_get_uri (GTK_LINK_BUTTON (widget)); + browser = gconf_client_get_string (totem->gc, "/desktop/gnome/url-handlers/http/command", NULL); + + if (browser == NULL || browser[0] == '\0') { + char *message; + + message = g_strdup_printf(_("Could not launch URL \"%s\": %s"), uri, _("Default browser not configured")); + totem_interface_error (_("Error launching URI"), message, GTK_WINDOW (totem->win)); + g_free (message); + } else { + char *message; + + command = g_strdup_printf (browser, uri); + if (g_spawn_command_line_async ((const char*) command, &error) == FALSE) { + message = g_strdup_printf(_("Could not launch URL \"%s\": %s"), uri, error->message); + totem_interface_error (_("Error launching URI"), message, GTK_WINDOW (totem->win)); + g_free (message); + g_error_free (error); + } + g_free (command); + } + + g_free (browser); +} + +void +totem_interface_error_with_link (const char *title, const char *reason, + const char *uri, const char *label, GtkWindow *parent, Totem *totem) +{ + GtkWidget *error_dialog, *link_button, *hbox; + + if (label == NULL) + label = uri; + + error_dialog = totem_interface_error_dialog (title, reason, parent); + link_button = gtk_link_button_new_with_label (uri, label); + g_signal_connect (G_OBJECT (link_button), "clicked", G_CALLBACK (link_button_clicked_cb), totem); + + hbox = gtk_hbox_new (TRUE, 0); + gtk_box_pack_start (GTK_BOX (hbox), link_button, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (error_dialog)->vbox), hbox, TRUE, FALSE, 0); + + gtk_dialog_set_default_response (GTK_DIALOG (error_dialog), GTK_RESPONSE_OK); + + g_signal_connect (G_OBJECT (error_dialog), "destroy", G_CALLBACK + (gtk_widget_destroy), error_dialog); + g_signal_connect (G_OBJECT (error_dialog), "response", G_CALLBACK + (gtk_widget_destroy), error_dialog); + gtk_window_set_modal (GTK_WINDOW (error_dialog), TRUE); + + gtk_widget_show_all (error_dialog); +} + GtkBuilder * totem_interface_load (const char *name, gboolean fatal, GtkWindow *parent, gpointer user_data) { diff --git a/src/totem-interface.h b/src/totem-interface.h index e4a4b7160..e97095d47 100644 --- a/src/totem-interface.h +++ b/src/totem-interface.h @@ -24,6 +24,7 @@ #define TOTEM_INTERFACE_H #include <gtk/gtk.h> +#include "totem.h" G_BEGIN_DECLS @@ -43,6 +44,12 @@ void totem_interface_error (const char *title, void totem_interface_error_blocking (const char *title, const char *reason, GtkWindow *parent); +void totem_interface_error_with_link (const char *title, + const char *reason, + const char *uri, + const char *label, + GtkWindow *parent, + Totem *totem); void totem_interface_set_transient_for (GtkWindow *window, GtkWindow *parent); char * totem_interface_get_license (void); diff --git a/src/totem.c b/src/totem.c index b833a855d..0b83bfbbb 100644 --- a/src/totem.c +++ b/src/totem.c @@ -469,8 +469,13 @@ totem_action_load_media (Totem *totem, TotemDiscMediaType type, const char *devi gboolean retval; if (bacon_video_widget_can_play (totem->bvw, type) == FALSE) { - msg = g_strdup_printf (_("Totem cannot play this type of media (%s) because you do not have the appropriate plugins to handle it."), _(totem_cd_get_human_readable_name (type))); - totem_action_error (msg, _("Please install the necessary plugins and restart Totem to be able to play this media."), totem); + if (type == MEDIA_TYPE_DVD || type == MEDIA_TYPE_VCD) + msg = g_strdup_printf(_("Totem cannot play this type of media (%s) because it does not have the appropriate plugins to be able to read from the disc."), _(totem_cd_get_human_readable_name (type))); + else + msg = g_strdup_printf (_("Totem cannot play this type of media (%s) because you do not have the appropriate plugins to handle it."), _(totem_cd_get_human_readable_name (type))); + totem_interface_error_with_link (msg, _("Please install the necessary plugins and restart Totem to be able to play this media."), + "http://www.gnome.org/projects/totem/#codecs", _("More information about media plugins"), + GTK_WINDOW (totem->win), totem); g_free (msg); return FALSE; } |