Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add detail page for firmware releases - Revenge of libfwupd #206

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c993930
Install libappstream-dev as dependency
meisenzahl Mar 10, 2021
ee8afe7
Add and use FirmwareReleaseView
meisenzahl Mar 10, 2021
321e280
FirmwareReleaseView: Emit signal to update
meisenzahl Mar 10, 2021
fda07bd
Move update logic to FirmwareView
meisenzahl Mar 10, 2021
f20609a
FirmwareReleaseView: Go back if trying to install update
meisenzahl Mar 10, 2021
978cd89
Refactor
meisenzahl Mar 11, 2021
991e073
Suggest to update
meisenzahl Mar 11, 2021
ea8abc7
Merge branch 'master' into add-detail-page-for-firmware-releases--rev…
danirabbit Mar 25, 2021
2e6a5c0
FirmwareReleaseView: signals at the top, construct before functions
danirabbit Mar 25, 2021
88e2d8a
FirmwareReleaseView: group calls to this
danirabbit Mar 25, 2021
a4124c1
FirmwareReleaseView: Remove unused label
danirabbit Mar 25, 2021
c14161e
FirmwareReleaseView: cache deck once found
danirabbit Mar 25, 2021
0889a5d
FirmwareReleaseView: Only set fallback if icons.data is null
danirabbit Mar 25, 2021
cd628eb
FirmwareUpdateRow: cache updatable
danirabbit Mar 25, 2021
e631868
FirwareUpdateRow: signal at the top
danirabbit Mar 25, 2021
e8af299
FirmwareUpdateRow: Set is updatable on construct since we have to che…
danirabbit Mar 25, 2021
81a8104
FirwareUpdateRow: Only one suggested action per context
danirabbit Mar 25, 2021
b2f4084
FirwareUpdateRow: Reduce scope of image
danirabbit Mar 25, 2021
e939b71
FirmwareReleaseView: simplify update button logic
danirabbit Mar 25, 2021
38f4a1d
FirmwareView: Use Granite.MessageDialog with gicon
danirabbit Mar 25, 2021
760fac3
FirmwareView: Correctly return on cancel
danirabbit Mar 25, 2021
552c85e
FirmwareView: Remove extra grids
danirabbit Mar 25, 2021
eb3dd84
FirmwareView: Use add_button in message dialogs
danirabbit Mar 25, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Install Dependencies
run: |
apt update
apt install -y meson libfwupd-dev libgranite-dev libgtk-3-dev libgtop2-dev libhandy-1-dev libswitchboard-2.0-dev valac
apt install -y meson libfwupd-dev libgranite-dev libgtk-3-dev libgtop2-dev libhandy-1-dev libswitchboard-2.0-dev libappstream-dev valac
- name: Build
env:
DESTDIR: out
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ You'll need the following dependencies:
* libgtk-3-dev
* libgtop2-dev
* libhandy-1-dev
* libappstream-dev
* meson
* valac
* switcheroo-control (at runtime)
Expand Down
1 change: 1 addition & 0 deletions po/POTFILES
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
src/Plug.vala
src/Views/FirmwareReleaseView.vala
src/Views/FirmwareView.vala
src/Views/HardwareView.vala
src/Views/OperatingSystemView.vala
Expand Down
243 changes: 243 additions & 0 deletions src/Views/FirmwareReleaseView.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
/*
* Copyright (c) 2021 elementary, Inc. (https://elementary.io)
*
* 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 3 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, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* Authored by: Marius Meisenzahl <mariusmeisenzahl@gmail.com>
*/

public class About.FirmwareReleaseView : Gtk.Grid {
public signal void update (Fwupd.Device device, Fwupd.Release release);

private Fwupd.Device device;
private Fwupd.Release? release;
private Granite.Widgets.AlertView placeholder;
private Gtk.ScrolledWindow scrolled_window;
private Gtk.Stack content;
private Gtk.Revealer update_button_revealer;
private Gtk.Button update_button;
private Gtk.Label title_label;
private Gtk.Label summary_label;
private Gtk.Label description_label;
private Gtk.Label version_value_label;
private Gtk.Label vendor_value_label;
private Gtk.Label size_value_label;
private Gtk.Label install_duration_value_label;
private Hdy.Deck? deck;

construct {
var back_button = new Gtk.Button.with_label (_("All Updates")) {
halign = Gtk.Align.START,
margin = 6
};
back_button.get_style_context ().add_class (Granite.STYLE_CLASS_BACK_BUTTON);

title_label = new Gtk.Label ("") {
ellipsize = Pango.EllipsizeMode.END,
use_markup = true
};

update_button = new Gtk.Button.with_label ("") {
halign = Gtk.Align.END,
margin = 6,
sensitive = false
};
update_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);

update_button_revealer = new Gtk.Revealer ();
update_button_revealer.add (update_button);

var header_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6) {
hexpand = true
};
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 = Gtk.Align.START,
wrap = true
};
summary_label.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL);

description_label = new Gtk.Label ("") {
halign = Gtk.Align.START,
wrap = true
};

var version_label = new Gtk.Label (_("Version:")) {
xalign = 1
};

version_value_label = new Gtk.Label ("") {
xalign = 0,
hexpand = true
};

var vendor_label = new Gtk.Label (_("Vendor:")) {
xalign = 1
};

vendor_value_label = new Gtk.Label ("") {
xalign = 0,
hexpand = true
};

var size_label = new Gtk.Label (_("Size:")) {
xalign = 1
};

size_value_label = new Gtk.Label ("") {
xalign = 0,
hexpand = true
};

var install_duration_label = new Gtk.Label (_("Estimated time to install:")) {
xalign = 1
};

install_duration_value_label = new Gtk.Label ("") {
xalign = 0,
hexpand = true
};

var key_val_grid = new Gtk.Grid () {
column_homogeneous = true,
column_spacing = 6,
halign = Gtk.Align.CENTER,
margin_top = 12,
row_spacing = 3
};
key_val_grid.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL);

key_val_grid.attach (version_label, 0, 0);
key_val_grid.attach (version_value_label, 1, 0);
key_val_grid.attach (vendor_label, 0, 1);
key_val_grid.attach (vendor_value_label, 1, 1);
key_val_grid.attach (size_label, 0, 2);
key_val_grid.attach (size_value_label, 1, 2);
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);

var grid = new Gtk.Grid () {
halign = Gtk.Align.CENTER,
margin = 12,
orientation = Gtk.Orientation.VERTICAL,
row_spacing = 12,
vexpand = true
};
grid.add (summary_label);
grid.add (description_label);
grid.add (key_val_grid);

scrolled_window = new Gtk.ScrolledWindow (null, null) {
hscrollbar_policy = Gtk.PolicyType.NEVER,
vexpand = true
};
scrolled_window.add (grid);

content = new Gtk.Stack ();
content.add (placeholder);
content.add (scrolled_window);

orientation = Gtk.Orientation.VERTICAL;
get_style_context ().add_class (Gtk.STYLE_CLASS_VIEW);
add (header_box);
add (new Gtk.Separator (Gtk.Orientation.HORIZONTAL));
add (content);
show_all ();

back_button.clicked.connect (() => {
go_back ();
});

update_button.clicked.connect (() => {
go_back ();
update (device, release);
});
}

public void update_view (Fwupd.Device device, Fwupd.Release? release) {
this.device = device;
this.release = release;

var device_name = device.get_name ();

title_label.label = "<b>%s</b>".printf (device_name);
update_button_revealer.reveal_child = release != null;

if (release == null) {
placeholder.title = device_name;

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

content.visible_child = placeholder;

return;
}

content.visible_child = scrolled_window;

var release_version = release.get_version ();
if (release.get_flags () == Fwupd.RELEASE_FLAG_IS_UPGRADE && release_version != device.get_version ()) {
update_button.label = _("Update");
update_button.sensitive = true;
} else {
update_button.label = _("Up to date");
update_button.sensitive = false;
}

summary_label.label = release.get_summary ();
try {
description_label.label = AppStream.markup_convert_simple (release.get_description ());
} catch (Error e) {
description_label.label = "";
warning ("Could not convert markup of release: %s", e.message);
}
version_value_label.label = release_version;
vendor_value_label.label = release.get_vendor ();
size_value_label.label = GLib.format_size (release.get_size ());

uint32 duration_minutes = release.get_install_duration () / 60;
if (duration_minutes < 1) {
install_duration_value_label.label = _("less than a minute");
} 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.navigate (Hdy.NavigationDirection.BACK);
}
}
Loading