privacy: Add diagnostics page

The UI file is not formatted on purpose to facilitate the review. It
will be reformatted in a later commit.
This commit is contained in:
Marco Melorio 2023-06-03 23:13:02 +02:00 committed by Felipe Borges
parent c94afe06a8
commit ef58f0e097
14 changed files with 72 additions and 118 deletions

View file

@ -1,6 +0,0 @@
<?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>

View file

@ -1,15 +0,0 @@
[Desktop Entry]
Name=Diagnostics
Comment=Settings for automatically problem reporting
Exec=gnome-control-center diagnostics
# FIXME
# Translators: Do NOT translate or transliterate this text (this is an icon file name)!
Icon=org.gnome.Settings-diagnostics-symbolic
Terminal=false
Type=Application
NoDisplay=true
StartupNotify=true
Categories=GNOME;GTK;Settings;DesktopSettings;X-GNOME-Settings-Panel;X-GNOME-PrivacySettings;
OnlyShowIn=GNOME;Unity;
# Translators: Search terms to find the Diagnostics panel. Do NOT translate or localize the semicolons! The list MUST also end with a semicolon!
Keywords=diagnostics;crash;

View file

@ -1,4 +0,0 @@
install_data(
'scalable/org.gnome.Settings-diagnostics-symbolic.svg',
install_dir: join_paths(control_center_icondir, 'hicolor', 'scalable', 'apps')
)

View file

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg height="16px" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg">
<g fill="#2e3436">
<path d="m 3.011719 1 c -1.644531 0 -3.0000002 1.355469 -3.0000002 3 v 6 c 0 1.644531 1.3554692 3 3.0000002 3 h 1.988281 v -2 h -1.988281 c -0.570313 0 -1 -0.429688 -1 -1 v -6 c 0 -0.570312 0.429687 -1 1 -1 h 8.976562 c 0.570313 0 1 0.429688 1 1 v 1 h 2 v -1 c 0 -1.644531 -1.355469 -3 -3 -3 z m 0 0"/>
<path d="m 5.011719 14 c -1.105469 0 -2 0.894531 -2 2 h 10 c 0 -1.105469 -0.894531 -2 -2 -2 z m 0 0"/>
<path d="m 9.5 4 c -2.484375 0 -4.5 2.015625 -4.5 4.5 s 2.015625 4.5 4.5 4.5 c 0.847656 0 1.675781 -0.242188 2.390625 -0.695312 l 2.402344 2.402343 c 0.390625 0.390625 1.023437 0.390625 1.414062 0 s 0.390625 -1.023437 0 -1.414062 l -2.398437 -2.398438 c 0.449218 -0.71875 0.691406 -1.546875 0.691406 -2.394531 c 0 -2.484375 -2.015625 -4.5 -4.5 -4.5 z m 0 2 c 1.378906 0 2.5 1.121094 2.5 2.5 s -1.121094 2.5 -2.5 2.5 s -2.5 -1.121094 -2.5 -2.5 s 1.121094 -2.5 2.5 -2.5 z m 0 0"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1 KiB

View file

@ -1,32 +0,0 @@
panels_list += cappletname
desktop = 'gnome-@0@-panel.desktop'.format(cappletname)
i18n.merge_file(
type: 'desktop',
input: desktop + '.in',
output: desktop,
po_dir: po_dir,
install: true,
install_dir: control_center_desktopdir
)
sources = files('cc-diagnostics-panel.c')
sources += gnome.compile_resources(
'cc-' + cappletname + '-resources',
cappletname + '.gresource.xml',
c_name: 'cc_' + cappletname,
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
)
subdir('icons')

View file

@ -18,17 +18,16 @@
* Author: Matthias Clasen <mclasen@redhat.com>
*/
#include "cc-diagnostics-panel.h"
#include "cc-diagnostics-resources.h"
#include "cc-diagnostics-page.h"
#include "cc-util.h"
#include "shell/cc-application.h"
#include <gio/gdesktopappinfo.h>
#include <glib/gi18n.h>
struct _CcDiagnosticsPanel
struct _CcDiagnosticsPage
{
CcPanel parent_instance;
AdwNavigationPage parent_instance;
AdwPreferencesGroup *diagnostics_group;
GtkSwitch *abrt_switch;
@ -36,30 +35,20 @@ struct _CcDiagnosticsPanel
GSettings *privacy_settings;
};
CC_PANEL_REGISTER (CcDiagnosticsPanel, cc_diagnostics_panel)
G_DEFINE_TYPE (CcDiagnosticsPage, cc_diagnostics_page, ADW_TYPE_NAVIGATION_PAGE)
/* 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)
{
CcDiagnosticsPage *self = CC_DIAGNOSTICS_PAGE (user_data);
g_debug ("ABRT appeared");
set_panel_visibility (CC_PANEL_VISIBLE);
gtk_widget_set_visible (GTK_WIDGET (self), TRUE);
}
static void
@ -67,60 +56,56 @@ abrt_vanished_cb (GDBusConnection *connection,
const gchar *name,
gpointer user_data)
{
CcDiagnosticsPage *self = CC_DIAGNOSTICS_PAGE (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);
gtk_widget_set_visible (GTK_WIDGET (self), FALSE);
}
static void
cc_diagnostics_panel_finalize (GObject *object)
cc_diagnostics_page_finalize (GObject *object)
{
CcDiagnosticsPanel *self = CC_DIAGNOSTICS_PANEL (object);
CcDiagnosticsPage *self = CC_DIAGNOSTICS_PAGE (object);
g_clear_object (&self->privacy_settings);
G_OBJECT_CLASS (cc_diagnostics_panel_parent_class)->finalize (object);
G_OBJECT_CLASS (cc_diagnostics_page_parent_class)->finalize (object);
}
static void
cc_diagnostics_panel_class_init (CcDiagnosticsPanelClass *klass)
cc_diagnostics_page_class_init (CcDiagnosticsPageClass *klass)
{
GObjectClass *oclass = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
oclass->finalize = cc_diagnostics_panel_finalize;
oclass->finalize = cc_diagnostics_page_finalize;
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/diagnostics/cc-diagnostics-panel.ui");
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/privacy/cc-diagnostics-page.ui");
gtk_widget_class_bind_template_child (widget_class, CcDiagnosticsPanel, diagnostics_group);
gtk_widget_class_bind_template_child (widget_class, CcDiagnosticsPanel, abrt_switch);
gtk_widget_class_bind_template_child (widget_class, CcDiagnosticsPage, diagnostics_group);
gtk_widget_class_bind_template_child (widget_class, CcDiagnosticsPage, abrt_switch);
}
static void
cc_diagnostics_panel_init (CcDiagnosticsPanel *self)
cc_diagnostics_page_init (CcDiagnosticsPage *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));
g_bus_watch_name (G_BUS_TYPE_SYSTEM,
"org.freedesktop.problems.daemon",
G_BUS_NAME_WATCHER_FLAGS_NONE,
abrt_appeared_cb,
abrt_vanished_cb,
self,
NULL);
gtk_widget_set_visible (GTK_WIDGET (self), FALSE);
self->privacy_settings = g_settings_new ("org.gnome.desktop.privacy");
g_settings_bind (self->privacy_settings, "report-technical-problems",

View file

@ -20,13 +20,11 @@
#pragma once
#include <shell/cc-panel.h>
#include <adwaita.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);
#define CC_TYPE_DIAGNOSTICS_PAGE (cc_diagnostics_page_get_type ())
G_DECLARE_FINAL_TYPE (CcDiagnosticsPage, cc_diagnostics_page, CC, DIAGNOSTICS_PAGE, AdwNavigationPage)
G_END_DECLS

View file

@ -1,7 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="CcDiagnosticsPanel" parent="CcPanel">
<child type="content">
<template class="CcDiagnosticsPage" parent="AdwNavigationPage">
<property name="title" translatable="yes">Diagnostics</property>
<property name="tag">diagnostics-page</property>
<property name="child">
<object class="AdwToolbarView">
<property name="top-bar-style">raised</property>
<child type="top">
<object class="AdwHeaderBar"/>
</child>
<property name="content">
<object class="AdwPreferencesPage">
<child>
<object class="AdwPreferencesGroup" id="diagnostics_group">
@ -21,6 +29,8 @@
</object>
</child>
</object>
</child>
</property>
</object>
</property>
</template>
</interface>

View file

@ -20,6 +20,7 @@
#include "cc-privacy-panel.h"
#include "cc-diagnostics-page.h"
#include "cc-privacy-resources.h"
#include "cc-screen-page.h"
#include "cc-usage-page.h"
@ -38,6 +39,7 @@ cc_privacy_panel_class_init (CcPrivacyPanelClass *klass)
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/privacy/cc-privacy-panel.ui");
g_type_ensure (CC_TYPE_DIAGNOSTICS_PAGE);
g_type_ensure (CC_TYPE_SCREEN_PAGE);
g_type_ensure (CC_TYPE_USAGE_PAGE);
}

View file

@ -61,6 +61,21 @@
</object>
</child>
<child>
<object class="CcListRow">
<property name="title" translatable="yes">_Diagnostics</property>
<property name="subtitle" translatable="yes">Settings for automatic problem reporting</property>
<property name="icon-name">diagnostics-symbolic</property>
<property name="use-underline">True</property>
<property name="show-arrow">True</property>
<property name="action-name">navigation.push</property>
<property name="action-target">'diagnostics-page'</property>
<binding name="visible">
<lookup name="visible">diagnostics_page</lookup>
</binding>
</object>
</child>
</object>
</child>
</object>
@ -79,6 +94,10 @@
<object class="CcUsagePage"/>
</child>
<child>
<object class="CcDiagnosticsPage" id="diagnostics_page"/>
</child>
</object>
</child>
</template>

View file

@ -11,4 +11,4 @@ StartupNotify=true
Categories=GNOME;GTK;Settings;DesktopSettings;X-GNOME-Settings-Panel;X-GNOME-AccountSettings;
OnlyShowIn=GNOME;
# Translators: Search terms to find the Privacy panel. Do NOT translate or localize the semicolons! The list MUST also end with a semicolon!
Keywords=Privacy;Screen;Lock;Private;Usage;Recent;History;Files;Temporary;Tmp;Trash;Purge;Retain;
Keywords=Privacy;Screen;Lock;Private;Usage;Recent;History;Files;Temporary;Tmp;Trash;Purge;Retain;Diagnostics;Crash;

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" height="16px" viewBox="0 0 16 16" width="16px"><path d="m 3.011719 1 c -1.644531 0 -3.0000002 1.355469 -3.0000002 3 v 6 c 0 1.644531 1.3554692 3 3.0000002 3 h 0.996093 c 0.546876 0 0.992188 -0.445312 0.992188 -0.992188 v -0.015624 c 0 -0.546876 -0.445312 -0.992188 -0.992188 -0.992188 h -0.996093 c -0.570313 0 -1 -0.429688 -1 -1 v -6 c 0 -0.570312 0.429687 -1 1 -1 h 8.976562 c 0.570313 0 1 0.429688 1 1 v 0.011719 c 0 0.546875 0.441407 0.988281 0.988281 0.988281 h 0.023438 c 0.546875 0 0.988281 -0.441406 0.988281 -0.988281 v -0.011719 c 0 -1.644531 -1.355469 -3 -3 -3 z m 6.488281 3 c -2.484375 0 -4.5 2.015625 -4.5 4.5 s 2.015625 4.5 4.5 4.5 c 0.847656 0 1.675781 -0.242188 2.390625 -0.695312 l 2.402344 2.402343 c 0.390625 0.390625 1.023437 0.390625 1.414062 0 s 0.390625 -1.023437 0 -1.414062 l -2.402343 -2.398438 c 0.453124 -0.71875 0.695312 -1.546875 0.695312 -2.394531 c 0 -2.484375 -2.015625 -4.5 -4.5 -4.5 z m 0 2 c 1.378906 0 2.5 1.121094 2.5 2.5 s -1.121094 2.5 -2.5 2.5 s -2.5 -1.121094 -2.5 -2.5 s 1.121094 -2.5 2.5 -2.5 z m -4.488281 8 c -1.105469 0 -2 0.894531 -2 2 h 10 c 0 -1.105469 -0.894531 -2 -2 -2 z m 0 0"/></svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -11,6 +11,7 @@ i18n.merge_file(
)
sources = files(
'cc-diagnostics-page.c',
'cc-privacy-panel.c',
'cc-screen-page.c',
'cc-usage-page.c',

View file

@ -1,11 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gnome/control-center/privacy">
<file preprocess="xml-stripblanks">cc-diagnostics-page.ui</file>
<file preprocess="xml-stripblanks">cc-privacy-panel.ui</file>
<file preprocess="xml-stripblanks">cc-screen-page.ui</file>
<file preprocess="xml-stripblanks">cc-usage-page.ui</file>
</gresource>
<gresource prefix="/org/gnome/Settings">
<file preprocess="xml-stripblanks">icons/scalable/actions/diagnostics-symbolic.svg</file>
<file preprocess="xml-stripblanks">icons/scalable/actions/lock-symbolic.svg</file>
<file preprocess="xml-stripblanks">icons/scalable/actions/trash-symbolic.svg</file>
</gresource>