Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion po/POTFILES
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ src/Monitor.vala
src/MainWindow.vala
src/Utils.vala
src/Indicator/Widgets/PopoverWidget.vala
src/Views/ProcessView/ProcessInfoView/Preventor.vala
src/Views/ProcessView/ProcessInfoView/ProcessInfoHeader.vala
src/Views/ProcessView/ProcessInfoView/ProcessInfoIOStats.vala
src/Views/ProcessView/ProcessInfoView/ProcessInfoView.vala
Expand Down
63 changes: 0 additions & 63 deletions src/Views/ProcessView/ProcessInfoView/Preventor.vala

This file was deleted.

90 changes: 63 additions & 27 deletions src/Views/ProcessView/ProcessInfoView/ProcessInfoView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

public class Monitor.ProcessInfoView : Gtk.Box {
private Preventor preventor;
private Gtk.Box process_action_bar;
private ProcessInfoIOStats process_info_io_stats = new ProcessInfoIOStats ();

private Process _process;
Expand All @@ -25,7 +25,7 @@ public class Monitor.ProcessInfoView : Gtk.Box {
if (_process.uid != Posix.getuid ()) {
process_info_cpu_ram.hide ();
process_info_io_stats.hide ();
preventor.hide ();
process_action_bar.hide ();
} else {
_process.fd_permission_error.connect (show_permission_error_infobar);

Expand Down Expand Up @@ -86,48 +86,84 @@ public class Monitor.ProcessInfoView : Gtk.Box {

grid.attach (process_info_io_stats, 0, 4, 1, 1);

end_process_button = new Gtk.Button.with_label (_("Shut Down…")) {
tooltip_markup = Granite.markup_accel_tooltip ({ "<Ctrl>E" })
};

var process_action_bar = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
process_action_bar.margin_top = 12;
process_action_bar.valign = Gtk.Align.END;
process_action_bar.halign = Gtk.Align.END;

end_process_button = new Gtk.Button.with_label (_("End Process"));
end_process_button.margin_end = 10;
end_process_button.tooltip_markup = Granite.markup_accel_tooltip ({ "<Ctrl>E" }, _("End selected process"));
var end_process_button_context = end_process_button.get_style_context ();
end_process_button_context.add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);

kill_process_button = new Gtk.Button.with_label (_("Kill Process"));
kill_process_button.tooltip_markup = Granite.markup_accel_tooltip ({ "<Ctrl>K" }, _("Kill selected process"));
var kill_process_button_context = kill_process_button.get_style_context ();
kill_process_button_context.add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION);
kill_process_button = new Gtk.Button.with_label (_("Force Quit…")) {
tooltip_markup = Granite.markup_accel_tooltip ({ "<Ctrl>K" })
};
kill_process_button.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION);

process_action_bar = new Gtk.Box (HORIZONTAL, 12) {
halign = END,
valign = END,
homogeneous = true,
margin_top = 12
};
process_action_bar.add (end_process_button);
process_action_bar.add (kill_process_button);

preventor = new Preventor (process_action_bar, "process_action_bar");

kill_process_button.clicked.connect (() => {
preventor.set_prevention (_("Confirm kill of the process?"));
preventor.confirmed.connect ((is_confirmed) => {
if (is_confirmed) process.kill (); // maybe add a toast that process killed
var confirmation_dialog = new Granite.MessageDialog (
_("Force “%s” to quit without initiating shutdown tasks?").printf (process_info_header.application_name.label),
_("This may lead to data loss. Only Force Quit if Shut Down has failed."),
new ThemedIcon ("computer-fail"),
Gtk.ButtonsType.CANCEL
) {
badge_icon = new ThemedIcon ("process-stop"),
modal = true,
transient_for = (Gtk.Window) get_toplevel ()
};

var accept_button = confirmation_dialog.add_button (_("Force Quit"), Gtk.ResponseType.ACCEPT);
accept_button.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION);

confirmation_dialog.response.connect ((response) => {
if (response == Gtk.ResponseType.ACCEPT) {
// TODO: maybe add a toast that process killed
process.kill ();
}

confirmation_dialog.close ();
});

confirmation_dialog.present ();
});

end_process_button.clicked.connect (() => {
preventor.set_prevention (_("Confirm end of the process?"));
preventor.confirmed.connect ((is_confirmed) => {
if (is_confirmed) process.end (); // maybe add a toast that process ended
var confirmation_dialog = new Granite.MessageDialog (
_("Ask “%s” to shut down?").printf (process_info_header.application_name.label),
_("The process will be asked to initiate shutdown tasks and close. In some cases the process may not quit."),
new ThemedIcon ("system-shutdown"),
Gtk.ButtonsType.CANCEL
) {
badge_icon = new ThemedIcon ("dialog-question"),
modal = true,
transient_for = (Gtk.Window) get_toplevel ()
};

var accept_button = confirmation_dialog.add_button (_("Shut Down"), Gtk.ResponseType.ACCEPT);
accept_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);

confirmation_dialog.response.connect ((response) => {
if (response == Gtk.ResponseType.ACCEPT) {
// TODO: maybe add a toast that process killed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm inclined toward adding a toast or notification before merging, instead of leaving it to another request. For Shutdown, it's important that the user knows whether or not the request was successfully fulfilled, or if they need to think about Force Quitting instead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was already a leftover TODO from main. I'm not adding any functionality here. I'd prefer to leave that to a follow up since I didn't introduce that problem in this branch

process.end ();
}

confirmation_dialog.close ();
});

confirmation_dialog.present ();
});

grid.attach (preventor, 0, 5, 1, 1);
grid.attach (process_action_bar, 0, 5);

show_all ();
process_info_cpu_ram.hide ();
process_info_io_stats.hide ();
preventor.hide ();
process_action_bar.hide ();
}

private void show_permission_error_infobar (string error) {
Expand Down
1 change: 0 additions & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ source_app_files = [
'Views/SystemView/SystemGPUView.vala',

# Widgets related only to ProcessInfoView
'Views/ProcessView/ProcessInfoView/Preventor.vala',
'Views/ProcessView/ProcessInfoView/ProcessInfoHeader.vala',
'Views/ProcessView/ProcessInfoView/ProcessInfoCPURAM.vala',
'Views/ProcessView/ProcessInfoView/ProcessInfoIOStats.vala',
Expand Down