[gnome-software/1612-revisit-error-display] gs-common: Add gs_utils_show_error_dialog_simple()



commit 010f6370896db023d1ba1de5ffd24cb924dcb348
Author: Milan Crha <mcrha redhat com>
Date:   Tue Aug 23 14:14:55 2022 +0200

    gs-common: Add gs_utils_show_error_dialog_simple()
    
    A simple version of the gs_utils_show_error_dialog(), not showing
    the title and not adding a prefix for the details.

 src/gs-common.c | 32 ++++++++++++++++++++++++++++++++
 src/gs-common.h |  4 ++++
 2 files changed, 36 insertions(+)
---
diff --git a/src/gs-common.c b/src/gs-common.c
index f9fbffd95..0c83d858d 100644
--- a/src/gs-common.c
+++ b/src/gs-common.c
@@ -567,6 +567,38 @@ gs_utils_show_error_dialog (GtkWindow *parent,
        gtk_widget_show (dialog);
 }
 
+/**
+ * gs_utils_show_error_dialog_simple:
+ * @parent: transient parent, or %NULL for none
+ * @msg: the message for the dialog
+ * @details: (nullable): the detailed error message, or %NULL for none
+ *
+ * Shows a message dialog for displaying error messages and possible
+ * detailed information.
+ *
+ * Since: 43
+ */
+void
+gs_utils_show_error_dialog_simple (GtkWindow *parent,
+                                  const gchar *msg,
+                                  const gchar *details)
+{
+       GtkWidget *dialog;
+
+       dialog = gtk_message_dialog_new (parent,
+                                        0,
+                                        GTK_MESSAGE_INFO,
+                                        GTK_BUTTONS_CLOSE,
+                                        "%s", msg);
+       if (details != NULL)
+               insert_details_widget (GTK_MESSAGE_DIALOG (dialog), details, FALSE);
+
+       g_signal_connect_swapped (dialog, "response",
+                                 G_CALLBACK (gtk_window_destroy),
+                                 dialog);
+       gtk_widget_show (dialog);
+}
+
 /**
  * gs_utils_ask_user_accepts:
  * @parent: (nullable): modal parent, or %NULL for none
diff --git a/src/gs-common.h b/src/gs-common.h
index f7292e933..6a9683421 100644
--- a/src/gs-common.h
+++ b/src/gs-common.h
@@ -40,6 +40,10 @@ void          gs_utils_show_error_dialog     (GtkWindow      *parent,
                                                 const gchar    *title,
                                                 const gchar    *msg,
                                                 const gchar    *details);
+void            gs_utils_show_error_dialog_simple
+                                               (GtkWindow *parent,
+                                                const gchar *msg,
+                                                const gchar *details);
 gboolean        gs_utils_ask_user_accepts      (GtkWindow      *parent,
                                                 const gchar    *title,
                                                 const gchar    *msg,


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