Skip to content
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
80 changes: 35 additions & 45 deletions src/Views/ProcessView/ProcessInfoView/ProcessInfoView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
*/

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

private Process _process;
public Process ? process {
public Process? process {
get {
return _process;
}
Expand Down Expand Up @@ -45,68 +42,47 @@ public class Monitor.ProcessInfoView : Gtk.Box {
}
}
}
public string ? icon_name;

private Gtk.Box process_action_bar;
private ProcessInfoIOStats process_info_io_stats;

private Gtk.InfoBar permission_error_infobar;
private Gtk.Label permission_error_label;

private ProcessInfoHeader process_info_header;
private ProcessInfoCPURAM process_info_cpu_ram;

private Gtk.Button end_process_button;
private Gtk.Button kill_process_button;

public ProcessInfoView () {
orientation = Gtk.Orientation.VERTICAL;
hexpand = true;
construct {
permission_error_label = new Gtk.Label (Utils.NO_DATA);

permission_error_infobar = new Gtk.InfoBar () {
message_type = Gtk.MessageType.ERROR,
revealed = false,
message_type = ERROR,
revealed = false
};
permission_error_label = new Gtk.Label (Utils.NO_DATA);
permission_error_infobar.add_child (permission_error_label);
append (permission_error_infobar);

var grid = new Gtk.Grid () {
margin_top = 12,
margin_bottom = 12,
margin_start = 12,
margin_end = 12,
hexpand = true,
column_spacing = 12
};
append (grid);


process_info_header = new ProcessInfoHeader ();
grid.attach (process_info_header, 0, 0, 1, 1);

var separator = new Gtk.Separator (Gtk.Orientation.HORIZONTAL) {
var separator = new Gtk.Separator (HORIZONTAL) {
margin_top = 12,
margin_bottom = 12,
margin_start = 12,
margin_end = 12,
hexpand = true
margin_bottom = 12
};
grid.attach (separator, 0, 1, 1, 1);

process_info_cpu_ram = new ProcessInfoCPURAM ();
process_info_cpu_ram.hide ();
grid.attach (process_info_cpu_ram, 0, 2, 1, 1);

grid.attach (process_info_io_stats, 0, 4, 1, 1);
process_info_io_stats = new ProcessInfoIOStats ();

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

kill_process_button = new Gtk.Button.with_label (_("Force Quit…")) {
var kill_process_button = new Gtk.Button.with_label (_("Force Quit…")) {
tooltip_markup = Granite.markup_accel_tooltip ({ "<Ctrl>K" })
};
kill_process_button.add_css_class (Granite.CssClass.DESTRUCTIVE);

process_action_bar = new Gtk.Box (HORIZONTAL, 12) {
process_action_bar = new Granite.Box (HORIZONTAL) {
halign = END,
valign = END,
homogeneous = true,
Expand All @@ -115,9 +91,26 @@ public class Monitor.ProcessInfoView : Gtk.Box {
process_action_bar.append (end_process_button);
process_action_bar.append (kill_process_button);

var box = new Granite.Box (VERTICAL) {
margin_top = 12,
margin_bottom = 12,
margin_start = 12,
margin_end = 12
};
box.append (process_info_header);
box.append (separator);
box.append (process_info_cpu_ram);
box.append (process_info_io_stats);
box.append (process_action_bar);

orientation = VERTICAL;
hexpand = true;
append (permission_error_infobar);
append (box);

kill_process_button.clicked.connect (() => {
var confirmation_dialog = new Granite.MessageDialog (
_("Force “%s” to quit without initiating shutdown tasks?").printf (process_info_header.application_name.label),
_("Force “%s” to quit without initiating shutdown tasks?").printf (process.application_name),
_("This may lead to data loss. Only Force Quit if Shut Down has failed."),
new ThemedIcon ("computer-fail"),
Gtk.ButtonsType.CANCEL
Expand All @@ -144,11 +137,11 @@ public class Monitor.ProcessInfoView : Gtk.Box {

end_process_button.clicked.connect (() => {
var confirmation_dialog = new Granite.MessageDialog (
_("Ask “%s” to shut down?").printf (process_info_header.application_name.label),
_("Ask “%s” to shut down?").printf (process.application_name),
_("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_root ()
Expand All @@ -168,13 +161,11 @@ public class Monitor.ProcessInfoView : Gtk.Box {

confirmation_dialog.present ();
});

grid.attach (process_action_bar, 0, 5);
}

private void show_permission_error_infobar (string error) {
if (!permission_error_infobar.revealed) {
permission_error_label.set_text (error);
permission_error_label.label = error;
permission_error_infobar.revealed = true;
}
}
Expand All @@ -190,5 +181,4 @@ public class Monitor.ProcessInfoView : Gtk.Box {
process_info_io_stats.open_files_tree_view.visible = true;
}
}

}