[gnome-usage] code style: add a space before each parenthesis
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-usage] code style: add a space before each parenthesis
- Date: Fri, 10 Dec 2021 12:34:54 +0000 (UTC)
commit 1e031cd4986d556473ff6d79e1f5a05e4ca95fbe
Author: Nahuel Gomez <contact nahuelgomez com ar>
Date: Fri Dec 3 14:42:13 2021 -0300
code style: add a space before each parenthesis
Improves code consistency while aligning with other Vala projects
src/animated-scrolled-window.vala | 28 ++++----
src/app-item.vala | 72 ++++++++++----------
src/application.vala | 36 +++++-----
src/color-rectangle.vala | 32 ++++-----
src/cpu-graph-model.vala | 50 +++++++-------
src/cpu-graph.vala | 64 +++++++++---------
src/cpu-monitor.vala | 22 +++---
src/cpu-sub-view.vala | 46 ++++++-------
src/game-mode.vala | 58 ++++++++--------
src/gnome-usage.vala | 12 ++--
src/graph-box.vala | 4 +-
src/graph-stack-switcher.vala | 34 +++++-----
src/graph-stacked-renderer.vala | 24 +++----
src/graph-switcher-button.vala | 34 +++++-----
src/loading-notification.vala | 6 +-
src/memory-graph-model.vala | 28 ++++----
src/memory-graph.vala | 36 +++++-----
src/memory-monitor.vala | 12 ++--
src/memory-speedometer.vala | 12 ++--
src/memory-sub-view.vala | 52 +++++++--------
src/performance-view.vala | 14 ++--
src/pie-chart.vala | 32 ++++-----
src/primary-menu.vala | 6 +-
src/process-list-box.vala | 54 +++++++--------
src/process-row.vala | 54 +++++++--------
src/process.vala | 14 ++--
src/quit-process-dialog.vala | 10 +--
src/settings.vala | 6 +-
src/speedometer.vala | 26 ++++----
src/storage/storage-actionbar.vala | 34 +++++-----
src/storage/storage-graph.vala | 76 ++++++++++-----------
src/storage/storage-row-popover.vala | 2 +-
src/storage/storage-view-item.vala | 4 +-
src/storage/storage-view-row.vala | 34 +++++-----
src/storage/storage-view.vala | 126 +++++++++++++++++------------------
src/storage/tracker-controller.vala | 4 +-
src/swap-speedometer.vala | 14 ++--
src/system-monitor.vala | 78 +++++++++++-----------
src/utils.vala | 42 ++++++------
src/view.vala | 2 +-
src/window.vala | 52 +++++++--------
41 files changed, 673 insertions(+), 673 deletions(-)
---
diff --git a/src/animated-scrolled-window.vala b/src/animated-scrolled-window.vala
index 7e58ac5..0ba6aa6 100644
--- a/src/animated-scrolled-window.vala
+++ b/src/animated-scrolled-window.vala
@@ -1,43 +1,43 @@
using Gtk;
public class Usage.AnimatedScrolledWindow : Gtk.ScrolledWindow {
- public signal void scroll_changed(double y);
+ public signal void scroll_changed (double y);
private const uint DURATION = 400;
construct {
- get_vadjustment().value_changed.connect(() => {
- scroll_changed(get_vadjustment().get_value());
+ get_vadjustment ().value_changed.connect (() => {
+ scroll_changed (get_vadjustment ().get_value ());
});
}
- public void animated_scroll_vertically(int y) {
- var clock = get_frame_clock();
- int64 start_time = clock.get_frame_time();
+ public void animated_scroll_vertically (int y) {
+ var clock = get_frame_clock ();
+ int64 start_time = clock.get_frame_time ();
int64 end_time = start_time + 1000 * DURATION;
- double source = vadjustment.get_value();
+ double source = vadjustment.get_value ();
double target = y;
ulong tick_id = 0;
- tick_id = clock.update.connect(() => {
- int64 now = clock.get_frame_time();
+ tick_id = clock.update.connect (() => {
+ int64 now = clock.get_frame_time ();
if (!animate_step (now, start_time, end_time, source, target)) {
- clock.disconnect(tick_id);
+ clock.disconnect (tick_id);
tick_id = 0;
- clock.end_updating();
+ clock.end_updating ();
}
});
- clock.begin_updating();
+ clock.begin_updating ();
}
private bool animate_step (int64 now, int64 start_time, int64 end_time, double source, double target) {
if (now < end_time) {
double t = (now - start_time) / (double) (end_time - start_time);
t = ease_out_cubic (t);
- vadjustment.set_value(source + t * (target - source));
+ vadjustment.set_value (source + t * (target - source));
return true;
} else {
- vadjustment.set_value(target);
+ vadjustment.set_value (target);
return false;
}
}
diff --git a/src/app-item.vala b/src/app-item.vala
index fa93128..89ee8f0 100644
--- a/src/app-item.vala
+++ b/src/app-item.vala
@@ -12,7 +12,7 @@ public class Usage.AppItem : Object {
private static HashTable<string, AppInfo>? appid_map;
private AppInfo? app_info = null;
- public static void init() {
+ public static void init () {
apps_info = new HashTable<string, AppInfo> (str_hash, str_equal);
appid_map = new HashTable<string, AppInfo> (str_hash, str_equal);
@@ -29,7 +29,7 @@ public class Usage.AppItem : Object {
}
if (id == null) {
- id = info.get_id();
+ id = info.get_id ();
if (id != null && id.has_suffix (".desktop"))
id = id[0:id.length - 8];
if (id != null)
@@ -80,7 +80,7 @@ public class Usage.AppItem : Object {
/* Strip .service */
tmp = tmp[0:tmp.length-8];
/* Remove any @ element (if there) */
- escaped_id = tmp.split("@", 2)[0];
+ escaped_id = tmp.split ("@", 2)[0];
}
if (escaped_id == null)
@@ -88,7 +88,7 @@ public class Usage.AppItem : Object {
/* Now, unescape any \xXX escapes, which should only be dashes
* from the reverse domain name. */
- id = escaped_id.compress();
+ id = escaped_id.compress ();
if (id == null)
return null;
@@ -99,7 +99,7 @@ public class Usage.AppItem : Object {
AppInfo? info = null;
string ?cgroup = null;
- cgroup = Process.read_cgroup(p.pid);
+ cgroup = Process.read_cgroup (p.pid);
if (cgroup != null) {
/* Try to extract an application ID, this is a bit "magic".
* See https://systemd.io/DESKTOP_ENVIRONMENTS/
@@ -109,7 +109,7 @@ public class Usage.AppItem : Object {
string ?appid = null;
string[] components;
- components = cgroup.split("/");
+ components = cgroup.split ("/");
systemd_unit = components[components.length - 1];
appid = appid_from_unit (systemd_unit);
if (appid != null)
@@ -133,17 +133,17 @@ public class Usage.AppItem : Object {
return info != null;
}
- public AppItem(Process process) {
+ public AppItem (Process process) {
app_info = app_info_for_process (process);
representative_cmdline = process.cmdline;
representative_uid = process.uid;
- display_name = find_display_name();
- processes.insert(process.pid, process);
- load_user_account.begin();
+ display_name = find_display_name ();
+ processes.insert (process.pid, process);
+ load_user_account.begin ();
gamemode = process.gamemode;
}
- public AppItem.system() {
+ public AppItem.system () {
display_name = _("System");
representative_cmdline = "system";
}
@@ -152,47 +152,47 @@ public class Usage.AppItem : Object {
processes = new HashTable<Pid?, Process>(int_hash, int_equal);
}
- public bool contains_process(Pid pid) {
- return processes.contains(pid);
+ public bool contains_process (Pid pid) {
+ return processes.contains (pid);
}
- public Icon get_icon() {
- var app_icon = (app_info == null) ? null : app_info.get_icon();
+ public Icon get_icon () {
+ var app_icon = (app_info == null) ? null : app_info.get_icon ();
if (app_info == null || app_icon == null)
- return new GLib.ThemedIcon("system-run-symbolic");
+ return new GLib.ThemedIcon ("system-run-symbolic");
else
return app_icon;
}
- public Process get_process_by_pid(Pid pid) {
- return processes.get(pid);
+ public Process get_process_by_pid (Pid pid) {
+ return processes.get (pid);
}
- public void insert_process(Process process) {
- processes.insert(process.pid, process);
+ public void insert_process (Process process) {
+ processes.insert (process.pid, process);
}
- public void kill() {
- foreach (var process in processes.get_values()) {
+ public void kill () {
+ foreach (var process in processes.get_values ()) {
debug ("Terminating %d", (int) process.pid);
- Posix.kill(process.pid, Posix.Signal.KILL);
+ Posix.kill (process.pid, Posix.Signal.KILL);
}
}
- public void mark_as_not_updated() {
- foreach (var process in processes.get_values())
+ public void mark_as_not_updated () {
+ foreach (var process in processes.get_values ())
process.mark_as_updated = false;
}
- public void remove_processes() {
+ public void remove_processes () {
cpu_load = 0;
mem_usage = 0;
int games = 0;
- foreach (var process in processes.get_values()) {
+ foreach (var process in processes.get_values ()) {
if (!process.mark_as_updated) {
- processes.remove(process.pid);
+ processes.remove (process.pid);
} else {
cpu_load += process.cpu_load;
mem_usage += process.mem_usage;
@@ -202,25 +202,25 @@ public class Usage.AppItem : Object {
}
gamemode = games > 0;
- cpu_load = double.min(100, cpu_load);
+ cpu_load = double.min (100, cpu_load);
}
public void remove_process (Process process) {
processes.remove (process.pid);
}
- public void replace_process(Process process) {
- processes.replace(process.pid, process);
+ public void replace_process (Process process) {
+ processes.replace (process.pid, process);
}
- private string find_display_name() {
+ private string find_display_name () {
if (app_info != null)
- return app_info.get_display_name();
+ return app_info.get_display_name ();
else
return representative_cmdline;
}
- private async void load_user_account() {
+ private async void load_user_account () {
try {
Fdo.Accounts accounts = yield Bus.get_proxy (BusType.SYSTEM,
"org.freedesktop.Accounts",
@@ -234,12 +234,12 @@ public class Usage.AppItem : Object {
}
}
- private static void sanitize_cmd(ref string? commandline) {
+ private static void sanitize_cmd (ref string? commandline) {
if (commandline == null)
return;
// flatpak: parse the command line of the containerized program
- if (commandline.contains("flatpak run")) {
+ if (commandline.contains ("flatpak run")) {
var index = commandline.index_of ("--command=") + 10;
commandline = commandline.substring (index);
}
diff --git a/src/application.vala b/src/application.vala
index 895dde0..8bbc45e 100644
--- a/src/application.vala
+++ b/src/application.vala
@@ -30,34 +30,34 @@ public class Usage.Application : Gtk.Application {
application_id = Config.APPLICATION_ID;
}
- public Window? get_window() {
+ public Window? get_window () {
return window;
}
- public override void activate() {
+ public override void activate () {
if (window != null)
return;
- window = new Window(this);
+ window = new Window (this);
- set_accels_for_action("app.quit", {"<Primary>q"});
+ set_accels_for_action ("app.quit", {"<Primary>q"});
- window.show();
+ window.show ();
}
- protected override void startup() {
- base.startup();
+ protected override void startup () {
+ base.startup ();
- Hdy.init();
+ Hdy.init ();
- add_action_entries(app_entries, this);
+ add_action_entries (app_entries, this);
set_accels_for_action ("app.search", {"<Primary>f"});
var icon_theme = Gtk.IconTheme.get_default ();
icon_theme.add_resource_path ("/org/gnome/Usage/icons/hicolor");
}
- private void on_about(GLib.SimpleAction action, GLib.Variant? parameter) {
+ private void on_about (GLib.SimpleAction action, GLib.Variant? parameter) {
string[] authors = {
"Petr Štětka <pstetka redhat com>"
};
@@ -80,20 +80,20 @@ public class Usage.Application : Gtk.Application {
license_type: License.GPL_3_0);
}
- private void on_quit(GLib.SimpleAction action, GLib.Variant? parameter) {
- window.destroy();
+ private void on_quit (GLib.SimpleAction action, GLib.Variant? parameter) {
+ window.destroy ();
}
- private void on_search(GLib.SimpleAction action, GLib.Variant? parameter) {
- window.action_on_search();
+ private void on_search (GLib.SimpleAction action, GLib.Variant? parameter) {
+ window.action_on_search ();
}
private void on_activate_radio (GLib.SimpleAction action, GLib.Variant? state) {
- action.change_state(state);
+ action.change_state (state);
}
- private void change_filter_processes_state(GLib.SimpleAction action, GLib.Variant? state) {
- action.set_state(state);
- SystemMonitor.get_default().group_system_apps = state.get_string() == "group-system" ? true : false;
+ private void change_filter_processes_state (GLib.SimpleAction action, GLib.Variant? state) {
+ action.set_state (state);
+ SystemMonitor.get_default ().group_system_apps = state.get_string () == "group-system" ? true :
false;
}
}
diff --git a/src/color-rectangle.vala b/src/color-rectangle.vala
index d3209f9..41ba253 100644
--- a/src/color-rectangle.vala
+++ b/src/color-rectangle.vala
@@ -24,7 +24,7 @@ public class Usage.ColorRectangle : Gtk.DrawingArea {
public Gdk.RGBA color { get; set; }
class construct {
- set_css_name("ColorRectangle");
+ set_css_name ("ColorRectangle");
}
construct {
@@ -40,31 +40,31 @@ public class Usage.ColorRectangle : Gtk.DrawingArea {
double y = 0;
double radius = height / 5;
- context.new_sub_path();
- context.arc(x + width - radius, y + radius, radius, -90 * degrees, 0 * degrees);
- context.arc(x + width - radius, y + height - radius, radius, 0 * degrees, 90 * degrees);
- context.arc(x + radius, y + height - radius, radius, 90 * degrees, 180 * degrees);
- context.arc(x + radius, y + radius, radius, 180 * degrees, 270 * degrees);
- context.close_path();
+ context.new_sub_path ();
+ context.arc (x + width - radius, y + radius, radius, -90 * degrees, 0 * degrees);
+ context.arc (x + width - radius, y + height - radius, radius, 0 * degrees, 90 * degrees);
+ context.arc (x + radius, y + height - radius, radius, 90 * degrees, 180 * degrees);
+ context.arc (x + radius, y + radius, radius, 180 * degrees, 270 * degrees);
+ context.close_path ();
Gdk.cairo_set_source_rgba (context, color);
- context.fill();
+ context.fill ();
return true;
});
}
- public ColorRectangle.new_from_rgba(Gdk.RGBA color) {
+ public ColorRectangle.new_from_rgba (Gdk.RGBA color) {
this.color = color;
- queue_draw_area(0, 0, this.get_allocated_width(), this.get_allocated_height());
+ queue_draw_area (0, 0, this.get_allocated_width (), this.get_allocated_height ());
}
- public ColorRectangle.new_from_css(string css_class) {
- set_color_from_css(css_class);
+ public ColorRectangle.new_from_css (string css_class) {
+ set_color_from_css (css_class);
}
- public void set_color_from_css(string css_class) {
- get_style_context().add_class(css_class);
- color = get_style_context().get_color(get_style_context().get_state());
- queue_draw_area(0, 0, this.get_allocated_width(), this.get_allocated_height());
+ public void set_color_from_css (string css_class) {
+ get_style_context ().add_class (css_class);
+ color = get_style_context ().get_color (get_style_context ().get_state ());
+ queue_draw_area (0, 0, this.get_allocated_width (), this.get_allocated_height ());
}
}
diff --git a/src/cpu-graph-model.vala b/src/cpu-graph-model.vala
index fa3131a..fa230a0 100644
--- a/src/cpu-graph-model.vala
+++ b/src/cpu-graph-model.vala
@@ -27,45 +27,45 @@ public class Usage.CpuGraphModel : GraphModel {
private bool[] change_small_process_usage;
public CpuGraphModel () {
- var settings = Settings.get_default();
+ var settings = Settings.get_default ();
set_timespan (settings.graph_timespan * 1000);
set_max_samples (settings.graph_max_samples);
- var column_total = new GraphColumn("TOTAL CPU", Type.from_name("gdouble"));
- add_column(column_total);
+ var column_total = new GraphColumn ("TOTAL CPU", Type.from_name ("gdouble"));
+ add_column (column_total);
- change_big_process_usage = new bool[get_num_processors()];
- change_small_process_usage = new bool[get_num_processors()];
+ change_big_process_usage = new bool[get_num_processors ()];
+ change_small_process_usage = new bool[get_num_processors ()];
- for (int i = 0; i < get_num_processors(); i++) {
- var column_x_cpu = new GraphColumn("CPU: " + i.to_string(), Type.from_name("gdouble"));
- add_column(column_x_cpu);
+ for (int i = 0; i < get_num_processors (); i++) {
+ var column_x_cpu = new GraphColumn ("CPU: " + i.to_string (), Type.from_name ("gdouble"));
+ add_column (column_x_cpu);
change_big_process_usage[i] = true;
change_small_process_usage[i] = true;
}
- Timeout.add(settings.graph_update_interval, update_data);
+ Timeout.add (settings.graph_update_interval, update_data);
}
- bool update_data() {
+ bool update_data () {
GraphModelIter iter;
push (out iter, get_monotonic_time ());
- SystemMonitor monitor = SystemMonitor.get_default();
+ SystemMonitor monitor = SystemMonitor.get_default ();
- for (int i = 0; i < get_num_processors(); i++) {
- iter_set_value(iter, i, monitor.x_cpu_load[i]);
+ for (int i = 0; i < get_num_processors (); i++) {
+ iter_set_value (iter, i, monitor.x_cpu_load[i]);
if (monitor.x_cpu_load[i] >= 90) {
if (change_big_process_usage[i]) {
- big_process_usage(i);
+ big_process_usage (i);
change_big_process_usage[i] = false;
change_small_process_usage[i] = true;
}
} else {
if (change_small_process_usage[i]) {
- small_process_usage(i);
+ small_process_usage (i);
change_small_process_usage[i] = false;
change_big_process_usage[i] = true;
}
@@ -83,39 +83,39 @@ public class Usage.CpuGraphModelMostUsedCore : GraphModel {
private bool change_small_process_usage = true;
public CpuGraphModelMostUsedCore () {
- var settings = Settings.get_default();
+ var settings = Settings.get_default ();
set_timespan (settings.graph_timespan * 1000);
set_max_samples (settings.graph_max_samples);
- var column = new GraphColumn("MOST USED CORE", Type.from_name("gdouble"));
- add_column(column);
+ var column = new GraphColumn ("MOST USED CORE", Type.from_name ("gdouble"));
+ add_column (column);
- Timeout.add(settings.graph_update_interval, update_data);
+ Timeout.add (settings.graph_update_interval, update_data);
}
- bool update_data() {
+ bool update_data () {
GraphModelIter iter;
push (out iter, get_monotonic_time ());
- SystemMonitor monitor = SystemMonitor.get_default();
+ SystemMonitor monitor = SystemMonitor.get_default ();
double most_used_core = monitor.x_cpu_load[0];
- for (int i = 1; i < get_num_processors(); i++) {
+ for (int i = 1; i < get_num_processors (); i++) {
if (monitor.x_cpu_load[i] > most_used_core)
most_used_core = monitor.x_cpu_load[i];
}
- iter_set_value(iter, 0, most_used_core);
+ iter_set_value (iter, 0, most_used_core);
if (most_used_core >= 90) {
if (change_big_process_usage) {
- big_process_usage();
+ big_process_usage ();
change_big_process_usage = false;
change_small_process_usage = true;
}
} else {
if (change_small_process_usage) {
- small_process_usage();
+ small_process_usage ();
change_small_process_usage = false;
change_big_process_usage = true;
}
diff --git a/src/cpu-graph.vala b/src/cpu-graph.vala
index d7843a2..4440442 100644
--- a/src/cpu-graph.vala
+++ b/src/cpu-graph.vala
@@ -32,33 +32,33 @@ public class Usage.CpuGraphMostUsedCore : GraphView {
private Gdk.RGBA color_normal;
class construct {
- set_css_name("rg-graph");
+ set_css_name ("rg-graph");
}
public CpuGraphMostUsedCore () {
- get_style_context().add_class("line_max");
- line_color_max = get_style_context().get_color(get_style_context().get_state());
- get_style_context().remove_class("line_max");
- get_style_context().add_class("line");
- line_color_normal = get_style_context().get_color(get_style_context().get_state());
- get_style_context().remove_class("line");
- get_style_context().add_class("stacked_max");
- color_max = get_style_context().get_color(get_style_context().get_state());
- get_style_context().remove_class("stacked_max");
- get_style_context().add_class("stacked");
- color_normal = get_style_context().get_color(get_style_context().get_state());
- get_style_context().remove_class("stacked");
+ get_style_context ().add_class ("line_max");
+ line_color_max = get_style_context ().get_color (get_style_context ().get_state ());
+ get_style_context ().remove_class ("line_max");
+ get_style_context ().add_class ("line");
+ line_color_normal = get_style_context ().get_color (get_style_context ().get_state ());
+ get_style_context ().remove_class ("line");
+ get_style_context ().add_class ("stacked_max");
+ color_max = get_style_context ().get_color (get_style_context ().get_state ());
+ get_style_context ().remove_class ("stacked_max");
+ get_style_context ().add_class ("stacked");
+ color_normal = get_style_context ().get_color (get_style_context ().get_state ());
+ get_style_context ().remove_class ("stacked");
if (graph_model == null)
- graph_model = new CpuGraphModelMostUsedCore();
+ graph_model = new CpuGraphModelMostUsedCore ();
- set_model(graph_model);
+ set_model (graph_model);
- renderer = new GraphStackedRenderer();
+ renderer = new GraphStackedRenderer ();
renderer.stroke_color_rgba = line_color_normal;
renderer.stacked_color_rgba = color_normal;
renderer.line_width = 1.0;
- add_renderer(renderer);
+ add_renderer (renderer);
graph_model.big_process_usage.connect (() => {
renderer.stroke_color_rgba = line_color_max;
@@ -82,30 +82,30 @@ public class Usage.CpuGraph : GraphView {
private Gdk.RGBA line_color_normal;
class construct {
- set_css_name("rg-graph");
+ set_css_name ("rg-graph");
}
- public CpuGraph() {
- get_style_context().add_class("line_max");
- line_color_max = get_style_context().get_color(get_style_context().get_state());
- get_style_context().remove_class("line_max");
- get_style_context().add_class("line");
- line_color_normal = get_style_context().get_color(get_style_context().get_state());
- get_style_context().remove_class("line");
- get_style_context().add_class("big");
+ public CpuGraph () {
+ get_style_context ().add_class ("line_max");
+ line_color_max = get_style_context ().get_color (get_style_context ().get_state ());
+ get_style_context ().remove_class ("line_max");
+ get_style_context ().add_class ("line");
+ line_color_normal = get_style_context ().get_color (get_style_context ().get_state ());
+ get_style_context ().remove_class ("line");
+ get_style_context ().add_class ("big");
if (graph_model == null)
- graph_model = new CpuGraphModel();
+ graph_model = new CpuGraphModel ();
- set_model(graph_model);
+ set_model (graph_model);
- renderers = new GraphLineRenderer[get_num_processors()];
- for (int i = 0; i < get_num_processors(); i++) {
- renderers[i] = new GraphLineRenderer();
+ renderers = new GraphLineRenderer[get_num_processors ()];
+ for (int i = 0; i < get_num_processors (); i++) {
+ renderers[i] = new GraphLineRenderer ();
renderers[i].column = i;
renderers[i].stroke_color_rgba = line_color_normal;
renderers[i].line_width = 1.5;
- add_renderer(renderers[i]);
+ add_renderer (renderers[i]);
}
graph_model.big_process_usage.connect ((column) => {
diff --git a/src/cpu-monitor.vala b/src/cpu-monitor.vala
index b78ea80..72b52a1 100644
--- a/src/cpu-monitor.vala
+++ b/src/cpu-monitor.vala
@@ -27,20 +27,20 @@ public class Usage.CpuMonitor : Monitor {
private uint64[] x_cpu_last_used;
private uint64[] x_cpu_last_total;
- public CpuMonitor() {
- x_cpu_load = new double[get_num_processors()];
- x_cpu_last_used = new uint64[get_num_processors()];
- x_cpu_last_total = new uint64[get_num_processors()];
+ public CpuMonitor () {
+ x_cpu_load = new double[get_num_processors ()];
+ x_cpu_last_used = new uint64[get_num_processors ()];
+ x_cpu_last_total = new uint64[get_num_processors ()];
}
- public void update() {
+ public void update () {
GTop.Cpu cpu_data;
GTop.get_cpu (out cpu_data);
var used = cpu_data.user + cpu_data.nice + cpu_data.sys;
cpu_load = (((double) (used - cpu_last_used)) / (cpu_data.total - cpu_last_total)) * 100;
cpu_last_total_step = cpu_data.total - cpu_last_total;
- var x_cpu_used = new uint64[get_num_processors()];
+ var x_cpu_used = new uint64[get_num_processors ()];
for (int i = 0; i < x_cpu_load.length; i++) {
x_cpu_used[i] = cpu_data.xcpu_user[i] + cpu_data.xcpu_nice[i] + cpu_data.xcpu_sys[i];
x_cpu_load[i] = (((double) (x_cpu_used[i] - x_cpu_last_used[i])) / (cpu_data.xcpu_total[i] -
x_cpu_last_total[i])) * 100;
@@ -52,15 +52,15 @@ public class Usage.CpuMonitor : Monitor {
x_cpu_last_total = cpu_data.xcpu_total;
}
- public double get_cpu_load() {
+ public double get_cpu_load () {
return cpu_load;
}
- public double[] get_x_cpu_load() {
+ public double[] get_x_cpu_load () {
return x_cpu_load;
}
- public void update_process(ref Process process) {
+ public void update_process (ref Process process) {
GTop.ProcTime proc_time;
GTop.ProcState proc_state;
@@ -68,8 +68,8 @@ public class Usage.CpuMonitor : Monitor {
GTop.get_proc_state (out proc_state, process.pid);
process.last_processor = proc_state.last_processor;
- double cpu_load = (((double) (proc_time.rtime - process.cpu_last_used)) / cpu_last_total_step) * 100
* get_num_processors();
- cpu_load = double.min(100, cpu_load);
+ double cpu_load = (((double) (proc_time.rtime - process.cpu_last_used)) / cpu_last_total_step) * 100
* get_num_processors ();
+ cpu_load = double.min (100, cpu_load);
process.cpu_load = cpu_load;
process.cpu_last_used = proc_time.rtime;
process.x_cpu_last_used = proc_time.xcpu_utime[process.last_processor] +
proc_time.xcpu_stime[process.last_processor];
diff --git a/src/cpu-sub-view.vala b/src/cpu-sub-view.vala
index acf6915..c24b4c9 100644
--- a/src/cpu-sub-view.vala
+++ b/src/cpu-sub-view.vala
@@ -22,59 +22,59 @@ public class Usage.ProcessorSubView : View, SubView {
private ProcessListBox process_list_box;
private NoResultsFoundView no_process_view;
- public ProcessorSubView() {
+ public ProcessorSubView () {
name = "PROCESSOR";
- var label = new Gtk.Label("<span font_desc=\"14.0\">" + _("Processor") + "</span>");
- label.set_use_markup(true);
+ var label = new Gtk.Label ("<span font_desc=\"14.0\">" + _("Processor") + "</span>");
+ label.set_use_markup (true);
label.margin_top = 25;
label.margin_bottom = 15;
- var cpu_graph = new CpuGraph();
+ var cpu_graph = new CpuGraph ();
cpu_graph.hexpand = true;
- var cpu_graph_box = new GraphBox(cpu_graph);
+ var cpu_graph_box = new GraphBox (cpu_graph);
cpu_graph_box.height_request = 225;
cpu_graph_box.valign = Gtk.Align.START;
- process_list_box = new ProcessListBox(ProcessListBoxType.PROCESSOR);
+ process_list_box = new ProcessListBox (ProcessListBoxType.PROCESSOR);
process_list_box.margin_bottom = 20;
process_list_box.margin_top = 30;
- var spinner = new Gtk.Spinner();
+ var spinner = new Gtk.Spinner ();
spinner.active = true;
spinner.margin_top = 30;
spinner.height_request = 250;
- no_process_view = new NoResultsFoundView();
+ no_process_view = new NoResultsFoundView ();
- var cpu_box = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
- cpu_box.pack_start(label, false, false, 0);
- cpu_box.pack_start(cpu_graph_box, false, false, 0);
- cpu_box.pack_start(spinner, true, true, 0);
- cpu_box.add(no_process_view);
+ var cpu_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
+ cpu_box.pack_start (label, false, false, 0);
+ cpu_box.pack_start (cpu_graph_box, false, false, 0);
+ cpu_box.pack_start (spinner, true, true, 0);
+ cpu_box.add (no_process_view);
- var system_monitor = SystemMonitor.get_default();
+ var system_monitor = SystemMonitor.get_default ();
system_monitor.notify["process-list-ready"].connect ((sender, property) => {
if (system_monitor.process_list_ready) {
- cpu_box.pack_start(process_list_box, false, false, 0);
- cpu_box.remove(spinner);
+ cpu_box.pack_start (process_list_box, false, false, 0);
+ cpu_box.remove (spinner);
} else {
- cpu_box.pack_start(spinner, true, true, 0);
- cpu_box.remove(process_list_box);
+ cpu_box.pack_start (spinner, true, true, 0);
+ cpu_box.remove (process_list_box);
}
});
process_list_box.bind_property ("empty", no_process_view, "visible", BindingFlags.BIDIRECTIONAL);
- add(cpu_box);
+ add (cpu_box);
}
- public override void show_all() {
- base.show_all();
- this.no_process_view.hide();
+ public override void show_all () {
+ base.show_all ();
+ this.no_process_view.hide ();
}
- public void search_in_processes(string text) {
+ public void search_in_processes (string text) {
process_list_box.search_text = text;
}
}
diff --git a/src/game-mode.vala b/src/game-mode.vala
index af85388..ad2b025 100644
--- a/src/game-mode.vala
+++ b/src/game-mode.vala
@@ -19,34 +19,34 @@ public interface GameMode.Client : GLib.Object {
public abstract int client_count { get; }
[DBus (name = "RegisterGame")]
- public abstract int register_game(int pid) throws DBusError, IOError;
+ public abstract int register_game (int pid) throws DBusError, IOError;
[DBus (name = "UnregisterGame")]
- public abstract int unregister_game(int pid) throws DBusError, IOError;
+ public abstract int unregister_game (int pid) throws DBusError, IOError;
[DBus (name = "QueryStatus")]
- public abstract int query_status(int pid) throws DBusError, IOError;
+ public abstract int query_status (int pid) throws DBusError, IOError;
[DBus (name = "RegisterGameByPID")]
- public abstract int register_game_by_pid(int pid, int requestor) throws DBusError, IOError;
+ public abstract int register_game_by_pid (int pid, int requestor) throws DBusError, IOError;
[DBus (name = "UnregisterGameByPID")]
- public abstract int unregister_game_by_pid(int pid, int requestor) throws DBusError, IOError;
+ public abstract int unregister_game_by_pid (int pid, int requestor) throws DBusError, IOError;
[DBus (name = "QueryStatusByPID")]
- public abstract int query_status_by_pid(int pid, int requestor) throws DBusError, IOError;
+ public abstract int query_status_by_pid (int pid, int requestor) throws DBusError, IOError;
[DBus (name = "RefreshConfig")]
- public abstract int refresh_config() throws DBusError, IOError;
+ public abstract int refresh_config () throws DBusError, IOError;
[DBus (name = "ListGames")]
- public abstract GameInfo[] list_games() throws DBusError, IOError;
+ public abstract GameInfo[] list_games () throws DBusError, IOError;
[DBus (name = "GameRegistered")]
- public signal void game_registered(int pid, GLib.ObjectPath path);
+ public signal void game_registered (int pid, GLib.ObjectPath path);
[DBus (name = "GameUnregistered")]
- public signal void game_unregistered(int pid, GLib.ObjectPath path);
+ public signal void game_unregistered (int pid, GLib.ObjectPath path);
}
public struct GameMode.GameInfo {
@@ -62,9 +62,9 @@ public class GameMode.PidList : GLib.Object {
/* singelton */
private static PidList singelton;
- public static PidList get_default() {
+ public static PidList get_default () {
if (singelton == null)
- singelton = new PidList();
+ singelton = new PidList ();
return singelton;
}
@@ -74,50 +74,50 @@ public class GameMode.PidList : GLib.Object {
_pids = new HashTable<int, GLib.ObjectPath>(direct_hash, direct_equal);
}
- public PidList() {
+ public PidList () {
try {
- client = Bus.get_proxy_sync(BusType.SESSION,
+ client = Bus.get_proxy_sync (BusType.SESSION,
"com.feralinteractive.GameMode",
"/com/feralinteractive/GameMode");
- client.game_registered.connect(this.on_game_registered);
- client.game_unregistered.connect(this.on_game_unregistered);
+ client.game_registered.connect (this.on_game_registered);
+ client.game_unregistered.connect (this.on_game_unregistered);
- var games = client.list_games();
+ var games = client.list_games ();
foreach (GameMode.GameInfo info in games) {
- _pids.insert(info.pid, info.path);
+ _pids.insert (info.pid, info.path);
}
- } catch(IOError e) {
- warning("GameMode Proxy creation failed: %s", e.message);
- } catch(GLib.DBusError e) {
- warning("GameMode D-Bus error: %s", e.message);
+ } catch (IOError e) {
+ warning ("GameMode Proxy creation failed: %s", e.message);
+ } catch (GLib.DBusError e) {
+ warning ("GameMode D-Bus error: %s", e.message);
}
}
/* public */
public int[] pids {
owned get {
- return _pids.get_keys_as_array();
+ return _pids.get_keys_as_array ();
}
}
- public bool contains(int pid) {
+ public bool contains (int pid) {
return pid in _pids;
}
[Signal (detailed = true)]
- public signal void changed(int pid, bool added);
+ public signal void changed (int pid, bool added);
/* Signals */
- private void on_game_registered(int pid, GLib.ObjectPath path) {
- _pids.insert(pid, path);
+ private void on_game_registered (int pid, GLib.ObjectPath path) {
+ _pids.insert (pid, path);
changed["added"](pid, true);
}
- private void on_game_unregistered(int pid, GLib.ObjectPath path) {
- _pids.remove(pid);
+ private void on_game_unregistered (int pid, GLib.ObjectPath path) {
+ _pids.remove (pid);
changed["removed"](pid, false);
}
}
\ No newline at end of file
diff --git a/src/gnome-usage.vala b/src/gnome-usage.vala
index 167ffa1..bf96377 100644
--- a/src/gnome-usage.vala
+++ b/src/gnome-usage.vala
@@ -19,11 +19,11 @@
*/
public static int main (string[] args) {
- Intl.bindtextdomain(Config.GETTEXT_PACKAGE, Config.GNOMELOCALEDIR);
- Intl.setlocale(LocaleCategory.ALL, "");
- Intl.textdomain(Config.GETTEXT_PACKAGE);
- Intl.bind_textdomain_codeset(Config.GETTEXT_PACKAGE, "utf-8");
+ Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.GNOMELOCALEDIR);
+ Intl.setlocale (LocaleCategory.ALL, "");
+ Intl.textdomain (Config.GETTEXT_PACKAGE);
+ Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "utf-8");
- var application = new Usage.Application();
- return application.run(args);
+ var application = new Usage.Application ();
+ return application.run (args);
}
diff --git a/src/graph-box.vala b/src/graph-box.vala
index 2d88acd..f8c7a83 100644
--- a/src/graph-box.vala
+++ b/src/graph-box.vala
@@ -23,10 +23,10 @@ using Gtk;
public class GraphBox : Gtk.Box {
class construct {
- set_css_name("graph-box");
+ set_css_name ("graph-box");
}
public GraphBox (Dazzle.GraphView graph) {
- add(graph);
+ add (graph);
}
}
diff --git a/src/graph-stack-switcher.vala b/src/graph-stack-switcher.vala
index c4dd30d..be9d3a3 100644
--- a/src/graph-stack-switcher.vala
+++ b/src/graph-stack-switcher.vala
@@ -25,35 +25,35 @@ public class Usage.GraphStackSwitcher : Gtk.Box {
GraphSwitcherButton[] buttons;
class construct {
- set_css_name("graph-stack-switcher");
+ set_css_name ("graph-stack-switcher");
}
- public GraphStackSwitcher(AnimatedScrolledWindow scrolled_window, View[] sub_views) {
- Object(orientation: Gtk.Orientation.VERTICAL, spacing: 0);
+ public GraphStackSwitcher (AnimatedScrolledWindow scrolled_window, View[] sub_views) {
+ Object (orientation: Gtk.Orientation.VERTICAL, spacing: 0);
this.sub_views = sub_views;
this.scrolled_window = scrolled_window;
- scrolled_window.scroll_changed.connect(on_scroll_changed);
+ scrolled_window.scroll_changed.connect (on_scroll_changed);
buttons = {
- new GraphSwitcherButton.processor(_("Processor")),
- new GraphSwitcherButton.memory(_("Memory"))
+ new GraphSwitcherButton.processor (_("Processor")),
+ new GraphSwitcherButton.memory (_("Memory"))
};
foreach (GraphSwitcherButton button in buttons) {
- this.pack_start(button, false, true, 0);
+ this.pack_start (button, false, true, 0);
- button.button_release_event.connect(() => {
- var button_number = get_button_number(button);
- scroll_to_view(button_number);
+ button.button_release_event.connect (() => {
+ var button_number = get_button_number (button);
+ scroll_to_view (button_number);
return false;
});
}
}
- private int get_button_number(Gtk.Button button) {
+ private int get_button_number (Gtk.Button button) {
for (int i = 0; i < buttons.length; i++) {
if (buttons[i] == button)
return i;
@@ -62,24 +62,24 @@ public class Usage.GraphStackSwitcher : Gtk.Box {
return 0;
}
- private void scroll_to_view(int button_number) {
+ private void scroll_to_view (int button_number) {
Gtk.Allocation alloc;
- this.sub_views[button_number].get_allocation(out alloc);
- scrolled_window.animated_scroll_vertically(alloc.y);
+ this.sub_views[button_number].get_allocation (out alloc);
+ scrolled_window.animated_scroll_vertically (alloc.y);
}
- private void on_scroll_changed(double y) {
+ private void on_scroll_changed (double y) {
Gtk.Allocation alloc;
var button_number = 0;
for (int i = 1; i < buttons.length; i++) {
- this.sub_views[i].get_allocation(out alloc);
+ this.sub_views[i].get_allocation (out alloc);
if (y < alloc.y)
break;
button_number = i;
}
- buttons[button_number].set_active(true);
+ buttons[button_number].set_active (true);
}
}
diff --git a/src/graph-stacked-renderer.vala b/src/graph-stacked-renderer.vala
index 83b855e..56ce5b6 100644
--- a/src/graph-stacked-renderer.vala
+++ b/src/graph-stacked-renderer.vala
@@ -28,11 +28,11 @@ public class GraphStackedRenderer : Object, GraphRenderer {
public Gdk.RGBA stroke_color_rgba { get; set; }
public Gdk.RGBA stacked_color_rgba { get; set; }
- public void render(GraphModel model, int64 x_begin, int64 x_end, double y_begin, double y_end, Context
cr, RectangleInt area) {
+ public void render (GraphModel model, int64 x_begin, int64 x_end, double y_begin, double y_end, Context
cr, RectangleInt area) {
GraphModelIter iter;
- cr.save();
+ cr.save ();
- if (model.get_iter_first(out iter)) {
+ if (model.get_iter_first (out iter)) {
double chunk = area.width / (double) (model.max_samples - 1) / 2.0;
double last_x = calc_x (iter, x_begin, x_end, area.width);
double last_y = area.height;
@@ -54,10 +54,10 @@ public class GraphStackedRenderer : Object, GraphRenderer {
cr.set_source_rgba (stacked_color_rgba.red, stacked_color_rgba.green, stacked_color_rgba.blue,
stacked_color_rgba.alpha);
cr.rel_line_to (0, area.height);
cr.stroke_preserve ();
- cr.close_path();
- cr.fill();
+ cr.close_path ();
+ cr.fill ();
- if (model.get_iter_first(out iter)) {
+ if (model.get_iter_first (out iter)) {
double chunk = area.width / (double) (model.max_samples - 1) / 2.0;
double last_x = calc_x (iter, x_begin, x_end, area.width);
double last_y = area.height;
@@ -81,7 +81,7 @@ public class GraphStackedRenderer : Object, GraphRenderer {
}
private static double calc_x (GraphModelIter iter, int64 begin, int64 end, uint width) {
- var timestamp = GraphModel.iter_get_timestamp(iter);
+ var timestamp = GraphModel.iter_get_timestamp (iter);
return ((timestamp - begin) / (double) (end - begin) * width);
}
@@ -89,19 +89,19 @@ public class GraphStackedRenderer : Object, GraphRenderer {
private static double calc_y (GraphModelIter iter, double range_begin, double range_end, uint height,
uint column) {
double y;
- var val = GraphModel.iter_get_value(iter, column);
- switch (val.type()) {
+ var val = GraphModel.iter_get_value (iter, column);
+ switch (val.type ()) {
case Type.DOUBLE:
- y = val.get_double();
+ y = val.get_double ();
break;
case Type.UINT:
- y = val.get_uint();
+ y = val.get_uint ();
break;
case Type.UINT64:
y = val.get_uint64();
break;
case Type.INT:
- y = val.get_int();
+ y = val.get_int ();
break;
case Type.INT64:
y = val.get_int64();
diff --git a/src/graph-switcher-button.vala b/src/graph-switcher-button.vala
index 38000af..c1356eb 100644
--- a/src/graph-switcher-button.vala
+++ b/src/graph-switcher-button.vala
@@ -21,31 +21,31 @@
public class Usage.GraphSwitcherButton : Gtk.RadioButton {
private static Gtk.RadioButton? _group = null;
- public GraphSwitcherButton.processor(string label) {
- var processor_graph = new CpuGraphMostUsedCore();
- child = createContent(processor_graph, label);
+ public GraphSwitcherButton.processor (string label) {
+ var processor_graph = new CpuGraphMostUsedCore ();
+ child = createContent (processor_graph, label);
}
- public GraphSwitcherButton.memory(string label) {
- var memory_graph = new MemoryGraph();
- child = createContent(memory_graph, label);
+ public GraphSwitcherButton.memory (string label) {
+ var memory_graph = new MemoryGraph ();
+ child = createContent (memory_graph, label);
}
- private Gtk.Box createContent(Dazzle.GraphView graph, string label_text) {
+ private Gtk.Box createContent (Dazzle.GraphView graph, string label_text) {
graph.height_request = 80;
graph.hexpand = true;
- var graph_box = new GraphBox(graph);
+ var graph_box = new GraphBox (graph);
graph_box.margin_top = 12;
graph_box.margin_start = 8;
graph_box.margin_end = 8;
- var label = new Gtk.Label(label_text);
+ var label = new Gtk.Label (label_text);
label.margin_top = 6;
label.margin_bottom = 3;
- var box = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
- box.pack_start(graph_box, true, true, 0);
- box.pack_start(label, false, false, 0);
+ var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
+ box.pack_start (graph_box, true, true, 0);
+ box.pack_start (label, false, false, 0);
return box;
}
@@ -54,12 +54,12 @@ public class Usage.GraphSwitcherButton : Gtk.RadioButton {
if (_group == null)
_group = this;
else
- join_group(_group);
+ join_group (_group);
- set_mode(false);
+ set_mode (false);
- var context = get_style_context();
- context.add_class("flat");
- context.add_class("graph-switcher");
+ var context = get_style_context ();
+ context.add_class ("flat");
+ context.add_class ("graph-switcher");
}
}
diff --git a/src/loading-notification.vala b/src/loading-notification.vala
index 3be4099..8cc2ff8 100644
--- a/src/loading-notification.vala
+++ b/src/loading-notification.vala
@@ -36,11 +36,11 @@ private class Usage.LoadingNotification: Gtk.Revealer {
dismissed.connect ( () => {
if (dismiss_func != null)
dismiss_func ();
- set_reveal_child(false);
+ set_reveal_child (false);
});
}
- public void dismiss() {
- dismissed();
+ public void dismiss () {
+ dismissed ();
}
}
diff --git a/src/memory-graph-model.vala b/src/memory-graph-model.vala
index 814eae0..6910a38 100644
--- a/src/memory-graph-model.vala
+++ b/src/memory-graph-model.vala
@@ -23,29 +23,29 @@ using Dazzle;
public class Usage.MemoryGraphModel : GraphModel {
public const int COLUMN_RAM = 0;
public const int COLUMN_SWAP = 1;
- public signal void big_ram_usage();
- public signal void small_ram_usage();
+ public signal void big_ram_usage ();
+ public signal void small_ram_usage ();
private bool change_big_ram_usage = true;
private bool change_small_ram_usage = true;
public MemoryGraphModel () {
- var settings = Settings.get_default();
+ var settings = Settings.get_default ();
set_timespan (settings.graph_timespan * 1000);
set_max_samples (settings.graph_max_samples);
- var column_ram = new GraphColumn("RAM", Type.from_name("gdouble"));
- add_column(column_ram);
- var column_swap = new GraphColumn("SWAP", Type.from_name("gdouble"));
- add_column(column_swap);
+ var column_ram = new GraphColumn ("RAM", Type.from_name ("gdouble"));
+ add_column (column_ram);
+ var column_swap = new GraphColumn ("SWAP", Type.from_name ("gdouble"));
+ add_column (column_swap);
- Timeout.add(settings.graph_update_interval, update_data);
+ Timeout.add (settings.graph_update_interval, update_data);
}
- bool update_data() {
+ bool update_data () {
GraphModelIter iter;
push (out iter, get_monotonic_time ());
- SystemMonitor monitor = SystemMonitor.get_default();
+ SystemMonitor monitor = SystemMonitor.get_default ();
double ram_usage = 0;
if (monitor.ram_total != 0)
ram_usage = (((double) monitor.ram_usage / monitor.ram_total) * 100);
@@ -54,18 +54,18 @@ public class Usage.MemoryGraphModel : GraphModel {
if (monitor.ram_total != 0)
swap_usage = (((double) monitor.swap_usage / monitor.swap_total) * 100);
- iter_set_value(iter, COLUMN_RAM, ram_usage);
- iter_set_value(iter, COLUMN_SWAP, swap_usage);
+ iter_set_value (iter, COLUMN_RAM, ram_usage);
+ iter_set_value (iter, COLUMN_SWAP, swap_usage);
if (ram_usage >= 90) {
if (change_big_ram_usage) {
- big_ram_usage();
+ big_ram_usage ();
change_big_ram_usage = false;
change_small_ram_usage = true;
}
} else {
if (change_small_ram_usage) {
- small_ram_usage();
+ small_ram_usage ();
change_small_ram_usage = false;
change_big_ram_usage = true;
}
diff --git a/src/memory-graph.vala b/src/memory-graph.vala
index c33ca72..6badbc3 100644
--- a/src/memory-graph.vala
+++ b/src/memory-graph.vala
@@ -28,36 +28,36 @@ public class Usage.MemoryGraph : GraphView {
private Gdk.RGBA color_normal;
class construct {
- set_css_name("rg-graph");
+ set_css_name ("rg-graph");
}
public MemoryGraph () {
- get_style_context().add_class("line_max");
- line_color_max = get_style_context().get_color(get_style_context().get_state());
- get_style_context().remove_class("line_max");
- get_style_context().add_class("line");
- line_color_normal = get_style_context().get_color(get_style_context().get_state());
- get_style_context().remove_class("line");
- get_style_context().add_class("stacked_max");
- color_max = get_style_context().get_color(get_style_context().get_state());
- get_style_context().remove_class("stacked_max");
- get_style_context().add_class("stacked");
- color_normal = get_style_context().get_color(get_style_context().get_state());
- get_style_context().remove_class("stacked");
+ get_style_context ().add_class ("line_max");
+ line_color_max = get_style_context ().get_color (get_style_context ().get_state ());
+ get_style_context ().remove_class ("line_max");
+ get_style_context ().add_class ("line");
+ line_color_normal = get_style_context ().get_color (get_style_context ().get_state ());
+ get_style_context ().remove_class ("line");
+ get_style_context ().add_class ("stacked_max");
+ color_max = get_style_context ().get_color (get_style_context ().get_state ());
+ get_style_context ().remove_class ("stacked_max");
+ get_style_context ().add_class ("stacked");
+ color_normal = get_style_context ().get_color (get_style_context ().get_state ());
+ get_style_context ().remove_class ("stacked");
if (graph_model == null) {
- graph_model = new MemoryGraphModel();
- set_model(graph_model);
+ graph_model = new MemoryGraphModel ();
+ set_model (graph_model);
} else {
- set_model(graph_model);
+ set_model (graph_model);
}
- var renderer_ram = new GraphStackedRenderer();
+ var renderer_ram = new GraphStackedRenderer ();
renderer_ram.column = MemoryGraphModel.COLUMN_RAM;
renderer_ram.stroke_color_rgba = line_color_normal;
renderer_ram.stacked_color_rgba = color_normal;
renderer_ram.line_width = 1.2;
- add_renderer(renderer_ram);
+ add_renderer (renderer_ram);
graph_model.big_ram_usage.connect (() => {
renderer_ram.stroke_color_rgba = line_color_max;
diff --git a/src/memory-monitor.vala b/src/memory-monitor.vala
index a4669a3..b30bce9 100644
--- a/src/memory-monitor.vala
+++ b/src/memory-monitor.vala
@@ -24,7 +24,7 @@ public class Usage.MemoryMonitor : Monitor {
private uint64 swap_usage;
private uint64 swap_total;
- public void update() {
+ public void update () {
/* Memory */
GTop.Mem mem;
GTop.get_mem (out mem);
@@ -38,20 +38,20 @@ public class Usage.MemoryMonitor : Monitor {
swap_total = swap.total;
}
- public uint64 get_ram_usage() {
+ public uint64 get_ram_usage () {
return ram_usage;
}
- public uint64 get_swap_usage() {
+ public uint64 get_swap_usage () {
return swap_usage;
}
- public uint64 get_ram_total() {
+ public uint64 get_ram_total () {
return ram_total;
}
- public uint64 get_swap_total() {
+ public uint64 get_swap_total () {
return swap_total;
}
- public void update_process(ref Process process) {
+ public void update_process (ref Process process) {
GTop.Mem mem;
GTop.ProcMem proc_mem;
diff --git a/src/memory-speedometer.vala b/src/memory-speedometer.vala
index 17245cf..1497e1c 100644
--- a/src/memory-speedometer.vala
+++ b/src/memory-speedometer.vala
@@ -37,21 +37,21 @@ public class Usage.MemorySpeedometer : Gtk.Bin {
private double ram_usage { get; set; }
construct {
- var monitor = SystemMonitor.get_default();
- Timeout.add_seconds(1, () => {
+ var monitor = SystemMonitor.get_default ();
+ Timeout.add_seconds (1, () => {
var percentage = (((double) monitor.ram_usage / monitor.ram_total) * 100);
this.speedometer.percentage = (int)percentage;
- label.label = "%d".printf((int)percentage) + "%";
+ label.label = "%d".printf ((int)percentage) + "%";
var available = (monitor.ram_total - monitor.ram_usage);
- ram_used.label = Utils.format_size_values(monitor.ram_usage);
- ram_available.label = Utils.format_size_values(available);
+ ram_used.label = Utils.format_size_values (monitor.ram_usage);
+ ram_available.label = Utils.format_size_values (available);
return true;
});
- this.show_all();
+ this.show_all ();
}
}
diff --git a/src/memory-sub-view.vala b/src/memory-sub-view.vala
index a99dc23..9d94d53 100644
--- a/src/memory-sub-view.vala
+++ b/src/memory-sub-view.vala
@@ -22,61 +22,61 @@ public class Usage.MemorySubView : View, SubView {
private ProcessListBox process_list_box;
private NoResultsFoundView no_process_view;
- public MemorySubView() {
+ public MemorySubView () {
name = "MEMORY";
- var label = new Gtk.Label("<span font_desc=\"14.0\">" + _("Memory") + "</span>");
- label.set_use_markup(true);
+ var label = new Gtk.Label ("<span font_desc=\"14.0\">" + _("Memory") + "</span>");
+ label.set_use_markup (true);
label.margin_top = 25;
label.margin_bottom = 15;
- process_list_box = new ProcessListBox(ProcessListBoxType.MEMORY);
+ process_list_box = new ProcessListBox (ProcessListBoxType.MEMORY);
process_list_box.margin_bottom = 20;
process_list_box.margin_top = 30;
- var spinner = new Gtk.Spinner();
+ var spinner = new Gtk.Spinner ();
spinner.active = true;
spinner.margin_top = 30;
spinner.height_request = 250;
- no_process_view = new NoResultsFoundView();
+ no_process_view = new NoResultsFoundView ();
- var memory_graph = new MemorySpeedometer();
- var swap_graph = new SwapSpeedometer();
+ var memory_graph = new MemorySpeedometer ();
+ var swap_graph = new SwapSpeedometer ();
swap_graph.valign = Gtk.Align.END;
- var speedometers = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
- speedometers.pack_start(memory_graph, false, false, 0);
- speedometers.pack_end(swap_graph, false, false, 0);
+ var speedometers = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
+ speedometers.pack_start (memory_graph, false, false, 0);
+ speedometers.pack_end (swap_graph, false, false, 0);
speedometers.margin_top = 30;
- var memory_box = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
- memory_box.pack_start(label, false, false, 0);
- memory_box.pack_start(speedometers, false, false, 0);
- memory_box.pack_start(spinner, true, true, 0);
- memory_box.add(no_process_view);
+ var memory_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
+ memory_box.pack_start (label, false, false, 0);
+ memory_box.pack_start (speedometers, false, false, 0);
+ memory_box.pack_start (spinner, true, true, 0);
+ memory_box.add (no_process_view);
- var system_monitor = SystemMonitor.get_default();
+ var system_monitor = SystemMonitor.get_default ();
system_monitor.notify["process-list-ready"].connect ((sender, property) => {
if (system_monitor.process_list_ready) {
- memory_box.pack_start(process_list_box, false, false, 0);
- memory_box.remove(spinner);
+ memory_box.pack_start (process_list_box, false, false, 0);
+ memory_box.remove (spinner);
} else {
- memory_box.pack_start(spinner, true, true, 0);
- memory_box.remove(process_list_box);
+ memory_box.pack_start (spinner, true, true, 0);
+ memory_box.remove (process_list_box);
}
});
process_list_box.bind_property ("empty", no_process_view, "visible", BindingFlags.BIDIRECTIONAL);
- add(memory_box);
+ add (memory_box);
}
- public override void show_all() {
- base.show_all();
- this.no_process_view.hide();
+ public override void show_all () {
+ base.show_all ();
+ this.no_process_view.hide ();
}
- public void search_in_processes(string text) {
+ public void search_in_processes (string text) {
process_list_box.search_text = text;
}
}
diff --git a/src/performance-view.vala b/src/performance-view.vala
index 5de2e4c..505fb32 100644
--- a/src/performance-view.vala
+++ b/src/performance-view.vala
@@ -45,14 +45,14 @@ public class Usage.PerformanceView : View {
icon_name = "speedometer-symbolic";
sub_views = new View[] {
- new ProcessorSubView(),
- new MemorySubView()
+ new ProcessorSubView (),
+ new MemorySubView ()
};
foreach (var sub_view in sub_views)
- performance_content.pack_start(sub_view, true, true, 0);
+ performance_content.pack_start (sub_view, true, true, 0);
- var stackSwitcher = new GraphStackSwitcher(scrolled_window, sub_views);
+ var stackSwitcher = new GraphStackSwitcher (scrolled_window, sub_views);
switcher_box.add (stackSwitcher);
show_all ();
@@ -61,10 +61,10 @@ public class Usage.PerformanceView : View {
[GtkCallback]
private void on_search_entry_changed () {
foreach (View sub_view in sub_views)
- ((SubView) sub_view).search_in_processes(search_entry.get_text());
+ ((SubView) sub_view).search_in_processes (search_entry.get_text ());
}
- public void set_search_mode(bool enable) {
- search_bar.set_search_mode(enable);
+ public void set_search_mode (bool enable) {
+ search_bar.set_search_mode (enable);
}
}
diff --git a/src/pie-chart.vala b/src/pie-chart.vala
index 14b1fd8..9ed67d9 100644
--- a/src/pie-chart.vala
+++ b/src/pie-chart.vala
@@ -28,11 +28,11 @@ public class Usage.PieChart : Gtk.DrawingArea {
Gdk.RGBA available;
class construct {
- set_css_name("PieChart");
+ set_css_name ("PieChart");
}
- public PieChart() {
- set_styles();
+ public PieChart () {
+ set_styles ();
this.draw.connect ((context) => {
int height = this.get_allocated_height ();
@@ -52,7 +52,7 @@ public class Usage.PieChart : Gtk.DrawingArea {
context.move_to (xc, yc);
Gdk.cairo_set_source_rgba (context, used_color);
context.arc (xc, yc, radius, angle1, angle2);
- context.fill();
+ context.fill ();
}
if (other_percentages > 0) {
@@ -62,7 +62,7 @@ public class Usage.PieChart : Gtk.DrawingArea {
context.move_to (xc, yc);
Gdk.cairo_set_source_rgba (context, others_color);
context.arc (xc, yc, radius, angle1, angle2);
- context.fill();
+ context.fill ();
}
angle1 = angle2;
@@ -70,24 +70,24 @@ public class Usage.PieChart : Gtk.DrawingArea {
context.move_to (xc, yc);
Gdk.cairo_set_source_rgba (context, available);
context.arc (xc, yc, radius, angle1, angle2);
- context.fill();
+ context.fill ();
return true;
});
}
- private void set_styles() {
- var context = get_style_context();
- context.add_class("used");
- used_color = context.get_color(context.get_state());
- context.add_class("others");
- others_color = context.get_color(context.get_state());
- context.add_class("available");
- available = context.get_color(context.get_state());
+ private void set_styles () {
+ var context = get_style_context ();
+ context.add_class ("used");
+ used_color = context.get_color (context.get_state ());
+ context.add_class ("others");
+ others_color = context.get_color (context.get_state ());
+ context.add_class ("available");
+ available = context.get_color (context.get_state ());
}
- public void update(int used_percentages, int other_percentages) {
+ public void update (int used_percentages, int other_percentages) {
this.used_percentages = used_percentages;
this.other_percentages = used_percentages + other_percentages;
- this.queue_draw();
+ this.queue_draw ();
}
}
diff --git a/src/primary-menu.vala b/src/primary-menu.vala
index 4b304fc..ecb0a03 100644
--- a/src/primary-menu.vala
+++ b/src/primary-menu.vala
@@ -28,14 +28,14 @@ public class Usage.PrimaryMenu : Gtk.Popover {
public HeaderBarMode mode { get; set; }
- public PrimaryMenu() {
+ public PrimaryMenu () {
notify["mode"].connect ((sender, property) => {
switch (mode) {
case HeaderBarMode.PERFORMANCE:
- performance_container.show();
+ performance_container.show ();
break;
case HeaderBarMode.STORAGE:
- performance_container.hide();
+ performance_container.hide ();
break;
}
});
diff --git a/src/process-list-box.vala b/src/process-list-box.vala
index 2fda550..d3dff32 100644
--- a/src/process-list-box.vala
+++ b/src/process-list-box.vala
@@ -32,37 +32,37 @@ public class Usage.ProcessListBox : Gtk.ListBox {
private ListStore model;
private ProcessListBoxType type;
- public ProcessListBox(ProcessListBoxType type) {
+ public ProcessListBox (ProcessListBoxType type) {
set_selection_mode (Gtk.SelectionMode.NONE);
set_header_func (update_header);
this.type = type;
- model = new ListStore(typeof(AppItem));
- bind_model(model, on_row_created);
+ model = new ListStore (typeof (AppItem));
+ bind_model (model, on_row_created);
- row_activated.connect((row) => {
+ row_activated.connect ((row) => {
var process_row = (ProcessRow) row;
- process_row.activate();
+ process_row.activate ();
});
this.notify["search-text"].connect ((sender, property) => {
- update();
+ update ();
});
- var system_monitor = SystemMonitor.get_default();
+ var system_monitor = SystemMonitor.get_default ();
system_monitor.notify["process-list-ready"].connect (() => {
if (system_monitor.process_list_ready)
- update();
+ update ();
});
- var settings = Settings.get_default();
- Timeout.add(settings.list_update_interval_UI, update);
+ var settings = Settings.get_default ();
+ Timeout.add (settings.list_update_interval_UI, update);
bind_property ("empty", this, "visible", BindingFlags.INVERT_BOOLEAN);
}
- private bool update() {
- model.remove_all();
+ private bool update () {
+ model.remove_all ();
CompareDataFunc<AppItem> app_cmp = (a, b) => {
AppItem app_a = (AppItem) a;
@@ -77,45 +77,45 @@ public class Usage.ProcessListBox : Gtk.ListBox {
}
};
- var system_monitor = SystemMonitor.get_default();
+ var system_monitor = SystemMonitor.get_default ();
if (search_text == "") {
switch (type) {
default:
case ProcessListBoxType.PROCESSOR:
- foreach (unowned AppItem app in system_monitor.get_apps()) {
+ foreach (unowned AppItem app in system_monitor.get_apps ()) {
if (app.cpu_load > APP_CPU_MIN_LOAD_LIMIT)
- model.insert_sorted(app, app_cmp);
+ model.insert_sorted (app, app_cmp);
}
break;
case ProcessListBoxType.MEMORY:
- foreach (unowned AppItem app in system_monitor.get_apps())
+ foreach (unowned AppItem app in system_monitor.get_apps ())
if (app.mem_usage > APP_MEM_MIN_USAGE_LIMIT)
- model.insert_sorted(app, app_cmp);
+ model.insert_sorted (app, app_cmp);
break;
}
} else {
- foreach (unowned AppItem app in system_monitor.get_apps()) {
- if (app.display_name.down().contains(search_text.down()) ||
app.representative_cmdline.down().contains(search_text.down()))
- model.insert_sorted(app, app_cmp);
+ foreach (unowned AppItem app in system_monitor.get_apps ()) {
+ if (app.display_name.down ().contains (search_text.down ()) ||
app.representative_cmdline.down ().contains (search_text.down ()))
+ model.insert_sorted (app, app_cmp);
}
}
- empty = (model.get_n_items() == 0);
+ empty = (model.get_n_items () == 0);
return true;
}
private Gtk.Widget on_row_created (Object item) {
- return new ProcessRow((AppItem) item, type);
+ return new ProcessRow ((AppItem) item, type);
}
- private void update_header(Gtk.ListBoxRow row, Gtk.ListBoxRow? before_row) {
+ private void update_header (Gtk.ListBoxRow row, Gtk.ListBoxRow? before_row) {
if (before_row == null) {
- row.set_header(null);
+ row.set_header (null);
} else {
var separator = new Gtk.Separator (Gtk.Orientation.HORIZONTAL);
- separator.get_style_context().add_class("list");
- separator.show();
- row.set_header(separator);
+ separator.get_style_context ().add_class ("list");
+ separator.show ();
+ row.set_header (separator);
}
}
}
diff --git a/src/process-row.vala b/src/process-row.vala
index 2565d8a..c879998 100644
--- a/src/process-row.vala
+++ b/src/process-row.vala
@@ -47,48 +47,48 @@ public class Usage.ProcessRow : Gtk.ListBoxRow {
private ProcessListBoxType type;
- public ProcessRow(AppItem app, ProcessListBoxType type) {
+ public ProcessRow (AppItem app, ProcessListBoxType type) {
this.type = type;
this.app = app;
- this.icon.gicon = app.get_icon();
- this.app.bind_property("gamemode", gamemode, "visible", BindingFlags.SYNC_CREATE);
- update();
+ this.icon.gicon = app.get_icon ();
+ this.app.bind_property ("gamemode", gamemode, "visible", BindingFlags.SYNC_CREATE);
+ update ();
}
- private void update() {
- update_load_label();
- update_user_tag();
+ private void update () {
+ update_load_label ();
+ update_user_tag ();
title_label.label = app.display_name;
}
- private void update_load_label() {
+ private void update_load_label () {
switch (type) {
case ProcessListBoxType.PROCESSOR:
- load_label.label = ((int) app.cpu_load).to_string() + " %";
+ load_label.label = ((int) app.cpu_load).to_string () + " %";
break;
case ProcessListBoxType.MEMORY:
- load_label.label = Utils.format_size_values(app.mem_usage);
+ load_label.label = Utils.format_size_values (app.mem_usage);
break;
}
}
- private void update_user_tag() {
+ private void update_user_tag () {
if (app.user == null)
return;
- remove_user_tag();
- create_user_tag();
+ remove_user_tag ();
+ create_user_tag ();
}
- private void remove_user_tag() {
+ private void remove_user_tag () {
user_tag_box.visible = false;
- user_tag_box.get_style_context().remove_class(CSS_TAG_USER);
- user_tag_box.get_style_context().remove_class(CSS_TAG_ROOT);
- user_tag_box.get_style_context().remove_class(CSS_TAG_SYSTEM);
+ user_tag_box.get_style_context ().remove_class (CSS_TAG_USER);
+ user_tag_box.get_style_context ().remove_class (CSS_TAG_ROOT);
+ user_tag_box.get_style_context ().remove_class (CSS_TAG_SYSTEM);
}
- private void create_user_tag() {
+ private void create_user_tag () {
string class_name = "";
if (app.user.LocalAccount) {
class_name = CSS_TAG_USER;
@@ -98,22 +98,22 @@ public class Usage.ProcessRow : Gtk.ListBoxRow {
class_name = CSS_TAG_SYSTEM;
}
- user_tag_box.get_style_context().add_class(class_name);
+ user_tag_box.get_style_context ().add_class (class_name);
user_tag_label.label = app.user.UserName;
- user_tag_box.visible = !is_logged_in();
+ user_tag_box.visible = !is_logged_in ();
}
- private bool is_logged_in(){
- return app.user.UserName == GLib.Environment.get_user_name();
+ private bool is_logged_in (){
+ return app.user.UserName == GLib.Environment.get_user_name ();
}
- public new void activate() {
- var settings = Settings.get_default();
+ public new void activate () {
+ var settings = Settings.get_default ();
if (app.representative_cmdline in settings.get_strv ("unkillable-processes"))
return;
- var dialog = new QuitProcessDialog(app);
- dialog.set_transient_for(get_toplevel() as Gtk.Window);
- dialog.show_all();
+ var dialog = new QuitProcessDialog (app);
+ dialog.set_transient_for (get_toplevel () as Gtk.Window);
+ dialog.show_all ();
}
}
diff --git a/src/process.vala b/src/process.vala
index 946b2e2..b8beb65 100644
--- a/src/process.vala
+++ b/src/process.vala
@@ -40,10 +40,10 @@ public class Usage.Process : Object {
private string? _app_id = null;
private bool _app_id_checked = false;
- public Process(Pid pid) {
+ public Process (Pid pid) {
this.pid = pid;
this.cmdline = get_full_process_cmd (pid);
- this.uid = _get_uid();
+ this.uid = _get_uid ();
}
public void update_status () {
@@ -73,9 +73,9 @@ public class Usage.Process : Object {
mark_as_updated = true;
}
- private uint _get_uid() {
+ private uint _get_uid () {
GTop.ProcUid procUid;
- GTop.get_proc_uid(out procUid, pid);
+ GTop.get_proc_uid (out procUid, pid);
return procUid.uid;
}
@@ -140,10 +140,10 @@ public class Usage.Process : Object {
if (status != IOStatus.NORMAL)
return null;
- lines = data.split("\n");
+ lines = data.split ("\n");
// Only do anything with cgroup v2
- if (!lines[0].has_prefix("0::"))
+ if (!lines[0].has_prefix ("0::"))
return null;
cgroup = lines[0][3:lines[0].length];
@@ -230,7 +230,7 @@ public class Usage.Process : Object {
for (int i = 0; i < str.length; i++) {
if (str[i] == ' ') {
- return str.substring(0, i);
+ return str.substring (0, i);
}
}
diff --git a/src/quit-process-dialog.vala b/src/quit-process-dialog.vala
index 04e5378..61a3552 100644
--- a/src/quit-process-dialog.vala
+++ b/src/quit-process-dialog.vala
@@ -25,21 +25,21 @@ using Gtk;
public class Usage.QuitProcessDialog : Gtk.MessageDialog {
private AppItem app;
- public QuitProcessDialog(AppItem app) {
+ public QuitProcessDialog (AppItem app) {
this.app = app;
- this.text = this.text.printf(app.display_name);
+ this.text = this.text.printf (app.display_name);
}
[GtkCallback]
private void on_force_quit_button_clicked () {
- app.kill();
- this.destroy();
+ app.kill ();
+ this.destroy ();
}
[GtkCallback]
public void cancel () {
/* FIXME: For some reason we are not able to connect to the
* destroy signal right from the .ui file. */
- this.destroy();
+ this.destroy ();
}
}
diff --git a/src/settings.vala b/src/settings.vala
index b86c56b..73a4049 100644
--- a/src/settings.vala
+++ b/src/settings.vala
@@ -30,14 +30,14 @@ public class Usage.Settings : GLib.Settings {
private static Settings settings;
- public static Settings get_default() {
+ public static Settings get_default () {
if (settings == null)
settings = new Settings ();
return settings;
}
- public Settings() {
- Object(schema_id: Config.APPLICATION_ID);
+ public Settings () {
+ Object (schema_id: Config.APPLICATION_ID);
}
}
diff --git a/src/speedometer.vala b/src/speedometer.vala
index 6a29738..e21e025 100644
--- a/src/speedometer.vala
+++ b/src/speedometer.vala
@@ -36,22 +36,22 @@ public class Usage.Speedometer : Buildable, Gtk.Bin {
return _percentage;
}
set {
- on_percentage_changed(value);
+ on_percentage_changed (value);
_percentage = value;
}
}
construct {
- css_provider = new Gtk.CssProvider();
- inner.get_style_context().add_provider(css_provider,
- Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
+ css_provider = new Gtk.CssProvider ();
+ inner.get_style_context ().add_provider (css_provider,
+ Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
- bind_property("width-request", content_area, "width-request", BindingFlags.BIDIRECTIONAL);
- bind_property("height-request", content_area, "height-request", BindingFlags.BIDIRECTIONAL);
+ bind_property ("width-request", content_area, "width-request", BindingFlags.BIDIRECTIONAL);
+ bind_property ("height-request", content_area, "height-request", BindingFlags.BIDIRECTIONAL);
}
- private void on_percentage_changed(int new_value) {
+ private void on_percentage_changed (int new_value) {
if (new_value <= 0 && new_value >= 100)
return;
@@ -70,22 +70,22 @@ public class Usage.Speedometer : Buildable, Gtk.Bin {
}";
try {
- css_provider.load_from_data(css);
+ css_provider.load_from_data (css);
}
catch (GLib.Error error) {
- warning("Failed to animate speedometer: %s", error.message);
+ warning ("Failed to animate speedometer: %s", error.message);
}
}
- public void add_child(Builder builder, Object child, string? type) {
+ public void add_child (Builder builder, Object child, string? type) {
/* This is a Vala bug. It will cause a "warning".
- (content_area as Buildable).add_child(builder, child, type);*/
+ (content_area as Buildable).add_child (builder, child, type);*/
if (child is Gtk.Label) {
- content_area.add(child as Gtk.Widget);
+ content_area.add (child as Gtk.Widget);
return;
}
- base.add_child(builder, child, type);
+ base.add_child (builder, child, type);
}
}
diff --git a/src/storage/storage-actionbar.vala b/src/storage/storage-actionbar.vala
index fa197d4..9d99199 100644
--- a/src/storage/storage-actionbar.vala
+++ b/src/storage/storage-actionbar.vala
@@ -27,57 +27,57 @@ public class Usage.StorageActionBar : Gtk.ActionBar {
public signal void refresh_listbox ();
- public void update_selected_items(List<StorageViewItem> selected_items) {
+ public void update_selected_items (List<StorageViewItem> selected_items) {
this.selected_items = selected_items;
uint64 size = 0;
foreach (var item in selected_items) {
size += item.size;
}
- size_label.label = _("%s selected").printf(Utils.format_size_values(size));
+ size_label.label = _("%s selected").printf (Utils.format_size_values (size));
}
[GtkCallback]
- private void delete_clicked() {
- var application = GLib.Application.get_default() as Application;
+ private void delete_clicked () {
+ var application = GLib.Application.get_default () as Application;
string display_message = _("Are you sure you want to permanently delete selected items?");
if (application == null)
return;
- var dialog = new Gtk.MessageDialog (application.get_window(), Gtk.DialogFlags.MODAL,
+ var dialog = new Gtk.MessageDialog (application.get_window (), Gtk.DialogFlags.MODAL,
Gtk.MessageType.WARNING, Gtk.ButtonsType.OK_CANCEL, display_message);
dialog.secondary_text = _("If you delete these items, they will be permanently lost.");
- if (dialog.run() == Gtk.ResponseType.OK) {
+ if (dialog.run () == Gtk.ResponseType.OK) {
foreach (var item in selected_items) {
if (item.type == FileType.DIRECTORY && item.custom_type == StorageViewType.ROOT_ITEM)
- delete_file(item.uri, false);
+ delete_file (item.uri, false);
else
- delete_file(item.uri, true);
+ delete_file (item.uri, true);
}
- refresh_listbox();
+ refresh_listbox ();
}
- dialog.destroy();
+ dialog.destroy ();
}
- private void delete_file(string uri, bool delete_basefile) {
- var file = File.new_for_uri(uri);
+ private void delete_file (string uri, bool delete_basefile) {
+ var file = File.new_for_uri (uri);
var type = file.query_file_type (FileQueryInfoFlags.NOFOLLOW_SYMLINKS);
try {
if (type == FileType.DIRECTORY) {
FileInfo info;
- FileEnumerator enumerator = file.enumerate_children("standard::*",
FileQueryInfoFlags.NOFOLLOW_SYMLINKS, null);
+ FileEnumerator enumerator = file.enumerate_children ("standard::*",
FileQueryInfoFlags.NOFOLLOW_SYMLINKS, null);
- while((info = enumerator.next_file(null)) != null) {
- var child = file.get_child(info.get_name());
- delete_file(child.get_uri(), true);
+ while ((info = enumerator.next_file (null)) != null) {
+ var child = file.get_child (info.get_name ());
+ delete_file (child.get_uri (), true);
}
}
if (delete_basefile)
- file.delete();
+ file.delete ();
}
catch (Error e) {
stderr.printf ("Error: %s\n", e.message);
diff --git a/src/storage/storage-graph.vala b/src/storage/storage-graph.vala
index f8c8d79..38981aa 100644
--- a/src/storage/storage-graph.vala
+++ b/src/storage/storage-graph.vala
@@ -30,12 +30,12 @@ public class Usage.StorageGraph : Gtk.DrawingArea {
get { return _model; }
set {
_model = value;
- this.draw.connect(draw_storage_graph);
+ this.draw.connect (draw_storage_graph);
this.queue_draw ();
root = false;
- for (int i = 0; i < value.get_n_items(); i++) {
- var item = model.get_item(i) as StorageViewItem;
+ for (int i = 0; i < value.get_n_items (); i++) {
+ var item = model.get_item (i) as StorageViewItem;
if (item.custom_type == StorageViewType.OS) {
root = true;
break;
@@ -47,7 +47,7 @@ public class Usage.StorageGraph : Gtk.DrawingArea {
public uint min_percentage_shown_files { get; set; }
class construct {
- set_css_name("StorageGraph");
+ set_css_name ("StorageGraph");
}
public enum Circle {
@@ -56,7 +56,7 @@ public class Usage.StorageGraph : Gtk.DrawingArea {
BASE
}
- public void update_selected_items(List<StorageViewItem> selected_items) {
+ public void update_selected_items (List<StorageViewItem> selected_items) {
this.selected_items = selected_items;
uint64 size = 0;
@@ -64,22 +64,22 @@ public class Usage.StorageGraph : Gtk.DrawingArea {
size += item.size;
selected_size = size;
- this.queue_draw();
+ this.queue_draw ();
}
- private void draw_circle(Cairo.Context context, double x, double y, double radius, int section, Circle
circle) {
+ private void draw_circle (Cairo.Context context, double x, double y, double radius, int section, Circle
circle) {
double start_angle = 0;
double final_angle = - Math.PI / 2.0;
double ratio = 0;
uint shown_items_number = 1;
- var background_color =
get_toplevel().get_style_context().get_background_color(get_toplevel().get_style_context().get_state());
- var foreground_color = get_style_context().get_color(get_style_context().get_state());
+ var background_color = get_toplevel ().get_style_context ().get_background_color (get_toplevel
().get_style_context ().get_state ());
+ var foreground_color = get_style_context ().get_color (get_style_context ().get_state ());
- for (int i = 1; i < model.get_n_items(); i++) {
- var item = (model.get_item(i) as StorageViewItem);
+ for (int i = 1; i < model.get_n_items (); i++) {
+ var item = (model.get_item (i) as StorageViewItem);
if (i > 0 && i < 3 && (item.percentage < min_percentage_shown_files)) {
- shown_items_number = model.get_n_items();
+ shown_items_number = model.get_n_items ();
continue;
}
@@ -91,25 +91,25 @@ public class Usage.StorageGraph : Gtk.DrawingArea {
if (shown_items_number < 3)
shown_items_number = 3;
- for (int i = 0; i < model.get_n_items(); i++) {
- var item = model.get_item(i) as StorageViewItem;
+ for (int i = 0; i < model.get_n_items (); i++) {
+ var item = model.get_item (i) as StorageViewItem;
var item_radius = radius;
if (item.custom_type == StorageViewType.UP_FOLDER || item.size == 0)
continue;
- var style_context = get_style_context();
- style_context.add_class(item.style_class);
- var base_color = style_context.get_background_color(style_context.get_state());
- style_context.remove_class(item.style_class);
+ var style_context = get_style_context ();
+ style_context.add_class (item.style_class);
+ var base_color = style_context.get_background_color (style_context.get_state ());
+ style_context.remove_class (item.style_class);
Gdk.RGBA fill_color = base_color;
if (!root) {
- fill_color = Utils.generate_color(base_color, i, shown_items_number, true);
+ fill_color = Utils.generate_color (base_color, i, shown_items_number, true);
item.color = fill_color;
}
- if (selected_items.find(item) != null)
+ if (selected_items.find (item) != null)
item_radius += radius / 6;
context.set_line_width (2.0);
@@ -128,9 +128,9 @@ public class Usage.StorageGraph : Gtk.DrawingArea {
Gdk.cairo_set_source_rgba (context, fill_color);
context.arc (x, y, item_radius, start_angle, final_angle);
context.line_to (x, y);
- context.fill_preserve();
+ context.fill_preserve ();
Gdk.cairo_set_source_rgba (context, foreground_color);
- context.stroke();
+ context.stroke ();
if (start_angle >= (2 * Math.PI - Math.PI / 2.0))
break;
@@ -138,17 +138,17 @@ public class Usage.StorageGraph : Gtk.DrawingArea {
context.move_to (x, y);
context.line_to (x, y-(radius));
- context.stroke();
+ context.stroke ();
context.arc (x, y, radius/1.8, 0, 2 * Math.PI);
Gdk.cairo_set_source_rgba (context, background_color);
- context.fill_preserve();
+ context.fill_preserve ();
Gdk.cairo_set_source_rgba (context, foreground_color);
- context.stroke();
+ context.stroke ();
}
}
- private bool draw_storage_graph(Cairo.Context context) {
+ private bool draw_storage_graph (Cairo.Context context) {
int height = this.get_allocated_height ();
int width = this.get_allocated_width ();
@@ -161,38 +161,38 @@ public class Usage.StorageGraph : Gtk.DrawingArea {
x = width / 2.0;
y = height / 2.0;
- draw_circle(context, x, y, radius, 0, Circle.BASE);
- draw_selected_size_text(context);
+ draw_circle (context, x, y, radius, 0, Circle.BASE);
+ draw_selected_size_text (context);
return true;
}
- private void draw_selected_size_text(Cairo.Context context) {
+ private void draw_selected_size_text (Cairo.Context context) {
if (selected_size == 0)
return;
var layout = create_pango_layout (null);
- var text = Utils.format_size_values(selected_size);
+ var text = Utils.format_size_values (selected_size);
int height = get_allocated_height ();
int width = get_allocated_width ();
double radius = int.min (width, height) / 22;
- var text_color =
get_toplevel().get_style_context().get_color(get_toplevel().get_style_context().get_state());
- var text_color_string = "#%02x%02x%02x".printf(
- (uint)(Math.round(text_color.red*255)),
- (uint)(Math.round(text_color.green*255)),
- (uint)(Math.round(text_color.blue*255))).up();
+ var text_color = get_toplevel ().get_style_context ().get_color (get_toplevel ().get_style_context
().get_state ());
+ var text_color_string = "#%02x%02x%02x".printf (
+ (uint)(Math.round (text_color.red*255)),
+ (uint)(Math.round (text_color.green*255)),
+ (uint)(Math.round (text_color.blue*255))).up ();
- var markup = "<span foreground='" + text_color_string + "' font='" + radius.to_string() + "'><b>" +
text + "</b></span>";
+ var markup = "<span foreground='" + text_color_string + "' font='" + radius.to_string () + "'><b>" +
text + "</b></span>";
layout.set_markup (markup, -1);
Pango.Rectangle layout_rect;
layout.get_pixel_extents (null, out layout_rect);
- layout.set_alignment(Pango.Alignment.CENTER);
+ layout.set_alignment (Pango.Alignment.CENTER);
var x = (width - layout_rect.width) / 2;
var y = (height - layout_rect.height) / 2;
- get_style_context().render_layout (context, x, y, layout);
+ get_style_context ().render_layout (context, x, y, layout);
}
}
diff --git a/src/storage/storage-row-popover.vala b/src/storage/storage-row-popover.vala
index 2f45b31..a581c16 100644
--- a/src/storage/storage-row-popover.vala
+++ b/src/storage/storage-row-popover.vala
@@ -35,6 +35,6 @@ public class Usage.StorageRowPopover : Gtk.Popover {
break;
}
- popup();
+ popup ();
}
}
diff --git a/src/storage/storage-view-item.vala b/src/storage/storage-view-item.vala
index 81398bd..f18a9e1 100644
--- a/src/storage/storage-view-item.vala
+++ b/src/storage/storage-view-item.vala
@@ -62,8 +62,8 @@ public class Usage.StorageViewItem : GLib.Object {
}
}
- public static StorageViewItem? from_file(File file) {
- var item = new StorageViewItem();
+ public static StorageViewItem? from_file (File file) {
+ var item = new StorageViewItem ();
item.uri = file.get_uri ();
try {
diff --git a/src/storage/storage-view-row.vala b/src/storage/storage-view-row.vala
index 18bf28d..9d7927e 100644
--- a/src/storage/storage-view-row.vala
+++ b/src/storage/storage-view-row.vala
@@ -63,39 +63,39 @@ public class Usage.StorageViewRow : Gtk.ListBoxRow {
get { return check_button.active; }
}
- public signal void check_button_toggled();
+ public signal void check_button_toggled ();
public StorageViewItem item;
public StorageViewRow.from_item (StorageViewItem item) {
this.item = item;
- var tag_style_context = tag.get_style_context();
+ var tag_style_context = tag.get_style_context ();
tag_style_context.add_class (item.style_class);
- item.color = tag_style_context.get_background_color(tag_style_context.get_state());
+ item.color = tag_style_context.get_background_color (tag_style_context.get_state ());
check_button.visible = item.show_check_button;
- check_button.toggled.connect(() => {
- check_button_toggled();
+ check_button.toggled.connect (() => {
+ check_button_toggled ();
});
- item.notify.connect(() => {
- set_up();
+ item.notify.connect (() => {
+ set_up ();
});
- set_up();
+ set_up ();
if (item.type == FileType.DIRECTORY || item.custom_type != StorageViewType.NONE)
tag.width_request = tag.height_request = 20;
if (item.custom_type == StorageViewType.UP_FOLDER) {
- get_style_context().add_class("up-folder");
+ get_style_context ().add_class ("up-folder");
if (!item.loaded) {
spinner.visible = true;
size_label.visible = false;
}
- item.notify["loaded"].connect(() => {
+ item.notify["loaded"].connect (() => {
if (item.loaded) {
spinner.visible = false;
size_label.visible = true;
@@ -104,15 +104,15 @@ public class Usage.StorageViewRow : Gtk.ListBoxRow {
}
}
- private void set_up() {
+ private void set_up () {
title.label = item.name;
size_label.label = Utils.format_size_values (item.size);
- change_color(item.color);
+ change_color (item.color);
}
- private void change_color(Gdk.RGBA color) {
- var css_provider = new Gtk.CssProvider();
- tag.get_style_context().add_provider(css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
+ private void change_color (Gdk.RGBA color) {
+ var css_provider = new Gtk.CssProvider ();
+ tag.get_style_context ().add_provider (css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
var css =
@".row-tag {
@@ -120,10 +120,10 @@ public class Usage.StorageViewRow : Gtk.ListBoxRow {
}";
try {
- css_provider.load_from_data(css);
+ css_provider.load_from_data (css);
}
catch (GLib.Error error) {
- warning("Failed to color StorageViewRow: %s", error.message);
+ warning ("Failed to color StorageViewRow: %s", error.message);
}
}
}
diff --git a/src/storage/storage-view.vala b/src/storage/storage-view.vala
index 35d2bb7..2138b1f 100644
--- a/src/storage/storage-view.vala
+++ b/src/storage/storage-view.vala
@@ -52,8 +52,8 @@ public class Usage.StorageView : Usage.View {
private StorageQueryBuilder query_builder;
private StorageViewItem os_item = new StorageViewItem ();
- private StorageRowPopover row_popover = new StorageRowPopover();
- private Cancellable cancellable = new Cancellable();
+ private StorageRowPopover row_popover = new StorageRowPopover ();
+ private Cancellable cancellable = new Cancellable ();
private uint need_refresh_depth = 0;
@@ -87,21 +87,21 @@ public class Usage.StorageView : Usage.View {
query_builder = new StorageQueryBuilder ();
controller = new TrackerController (connection);
- actionbar.refresh_listbox.connect(() => {
- var item = actual_item.peek_head();
+ actionbar.refresh_listbox.connect (() => {
+ var item = actual_item.peek_head ();
- stack_listbox_up();
- clear_selected_items();
+ stack_listbox_up ();
+ clear_selected_items ();
- if (listbox.get_depth() >= 1) {
- selected_items_stack.push_head((owned) selected_items);
- actual_item.push_head(item);
+ if (listbox.get_depth () >= 1) {
+ selected_items_stack.push_head ((owned) selected_items);
+ actual_item.push_head (item);
present_dir.begin (item.uri, item.dir, cancellable);
} else {
populate_view.begin ();
}
- need_refresh_depth = listbox.get_depth();
+ need_refresh_depth = listbox.get_depth ();
});
}
@@ -117,53 +117,53 @@ public class Usage.StorageView : Usage.View {
private void on_row_activated (Gtk.ListBoxRow row) {
var storage_row = row as StorageViewRow;
- cancellable.cancel();
- cancellable = new Cancellable();
+ cancellable.cancel ();
+ cancellable = new Cancellable ();
if (storage_row.item.custom_type == StorageViewType.UP_FOLDER) {
- stack_listbox_up();
+ stack_listbox_up ();
} else if (storage_row.item.type == FileType.DIRECTORY) {
- selected_items_stack.push_head((owned) selected_items);
- actual_item.push_head(storage_row.item);
- clear_selected_items();
+ selected_items_stack.push_head ((owned) selected_items);
+ actual_item.push_head (storage_row.item);
+ clear_selected_items ();
present_dir.begin (storage_row.item.uri, storage_row.item.dir, cancellable);
} else if (storage_row.item.custom_type != StorageViewType.NONE) {
- row_popover.present(storage_row);
+ row_popover.present (storage_row);
} else {
try {
- AppInfo.launch_default_for_uri(storage_row.item.uri, null);
+ AppInfo.launch_default_for_uri (storage_row.item.uri, null);
} catch (GLib.Error error) {
warning (error.message);
}
}
}
- private void stack_listbox_up() {
- selected_items = selected_items_stack.pop_head();
- actual_item.pop_head();
- refresh_actionbar();
- listbox.pop();
+ private void stack_listbox_up () {
+ selected_items = selected_items_stack.pop_head ();
+ actual_item.pop_head ();
+ refresh_actionbar ();
+ listbox.pop ();
- var first_item = listbox.get_model().get_item(0) as StorageViewItem;
+ var first_item = listbox.get_model ().get_item (0) as StorageViewItem;
var refresh = false;
- if (need_refresh_depth >= listbox.get_depth()) {
+ if (need_refresh_depth >= listbox.get_depth ()) {
need_refresh_depth -= 1;
refresh = true;
}
- if (listbox.get_depth() > 1 && first_item.loaded == false || refresh) {
- var item = actual_item.peek_head();
+ if (listbox.get_depth () > 1 && first_item.loaded == false || refresh) {
+ var item = actual_item.peek_head ();
- clear_selected_items();
- listbox.pop();
+ clear_selected_items ();
+ listbox.pop ();
- if (listbox.get_depth() == 0)
+ if (listbox.get_depth () == 0)
populate_view.begin ();
else
present_dir.begin (item.uri, item.dir, cancellable);
} else {
- graph.model = (ListStore) listbox.get_model();
+ graph.model = (ListStore) listbox.get_model ();
}
}
@@ -176,27 +176,27 @@ public class Usage.StorageView : Usage.View {
var row = new StorageViewRow.from_item (item);
row.visible = true;
- if (selected_items.find(item) != null)
+ if (selected_items.find (item) != null)
row.check_button.active = true;
- row.check_button_toggled.connect(() => {
+ row.check_button_toggled.connect (() => {
if (row.selected)
- selected_items.append(row.item);
+ selected_items.append (row.item);
else
- selected_items.remove(row.item);
+ selected_items.remove (row.item);
- refresh_actionbar();
+ refresh_actionbar ();
});
if (item.custom_type == StorageViewType.AVAILABLE_GRAPH)
- return new Gtk.ListBoxRow();
+ return new Gtk.ListBoxRow ();
- graph.model = (ListStore) listbox.get_model();
+ graph.model = (ListStore) listbox.get_model ();
return row;
}
private async void present_dir (string uri, UserDirectory? dir, Cancellable cancellable) {
- if (connection == null || cancellable.is_cancelled())
+ if (connection == null || cancellable.is_cancelled ())
return;
var model = new GLib.ListStore (typeof (StorageViewItem));
@@ -204,20 +204,20 @@ public class Usage.StorageView : Usage.View {
var item = StorageViewItem.from_file (file);
item.custom_type = StorageViewType.UP_FOLDER;
item.dir = dir;
- model.insert(0, item);
+ model.insert (0, item);
- controller.set_model(model);
- controller.enumerate_children.begin(uri, dir, cancellable, (obj, res) => {
- if (!cancellable.is_cancelled()) {
- var up_folder_item = model.get_item(0) as StorageViewItem;
- up_folder_item.size = controller.enumerate_children.end(res);
+ controller.set_model (model);
+ controller.enumerate_children.begin (uri, dir, cancellable, (obj, res) => {
+ if (!cancellable.is_cancelled ()) {
+ var up_folder_item = model.get_item (0) as StorageViewItem;
+ up_folder_item.size = controller.enumerate_children.end (res);
up_folder_item.loaded = true;
graph.model = model;
}
});
- listbox.push (new Gtk.ListBoxRow(), model, create_file_row);
- if (!cancellable.is_cancelled())
+ listbox.push (new Gtk.ListBoxRow (), model, create_file_row);
+ if (!cancellable.is_cancelled ())
graph.model = model;
}
@@ -258,13 +258,13 @@ public class Usage.StorageView : Usage.View {
var total_used_percentage = ((double) total_used_size / total_size) * 100;
var total_free_percentage = ((double) total_free_size / total_size) * 100;
- total_used_percentage = Math.round(total_used_percentage);
- total_free_percentage = Math.round(total_free_percentage);
+ total_used_percentage = Math.round (total_used_percentage);
+ total_free_percentage = Math.round (total_free_percentage);
- used_row.size_label.label = Utils.format_size_values (total_used_size) + " (%d%)".printf((int)
total_used_percentage);
+ used_row.size_label.label = Utils.format_size_values (total_used_size) + " (%d%)".printf ((int)
total_used_percentage);
used_row.tag.get_style_context ().add_class ("used-tag");
- available_row.size_label.label = Utils.format_size_values (total_free_size) + " (%d%)".printf((int)
total_free_percentage);
+ available_row.size_label.label = Utils.format_size_values (total_free_size) + " (%d%)".printf ((int)
total_free_percentage);
available_row.tag.get_style_context ().add_class ("available-tag");
}
@@ -275,7 +275,7 @@ public class Usage.StorageView : Usage.View {
return;
var model = new GLib.ListStore (typeof (StorageViewItem));
- model.append(os_item);
+ model.append (os_item);
var items_loaded = 0;
@@ -293,35 +293,35 @@ public class Usage.StorageView : Usage.View {
items_loaded++;
if (items_loaded == xdg_folders.length)
- loading_notification.dismiss();
+ loading_notification.dismiss ();
} catch (GLib.Error error) {
warning (error.message);
}
});
}
- listbox.push (new Gtk.ListBoxRow(), model, create_file_row);
+ listbox.push (new Gtk.ListBoxRow (), model, create_file_row);
var available_graph_item = new StorageViewItem ();
available_graph_item.size = total_free_size;
available_graph_item.custom_type = StorageViewType.AVAILABLE_GRAPH;
available_graph_item.percentage = available_graph_item.size * 100 / (double) total_size;
- model.append(available_graph_item);
+ model.append (available_graph_item);
graph.model = model;
}
- private void refresh_actionbar() {
- actionbar.update_selected_items(selected_items);
- graph.update_selected_items(selected_items);
+ private void refresh_actionbar () {
+ actionbar.update_selected_items (selected_items);
+ graph.update_selected_items (selected_items);
- if (selected_items.length() == 0)
- actionbar.hide();
+ if (selected_items.length () == 0)
+ actionbar.hide ();
else
- actionbar.show();
+ actionbar.show ();
}
- private void clear_selected_items() {
+ private void clear_selected_items () {
selected_items = new List<StorageViewItem>();
- refresh_actionbar();
+ refresh_actionbar ();
}
}
diff --git a/src/storage/tracker-controller.vala b/src/storage/tracker-controller.vala
index f7d5fb6..34debdf 100644
--- a/src/storage/tracker-controller.vala
+++ b/src/storage/tracker-controller.vala
@@ -33,7 +33,7 @@ public class Usage.TrackerController : GLib.Object {
this.connection = connection;
}
- public void set_model(GLib.ListStore model) {
+ public void set_model (GLib.ListStore model) {
this.model = model;
}
@@ -53,7 +53,7 @@ public class Usage.TrackerController : GLib.Object {
parent_size = yield get_file_size (uri);
while (yield worker.fetch_next (out n_uri, out file_type)) {
- if (!cancellable.is_cancelled()) {
+ if (!cancellable.is_cancelled ()) {
var file = File.new_for_uri (n_uri);
var item = StorageViewItem.from_file (file);
diff --git a/src/swap-speedometer.vala b/src/swap-speedometer.vala
index 4b7b5e5..b608a35 100644
--- a/src/swap-speedometer.vala
+++ b/src/swap-speedometer.vala
@@ -37,22 +37,22 @@ public class Usage.SwapSpeedometer : Gtk.Bin {
private double swap_usage { get; set; }
construct {
- var monitor = SystemMonitor.get_default();
- Timeout.add_seconds(1, () => {
+ var monitor = SystemMonitor.get_default ();
+ Timeout.add_seconds (1, () => {
var available = (monitor.swap_total - monitor.swap_usage);
var percentage = 0.0;
if (available > 0)
percentage = (((double) monitor.swap_usage / monitor.swap_total) * 100);
- this.speedometer.percentage = (int)percentage;
- label.label = "%d".printf((int)percentage) + "%";
+ this.speedometer.percentage = (int) percentage;
+ label.label = "%d".printf ((int) percentage) + "%";
- swap_used.label = Utils.format_size_values(monitor.swap_usage);
- swap_available.label = Utils.format_size_values(available);
+ swap_used.label = Utils.format_size_values (monitor.swap_usage);
+ swap_available.label = Utils.format_size_values (available);
return true;
});
- this.show_all();
+ this.show_all ();
}
}
diff --git a/src/system-monitor.vala b/src/system-monitor.vala
index b69c494..5cc9421 100644
--- a/src/system-monitor.vala
+++ b/src/system-monitor.vala
@@ -37,75 +37,75 @@ public class Usage.SystemMonitor : Object {
private int process_mode = GTop.KERN_PROC_ALL;
private static SystemMonitor system_monitor;
- public static SystemMonitor get_default() {
+ public static SystemMonitor get_default () {
if (system_monitor == null)
system_monitor = new SystemMonitor ();
return system_monitor;
}
- public List<unowned AppItem> get_apps() {
- return app_table.get_values();
+ public List<unowned AppItem> get_apps () {
+ return app_table.get_values ();
}
- public unowned AppItem get_app_by_name(string name) {
- return app_table.get(name);
+ public unowned AppItem get_app_by_name (string name) {
+ return app_table.get (name);
}
- public SystemMonitor() {
- GTop.init();
- AppItem.init();
+ public SystemMonitor () {
+ GTop.init ();
+ AppItem.init ();
- cpu_monitor = new CpuMonitor();
- memory_monitor = new MemoryMonitor();
- gamemode_pids = new GameMode.PidList();
+ cpu_monitor = new CpuMonitor ();
+ memory_monitor = new MemoryMonitor ();
+ gamemode_pids = new GameMode.PidList ();
- app_table = new HashTable<string, AppItem>(str_hash, str_equal);
- process_table = new HashTable<GLib.Pid, Process>(direct_hash, direct_equal);
- var settings = Settings.get_default();
+ app_table = new HashTable<string, AppItem> (str_hash, str_equal);
+ process_table = new HashTable<GLib.Pid, Process> (direct_hash, direct_equal);
+ var settings = Settings.get_default ();
- init();
+ init ();
this.notify["group-system-apps"].connect ((sender, property) => {
- init();
+ init ();
});
- Timeout.add(settings.data_update_interval, update_data);
+ Timeout.add (settings.data_update_interval, update_data);
}
- private void init() {
- var settings = Settings.get_default();
- app_table.remove_all();
+ private void init () {
+ var settings = Settings.get_default ();
+ app_table.remove_all ();
process_list_ready = false;
if (group_system_apps) {
- var system = new AppItem.system();
- app_table.insert("system" , system);
+ var system = new AppItem.system ();
+ app_table.insert ("system" , system);
}
foreach (var p in process_table.get_values ()) {
process_added (p);
}
- update_data();
- Timeout.add(settings.data_update_interval, () => {
+ update_data ();
+ Timeout.add (settings.data_update_interval, () => {
process_list_ready = true;
return false;
});
}
- private bool update_data() {
- cpu_monitor.update();
- memory_monitor.update();
+ private bool update_data () {
+ cpu_monitor.update ();
+ memory_monitor.update ();
- cpu_load = cpu_monitor.get_cpu_load();
- x_cpu_load = cpu_monitor.get_x_cpu_load();
- ram_usage = memory_monitor.get_ram_usage();
- ram_total = memory_monitor.get_ram_total();
- swap_usage = memory_monitor.get_swap_usage();
- swap_total = memory_monitor.get_swap_total();
+ cpu_load = cpu_monitor.get_cpu_load ();
+ x_cpu_load = cpu_monitor.get_x_cpu_load ();
+ ram_usage = memory_monitor.get_ram_usage ();
+ ram_total = memory_monitor.get_ram_total ();
+ swap_usage = memory_monitor.get_swap_usage ();
+ swap_total = memory_monitor.get_swap_total ();
foreach (var app in app_table.get_values ())
- app.mark_as_not_updated();
+ app.mark_as_not_updated ();
/* Try to find the difference between the old list of pids,
* and the new ones, i.e. the one that got added and removed */
@@ -227,11 +227,11 @@ public class Usage.SystemMonitor : Object {
return p.cmdline;
}
- private void update_process(ref Process process) {
- cpu_monitor.update_process(ref process);
- memory_monitor.update_process(ref process);
- process.update_status();
- process.gamemode = gamemode_pids.contains((int) process.pid);
+ private void update_process (ref Process process) {
+ cpu_monitor.update_process (ref process);
+ memory_monitor.update_process (ref process);
+ process.update_status ();
+ process.gamemode = gamemode_pids.contains ((int) process.pid);
}
public static void sort_pids (void *pids, size_t elm, size_t length) {
diff --git a/src/utils.vala b/src/utils.vala
index 1f8a588..d3ca9ff 100644
--- a/src/utils.vala
+++ b/src/utils.vala
@@ -19,21 +19,21 @@
*/
public class Usage.Utils {
- public static string format_size_values(uint64 value) {
+ public static string format_size_values (uint64 value) {
if (value >= 1000)
- return GLib.format_size(value);
+ return GLib.format_size (value);
else
- return _("%llu B").printf(value);
+ return _("%llu B").printf (value);
}
- public static string format_size_speed_values(uint64 value) {
+ public static string format_size_speed_values (uint64 value) {
if (value >= 1000)
- return _("%s/s").printf(GLib.format_size(value));
+ return _("%s/s").printf (GLib.format_size (value));
else
- return _("%llu B/s").printf(value);
+ return _("%llu B/s").printf (value);
}
- public static Gdk.RGBA generate_color(Gdk.RGBA default_color, uint order, uint all_count, bool reverse =
false) {
+ public static Gdk.RGBA generate_color (Gdk.RGBA default_color, uint order, uint all_count, bool reverse
= false) {
double step = 100 / (double) all_count;
uint half_count = all_count / 2;
@@ -43,40 +43,40 @@ public class Usage.Utils {
if (order > (all_count / 2)) {
double percentage = step * (order - half_count);
if (reverse)
- return Utils.color_lighter(default_color, percentage);
+ return Utils.color_lighter (default_color, percentage);
else
- return Utils.color_darker(default_color, percentage);
+ return Utils.color_darker (default_color, percentage);
} else {
double percentage = step * (half_count - (order-1));
if (reverse)
- return Utils.color_darker(default_color, percentage);
+ return Utils.color_darker (default_color, percentage);
else
- return Utils.color_lighter(default_color, percentage);
+ return Utils.color_lighter (default_color, percentage);
}
}
- public static Gdk.RGBA color_darker(Gdk.RGBA color, double percentage) {
- color.red = color_field_darker(color.red, percentage);
- color.green = color_field_darker(color.green, percentage);
- color.blue = color_field_darker(color.blue, percentage);
+ public static Gdk.RGBA color_darker (Gdk.RGBA color, double percentage) {
+ color.red = color_field_darker (color.red, percentage);
+ color.green = color_field_darker (color.green, percentage);
+ color.blue = color_field_darker (color.blue, percentage);
return color;
}
- public static Gdk.RGBA color_lighter(Gdk.RGBA color, double percentage) {
- color.red = color_field_lighter(color.red, percentage);
- color.green = color_field_lighter(color.green, percentage);
- color.blue = color_field_lighter(color.blue, percentage);
+ public static Gdk.RGBA color_lighter (Gdk.RGBA color, double percentage) {
+ color.red = color_field_lighter (color.red, percentage);
+ color.green = color_field_lighter (color.green, percentage);
+ color.blue = color_field_lighter (color.blue, percentage);
return color;
}
- private static double color_field_darker(double field, double percentage) {
+ private static double color_field_darker (double field, double percentage) {
field = field * 255;
return (field - ((field / 100) * percentage)) / 255;
}
- private static double color_field_lighter(double field, double percentage) {
+ private static double color_field_lighter (double field, double percentage) {
field = field * 255;
return (field + (((255 - field) / 100) * percentage)) / 255;
}
diff --git a/src/view.vala b/src/view.vala
index 2e39a2b..61c5227 100644
--- a/src/view.vala
+++ b/src/view.vala
@@ -28,5 +28,5 @@ public abstract class Usage.View : Gtk.Bin {
}
public interface Usage.SubView {
- public abstract void search_in_processes(string text);
+ public abstract void search_in_processes (string text);
}
diff --git a/src/window.vala b/src/window.vala
index 95b4e9c..6196d7f 100644
--- a/src/window.vala
+++ b/src/window.vala
@@ -48,36 +48,36 @@ public class Usage.Window : Hdy.ApplicationWindow {
private View[] views;
- public Window(Gtk.Application application) {
- GLib.Object(application : application);
+ public Window (Gtk.Application application) {
+ GLib.Object (application : application);
if (Config.PROFILE == "Devel") {
- get_style_context().add_class("devel");
+ get_style_context ().add_class ("devel");
}
- load_css();
- Gtk.Settings.get_for_screen(get_screen()).notify["gtk-application-prefer-dark-theme"].connect(() => {
- load_css();
+ load_css ();
+ Gtk.Settings.get_for_screen (get_screen ()).notify["gtk-application-prefer-dark-theme"].connect (()
=> {
+ load_css ();
});
mode = HeaderBarMode.PERFORMANCE;
- menu = new Usage.PrimaryMenu();
- this.primary_menu_button.set_popover(menu);
+ menu = new Usage.PrimaryMenu ();
+ this.primary_menu_button.set_popover (menu);
- set_mode(HeaderBarMode.PERFORMANCE);
+ set_mode (HeaderBarMode.PERFORMANCE);
views = new View[] {
- new PerformanceView(),
- new StorageView(),
+ new PerformanceView (),
+ new StorageView (),
};
foreach (var view in views) {
- stack.add_titled(view, view.name, view.title);
+ stack.add_titled (view, view.name, view.title);
stack.child_set (view, "icon-name", view.icon_name, null);
}
}
- public void set_mode(HeaderBarMode mode) {
+ public void set_mode (HeaderBarMode mode) {
switch (this.mode) {
case HeaderBarMode.PERFORMANCE:
performance_search_revealer.reveal_child = false;
@@ -97,44 +97,44 @@ public class Usage.Window : Hdy.ApplicationWindow {
this.mode = mode;
}
- public void action_on_search() {
+ public void action_on_search () {
switch (mode) {
case HeaderBarMode.PERFORMANCE:
- performance_search_button.set_active(!performance_search_button.get_active());
+ performance_search_button.set_active (!performance_search_button.get_active ());
break;
case HeaderBarMode.STORAGE:
break;
}
}
- public View[] get_views() {
+ public View[] get_views () {
return views;
}
- private void load_css() {
- var provider = new Gtk.CssProvider();
- Gtk.StyleContext.reset_widgets(get_screen());
- provider.load_from_resource("/org/gnome/Usage/interface/adwaita.css");
- Gtk.StyleContext.add_provider_for_screen(get_screen(), provider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
+ private void load_css () {
+ var provider = new Gtk.CssProvider ();
+ Gtk.StyleContext.reset_widgets (get_screen ());
+ provider.load_from_resource ("/org/gnome/Usage/interface/adwaita.css");
+ Gtk.StyleContext.add_provider_for_screen (get_screen (), provider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
}
[GtkCallback]
private void on_performance_search_button_toggled () {
- var application = GLib.Application.get_default() as Application;
+ var application = GLib.Application.get_default () as Application;
if (application == null)
return;
/* TODO: Implement a saner way of toggling this mode. */
- ((PerformanceView)
application.get_window().get_views()[Views.PERFORMANCE]).set_search_mode(performance_search_button.active);
+ ((PerformanceView) application.get_window ().get_views ()[Views.PERFORMANCE]).set_search_mode
(performance_search_button.active);
}
[GtkCallback]
- private void on_visible_child_changed() {
+ private void on_visible_child_changed () {
if (stack.visible_child_name == views[Views.PERFORMANCE].name) {
- set_mode(HeaderBarMode.PERFORMANCE);
+ set_mode (HeaderBarMode.PERFORMANCE);
} else if (stack.visible_child_name == views[Views.STORAGE].name) {
- set_mode(HeaderBarMode.STORAGE);
+ set_mode (HeaderBarMode.STORAGE);
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]