[gnome-font-viewer] font-view: factor out a method to display error dialog



commit bc422f33c0fa2833780c24f74853b941ea0bd47f
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Thu Jul 4 16:07:29 2019 -0700

    font-view: factor out a method to display error dialog
    
    We'll reuse this to display an error when installation fails.

 src/font-view.c | 31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)
---
diff --git a/src/font-view.c b/src/font-view.c
index b9bac8b..e58095b 100644
--- a/src/font-view.c
+++ b/src/font-view.c
@@ -557,6 +557,24 @@ font_model_config_changed_cb (FontViewModel *model,
         install_button_refresh_appearance (self, NULL);
 }
 
+static void
+font_view_show_error (FontViewApplication *self,
+                      const gchar *primary_text,
+                      const gchar *secondary_text)
+{
+    GtkWidget *dialog;
+
+    dialog = gtk_message_dialog_new (GTK_WINDOW (self->main_window),
+                                     GTK_DIALOG_MODAL,
+                                     GTK_MESSAGE_ERROR,
+                                     GTK_BUTTONS_CLOSE,
+                                     primary_text);
+    gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+                                              "%s", secondary_text);
+    g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
+    gtk_widget_show (dialog);
+}
+
 static void
 font_view_show_install_error (FontViewApplication *self,
                               GError *error)
@@ -717,18 +735,7 @@ 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);
+    font_view_show_error (self, _("This font could not be displayed."), message);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]