Top/ps process monitor
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2254 lines
68 KiB

5 years ago
#include "system.h"
#include "process.h"
#include "disks.h"
5 years ago
#include "ui.h"
#include <stdio.h>
#include <sys/types.h>
#include <pwd.h>
#if defined(__APPLE__) && defined(__MACH__)
# define __MacOS__
#endif
static Eina_Lock _lock;
5 years ago
static results_t *_results = NULL;
static long _memory_total = 0, _memory_used = 0;
static Data_Unit _data_unit_current = 0;
void
ui_shutdown(Ui *ui)
{
evas_object_hide(ui->win);
if (ui->thread_system)
ecore_thread_cancel(ui->thread_system);
if (ui->thread_process)
ecore_thread_cancel(ui->thread_process);
if (ui->thread_system)
ecore_thread_wait(ui->thread_system, 1.0);
if (ui->thread_process)
ecore_thread_wait(ui->thread_process, 1.0);
eina_lock_free(&_lock);
ecore_main_loop_quit();
}
5 years ago
static void
5 years ago
_system_stats_thread(void *data, Ecore_Thread *thread)
5 years ago
{
Ui *ui;
int i;
ui = data;
while (1)
{
results_t *results = malloc(sizeof(results_t));
system_stats_all_get(results);
ecore_thread_feedback(thread, results);
for (i = 0; i < ui->poll_delay * 2; i++)
{
if (ecore_thread_check(thread))
return;
if (ui->skip_wait)
{
ui->skip_wait = EINA_FALSE;
break;
}
5 years ago
usleep(500000);
}
}
}
const char *
_data_unit_symbol_get(Data_Unit unit)
5 years ago
{
const char *symbol;
5 years ago
switch (unit)
5 years ago
{
case DATA_UNIT_KB:
symbol = "K";
break;
5 years ago
case DATA_UNIT_MB:
symbol = "M";
break;
5 years ago
case DATA_UNIT_GB:
symbol = "G";
break;
}
5 years ago
return symbol;
5 years ago
}
static unsigned long
_mem_adjust(Data_Unit unit, unsigned long value)
5 years ago
{
if (unit == DATA_UNIT_KB)
{
//FIXME: KB is memory base default.
}
else if (unit == DATA_UNIT_MB)
{
value >>= 10;
}
else if (unit == DATA_UNIT_GB)
{
value >>= 20;
}
5 years ago
return value;
5 years ago
}
static char *
_progress_mem_format_cb(double val)
5 years ago
{
char buf[1024];
const char *symbol = _data_unit_symbol_get(_data_unit_current);
5 years ago
snprintf(buf, sizeof(buf), "%ld %c out of %ld %c",
_mem_adjust(_data_unit_current, _memory_used), *symbol,
_mem_adjust(_data_unit_current, _memory_total), *symbol);
5 years ago
return strdup(buf);
5 years ago
}
static void
_progress_mem_format_free_cb(char *str)
5 years ago
{
if (str)
free(str);
5 years ago
}
static char *
_progress_incoming_format_cb(double val)
5 years ago
{
char buf[1024];
double incoming;
const char *unit = "B/s";
5 years ago
incoming = _results->incoming;
if (incoming > 1048576)
{
incoming /= 1048576;
unit = "MB/s";
}
else if (incoming > 1024 && incoming < 1048576)
{
incoming /= 1024;
unit = "KB/s";
}
5 years ago
snprintf(buf, sizeof(buf), "%.2f %s", incoming, unit);
5 years ago
return strdup(buf);
5 years ago
}
static void
_progress_incoming_format_free_cb(char *str)
5 years ago
{
if (str)
free(str);
5 years ago
}
static char *
_progress_outgoing_format_cb(double val)
5 years ago
{
char buf[1024];
double outgoing;
const char *unit = "B/s";
5 years ago
outgoing = _results->outgoing;
if (outgoing > 1048576)
{
outgoing /= 1048576;
unit = "MB/s";
}
else if (outgoing > 1024 && outgoing < 1048576)
{
outgoing /= 1024;
unit = "KB/s";
}
5 years ago
snprintf(buf, sizeof(buf), "%.2f %s", outgoing, unit);
5 years ago
return strdup(buf);
5 years ago
}
static void
_progress_outgoing_format_free_cb(char *str)
5 years ago
{
if (str)
free(str);
5 years ago
}
static void
_extra_view_update(Ui *ui, results_t *results)
5 years ago
{
Evas_Object *box, *frame, *progress;
int i;
5 years ago
if (!ui->extra_visible)
return;
5 years ago
_results = results;
5 years ago
elm_box_clear(ui->extra_activity);
5 years ago
box = elm_box_add(ui->content);
evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(box);
5 years ago
if (results->power.battery_count)
{
frame = elm_frame_add(box);
evas_object_size_hint_align_set(frame, EVAS_HINT_FILL, 0);
evas_object_size_hint_weight_set(frame, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
if (results->power.have_ac)
elm_object_text_set(frame, "Battery (plugged in)");
else
elm_object_text_set(frame, "Battery");
5 years ago
evas_object_show(frame);
5 years ago
progress = elm_progressbar_add(frame);
evas_object_size_hint_align_set(progress, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(progress, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_progressbar_span_size_set(progress, 1.0);
elm_progressbar_unit_format_set(progress, "%1.2f%%");
elm_progressbar_value_set(progress, (double)results->power.percent / 100);
evas_object_show(progress);
elm_object_content_set(frame, progress);
elm_box_pack_end(box, frame);
}
5 years ago
frame = elm_frame_add(box);
evas_object_size_hint_align_set(frame, EVAS_HINT_FILL, 0);
evas_object_size_hint_weight_set(frame, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_object_text_set(frame, "Network Incoming");
evas_object_show(frame);
5 years ago
progress = elm_progressbar_add(frame);
evas_object_size_hint_align_set(progress, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(progress, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_progressbar_span_size_set(progress, 1.0);
elm_progressbar_unit_format_set(progress, "");
elm_progressbar_unit_format_function_set(progress, _progress_incoming_format_cb, _progress_incoming_format_free_cb);
5 years ago
if (results->incoming == 0)
elm_progressbar_value_set(progress, 0);
else
elm_progressbar_value_set(progress, 1.0);
5 years ago
evas_object_show(progress);
elm_object_content_set(frame, progress);
elm_box_pack_end(box, frame);
frame = elm_frame_add(box);
evas_object_size_hint_align_set(frame, EVAS_HINT_FILL, 0);
evas_object_size_hint_weight_set(frame, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_object_text_set(frame, "Network Outgoing");
evas_object_show(frame);
progress = elm_progressbar_add(frame);
evas_object_size_hint_align_set(progress, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(progress, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_progressbar_span_size_set(progress, 1.0);
elm_progressbar_unit_format_set(progress, "");
elm_progressbar_unit_format_function_set(progress, _progress_outgoing_format_cb, _progress_outgoing_format_free_cb);
if (results->outgoing == 0)
elm_progressbar_value_set(progress, 0);
else
elm_progressbar_value_set(progress, 1.0);
evas_object_show(progress);
5 years ago
elm_object_content_set(frame, progress);
elm_box_pack_end(box, frame);
elm_box_pack_end(ui->extra_activity, box);
}
static unsigned long
_disk_adjust(Data_Unit unit, unsigned long value)
{
if (unit == DATA_UNIT_KB)
{
value >>= 10;
}
else if (unit == DATA_UNIT_MB)
{
value >>= 20;
}
else if (unit == DATA_UNIT_GB)
{
value >>= 30;
}
return value;
5 years ago
}
static void
_ui_disk_add(Ui *ui, const char *path, const char *mount, unsigned long total, unsigned long used)
5 years ago
{
Evas_Object *frame, *progress;
const char *symbol;
double ratio, value;
frame = elm_frame_add(ui->disk_activity);
evas_object_size_hint_align_set(frame, EVAS_HINT_FILL, 0);
evas_object_size_hint_weight_set(frame, EVAS_HINT_EXPAND, 0);
elm_object_text_set(frame, eina_slstr_printf("%s on %s", path, mount));
evas_object_show(frame);
progress = elm_progressbar_add(frame);
evas_object_size_hint_align_set(progress, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(progress, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_progressbar_span_size_set(progress, 1.0);
symbol = _data_unit_symbol_get(ui->data_unit);
elm_progressbar_unit_format_set(progress,
eina_slstr_printf(
"%lu%c of %lu%c",
_disk_adjust(ui->data_unit, used), *symbol,
_disk_adjust(ui->data_unit, total), *symbol));
elm_object_content_set(frame, progress);
ratio = total / 100.0;
value = used / ratio;
if (used == 0 && total == 0)
elm_progressbar_value_set(progress, 1.0);
else
elm_progressbar_value_set(progress, value / 100.0);
evas_object_show(progress);
elm_box_pack_end(ui->disk_activity, frame);
5 years ago
}
static void
_disk_view_update(Ui *ui)
5 years ago
{
Eina_List *disks;
char *path;
unsigned long total, used;
if (!ui->disk_visible)
return;
elm_box_clear(ui->disk_activity);
disks = disks_get();
EINA_LIST_FREE(disks, path)
5 years ago
{
char *mount = disk_mount_point_get(path);
if (mount)
{
if (disk_usage_get(mount, &total, &used))
{
_ui_disk_add(ui, path, mount, total, used);
}
free(mount);
}
free(path);
5 years ago
}
if (disks)
free(disks);
5 years ago
}
static void
_memory_view_update(Ui *ui, results_t *results)
5 years ago
{
Evas_Object *box, *frame, *progress;
const char *symbol;
double ratio, value;
5 years ago
if (!ui->mem_visible)
return;
5 years ago
elm_box_clear(ui->mem_activity);
5 years ago
symbol = _data_unit_symbol_get(ui->data_unit);
5 years ago
box = elm_box_add(ui->content);
evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(box);
5 years ago
frame = elm_frame_add(box);
evas_object_size_hint_align_set(frame, EVAS_HINT_FILL, 0);
evas_object_size_hint_weight_set(frame, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_object_text_set(frame, "Memory Used");
evas_object_show(frame);
progress = elm_progressbar_add(frame);
evas_object_size_hint_align_set(progress, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(progress, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_progressbar_span_size_set(progress, 1.0);
elm_progressbar_unit_format_set(progress,
eina_slstr_printf(
"%lu %c / %lu %c",
_mem_adjust(ui->data_unit, results->memory.used), *symbol,
_mem_adjust(ui->data_unit, results->memory.total), *symbol));
5 years ago
ratio = results->memory.total / 100.0;
value = results->memory.used / ratio;
elm_progressbar_value_set(progress, value / 100);
evas_object_show(progress);
elm_object_content_set(frame, progress);
elm_box_pack_end(box, frame);
5 years ago
frame = elm_frame_add(box);
evas_object_size_hint_align_set(frame, EVAS_HINT_FILL, 0);
evas_object_size_hint_weight_set(frame, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_object_text_set(frame, "Memory Cached");
evas_object_show(frame);
progress = elm_progressbar_add(frame);
evas_object_size_hint_align_set(progress, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(progress, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_progressbar_span_size_set(progress, 1.0);
elm_progressbar_unit_format_set(progress, eina_slstr_printf(
"%lu %c / %lu %c",
_mem_adjust(ui->data_unit, results->memory.cached), *symbol,
_mem_adjust(ui->data_unit, results->memory.total), *symbol));
5 years ago
ratio = results->memory.total / 100.0;
value = results->memory.cached / ratio;
elm_progressbar_value_set(progress, value / 100);
evas_object_show(progress);
elm_object_content_set(frame, progress);
elm_box_pack_end(box, frame);
5 years ago
frame = elm_frame_add(box);
evas_object_size_hint_align_set(frame, EVAS_HINT_FILL, 0);
evas_object_size_hint_weight_set(frame, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_object_text_set(frame, "Memory Buffered");
evas_object_show(frame);
progress = elm_progressbar_add(frame);
evas_object_size_hint_align_set(progress, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(progress, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_progressbar_span_size_set(progress, 1.0);
elm_progressbar_unit_format_set(progress,
eina_slstr_printf(
"%lu %c / %lu %c",
_mem_adjust(ui->data_unit, results->memory.buffered), *symbol,
_mem_adjust(ui->data_unit, results->memory.total), *symbol));
5 years ago
ratio = results->memory.total / 100.0;
value = results->memory.buffered / ratio;
elm_progressbar_value_set(progress, value / 100);
evas_object_show(progress);
elm_object_content_set(frame, progress);
elm_box_pack_end(box, frame);
5 years ago
frame = elm_frame_add(box);
evas_object_size_hint_align_set(frame, EVAS_HINT_FILL, 0);
evas_object_size_hint_weight_set(frame, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_object_text_set(frame, "Memory Shared");
evas_object_show(frame);
progress = elm_progressbar_add(frame);
evas_object_size_hint_align_set(progress, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(progress, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_progressbar_span_size_set(progress, 1.0);
elm_progressbar_unit_format_set(progress,
eina_slstr_printf(
"%lu %c / %lu %c",
_mem_adjust(ui->data_unit, results->memory.shared), *symbol,
_mem_adjust(ui->data_unit, results->memory.total), *symbol));
5 years ago
ratio = results->memory.total / 100.0;
value = results->memory.shared / ratio;
elm_progressbar_value_set(progress, value / 100);
evas_object_show(progress);
elm_object_content_set(frame, progress);
elm_box_pack_end(box, frame);
5 years ago
elm_box_pack_end(ui->mem_activity, box);
5 years ago
}
static void
_cpu_view_update(Ui *ui, results_t *results)
5 years ago
{
Evas_Object *box, *frame, *progress;
int i;
5 years ago
if (!ui->cpu_visible)
return;
5 years ago
elm_box_clear(ui->cpu_activity);
5 years ago
box = elm_box_add(ui->content);
evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(box);
5 years ago
for (i = 0; i < results->cpu_count; i++)
5 years ago
{
frame = elm_frame_add(box);
evas_object_size_hint_align_set(frame, EVAS_HINT_FILL, 0);
evas_object_size_hint_weight_set(frame, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
if (i == 0 && results->temperature != INVALID_TEMP)
elm_object_text_set(frame, eina_slstr_printf("CPU %d (%d °C)", i, results->temperature));
else
elm_object_text_set(frame, eina_slstr_printf("CPU %d", i));
5 years ago
evas_object_show(frame);
5 years ago
progress = elm_progressbar_add(frame);
evas_object_size_hint_align_set(progress, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(progress, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_progressbar_span_size_set(progress, 1.0);
elm_progressbar_unit_format_set(progress, "%1.2f%%");
5 years ago
elm_progressbar_value_set(progress, results->cores[i]->percent / 100);
evas_object_show(progress);
elm_object_content_set(frame, progress);
elm_box_pack_end(box, frame);
5 years ago
}
elm_box_pack_end(ui->cpu_activity, box);
5 years ago
}
static void
_system_stats_thread_feedback_cb(void *data, Ecore_Thread *thread, void *msg)
5 years ago
{
Ui *ui;
results_t *results;
double cpu_usage = 0.0;
5 years ago
int i;
ui = data;
results = msg;
5 years ago
if (ecore_thread_check(thread))
goto out;
_cpu_view_update(ui, results);
_memory_view_update(ui, results);
_disk_view_update(ui);
_extra_view_update(ui, results);
for (i = 0; i < results->cpu_count; i++)
{
cpu_usage += results->cores[i]->percent;
free(results->cores[i]);
5 years ago
}
cpu_usage = cpu_usage / results->cpu_count;
5 years ago
_memory_total = results->memory.total;
_memory_used = results->memory.used;
5 years ago
elm_progressbar_value_set(ui->progress_cpu, (double)cpu_usage / 100);
elm_progressbar_value_set(ui->progress_mem, (double)((results->memory.total / 100.0) * results->memory.used) / 1000000000000);
out:
free(results->cores);
free(results);
}
static int
_sort_by_pid(const void *p1, const void *p2)
5 years ago
{
const Proc_Stats *inf1, *inf2;
5 years ago
inf1 = p1; inf2 = p2;
5 years ago
return inf1->pid - inf2->pid;
5 years ago
}
static int
_sort_by_uid(const void *p1, const void *p2)
5 years ago
{
const Proc_Stats *inf1, *inf2;
5 years ago
inf1 = p1; inf2 = p2;
5 years ago
return inf1->uid - inf2->uid;
5 years ago
}
static int
_sort_by_nice(const void *p1, const void *p2)
5 years ago
{
const Proc_Stats *inf1, *inf2;
5 years ago
inf1 = p1; inf2 = p2;
5 years ago
return inf1->nice - inf2->nice;
}
5 years ago
static int
_sort_by_pri(const void *p1, const void *p2)
{
const Proc_Stats *inf1, *inf2;
5 years ago
inf1 = p1; inf2 = p2;
5 years ago
return inf1->priority - inf2->priority;
5 years ago
}
static int
_sort_by_cpu(const void *p1, const void *p2)
5 years ago
{
const Proc_Stats *inf1, *inf2;
5 years ago
inf1 = p1; inf2 = p2;
5 years ago
return inf1->cpu_id - inf2->cpu_id;
}
5 years ago
static int
_sort_by_threads(const void *p1, const void *p2)
{
const Proc_Stats *inf1, *inf2;
5 years ago
inf1 = p1; inf2 = p2;
5 years ago
return inf1->numthreads - inf2->numthreads;
5 years ago
}
static int
_sort_by_size(const void *p1, const void *p2)
5 years ago
{
const Proc_Stats *inf1, *inf2;
int64_t size1, size2;
5 years ago
inf1 = p1; inf2 = p2;
5 years ago
size1 = inf1->mem_size;
size2 = inf2->mem_size;
5 years ago
if (size1 < size2)
return -1;
if (size2 > size1)
return 1;
5 years ago
return 0;
5 years ago
}
static int
_sort_by_rss(const void *p1, const void *p2)
5 years ago
{
const Proc_Stats *inf1, *inf2;
int64_t size1, size2;
5 years ago
inf1 = p1; inf2 = p2;
5 years ago
size1 = inf1->mem_rss;
size2 = inf2->mem_rss;
5 years ago
if (size1 < size2)
return -1;
if (size2 > size1)
return 1;
5 years ago
return 0;
5 years ago
}
static int
_sort_by_cpu_usage(const void *p1, const void *p2)
5 years ago
{
const Proc_Stats *inf1, *inf2;
double one, two;
5 years ago
inf1 = p1; inf2 = p2;
5 years ago
one = inf1->cpu_usage;
two = inf2->cpu_usage;
5 years ago
if (one < two)
return -1;
if (two > one)
return 1;
5 years ago
return 0;
5 years ago
}
static int
_sort_by_cmd(const void *p1, const void *p2)
5 years ago
{
const Proc_Stats *inf1, *inf2;
5 years ago
inf1 = p1; inf2 = p2;
5 years ago
return strcasecmp(inf1->command, inf2->command);
}
5 years ago
static int
_sort_by_state(const void *p1, const void *p2)
{
const Proc_Stats *inf1, *inf2;
5 years ago
inf1 = p1; inf2 = p2;
5 years ago
return strcmp(inf1->state, inf2->state);
5 years ago
}
static void
_fields_append(Ui *ui, Proc_Stats *proc)
5 years ago
{
const char *symbol;
int64_t mem_size, mem_rss;
5 years ago
if (ui->program_pid == proc->pid)
return;
5 years ago
symbol = _data_unit_symbol_get(ui->data_unit);
5 years ago
mem_size = proc->mem_size;
mem_rss = proc->mem_rss;
5 years ago
if (ui->data_unit == DATA_UNIT_KB)
{
mem_size >>= 10;
mem_rss >>= 10;
}
else if (ui->data_unit == DATA_UNIT_MB)
{
mem_size >>= 20;
mem_rss >>= 20;
}
else
{
mem_size >>= 30;
mem_rss >>= 30;
}
5 years ago
eina_strlcat(ui->fields[PROCESS_INFO_FIELD_PID], eina_slstr_printf("<link>%d</link> <br>", proc->pid), TEXT_FIELD_MAX);
eina_strlcat(ui->fields[PROCESS_INFO_FIELD_UID], eina_slstr_printf("%d <br>", proc->uid), TEXT_FIELD_MAX);
eina_strlcat(ui->fields[PROCESS_INFO_FIELD_SIZE], eina_slstr_printf("%lld %c<br>", mem_size, *symbol), TEXT_FIELD_MAX);
eina_strlcat(ui->fields[PROCESS_INFO_FIELD_RSS], eina_slstr_printf("%lld %c<br>", mem_rss, *symbol), TEXT_FIELD_MAX);
eina_strlcat(ui->fields[PROCESS_INFO_FIELD_COMMAND], eina_slstr_printf("%s<br>", proc->command), TEXT_FIELD_MAX);
eina_strlcat(ui->fields[PROCESS_INFO_FIELD_STATE], eina_slstr_printf("%s <br>", proc->state), TEXT_FIELD_MAX);
eina_strlcat(ui->fields[PROCESS_INFO_FIELD_CPU_USAGE], eina_slstr_printf("%.1f%% <br>", proc->cpu_usage), TEXT_FIELD_MAX);
5 years ago
}
static void
_fields_show(Ui *ui)
5 years ago
{
elm_object_text_set(ui->entry_pid, ui->fields[PROCESS_INFO_FIELD_PID]);
elm_object_text_set(ui->entry_uid, ui->fields[PROCESS_INFO_FIELD_UID]);
elm_object_text_set(ui->entry_size, ui->fields[PROCESS_INFO_FIELD_SIZE]);
elm_object_text_set(ui->entry_rss, ui->fields[PROCESS_INFO_FIELD_RSS]);
elm_object_text_set(ui->entry_cmd, ui->fields[PROCESS_INFO_FIELD_COMMAND]);
elm_object_text_set(ui->entry_state, ui->fields[PROCESS_INFO_FIELD_STATE]);
elm_object_text_set(ui->entry_cpu_usage, ui->fields[PROCESS_INFO_FIELD_CPU_USAGE]);
5 years ago
}
static void
_fields_clear(Ui *ui)
5 years ago
{
for (int i = 0; i < PROCESS_INFO_FIELDS; i++)
{
ui->fields[i][0] = '\0';
}
5 years ago
}
static void
_fields_free(Ui *ui)
5 years ago
{
for (int i = 0; i < PROCESS_INFO_FIELDS; i++)
{
free(ui->fields[i]);
}
}
5 years ago
static Eina_List *
_list_sort(Ui *ui, Eina_List *list)
{
switch (ui->sort_type)
{
case SORT_BY_NONE:
case SORT_BY_PID:
list = eina_list_sort(list, eina_list_count(list), _sort_by_pid);
break;
5 years ago
case SORT_BY_UID:
list = eina_list_sort(list, eina_list_count(list), _sort_by_uid);
break;
case SORT_BY_NICE:
list = eina_list_sort(list, eina_list_count(list), _sort_by_nice);
break;
case SORT_BY_PRI:
list = eina_list_sort(list, eina_list_count(list), _sort_by_pri);
break;
case SORT_BY_CPU:
list = eina_list_sort(list, eina_list_count(list), _sort_by_cpu);
break;
5 years ago
case SORT_BY_THREADS:
list = eina_list_sort(list, eina_list_count(list), _sort_by_threads);
break;
5 years ago