Skip to content

Commit

Permalink
Port to Gtk4 (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit authored Dec 24, 2023
1 parent e258734 commit a87e106
Show file tree
Hide file tree
Showing 18 changed files with 172 additions and 185 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gettext.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Gettext Updates

on:
push:
branches: [master]
branches: [main]

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Install Dependencies
run: |
apt update
apt install -y meson libfwupd-dev libgranite-dev libgtk-3-dev libgtop2-dev libgudev-1.0-dev libudisks2-dev libhandy-1-dev libswitchboard-2.0-dev libappstream-dev valac
apt install -y meson libadwaita-1-dev libfwupd-dev libgranite-7-dev libgtk-4-dev libgtop2-dev libgudev-1.0-dev libudisks2-dev libswitchboard-3-dev libappstream-dev valac
- name: Build
env:
DESTDIR: out
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Release

on:
pull_request:
branches: [master]
branches: [main]
types: [closed]
jobs:
release:
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Switchboard System Plug
# System Settings
[![Translation status](https://l10n.elementary.io/widgets/switchboard/-/switchboard-plug-about/svg-badge.svg)](https://l10n.elementary.io/engage/switchboard/?utm_source=widget)

![screenshot](data/screenshot.png?raw=true)
Expand All @@ -7,14 +7,14 @@

You'll need the following dependencies:

* libswitchboard-2.0-dev
* libswitchboard-3-dev
* libfwupd-dev
* libgranite-dev
* libgtk-3-dev
* libgranite-7-dev
* libgtk-4-dev
* libgtop2-dev
* libgudev-1.0-dev
* libudisks2-dev
* libhandy-1-dev
* libadwaita-1-dev
* libappstream-dev
* meson
* valac
Expand All @@ -32,7 +32,7 @@ To install, use `ninja install`

## OEM Configuration

The Switchboard System plug can load OEM information supplied by an `oem.conf` file placed in `/etc` with the following format:
System Settings can load OEM information supplied by an `oem.conf` file placed in `/etc` with the following format:

```ini
[OEM]
Expand Down
14 changes: 9 additions & 5 deletions data/OperatingSystemView.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
avatar.image {
.logo {
color: white;
background-image: linear-gradient(
to bottom,
alpha(@accent_color_500, 0.25),
alpha(@accent_color_700, 0.75)
);
}

.logo {
color: white;
border-radius: 100%;
box-shadow:
inset 0 -2px 0 0 alpha(@highlight_color, 0.2),
inset 0 2px 0 0 alpha(@highlight_color, 0.3),
inset 2px 0 0 0 alpha(@highlight_color, 0.07),
inset -2px 0 0 0 alpha(@highlight_color, 0.07),
inset 0 0 0 1px alpha(black, 0.7);
-gtk-icon-shadow:
0 1px 1px alpha(black, 0.3),
0 2px 3px alpha(@accent_color_900, 0.2);
Expand Down
2 changes: 1 addition & 1 deletion data/gresource.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/io/elementary/switchboard/system">
<gresource prefix="/io/elementary/settings/system">
<file alias="OperatingSystemView.css" compressed="true">OperatingSystemView.css</file>
</gresource>
</gresources>
4 changes: 2 additions & 2 deletions data/meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
i18n.merge_file(
input: 'io.elementary.switchboard.about.appdata.xml.in',
output: 'io.elementary.switchboard.about.appdata.xml',
input: 'system.metainfo.xml.in',
output: 'io.elementary.settings.system.metainfo.xml.in',
po_dir: join_paths(meson.source_root (), 'po', 'extra'),
install_dir: join_paths(datadir, 'metainfo'),
install: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="addon">
<id>io.elementary.switchboard.about</id>
<extends>io.elementary.switchboard</extends>
<id>io.elementary.settings.system</id>
<extends>io.elementary.settings</extends>
<name>System</name>
<summary>View operating system and hardware information</summary>
<icon type="stock">application-x-firmware</icon>
<translation type="gettext">about-plug</translation>
<translation type="gettext">io.elementary.settings.system</translation>

<releases>
<release version="6.2.0" date="2023-01-26" urgency="medium">
Expand Down Expand Up @@ -91,13 +91,13 @@
</releases>
<screenshots>
<screenshot type="default">
<image>https://raw.githubusercontent.com/elementary/switchboard-plug-about/master/data/screenshot.png</image>
<image>https://raw.githubusercontent.com/elementary/switchboard-plug-about/main/data/screenshot.png</image>
</screenshot>
<screenshot>
<image>https://raw.githubusercontent.com/elementary/switchboard-plug-about/master/data/screenshot-hardware.png</image>
<image>https://raw.githubusercontent.com/elementary/switchboard-plug-about/main/data/screenshot-hardware.png</image>
</screenshot>
<screenshot>
<image>https://raw.githubusercontent.com/elementary/switchboard-plug-about/master/data/screenshot-firmware.png</image>
<image>https://raw.githubusercontent.com/elementary/switchboard-plug-about/main/data/screenshot-firmware.png</image>
</screenshot>
</screenshots>
<url type="homepage">https://elementary.io</url>
Expand Down
4 changes: 2 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
project(
'about',
'system',
'vala', 'c',
version: '6.2.0'
)

gettext_name = meson.project_name() + '-plug'
gettext_name = 'io.elementary.settings.' + meson.project_name()
gnome = import('gnome')
i18n = import('i18n')

Expand Down
2 changes: 1 addition & 1 deletion po/extra/POTFILES
Original file line number Diff line number Diff line change
@@ -1 +1 @@
data/io.elementary.switchboard.about.appdata.xml.in
data/system.metainfo.xml.in
File renamed without changes.
11 changes: 8 additions & 3 deletions src/Plug.vala
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class About.Plug : Switchboard.Plug {

Object (
category: Category.SYSTEM,
code_name: "io.elementary.switchboard.about",
code_name: "io.elementary.settings.system",
display_name: _("System"),
description: _("View operating system and hardware information"),
icon: "application-x-firmware",
Expand All @@ -65,17 +65,22 @@ public class About.Plug : Switchboard.Plug {

var stack_switcher = new Gtk.StackSwitcher () {
halign = Gtk.Align.CENTER,
homogeneous = true,
margin_top = 24,
stack = stack
};

var size_group = new Gtk.SizeGroup (HORIZONTAL);
var child = stack_switcher.get_first_child ();
while (child != null) {
size_group.add_widget (child);
child = child.get_next_sibling ();
}

main_grid = new Gtk.Grid () {
row_spacing = 12
};
main_grid.attach (stack_switcher, 0, 0);
main_grid.attach (stack, 0, 1);
main_grid.show_all ();
}

return main_grid;
Expand Down
60 changes: 27 additions & 33 deletions src/Views/FirmwareReleaseView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class About.FirmwareReleaseView : Gtk.Box {

private Fwupd.Device device;
private Fwupd.Release? release;
private Granite.Widgets.AlertView placeholder;
private Granite.Placeholder placeholder;
private Gtk.ScrolledWindow scrolled_window;
private Gtk.Stack stack;
private Gtk.Revealer update_button_revealer;
Expand All @@ -22,7 +22,7 @@ public class About.FirmwareReleaseView : Gtk.Box {
private Gtk.Label vendor_value_label;
private Gtk.Label size_value_label;
private Gtk.Label install_duration_value_label;
private Hdy.Deck? deck;
private Adw.Leaflet? deck;

construct {
var back_button = new Gtk.Button.with_label (_("All Updates")) {
Expand All @@ -32,7 +32,7 @@ public class About.FirmwareReleaseView : Gtk.Box {
margin_bottom = 6,
margin_start = 6,
};
back_button.get_style_context ().add_class (Granite.STYLE_CLASS_BACK_BUTTON);
back_button.add_css_class (Granite.STYLE_CLASS_BACK_BUTTON);

title_label = new Gtk.Label ("") {
ellipsize = END,
Expand All @@ -47,24 +47,24 @@ public class About.FirmwareReleaseView : Gtk.Box {
margin_start = 6,
sensitive = false
};
update_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
update_button.add_css_class (Granite.STYLE_CLASS_SUGGESTED_ACTION);

update_button_revealer = new Gtk.Revealer () {
child = update_button
};

var header_box = new Gtk.Box (HORIZONTAL, 6) {
hexpand = true
var header_box = new Gtk.CenterBox () {
hexpand = true,
start_widget = back_button,
center_widget = title_label,
end_widget = update_button_revealer
};
header_box.pack_start (back_button);
header_box.set_center_widget (title_label);
header_box.pack_end (update_button_revealer);

summary_label = new Gtk.Label ("") {
halign = START,
wrap = true
};
summary_label.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL);
summary_label.add_css_class (Granite.STYLE_CLASS_H2_LABEL);

description_label = new Gtk.Label ("") {
halign = START,
Expand Down Expand Up @@ -114,7 +114,7 @@ public class About.FirmwareReleaseView : Gtk.Box {
margin_top = 12,
row_spacing = 3
};
key_val_grid.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL);
key_val_grid.add_css_class (Granite.STYLE_CLASS_DIM_LABEL);

key_val_grid.attach (version_label, 0, 0);
key_val_grid.attach (version_value_label, 1, 0);
Expand All @@ -125,12 +125,9 @@ public class About.FirmwareReleaseView : Gtk.Box {
key_val_grid.attach (install_duration_label, 0, 3);
key_val_grid.attach (install_duration_value_label, 1, 3);

placeholder = new Granite.Widgets.AlertView (
"",
_("There are no releases available for this device."),
""
);
placeholder.get_style_context ().remove_class (Gtk.STYLE_CLASS_VIEW);
placeholder = new Granite.Placeholder ("") {
description = _("There are no releases available for this device.")
};

var box = new Gtk.Box (VERTICAL, 12) {
halign = CENTER,
Expand All @@ -140,26 +137,25 @@ public class About.FirmwareReleaseView : Gtk.Box {
margin_start = 12,
vexpand = true
};
box.add (summary_label);
box.add (description_label);
box.add (key_val_grid);
box.append (summary_label);
box.append (description_label);
box.append (key_val_grid);

scrolled_window = new Gtk.ScrolledWindow (null, null) {
scrolled_window = new Gtk.ScrolledWindow () {
child = box,
hscrollbar_policy = NEVER,
vexpand = true
};

stack = new Gtk.Stack ();
stack.add (placeholder);
stack.add (scrolled_window);
stack.add_child (placeholder);
stack.add_child (scrolled_window);

orientation = VERTICAL;
get_style_context ().add_class (Gtk.STYLE_CLASS_VIEW);
add (header_box);
add (new Gtk.Separator (HORIZONTAL));
add (stack);
show_all ();
add_css_class (Granite.STYLE_CLASS_VIEW);
append (header_box);
append (new Gtk.Separator (HORIZONTAL));
append (stack);

back_button.clicked.connect (() => {
go_back ();
Expand All @@ -185,9 +181,9 @@ public class About.FirmwareReleaseView : Gtk.Box {

var icons = device.get_icons ();
if (icons.data != null) {
placeholder.icon_name = icons.data[0];
placeholder.icon = new ThemedIcon (icons.data[0]);
} else {
placeholder.icon_name = "application-x-firmware";
placeholder.icon = new ThemedIcon ("application-x-firmware");
}

stack.visible_child = placeholder;
Expand Down Expand Up @@ -227,13 +223,11 @@ public class About.FirmwareReleaseView : Gtk.Box {
} else {
install_duration_value_label.label = GLib.ngettext ("%llu minute", "%llu minutes", duration_minutes).printf (duration_minutes);
}

show_all ();
}

private void go_back () {
if (deck == null) {
deck = (Hdy.Deck) get_ancestor (typeof (Hdy.Deck));
deck = (Adw.Leaflet) get_ancestor (typeof (Adw.Leaflet));
}

deck.navigate (BACK);
Expand Down
Loading

0 comments on commit a87e106

Please sign in to comment.