Blame SOURCES/0003-info-Update-registration-state-in-panel-when-it-happ.patch

8230d6
From 8bd1e37f59f3b4ec617d6d0bccf7fd77a9d03ca5 Mon Sep 17 00:00:00 2001
8230d6
From: Ray Strode <rstrode@redhat.com>
8230d6
Date: Sun, 24 Jan 2021 13:03:03 -0500
8230d6
Subject: [PATCH 3/4] info: Update registration state in panel when it happens
8230d6
 on disk
8230d6
8230d6
The code was failing to listen for change notifications, so if the
8230d6
panel was open while the system got registered, it wouldn't update.
8230d6
8230d6
This commit fixes that.
8230d6
---
8230d6
 panels/info/cc-info-overview-panel.c          | 33 ++++++++++++++++---
8230d6
 panels/info/cc-subscription-details-dialog.c  | 17 ++++++++--
8230d6
 panels/info/cc-subscription-details-dialog.h  |  3 +-
8230d6
 panels/info/cc-subscription-register-dialog.c | 17 ++++++++--
8230d6
 panels/info/cc-subscription-register-dialog.h |  3 +-
8230d6
 5 files changed, 63 insertions(+), 10 deletions(-)
8230d6
8230d6
diff --git a/panels/info/cc-info-overview-panel.c b/panels/info/cc-info-overview-panel.c
8230d6
index b2cbefb25..65246758e 100644
8230d6
--- a/panels/info/cc-info-overview-panel.c
8230d6
+++ b/panels/info/cc-info-overview-panel.c
8230d6
@@ -60,60 +60,61 @@ typedef struct {
8230d6
 } GraphicsData;
8230d6
 
8230d6
 typedef struct
8230d6
 {
8230d6
   GtkWidget      *system_image;
8230d6
   GtkWidget      *version_label;
8230d6
   GtkWidget      *name_entry;
8230d6
   GtkWidget      *memory_label;
8230d6
   GtkWidget      *processor_label;
8230d6
   GtkWidget      *os_name_label;
8230d6
   GtkWidget      *os_type_label;
8230d6
   GtkWidget      *disk_label;
8230d6
   GtkWidget      *graphics_label;
8230d6
   GtkWidget      *virt_type_label;
8230d6
   GtkWidget      *subscription_stack;
8230d6
   GtkWidget      *details_button;
8230d6
   GtkWidget      *register_button;
8230d6
   GtkWidget      *updates_separator;
8230d6
   GtkWidget      *updates_button;
8230d6
 
8230d6
   /* Virtualisation labels */
8230d6
   GtkWidget      *label8;
8230d6
   GtkWidget      *grid1;
8230d6
   GtkWidget      *label18;
8230d6
 
8230d6
   char           *gnome_version;
8230d6
   char           *gnome_distributor;
8230d6
   char           *gnome_date;
8230d6
 
8230d6
   GCancellable   *cancellable;
8230d6
+  GCancellable   *subscription_cancellable;
8230d6
 
8230d6
   /* Free space */
8230d6
   GList          *primary_mounts;
8230d6
   guint64         total_bytes;
8230d6
 
8230d6
   GraphicsData   *graphics_data;
8230d6
 
8230d6
   GDBusProxy     *subscription_proxy;
8230d6
 } CcInfoOverviewPanelPrivate;
8230d6
 
8230d6
 struct _CcInfoOverviewPanel
8230d6
 {
8230d6
  CcPanel parent_instance;
8230d6
 
8230d6
   /*< private >*/
8230d6
  CcInfoOverviewPanelPrivate *priv;
8230d6
 };
8230d6
 
8230d6
 static void get_primary_disc_info_start (CcInfoOverviewPanel *self);
8230d6
 
8230d6
 typedef struct
8230d6
 {
8230d6
   char *major;
8230d6
   char *minor;
8230d6
   char *micro;
8230d6
   char *distributor;
8230d6
   char *date;
8230d6
   char **current;
8230d6
 } VersionData;
8230d6
 
8230d6
@@ -821,165 +822,188 @@ reload_subscription_status (CcInfoOverviewPanel *self)
8230d6
 
8230d6
   switch (status)
8230d6
     {
8230d6
     case GSD_SUBMAN_SUBSCRIPTION_STATUS_UNKNOWN:
8230d6
     case GSD_SUBMAN_SUBSCRIPTION_STATUS_INVALID:
8230d6
     case GSD_SUBMAN_SUBSCRIPTION_STATUS_DISABLED:
8230d6
     case GSD_SUBMAN_SUBSCRIPTION_STATUS_PARTIALLY_VALID:
8230d6
       gtk_stack_set_visible_child_name (GTK_STACK (priv->subscription_stack), "not-registered");
8230d6
       gtk_widget_set_sensitive (priv->updates_button, FALSE);
8230d6
       break;
8230d6
 
8230d6
     case GSD_SUBMAN_SUBSCRIPTION_STATUS_VALID:
8230d6
       gtk_stack_set_visible_child_name (GTK_STACK (priv->subscription_stack), "registered");
8230d6
       gtk_widget_set_sensitive (priv->updates_button, TRUE);
8230d6
       break;
8230d6
 
8230d6
     default:
8230d6
       g_assert_not_reached ();
8230d6
       break;
8230d6
     }
8230d6
 }
8230d6
 
8230d6
 static void
8230d6
 on_details_button_clicked (GtkWidget           *widget,
8230d6
                            CcInfoOverviewPanel *self)
8230d6
 {
8230d6
   CcInfoOverviewPanelPrivate *priv = cc_info_overview_panel_get_instance_private (self);
8230d6
   CcSubscriptionDetailsDialog *dialog;
8230d6
   GtkWindow *toplevel;
8230d6
 
8230d6
-  dialog = cc_subscription_details_dialog_new (priv->subscription_proxy);
8230d6
+  dialog = cc_subscription_details_dialog_new (priv->subscription_proxy,
8230d6
+                                               priv->subscription_cancellable);
8230d6
   toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self)));
8230d6
   gtk_window_set_transient_for (GTK_WINDOW (dialog), toplevel);
8230d6
 
8230d6
   gtk_dialog_run (GTK_DIALOG (dialog));
8230d6
   gtk_widget_destroy (GTK_WIDGET (dialog));
8230d6
-
8230d6
-  reload_subscription_status (self);
8230d6
 }
8230d6
 
8230d6
 static void
8230d6
 on_register_button_clicked (GtkWidget           *widget,
8230d6
                             CcInfoOverviewPanel *self)
8230d6
 {
8230d6
   CcInfoOverviewPanelPrivate *priv = cc_info_overview_panel_get_instance_private (self);
8230d6
   CcSubscriptionRegisterDialog *dialog;
8230d6
   GtkWindow *toplevel;
8230d6
 
8230d6
-  dialog = cc_subscription_register_dialog_new (priv->subscription_proxy);
8230d6
+  dialog = cc_subscription_register_dialog_new (priv->subscription_proxy,
8230d6
+                                                priv->subscription_cancellable);
8230d6
   toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self)));
8230d6
   gtk_window_set_transient_for (GTK_WINDOW (dialog), toplevel);
8230d6
 
8230d6
   gtk_dialog_run (GTK_DIALOG (dialog));
8230d6
   gtk_widget_destroy (GTK_WIDGET (dialog));
8230d6
+}
8230d6
+
8230d6
+static void
8230d6
+on_subscription_status_changed (GDBusProxy *proxy,
8230d6
+                                GVariant *changed_properties,
8230d6
+                                GStrv invalidated_properties,
8230d6
+                                CcInfoOverviewPanel *self)
8230d6
+{
8230d6
+  CcInfoOverviewPanelPrivate *priv = cc_info_overview_panel_get_instance_private (self);
8230d6
+
8230d6
+  g_cancellable_cancel (priv->subscription_cancellable);
8230d6
+  g_object_unref (priv->subscription_cancellable);
8230d6
+
8230d6
+  priv->subscription_cancellable = g_cancellable_new ();
8230d6
 
8230d6
   reload_subscription_status (self);
8230d6
 }
8230d6
 
8230d6
 static void
8230d6
 info_overview_panel_setup_subscriptions (CcInfoOverviewPanel *self)
8230d6
 {
8230d6
   CcInfoOverviewPanelPrivate *priv = cc_info_overview_panel_get_instance_private (self);
8230d6
   g_autoptr(GError) error = NULL;
8230d6
 
8230d6
   priv->subscription_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
8230d6
                                                             G_DBUS_PROXY_FLAGS_NONE,
8230d6
                                                             NULL,
8230d6
                                                             "org.gnome.SettingsDaemon.Subscription",
8230d6
                                                             "/org/gnome/SettingsDaemon/Subscription",
8230d6
                                                             "org.gnome.SettingsDaemon.Subscription",
8230d6
                                                             NULL, &error);
8230d6
   if (error != NULL)
8230d6
     {
8230d6
       g_debug ("Unable to create a proxy for org.gnome.SettingsDaemon.Subscription: %s",
8230d6
                error->message);
8230d6
       reload_subscription_status (self);
8230d6
       return;
8230d6
     }
8230d6
 
8230d6
+  g_signal_connect (priv->subscription_proxy, "g-properties-changed",
8230d6
+                    G_CALLBACK (on_subscription_status_changed), self);
8230d6
+
8230d6
   g_signal_connect (priv->details_button, "clicked", G_CALLBACK (on_details_button_clicked), self);
8230d6
   g_signal_connect (priv->register_button, "clicked", G_CALLBACK (on_register_button_clicked), self);
8230d6
 
8230d6
   reload_subscription_status (self);
8230d6
 }
8230d6
 
8230d6
 static gboolean
8230d6
 does_gnome_software_exist (void)
8230d6
 {
8230d6
   return g_file_test (BINDIR "/gnome-software", G_FILE_TEST_EXISTS);
8230d6
 }
8230d6
 
8230d6
 static gboolean
8230d6
 does_gpk_update_viewer_exist (void)
8230d6
 {
8230d6
   return g_file_test (BINDIR "/gpk-update-viewer", G_FILE_TEST_EXISTS);
8230d6
 }
8230d6
 
8230d6
 static void
8230d6
 on_updates_button_clicked (GtkWidget           *widget,
8230d6
                            CcInfoOverviewPanel *self)
8230d6
 {
8230d6
   g_autoptr(GError) error = NULL;
8230d6
   gboolean ret;
8230d6
   g_auto(GStrv) argv = NULL;
8230d6
 
8230d6
   argv = g_new0 (gchar *, 3);
8230d6
   if (does_gnome_software_exist ())
8230d6
     {
8230d6
       argv[0] = g_build_filename (BINDIR, "gnome-software", NULL);
8230d6
       argv[1] = g_strdup_printf ("--mode=updates");
8230d6
     }
8230d6
   else
8230d6
     {
8230d6
       argv[0] = g_build_filename (BINDIR, "gpk-update-viewer", NULL);
8230d6
     }
8230d6
   ret = g_spawn_async (NULL, argv, NULL, 0, NULL, NULL, NULL, &error);
8230d6
   if (!ret)
8230d6
       g_warning ("Failed to spawn %s: %s", argv[0], error->message);
8230d6
 }
8230d6
 
8230d6
 static void
8230d6
 cc_info_overview_panel_dispose (GObject *object)
8230d6
 {
8230d6
   CcInfoOverviewPanelPrivate *priv = cc_info_overview_panel_get_instance_private (CC_INFO_OVERVIEW_PANEL (object));
8230d6
 
8230d6
   g_clear_pointer (&priv->graphics_data, graphics_data_free);
8230d6
 
8230d6
   G_OBJECT_CLASS (cc_info_overview_panel_parent_class)->dispose (object);
8230d6
 }
8230d6
 
8230d6
 static void
8230d6
 cc_info_overview_panel_finalize (GObject *object)
8230d6
 {
8230d6
   CcInfoOverviewPanelPrivate *priv = cc_info_overview_panel_get_instance_private (CC_INFO_OVERVIEW_PANEL (object));
8230d6
 
8230d6
+  if (priv->subscription_cancellable)
8230d6
+    {
8230d6
+      g_cancellable_cancel (priv->subscription_cancellable);
8230d6
+      g_clear_object (&priv->subscription_cancellable);
8230d6
+    }
8230d6
+
8230d6
   if (priv->cancellable)
8230d6
     {
8230d6
       g_cancellable_cancel (priv->cancellable);
8230d6
       g_clear_object (&priv->cancellable);
8230d6
     }
8230d6
 
8230d6
   if (priv->primary_mounts)
8230d6
     g_list_free_full (priv->primary_mounts, (GDestroyNotify) g_unix_mount_free);
8230d6
 
8230d6
   g_free (priv->gnome_version);
8230d6
   g_free (priv->gnome_date);
8230d6
   g_free (priv->gnome_distributor);
8230d6
 
8230d6
   g_clear_object (&priv->subscription_proxy);
8230d6
 
8230d6
   G_OBJECT_CLASS (cc_info_overview_panel_parent_class)->finalize (object);
8230d6
 }
8230d6
 
8230d6
 static void
8230d6
 cc_info_overview_panel_class_init (CcInfoOverviewPanelClass *klass)
8230d6
 {
8230d6
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
8230d6
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
8230d6
 
8230d6
   object_class->finalize = cc_info_overview_panel_finalize;
8230d6
   object_class->dispose = cc_info_overview_panel_dispose;
8230d6
 
8230d6
   gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/info/info-overview.ui");
8230d6
 
8230d6
   gtk_widget_class_bind_template_child_private (widget_class, CcInfoOverviewPanel, system_image);
8230d6
@@ -987,55 +1011,56 @@ cc_info_overview_panel_class_init (CcInfoOverviewPanelClass *klass)
8230d6
   gtk_widget_class_bind_template_child_private (widget_class, CcInfoOverviewPanel, name_entry);
8230d6
   gtk_widget_class_bind_template_child_private (widget_class, CcInfoOverviewPanel, memory_label);
8230d6
   gtk_widget_class_bind_template_child_private (widget_class, CcInfoOverviewPanel, processor_label);
8230d6
   gtk_widget_class_bind_template_child_private (widget_class, CcInfoOverviewPanel, os_name_label);
8230d6
   gtk_widget_class_bind_template_child_private (widget_class, CcInfoOverviewPanel, os_type_label);
8230d6
   gtk_widget_class_bind_template_child_private (widget_class, CcInfoOverviewPanel, disk_label);
8230d6
   gtk_widget_class_bind_template_child_private (widget_class, CcInfoOverviewPanel, graphics_label);
8230d6
   gtk_widget_class_bind_template_child_private (widget_class, CcInfoOverviewPanel, virt_type_label);
8230d6
   gtk_widget_class_bind_template_child_private (widget_class, CcInfoOverviewPanel, subscription_stack);
8230d6
   gtk_widget_class_bind_template_child_private (widget_class, CcInfoOverviewPanel, details_button);
8230d6
   gtk_widget_class_bind_template_child_private (widget_class, CcInfoOverviewPanel, register_button);
8230d6
   gtk_widget_class_bind_template_child_private (widget_class, CcInfoOverviewPanel, updates_separator);
8230d6
   gtk_widget_class_bind_template_child_private (widget_class, CcInfoOverviewPanel, updates_button);
8230d6
   gtk_widget_class_bind_template_child_private (widget_class, CcInfoOverviewPanel, label8);
8230d6
   gtk_widget_class_bind_template_child_private (widget_class, CcInfoOverviewPanel, grid1);
8230d6
   gtk_widget_class_bind_template_child_private (widget_class, CcInfoOverviewPanel, label18);
8230d6
 
8230d6
   g_type_ensure (CC_TYPE_HOSTNAME_ENTRY);
8230d6
 }
8230d6
 
8230d6
 static void
8230d6
 cc_info_overview_panel_init (CcInfoOverviewPanel *self)
8230d6
 {
8230d6
   CcInfoOverviewPanelPrivate *priv = cc_info_overview_panel_get_instance_private (self);
8230d6
 
8230d6
   gtk_widget_init_template (GTK_WIDGET (self));
8230d6
 
8230d6
   g_resources_register (cc_info_get_resource ());
8230d6
 
8230d6
   priv->cancellable = g_cancellable_new ();
8230d6
+  priv->subscription_cancellable = g_cancellable_new ();
8230d6
 
8230d6
   priv->graphics_data = get_graphics_data ();
8230d6
 
8230d6
   if (does_gnome_software_exist () || does_gpk_update_viewer_exist ())
8230d6
     g_signal_connect (priv->updates_button, "clicked", G_CALLBACK (on_updates_button_clicked), self);
8230d6
   else
8230d6
     gtk_widget_hide (priv->updates_button);
8230d6
 
8230d6
   info_overview_panel_setup_overview (self);
8230d6
   info_overview_panel_setup_virt (self);
8230d6
   info_overview_panel_setup_subscriptions (self);
8230d6
 
8230d6
   /* show separator when both items are visible */
8230d6
   if (gtk_widget_get_visible (priv->subscription_stack) && gtk_widget_get_visible (priv->updates_button))
8230d6
     gtk_widget_show (priv->updates_separator);
8230d6
   else
8230d6
     gtk_widget_hide (priv->updates_separator);
8230d6
 }
8230d6
 
8230d6
 GtkWidget *
8230d6
 cc_info_overview_panel_new (void)
8230d6
 {
8230d6
   return g_object_new (CC_TYPE_INFO_OVERVIEW_PANEL,
8230d6
                        NULL);
8230d6
 }
8230d6
diff --git a/panels/info/cc-subscription-details-dialog.c b/panels/info/cc-subscription-details-dialog.c
8230d6
index 1931ced81..3d77e6c48 100644
8230d6
--- a/panels/info/cc-subscription-details-dialog.c
8230d6
+++ b/panels/info/cc-subscription-details-dialog.c
8230d6
@@ -311,97 +311,110 @@ header_unregister_button_clicked_cb (CcSubscriptionDetailsDialog *self)
8230d6
                      self);
8230d6
 }
8230d6
 
8230d6
 static void
8230d6
 back_button_clicked_cb (CcSubscriptionDetailsDialog *self)
8230d6
 {
8230d6
   gtk_spinner_stop (self->spinner);
8230d6
 
8230d6
   self->state = DIALOG_STATE_SHOW_DETAILS;
8230d6
   dialog_reload (self);
8230d6
 }
8230d6
 
8230d6
 static void
8230d6
 unregister_button_clicked_cb (CcSubscriptionDetailsDialog *self)
8230d6
 {
8230d6
   self->state = DIALOG_STATE_UNREGISTER;
8230d6
   dialog_reload (self);
8230d6
 }
8230d6
 
8230d6
 static void
8230d6
 dismiss_notification (CcSubscriptionDetailsDialog *self)
8230d6
 {
8230d6
   gtk_revealer_set_reveal_child (self->notification_revealer, FALSE);
8230d6
 }
8230d6
 
8230d6
 static void
8230d6
 cc_subscription_details_dialog_init (CcSubscriptionDetailsDialog *self)
8230d6
 {
8230d6
   gtk_widget_init_template (GTK_WIDGET (self));
8230d6
 
8230d6
-  self->cancellable = g_cancellable_new ();
8230d6
   self->products = g_ptr_array_new_with_free_func ((GDestroyNotify) product_data_free);
8230d6
   self->state = DIALOG_STATE_SHOW_DETAILS;
8230d6
 }
8230d6
 
8230d6
 static void
8230d6
 cc_subscription_details_dialog_dispose (GObject *obj)
8230d6
 {
8230d6
   CcSubscriptionDetailsDialog *self = (CcSubscriptionDetailsDialog *) obj;
8230d6
 
8230d6
   g_cancellable_cancel (self->cancellable);
8230d6
   g_clear_object (&self->cancellable);
8230d6
   g_clear_object (&self->subscription_proxy);
8230d6
 
8230d6
   G_OBJECT_CLASS (cc_subscription_details_dialog_parent_class)->dispose (obj);
8230d6
 }
8230d6
 
8230d6
 static void
8230d6
 cc_subscription_details_dialog_finalize (GObject *obj)
8230d6
 {
8230d6
   CcSubscriptionDetailsDialog *self = (CcSubscriptionDetailsDialog *) obj;
8230d6
 
8230d6
   g_clear_pointer (&self->products, g_ptr_array_unref);
8230d6
 
8230d6
   G_OBJECT_CLASS (cc_subscription_details_dialog_parent_class)->finalize (obj);
8230d6
 }
8230d6
 
8230d6
 static void
8230d6
 cc_subscription_details_dialog_class_init (CcSubscriptionDetailsDialogClass *klass)
8230d6
 {
8230d6
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
8230d6
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
8230d6
 
8230d6
   object_class->dispose = cc_subscription_details_dialog_dispose;
8230d6
   object_class->finalize = cc_subscription_details_dialog_finalize;
8230d6
 
8230d6
   gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/info/cc-subscription-details-dialog.ui");
8230d6
 
8230d6
   gtk_widget_class_bind_template_child (widget_class, CcSubscriptionDetailsDialog, back_button);
8230d6
   gtk_widget_class_bind_template_child (widget_class, CcSubscriptionDetailsDialog, spinner);
8230d6
   gtk_widget_class_bind_template_child (widget_class, CcSubscriptionDetailsDialog, header_unregister_button);
8230d6
   gtk_widget_class_bind_template_child (widget_class, CcSubscriptionDetailsDialog, notification_revealer);
8230d6
   gtk_widget_class_bind_template_child (widget_class, CcSubscriptionDetailsDialog, error_label);
8230d6
   gtk_widget_class_bind_template_child (widget_class, CcSubscriptionDetailsDialog, stack);
8230d6
   gtk_widget_class_bind_template_child (widget_class, CcSubscriptionDetailsDialog, products_box1);
8230d6
   gtk_widget_class_bind_template_child (widget_class, CcSubscriptionDetailsDialog, products_box2);
8230d6
   gtk_widget_class_bind_template_child (widget_class, CcSubscriptionDetailsDialog, unregister_button);
8230d6
 
8230d6
   gtk_widget_class_bind_template_callback (widget_class, back_button_clicked_cb);
8230d6
   gtk_widget_class_bind_template_callback (widget_class, header_unregister_button_clicked_cb);
8230d6
   gtk_widget_class_bind_template_callback (widget_class, unregister_button_clicked_cb);
8230d6
   gtk_widget_class_bind_template_callback (widget_class, dismiss_notification);
8230d6
 }
8230d6
 
8230d6
+static void
8230d6
+on_dialog_cancelled (CcSubscriptionDetailsDialog *self)
8230d6
+{
8230d6
+  gtk_dialog_response (GTK_DIALOG (self), GTK_RESPONSE_CLOSE);
8230d6
+}
8230d6
+
8230d6
 CcSubscriptionDetailsDialog *
8230d6
-cc_subscription_details_dialog_new (GDBusProxy *subscription_proxy)
8230d6
+cc_subscription_details_dialog_new (GDBusProxy *subscription_proxy,
8230d6
+                                    GCancellable *cancellable)
8230d6
 {
8230d6
   CcSubscriptionDetailsDialog *self;
8230d6
 
8230d6
   self = g_object_new (CC_TYPE_SUBSCRIPTION_DETAILS_DIALOG, "use-header-bar", TRUE, NULL);
8230d6
   self->subscription_proxy = g_object_ref (subscription_proxy);
8230d6
+  self->cancellable = g_object_ref (cancellable);
8230d6
+
8230d6
+  g_signal_connect_object (G_OBJECT (self->cancellable),
8230d6
+                           "cancelled",
8230d6
+                           G_CALLBACK (on_dialog_cancelled),
8230d6
+                           self,
8230d6
+                           G_CONNECT_SWAPPED);
8230d6
 
8230d6
   load_installed_products (self);
8230d6
   dialog_reload (self);
8230d6
 
8230d6
   return self;
8230d6
 }
8230d6
diff --git a/panels/info/cc-subscription-details-dialog.h b/panels/info/cc-subscription-details-dialog.h
8230d6
index a61a22838..f14dd157b 100644
8230d6
--- a/panels/info/cc-subscription-details-dialog.h
8230d6
+++ b/panels/info/cc-subscription-details-dialog.h
8230d6
@@ -1,32 +1,33 @@
8230d6
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
8230d6
  *
8230d6
  * Copyright 2019  Red Hat, Inc,
8230d6
  *
8230d6
  * This program is free software; you can redistribute it and/or modify
8230d6
  * it under the terms of the GNU General Public License as published by
8230d6
  * the Free Software Foundation; either version 2 of the License, or
8230d6
  * (at your option) any later version.
8230d6
  *
8230d6
  * This program is distributed in the hope that it will be useful,
8230d6
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
8230d6
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
8230d6
  * GNU General Public License for more details.
8230d6
  *
8230d6
  * You should have received a copy of the GNU General Public License
8230d6
  * along with this program; if not, see <http://www.gnu.org/licenses/>.
8230d6
  *
8230d6
  * Written by: Kalev Lember <klember@redhat.com>
8230d6
  */
8230d6
 
8230d6
 #pragma once
8230d6
 
8230d6
 #include <gtk/gtk.h>
8230d6
 
8230d6
 G_BEGIN_DECLS
8230d6
 
8230d6
 #define CC_TYPE_SUBSCRIPTION_DETAILS_DIALOG (cc_subscription_details_dialog_get_type ())
8230d6
 G_DECLARE_FINAL_TYPE (CcSubscriptionDetailsDialog, cc_subscription_details_dialog, CC, SUBSCRIPTION_DETAILS_DIALOG, GtkDialog)
8230d6
 
8230d6
-CcSubscriptionDetailsDialog *cc_subscription_details_dialog_new (GDBusProxy *subscription_proxy);
8230d6
+CcSubscriptionDetailsDialog *cc_subscription_details_dialog_new (GDBusProxy   *subscription_proxy,
8230d6
+                                                                 GCancellable *cancellable);
8230d6
 
8230d6
 G_END_DECLS
8230d6
diff --git a/panels/info/cc-subscription-register-dialog.c b/panels/info/cc-subscription-register-dialog.c
8230d6
index d7a17cc99..e8c2f581c 100644
8230d6
--- a/panels/info/cc-subscription-register-dialog.c
8230d6
+++ b/panels/info/cc-subscription-register-dialog.c
8230d6
@@ -299,61 +299,60 @@ subscription_register_with_username (CcSubscriptionRegisterDialog *self)
8230d6
                      self->cancellable,
8230d6
                      registration_done_cb,
8230d6
                      self);
8230d6
 }
8230d6
 
8230d6
 static void
8230d6
 register_button_clicked_cb (CcSubscriptionRegisterDialog *self)
8230d6
 {
8230d6
   if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->register_with_activation_keys_radio)))
8230d6
     subscription_register_with_activation_keys (self);
8230d6
   else
8230d6
     subscription_register_with_username (self);
8230d6
 
8230d6
   gtk_spinner_start (self->spinner);
8230d6
 
8230d6
   self->state = DIALOG_STATE_REGISTERING;
8230d6
   dialog_reload (self);
8230d6
 }
8230d6
 
8230d6
 static void
8230d6
 dismiss_notification (CcSubscriptionRegisterDialog *self)
8230d6
 {
8230d6
   gtk_revealer_set_reveal_child (self->notification_revealer, FALSE);
8230d6
 }
8230d6
 
8230d6
 static void
8230d6
 cc_subscription_register_dialog_init (CcSubscriptionRegisterDialog *self)
8230d6
 {
8230d6
   gtk_widget_init_template (GTK_WIDGET (self));
8230d6
 
8230d6
-  self->cancellable = g_cancellable_new ();
8230d6
   self->state = DIALOG_STATE_REGISTER;
8230d6
 
8230d6
   gtk_entry_set_text (self->url_entry, SERVER_URL);
8230d6
   gtk_widget_grab_focus (GTK_WIDGET (self->login_entry));
8230d6
   dialog_validate (self);
8230d6
   dialog_reload (self);
8230d6
 }
8230d6
 
8230d6
 static void
8230d6
 cc_subscription_register_dialog_dispose (GObject *obj)
8230d6
 {
8230d6
   CcSubscriptionRegisterDialog *self = (CcSubscriptionRegisterDialog *) obj;
8230d6
 
8230d6
   g_cancellable_cancel (self->cancellable);
8230d6
   g_clear_object (&self->cancellable);
8230d6
   g_clear_object (&self->subscription_proxy);
8230d6
 
8230d6
   G_OBJECT_CLASS (cc_subscription_register_dialog_parent_class)->dispose (obj);
8230d6
 }
8230d6
 
8230d6
 static void
8230d6
 cc_subscription_register_dialog_finalize (GObject *obj)
8230d6
 {
8230d6
   G_OBJECT_CLASS (cc_subscription_register_dialog_parent_class)->finalize (obj);
8230d6
 }
8230d6
 
8230d6
 static void
8230d6
 cc_subscription_register_dialog_class_init (CcSubscriptionRegisterDialogClass *klass)
8230d6
 {
8230d6
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
8230d6
@@ -364,40 +363,54 @@ cc_subscription_register_dialog_class_init (CcSubscriptionRegisterDialogClass *k
8230d6
 
8230d6
   gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/info/cc-subscription-register-dialog.ui");
8230d6
 
8230d6
   gtk_widget_class_bind_template_child (widget_class, CcSubscriptionRegisterDialog, spinner);
8230d6
   gtk_widget_class_bind_template_child (widget_class, CcSubscriptionRegisterDialog, register_button);
8230d6
   gtk_widget_class_bind_template_child (widget_class, CcSubscriptionRegisterDialog, notification_revealer);
8230d6
   gtk_widget_class_bind_template_child (widget_class, CcSubscriptionRegisterDialog, error_label);
8230d6
   gtk_widget_class_bind_template_child (widget_class, CcSubscriptionRegisterDialog, default_url_radio);
8230d6
   gtk_widget_class_bind_template_child (widget_class, CcSubscriptionRegisterDialog, custom_url_radio);
8230d6
   gtk_widget_class_bind_template_child (widget_class, CcSubscriptionRegisterDialog, register_radio);
8230d6
   gtk_widget_class_bind_template_child (widget_class, CcSubscriptionRegisterDialog, register_with_activation_keys_radio);
8230d6
   gtk_widget_class_bind_template_child (widget_class, CcSubscriptionRegisterDialog, stack);
8230d6
   gtk_widget_class_bind_template_child (widget_class, CcSubscriptionRegisterDialog, register_grid);
8230d6
   gtk_widget_class_bind_template_child (widget_class, CcSubscriptionRegisterDialog, register_with_activation_keys_grid);
8230d6
   gtk_widget_class_bind_template_child (widget_class, CcSubscriptionRegisterDialog, url_label);
8230d6
   gtk_widget_class_bind_template_child (widget_class, CcSubscriptionRegisterDialog, url_entry);
8230d6
   gtk_widget_class_bind_template_child (widget_class, CcSubscriptionRegisterDialog, login_entry);
8230d6
   gtk_widget_class_bind_template_child (widget_class, CcSubscriptionRegisterDialog, password_entry);
8230d6
   gtk_widget_class_bind_template_child (widget_class, CcSubscriptionRegisterDialog, activation_keys_entry);
8230d6
   gtk_widget_class_bind_template_child (widget_class, CcSubscriptionRegisterDialog, organization_label);
8230d6
   gtk_widget_class_bind_template_child (widget_class, CcSubscriptionRegisterDialog, organization_entry);
8230d6
   gtk_widget_class_bind_template_child (widget_class, CcSubscriptionRegisterDialog, organization_entry_with_activation_keys);
8230d6
 
8230d6
   gtk_widget_class_bind_template_callback (widget_class, dialog_validate);
8230d6
   gtk_widget_class_bind_template_callback (widget_class, register_button_clicked_cb);
8230d6
   gtk_widget_class_bind_template_callback (widget_class, dismiss_notification);
8230d6
   gtk_widget_class_bind_template_callback (widget_class, custom_url_radio_toggled_cb);
8230d6
   gtk_widget_class_bind_template_callback (widget_class, register_with_activation_keys_radio_toggled_cb);
8230d6
 }
8230d6
 
8230d6
+static void
8230d6
+on_dialog_cancelled (CcSubscriptionRegisterDialog *self)
8230d6
+{
8230d6
+  gtk_dialog_response (GTK_DIALOG (self), GTK_RESPONSE_CLOSE);
8230d6
+}
8230d6
+
8230d6
 CcSubscriptionRegisterDialog *
8230d6
-cc_subscription_register_dialog_new (GDBusProxy *subscription_proxy)
8230d6
+cc_subscription_register_dialog_new (GDBusProxy *subscription_proxy,
8230d6
+                                     GCancellable *cancellable)
8230d6
 {
8230d6
   CcSubscriptionRegisterDialog *self;
8230d6
 
8230d6
   self = g_object_new (CC_TYPE_SUBSCRIPTION_REGISTER_DIALOG, "use-header-bar", TRUE, NULL);
8230d6
   self->subscription_proxy = g_object_ref (subscription_proxy);
8230d6
+  self->cancellable = g_object_ref (cancellable);
8230d6
+
8230d6
+  g_signal_connect_object (G_OBJECT (self->cancellable),
8230d6
+                           "cancelled",
8230d6
+                           G_CALLBACK (on_dialog_cancelled),
8230d6
+                           self,
8230d6
+                           G_CONNECT_SWAPPED);
8230d6
 
8230d6
   return self;
8230d6
 }
8230d6
diff --git a/panels/info/cc-subscription-register-dialog.h b/panels/info/cc-subscription-register-dialog.h
8230d6
index c5918df9f..31c254084 100644
8230d6
--- a/panels/info/cc-subscription-register-dialog.h
8230d6
+++ b/panels/info/cc-subscription-register-dialog.h
8230d6
@@ -1,32 +1,33 @@
8230d6
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
8230d6
  *
8230d6
  * Copyright 2019  Red Hat, Inc,
8230d6
  *
8230d6
  * This program is free software; you can redistribute it and/or modify
8230d6
  * it under the terms of the GNU General Public License as published by
8230d6
  * the Free Software Foundation; either version 2 of the License, or
8230d6
  * (at your option) any later version.
8230d6
  *
8230d6
  * This program is distributed in the hope that it will be useful,
8230d6
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
8230d6
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
8230d6
  * GNU General Public License for more details.
8230d6
  *
8230d6
  * You should have received a copy of the GNU General Public License
8230d6
  * along with this program; if not, see <http://www.gnu.org/licenses/>.
8230d6
  *
8230d6
  * Written by: Kalev Lember <klember@redhat.com>
8230d6
  */
8230d6
 
8230d6
 #pragma once
8230d6
 
8230d6
 #include <gtk/gtk.h>
8230d6
 
8230d6
 G_BEGIN_DECLS
8230d6
 
8230d6
 #define CC_TYPE_SUBSCRIPTION_REGISTER_DIALOG (cc_subscription_register_dialog_get_type ())
8230d6
 G_DECLARE_FINAL_TYPE (CcSubscriptionRegisterDialog, cc_subscription_register_dialog, CC, SUBSCRIPTION_REGISTER_DIALOG, GtkDialog)
8230d6
 
8230d6
-CcSubscriptionRegisterDialog *cc_subscription_register_dialog_new (GDBusProxy *subscription_proxy);
8230d6
+CcSubscriptionRegisterDialog *cc_subscription_register_dialog_new (GDBusProxy *subscription_proxy,
8230d6
+                                                                   GCancellable *cancellable);
8230d6
 
8230d6
 G_END_DECLS
8230d6
-- 
8230d6
2.28.0
8230d6