summaryrefslogtreecommitdiffstats
path: root/panels/diagnostics
diff options
context:
space:
mode:
Diffstat (limited to 'panels/diagnostics')
-rw-r--r--panels/diagnostics/cc-diagnostics-panel.c149
-rw-r--r--panels/diagnostics/cc-diagnostics-panel.h32
-rw-r--r--panels/diagnostics/cc-diagnostics-panel.ui100
-rw-r--r--panels/diagnostics/diagnostics.gresource.xml6
-rw-r--r--panels/diagnostics/gnome-diagnostics-panel.desktop.in.in19
-rw-r--r--panels/diagnostics/meson.build40
6 files changed, 346 insertions, 0 deletions
diff --git a/panels/diagnostics/cc-diagnostics-panel.c b/panels/diagnostics/cc-diagnostics-panel.c
new file mode 100644
index 0000000..7f1b5e2
--- /dev/null
+++ b/panels/diagnostics/cc-diagnostics-panel.c
@@ -0,0 +1,149 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2018 Red Hat, Inc
+ *
+ * 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/>.
+ *
+ * Author: Matthias Clasen <mclasen@redhat.com>
+ */
+
+#include "list-box-helper.h"
+#include "cc-diagnostics-panel.h"
+#include "cc-diagnostics-resources.h"
+#include "cc-os-release.h"
+#include "cc-util.h"
+#include "shell/cc-application.h"
+
+#include <gio/gdesktopappinfo.h>
+#include <glib/gi18n.h>
+
+struct _CcDiagnosticsPanel
+{
+ CcPanel parent_instance;
+
+ GtkLabel *diagnostics_explanation_label;
+ GtkListBox *diagnostics_list_box;
+ GtkSwitch *abrt_switch;
+
+ GSettings *privacy_settings;
+};
+
+CC_PANEL_REGISTER (CcDiagnosticsPanel, cc_diagnostics_panel)
+
+/* Static init function */
+
+static void
+set_panel_visibility (CcPanelVisibility visibility)
+{
+ CcApplication *application;
+
+ application = CC_APPLICATION (g_application_get_default ());
+ cc_shell_model_set_panel_visibility (cc_application_get_model (application),
+ "diagnostics",
+ visibility);
+
+}
+
+static void
+abrt_appeared_cb (GDBusConnection *connection,
+ const gchar *name,
+ const gchar *name_owner,
+ gpointer user_data)
+{
+ g_debug ("ABRT appeared");
+ set_panel_visibility (CC_PANEL_VISIBLE);
+}
+
+static void
+abrt_vanished_cb (GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+ g_debug ("ABRT vanished");
+ set_panel_visibility (CC_PANEL_VISIBLE_IN_SEARCH);
+}
+
+void
+cc_diagnostics_panel_static_init_func (void)
+{
+ g_bus_watch_name (G_BUS_TYPE_SYSTEM,
+ "org.freedesktop.problems.daemon",
+ G_BUS_NAME_WATCHER_FLAGS_NONE,
+ abrt_appeared_cb,
+ abrt_vanished_cb,
+ NULL,
+ NULL);
+
+ set_panel_visibility (CC_PANEL_VISIBLE_IN_SEARCH);
+}
+
+static void
+cc_diagnostics_panel_finalize (GObject *object)
+{
+ CcDiagnosticsPanel *self = CC_DIAGNOSTICS_PANEL (object);
+
+ g_clear_object (&self->privacy_settings);
+
+ G_OBJECT_CLASS (cc_diagnostics_panel_parent_class)->finalize (object);
+}
+
+static void
+cc_diagnostics_panel_class_init (CcDiagnosticsPanelClass *klass)
+{
+ GObjectClass *oclass = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ oclass->finalize = cc_diagnostics_panel_finalize;
+
+ gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/diagnostics/cc-diagnostics-panel.ui");
+
+ gtk_widget_class_bind_template_child (widget_class, CcDiagnosticsPanel, diagnostics_explanation_label);
+ gtk_widget_class_bind_template_child (widget_class, CcDiagnosticsPanel, diagnostics_list_box);
+ gtk_widget_class_bind_template_child (widget_class, CcDiagnosticsPanel, abrt_switch);
+}
+
+static void
+cc_diagnostics_panel_init (CcDiagnosticsPanel *self)
+{
+ g_autofree gchar *os_name = NULL;
+ g_autofree gchar *url = NULL;
+ g_autofree gchar *msg = NULL;
+ g_autofree gchar *link = NULL;
+
+ g_resources_register (cc_diagnostics_get_resource ());
+
+ gtk_widget_init_template (GTK_WIDGET (self));
+
+ gtk_list_box_set_header_func (self->diagnostics_list_box,
+ cc_list_box_update_header_func,
+ NULL, NULL);
+
+ self->privacy_settings = g_settings_new ("org.gnome.desktop.privacy");
+
+ g_settings_bind (self->privacy_settings, "report-technical-problems",
+ self->abrt_switch, "active",
+ G_SETTINGS_BIND_DEFAULT);
+
+ os_name = cc_os_release_get_value ("NAME");
+ url = cc_os_release_get_value ("PRIVACY_POLICY_URL");
+ if (!url)
+ url = g_strdup ("http://www.gnome.org/privacy-policy");
+ /* translators: Text used in link to privacy policy */
+ link = g_strdup_printf ("<a href=\"%s\">%s</a>", url, _("Learn more"));
+ /* translators: The first '%s' is the distributor's name, such as 'Fedora', the second '%s' is a link to the privacy policy */
+ msg = g_strdup_printf (_("Sending reports of technical problems helps us improve %s. Reports "
+ "are sent anonymously and are scrubbed of personal data. %s"),
+ os_name, link);
+ gtk_label_set_markup (self->diagnostics_explanation_label, msg);
+}
diff --git a/panels/diagnostics/cc-diagnostics-panel.h b/panels/diagnostics/cc-diagnostics-panel.h
new file mode 100644
index 0000000..3875ec5
--- /dev/null
+++ b/panels/diagnostics/cc-diagnostics-panel.h
@@ -0,0 +1,32 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2018 Red Hat, Inc
+ *
+ * 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/>.
+ *
+ * Author: Matthias Clasen <mclasen@redhat.com>
+ */
+
+#pragma once
+
+#include <shell/cc-panel.h>
+
+G_BEGIN_DECLS
+
+#define CC_TYPE_DIAGNOSTICS_PANEL (cc_diagnostics_panel_get_type ())
+G_DECLARE_FINAL_TYPE (CcDiagnosticsPanel, cc_diagnostics_panel, CC, DIAGNOSTICS_PANEL, CcPanel)
+
+void cc_diagnostics_panel_static_init_func (void);
+
+G_END_DECLS
diff --git a/panels/diagnostics/cc-diagnostics-panel.ui b/panels/diagnostics/cc-diagnostics-panel.ui
new file mode 100644
index 0000000..4838a63
--- /dev/null
+++ b/panels/diagnostics/cc-diagnostics-panel.ui
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.18.1 -->
+<interface>
+ <requires lib="gtk+" version="3.14"/>
+ <template class="CcDiagnosticsPanel" parent="CcPanel">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkScrolledWindow">
+ <property name="visible">1</property>
+ <property name="hscrollbar-policy">never</property>
+ <child>
+ <object class="HdyClamp">
+ <property name="visible">True</property>
+ <property name="margin_top">32</property>
+ <property name="margin_bottom">32</property>
+ <property name="margin_start">12</property>
+ <property name="margin_end">12</property>
+
+ <child>
+ <object class="GtkBox">
+ <property name="visible">1</property>
+ <property name="orientation">vertical</property>
+ <property name="hexpand">1</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">1</property>
+ <property name="margin-bottom">12</property>
+ <property name="label" translatable="yes">Problem Reporting</property>
+ <property name="wrap">1</property>
+ <property name="max-width-chars">50</property>
+ <property name="xalign">0</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="diagnostics_explanation_label">
+ <property name="visible">1</property>
+ <property name="margin-bottom">12</property>
+ <property name="use-markup">1</property>
+ <property name="wrap">1</property>
+ <property name="max-width-chars">50</property>
+ <property name="xalign">0</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkListBox" id="diagnostics_list_box">
+ <property name="visible">1</property>
+ <property name="can-focus">1</property>
+ <property name="selection-mode">none</property>
+ <child>
+ <object class="GtkListBoxRow">
+ <property name="visible">1</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">1</property>
+ <property name="margin_start">12</property>
+ <property name="margin_end">12</property>
+ <property name="margin_top">12</property>
+ <property name="margin_bottom">12</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">1</property>
+ <property name="label" translatable="yes">_Automatic Problem Reporting</property>
+ <property name="use_underline">1</property>
+ <property name="mnemonic_widget">abrt_switch</property>
+ <property name="xalign">0</property>
+ <property name="valign">center</property>
+ </object>
+ <packing>
+ <property name="expand">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSwitch" id="abrt_switch">
+ <property name="visible">1</property>
+ <property name="halign">end</property>
+ <property name="valign">center</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <style>
+ <class name="view"/>
+ <class name="frame"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/panels/diagnostics/diagnostics.gresource.xml b/panels/diagnostics/diagnostics.gresource.xml
new file mode 100644
index 0000000..541d62c
--- /dev/null
+++ b/panels/diagnostics/diagnostics.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/gnome/control-center/diagnostics">
+ <file preprocess="xml-stripblanks">cc-diagnostics-panel.ui</file>
+ </gresource>
+</gresources>
diff --git a/panels/diagnostics/gnome-diagnostics-panel.desktop.in.in b/panels/diagnostics/gnome-diagnostics-panel.desktop.in.in
new file mode 100644
index 0000000..33d2a9d
--- /dev/null
+++ b/panels/diagnostics/gnome-diagnostics-panel.desktop.in.in
@@ -0,0 +1,19 @@
+[Desktop Entry]
+Name=Diagnostics
+Comment=Report your problems
+Exec=gnome-control-center diagnostics
+# FIXME
+# Translators: Do NOT translate or transliterate this text (this is an icon file name)!
+Icon=system-help
+Terminal=false
+Type=Application
+NoDisplay=true
+StartupNotify=true
+Categories=GNOME;GTK;Settings;DesktopSettings;X-GNOME-Settings-Panel;X-GNOME-PrivacySettings;
+OnlyShowIn=GNOME;Unity;
+X-GNOME-Bugzilla-Bugzilla=GNOME
+X-GNOME-Bugzilla-Product=gnome-control-center
+X-GNOME-Bugzilla-Component=privacy
+X-GNOME-Bugzilla-Version=@VERSION@
+# Translators: Search terms to find the Privacy panel. Do NOT translate or localize the semicolons! The list MUST also end with a semicolon!
+Keywords=screen;lock;diagnostics;crash;private;recent;temporary;tmp;index;name;network;identity;privacy;
diff --git a/panels/diagnostics/meson.build b/panels/diagnostics/meson.build
new file mode 100644
index 0000000..fac9b4c
--- /dev/null
+++ b/panels/diagnostics/meson.build
@@ -0,0 +1,40 @@
+panels_list += cappletname
+desktop = 'gnome-@0@-panel.desktop'.format(cappletname)
+
+desktop_in = configure_file(
+ input: desktop + '.in.in',
+ output: desktop + '.in',
+ configuration: desktop_conf
+)
+
+i18n.merge_file(
+ desktop,
+ type: 'desktop',
+ input: desktop_in,
+ output: desktop,
+ po_dir: po_dir,
+ install: true,
+ install_dir: control_center_desktopdir
+)
+
+sources = files('cc-diagnostics-panel.c')
+
+resource_data = files('cc-diagnostics-panel.ui')
+
+sources += gnome.compile_resources(
+ 'cc-' + cappletname + '-resources',
+ cappletname + '.gresource.xml',
+ c_name: 'cc_' + cappletname,
+ dependencies: resource_data,
+ export: true
+)
+
+cflags += '-DGNOMELOCALEDIR="@0@"'.format(control_center_localedir)
+
+panels_libs += static_library(
+ cappletname,
+ sources: sources,
+ include_directories: [top_inc, common_inc],
+ dependencies: common_deps,
+ c_args: cflags
+)