Skip to content

Commit

Permalink
Add error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
leolost2605 committed Jan 22, 2024
1 parent 905c1db commit 3006e87
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/DBus/SystemUpdate.vala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ public interface SystemUpdate : Object {
CHECKING,
AVAILABLE,
DOWNLOADING,
RESTART_REQUIRED
RESTART_REQUIRED,
ERROR
}

public struct CurrentState {
Expand Down
18 changes: 16 additions & 2 deletions src/Views/OperatingSystemView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class About.OperatingSystemView : Gtk.Box {
private Gtk.Label updates_description;
private Gtk.Revealer update_button_revealer;
private Gtk.Revealer cancel_button_revealer;
private Gtk.Revealer error_button_revealer;

construct {
var style_provider = new Gtk.CssProvider ();
Expand Down Expand Up @@ -161,7 +162,7 @@ public class About.OperatingSystemView : Gtk.Box {
margin_end = 6,
valign = CENTER
};
update_button.add_css_class (Granite.STYLE_CLASS_SUGGESTED_ACTION)
update_button.add_css_class (Granite.STYLE_CLASS_SUGGESTED_ACTION);

update_button_revealer = new Gtk.Revealer () {
child = update_button,
Expand All @@ -175,7 +176,18 @@ public class About.OperatingSystemView : Gtk.Box {
};

cancel_button_revealer = new Gtk.Revealer () {
child = update_button,
child = cancel_button,
overflow = VISIBLE,
transition_type = SLIDE_LEFT
};

var error_button = new Gtk.Button.with_label (_("Refresh")) {
margin_end = 6,
valign = CENTER
};

error_button_revealer = new Gtk.Revealer () {
child = error_button,
overflow = VISIBLE,
transition_type = SLIDE_LEFT
};
Expand All @@ -190,6 +202,7 @@ public class About.OperatingSystemView : Gtk.Box {
updates_grid.attach (updates_description, 1, 1);
updates_grid.attach (update_button_revealer, 2, 0, 1, 2);
updates_grid.attach (cancel_button_revealer, 3, 0, 1, 2);
updates_grid.attach (error_button_revealer, 2, 0, 1, 2);

var frame = new Gtk.Frame (null) {
child = updates_grid,
Expand Down Expand Up @@ -359,6 +372,7 @@ public class About.OperatingSystemView : Gtk.Box {

update_button_revealer.reveal_child = current_state.state == AVAILABLE;
cancel_button_revealer.reveal_child = current_state.state == DOWNLOADING;
error_button_revealer.reveal_child = current_state.state == ERROR;

switch (current_state.state) {
case UP_TO_DATE:
Expand Down

0 comments on commit 3006e87

Please sign in to comment.