[gnome-software/603-gnome-software-reports-unknown-error-when-there-is-a-signing-issue: 17/17] Move the gtk+ widget out of the packagekit and use a new plugin signal for it




commit 15c983ae19d98d95f3343669df00a64c26b05d0b
Author: Milan Crha <mcrha redhat com>
Date:   Mon Jul 12 18:16:18 2021 +0200

    Move the gtk+ widget out of the packagekit and use a new plugin signal for it

 lib/gs-plugin-loader.c                  |  25 +++++
 lib/gs-plugin.c                         |  43 ++++++++
 lib/gs-plugin.h                         |  12 ++-
 plugins/packagekit/gs-packagekit-task.c | 169 ++++++--------------------------
 src/gs-common.c                         |  75 ++++++++++++--
 src/gs-common.h                         |   5 +
 src/gs-shell.c                          |  14 +++
 7 files changed, 192 insertions(+), 151 deletions(-)
---
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index 474aad154..11181a126 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -92,6 +92,7 @@ enum {
        SIGNAL_UPDATES_CHANGED,
        SIGNAL_RELOAD,
        SIGNAL_BASIC_AUTH_START,
+       SIGNAL_ASK_USER_ACCEPTS,
        SIGNAL_LAST
 };
 
@@ -2159,6 +2160,22 @@ gs_plugin_loader_basic_auth_start_cb (GsPlugin *plugin,
                       user_data);
 }
 
+static gboolean
+gs_plugin_loader_ask_user_accepts_cb (GsPlugin *plugin,
+                                     const gchar *title,
+                                     const gchar *msg,
+                                     const gchar *details,
+                                     const gchar *accept_label,
+                                     GsPluginLoader *plugin_loader)
+{
+       gboolean accepts = FALSE;
+       g_debug ("emitting ask-user-accepts title:'%s', msg:'%s' details:'%s'", title, msg, details);
+       g_signal_emit (plugin_loader,
+                      signals[SIGNAL_ASK_USER_ACCEPTS], 0,
+                      title, msg, details, accept_label, &accepts);
+       return accepts;
+}
+
 static gboolean
 gs_plugin_loader_job_actions_changed_delay_cb (gpointer user_data)
 {
@@ -2266,6 +2283,9 @@ gs_plugin_loader_open_plugin (GsPluginLoader *plugin_loader,
        g_signal_connect (plugin, "repository-changed",
                          G_CALLBACK (gs_plugin_loader_repository_changed_cb),
                          plugin_loader);
+       g_signal_connect (plugin, "ask-user-accepts",
+                         G_CALLBACK (gs_plugin_loader_ask_user_accepts_cb),
+                         plugin_loader);
        gs_plugin_set_soup_session (plugin, plugin_loader->soup_session);
        gs_plugin_set_language (plugin, plugin_loader->language);
        gs_plugin_set_scale (plugin, gs_plugin_loader_get_scale (plugin_loader));
@@ -2898,6 +2918,11 @@ gs_plugin_loader_class_init (GsPluginLoaderClass *klass)
                              G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
                              0, NULL, NULL, g_cclosure_marshal_generic,
                              G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_POINTER);
+       signals [SIGNAL_ASK_USER_ACCEPTS] =
+               g_signal_new ("ask-user-accepts",
+                             G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+                             0, NULL, NULL, g_cclosure_marshal_generic,
+                             G_TYPE_BOOLEAN, 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
 }
 
 static void
diff --git a/lib/gs-plugin.c b/lib/gs-plugin.c
index 3ef285b8f..2a7e704ef 100644
--- a/lib/gs-plugin.c
+++ b/lib/gs-plugin.c
@@ -90,6 +90,7 @@ enum {
        SIGNAL_ALLOW_UPDATES,
        SIGNAL_BASIC_AUTH_START,
        SIGNAL_REPOSITORY_CHANGED,
+       SIGNAL_ASK_USER_ACCEPTS,
        SIGNAL_LAST
 };
 
@@ -1987,6 +1988,13 @@ gs_plugin_class_init (GsPluginClass *klass)
                              G_STRUCT_OFFSET (GsPluginClass, repository_changed),
                              NULL, NULL, g_cclosure_marshal_generic,
                              G_TYPE_NONE, 1, GS_TYPE_APP);
+
+       signals [SIGNAL_ASK_USER_ACCEPTS] =
+               g_signal_new ("ask-user-accepts",
+                             G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+                             G_STRUCT_OFFSET (GsPluginClass, ask_user_accepts),
+                             NULL, NULL, g_cclosure_marshal_generic,
+                             G_TYPE_BOOLEAN, 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
 }
 
 static void
@@ -2119,3 +2127,38 @@ gs_plugin_update_cache_state_for_repository (GsPlugin *plugin,
                }
        }
 }
+
+/**
+ * gs_plugin_ask_user_accepts:
+ * @plugin: a #GsPlugin
+ * @title: the title for the question
+ * @msg: the message for the question
+ * @details: (nullable): the detailed error message, or %NULL for none
+ * @accept_label: (nullable): a label of the 'accept' button, or %NULL to use 'Accept'
+ *
+ * Asks the user whether he/she accepts what is described by @title and @msg,
+ * eventually with the @details.
+ *
+ * Note: This is a blocking call and can be called only from the main/GUI thread.
+ *
+ * Returns: whether the user accepted the question
+ *
+ * Since: 41
+ **/
+gboolean
+gs_plugin_ask_user_accepts (GsPlugin *plugin,
+                           const gchar *title,
+                           const gchar *msg,
+                           const gchar *details,
+                           const gchar *accept_label)
+{
+       gboolean accepts = FALSE;
+       g_signal_emit (plugin,
+                      signals[SIGNAL_ASK_USER_ACCEPTS], 0,
+                      title,
+                      msg,
+                      details,
+                      accept_label,
+                      &accepts);
+       return accepts;
+}
diff --git a/lib/gs-plugin.h b/lib/gs-plugin.h
index 91a65488a..b3f2b4f69 100644
--- a/lib/gs-plugin.h
+++ b/lib/gs-plugin.h
@@ -45,7 +45,12 @@ struct _GsPluginClass
                                                         gpointer        user_data);
        void                    (*repository_changed)   (GsPlugin       *plugin,
                                                         GsApp          *repository);
-       gpointer                 padding[24];
+       gboolean                (*ask_user_accepts)     (GsPlugin       *plugin,
+                                                        const gchar    *title,
+                                                        const gchar    *msg,
+                                                        const gchar    *details,
+                                                        const gchar    *accept_label);
+       gpointer                 padding[23];
 };
 
 typedef struct GsPluginData    GsPluginData;
@@ -136,5 +141,10 @@ void               gs_plugin_repository_changed            (GsPlugin       *plugin,
 void           gs_plugin_update_cache_state_for_repository
                                                        (GsPlugin *plugin,
                                                         GsApp *repository);
+gboolean       gs_plugin_ask_user_accepts              (GsPlugin       *plugin,
+                                                        const gchar    *title,
+                                                        const gchar    *msg,
+                                                        const gchar    *details,
+                                                        const gchar    *accept_label);
 
 G_END_DECLS
diff --git a/plugins/packagekit/gs-packagekit-task.c b/plugins/packagekit/gs-packagekit-task.c
index 45c2e5bcf..e003f6a70 100644
--- a/plugins/packagekit/gs-packagekit-task.c
+++ b/plugins/packagekit/gs-packagekit-task.c
@@ -19,137 +19,23 @@ typedef struct _GsPackageKitTaskPrivate {
 
 G_DEFINE_TYPE_WITH_PRIVATE (GsPackageKitTask, gs_packagekit_task, PK_TYPE_TASK)
 
-static void
-do_not_expand (GtkWidget *child,
-              gpointer data)
-{
-       gtk_container_child_set (GTK_CONTAINER (gtk_widget_get_parent (child)),
-                                child, "expand", FALSE, "fill", FALSE, NULL);
-}
-
 static gboolean
-unset_focus (GtkWidget *widget,
-            GdkEvent *event,
-            gpointer data)
-{
-       if (GTK_IS_WINDOW (widget))
-               gtk_window_set_focus (GTK_WINDOW (widget), NULL);
-       return FALSE;
-}
-
-static void
-insert_details_widget (GtkMessageDialog *dialog,
-                      const gchar *details)
-{
-       GtkWidget *message_area, *sw, *label;
-       GtkWidget *box, *tv;
-       GtkTextBuffer *buffer;
-       GList *children;
-       GtkStyleContext *style_context;
-       g_autoptr(GError) error = NULL;
-       g_autoptr(GtkCssProvider) css_provider = NULL;
-       PangoAttrList *attr_list;
-
-       g_assert (GTK_IS_MESSAGE_DIALOG (dialog));
-       g_assert (details != NULL);
-
-       gtk_window_set_resizable (GTK_WINDOW (dialog), TRUE);
-
-       message_area = gtk_message_dialog_get_message_area (dialog);
-       g_assert (GTK_IS_BOX (message_area));
-       /* make the hbox expand */
-       box = gtk_widget_get_parent (message_area);
-       gtk_container_child_set (GTK_CONTAINER (gtk_widget_get_parent (box)), box,
-                                "expand", TRUE, "fill", TRUE, NULL);
-       /* make the labels not expand */
-       gtk_container_foreach (GTK_CONTAINER (message_area), do_not_expand, NULL);
-
-       /* Find the secondary label and set its width_chars.   */
-       /* Otherwise the label will tend to expand vertically. */
-       children = gtk_container_get_children (GTK_CONTAINER (message_area));
-       if (children && children->next && GTK_IS_LABEL (children->next->data)) {
-               gtk_label_set_width_chars (GTK_LABEL (children->next->data), 40);
-       }
-
-       label = gtk_label_new (_("Details"));
-       gtk_widget_set_halign (label, GTK_ALIGN_START);
-       gtk_widget_set_visible (label, TRUE);
-       attr_list = pango_attr_list_new ();
-       pango_attr_list_insert (attr_list, pango_attr_weight_new (PANGO_WEIGHT_BOLD));
-       gtk_label_set_attributes (GTK_LABEL (label), attr_list);
-       pango_attr_list_unref (attr_list);
-       gtk_container_add (GTK_CONTAINER (message_area), label);
-
-       sw = gtk_scrolled_window_new (NULL, NULL);
-       gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
-                                            GTK_SHADOW_IN);
-       gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
-                                       GTK_POLICY_NEVER,
-                                       GTK_POLICY_AUTOMATIC);
-       gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (sw), 150);
-       gtk_widget_set_visible (sw, TRUE);
-
-       tv = gtk_text_view_new ();
-       buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tv));
-       gtk_text_view_set_editable (GTK_TEXT_VIEW (tv), FALSE);
-       gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (tv), GTK_WRAP_WORD);
-       gtk_style_context_add_class (gtk_widget_get_style_context (tv),
-                                    "gs-packagekit-question-details");
-       style_context = gtk_widget_get_style_context (tv);
-       css_provider = gtk_css_provider_new ();
-       gtk_css_provider_load_from_data (css_provider,
-               ".gs-packagekit-question-details {\n"
-               "       font-family: Monospace;\n"
-               "       font-size: smaller;\n"
-               "       padding: 16px;\n"
-               "}", -1, &error);
-       if (error)
-               g_warning ("GsPackageKitTask: Failed to parse CSS: %s", error->message);
-       gtk_style_context_add_provider (style_context, GTK_STYLE_PROVIDER (css_provider),
-                                       GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
-
-       gtk_text_buffer_set_text (buffer, details, -1);
-       gtk_widget_set_visible (tv, TRUE);
-
-       gtk_container_add (GTK_CONTAINER (sw), tv);
-       gtk_widget_set_vexpand (sw, TRUE);
-       gtk_container_add (GTK_CONTAINER (message_area), sw);
-       gtk_container_child_set (GTK_CONTAINER (message_area), sw, "pack-type", GTK_PACK_END, NULL);
-
-       g_signal_connect (dialog, "map-event", G_CALLBACK (unset_focus), NULL);
-}
-
-static gboolean
-gs_packagekit_task_user_accepted (const gchar *title,
+gs_packagekit_task_user_accepted (PkTask *task,
+                                 const gchar *title,
                                  const gchar *msg,
                                  const gchar *details,
-                                 const gchar *ok_label)
+                                 const gchar *accept_label)
 {
-       GtkWidget *dialog;
-       GtkWindow *parent = NULL;
-       GApplication *application = g_application_get_default ();
-       gint response;
-
-       if (application && GTK_IS_APPLICATION (application))
-               parent = gtk_application_get_active_window (GTK_APPLICATION (application));
-
-       dialog = gtk_message_dialog_new_with_markup (parent,
-                                                    GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
-                                                    GTK_MESSAGE_QUESTION,
-                                                    GTK_BUTTONS_NONE,
-                                                    "<big><b>%s</b></big>", title);
-       gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-                                                 "%s", msg);
-       if (details != NULL)
-               insert_details_widget (GTK_MESSAGE_DIALOG (dialog), details);
-       gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Cancel"), GTK_RESPONSE_CANCEL);
-       gtk_dialog_add_button (GTK_DIALOG (dialog), ok_label, GTK_RESPONSE_OK);
-
-       response = gtk_dialog_run (GTK_DIALOG (dialog));
-
-       gtk_widget_destroy (dialog);
-
-       return response == GTK_RESPONSE_OK;
+       GsPackageKitTask *gs_task = GS_PACKAGEKIT_TASK (task);
+       GsPackageKitTaskPrivate *priv = gs_packagekit_task_get_instance_private (gs_task);
+       g_autoptr(GsPlugin) plugin = NULL;
+       gboolean accepts = FALSE;
+
+       plugin = g_weak_ref_get (&priv->plugin_weakref);
+       if (plugin)
+               accepts = gs_plugin_ask_user_accepts (plugin, title, msg, details, accept_label);
+
+       return accepts;
 }
 
 typedef struct _QuestionData {
@@ -158,7 +44,7 @@ typedef struct _QuestionData {
        gchar *title;
        gchar *msg;
        gchar *details;
-       gchar *ok_label;
+       gchar *accept_label;
 } QuestionData;
 
 static QuestionData *
@@ -167,7 +53,7 @@ question_data_new (GsPackageKitTask *task,
                   const gchar *title,
                   const gchar *msg,
                   const gchar *details,
-                  const gchar *ok_label)
+                  const gchar *accept_label)
 {
        QuestionData *qd;
 
@@ -177,7 +63,7 @@ question_data_new (GsPackageKitTask *task,
        qd->title = g_strdup (title);
        qd->msg = g_strdup (msg);
        qd->details = g_strdup (details);
-       qd->ok_label = g_strdup (ok_label);
+       qd->accept_label = g_strdup (accept_label);
 
        return qd;
 }
@@ -192,7 +78,7 @@ question_data_free (gpointer ptr)
                g_free (qd->title);
                g_free (qd->msg);
                g_free (qd->details);
-               g_free (qd->ok_label);
+               g_free (qd->accept_label);
                g_slice_free (QuestionData, qd);
        }
 }
@@ -201,15 +87,14 @@ static gboolean
 gs_packagekit_task_question_idle_cb (gpointer user_data)
 {
        QuestionData *qd = user_data;
-       PkTask *task;
+       g_autoptr(PkTask) task = NULL;
 
        task = g_weak_ref_get (&qd->task_weakref);
        if (task) {
-               if (gs_packagekit_task_user_accepted (qd->title, qd->msg, qd->details, qd->ok_label))
+               if (gs_packagekit_task_user_accepted (task, qd->title, qd->msg, qd->details, 
qd->accept_label))
                        pk_task_user_accepted (task, qd->request);
                else
                        pk_task_user_declined (task, qd->request);
-               g_object_unref (task);
        }
 
        return G_SOURCE_REMOVE;
@@ -221,11 +106,11 @@ gs_packagekit_task_schedule_question (GsPackageKitTask *task,
                                      const gchar *title,
                                      const gchar *msg,
                                      const gchar *details,
-                                     const gchar *ok_label)
+                                     const gchar *accept_label)
 {
        QuestionData *qd;
 
-       qd = question_data_new (task, request, title, msg, details, ok_label);
+       qd = question_data_new (task, request, title, msg, details, accept_label);
        g_idle_add_full (G_PRIORITY_HIGH_IDLE, gs_packagekit_task_question_idle_cb, qd, question_data_free);
 }
 
@@ -240,19 +125,23 @@ gs_packagekit_task_untrusted_question (PkTask *task,
        const gchar *title;
        const gchar *msg;
        const gchar *details;
-       const gchar *ok_label;
+       const gchar *accept_label;
 
        switch (priv->action) {
        case GS_PLUGIN_ACTION_INSTALL:
                title = _("Install Unsigned Software?");
                msg = _("Software that is to be installed is not signed. It will not be possible to verify 
the origin of updates to this software, or whether updates have been tampered with.");
-               ok_label = _("_Install");
+               accept_label = _("_Install");
                break;
        case GS_PLUGIN_ACTION_DOWNLOAD:
+               title = _("Download Unsigned Software?");
+               msg = _("Unsigned updates are available. Without a signature, it is not possible to verify 
the origin of the update, or whether it has been tampered with.");
+               accept_label = _("_Download");
+               break;
        case GS_PLUGIN_ACTION_UPDATE:
                title = _("Update Unsigned Software?");
                msg = _("Unsigned updates are available. Without a signature, it is not possible to verify 
the origin of the update, or whether it has been tampered with. Software updates will be disabled until 
unsigned updates are either removed or updated.");
-               ok_label = _("_Update");
+               accept_label = _("_Update");
                break;
        default:
                pk_task_user_declined (task, request);
@@ -265,7 +154,7 @@ gs_packagekit_task_untrusted_question (PkTask *task,
        else
                details = NULL;
 
-       gs_packagekit_task_schedule_question (gs_task, request, title, msg, details, ok_label);
+       gs_packagekit_task_schedule_question (gs_task, request, title, msg, details, accept_label);
 }
 
 static void
diff --git a/src/gs-common.c b/src/gs-common.c
index 9c57a5573..c3ea1abdd 100644
--- a/src/gs-common.c
+++ b/src/gs-common.c
@@ -484,7 +484,9 @@ unset_focus (GtkWidget *widget, GdkEvent *event, gpointer data)
  * Inserts a widget displaying the detailed message into the message dialog.
  */
 static void
-insert_details_widget (GtkMessageDialog *dialog, const gchar *details)
+insert_details_widget (GtkMessageDialog *dialog,
+                      const gchar *details,
+                      gboolean add_prefix)
 {
        GtkWidget *message_area, *sw, *label;
        GtkWidget *box, *tv;
@@ -497,13 +499,15 @@ insert_details_widget (GtkMessageDialog *dialog, const gchar *details)
 
        gtk_window_set_resizable (GTK_WINDOW (dialog), TRUE);
 
-       msg = g_string_new ("");
-       g_string_append_printf (msg, "%s\n\n%s",
-                               /* TRANSLATORS: these are show_detailed_error messages from the
-                                * package manager no mortal is supposed to understand,
-                                * but google might know what they mean */
-                               _("Detailed errors from the package manager follow:"),
-                               details);
+       if (add_prefix) {
+               msg = g_string_new ("");
+               g_string_append_printf (msg, "%s\n\n%s",
+                                       /* TRANSLATORS: these are show_detailed_error messages from the
+                                        * package manager no mortal is supposed to understand,
+                                        * but google might know what they mean */
+                                       _("Detailed errors from the package manager follow:"),
+                                       details);
+       }
 
        message_area = gtk_message_dialog_get_message_area (dialog);
        g_assert (GTK_IS_BOX (message_area));
@@ -541,7 +545,7 @@ insert_details_widget (GtkMessageDialog *dialog, const gchar *details)
        gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (tv), GTK_WRAP_WORD);
        gtk_style_context_add_class (gtk_widget_get_style_context (tv),
                                     "update-failed-details");
-       gtk_text_buffer_set_text (buffer, msg->str, -1);
+       gtk_text_buffer_set_text (buffer, msg ? msg->str : details, -1);
        gtk_widget_set_visible (tv, TRUE);
 
        gtk_container_add (GTK_CONTAINER (sw), tv);
@@ -577,7 +581,7 @@ gs_utils_show_error_dialog (GtkWindow *parent,
        gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
                                                  "%s", msg);
        if (details != NULL)
-               insert_details_widget (GTK_MESSAGE_DIALOG (dialog), details);
+               insert_details_widget (GTK_MESSAGE_DIALOG (dialog), details, TRUE);
 
        g_signal_connect_swapped (dialog, "response",
                                  G_CALLBACK (gtk_widget_destroy),
@@ -585,6 +589,57 @@ gs_utils_show_error_dialog (GtkWindow *parent,
        gtk_widget_show (dialog);
 }
 
+/**
+ * gs_utils_ask_user_accepts:
+ * @parent: (nullable): modal parent, or %NULL for none
+ * @title: the title for the dialog
+ * @msg: the message for the dialog
+ * @details: (nullable): the detailed error message, or %NULL for none
+ * @accept_label: (nullable): a label of the 'accept' button, or %NULL to use 'Accept'
+ *
+ * Shows a modal question dialog for displaying an accept/cancel question to the user.
+ *
+ * Returns: whether the user accepted the question
+ *
+ * Since: 41
+ **/
+gboolean
+gs_utils_ask_user_accepts (GtkWindow *parent,
+                          const gchar *title,
+                          const gchar *msg,
+                          const gchar *details,
+                          const gchar *accept_label)
+{
+       GtkWidget *dialog;
+       gint response;
+
+       g_return_val_if_fail (title != NULL, FALSE);
+       g_return_val_if_fail (msg != NULL, FALSE);
+
+       if (accept_label == NULL || *accept_label == '\0') {
+               /* Translators: an accept label caption, in a Cancel/Accept dialog */
+               accept_label = _("_Accept");
+       }
+
+       dialog = gtk_message_dialog_new_with_markup (parent,
+                                                    GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                    GTK_MESSAGE_QUESTION,
+                                                    GTK_BUTTONS_NONE,
+                                                    "<big><b>%s</b></big>", title);
+       gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+                                                 "%s", msg);
+       if (details != NULL)
+               insert_details_widget (GTK_MESSAGE_DIALOG (dialog), details, FALSE);
+       gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Cancel"), GTK_RESPONSE_CANCEL);
+       gtk_dialog_add_button (GTK_DIALOG (dialog), accept_label, GTK_RESPONSE_OK);
+
+       response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+       gtk_widget_destroy (dialog);
+
+       return response == GTK_RESPONSE_OK;
+}
+
 /**
  * gs_utils_get_error_value:
  * @error: A GError
diff --git a/src/gs-common.h b/src/gs-common.h
index ef29c1b33..106630c65 100644
--- a/src/gs-common.h
+++ b/src/gs-common.h
@@ -42,6 +42,11 @@ void          gs_utils_show_error_dialog     (GtkWindow      *parent,
                                                 const gchar    *title,
                                                 const gchar    *msg,
                                                 const gchar    *details);
+gboolean        gs_utils_ask_user_accepts      (GtkWindow      *parent,
+                                                const gchar    *title,
+                                                const gchar    *msg,
+                                                const gchar    *details,
+                                                const gchar    *accept_label);
 gchar          *gs_utils_build_unique_id_kind  (AsComponentKind kind,
                                                 const gchar    *id);
 gboolean        gs_utils_list_has_component_fuzzy      (GsAppList      *list,
diff --git a/src/gs-shell.c b/src/gs-shell.c
index 93fc4b77f..00ad6227e 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -414,6 +414,17 @@ gs_shell_basic_auth_start_cb (GsPluginLoader *plugin_loader,
                                  G_CALLBACK (gtk_widget_destroy), dialog);
 }
 
+static gboolean
+gs_shell_ask_user_accepts_cb (GsPluginLoader *plugin_loader,
+                             const gchar *title,
+                             const gchar *msg,
+                             const gchar *details,
+                             const gchar *accept_label,
+                             GsShell *shell)
+{
+       return gs_utils_ask_user_accepts (GTK_WINDOW (shell), title, msg, details, accept_label);
+}
+
 static void
 free_back_entry (BackEntry *entry)
 {
@@ -2130,6 +2141,9 @@ gs_shell_setup (GsShell *shell, GsPluginLoader *plugin_loader, GCancellable *can
        g_signal_connect_object (shell->plugin_loader, "basic-auth-start",
                                 G_CALLBACK (gs_shell_basic_auth_start_cb),
                                 shell, 0);
+       g_signal_connect_object (shell->plugin_loader, "ask-user-accepts",
+                                G_CALLBACK (gs_shell_ask_user_accepts_cb),
+                                shell, 0);
 
        g_object_bind_property (shell->plugin_loader, "allow-updates",
                                shell->pages[GS_SHELL_MODE_UPDATES], "visible",


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