Add a diagnostic panel
This is a broken out version of the privacy panel dialog.
This commit is contained in:
parent
5c36cc837d
commit
13a4f9a2af
7 changed files with 366 additions and 1 deletions
154
panels/diagnostics/cc-diagnostics-panel.c
Normal file
154
panels/diagnostics/cc-diagnostics-panel.c
Normal file
|
@ -0,0 +1,154 @@
|
|||
/* -*- 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;
|
||||
GtkLabel *diagnostics_learn_more_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_learn_more_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_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");
|
||||
/* translators: '%s' is the distributor's name, such as 'Fedora' */
|
||||
msg = g_strdup_printf (_("Sending reports of technical problems helps us improve %s. Reports "
|
||||
"are sent anonymously and are scrubbed of personal data."),
|
||||
os_name);
|
||||
gtk_label_set_text (self->diagnostics_explanation_label, msg);
|
||||
|
||||
url = cc_os_release_get_value ("PRIVACY_POLICY_URL");
|
||||
if (!url)
|
||||
url = g_strdup ("http://www.gnome.org/privacy-policy");
|
||||
|
||||
msg = g_strdup_printf ("%s <a href=\"%s\">Learn more</a>",
|
||||
_("Reports are sent anonymously and are scrubbed of personal data."),
|
||||
url);
|
||||
gtk_label_set_markup (self->diagnostics_learn_more_label, msg);
|
||||
}
|
32
panels/diagnostics/cc-diagnostics-panel.h
Normal file
32
panels/diagnostics/cc-diagnostics-panel.h
Normal file
|
@ -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
|
113
panels/diagnostics/cc-diagnostics-panel.ui
Normal file
113
panels/diagnostics/cc-diagnostics-panel.ui
Normal file
|
@ -0,0 +1,113 @@
|
|||
<?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="HdyColumn">
|
||||
<property name="visible">True</property>
|
||||
<property name="maximum_width">600</property>
|
||||
<property name="linear_growth_width">400</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="label" translatable="yes">Sending reports of technical problems help us improve this operating system.</property>
|
||||
<property name="wrap">1</property>
|
||||
<property name="max-width-chars">50</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="diagnostics_learn_more_label">
|
||||
<property name="visible">1</property>
|
||||
<property name="margin-bottom">12</property>
|
||||
<property name="label" translatable="yes">Reports are sent anonymously and are scrubbed of personal data.</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>
|
6
panels/diagnostics/diagnostics.gresource.xml
Normal file
6
panels/diagnostics/diagnostics.gresource.xml
Normal file
|
@ -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>
|
19
panels/diagnostics/gnome-diagnostics-panel.desktop.in.in
Normal file
19
panels/diagnostics/gnome-diagnostics-panel.desktop.in.in
Normal file
|
@ -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;
|
40
panels/diagnostics/meson.build
Normal file
40
panels/diagnostics/meson.build
Normal file
|
@ -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
|
||||
)
|
|
@ -73,6 +73,7 @@ extern GType cc_lock_panel_get_type (void);
|
|||
extern GType cc_diagnostics_panel_get_type (void);
|
||||
|
||||
/* Static init functions */
|
||||
extern void cc_diagnostics_panel_static_init_func (void);
|
||||
#ifdef BUILD_NETWORK
|
||||
extern void cc_wifi_panel_static_init_func (void);
|
||||
#endif /* BUILD_NETWORK */
|
||||
|
@ -99,7 +100,7 @@ static CcPanelLoaderVtable default_panels[] =
|
|||
PANEL_TYPE("color", cc_color_panel_get_type, NULL),
|
||||
PANEL_TYPE("datetime", cc_date_time_panel_get_type, NULL),
|
||||
PANEL_TYPE("default-apps", cc_default_apps_panel_get_type, NULL),
|
||||
PANEL_TYPE("diagnostics", cc_diagnostics_panel_get_type, NULL),
|
||||
PANEL_TYPE("diagnostics", cc_diagnostics_panel_get_type, cc_diagnostics_panel_static_init_func),
|
||||
PANEL_TYPE("display", cc_display_panel_get_type, NULL),
|
||||
PANEL_TYPE("info-overview", cc_info_overview_panel_get_type, NULL),
|
||||
PANEL_TYPE("keyboard", cc_keyboard_panel_get_type, NULL),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue