Refactoring and fixing stuff.
This commit is contained in:
parent
f5a1292c39
commit
45b3dcfa87
|
@ -6,6 +6,10 @@ This is a process monitor and system monitor.
|
||||||
|
|
||||||
Currently have full engines for Linux, FreeBSD, OpenBSD and MacOS.
|
Currently have full engines for Linux, FreeBSD, OpenBSD and MacOS.
|
||||||
|
|
||||||
|
The plan is to rewrite the whole program to log system information
|
||||||
|
over time to disk so we can do nice things with E and displaying
|
||||||
|
system information (not duplicating loads of code).
|
||||||
|
|
||||||
REQUIREMENTS:
|
REQUIREMENTS:
|
||||||
|
|
||||||
An installation of EFL (v1.19.0+). Remember to set your PKG_CONFIG_PATH environment
|
An installation of EFL (v1.19.0+). Remember to set your PKG_CONFIG_PATH environment
|
||||||
|
|
17
src/disks.c
17
src/disks.c
|
@ -167,7 +167,7 @@ disks_get(void)
|
||||||
if ((sysctl(mib, miblen, drives, &len, NULL, 0)) == -1)
|
if ((sysctl(mib, miblen, drives, &len, NULL, 0)) == -1)
|
||||||
{
|
{
|
||||||
free(drives);
|
free(drives);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Eina_List *list = NULL;
|
Eina_List *list = NULL;
|
||||||
|
@ -176,21 +176,21 @@ disks_get(void)
|
||||||
while (dev)
|
while (dev)
|
||||||
{
|
{
|
||||||
end = strchr(dev, ':');
|
end = strchr(dev, ':');
|
||||||
if (!end) break;
|
if (!end) break;
|
||||||
|
|
||||||
*end = '\0';
|
*end = '\0';
|
||||||
|
|
||||||
if (dev[0] == ',')
|
if (dev[0] == ',')
|
||||||
dev++;
|
dev++;
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "/dev/%s", dev);
|
snprintf(buf, sizeof(buf), "/dev/%s", dev);
|
||||||
|
|
||||||
list = eina_list_append(list, strdup(buf));
|
list = eina_list_append(list, strdup(buf));
|
||||||
|
|
||||||
end++;
|
end++;
|
||||||
dev = strchr(end, ',');
|
dev = strchr(end, ',');
|
||||||
if (!dev) break;
|
if (!dev) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(drives);
|
free(drives);
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ disks_get(void)
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
Eina_List *devs, *list;
|
Eina_List *devs, *list;
|
||||||
|
|
||||||
list = NULL;
|
list = NULL;
|
||||||
|
|
||||||
devs = ecore_file_ls("/dev");
|
devs = ecore_file_ls("/dev");
|
||||||
|
|
||||||
|
@ -265,3 +265,4 @@ disks_get(void)
|
||||||
return NULL;
|
return NULL;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,13 +5,12 @@
|
||||||
#include <Ecore.h>
|
#include <Ecore.h>
|
||||||
|
|
||||||
Eina_Bool
|
Eina_Bool
|
||||||
disk_usage_get(const char *mountpoint, unsigned long *total, unsigned long *used);
|
disk_usage_get(const char *mountpoint, unsigned long *total, unsigned long *used);
|
||||||
|
|
||||||
char *
|
char *
|
||||||
disk_mount_point_get(const char *path);
|
disk_mount_point_get(const char *path);
|
||||||
|
|
||||||
Eina_List *
|
Eina_List *
|
||||||
disks_get(void);
|
disks_get(void);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* Copyright 2018. Alastair Poole <netstar@gmail.com>
|
/* Copyright 2018. Alastair Poole <netstar@gmail.com>
|
||||||
See LICENSE file for details.
|
See LICENSE file for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define VERSION "0.1.1"
|
#define VERSION "0.1.1"
|
||||||
|
|
||||||
|
|
|
@ -365,7 +365,7 @@ _process_list_openbsd_get(void)
|
||||||
|
|
||||||
kp = kvm_getprocs(kern, KERN_PROC_SHOW_THREADS, 0, sizeof(*kp), &pid_count);
|
kp = kvm_getprocs(kern, KERN_PROC_SHOW_THREADS, 0, sizeof(*kp), &pid_count);
|
||||||
|
|
||||||
EINA_LIST_FOREACH (list, l, p)
|
EINA_LIST_FOREACH(list, l, p)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < pid_count; i++)
|
for (int i = 0; i < pid_count; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -50,7 +50,7 @@ typedef struct _Proc_Stats
|
||||||
* @return A list of proc_t members for all processes.
|
* @return A list of proc_t members for all processes.
|
||||||
*/
|
*/
|
||||||
Eina_List *
|
Eina_List *
|
||||||
proc_info_all_get(void);
|
proc_info_all_get(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query a process for its current state.
|
* Query a process for its current state.
|
||||||
|
@ -60,7 +60,7 @@ proc_info_all_get(void);
|
||||||
* @return A proc_t pointer containing the process information.
|
* @return A proc_t pointer containing the process information.
|
||||||
*/
|
*/
|
||||||
Proc_Stats *
|
Proc_Stats *
|
||||||
proc_info_by_pid(int pid);
|
proc_info_by_pid(int pid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
|
|
17
src/system.c
17
src/system.c
|
@ -155,7 +155,11 @@ _sysctlfromname(const char *name, void *mib, int depth, size_t *len)
|
||||||
static int
|
static int
|
||||||
cpu_count(void)
|
cpu_count(void)
|
||||||
{
|
{
|
||||||
int cores = 0;
|
static int cores = 0;
|
||||||
|
|
||||||
|
if (cores != 0)
|
||||||
|
return cores;
|
||||||
|
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
@ -1124,7 +1128,6 @@ system_power_state_get(power_t *power)
|
||||||
_power_state_get(power);
|
_power_state_get(power);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
system_network_transfer_get(unsigned long *incoming, unsigned long *outgoing)
|
system_network_transfer_get(unsigned long *incoming, unsigned long *outgoing)
|
||||||
{
|
{
|
||||||
|
@ -1176,13 +1179,14 @@ system_cpu_memory_get(double *percent_cpu, long *memory_total, long *memory_used
|
||||||
return results.cpu_count;
|
return results.cpu_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *_network_transfer_get_thread_cb(void *arg)
|
static void *
|
||||||
|
_network_transfer_get_thread_cb(void *arg)
|
||||||
{
|
{
|
||||||
results_t *results = arg;
|
results_t *results = arg;
|
||||||
|
|
||||||
_network_transfer_get(results);
|
_network_transfer_get(results);
|
||||||
|
|
||||||
return ((void *) 0);
|
return (void *)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1202,8 +1206,8 @@ system_stats_all_get(results_t *results)
|
||||||
if (error)
|
if (error)
|
||||||
_network_transfer_get(results);
|
_network_transfer_get(results);
|
||||||
|
|
||||||
if (_power_battery_count_get(&results->power))
|
if (_power_battery_count_get(&results->power))
|
||||||
_power_state_get(&results->power);
|
_power_state_get(&results->power);
|
||||||
|
|
||||||
_temperature_cpu_get(&results->temperature);
|
_temperature_cpu_get(&results->temperature);
|
||||||
|
|
||||||
|
@ -1214,4 +1218,3 @@ system_stats_all_get(results_t *results)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
12
src/system.h
12
src/system.h
|
@ -48,23 +48,23 @@ struct results_t
|
||||||
|
|
||||||
unsigned long incoming;
|
unsigned long incoming;
|
||||||
unsigned long outgoing;
|
unsigned long outgoing;
|
||||||
#define INVALID_TEMP -999
|
#define INVALID_TEMP -999
|
||||||
int temperature;
|
int temperature;
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
system_stats_all_get(results_t *results);
|
system_stats_all_get(results_t *results);
|
||||||
|
|
||||||
int
|
int
|
||||||
system_cpu_memory_get(double *percent_cpu, long *memory_total, long *memory_used);
|
system_cpu_memory_get(double *percent_cpu, long *memory_total, long *memory_used);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
system_network_transfer_get(unsigned long *incoming, unsigned long *outgoing);
|
system_network_transfer_get(unsigned long *incoming, unsigned long *outgoing);
|
||||||
|
|
||||||
int
|
int
|
||||||
system_temperature_cpu_get(void);
|
system_temperature_cpu_get(void);
|
||||||
|
|
||||||
void
|
void
|
||||||
system_power_state_get(power_t *power);
|
system_power_state_get(power_t *power);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
109
src/ui.c
109
src/ui.c
|
@ -96,7 +96,7 @@ _system_stats_thread_feedback_cb(void *data, Ecore_Thread *thread, void *msg)
|
||||||
_memory_total = results->memory.total >>= 10;
|
_memory_total = results->memory.total >>= 10;
|
||||||
_memory_used = results->memory.used >>= 10;
|
_memory_used = results->memory.used >>= 10;
|
||||||
|
|
||||||
elm_progressbar_value_set(ui->progress_cpu, (double) cpu_usage / 100);
|
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) / 1000000);
|
elm_progressbar_value_set(ui->progress_mem, (double)((results->memory.total / 100.0) * results->memory.used) / 1000000);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
@ -251,9 +251,11 @@ _data_unit_symbol_get(Data_Unit unit)
|
||||||
case DATA_UNIT_KB:
|
case DATA_UNIT_KB:
|
||||||
symbol = "K";
|
symbol = "K";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DATA_UNIT_MB:
|
case DATA_UNIT_MB:
|
||||||
symbol = "M";
|
symbol = "M";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DATA_UNIT_GB:
|
case DATA_UNIT_GB:
|
||||||
symbol = "G";
|
symbol = "G";
|
||||||
break;
|
break;
|
||||||
|
@ -265,16 +267,16 @@ _data_unit_symbol_get(Data_Unit unit)
|
||||||
static void
|
static void
|
||||||
_fields_append(Ui *ui, Proc_Stats *proc)
|
_fields_append(Ui *ui, Proc_Stats *proc)
|
||||||
{
|
{
|
||||||
const char *format;
|
const char *symbol;
|
||||||
int64_t mem_size, mem_rss;
|
int64_t mem_size, mem_rss;
|
||||||
|
|
||||||
if (ui->program_pid == proc->pid)
|
if (ui->program_pid == proc->pid)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
format = _data_unit_symbol_get(ui->data_unit);
|
symbol = _data_unit_symbol_get(ui->data_unit);
|
||||||
|
|
||||||
mem_size = proc->mem_size;
|
mem_size = proc->mem_size;
|
||||||
mem_rss = proc->mem_rss;
|
mem_rss = proc->mem_rss;
|
||||||
|
|
||||||
if (ui->data_unit == DATA_UNIT_KB)
|
if (ui->data_unit == DATA_UNIT_KB)
|
||||||
{
|
{
|
||||||
|
@ -284,7 +286,7 @@ _fields_append(Ui *ui, Proc_Stats *proc)
|
||||||
else if (ui->data_unit == DATA_UNIT_MB)
|
else if (ui->data_unit == DATA_UNIT_MB)
|
||||||
{
|
{
|
||||||
mem_size >>= 20;
|
mem_size >>= 20;
|
||||||
mem_rss >>= 10;
|
mem_rss >>= 20;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -294,8 +296,8 @@ _fields_append(Ui *ui, Proc_Stats *proc)
|
||||||
|
|
||||||
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_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_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, *format), 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, *format), 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_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_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);
|
eina_strlcat(ui->fields[PROCESS_INFO_FIELD_CPU_USAGE], eina_slstr_printf("%.1f%% <br>", proc->cpu_usage), TEXT_FIELD_MAX);
|
||||||
|
@ -401,19 +403,19 @@ _system_process_list_feedback_cb(void *data, Ecore_Thread *thread EINA_UNUSED, v
|
||||||
|
|
||||||
list = proc_info_all_get();
|
list = proc_info_all_get();
|
||||||
|
|
||||||
EINA_LIST_FOREACH (list, l, proc)
|
EINA_LIST_FOREACH(list, l, proc)
|
||||||
{
|
{
|
||||||
int64_t time_prev = ui->cpu_times[proc->pid];
|
int64_t time_prev = ui->cpu_times[proc->pid];
|
||||||
proc->cpu_usage = 0;
|
proc->cpu_usage = 0;
|
||||||
if (!ui->first_run && proc->cpu_time > time_prev)
|
if (!ui->first_run && proc->cpu_time > time_prev)
|
||||||
{
|
{
|
||||||
proc->cpu_usage = (double) (proc->cpu_time - time_prev) / ui->poll_delay;
|
proc->cpu_usage = (double)(proc->cpu_time - time_prev) / ui->poll_delay;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
list = _list_sort(ui, list);
|
list = _list_sort(ui, list);
|
||||||
|
|
||||||
EINA_LIST_FREE (list, proc)
|
EINA_LIST_FREE(list, proc)
|
||||||
{
|
{
|
||||||
_fields_append(ui, proc);
|
_fields_append(ui, proc);
|
||||||
ui->first_run = EINA_FALSE;
|
ui->first_run = EINA_FALSE;
|
||||||
|
@ -534,7 +536,6 @@ _btn_uid_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info E
|
||||||
elm_scroller_page_bring_in(ui->scroller, 0, 0);
|
elm_scroller_page_bring_in(ui->scroller, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_btn_cpu_usage_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
_btn_cpu_usage_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||||
{
|
{
|
||||||
|
@ -628,18 +629,6 @@ _btn_quit_clicked_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void
|
||||||
ui_shutdown(ui);
|
ui_shutdown(ui);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
_btn_about_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|
||||||
{
|
|
||||||
Ui *ui;
|
|
||||||
Evas_Object *win;
|
|
||||||
|
|
||||||
ui = data;
|
|
||||||
win = ui->win;
|
|
||||||
|
|
||||||
printf("(c) Copyright 2018. Alastair Poole <netstar@gmail.com>\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_list_item_del_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
_list_item_del_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||||
{
|
{
|
||||||
|
@ -707,13 +696,13 @@ _process_panel_update(void *data)
|
||||||
list = elm_list_items_get(ui->list_pid);
|
list = elm_list_items_get(ui->list_pid);
|
||||||
EINA_LIST_FOREACH(list, l, it)
|
EINA_LIST_FOREACH(list, l, it)
|
||||||
{
|
{
|
||||||
pid_t *pid = elm_object_item_data_get(it);
|
pid_t *pid = elm_object_item_data_get(it);
|
||||||
if (pid && *pid == ui->selected_pid)
|
if (pid && *pid == ui->selected_pid)
|
||||||
{
|
{
|
||||||
elm_list_item_selected_set(it, EINA_TRUE);
|
elm_list_item_selected_set(it, EINA_TRUE);
|
||||||
elm_list_item_bring_in(it);
|
elm_list_item_bring_in(it);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
elm_object_text_set(ui->entry_pid_cmd, proc->command);
|
elm_object_text_set(ui->entry_pid_cmd, proc->command);
|
||||||
|
@ -734,7 +723,7 @@ _process_panel_update(void *data)
|
||||||
|
|
||||||
if (ui->pid_cpu_time && proc->cpu_time >= ui->pid_cpu_time)
|
if (ui->pid_cpu_time && proc->cpu_time >= ui->pid_cpu_time)
|
||||||
{
|
{
|
||||||
cpu_usage = (double) (proc->cpu_time - ui->pid_cpu_time) / ui->poll_delay;
|
cpu_usage = (double)(proc->cpu_time - ui->pid_cpu_time) / ui->poll_delay;
|
||||||
}
|
}
|
||||||
|
|
||||||
elm_object_text_set(ui->entry_pid_cpu_usage, eina_slstr_printf("%.1f%%", cpu_usage));
|
elm_object_text_set(ui->entry_pid_cpu_usage, eina_slstr_printf("%.1f%%", cpu_usage));
|
||||||
|
@ -878,14 +867,15 @@ _disk_adjust(Data_Unit unit, unsigned long value)
|
||||||
{
|
{
|
||||||
if (unit == DATA_UNIT_KB)
|
if (unit == DATA_UNIT_KB)
|
||||||
{
|
{
|
||||||
value <<= 10;
|
value >>= 10;
|
||||||
}
|
}
|
||||||
else if (unit == DATA_UNIT_MB)
|
else if (unit == DATA_UNIT_MB)
|
||||||
{
|
{
|
||||||
|
value >>= 20;
|
||||||
}
|
}
|
||||||
else if (unit == DATA_UNIT_GB)
|
else if (unit == DATA_UNIT_GB)
|
||||||
{
|
{
|
||||||
value >>= 10;
|
value >>= 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
@ -895,7 +885,7 @@ static void
|
||||||
_ui_disk_add(Ui *ui, const char *path, const char *mount, unsigned long total, unsigned long used)
|
_ui_disk_add(Ui *ui, const char *path, const char *mount, unsigned long total, unsigned long used)
|
||||||
{
|
{
|
||||||
Evas_Object *frame, *progress;
|
Evas_Object *frame, *progress;
|
||||||
const char *format;
|
const char *symbol;
|
||||||
double ratio, value;
|
double ratio, value;
|
||||||
|
|
||||||
frame = elm_frame_add(ui->disk_activity);
|
frame = elm_frame_add(ui->disk_activity);
|
||||||
|
@ -909,10 +899,13 @@ _ui_disk_add(Ui *ui, const char *path, const char *mount, unsigned long total, u
|
||||||
evas_object_size_hint_weight_set(progress, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
evas_object_size_hint_weight_set(progress, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
elm_progressbar_span_size_set(progress, 1.0);
|
elm_progressbar_span_size_set(progress, 1.0);
|
||||||
|
|
||||||
format = _data_unit_symbol_get(ui->data_unit);
|
symbol = _data_unit_symbol_get(ui->data_unit);
|
||||||
|
|
||||||
elm_progressbar_unit_format_set(progress,
|
elm_progressbar_unit_format_set(progress,
|
||||||
eina_slstr_printf("%lu%c of %lu%c", _disk_adjust(ui->data_unit, used), *format, _disk_adjust(ui->data_unit, total), *format));
|
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);
|
elm_object_content_set(frame, progress);
|
||||||
|
|
||||||
|
@ -949,8 +942,7 @@ _disk_view_update(Ui *ui)
|
||||||
{
|
{
|
||||||
if (disk_usage_get(mount, &total, &used))
|
if (disk_usage_get(mount, &total, &used))
|
||||||
{
|
{
|
||||||
total >>= 20; used >>= 20;
|
_ui_disk_add(ui, path, mount, total, used);
|
||||||
_ui_disk_add(ui, path, mount, total, used);
|
|
||||||
}
|
}
|
||||||
free(mount);
|
free(mount);
|
||||||
}
|
}
|
||||||
|
@ -971,10 +963,10 @@ _progress_incoming_format_cb(double val)
|
||||||
incoming = _results->incoming;
|
incoming = _results->incoming;
|
||||||
if (incoming > 1048576)
|
if (incoming > 1048576)
|
||||||
{
|
{
|
||||||
incoming /= 1048576;
|
incoming /= 1048576;
|
||||||
unit = "MB/s";
|
unit = "MB/s";
|
||||||
}
|
}
|
||||||
else if (incoming > 1024 && incoming < 1048576)
|
else if (incoming > 1024 && incoming < 1048576)
|
||||||
{
|
{
|
||||||
incoming /= 1024;
|
incoming /= 1024;
|
||||||
unit = "KB/s";
|
unit = "KB/s";
|
||||||
|
@ -1002,8 +994,8 @@ _progress_outgoing_format_cb(double val)
|
||||||
outgoing = _results->outgoing;
|
outgoing = _results->outgoing;
|
||||||
if (outgoing > 1048576)
|
if (outgoing > 1048576)
|
||||||
{
|
{
|
||||||
outgoing /= 1048576;
|
outgoing /= 1048576;
|
||||||
unit = "MB/s";
|
unit = "MB/s";
|
||||||
}
|
}
|
||||||
else if (outgoing > 1024 && outgoing < 1048576)
|
else if (outgoing > 1024 && outgoing < 1048576)
|
||||||
{
|
{
|
||||||
|
@ -1088,7 +1080,7 @@ static void
|
||||||
_memory_view_update(Ui *ui, results_t *results)
|
_memory_view_update(Ui *ui, results_t *results)
|
||||||
{
|
{
|
||||||
Evas_Object *box, *frame, *progress;
|
Evas_Object *box, *frame, *progress;
|
||||||
const char *format;
|
const char *symbol;
|
||||||
double ratio, value;
|
double ratio, value;
|
||||||
|
|
||||||
if (!ui->mem_visible)
|
if (!ui->mem_visible)
|
||||||
|
@ -1096,7 +1088,7 @@ _memory_view_update(Ui *ui, results_t *results)
|
||||||
|
|
||||||
elm_box_clear(ui->mem_activity);
|
elm_box_clear(ui->mem_activity);
|
||||||
|
|
||||||
format = _data_unit_symbol_get(ui->data_unit);
|
symbol = _data_unit_symbol_get(ui->data_unit);
|
||||||
|
|
||||||
box = elm_box_add(ui->content);
|
box = elm_box_add(ui->content);
|
||||||
evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||||
|
@ -1113,7 +1105,11 @@ _memory_view_update(Ui *ui, results_t *results)
|
||||||
evas_object_size_hint_weight_set(progress, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
evas_object_size_hint_weight_set(progress, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
elm_progressbar_span_size_set(progress, 1.0);
|
elm_progressbar_span_size_set(progress, 1.0);
|
||||||
elm_progressbar_unit_format_set(progress,
|
elm_progressbar_unit_format_set(progress,
|
||||||
eina_slstr_printf("%lu %c / %lu %c", _mem_adjust(ui->data_unit, results->memory.used), *format, _mem_adjust(ui->data_unit, results->memory.total), *format));
|
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));
|
||||||
|
|
||||||
ratio = results->memory.total / 100.0;
|
ratio = results->memory.total / 100.0;
|
||||||
value = results->memory.used / ratio;
|
value = results->memory.used / ratio;
|
||||||
elm_progressbar_value_set(progress, value / 100);
|
elm_progressbar_value_set(progress, value / 100);
|
||||||
|
@ -1130,8 +1126,11 @@ _memory_view_update(Ui *ui, results_t *results)
|
||||||
evas_object_size_hint_align_set(progress, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
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);
|
evas_object_size_hint_weight_set(progress, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
elm_progressbar_span_size_set(progress, 1.0);
|
elm_progressbar_span_size_set(progress, 1.0);
|
||||||
elm_progressbar_unit_format_set(progress,
|
elm_progressbar_unit_format_set(progress, eina_slstr_printf(
|
||||||
eina_slstr_printf("%lu %c / %lu %c", _mem_adjust(ui->data_unit, results->memory.cached), *format, _mem_adjust(ui->data_unit, results->memory.total), *format));
|
"%lu %c / %lu %c",
|
||||||
|
_mem_adjust(ui->data_unit, results->memory.cached), *symbol,
|
||||||
|
_mem_adjust(ui->data_unit, results->memory.total), *symbol));
|
||||||
|
|
||||||
ratio = results->memory.total / 100.0;
|
ratio = results->memory.total / 100.0;
|
||||||
value = results->memory.cached / ratio;
|
value = results->memory.cached / ratio;
|
||||||
elm_progressbar_value_set(progress, value / 100);
|
elm_progressbar_value_set(progress, value / 100);
|
||||||
|
@ -1149,7 +1148,11 @@ _memory_view_update(Ui *ui, results_t *results)
|
||||||
evas_object_size_hint_weight_set(progress, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
evas_object_size_hint_weight_set(progress, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
elm_progressbar_span_size_set(progress, 1.0);
|
elm_progressbar_span_size_set(progress, 1.0);
|
||||||
elm_progressbar_unit_format_set(progress,
|
elm_progressbar_unit_format_set(progress,
|
||||||
eina_slstr_printf("%lu %c / %lu %c", _mem_adjust(ui->data_unit, results->memory.buffered), *format, _mem_adjust(ui->data_unit, results->memory.total), *format));
|
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));
|
||||||
|
|
||||||
ratio = results->memory.total / 100.0;
|
ratio = results->memory.total / 100.0;
|
||||||
value = results->memory.buffered / ratio;
|
value = results->memory.buffered / ratio;
|
||||||
elm_progressbar_value_set(progress, value / 100);
|
elm_progressbar_value_set(progress, value / 100);
|
||||||
|
@ -1167,7 +1170,11 @@ _memory_view_update(Ui *ui, results_t *results)
|
||||||
evas_object_size_hint_weight_set(progress, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
evas_object_size_hint_weight_set(progress, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
elm_progressbar_span_size_set(progress, 1.0);
|
elm_progressbar_span_size_set(progress, 1.0);
|
||||||
elm_progressbar_unit_format_set(progress,
|
elm_progressbar_unit_format_set(progress,
|
||||||
eina_slstr_printf("%lu %c / %lu %c", _mem_adjust(ui->data_unit, results->memory.shared), *format, _mem_adjust(ui->data_unit, results->memory.total), *format));
|
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));
|
||||||
|
|
||||||
ratio = results->memory.total / 100.0;
|
ratio = results->memory.total / 100.0;
|
||||||
value = results->memory.shared / ratio;
|
value = results->memory.shared / ratio;
|
||||||
elm_progressbar_value_set(progress, value / 100);
|
elm_progressbar_value_set(progress, value / 100);
|
||||||
|
@ -1213,7 +1220,7 @@ _extra_view_update(Ui *ui, results_t *results)
|
||||||
evas_object_size_hint_weight_set(progress, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
evas_object_size_hint_weight_set(progress, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
elm_progressbar_span_size_set(progress, 1.0);
|
elm_progressbar_span_size_set(progress, 1.0);
|
||||||
elm_progressbar_unit_format_set(progress, "%1.2f%%");
|
elm_progressbar_unit_format_set(progress, "%1.2f%%");
|
||||||
elm_progressbar_value_set(progress, (double) results->power.percent / 100);
|
elm_progressbar_value_set(progress, (double)results->power.percent / 100);
|
||||||
evas_object_show(progress);
|
evas_object_show(progress);
|
||||||
elm_object_content_set(frame, progress);
|
elm_object_content_set(frame, progress);
|
||||||
elm_box_pack_end(box, frame);
|
elm_box_pack_end(box, frame);
|
||||||
|
|
122
src/ui.h
122
src/ui.h
|
@ -49,91 +49,89 @@ typedef enum
|
||||||
|
|
||||||
typedef struct Ui
|
typedef struct Ui
|
||||||
{
|
{
|
||||||
Evas_Object *win;
|
Evas_Object *win;
|
||||||
Evas_Object *panel;
|
Evas_Object *panel;
|
||||||
Evas_Object *scroller;
|
Evas_Object *scroller;
|
||||||
|
|
||||||
Evas_Object *content;
|
Evas_Object *content;
|
||||||
|
|
||||||
Evas_Object *disk_view;
|
Evas_Object *disk_view;
|
||||||
Evas_Object *disk_activity;
|
Evas_Object *disk_activity;
|
||||||
Evas_Object *cpu_view;
|
Evas_Object *cpu_view;
|
||||||
Evas_Object *cpu_activity;
|
Evas_Object *cpu_activity;
|
||||||
Evas_Object *mem_view;
|
Evas_Object *mem_view;
|
||||||
Evas_Object *mem_activity;
|
Evas_Object *mem_activity;
|
||||||
Evas_Object *extra_view;
|
Evas_Object *extra_view;
|
||||||
Evas_Object *extra_activity;
|
Evas_Object *extra_activity;
|
||||||
Evas_Object *system_activity;
|
Evas_Object *system_activity;
|
||||||
|
|
||||||
Eina_Bool cpu_visible;
|
Eina_Bool cpu_visible;
|
||||||
Eina_Bool extra_visible;
|
Eina_Bool extra_visible;
|
||||||
Eina_Bool disk_visible;
|
Eina_Bool disk_visible;
|
||||||
Eina_Bool mem_visible;
|
Eina_Bool mem_visible;
|
||||||
|
|
||||||
Evas_Object *progress_cpu;
|
Evas_Object *progress_cpu;
|
||||||
Evas_Object *progress_mem;
|
Evas_Object *progress_mem;
|
||||||
|
|
||||||
Evas_Object *entry_pid;
|
Evas_Object *entry_pid;
|
||||||
Evas_Object *entry_uid;
|
Evas_Object *entry_uid;
|
||||||
Evas_Object *entry_size;
|
Evas_Object *entry_size;
|
||||||
Evas_Object *entry_rss;
|
Evas_Object *entry_rss;
|
||||||
Evas_Object *entry_cmd;
|
Evas_Object *entry_cmd;
|
||||||
Evas_Object *entry_state;
|
Evas_Object *entry_state;
|
||||||
Evas_Object *entry_cpu_usage;
|
Evas_Object *entry_cpu_usage;
|
||||||
|
|
||||||
Evas_Object *btn_pid;
|
Evas_Object *btn_pid;
|
||||||
Evas_Object *btn_uid;
|
Evas_Object *btn_uid;
|
||||||
Evas_Object *btn_size;
|
Evas_Object *btn_size;
|
||||||
Evas_Object *btn_rss;
|
Evas_Object *btn_rss;
|
||||||
Evas_Object *btn_cmd;
|
Evas_Object *btn_cmd;
|
||||||
Evas_Object *btn_state;
|
Evas_Object *btn_state;
|
||||||
Evas_Object *btn_cpu_usage;
|
Evas_Object *btn_cpu_usage;
|
||||||
|
|
||||||
Evas_Object *entry_pid_cmd;
|
Evas_Object *entry_pid_cmd;
|
||||||
Evas_Object *entry_pid_user;
|
Evas_Object *entry_pid_user;
|
||||||
Evas_Object *entry_pid_pid;
|
Evas_Object *entry_pid_pid;
|
||||||
Evas_Object *entry_pid_uid;
|
Evas_Object *entry_pid_uid;
|
||||||
Evas_Object *entry_pid_cpu;
|
Evas_Object *entry_pid_cpu;
|
||||||
Evas_Object *entry_pid_threads;
|
Evas_Object *entry_pid_threads;
|
||||||
Evas_Object *entry_pid_size;
|
Evas_Object *entry_pid_size;
|
||||||
Evas_Object *entry_pid_rss;
|
Evas_Object *entry_pid_rss;
|
||||||
Evas_Object *entry_pid_nice;
|
Evas_Object *entry_pid_nice;
|
||||||
Evas_Object *entry_pid_pri;
|
Evas_Object *entry_pid_pri;
|
||||||
Evas_Object *entry_pid_state;
|
Evas_Object *entry_pid_state;
|
||||||
Evas_Object *entry_pid_cpu_usage;
|
Evas_Object *entry_pid_cpu_usage;
|
||||||
|
|
||||||
Ecore_Thread *thread_system;
|
Ecore_Thread *thread_system;
|
||||||
Ecore_Thread *thread_process;
|
Ecore_Thread *thread_process;
|
||||||
|
|
||||||
Ecore_Timer *timer_pid;
|
Ecore_Timer *timer_pid;
|
||||||
pid_t selected_pid;
|
pid_t selected_pid;
|
||||||
pid_t program_pid;
|
pid_t program_pid;
|
||||||
|
|
||||||
Data_Unit data_unit;
|
Data_Unit data_unit;
|
||||||
|
|
||||||
#define TEXT_FIELD_MAX 65535
|
#define TEXT_FIELD_MAX 65535
|
||||||
char *fields[PROCESS_INFO_FIELDS];
|
char *fields[PROCESS_INFO_FIELDS];
|
||||||
|
|
||||||
Evas_Object *list_pid;
|
Evas_Object *list_pid;
|
||||||
|
|
||||||
Eina_Bool first_run;
|
Eina_Bool first_run;
|
||||||
|
|
||||||
int64_t cpu_times[PID_MAX];
|
int64_t cpu_times[PID_MAX];
|
||||||
int64_t pid_cpu_time;
|
int64_t pid_cpu_time;
|
||||||
|
|
||||||
int poll_delay;
|
int poll_delay;
|
||||||
|
|
||||||
Sort_Type sort_type;
|
|
||||||
Eina_Bool sort_reverse;
|
|
||||||
Eina_Bool panel_visible;
|
|
||||||
|
|
||||||
|
Sort_Type sort_type;
|
||||||
|
Eina_Bool sort_reverse;
|
||||||
|
Eina_Bool panel_visible;
|
||||||
} Ui;
|
} Ui;
|
||||||
|
|
||||||
Ui *
|
Ui *
|
||||||
ui_add(Evas_Object *win);
|
ui_add(Evas_Object *win);
|
||||||
|
|
||||||
void
|
void
|
||||||
ui_shutdown(Ui *ui);
|
ui_shutdown(Ui *ui);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue