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

Fix building on Fedora 26.

parent d8f44b58
......@@ -71,6 +71,22 @@ namespace Usage
public bool update()
{
CompareDataFunc<Process> processcmp = (a, b) => {
Process p_a = (Process) a;
Process p_b = (Process) b;
switch(type)
{
default:
case ProcessListBoxType.PROCESSOR:
return (int) ((uint64) (p_a.get_cpu_load() < p_b.get_cpu_load()) - (uint64) (p_a.get_cpu_load() > p_b.get_cpu_load()));
case ProcessListBoxType.MEMORY:
return (int) ((uint64) (p_a.get_mem_usage() < p_b.get_mem_usage()) - (uint64) (p_a.get_mem_usage() > p_b.get_mem_usage()));
case ProcessListBoxType.NETWORK:
return (int) ((uint64) (p_a.get_net_all() < p_b.get_net_all()) - (uint64) (p_a.get_net_all() > p_b.get_net_all()));
}
};
bind_model(null, null);
model.remove_all();
......@@ -81,15 +97,15 @@ namespace Usage
default:
case ProcessListBoxType.PROCESSOR:
foreach(unowned Process process in (GLib.Application.get_default() as Application).get_system_monitor().get_cpu_processes())
model.insert_sorted(process, sort);
model.insert_sorted(process, processcmp);
break;
case ProcessListBoxType.MEMORY:
foreach(unowned Process process in (GLib.Application.get_default() as Application).get_system_monitor().get_ram_processes())
model.insert_sorted(process, sort);
model.insert_sorted(process, processcmp);
break;
case ProcessListBoxType.NETWORK:
foreach(unowned Process process in (GLib.Application.get_default() as Application).get_system_monitor().get_net_processes())
model.insert_sorted(process, sort);
model.insert_sorted(process, processcmp);
break;
}
}
......@@ -98,7 +114,7 @@ namespace Usage
foreach(unowned Process process in (GLib.Application.get_default() as Application).get_system_monitor().get_ram_processes()) //because ram contains all processes
{
if(process.get_display_name().down().contains(search_text.down()) || process.get_cmdline().down().contains(search_text.down()))
model.insert_sorted(process, sort);
model.insert_sorted(process, processcmp);
}
}
......@@ -160,22 +176,5 @@ namespace Usage
row.set_header(separator);
}
}
private int sort(GLib.CompareDataFunc.G a, GLib.CompareDataFunc.G b)
{
Process p_a = (Process) a;
Process p_b = (Process) b;
switch(type)
{
default:
case ProcessListBoxType.PROCESSOR:
return (int) ((uint64) (p_a.get_cpu_load() < p_b.get_cpu_load()) - (uint64) (p_a.get_cpu_load() > p_b.get_cpu_load()));
case ProcessListBoxType.MEMORY:
return (int) ((uint64) (p_a.get_mem_usage() < p_b.get_mem_usage()) - (uint64) (p_a.get_mem_usage() > p_b.get_mem_usage()));
case ProcessListBoxType.NETWORK:
return (int) ((uint64) (p_a.get_net_all() < p_b.get_net_all()) - (uint64) (p_a.get_net_all() > p_b.get_net_all()));
}
}
}
}
......@@ -54,32 +54,74 @@ namespace Usage
public StorageItem.directory(StorageItemType parent, string name, string path, uint64 size, double percentage)
{
StorageItem.item(StorageItemType.DIRECTORY, parent, name, path, size, percentage);
this.type = StorageItemType.DIRECTORY;
this.parent = parent;
this.name = name;
this.path = path;
this.size = size;
this.percentage = percentage;
this.section = 0;
this.prefered_position = StorageItemPosition.ANYWHERE;
}
public StorageItem.file(StorageItemType parent, string name, string path, uint64 size, double percentage)
{
StorageItem.item(StorageItemType.FILE, parent, name, path, size, percentage);
this.type = StorageItemType.FILE;
this.parent = parent;
this.name = name;
this.path = path;
this.size = size;
this.percentage = percentage;
this.section = 0;
this.prefered_position = StorageItemPosition.ANYWHERE;
}
public StorageItem.trash(string path, uint64 size, double percentage, int section = 0)
{
StorageItem.item(StorageItemType.TRASH, StorageItemType.TRASH, _("Trash"), path, size, percentage, section, StorageItemPosition.PENULTIMATE);
this.type = StorageItemType.TRASH;
this.parent = StorageItemType.TRASH;
this.name = _("Trash");
this.path = path;
this.size = size;
this.percentage = percentage;
this.section = section;
this.prefered_position = StorageItemPosition.PENULTIMATE;
}
public StorageItem.storage(string name, string path, uint64 size, int section = 0)
{
StorageItem.item(StorageItemType.STORAGE, StorageItemType.STORAGE, name, path, size, 0, section, StorageItemPosition.FIRST);
this.type = StorageItemType.STORAGE;
this.parent = StorageItemType.STORAGE;
this.name = name;
this.path = path;
this.size = size;
this.percentage = 0;
this.section = section;
this.prefered_position = StorageItemPosition.FIRST;
}
public StorageItem.system(string name, uint64 size, double percentage, int section = 0)
{
StorageItem.item(StorageItemType.SYSTEM, StorageItemType.SYSTEM, name, "", size, percentage, section);
this.type = StorageItemType.SYSTEM;
this.parent = StorageItemType.SYSTEM;
this.name = name;
this.path = "";
this.size = size;
this.percentage = percentage;
this.section = section;
this.prefered_position = StorageItemPosition.ANYWHERE;
}
public StorageItem.available(uint64 size, double percentage, int section = 0)
{
StorageItem.item(StorageItemType.AVAILABLE, StorageItemType.AVAILABLE, _("Available"), "", size, percentage, section, StorageItemPosition.LAST);
this.type = StorageItemType.AVAILABLE;
this.parent = StorageItemType.AVAILABLE;
this.name = _("Available");
this.path = "";
this.size = size;
this.percentage = percentage;
this.section = section;
this.prefered_position = StorageItemPosition.LAST;
}
public StorageItemPosition get_prefered_position()
......@@ -132,4 +174,4 @@ namespace Usage
return path;
}
}
}
\ No newline at end of file
}
......@@ -31,11 +31,27 @@ namespace Usage
private void update()
{
CompareDataFunc<Process> processcmp = (a, b) => {
Process p_a = (Process) a;
Process p_b = (Process) b;
switch(type)
{
default:
case ProcessListBoxType.PROCESSOR:
return (int) ((uint64) (p_a.get_cpu_load() < p_b.get_cpu_load()) - (uint64) (p_a.get_cpu_load() > p_b.get_cpu_load()));
case ProcessListBoxType.MEMORY:
return (int) ((uint64) (p_a.get_mem_usage() < p_b.get_mem_usage()) - (uint64) (p_a.get_mem_usage() > p_b.get_mem_usage()));
case ProcessListBoxType.NETWORK:
return (int) ((uint64) (p_a.get_net_all() < p_b.get_net_all()) - (uint64) (p_a.get_net_all() > p_b.get_net_all()));
}
};
if(parent_process.get_sub_processes() != null)
{
foreach(unowned Process process in parent_process.get_sub_processes().get_values())
{
model.insert_sorted(process, sort);
model.insert_sorted(process, processcmp);
}
}
}
......@@ -59,22 +75,5 @@ namespace Usage
row.set_header(separator);
}
}
private int sort(GLib.CompareDataFunc.G a, GLib.CompareDataFunc.G b)
{
Process p_a = (Process) a;
Process p_b = (Process) b;
switch(type)
{
default:
case ProcessListBoxType.PROCESSOR:
return (int) ((uint64) (p_a.get_cpu_load() < p_b.get_cpu_load()) - (uint64) (p_a.get_cpu_load() > p_b.get_cpu_load()));
case ProcessListBoxType.MEMORY:
return (int) ((uint64) (p_a.get_mem_usage() < p_b.get_mem_usage()) - (uint64) (p_a.get_mem_usage() > p_b.get_mem_usage()));
case ProcessListBoxType.NETWORK:
return (int) ((uint64) (p_a.get_net_all() < p_b.get_net_all()) - (uint64) (p_a.get_net_all() > p_b.get_net_all()));
}
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment