gnome-control-center/SOURCES/0002-info-Move-helper-for-getting-subscription-status-to-.patch
2021-10-08 11:26:00 +00:00

229 lines
7.1 KiB
Diff

From 2025db03559f4ca8872045618cac75cfb2fe10f1 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Sun, 24 Jan 2021 10:29:56 -0500
Subject: [PATCH 2/4] info: Move helper for getting subscription status to
header
In the future we're going to need to be able to get the subscription
status in two files, so move the function for getting that status
to a common header.
Ideally we'd be using code generation for the subscription proxy
instead, but that's a bigger refactor that will have to wait for
another day.
---
panels/info/cc-info-overview-panel.c | 32 ++------------------------
panels/info/cc-subscription-common.h | 34 ++++++++++++++++++++++++++++
2 files changed, 36 insertions(+), 30 deletions(-)
create mode 100644 panels/info/cc-subscription-common.h
diff --git a/panels/info/cc-info-overview-panel.c b/panels/info/cc-info-overview-panel.c
index 1467060f9..b2cbefb25 100644
--- a/panels/info/cc-info-overview-panel.c
+++ b/panels/info/cc-info-overview-panel.c
@@ -1,56 +1,57 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright (C) 2017 Mohammed Sadiq <sadiq@sadiqpk.org>
* Copyright (C) 2010 Red Hat, Inc
* Copyright (C) 2008 William Jon McCann <jmccann@redhat.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
*/
#include <config.h>
#include "shell/cc-hostname-entry.h"
#include "cc-info-resources.h"
+#include "cc-subscription-common.h"
#include "cc-subscription-details-dialog.h"
#include "cc-subscription-register-dialog.h"
#include "info-cleanup.h"
#include <glib.h>
#include <glib/gi18n.h>
#include <gio/gio.h>
#include <gio/gunixmounts.h>
#include <gio/gdesktopappinfo.h>
#include <glibtop/fsusage.h>
#include <glibtop/mountlist.h>
#include <glibtop/mem.h>
#include <glibtop/sysinfo.h>
#include <gdk/gdk.h>
#ifdef GDK_WINDOWING_WAYLAND
#include <gdk/gdkwayland.h>
#endif
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
#endif
#include "gsd-disk-space-helper.h"
#include "cc-info-overview-panel.h"
typedef struct {
@@ -773,102 +774,73 @@ info_overview_panel_setup_overview (CcInfoOverviewPanel *self)
res = load_gnome_version (&priv->gnome_version,
&priv->gnome_distributor,
&priv->gnome_date);
if (res)
{
g_autofree gchar *text = NULL;
text = g_strdup_printf (_("Version %s"), priv->gnome_version);
gtk_label_set_text (GTK_LABEL (priv->version_label), text);
}
glibtop_get_mem (&mem);
memory_text = g_format_size_full (mem.total, G_FORMAT_SIZE_IEC_UNITS);
gtk_label_set_text (GTK_LABEL (priv->memory_label), memory_text ? memory_text : "");
info = glibtop_get_sysinfo ();
cpu_text = get_cpu_info (info);
gtk_label_set_markup (GTK_LABEL (priv->processor_label), cpu_text ? cpu_text : "");
os_type_text = get_os_type ();
gtk_label_set_text (GTK_LABEL (priv->os_type_label), os_type_text ? os_type_text : "");
os_name_text = get_os_name ();
gtk_label_set_text (GTK_LABEL (priv->os_name_label), os_name_text ? os_name_text : "");
get_primary_disc_info (self);
gtk_label_set_markup (GTK_LABEL (priv->graphics_label), priv->graphics_data->hardware_string);
}
-typedef enum {
- GSD_SUBMAN_SUBSCRIPTION_STATUS_UNKNOWN,
- GSD_SUBMAN_SUBSCRIPTION_STATUS_VALID,
- GSD_SUBMAN_SUBSCRIPTION_STATUS_INVALID,
- GSD_SUBMAN_SUBSCRIPTION_STATUS_DISABLED,
- GSD_SUBMAN_SUBSCRIPTION_STATUS_PARTIALLY_VALID,
- GSD_SUBMAN_SUBSCRIPTION_STATUS_LAST
-} GsdSubmanSubscriptionStatus;
-
-static gboolean
-get_subscription_status (CcInfoOverviewPanel *self, GsdSubmanSubscriptionStatus *status)
-{
- CcInfoOverviewPanelPrivate *priv = cc_info_overview_panel_get_instance_private (self);
- g_autoptr(GVariant) status_variant = NULL;
- guint32 u;
-
- status_variant = g_dbus_proxy_get_cached_property (priv->subscription_proxy, "SubscriptionStatus");
- if (!status_variant)
- {
- g_debug ("Unable to get SubscriptionStatus property");
- return FALSE;
- }
-
- g_variant_get (status_variant, "u", &u);
- *status = u;
-
- return TRUE;
-}
-
static void
reload_subscription_status (CcInfoOverviewPanel *self)
{
CcInfoOverviewPanelPrivate *priv = cc_info_overview_panel_get_instance_private (self);
GsdSubmanSubscriptionStatus status;
if (priv->subscription_proxy == NULL)
{
gtk_widget_hide (priv->subscription_stack);
return;
}
- if (!get_subscription_status (self, &status))
+ if (!get_subscription_status (priv->subscription_proxy, &status))
{
gtk_widget_hide (priv->subscription_stack);
return;
}
switch (status)
{
case GSD_SUBMAN_SUBSCRIPTION_STATUS_UNKNOWN:
case GSD_SUBMAN_SUBSCRIPTION_STATUS_INVALID:
case GSD_SUBMAN_SUBSCRIPTION_STATUS_DISABLED:
case GSD_SUBMAN_SUBSCRIPTION_STATUS_PARTIALLY_VALID:
gtk_stack_set_visible_child_name (GTK_STACK (priv->subscription_stack), "not-registered");
gtk_widget_set_sensitive (priv->updates_button, FALSE);
break;
case GSD_SUBMAN_SUBSCRIPTION_STATUS_VALID:
gtk_stack_set_visible_child_name (GTK_STACK (priv->subscription_stack), "registered");
gtk_widget_set_sensitive (priv->updates_button, TRUE);
break;
default:
g_assert_not_reached ();
break;
}
}
static void
on_details_button_clicked (GtkWidget *widget,
CcInfoOverviewPanel *self)
{
diff --git a/panels/info/cc-subscription-common.h b/panels/info/cc-subscription-common.h
new file mode 100644
index 000000000..034d64181
--- /dev/null
+++ b/panels/info/cc-subscription-common.h
@@ -0,0 +1,34 @@
+#ifndef CC_SUBSCRIPTION_COMMON_H
+#define CC_SUBSCRIPTION_COMMON_H
+
+typedef enum {
+ GSD_SUBMAN_SUBSCRIPTION_STATUS_UNKNOWN,
+ GSD_SUBMAN_SUBSCRIPTION_STATUS_VALID,
+ GSD_SUBMAN_SUBSCRIPTION_STATUS_INVALID,
+ GSD_SUBMAN_SUBSCRIPTION_STATUS_DISABLED,
+ GSD_SUBMAN_SUBSCRIPTION_STATUS_PARTIALLY_VALID,
+ GSD_SUBMAN_SUBSCRIPTION_STATUS_NO_INSTALLED_PRODUCTS,
+ GSD_SUBMAN_SUBSCRIPTION_STATUS_LAST
+} GsdSubmanSubscriptionStatus;
+
+static inline gboolean
+get_subscription_status (GDBusProxy *subscription_proxy,
+ GsdSubmanSubscriptionStatus *status)
+{
+ g_autoptr(GVariant) status_variant = NULL;
+ guint32 u;
+
+ status_variant = g_dbus_proxy_get_cached_property (subscription_proxy, "SubscriptionStatus");
+ if (!status_variant)
+ {
+ g_debug ("Unable to get SubscriptionStatus property");
+ return FALSE;
+ }
+
+ g_variant_get (status_variant, "u", &u);
+ *status = u;
+
+ return TRUE;
+}
+
+#endif
--
2.28.0