system: Add "About" page

This commit is contained in:
Felipe Borges 2023-10-10 16:17:30 +02:00
parent 34fcaa0654
commit fb13e45aba
32 changed files with 100 additions and 278 deletions

View file

@ -1,18 +0,0 @@
[Desktop Entry]
Name=About
Comment=View information about your system
Exec=gnome-control-center info-overview
# Translators: Do NOT translate or transliterate this text (this is an icon file name)!
Icon=org.gnome.Settings-about-symbolic
Terminal=false
Type=Application
NoDisplay=true
StartupNotify=true
Categories=GNOME;GTK;Settings;X-GNOME-Settings-Panel;X-GNOME-DetailsSettings;
OnlyShowIn=GNOME;Unity;
# Translators: Search terms to find the About panel.
# Do NOT translate or localize the semicolons!
# The list MUST also end with a semicolon!
# "Preferred Applications" is the old name for the preference, so make
# sure that you use the same "translation" for those keywords
Keywords=device;system;information;hostname;memory;processor;version;default;application;preferred;cd;dvd;usb;audio;video;disc;removable;media;autorun;

View file

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gnome/control-center/info-overview">
<file preprocess="xml-stripblanks">cc-info-overview-panel.ui</file>
<file preprocess="xml-stripblanks">cc-info-entry.ui</file>
<file preprocess="xml-stripblanks">cc-system-details-window.ui</file>
</gresource>
</gresources>

View file

@ -1,75 +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
)
cflags += [
'-DDATADIR="@0@"'.format(control_center_datadir),
'-DLIBEXECDIR="@0@"'.format(control_center_libexecdir),
]
sources = files(
'cc-info-overview-panel.c',
'cc-system-details-window.c',
'cc-info-entry.c',
'info-cleanup.c'
)
sources += gnome.compile_resources(
'cc-' + cappletname + '-resources',
cappletname + '.gresource.xml',
c_name: 'cc_' + cappletname.underscorify (),
export: true
)
deps = common_deps + [
dependency('udisks2', version: '>= 2.8.2'),
dependency('libgtop-2.0'),
gudev_dep,
]
info_panel_lib = static_library(
cappletname,
sources: sources,
include_directories: [ top_inc, common_inc ],
dependencies: deps,
c_args: cflags
)
panels_libs += info_panel_lib
print_renderer_deps = [
dependency('gtk4'),
epoxy_dep
]
executable(
'test-info-cleanup',
[ 'info-cleanup.c', 'test-info-cleanup.c' ],
include_directories: [ top_inc ],
dependencies: [ print_renderer_deps ],
c_args: cflags,
)
executable(
'gnome-control-center-print-renderer',
'gnome-control-center-print-renderer.c',
include_directories: [ top_inc ],
dependencies: [ print_renderer_deps ],
c_args: cflags,
install: true,
install_dir: control_center_libexecdir,
)
install_data(
[ 'gnome-logo-text.svg', 'gnome-logo-text-dark.svg' ],
install_dir: join_paths(control_center_datadir, 'icons')
)
subdir('icons')

View file

@ -6,7 +6,6 @@ panels = [
'color',
'datetime',
'display',
'info-overview',
'keyboard',
'mouse',
'multitasking',

View file

@ -20,21 +20,17 @@
*
*/
#include <config.h>
#include "cc-about-page.h"
#include "cc-hostname-entry.h"
#include "cc-info-overview-resources.h"
#include <glib/gi18n.h>
#include "cc-list-row.h"
#include "cc-system-details-window.h"
#include "cc-info-overview-panel.h"
struct _CcInfoOverviewPanel
#include <config.h>
#include <glib/gi18n.h>
struct _CcAboutPage
{
CcPanel parent_instance;
AdwNavigationPage parent_instance;
CcListRow *disk_row;
CcListRow *hardware_model_row;
@ -47,10 +43,10 @@ struct _CcInfoOverviewPanel
GtkWindow *system_details_window;
};
G_DEFINE_TYPE (CcInfoOverviewPanel, cc_info_overview_panel, CC_TYPE_PANEL)
G_DEFINE_TYPE (CcAboutPage, cc_about_page, ADW_TYPE_NAVIGATION_PAGE)
static void
info_overview_panel_setup_overview (CcInfoOverviewPanel *self)
about_page_setup_overview (CcAboutPage *self)
{
guint64 ram_size;
g_autofree char *memory_text = NULL;
@ -81,7 +77,7 @@ info_overview_panel_setup_overview (CcInfoOverviewPanel *self)
os_name_text = get_os_name ();
cc_list_row_set_secondary_label (self->os_name_row, os_name_text);
self->system_details_window = GTK_WINDOW (cc_system_details_window_new());
self->system_details_window = GTK_WINDOW (cc_system_details_window_new ());
parent = (GtkWindow *) gtk_widget_get_native (GTK_WIDGET (self));
gtk_window_set_transient_for (GTK_WINDOW (self->system_details_window), parent);
}
@ -123,18 +119,17 @@ does_gpk_update_viewer_exist (void)
}
static void
cc_info_panel_open_system_details (CcInfoOverviewPanel *self)
cc_about_page_open_system_details (CcAboutPage *self)
{
GtkWidget *parent;
parent = cc_shell_get_toplevel (cc_panel_get_shell (CC_PANEL (self)));
GtkNative *parent;
parent = gtk_widget_get_native (GTK_WIDGET (self));
gtk_window_set_transient_for (self->system_details_window, GTK_WINDOW (parent));
gtk_window_present (GTK_WINDOW (self->system_details_window));
}
static void
cc_info_panel_open_software_update (CcInfoOverviewPanel *self)
cc_about_page_open_software_update (CcAboutPage *self)
{
g_autoptr(GError) error = NULL;
gboolean ret;
@ -158,7 +153,7 @@ cc_info_panel_open_software_update (CcInfoOverviewPanel *self)
#if !defined(DISTRIBUTOR_LOGO) || defined(DARK_MODE_DISTRIBUTOR_LOGO)
static gboolean
use_dark_theme (CcInfoOverviewPanel *self)
use_dark_theme (CcAboutPage *self)
{
AdwStyleManager *style_manager = adw_style_manager_get_default ();
@ -167,7 +162,7 @@ use_dark_theme (CcInfoOverviewPanel *self)
#endif
static void
setup_os_logo (CcInfoOverviewPanel *self)
setup_os_logo (CcAboutPage *self)
{
#ifdef DISTRIBUTOR_LOGO
#ifdef DARK_MODE_DISTRIBUTOR_LOGO
@ -211,50 +206,41 @@ setup_os_logo (CcInfoOverviewPanel *self)
}
static void
cc_info_overview_panel_class_init (CcInfoOverviewPanelClass *klass)
cc_about_page_class_init (CcAboutPageClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
g_type_ensure (CC_TYPE_HOSTNAME_ENTRY);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/info-overview/cc-info-overview-panel.ui");
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/system/about/cc-about-page.ui");
gtk_widget_class_bind_template_child (widget_class, CcInfoOverviewPanel, disk_row);
gtk_widget_class_bind_template_child (widget_class, CcInfoOverviewPanel, hardware_model_row);
gtk_widget_class_bind_template_child (widget_class, CcInfoOverviewPanel, memory_row);
gtk_widget_class_bind_template_child (widget_class, CcInfoOverviewPanel, os_logo);
gtk_widget_class_bind_template_child (widget_class, CcInfoOverviewPanel, os_name_row);
gtk_widget_class_bind_template_child (widget_class, CcInfoOverviewPanel, processor_row);
gtk_widget_class_bind_template_child (widget_class, CcInfoOverviewPanel, software_updates_group);
gtk_widget_class_bind_template_child (widget_class, CcAboutPage, disk_row);
gtk_widget_class_bind_template_child (widget_class, CcAboutPage, hardware_model_row);
gtk_widget_class_bind_template_child (widget_class, CcAboutPage, memory_row);
gtk_widget_class_bind_template_child (widget_class, CcAboutPage, os_logo);
gtk_widget_class_bind_template_child (widget_class, CcAboutPage, os_name_row);
gtk_widget_class_bind_template_child (widget_class, CcAboutPage, processor_row);
gtk_widget_class_bind_template_child (widget_class, CcAboutPage, software_updates_group);
gtk_widget_class_bind_template_callback (widget_class, cc_info_panel_open_software_update);
gtk_widget_class_bind_template_callback (widget_class, cc_info_panel_open_system_details);
gtk_widget_class_bind_template_callback (widget_class, cc_about_page_open_software_update);
gtk_widget_class_bind_template_callback (widget_class, cc_about_page_open_system_details);
g_type_ensure (CC_TYPE_LIST_ROW);
}
static void
cc_info_overview_panel_init (CcInfoOverviewPanel *self)
cc_about_page_init (CcAboutPage *self)
{
AdwStyleManager *style_manager;
gtk_widget_init_template (GTK_WIDGET (self));
g_resources_register (cc_info_overview_get_resource ());
if ((!does_gnome_software_exist () || !does_gnome_software_allow_updates ()) && !does_gpk_update_viewer_exist ())
gtk_widget_set_visible (GTK_WIDGET (self->software_updates_group), FALSE);
info_overview_panel_setup_overview (self);
about_page_setup_overview (self);
style_manager = adw_style_manager_get_default ();
g_signal_connect_swapped (style_manager, "notify::dark", G_CALLBACK (setup_os_logo), self);
setup_os_logo (self);
}
GtkWidget *
cc_info_overview_panel_new (void)
{
return g_object_new (CC_TYPE_INFO_OVERVIEW_PANEL,
NULL);
}

View file

@ -23,9 +23,7 @@
G_BEGIN_DECLS
#define CC_TYPE_INFO_OVERVIEW_PANEL (cc_info_overview_panel_get_type ())
G_DECLARE_FINAL_TYPE (CcInfoOverviewPanel, cc_info_overview_panel, CC, INFO_OVERVIEW_PANEL, CcPanel)
GtkWidget *cc_info_overview_panel_new (void);
#define CC_TYPE_ABOUT_PAGE (cc_about_page_get_type ())
G_DECLARE_FINAL_TYPE (CcAboutPage, cc_about_page, CC, ABOUT_PAGE, AdwNavigationPage)
G_END_DECLS

View file

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="CcInfoOverviewPanel" parent="CcPanel">
<template class="CcAboutPage" parent="AdwNavigationPage">
<property name="title" translatable="yes">About</property>
<property name="tag">system-about-page</property>
<property name="child">
<object class="AdwToolbarView">
<child type="top">
@ -95,7 +97,7 @@
<object class="AdwActionRow">
<property name="activatable">True</property>
<property name="title" translatable="yes">System Details</property>
<signal name="activated" handler="cc_info_panel_open_system_details" swapped="yes"/>
<signal name="activated" handler="cc_about_page_open_system_details" swapped="yes"/>
<child type="suffix">
<object class="GtkImage">
<property name="valign">center</property>
@ -115,7 +117,7 @@
<object class="AdwActionRow">
<property name="activatable">True</property>
<property name="title" translatable="yes">Software Updates</property>
<signal name="activated" handler="cc_info_panel_open_software_update" swapped="yes"/>
<signal name="activated" handler="cc_about_page_open_software_update" swapped="yes"/>
<child type="suffix">
<object class="GtkImage">
<property name="valign">center</property>

View file

@ -109,7 +109,7 @@ cc_info_entry_class_init (CcInfoEntryClass *klass)
g_object_class_install_properties (object_class, N_PROPS, properties);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/info-overview/cc-info-entry.ui");
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/system/about/cc-info-entry.ui");
gtk_widget_class_bind_template_child (widget_class, CcInfoEntry, prop);
gtk_widget_class_bind_template_child (widget_class, CcInfoEntry, value);

View file

@ -930,7 +930,7 @@ cc_system_details_window_class_init (CcSystemDetailsWindowClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/info-overview/cc-system-details-window.ui");
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/system/about/cc-system-details-window.ui");
gtk_widget_class_bind_template_child (widget_class, CcSystemDetailsWindow, toast_overlay);
gtk_widget_class_bind_template_child (widget_class, CcSystemDetailsWindow, disk_row);

View file

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

View file

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

View file

@ -0,0 +1,29 @@
print_renderer_deps = [
dependency('gtk4'),
epoxy_dep
]
executable(
'test-info-cleanup',
[ 'info-cleanup.c', 'test-info-cleanup.c' ],
include_directories: [ top_inc ],
dependencies: [ print_renderer_deps ],
c_args: cflags,
)
executable(
'gnome-control-center-print-renderer',
'gnome-control-center-print-renderer.c',
include_directories: [ top_inc ],
dependencies: [ print_renderer_deps ],
c_args: cflags,
install: true,
install_dir: control_center_libexecdir,
)
install_data(
[ 'gnome-logo-text.svg', 'gnome-logo-text-dark.svg' ],
install_dir: join_paths(control_center_datadir, 'icons')
)
subdir('icons')

View file

@ -27,6 +27,7 @@
#include "cc-system-panel.h"
#include "cc-system-resources.h"
#include "about/cc-about-page.h"
#include "region/cc-region-page.h"
#include "remote-desktop/cc-remote-desktop-page.h"
@ -48,6 +49,7 @@ cc_system_panel_class_init (CcSystemPanelClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcSystemPanel, navigation);
g_type_ensure (CC_TYPE_ABOUT_PAGE);
g_type_ensure (CC_TYPE_REGION_PAGE);
g_type_ensure (CC_TYPE_REMOTE_DESKTOP_PAGE);
}

View file

@ -39,6 +39,16 @@
<property name="action-target">'system-remote-desktop-page'</property>
</object>
</child>
<child>
<object class="CcListRow">
<property name="title" translatable="yes">About</property>
<property name="icon-name">info-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">'system-about-page'</property>
</object>
</child>
</object>
</child>
@ -56,6 +66,9 @@
<child>
<object class="CcRemoteDesktopPage"/>
</child>
<child>
<object class="CcAboutPage"/>
</child>
</object>
</child>

View file

@ -12,6 +12,10 @@ i18n.merge_file(
sources = files(
'cc-system-panel.c',
'about/cc-about-page.c',
'about/cc-system-details-window.c',
'about/cc-info-entry.c',
'about/info-cleanup.c',
'region/cc-region-page.c',
'region/cc-format-chooser.c',
'region/cc-format-preview.c',
@ -30,16 +34,21 @@ sources += gnome.compile_resources(
libsecret_dep = dependency('libsecret-1')
gnutls_dep = dependency('gnutls')
libgtop2 = dependency('libgtop-2.0')
udisks2 = dependency('udisks2', version: '>= 2.8.2')
deps = common_deps + [
accounts_dep,
gcr_dep,
gnome_desktop_dep,
gnutls_dep,
gudev_dep,
libgtop2,
liblanguage_dep,
libsecret_dep,
polkit_gobject_dep,
pwquality_dep,
udisks2,
]
if enable_ibus
@ -56,6 +65,11 @@ sources += gnome.gdbus_codegen(
namespace: 'Gsd'
)
cflags += [
'-DDATADIR="@0@"'.format(control_center_datadir),
'-DLIBEXECDIR="@0@"'.format(control_center_libexecdir),
]
subdir('region')
panels_libs += static_library(
@ -65,3 +79,5 @@ panels_libs += static_library(
dependencies: deps,
c_args: cflags
)
subdir('about')

View file

@ -1,6 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gnome/control-center/system">
<file preprocess="xml-stripblanks">about/cc-about-page.ui</file>
<file preprocess="xml-stripblanks">about/cc-info-entry.ui</file>
<file preprocess="xml-stripblanks">about/cc-system-details-window.ui</file>
<file preprocess="xml-stripblanks">cc-system-panel.ui</file>
<file preprocess="xml-stripblanks">region/cc-region-page.ui</file>
<file preprocess="xml-stripblanks">region/cc-format-chooser.ui</file>

View file

@ -379,7 +379,6 @@ static const gchar * const panel_order[] = {
"user-accounts",
"reset-settings",
"datetime",
"info-overview",
};
static guint

View file

@ -39,7 +39,6 @@ extern GType cc_bluetooth_panel_get_type (void);
extern GType cc_color_panel_get_type (void);
extern GType cc_date_time_panel_get_type (void);
extern GType cc_display_panel_get_type (void);
extern GType cc_info_overview_panel_get_type (void);
extern GType cc_keyboard_panel_get_type (void);
extern GType cc_mouse_panel_get_type (void);
extern GType cc_multitasking_panel_get_type (void);
@ -94,7 +93,6 @@ 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("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),
PANEL_TYPE("mouse", cc_mouse_panel_get_type, NULL),
PANEL_TYPE("multitasking", cc_multitasking_panel_get_type, NULL),

View file

@ -1,19 +0,0 @@
Intel(R) Core(TM) i5-4590T CPU @ 2.00GHz Intel® Core™ i5-4590T
Intel(R) Ivybridge Mobile Intel® Ivybridge Mobile
Intel(R) Ivybridge Mobile Intel® Ivybridge Mobile
Gallium 0.4 on AMD KAVERI AMD KAVERI
AMD KAVERI (DRM 2.48.0 / 4.9.0-0.rc4.git2.2.fc26.x86_64, LLVM3) AMD KAVERI
AMD KAVERI (DRM 2.48.0 / 4.9.0-0.rc4.git2.2.fc26.x86_64, LLVM3 AMD KAVERI
Gallium 0.4 on AMD KAVERI (DRM 2.48.0 / 4.9.0-0.rc4.git2.2.fc26.x86_64, LLVM3) AMD KAVERI
Gallium 0.4 on AMD KAVERI (DRM 2.48.0 / 4.9.0-0.rc4.git2.2.fc26.x86_64, LLVM3 AMD KAVERI
AMD Ryzen Threadripper 1950X 16-Core Processor AMD Ryzen™ Threadripper™ 1950X
AMD Radeon RX 580 Series (POLARIS10, DRM 3.42.0, 5.15.13-1-ck-generic-v3, LLVM 13.0.0) AMD Radeon™ RX 580 Series
AMD EPYC 7251 8-Core Processor AMD EPYC™ 7251
Gallium 0.4 on SVGA3D SVGA3D
Gallium 0.4 on llvmpipe (LLVM 3.4, 128 bits) Software Rendering
llvmpipe (LLVM 12.0.1, 256 bits) Software Rendering
AMD FX(tm)-8350 Eight-Core Processor AMD FX™-8350
AMD Athlon(tm) II X3 435 Processor AMD Athlon™ II X3 435
NVIDIA GeForce GT 710/PCIe/SSE2 NVIDIA GeForce GT 710
Mesa DRI Intel(R) 965GM x86/MMX/SSE2 Intel® 965GM
NVIDIA GeForce RTX 3090/PCIe/SSE2 NVIDIA GeForce RTX™ 3090

View file

@ -1,21 +0,0 @@
test_units = [
'test-info-cleanup'
]
includes = [top_inc, include_directories('../../panels/info-overview')]
cflags = '-DTEST_SRCDIR="@0@"'.format(meson.current_source_dir())
foreach unit: test_units
exe = executable(
unit,
[unit + '.c'],
include_directories : includes,
dependencies : common_deps,
link_with : [info_panel_lib],
c_args : cflags
)
test(unit, exe)
endforeach

View file

@ -1,81 +0,0 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* 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 <glib.h>
#include <locale.h>
#include "info-cleanup.h"
static void
test_info (void)
{
g_autofree gchar *contents = NULL;
guint i;
g_auto(GStrv) lines = NULL;
if (g_file_get_contents (TEST_SRCDIR "/info-cleanup-test.txt", &contents, NULL, NULL) == FALSE) {
g_warning ("Failed to load '%s'", TEST_SRCDIR "/info-cleanup-test.txt");
g_test_fail ();
return;
}
lines = g_strsplit (contents, "\n", -1);
if (lines == NULL) {
g_warning ("Test file is empty");
g_test_fail ();
return;
}
for (i = 0; lines[i] != NULL; i++) {
g_auto(GStrv) items = NULL;
g_autofree gchar *utf8 = NULL;
g_autofree gchar *result = NULL;
if (*lines[i] == '#')
continue;
if (*lines[i] == '\0')
break;
items = g_strsplit (lines[i], "\t", -1);
utf8 = g_locale_from_utf8 (items[0], -1, NULL, NULL, NULL);
result = info_cleanup (items[0]);
if (g_strcmp0 (result, items[1]) != 0) {
g_error ("Result for '%s' doesn't match '%s' (got: '%s')",
utf8, items[1], result);
g_test_fail ();
} else {
g_debug ("Result for '%s' matches '%s'",
utf8, result);
}
}
}
int main (int argc, char **argv)
{
setlocale (LC_ALL, "");
g_test_init (&argc, &argv, NULL);
g_setenv ("G_DEBUG", "fatal_warnings", FALSE);
g_test_add_func ("/info/info", test_info);
return g_test_run ();
}

View file

@ -10,5 +10,4 @@ if not libadwaita_is_subproject
endif
subdir('printers')
subdir('info')
subdir('keyboard')