Line |
Branch |
Exec |
Source |
1 |
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- |
2 |
|
|
* |
3 |
|
|
* Copyright (C) 2018 Red Hat, Inc |
4 |
|
|
* |
5 |
|
|
* This program is free software; you can redistribute it and/or modify |
6 |
|
|
* it under the terms of the GNU General Public License as published by |
7 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
8 |
|
|
* (at your option) any later version. |
9 |
|
|
* |
10 |
|
|
* This program is distributed in the hope that it will be useful, |
11 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 |
|
|
* GNU General Public License for more details. |
14 |
|
|
* |
15 |
|
|
* You should have received a copy of the GNU General Public License |
16 |
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>. |
17 |
|
|
* |
18 |
|
|
* Author: Matthias Clasen <mclasen@redhat.com> |
19 |
|
|
*/ |
20 |
|
|
|
21 |
|
|
#include "cc-diagnostics-page.h" |
22 |
|
|
#include "cc-util.h" |
23 |
|
|
#include "shell/cc-application.h" |
24 |
|
|
|
25 |
|
|
#include <gio/gdesktopappinfo.h> |
26 |
|
|
#include <glib/gi18n.h> |
27 |
|
|
|
28 |
|
|
struct _CcDiagnosticsPage |
29 |
|
|
{ |
30 |
|
|
AdwNavigationPage parent_instance; |
31 |
|
|
|
32 |
|
|
AdwPreferencesGroup *diagnostics_group; |
33 |
|
|
AdwSwitchRow *abrt_row; |
34 |
|
|
|
35 |
|
|
GSettings *privacy_settings; |
36 |
|
|
}; |
37 |
|
|
|
38 |
|
✗ |
G_DEFINE_TYPE (CcDiagnosticsPage, cc_diagnostics_page, ADW_TYPE_NAVIGATION_PAGE) |
39 |
|
|
|
40 |
|
|
/* Static init function */ |
41 |
|
|
|
42 |
|
|
static void |
43 |
|
✗ |
abrt_appeared_cb (GDBusConnection *connection, |
44 |
|
|
const gchar *name, |
45 |
|
|
const gchar *name_owner, |
46 |
|
|
gpointer user_data) |
47 |
|
|
{ |
48 |
|
✗ |
CcDiagnosticsPage *self = CC_DIAGNOSTICS_PAGE (user_data); |
49 |
|
|
|
50 |
|
✗ |
g_debug ("ABRT appeared"); |
51 |
|
✗ |
gtk_widget_set_visible (GTK_WIDGET (self), TRUE); |
52 |
|
✗ |
} |
53 |
|
|
|
54 |
|
|
static void |
55 |
|
✗ |
abrt_vanished_cb (GDBusConnection *connection, |
56 |
|
|
const gchar *name, |
57 |
|
|
gpointer user_data) |
58 |
|
|
{ |
59 |
|
✗ |
CcDiagnosticsPage *self = CC_DIAGNOSTICS_PAGE (user_data); |
60 |
|
|
|
61 |
|
✗ |
g_debug ("ABRT vanished"); |
62 |
|
✗ |
gtk_widget_set_visible (GTK_WIDGET (self), FALSE); |
63 |
|
✗ |
} |
64 |
|
|
|
65 |
|
|
static void |
66 |
|
✗ |
cc_diagnostics_page_finalize (GObject *object) |
67 |
|
|
{ |
68 |
|
✗ |
CcDiagnosticsPage *self = CC_DIAGNOSTICS_PAGE (object); |
69 |
|
|
|
70 |
|
✗ |
g_clear_object (&self->privacy_settings); |
71 |
|
|
|
72 |
|
✗ |
G_OBJECT_CLASS (cc_diagnostics_page_parent_class)->finalize (object); |
73 |
|
✗ |
} |
74 |
|
|
|
75 |
|
|
static void |
76 |
|
✗ |
cc_diagnostics_page_class_init (CcDiagnosticsPageClass *klass) |
77 |
|
|
{ |
78 |
|
✗ |
GObjectClass *oclass = G_OBJECT_CLASS (klass); |
79 |
|
✗ |
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); |
80 |
|
|
|
81 |
|
✗ |
oclass->finalize = cc_diagnostics_page_finalize; |
82 |
|
|
|
83 |
|
✗ |
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/privacy/diagnostics/cc-diagnostics-page.ui"); |
84 |
|
|
|
85 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, CcDiagnosticsPage, diagnostics_group); |
86 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, CcDiagnosticsPage, abrt_row); |
87 |
|
✗ |
} |
88 |
|
|
|
89 |
|
|
static void |
90 |
|
✗ |
cc_diagnostics_page_init (CcDiagnosticsPage *self) |
91 |
|
|
{ |
92 |
|
✗ |
g_autofree gchar *os_name = NULL; |
93 |
|
✗ |
g_autofree gchar *url = NULL; |
94 |
|
✗ |
g_autofree gchar *msg = NULL; |
95 |
|
✗ |
g_autofree gchar *link = NULL; |
96 |
|
|
|
97 |
|
✗ |
gtk_widget_init_template (GTK_WIDGET (self)); |
98 |
|
|
|
99 |
|
✗ |
g_bus_watch_name (G_BUS_TYPE_SYSTEM, |
100 |
|
|
"org.freedesktop.problems.daemon", |
101 |
|
|
G_BUS_NAME_WATCHER_FLAGS_NONE, |
102 |
|
|
abrt_appeared_cb, |
103 |
|
|
abrt_vanished_cb, |
104 |
|
|
self, |
105 |
|
|
NULL); |
106 |
|
|
|
107 |
|
✗ |
gtk_widget_set_visible (GTK_WIDGET (self), FALSE); |
108 |
|
|
|
109 |
|
✗ |
self->privacy_settings = g_settings_new ("org.gnome.desktop.privacy"); |
110 |
|
|
|
111 |
|
✗ |
g_settings_bind (self->privacy_settings, "report-technical-problems", |
112 |
|
✗ |
self->abrt_row, "active", |
113 |
|
|
G_SETTINGS_BIND_DEFAULT); |
114 |
|
|
|
115 |
|
✗ |
os_name = g_get_os_info (G_OS_INFO_KEY_NAME); |
116 |
|
✗ |
if (!os_name) |
117 |
|
✗ |
os_name = g_strdup ("GNOME"); |
118 |
|
✗ |
url = g_get_os_info (G_OS_INFO_KEY_PRIVACY_POLICY_URL); |
119 |
|
|
|
120 |
|
✗ |
if (url) { |
121 |
|
|
/* translators: Text used in link to privacy policy */ |
122 |
|
✗ |
link = g_strdup_printf ("<a href=\"%s\">%s</a>", url, _("learn more")); |
123 |
|
|
|
124 |
|
|
/* translators: The first '%s' is the distributor's name, such as 'Fedora', the second '%s' is a link to the privacy policy */ |
125 |
|
✗ |
msg = g_strdup_printf (_("Sending reports of technical problems helps us improve %s. Reports " |
126 |
|
|
"are sent anonymously and are scrubbed of personal data — %s."), |
127 |
|
|
os_name, link); |
128 |
|
|
} else { |
129 |
|
|
/* translators: The '%s' is the distributor's name, such as 'Fedora' */ |
130 |
|
✗ |
msg = g_strdup_printf (_("Sending reports of technical problems helps us improve %s. Reports " |
131 |
|
|
"are sent anonymously and are scrubbed of personal data."), |
132 |
|
|
os_name); |
133 |
|
|
} |
134 |
|
✗ |
adw_preferences_group_set_description (self->diagnostics_group, msg); |
135 |
|
✗ |
} |
136 |
|
|
|