From 5cd279624ad264c97895a64c56946b5790b44390 Mon Sep 17 00:00:00 2001 From: raveit65 Date: Sun, 8 Jan 2017 20:20:43 +0100 Subject: Fontviewer: font-view, show an error dialog when unable to load a font taken from: https://git.gnome.org/browse/gnome-font-viewer/commit/?id=5a8f439 --- font-viewer/font-view.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'font-viewer') diff --git a/font-viewer/font-view.c b/font-viewer/font-view.c index 640f7443..379f4f95 100644 --- a/font-viewer/font-view.c +++ b/font-viewer/font-view.c @@ -386,6 +386,35 @@ back_button_clicked_cb (GtkButton *button, font_view_application_do_overview (self); } +static void +font_view_show_font_error (FontViewApplication *self, + const gchar *message) +{ + GtkWidget *dialog; + + dialog = gtk_message_dialog_new (GTK_WINDOW (self->main_window), + GTK_DIALOG_MODAL, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_CLOSE, + _("This font could not be displayed.")); + gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), + "%s", + message); + g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL); + gtk_widget_show (dialog); +} + +static void +font_widget_error_cb (SushiFontWidget *font_widget, + const gchar *message, + gpointer user_data) +{ + FontViewApplication *self = user_data; + + font_view_application_do_overview (self); + font_view_show_font_error (self, message); +} + static void font_widget_loaded_cb (SushiFontWidget *font_widget, gpointer user_data) @@ -481,6 +510,8 @@ font_view_application_do_open (FontViewApplication *self) g_signal_connect (self->font_widget, "loaded", G_CALLBACK (font_widget_loaded_cb), self); + g_signal_connect (self->font_widget, "error", + G_CALLBACK (font_widget_error_cb), self); } else { g_object_set (self->font_widget, "uri", uri, NULL); } -- cgit v1.2.1