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

Clean up buttons #283

Merged
merged 4 commits into from
Jan 22, 2024
Merged
Changes from all commits
Commits
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
70 changes: 17 additions & 53 deletions src/Views/OperatingSystemView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public class About.OperatingSystemView : Gtk.Box {
private Gtk.StringList updates;
private SystemUpdate? update_proxy = null;
private Gtk.Grid software_grid;
private Gtk.Button check_button;
private Gtk.Image updates_image;
private Gtk.Label updates_title;
private Gtk.Label updates_description;
Expand Down Expand Up @@ -124,7 +123,10 @@ public class About.OperatingSystemView : Gtk.Box {
_("Suggest Translations")
);

var bug_button = new Gtk.Button.with_label (_("Send Feedback"));
var bug_button = new Gtk.Button.with_label (_("Send Feedback")) {
halign = END,
hexpand = true
};

updates = new Gtk.StringList (null);

Expand All @@ -142,8 +144,7 @@ public class About.OperatingSystemView : Gtk.Box {
};

updates_image = new Gtk.Image () {
icon_size = LARGE,
margin_end = 6
icon_size = LARGE
};

updates_title = new Gtk.Label (null) {
Expand All @@ -158,35 +159,26 @@ public class About.OperatingSystemView : Gtk.Box {
updates_description.add_css_class (Granite.STYLE_CLASS_SMALL_LABEL);
updates_description.add_css_class (Granite.STYLE_CLASS_DIM_LABEL);

var update_button = new Gtk.Button.with_label (_("Download")) {
margin_start = 6,
margin_end = 6,
valign = CENTER
};
var update_button = new Gtk.Button.with_label (_("Download"));
update_button.add_css_class (Granite.STYLE_CLASS_SUGGESTED_ACTION);

var cancel_button = new Gtk.Button.with_label (_("Cancel")) {
margin_start = 6,
margin_end = 6,
valign = CENTER
};
var cancel_button = new Gtk.Button.with_label (_("Cancel"));

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

button_stack = new Gtk.Stack () {
transition_type = CROSSFADE
transition_type = CROSSFADE,
valign = CENTER
};
button_stack.add_named (new Gtk.Grid (), "blank");
button_stack.add_named (update_button, "update");
button_stack.add_named (cancel_button, "cancel");
button_stack.add_named (error_button, "error");
button_stack.add_named (refresh_button, "refresh");

var updates_grid = new Gtk.Grid () {
column_spacing = 6,
margin_top = 6,
margin_end = 6,
margin_bottom = 6,
margin_start = 6
};
Expand All @@ -203,21 +195,11 @@ public class About.OperatingSystemView : Gtk.Box {
};
frame.add_css_class (Granite.STYLE_CLASS_VIEW);

check_button = new Gtk.Button.with_label (_("Check for Updates"));

var settings_restore_button = new Gtk.Button.with_label (_("Restore Default Settings"));

var primary_button_box = new Gtk.Box (HORIZONTAL, 6) {
hexpand = true,
halign = END,
homogeneous = true
};
primary_button_box.append (bug_button);
primary_button_box.append (check_button);

var button_grid = new Gtk.Box (HORIZONTAL, 6);
button_grid.append (settings_restore_button);
button_grid.append (primary_button_box);
button_grid.append (bug_button);

software_grid = new Gtk.Grid () {
column_spacing = 32,
Expand Down Expand Up @@ -272,18 +254,6 @@ public class About.OperatingSystemView : Gtk.Box {
}
});

check_button.clicked.connect (() => {
if (update_proxy != null) {
update_proxy.check_for_updates.begin (false, false, (obj, res) => {
try {
update_proxy.check_for_updates.end (res);
} catch (Error e) {
critical ("Failed to check for updates: %s", e.message);
}
});
}
});

update_button.clicked.connect (() => {
if (update_proxy != null) {
update_proxy.update.begin ((obj, res) => {
Expand All @@ -308,7 +278,7 @@ public class About.OperatingSystemView : Gtk.Box {
}
});

error_button.clicked.connect (() => {
refresh_button.clicked.connect (() => {
if (update_proxy != null) {
update_proxy.check_for_updates.begin (true, false, (obj, res) => {
try {
Expand Down Expand Up @@ -382,20 +352,17 @@ public class About.OperatingSystemView : Gtk.Box {
new DateTime.from_unix_local (update_settings.get_int64 ("last-refresh-time"))
)
);
check_button.sensitive = true;
button_stack.visible_child_name = "blank";
button_stack.visible_child_name = "refresh";
break;
case CHECKING:
updates_image.icon_name = "emblem-synchronized";
updates_title.label = _("Checking for Updates");
updates_description.label = current_state.message;
check_button.sensitive = false;
button_stack.visible_child_name = "blank";
break;
case AVAILABLE:
updates_image.icon_name = "software-update-available";
updates_title.label = _("Updates Available");
check_button.sensitive = true;
button_stack.visible_child_name = "update";

try {
Expand All @@ -416,22 +383,19 @@ public class About.OperatingSystemView : Gtk.Box {
updates_image.icon_name = "browser-download";
updates_title.label = _("Downloading Updates");
updates_description.label = current_state.message;
check_button.sensitive = false;
button_stack.visible_child_name = "cancel";
break;
case RESTART_REQUIRED:
updates_image.icon_name = "system-reboot";
updates_title.label = _("Restart Required");
updates_description.label = _("A restart is required to finish installing updates");
check_button.sensitive = false;
button_stack.visible_child_name = "blank";
break;
case ERROR:
updates_image.icon_name = "dialog-error";
updates_title.label = _("Failed to download updates");
updates_description.label = _("Manually refreshing updates may resolve the issue.");
check_button.sensitive = false;
button_stack.visible_child_name = "error";
button_stack.visible_child_name = "refresh";
break;
}
}
Expand Down
Loading