Commit d4a0047e authored by Petr Štětka's avatar Petr Štětka
Browse files

Hide Stop button for "dangerous" processes.

No processes label dim.
parent cf95b887
<schemalist>
<schema id="org.gnome.Usage" path="/org/gnome/Usage/" gettext-domain="gnome-usage">
<key name="unkillable-processes" type="as">
<default>['gnome-shell']</default>
<summary>A list of processes, which we don't want kill</summary>
<description>This list is used for filtering, which processes user can't stop.</description>
</key>
</schema>
</schemalist>
\ No newline at end of file
......@@ -159,6 +159,7 @@ translate: c src/../external/rg/rg-stacked-renderer.c
translate: c src/../external/rg/rg-table.c
*translate: vala src/storage-row.vala
*translate: vala src/performance-view.vala
*translate: vala src/window.vala
*translate: vala src/cpu-graph.vala
*translate: vala src/system-monitor.vala
*translate: vala src/network-graph.vala
......@@ -166,8 +167,6 @@ translate: c src/../external/rg/rg-table.c
*translate: vala src/process-list-box.vala
*translate: vala src/disk-graph.vala
*translate: vala src/cpu-monitor.vala
*translate: vala src/process-row.vala
*translate: vala src/window.vala
*translate: vala src/disk-sub-view.vala
*translate: vala src/memory-monitor.vala
*translate: vala src/graph-stack-switcher.vala
......@@ -178,8 +177,10 @@ translate: c src/../external/rg/rg-table.c
*translate: vala src/network-sub-view.vala
*translate: vala src/memory-sub-view.vala
*translate: vala src/cpu-graph-table.vala
*translate: vala src/process-dialog.vala
*translate: vala src/graph-block.vala
*translate: vala src/memory-graph-table.vala
*translate: vala src/process-row.vala
*translate: vala src/process.vala
*translate: vala src/network-monitor.vala
*translate: vala src/data-view.vala
......@@ -187,10 +188,9 @@ translate: c src/../external/rg/rg-table.c
*translate: vala src/storage-main-list-box.vala
*translate: vala src/storage-graph.vala
*translate: vala src/view.vala
*translate: vala src/process-dialog.vala
*translate: vala src/sub-process-sub-row.vala
*translate: vala src/utils.vala
*translate: vala src/sub-process-list-box.vala
*translate: vala src/sub-process-sub-row.vala
*translate: vala src/pie-chart.vala
*translate: vala src/color-rectangle.vala
*translate: vala src/storage-list.vala
......@@ -204,3 +204,5 @@ translate: c src/../external/rg/rg-table.c
*desktop: data/org.gnome.Usage.desktop
scheme: data/org.gnome.Usage.gschema.xml
......@@ -34,6 +34,7 @@ namespace Usage
var no_process_label = new Gtk.Label("<span font_desc=\"14.0\">" + _("No application using processor.") + "</span>");
no_process_label.set_use_markup(true);
no_process_label.get_style_context().add_class("dim-label");
(GLib.Application.get_default() as Application).get_system_monitor().cpu_processes_ready.connect(() =>
{
......
......@@ -5,7 +5,9 @@ namespace Usage
public DiskSubView()
{
name = "DISK";
var label = new Gtk.Label("What library we can use for disk I/O usage?");
var label = new Gtk.Label("<span font_desc=\"14.0\">" + "What library we can use for disk I/O usage?" + "</span>");
label.set_use_markup(true);
label.get_style_context().add_class("dim-label");
this.add(label);
}
}
......
......@@ -34,6 +34,7 @@ namespace Usage
var no_process_label = new Gtk.Label("<span font_desc=\"14.0\">" + _("No application using memory.") + "</span>");
no_process_label.set_use_markup(true);
no_process_label.get_style_context().add_class("dim-label");
(GLib.Application.get_default() as Application).get_system_monitor().cpu_processes_ready.connect(() =>
{
......
......@@ -33,6 +33,7 @@ namespace Usage
var no_process_label = new Gtk.Label("<span font_desc=\"14.0\">" + _("No application using network.") + "</span>");
no_process_label.set_use_markup(true);
no_process_label.get_style_context().add_class("dim-label");
(GLib.Application.get_default() as Application).get_system_monitor().cpu_processes_ready.connect(() =>
{
......
......@@ -6,13 +6,14 @@ namespace Usage
{
ProcessDialogHeaderBar headerbar;
pid_t pid;
string process;
GraphBlock processor_graph_block;
GraphBlock memory_graph_block;
GraphBlock disk_graph_block;
GraphBlock downloads_graph_block;
GraphBlock uploads_graph_block;
public ProcessDialog(pid_t pid, string app_name)
public ProcessDialog(pid_t pid, string app_name, string process)
{
Object(use_header_bar: 1);
set_modal(true);
......@@ -21,6 +22,7 @@ namespace Usage
set_resizable(false);
this.pid = pid;
this.title = app_name;
this.process = process;
this.border_width = 5;
set_default_size (900, 350);
create_widgets();
......@@ -52,7 +54,7 @@ namespace Usage
var stop_button = new Gtk.Button.with_label(_("Stop"));
stop_button.get_style_context().add_class ("destructive-action");
headerbar = new ProcessDialogHeaderBar(stop_button, pid, this.title);
headerbar = new ProcessDialogHeaderBar(stop_button, pid, this.title, process);
set_titlebar(headerbar);
Timeout.add((GLib.Application.get_default() as Application).settings.list_update_pie_charts_UI, update);
......@@ -111,11 +113,13 @@ namespace Usage
{
private Gtk.Label label;
private string app_name;
private string process;
private Gtk.Button stop_button;
public ProcessDialogHeaderBar(Gtk.Button stop_button, pid_t pid, string app_name)
public ProcessDialogHeaderBar(Gtk.Button stop_button, pid_t pid, string app_name, string process)
{
this.app_name = app_name;
this.process = process;
show_close_button = true;
this.stop_button = stop_button;
......@@ -126,7 +130,8 @@ namespace Usage
var box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
box.hexpand = true;
box.pack_start(stop_button, false, false);
if(show_stop_button(process))
box.pack_start(stop_button, false, false);
label = new Gtk.Label(null);
label.justify = Gtk.Justification.CENTER;
box.set_center_widget(label);
......@@ -135,6 +140,14 @@ namespace Usage
show_all();
}
private bool show_stop_button(string process)
{
var settings = new GLib.Settings ("org.gnome.Usage");
var unkillable_processes = settings.get_strv ("unkillable-processes");
return !(process in unkillable_processes);
}
private void kill_process(pid_t pid)
{
Posix.kill (pid, Posix.SIGKILL);
......
......@@ -243,7 +243,7 @@ namespace Usage
}
else
{
var dialog = new ProcessDialog(process.get_pid(), display_name);
var dialog = new ProcessDialog(process.get_pid(), display_name, process.get_cmdline());
dialog.show_all();
}
}
......
......@@ -74,7 +74,7 @@ namespace Usage
public new void activate()
{
var dialog = new ProcessDialog(process.get_pid(), process.get_cmdline());
var dialog = new ProcessDialog(process.get_pid(), process.get_cmdline(), process.get_cmdline());
dialog.show_all();
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment