2020-01-04 04:59:03 -08:00
|
|
|
#include "config.h"
|
2020-04-14 10:24:27 -07:00
|
|
|
#include "ui.h"
|
2020-05-12 16:51:30 -07:00
|
|
|
#include "ui/ui_disk.h"
|
|
|
|
#include "ui/ui_misc.h"
|
|
|
|
#include "ui/ui_memory.h"
|
|
|
|
#include "ui/ui_cpu.h"
|
2020-05-17 08:33:27 -07:00
|
|
|
#include "ui/ui_process_view.h"
|
2020-05-12 16:51:30 -07:00
|
|
|
|
2018-06-04 03:11:21 -07:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/types.h>
|
2020-04-18 07:01:00 -07:00
|
|
|
#include <sys/resource.h>
|
2018-06-04 03:11:21 -07:00
|
|
|
#include <pwd.h>
|
|
|
|
|
2020-04-20 11:42:35 -07:00
|
|
|
Ui *_ui;
|
|
|
|
Evisum_Config *_evisum_config;
|
2018-06-04 03:11:21 -07:00
|
|
|
static Eina_Lock _lock;
|
2020-04-14 10:24:27 -07:00
|
|
|
|
|
|
|
static void
|
|
|
|
_config_save(Ui *ui)
|
|
|
|
{
|
2020-04-18 12:56:04 -07:00
|
|
|
Evas_Coord w, h;
|
|
|
|
|
2020-04-15 10:24:19 -07:00
|
|
|
if (!_evisum_config) return;
|
2020-04-18 12:56:04 -07:00
|
|
|
|
|
|
|
evas_object_geometry_get(ui->win, NULL, NULL, &w, &h);
|
2020-04-14 10:24:27 -07:00
|
|
|
|
2020-04-15 10:24:19 -07:00
|
|
|
_evisum_config->sort_type = ui->sort_type;
|
|
|
|
_evisum_config->sort_reverse = ui->sort_reverse;
|
2020-04-18 12:56:04 -07:00
|
|
|
_evisum_config->width = w;
|
|
|
|
_evisum_config->height = h;
|
2020-04-14 10:24:27 -07:00
|
|
|
|
2020-04-15 10:24:19 -07:00
|
|
|
config_save(_evisum_config);
|
2020-04-14 10:24:27 -07:00
|
|
|
}
|
2018-06-09 03:30:07 -07:00
|
|
|
|
2020-04-15 05:57:50 -07:00
|
|
|
static void
|
|
|
|
_config_load(Ui *ui)
|
|
|
|
{
|
2020-04-15 10:24:19 -07:00
|
|
|
_evisum_config = config_load();
|
2020-04-22 10:28:20 -07:00
|
|
|
|
2020-04-15 10:24:19 -07:00
|
|
|
ui->sort_type = _evisum_config->sort_type;
|
|
|
|
ui->sort_reverse = _evisum_config->sort_reverse;
|
2020-04-18 12:56:04 -07:00
|
|
|
|
2020-04-22 10:28:20 -07:00
|
|
|
if ((_evisum_config->width > 0) && (_evisum_config->height > 0))
|
|
|
|
evas_object_resize(ui->win, _evisum_config->width, _evisum_config->height);
|
2020-04-15 05:57:50 -07:00
|
|
|
}
|
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
static int
|
|
|
|
_sort_by_pid(const void *p1, const void *p2)
|
2018-06-04 03:11:21 -07:00
|
|
|
{
|
2020-04-16 14:03:25 -07:00
|
|
|
const Proc_Info *inf1, *inf2;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
inf1 = p1; inf2 = p2;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
return inf1->pid - inf2->pid;
|
2018-06-04 03:11:21 -07:00
|
|
|
}
|
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
static int
|
|
|
|
_sort_by_uid(const void *p1, const void *p2)
|
2018-06-04 03:11:21 -07:00
|
|
|
{
|
2020-04-16 14:03:25 -07:00
|
|
|
const Proc_Info *inf1, *inf2;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
inf1 = p1; inf2 = p2;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
return inf1->uid - inf2->uid;
|
2018-06-04 03:11:21 -07:00
|
|
|
}
|
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
static int
|
|
|
|
_sort_by_nice(const void *p1, const void *p2)
|
2018-06-04 03:11:21 -07:00
|
|
|
{
|
2020-04-16 14:03:25 -07:00
|
|
|
const Proc_Info *inf1, *inf2;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
inf1 = p1; inf2 = p2;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
return inf1->nice - inf2->nice;
|
|
|
|
}
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
static int
|
|
|
|
_sort_by_pri(const void *p1, const void *p2)
|
|
|
|
{
|
2020-04-16 14:03:25 -07:00
|
|
|
const Proc_Info *inf1, *inf2;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
inf1 = p1; inf2 = p2;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
return inf1->priority - inf2->priority;
|
2018-06-04 03:11:21 -07:00
|
|
|
}
|
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
static int
|
|
|
|
_sort_by_cpu(const void *p1, const void *p2)
|
2018-06-04 03:11:21 -07:00
|
|
|
{
|
2020-04-16 14:03:25 -07:00
|
|
|
const Proc_Info *inf1, *inf2;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
inf1 = p1; inf2 = p2;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
return inf1->cpu_id - inf2->cpu_id;
|
|
|
|
}
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
static int
|
|
|
|
_sort_by_threads(const void *p1, const void *p2)
|
|
|
|
{
|
2020-04-16 14:03:25 -07:00
|
|
|
const Proc_Info *inf1, *inf2;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
inf1 = p1; inf2 = p2;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
return inf1->numthreads - inf2->numthreads;
|
2018-06-04 03:11:21 -07:00
|
|
|
}
|
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
static int
|
|
|
|
_sort_by_size(const void *p1, const void *p2)
|
2018-06-04 03:11:21 -07:00
|
|
|
{
|
2020-04-16 14:03:25 -07:00
|
|
|
const Proc_Info *inf1, *inf2;
|
2018-10-12 05:10:37 -07:00
|
|
|
int64_t size1, size2;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
inf1 = p1; inf2 = p2;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2020-04-22 15:05:39 -07:00
|
|
|
size1 = inf1->mem_size;
|
|
|
|
size2 = inf2->mem_size;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
if (size1 < size2)
|
|
|
|
return -1;
|
|
|
|
if (size2 > size1)
|
|
|
|
return 1;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
return 0;
|
2018-06-04 03:11:21 -07:00
|
|
|
}
|
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
static int
|
|
|
|
_sort_by_rss(const void *p1, const void *p2)
|
2018-06-04 03:11:21 -07:00
|
|
|
{
|
2020-04-16 14:03:25 -07:00
|
|
|
const Proc_Info *inf1, *inf2;
|
2018-10-12 05:10:37 -07:00
|
|
|
int64_t size1, size2;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
inf1 = p1; inf2 = p2;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
size1 = inf1->mem_rss;
|
|
|
|
size2 = inf2->mem_rss;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
if (size1 < size2)
|
|
|
|
return -1;
|
|
|
|
if (size2 > size1)
|
|
|
|
return 1;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
return 0;
|
2018-06-04 03:11:21 -07:00
|
|
|
}
|
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
static int
|
|
|
|
_sort_by_cpu_usage(const void *p1, const void *p2)
|
2018-06-04 03:11:21 -07:00
|
|
|
{
|
2020-04-16 14:03:25 -07:00
|
|
|
const Proc_Info *inf1, *inf2;
|
2018-10-12 05:10:37 -07:00
|
|
|
double one, two;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
inf1 = p1; inf2 = p2;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
one = inf1->cpu_usage;
|
|
|
|
two = inf2->cpu_usage;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2020-05-17 11:30:00 -07:00
|
|
|
if (one > two)
|
2018-10-12 05:10:37 -07:00
|
|
|
return 1;
|
2020-05-17 11:30:00 -07:00
|
|
|
else if (one < two)
|
|
|
|
return -1;
|
|
|
|
else return 0;
|
2018-06-04 03:11:21 -07:00
|
|
|
}
|
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
static int
|
|
|
|
_sort_by_cmd(const void *p1, const void *p2)
|
2018-06-04 03:11:21 -07:00
|
|
|
{
|
2020-04-16 14:03:25 -07:00
|
|
|
const Proc_Info *inf1, *inf2;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
inf1 = p1; inf2 = p2;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
return strcasecmp(inf1->command, inf2->command);
|
|
|
|
}
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
static int
|
|
|
|
_sort_by_state(const void *p1, const void *p2)
|
|
|
|
{
|
2020-04-16 14:03:25 -07:00
|
|
|
const Proc_Info *inf1, *inf2;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
inf1 = p1; inf2 = p2;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
return strcmp(inf1->state, inf2->state);
|
2018-06-04 03:11:21 -07:00
|
|
|
}
|
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
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;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
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;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
case SORT_BY_THREADS:
|
|
|
|
list = eina_list_sort(list, eina_list_count(list), _sort_by_threads);
|
|
|
|
break;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
case SORT_BY_SIZE:
|
|
|
|
list = eina_list_sort(list, eina_list_count(list), _sort_by_size);
|
|
|
|
break;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
case SORT_BY_RSS:
|
|
|
|
list = eina_list_sort(list, eina_list_count(list), _sort_by_rss);
|
|
|
|
break;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
case SORT_BY_CMD:
|
|
|
|
list = eina_list_sort(list, eina_list_count(list), _sort_by_cmd);
|
|
|
|
break;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
case SORT_BY_STATE:
|
|
|
|
list = eina_list_sort(list, eina_list_count(list), _sort_by_state);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SORT_BY_CPU_USAGE:
|
|
|
|
list = eina_list_sort(list, eina_list_count(list), _sort_by_cpu_usage);
|
|
|
|
break;
|
2018-06-04 03:11:21 -07:00
|
|
|
}
|
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
if (ui->sort_reverse)
|
|
|
|
list = eina_list_reverse(list);
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
return list;
|
2018-06-04 03:11:21 -07:00
|
|
|
}
|
|
|
|
|
2020-02-24 09:22:22 -08:00
|
|
|
typedef struct {
|
|
|
|
pid_t pid;
|
|
|
|
int64_t cpu_time_prev;
|
|
|
|
} pid_cpu_time_t;
|
|
|
|
|
|
|
|
static void
|
|
|
|
_proc_pid_cpu_times_free(Ui *ui)
|
|
|
|
{
|
|
|
|
pid_cpu_time_t *tmp;
|
|
|
|
|
|
|
|
EINA_LIST_FREE(ui->cpu_times, tmp)
|
|
|
|
{
|
|
|
|
free(tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ui->cpu_times)
|
|
|
|
eina_list_free(ui->cpu_times);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-04-16 14:03:25 -07:00
|
|
|
_proc_pid_cpu_time_save(Ui *ui, Proc_Info *proc)
|
2020-02-24 09:22:22 -08:00
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
pid_cpu_time_t *tmp;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(ui->cpu_times, l, tmp)
|
|
|
|
{
|
|
|
|
if (tmp->pid == proc->pid)
|
|
|
|
{
|
|
|
|
tmp->cpu_time_prev = proc->cpu_time;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp = calloc(1, sizeof(pid_cpu_time_t));
|
|
|
|
if (tmp)
|
|
|
|
{
|
|
|
|
tmp->pid = proc->pid;
|
|
|
|
tmp->cpu_time_prev = proc->cpu_time;
|
|
|
|
ui->cpu_times = eina_list_append(ui->cpu_times, tmp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-04-16 14:03:25 -07:00
|
|
|
_proc_pid_cpu_usage_get(Ui *ui, Proc_Info *proc)
|
2020-02-24 09:22:22 -08:00
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
pid_cpu_time_t *tmp;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(ui->cpu_times, l, tmp)
|
|
|
|
{
|
|
|
|
if (tmp->pid == proc->pid)
|
|
|
|
{
|
|
|
|
if (tmp->cpu_time_prev && proc->cpu_time > tmp->cpu_time_prev)
|
|
|
|
{
|
|
|
|
proc->cpu_usage = (double) (proc->cpu_time - tmp->cpu_time_prev) /
|
|
|
|
ui->poll_delay;
|
|
|
|
}
|
|
|
|
_proc_pid_cpu_time_save(ui, proc);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_proc_pid_cpu_time_save(ui, proc);
|
|
|
|
}
|
|
|
|
|
2020-04-17 18:07:12 -07:00
|
|
|
static void
|
|
|
|
_item_unrealized_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|
|
|
{
|
2020-04-17 20:11:03 -07:00
|
|
|
Ui *ui;
|
2020-04-17 18:38:16 -07:00
|
|
|
Evas_Object *o;
|
2020-05-18 04:16:35 -07:00
|
|
|
Eina_List *contents = NULL;
|
2020-04-17 18:07:12 -07:00
|
|
|
|
2020-04-17 20:11:03 -07:00
|
|
|
ui = data;
|
|
|
|
|
2020-04-17 18:07:12 -07:00
|
|
|
elm_genlist_item_all_contents_unset(event_info, &contents);
|
2020-05-18 04:16:35 -07:00
|
|
|
|
2020-04-17 18:07:12 -07:00
|
|
|
EINA_LIST_FREE(contents, o)
|
2020-05-18 04:16:35 -07:00
|
|
|
{
|
|
|
|
evisum_ui_item_cache_item_release(ui->cache, o);
|
|
|
|
}
|
2020-04-17 18:07:12 -07:00
|
|
|
}
|
|
|
|
|
2020-04-15 18:27:09 -07:00
|
|
|
static void
|
|
|
|
_item_del(void *data, Evas_Object *obj EINA_UNUSED)
|
|
|
|
{
|
2020-04-16 14:03:25 -07:00
|
|
|
Proc_Info *proc = data;
|
2020-04-22 02:10:02 -07:00
|
|
|
proc_info_free(proc);
|
2020-04-18 05:41:25 -07:00
|
|
|
proc = NULL;
|
2020-04-15 18:27:09 -07:00
|
|
|
}
|
|
|
|
|
2020-04-14 10:24:27 -07:00
|
|
|
static Evas_Object *
|
2020-05-13 15:55:40 -07:00
|
|
|
_item_column_add(Evas_Object *table, const char *text, int col)
|
2020-04-14 10:24:27 -07:00
|
|
|
{
|
2020-05-13 15:55:40 -07:00
|
|
|
Evas_Object *rect, *label;
|
2020-04-14 10:24:27 -07:00
|
|
|
|
2020-05-13 15:55:40 -07:00
|
|
|
label = elm_label_add(table);
|
2020-04-14 10:24:27 -07:00
|
|
|
evas_object_size_hint_align_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_weight_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2020-05-13 15:55:40 -07:00
|
|
|
evas_object_data_set(table, text, label);
|
2020-04-14 10:24:27 -07:00
|
|
|
evas_object_show(label);
|
|
|
|
|
|
|
|
rect = evas_object_rectangle_add(table);
|
2020-04-17 18:07:12 -07:00
|
|
|
evas_object_data_set(label, "rect", rect);
|
2020-04-14 10:24:27 -07:00
|
|
|
|
2020-05-13 15:55:40 -07:00
|
|
|
elm_table_pack(table, rect, col, 0, 1, 1);
|
|
|
|
elm_table_pack(table, label, col, 0, 1, 1);
|
2020-04-14 10:24:27 -07:00
|
|
|
|
2020-05-13 15:55:40 -07:00
|
|
|
return label;
|
|
|
|
}
|
2020-04-14 10:24:27 -07:00
|
|
|
|
2020-05-13 15:55:40 -07:00
|
|
|
static Evas_Object *
|
|
|
|
_item_create(Evas_Object *parent)
|
|
|
|
{
|
|
|
|
Evas_Object *obj, *table, *label;
|
2020-04-14 10:24:27 -07:00
|
|
|
|
2020-05-13 15:55:40 -07:00
|
|
|
obj = parent;
|
|
|
|
|
|
|
|
table = elm_table_add(obj);
|
|
|
|
evas_object_size_hint_align_set(table, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_weight_set(table, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
evas_object_show(table);
|
|
|
|
|
|
|
|
_item_column_add(table, "proc_pid", 0);
|
|
|
|
_item_column_add(table, "proc_uid", 1);
|
|
|
|
_item_column_add(table, "proc_size", 2);
|
|
|
|
_item_column_add(table, "proc_rss", 3);
|
|
|
|
_item_column_add(table, "proc_cmd", 4);
|
|
|
|
|
|
|
|
label = _item_column_add(table, "proc_state", 5);
|
2020-04-17 18:27:18 -07:00
|
|
|
evas_object_size_hint_align_set(label, 0.5, EVAS_HINT_EXPAND);
|
2020-04-14 10:24:27 -07:00
|
|
|
|
2020-05-13 15:55:40 -07:00
|
|
|
label = _item_column_add(table, "proc_cpu_usage", 6);
|
2020-04-17 18:27:18 -07:00
|
|
|
evas_object_size_hint_align_set(label, 0.5, EVAS_HINT_EXPAND);
|
2020-04-14 10:24:27 -07:00
|
|
|
|
|
|
|
return table;
|
|
|
|
}
|
|
|
|
|
2020-04-17 18:07:12 -07:00
|
|
|
static Evas_Object *
|
|
|
|
_content_get(void *data, Evas_Object *obj, const char *source)
|
|
|
|
{
|
|
|
|
Ui *ui;
|
|
|
|
Proc_Info *proc;
|
2020-04-18 05:41:25 -07:00
|
|
|
struct passwd *pwd_entry;
|
2020-04-17 18:07:12 -07:00
|
|
|
Evas_Object *l, *r;
|
2020-04-18 12:06:48 -07:00
|
|
|
Evas_Coord w, ow;
|
2020-04-17 18:07:12 -07:00
|
|
|
|
|
|
|
proc = (void *) data;
|
|
|
|
ui = _ui;
|
|
|
|
|
|
|
|
if (strcmp(source, "elm.swallow.content")) return NULL;
|
|
|
|
if (!proc) return NULL;
|
|
|
|
if (!ui->ready) return NULL;
|
|
|
|
|
2020-05-18 04:16:35 -07:00
|
|
|
Item_Cache *it = evisum_ui_item_cache_item_get(ui->cache);
|
2020-04-17 18:07:12 -07:00
|
|
|
if (!it)
|
|
|
|
{
|
2020-04-20 02:58:18 -07:00
|
|
|
fprintf(stderr, "Error: Object cache creation failed.\n");
|
|
|
|
exit(-1);
|
2020-04-17 18:07:12 -07:00
|
|
|
}
|
|
|
|
|
2020-04-18 12:06:48 -07:00
|
|
|
evas_object_geometry_get(ui->btn_pid, NULL, NULL, &w, NULL);
|
2020-04-17 18:07:12 -07:00
|
|
|
l = evas_object_data_get(it->obj, "proc_pid");
|
2020-04-17 19:33:59 -07:00
|
|
|
elm_object_text_set(l, eina_slstr_printf("%d", proc->pid));
|
2020-04-18 12:06:48 -07:00
|
|
|
evas_object_geometry_get(l, NULL, NULL, &ow, NULL);
|
|
|
|
if (ow > w) evas_object_size_hint_min_set(ui->btn_pid, w, 1);
|
2020-04-17 18:07:12 -07:00
|
|
|
r = evas_object_data_get(l, "rect");
|
|
|
|
evas_object_size_hint_min_set(r, w, 1);
|
|
|
|
|
2020-04-18 12:06:48 -07:00
|
|
|
evas_object_geometry_get(ui->btn_uid, NULL, NULL, &w, NULL);
|
2020-04-17 18:07:12 -07:00
|
|
|
l = evas_object_data_get(it->obj, "proc_uid");
|
2020-04-18 05:41:25 -07:00
|
|
|
pwd_entry = getpwuid(proc->uid);
|
|
|
|
if (pwd_entry)
|
|
|
|
elm_object_text_set(l, pwd_entry->pw_name);
|
|
|
|
else
|
|
|
|
elm_object_text_set(l, eina_slstr_printf("%d", proc->uid));
|
2020-04-18 12:06:48 -07:00
|
|
|
evas_object_geometry_get(l, NULL, NULL, &ow, NULL);
|
|
|
|
if (ow > w) evas_object_size_hint_min_set(ui->btn_uid, w, 1);
|
2020-04-17 18:07:12 -07:00
|
|
|
r = evas_object_data_get(l, "rect");
|
|
|
|
evas_object_size_hint_min_set(r, w, 1);
|
|
|
|
|
2020-04-18 12:06:48 -07:00
|
|
|
evas_object_geometry_get(ui->btn_size, NULL, NULL, &w, NULL);
|
2020-04-17 18:07:12 -07:00
|
|
|
l = evas_object_data_get(it->obj, "proc_size");
|
2020-05-12 16:51:30 -07:00
|
|
|
elm_object_text_set(l, evisum_size_format(proc->mem_size));
|
2020-04-18 12:06:48 -07:00
|
|
|
evas_object_geometry_get(l, NULL, NULL, &ow, NULL);
|
|
|
|
if (ow > w) evas_object_size_hint_min_set(ui->btn_size, w, 1);
|
2020-04-17 18:07:12 -07:00
|
|
|
r = evas_object_data_get(l, "rect");
|
|
|
|
evas_object_size_hint_min_set(r, w, 1);
|
|
|
|
|
2020-04-18 12:06:48 -07:00
|
|
|
evas_object_geometry_get(ui->btn_rss, NULL, NULL, &w, NULL);
|
2020-04-17 18:07:12 -07:00
|
|
|
l = evas_object_data_get(it->obj, "proc_rss");
|
2020-05-12 16:51:30 -07:00
|
|
|
elm_object_text_set(l, evisum_size_format(proc->mem_rss));
|
2020-04-18 12:06:48 -07:00
|
|
|
evas_object_geometry_get(l, NULL, NULL, &ow, NULL);
|
|
|
|
if (ow > w) evas_object_size_hint_min_set(ui->btn_rss, w, 1);
|
2020-04-17 18:07:12 -07:00
|
|
|
r = evas_object_data_get(l, "rect");
|
|
|
|
evas_object_size_hint_min_set(r, w, 1);
|
|
|
|
|
2020-04-18 12:06:48 -07:00
|
|
|
evas_object_geometry_get(ui->btn_cmd, NULL, NULL, &w, NULL);
|
2020-04-17 18:07:12 -07:00
|
|
|
l = evas_object_data_get(it->obj, "proc_cmd");
|
2020-04-17 19:33:59 -07:00
|
|
|
elm_object_text_set(l, eina_slstr_printf("%s", proc->command));
|
2020-04-18 12:06:48 -07:00
|
|
|
evas_object_geometry_get(l, NULL, NULL, &ow, NULL);
|
|
|
|
if (ow > w) evas_object_size_hint_min_set(ui->btn_cmd, w, 1);
|
2020-04-17 18:07:12 -07:00
|
|
|
r = evas_object_data_get(l, "rect");
|
|
|
|
evas_object_size_hint_min_set(r, w, 1);
|
|
|
|
|
2020-04-18 12:06:48 -07:00
|
|
|
evas_object_geometry_get(ui->btn_state, NULL, NULL, &w, NULL);
|
2020-04-17 18:07:12 -07:00
|
|
|
l = evas_object_data_get(it->obj, "proc_state");
|
2020-04-17 19:33:59 -07:00
|
|
|
elm_object_text_set(l, eina_slstr_printf("%s", proc->state));
|
2020-04-18 12:06:48 -07:00
|
|
|
evas_object_geometry_get(l, NULL, NULL, &ow, NULL);
|
|
|
|
if (ow > w) evas_object_size_hint_min_set(ui->btn_state, w, 1);
|
2020-04-17 18:07:12 -07:00
|
|
|
r = evas_object_data_get(l, "rect");
|
|
|
|
evas_object_size_hint_min_set(r, w, 1);
|
|
|
|
|
2020-04-18 12:06:48 -07:00
|
|
|
evas_object_geometry_get(ui->btn_cpu_usage, NULL, NULL, &w, NULL);
|
2020-04-17 18:07:12 -07:00
|
|
|
l = evas_object_data_get(it->obj, "proc_cpu_usage");
|
2020-04-17 19:33:59 -07:00
|
|
|
elm_object_text_set(l, eina_slstr_printf("%.1f%%", proc->cpu_usage));
|
2020-04-18 12:06:48 -07:00
|
|
|
evas_object_geometry_get(l, NULL, NULL, &ow, NULL);
|
|
|
|
if (ow > w) evas_object_size_hint_min_set(ui->btn_cpu_usage, w, 1);
|
2020-04-17 18:07:12 -07:00
|
|
|
r = evas_object_data_get(l, "rect");
|
|
|
|
evas_object_size_hint_min_set(r, w, 1);
|
|
|
|
|
|
|
|
return it->obj;
|
|
|
|
}
|
|
|
|
|
2020-04-14 10:24:27 -07:00
|
|
|
static void
|
|
|
|
_genlist_ensure_n_items(Evas_Object *genlist, unsigned int items)
|
|
|
|
{
|
|
|
|
Elm_Object_Item *it;
|
|
|
|
Elm_Genlist_Item_Class *itc;
|
|
|
|
unsigned int i, existing = elm_genlist_items_count(genlist);
|
|
|
|
|
|
|
|
if (items < existing)
|
|
|
|
{
|
|
|
|
for (i = existing - items; i > 0; i--)
|
|
|
|
{
|
|
|
|
it = elm_genlist_last_item_get(genlist);
|
|
|
|
if (it)
|
2020-04-14 17:59:40 -07:00
|
|
|
elm_object_item_del(it);
|
2020-04-14 10:24:27 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (items == existing) return;
|
|
|
|
|
|
|
|
itc = elm_genlist_item_class_new();
|
|
|
|
itc->item_style = "full";
|
|
|
|
itc->func.text_get = NULL;
|
|
|
|
itc->func.content_get = _content_get;
|
|
|
|
itc->func.filter_get = NULL;
|
|
|
|
itc->func.del = _item_del;
|
|
|
|
|
|
|
|
for (i = existing; i < items; i++)
|
|
|
|
{
|
|
|
|
elm_genlist_item_append(genlist, itc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
elm_genlist_item_class_free(itc);
|
|
|
|
}
|
|
|
|
|
2020-05-08 15:01:58 -07:00
|
|
|
static void
|
|
|
|
_bring_in(Ui *ui)
|
|
|
|
{
|
|
|
|
int h_page, v_page;
|
|
|
|
static Eina_Bool init_done = EINA_FALSE;
|
|
|
|
|
|
|
|
if (init_done || !ui->ready) return;
|
|
|
|
|
|
|
|
elm_scroller_gravity_set(ui->scroller, 0.0, 0.0);
|
|
|
|
elm_scroller_last_page_get(ui->scroller, &h_page, &v_page);
|
|
|
|
elm_scroller_page_bring_in(ui->scroller, h_page, v_page);
|
|
|
|
init_done = EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
static void
|
2019-09-05 14:33:38 -07:00
|
|
|
_process_list_feedback_cb(void *data, Ecore_Thread *thread EINA_UNUSED, void *msg EINA_UNUSED)
|
2018-06-04 03:11:21 -07:00
|
|
|
{
|
|
|
|
Ui *ui;
|
2020-04-14 10:24:27 -07:00
|
|
|
Eina_List *list, *l, *l_next;
|
2020-04-16 14:03:25 -07:00
|
|
|
Proc_Info *proc;
|
2020-04-14 10:24:27 -07:00
|
|
|
Elm_Object_Item *it;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
ui = data;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2020-04-14 10:24:27 -07:00
|
|
|
eina_lock_take(&_lock);
|
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
list = proc_info_all_get();
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2020-04-14 10:24:27 -07:00
|
|
|
EINA_LIST_FOREACH_SAFE(list, l, l_next, proc)
|
2018-06-04 03:11:21 -07:00
|
|
|
{
|
2020-05-13 03:54:22 -07:00
|
|
|
if ((ui->search_text && ui->search_text[0] &&
|
2020-04-14 10:24:27 -07:00
|
|
|
strncasecmp(proc->command, ui->search_text, strlen(ui->search_text))) ||
|
|
|
|
(!ui->show_self && proc->pid == ui->program_pid))
|
|
|
|
{
|
2020-04-22 02:10:02 -07:00
|
|
|
proc_info_free(proc);
|
2020-04-14 10:24:27 -07:00
|
|
|
list = eina_list_remove_list(list, l);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_proc_pid_cpu_usage_get(ui, proc);
|
|
|
|
}
|
2018-06-04 03:11:21 -07:00
|
|
|
}
|
|
|
|
|
2020-04-14 10:24:27 -07:00
|
|
|
_genlist_ensure_n_items(ui->genlist_procs, eina_list_count(list));
|
|
|
|
it = elm_genlist_first_item_get(ui->genlist_procs);
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2020-04-17 20:11:03 -07:00
|
|
|
list = _list_sort(ui, list);
|
2018-10-12 05:10:37 -07:00
|
|
|
EINA_LIST_FREE(list, proc)
|
2018-06-04 03:11:21 -07:00
|
|
|
{
|
2020-05-16 10:58:43 -07:00
|
|
|
Proc_Info *prev = elm_object_item_data_get(it);
|
|
|
|
if (prev)
|
|
|
|
proc_info_free(prev);
|
|
|
|
|
2020-04-14 10:24:27 -07:00
|
|
|
elm_object_item_data_set(it, proc);
|
2020-04-16 06:50:53 -07:00
|
|
|
elm_genlist_item_update(it);
|
2020-04-14 10:24:27 -07:00
|
|
|
it = elm_genlist_item_next_get(it);
|
2018-06-04 03:11:21 -07:00
|
|
|
}
|
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
if (list)
|
|
|
|
eina_list_free(list);
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
eina_lock_release(&_lock);
|
2020-05-08 15:01:58 -07:00
|
|
|
|
|
|
|
_bring_in(ui);
|
2018-10-12 05:10:37 -07:00
|
|
|
}
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
static void
|
2019-09-05 14:33:38 -07:00
|
|
|
_process_list_update(Ui *ui)
|
2018-10-12 05:10:37 -07:00
|
|
|
{
|
2019-09-05 14:33:38 -07:00
|
|
|
_process_list_feedback_cb(ui, NULL, NULL);
|
2018-06-04 03:11:21 -07:00
|
|
|
}
|
|
|
|
|
2020-04-18 04:28:38 -07:00
|
|
|
#define POLL_ONE_SEC 4
|
|
|
|
|
2018-06-04 03:11:21 -07:00
|
|
|
static void
|
2019-09-05 14:33:38 -07:00
|
|
|
_process_list(void *data, Ecore_Thread *thread)
|
2018-06-04 03:11:21 -07:00
|
|
|
{
|
2020-04-18 03:40:51 -07:00
|
|
|
Ui *ui;
|
2020-05-11 14:51:36 -07:00
|
|
|
int delay = 1;
|
2020-04-18 03:40:51 -07:00
|
|
|
|
|
|
|
ui = data;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2020-04-14 10:24:27 -07:00
|
|
|
while (1)
|
2018-06-04 03:11:21 -07:00
|
|
|
{
|
2018-10-12 05:10:37 -07:00
|
|
|
ecore_thread_feedback(thread, ui);
|
2020-05-08 16:41:53 -07:00
|
|
|
for (int i = 0; i < delay * POLL_ONE_SEC; i++)
|
2018-10-12 05:10:37 -07:00
|
|
|
{
|
2020-02-15 18:03:32 -08:00
|
|
|
if (ecore_thread_check(thread)) return;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
if (ui->skip_wait)
|
|
|
|
{
|
|
|
|
ui->skip_wait = EINA_FALSE;
|
|
|
|
break;
|
|
|
|
}
|
2019-09-05 14:33:38 -07:00
|
|
|
usleep(250000);
|
2018-10-12 05:10:37 -07:00
|
|
|
}
|
2020-04-14 10:24:27 -07:00
|
|
|
ui->ready = EINA_TRUE;
|
2020-05-11 14:51:36 -07:00
|
|
|
delay = ui->poll_delay;
|
2018-10-12 05:10:37 -07:00
|
|
|
}
|
2018-06-04 03:11:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-10-12 05:10:37 -07:00
|
|
|
_btn_icon_state_set(Evas_Object *button, Eina_Bool reverse)
|
2018-06-04 03:11:21 -07:00
|
|
|
{
|
2018-10-12 05:10:37 -07:00
|
|
|
Evas_Object *icon = elm_icon_add(button);
|
2020-02-15 18:03:32 -08:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
if (reverse)
|
2020-05-12 16:51:30 -07:00
|
|
|
elm_icon_standard_set(icon, evisum_icon_path_get("go-down"));
|
2018-10-12 05:10:37 -07:00
|
|
|
else
|
2020-05-12 16:51:30 -07:00
|
|
|
elm_icon_standard_set(icon, evisum_icon_path_get("go-up"));
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
elm_object_part_content_set(button, "icon", icon);
|
2020-02-24 09:22:22 -08:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
evas_object_show(icon);
|
2018-06-04 03:11:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-10-12 05:10:37 -07:00
|
|
|
_btn_pid_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
2018-06-04 03:11:21 -07:00
|
|
|
{
|
|
|
|
Ui *ui = data;
|
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
if (ui->sort_type == SORT_BY_PID)
|
|
|
|
ui->sort_reverse = !ui->sort_reverse;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
_btn_icon_state_set(ui->btn_pid, ui->sort_reverse);
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
ui->sort_type = SORT_BY_PID;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2020-04-14 10:24:27 -07:00
|
|
|
_config_save(ui);
|
2019-09-05 14:33:38 -07:00
|
|
|
_process_list_update(ui);
|
2020-04-16 08:49:44 -07:00
|
|
|
|
2020-04-16 06:50:53 -07:00
|
|
|
elm_scroller_page_bring_in(ui->scroller, 0, 0);
|
2018-10-12 05:10:37 -07:00
|
|
|
}
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
static void
|
|
|
|
_btn_uid_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Ui *ui = data;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
if (ui->sort_type == SORT_BY_UID)
|
|
|
|
ui->sort_reverse = !ui->sort_reverse;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
_btn_icon_state_set(ui->btn_uid, ui->sort_reverse);
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
ui->sort_type = SORT_BY_UID;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2020-04-14 10:24:27 -07:00
|
|
|
_config_save(ui);
|
2019-09-05 14:33:38 -07:00
|
|
|
_process_list_update(ui);
|
2020-04-16 06:50:53 -07:00
|
|
|
|
|
|
|
elm_scroller_page_bring_in(ui->scroller, 0, 0);
|
2018-06-04 03:11:21 -07:00
|
|
|
}
|
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
static void
|
|
|
|
_btn_cpu_usage_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
2018-06-09 03:30:07 -07:00
|
|
|
{
|
2018-10-12 05:10:37 -07:00
|
|
|
Ui *ui = data;
|
|
|
|
|
|
|
|
if (ui->sort_type == SORT_BY_CPU_USAGE)
|
|
|
|
ui->sort_reverse = !ui->sort_reverse;
|
2018-06-09 03:30:07 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
_btn_icon_state_set(ui->btn_cpu_usage, ui->sort_reverse);
|
|
|
|
|
|
|
|
ui->sort_type = SORT_BY_CPU_USAGE;
|
|
|
|
|
2020-04-14 10:24:27 -07:00
|
|
|
_config_save(ui);
|
2019-09-05 14:33:38 -07:00
|
|
|
_process_list_update(ui);
|
2020-04-16 06:50:53 -07:00
|
|
|
|
|
|
|
elm_scroller_page_bring_in(ui->scroller, 0, 0);
|
2018-06-09 03:30:07 -07:00
|
|
|
}
|
|
|
|
|
2018-06-04 03:11:21 -07:00
|
|
|
static void
|
2018-10-12 05:10:37 -07:00
|
|
|
_btn_size_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
2018-06-09 03:30:07 -07:00
|
|
|
{
|
2018-10-12 05:10:37 -07:00
|
|
|
Ui *ui = data;
|
2018-06-09 03:30:07 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
if (ui->sort_type == SORT_BY_SIZE)
|
|
|
|
ui->sort_reverse = !ui->sort_reverse;
|
2018-06-09 03:30:07 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
_btn_icon_state_set(ui->btn_size, ui->sort_reverse);
|
2018-06-09 03:30:07 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
ui->sort_type = SORT_BY_SIZE;
|
2018-06-10 01:32:15 -07:00
|
|
|
|
2020-04-14 10:24:27 -07:00
|
|
|
_config_save(ui);
|
2019-09-05 14:33:38 -07:00
|
|
|
_process_list_update(ui);
|
2020-04-16 06:50:53 -07:00
|
|
|
|
|
|
|
elm_scroller_page_bring_in(ui->scroller, 0, 0);
|
2018-10-12 05:10:37 -07:00
|
|
|
}
|
2018-06-09 03:30:07 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
static void
|
|
|
|
_btn_rss_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Ui *ui = data;
|
2018-06-09 11:55:04 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
if (ui->sort_type == SORT_BY_RSS)
|
|
|
|
ui->sort_reverse = !ui->sort_reverse;
|
2018-06-09 03:30:07 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
_btn_icon_state_set(ui->btn_rss, ui->sort_reverse);
|
2018-06-09 03:30:07 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
ui->sort_type = SORT_BY_RSS;
|
|
|
|
|
2020-04-14 10:24:27 -07:00
|
|
|
_config_save(ui);
|
2019-09-05 14:33:38 -07:00
|
|
|
_process_list_update(ui);
|
2020-04-16 06:50:53 -07:00
|
|
|
|
|
|
|
elm_scroller_page_bring_in(ui->scroller, 0, 0);
|
2018-06-09 03:30:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-10-12 05:10:37 -07:00
|
|
|
_btn_cmd_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
2018-06-09 03:30:07 -07:00
|
|
|
{
|
2018-10-12 05:10:37 -07:00
|
|
|
Ui *ui = data;
|
2018-06-09 03:30:07 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
if (ui->sort_type == SORT_BY_CMD)
|
|
|
|
ui->sort_reverse = !ui->sort_reverse;
|
2018-06-10 06:09:44 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
_btn_icon_state_set(ui->btn_cmd, ui->sort_reverse);
|
2018-06-09 03:30:07 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
ui->sort_type = SORT_BY_CMD;
|
2018-06-09 03:30:07 -07:00
|
|
|
|
2020-04-14 10:24:27 -07:00
|
|
|
_config_save(ui);
|
2019-09-05 14:33:38 -07:00
|
|
|
_process_list_update(ui);
|
2020-04-16 06:50:53 -07:00
|
|
|
|
|
|
|
elm_scroller_page_bring_in(ui->scroller, 0, 0);
|
2018-06-09 03:30:07 -07:00
|
|
|
}
|
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
static void
|
|
|
|
_btn_state_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
2018-06-10 06:09:44 -07:00
|
|
|
{
|
2018-10-12 05:10:37 -07:00
|
|
|
Ui *ui = data;
|
2018-06-10 06:09:44 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
if (ui->sort_type == SORT_BY_STATE)
|
|
|
|
ui->sort_reverse = !ui->sort_reverse;
|
2018-06-10 06:09:44 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
_btn_icon_state_set(ui->btn_state, ui->sort_reverse);
|
2018-06-10 06:09:44 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
ui->sort_type = SORT_BY_STATE;
|
2018-06-10 06:09:44 -07:00
|
|
|
|
2020-04-14 10:24:27 -07:00
|
|
|
_config_save(ui);
|
2019-09-05 14:33:38 -07:00
|
|
|
_process_list_update(ui);
|
2020-04-16 06:50:53 -07:00
|
|
|
|
|
|
|
elm_scroller_page_bring_in(ui->scroller, 0, 0);
|
2018-06-10 06:09:44 -07:00
|
|
|
}
|
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
static void
|
|
|
|
_btn_quit_clicked_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
2018-06-10 06:09:44 -07:00
|
|
|
{
|
2020-03-22 06:48:59 -07:00
|
|
|
exit(0);
|
2018-06-10 06:09:44 -07:00
|
|
|
}
|
|
|
|
|
2020-04-18 05:41:25 -07:00
|
|
|
static void
|
|
|
|
_item_menu_dismissed_cb(void *data EINA_UNUSED, Evas_Object *obj, void *ev EINA_UNUSED)
|
|
|
|
{
|
2020-04-18 07:36:34 -07:00
|
|
|
Ui *ui = data;
|
|
|
|
|
2020-04-18 05:41:25 -07:00
|
|
|
evas_object_del(obj);
|
2020-04-18 07:36:34 -07:00
|
|
|
|
|
|
|
ui->menu = NULL;
|
2020-04-18 05:41:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_item_menu_start_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Proc_Info *proc;
|
|
|
|
|
|
|
|
proc = data;
|
|
|
|
if (!proc) return;
|
|
|
|
|
|
|
|
kill(proc->pid, SIGCONT);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_item_menu_stop_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Proc_Info *proc;
|
|
|
|
|
|
|
|
proc = data;
|
|
|
|
if (!proc) return;
|
|
|
|
|
|
|
|
kill(proc->pid, SIGSTOP);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_item_menu_kill_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Proc_Info *proc;
|
|
|
|
|
|
|
|
proc = data;
|
|
|
|
if (!proc) return;
|
|
|
|
|
|
|
|
kill(proc->pid, SIGKILL);
|
|
|
|
}
|
|
|
|
|
2020-04-18 07:01:00 -07:00
|
|
|
static void
|
|
|
|
_item_menu_cancel_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|
|
|
{
|
2020-04-18 07:36:34 -07:00
|
|
|
Ui *ui = data;
|
2020-04-18 07:01:00 -07:00
|
|
|
|
2020-04-18 07:36:34 -07:00
|
|
|
elm_menu_close(ui->menu);
|
|
|
|
ui->menu = NULL;
|
2020-04-18 07:01:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_item_menu_priority_increase_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Proc_Info *proc = data;
|
|
|
|
if (!proc) return;
|
|
|
|
|
|
|
|
setpriority(PRIO_PROCESS, proc->pid, proc->nice - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_item_menu_priority_decrease_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Proc_Info *proc = data;
|
|
|
|
if (!proc) return;
|
|
|
|
|
|
|
|
setpriority(PRIO_PROCESS, proc->pid, proc->nice + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_item_menu_priority_add(Evas_Object *menu, Elm_Object_Item *menu_it, Proc_Info *proc)
|
|
|
|
{
|
|
|
|
Elm_Object_Item *it;
|
|
|
|
|
2020-05-12 16:51:30 -07:00
|
|
|
it = elm_menu_item_add(menu, menu_it, evisum_icon_path_get("window"), eina_slstr_printf("%d", proc->nice), NULL, NULL);
|
2020-04-18 07:01:00 -07:00
|
|
|
elm_menu_item_separator_add(menu, menu_it);
|
2020-05-12 16:51:30 -07:00
|
|
|
elm_menu_item_add(menu, menu_it, evisum_icon_path_get("increase"), _("Increase"), _item_menu_priority_increase_cb, proc);
|
|
|
|
elm_menu_item_add(menu, menu_it, evisum_icon_path_get("decrease"), _("Decrease"), _item_menu_priority_decrease_cb, proc);
|
2020-04-18 07:01:00 -07:00
|
|
|
elm_object_item_disabled_set(it, EINA_TRUE);
|
|
|
|
}
|
|
|
|
|
2020-04-22 14:55:22 -07:00
|
|
|
static Evas_Object *
|
2020-04-18 05:41:25 -07:00
|
|
|
_item_menu_create(Ui *ui, Proc_Info *proc)
|
|
|
|
{
|
2020-04-18 05:40:42 -07:00
|
|
|
Elm_Object_Item *menu_it, *menu_it2;
|
2020-04-18 05:41:25 -07:00
|
|
|
Evas_Object *menu;
|
|
|
|
Eina_Bool stopped;
|
|
|
|
if (!proc) return NULL;
|
|
|
|
|
2020-04-18 07:36:34 -07:00
|
|
|
ui->menu = menu = elm_menu_add(ui->win);
|
2020-04-18 05:41:25 -07:00
|
|
|
if (!menu) return NULL;
|
|
|
|
|
2020-04-18 07:36:34 -07:00
|
|
|
evas_object_smart_callback_add(menu, "dismissed", _item_menu_dismissed_cb, ui);
|
2020-04-18 05:41:25 -07:00
|
|
|
|
|
|
|
stopped = !!strcmp(proc->state, "stop");
|
|
|
|
|
2020-05-12 16:51:30 -07:00
|
|
|
menu_it = elm_menu_item_add(menu, NULL, evisum_icon_path_get("window"), proc->command, NULL, NULL);
|
2020-04-18 07:01:00 -07:00
|
|
|
|
2020-05-12 16:51:30 -07:00
|
|
|
menu_it2 = elm_menu_item_add(menu, menu_it, evisum_icon_path_get("window"), _("Priority"), NULL, NULL);
|
2020-04-18 07:01:00 -07:00
|
|
|
_item_menu_priority_add(menu, menu_it2, proc);
|
|
|
|
|
|
|
|
elm_menu_item_separator_add(menu, menu_it);
|
2020-05-12 16:51:30 -07:00
|
|
|
menu_it2 = elm_menu_item_add(menu, menu_it, evisum_icon_path_get("start"), _("Start"), _item_menu_start_cb, proc);
|
2020-04-18 05:41:25 -07:00
|
|
|
if (stopped) elm_object_item_disabled_set(menu_it2, EINA_TRUE);
|
2020-05-12 16:51:30 -07:00
|
|
|
menu_it2 = elm_menu_item_add(menu, menu_it, evisum_icon_path_get("stop"), _("Stop"), _item_menu_stop_cb, proc);
|
2020-04-18 05:41:25 -07:00
|
|
|
if (!stopped) elm_object_item_disabled_set(menu_it2, EINA_TRUE);
|
2020-05-12 16:51:30 -07:00
|
|
|
elm_menu_item_add(menu, menu_it, evisum_icon_path_get("kill"), "Kill", _item_menu_kill_cb, proc);
|
2020-04-18 05:41:25 -07:00
|
|
|
elm_menu_item_separator_add(menu, menu_it);
|
2020-05-12 16:51:30 -07:00
|
|
|
elm_menu_item_add(menu, menu_it, evisum_icon_path_get("cancel"), _("Cancel"), _item_menu_cancel_cb, ui);
|
2020-04-18 05:41:25 -07:00
|
|
|
|
|
|
|
return menu;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_item_pid_secondary_clicked_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
Evas_Object *menu;
|
|
|
|
Evas_Event_Mouse_Up *ev;
|
|
|
|
Ui *ui;
|
|
|
|
Elm_Object_Item *it;
|
|
|
|
Proc_Info *proc;
|
|
|
|
|
|
|
|
ev = event_info;
|
|
|
|
if (ev->button != 3) return;
|
|
|
|
|
|
|
|
it = elm_genlist_at_xy_item_get(obj, ev->output.x, ev->output.y, NULL);
|
|
|
|
proc = elm_object_item_data_get(it);
|
|
|
|
if (!proc) return;
|
|
|
|
|
|
|
|
ui = data;
|
|
|
|
|
|
|
|
menu = _item_menu_create(ui, proc);
|
|
|
|
if (!menu) return;
|
|
|
|
|
|
|
|
elm_menu_move(menu, ev->canvas.x, ev->canvas.y);
|
|
|
|
evas_object_show(menu);
|
|
|
|
}
|
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
static void
|
2020-04-17 15:49:12 -07:00
|
|
|
_item_pid_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
|
2018-10-12 05:10:37 -07:00
|
|
|
{
|
|
|
|
Ui *ui;
|
2020-04-14 10:24:27 -07:00
|
|
|
Elm_Object_Item *it;
|
2020-04-16 14:03:25 -07:00
|
|
|
Proc_Info *proc;
|
2018-06-10 06:09:44 -07:00
|
|
|
|
2018-10-12 05:10:37 -07:00
|
|
|
ui = data;
|
2020-04-17 15:49:12 -07:00
|
|
|
it = event_info;
|
2020-04-18 07:36:34 -07:00
|
|
|
|
|
|
|
elm_genlist_item_selected_set(it, EINA_FALSE);
|
|
|
|
if (ui->menu) return;
|
|
|
|
|
2020-04-14 10:24:27 -07:00
|
|
|
proc = elm_object_item_data_get(it);
|
|
|
|
if (!proc) return;
|
2018-06-10 06:09:44 -07:00
|
|
|
|
2020-04-14 10:24:27 -07:00
|
|
|
ui->selected_pid = proc->pid;
|
2020-05-14 06:43:44 -07:00
|
|
|
ui_process_win_add(proc->pid, proc->command);
|
2018-06-10 06:09:44 -07:00
|
|
|
}
|
|
|
|
|
2018-06-09 03:30:07 -07:00
|
|
|
static void
|
2019-09-05 14:33:38 -07:00
|
|
|
_ui_tab_system_add(Ui *ui)
|
2018-06-04 03:11:21 -07:00
|
|
|
{
|
2018-06-09 11:55:04 -07:00
|
|
|
Evas_Object *parent, *box, *hbox, *frame, *table;
|
2020-04-16 06:50:53 -07:00
|
|
|
Evas_Object *progress, *button, *plist;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2018-06-09 11:55:04 -07:00
|
|
|
parent = ui->content;
|
|
|
|
|
2020-05-08 18:17:17 -07:00
|
|
|
ui->system_activity = ui->current_view = box = elm_box_add(parent);
|
2018-06-04 03:11:21 -07:00
|
|
|
evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
evas_object_show(box);
|
2018-06-09 03:30:07 -07:00
|
|
|
elm_table_pack(ui->content, ui->system_activity, 0, 1, 1, 1);
|
2018-06-04 03:11:21 -07:00
|
|
|
|
|
|
|
hbox = elm_box_add(box);
|
|
|
|
evas_object_size_hint_weight_set(hbox, EVAS_HINT_EXPAND, 0);
|
|
|
|
evas_object_size_hint_align_set(hbox, EVAS_HINT_FILL, 0);
|
|
|
|
elm_box_horizontal_set(hbox, EINA_TRUE);
|
|
|
|
evas_object_show(hbox);
|
2020-02-15 18:03:32 -08:00
|
|
|
elm_box_pack_end(box, hbox);
|
2018-06-04 03:11:21 -07:00
|
|
|
|
|
|
|
frame = elm_frame_add(hbox);
|
|
|
|
evas_object_size_hint_weight_set(frame, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(frame, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2020-04-23 04:28:07 -07:00
|
|
|
elm_object_text_set(frame, _("System CPU"));
|
2018-06-04 03:11:21 -07:00
|
|
|
evas_object_show(frame);
|
2020-02-15 18:03:32 -08:00
|
|
|
elm_box_pack_end(hbox, frame);
|
2018-06-04 03:11:21 -07:00
|
|
|
|
|
|
|
ui->progress_cpu = progress = elm_progressbar_add(parent);
|
|
|
|
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_object_content_set(frame, progress);
|
|
|
|
evas_object_show(progress);
|
|
|
|
|
|
|
|
frame = elm_frame_add(hbox);
|
|
|
|
evas_object_size_hint_weight_set(frame, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(frame, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2020-04-23 04:28:07 -07:00
|
|
|
elm_object_text_set(frame, _("System Memory"));
|
2018-06-04 03:11:21 -07:00
|
|
|
evas_object_show(frame);
|
2020-02-15 18:03:32 -08:00
|
|
|
elm_box_pack_end(hbox, frame);
|
2018-06-04 03:11:21 -07:00
|
|
|
|
|
|
|
ui->progress_mem = progress = elm_progressbar_add(parent);
|
|
|
|
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);
|
|
|
|
evas_object_show(progress);
|
2020-02-15 18:03:32 -08:00
|
|
|
elm_object_content_set(frame, progress);
|
2018-06-04 03:11:21 -07:00
|
|
|
|
|
|
|
table = elm_table_add(parent);
|
|
|
|
evas_object_size_hint_weight_set(table, EVAS_HINT_EXPAND, 0);
|
|
|
|
evas_object_size_hint_align_set(table, EVAS_HINT_FILL, 0);
|
|
|
|
evas_object_show(table);
|
|
|
|
|
|
|
|
ui->btn_pid = button = elm_button_add(parent);
|
2020-04-14 10:24:27 -07:00
|
|
|
if (ui->sort_type == SORT_BY_PID)
|
|
|
|
{
|
|
|
|
_btn_icon_state_set(button, ui->sort_reverse);
|
|
|
|
elm_object_focus_set(button, EINA_TRUE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
_btn_icon_state_set(button, EINA_FALSE);
|
|
|
|
|
2020-02-15 07:30:31 -08:00
|
|
|
evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2020-04-23 04:28:07 -07:00
|
|
|
elm_object_text_set(button, _("PID"));
|
2018-06-04 03:11:21 -07:00
|
|
|
evas_object_show(button);
|
|
|
|
elm_table_pack(table, button, 0, 0, 1, 1);
|
|
|
|
|
|
|
|
ui->btn_uid = button = elm_button_add(parent);
|
2020-04-14 10:24:27 -07:00
|
|
|
if (ui->sort_type == SORT_BY_UID)
|
|
|
|
{
|
|
|
|
_btn_icon_state_set(button, ui->sort_reverse);
|
|
|
|
elm_object_focus_set(button, EINA_TRUE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
_btn_icon_state_set(button, EINA_FALSE);
|
|
|
|
|
2020-02-15 07:30:31 -08:00
|
|
|
evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2020-04-23 04:28:07 -07:00
|
|
|
elm_object_text_set(button, _("UID"));
|
2018-06-04 03:11:21 -07:00
|
|
|
evas_object_show(button);
|
|
|
|
elm_table_pack(table, button, 1, 0, 1, 1);
|
|
|
|
|
|
|
|
ui->btn_size = button = elm_button_add(parent);
|
2020-04-14 10:24:27 -07:00
|
|
|
if (ui->sort_type == SORT_BY_SIZE)
|
|
|
|
{
|
|
|
|
_btn_icon_state_set(button, ui->sort_reverse);
|
|
|
|
elm_object_focus_set(button, EINA_TRUE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
_btn_icon_state_set(button, EINA_FALSE);
|
|
|
|
|
2020-02-15 07:30:31 -08:00
|
|
|
evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2020-04-23 04:28:07 -07:00
|
|
|
elm_object_text_set(button, _("Size"));
|
2018-06-04 03:11:21 -07:00
|
|
|
evas_object_show(button);
|
|
|
|
elm_table_pack(table, button, 2, 0, 1, 1);
|
|
|
|
|
|
|
|
ui->btn_rss = button = elm_button_add(parent);
|
2020-04-14 10:24:27 -07:00
|
|
|
if (ui->sort_type == SORT_BY_RSS)
|
|
|
|
{
|
|
|
|
_btn_icon_state_set(button, ui->sort_reverse);
|
|
|
|
elm_object_focus_set(button, EINA_TRUE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
_btn_icon_state_set(button, EINA_FALSE);
|
|
|
|
|
2020-02-15 07:30:31 -08:00
|
|
|
evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2020-04-23 04:28:07 -07:00
|
|
|
elm_object_text_set(button, _("Res"));
|
2018-06-04 03:11:21 -07:00
|
|
|
evas_object_show(button);
|
|
|
|
elm_table_pack(table, button, 3, 0, 1, 1);
|
|
|
|
|
|
|
|
ui->btn_cmd = button = elm_button_add(parent);
|
2020-04-14 10:24:27 -07:00
|
|
|
if (ui->sort_type == SORT_BY_CMD)
|
|
|
|
{
|
|
|
|
_btn_icon_state_set(button, ui->sort_reverse);
|
|
|
|
elm_object_focus_set(button, EINA_TRUE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
_btn_icon_state_set(button, EINA_FALSE);
|
|
|
|
|
2020-02-15 07:30:31 -08:00
|
|
|
evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2020-04-23 04:28:07 -07:00
|
|
|
elm_object_text_set(button, _("Command"));
|
2018-06-04 03:11:21 -07:00
|
|
|
evas_object_show(button);
|
|
|
|
elm_table_pack(table, button, 4, 0, 1, 1);
|
|
|
|
|
|
|
|
ui->btn_state = button = elm_button_add(parent);
|
2020-04-14 10:24:27 -07:00
|
|
|
if (ui->sort_type == SORT_BY_STATE)
|
|
|
|
{
|
|
|
|
_btn_icon_state_set(button, ui->sort_reverse);
|
|
|
|
elm_object_focus_set(button, EINA_TRUE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
_btn_icon_state_set(button, EINA_FALSE);
|
|
|
|
|
2020-02-15 07:30:31 -08:00
|
|
|
evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2020-04-23 04:28:07 -07:00
|
|
|
elm_object_text_set(button, _("State"));
|
2018-06-04 03:11:21 -07:00
|
|
|
evas_object_show(button);
|
|
|
|
elm_table_pack(table, button, 5, 0, 1, 1);
|
|
|
|
|
|
|
|
ui->btn_cpu_usage = button = elm_button_add(parent);
|
2020-04-14 10:24:27 -07:00
|
|
|
if (ui->sort_type == SORT_BY_CPU_USAGE)
|
|
|
|
{
|
|
|
|
_btn_icon_state_set(button, ui->sort_reverse);
|
|
|
|
elm_object_focus_set(button, EINA_TRUE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
_btn_icon_state_set(button, EINA_FALSE);
|
|
|
|
|
2020-02-15 07:30:31 -08:00
|
|
|
evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2020-04-23 04:28:07 -07:00
|
|
|
elm_object_text_set(button, _("CPU %"));
|
2018-06-04 03:11:21 -07:00
|
|
|
evas_object_show(button);
|
|
|
|
elm_table_pack(table, button, 6, 0, 1, 1);
|
|
|
|
|
2020-04-16 06:50:53 -07:00
|
|
|
ui->scroller = ui->genlist_procs = plist = elm_genlist_add(parent);
|
2020-05-08 15:01:58 -07:00
|
|
|
elm_scroller_gravity_set(ui->scroller, 0.0, 1.0);
|
2020-04-14 10:24:27 -07:00
|
|
|
elm_object_focus_allow_set(plist, EINA_FALSE);
|
|
|
|
elm_genlist_homogeneous_set(plist, EINA_TRUE);
|
|
|
|
evas_object_size_hint_weight_set(plist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(plist, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
evas_object_show(plist);
|
|
|
|
|
2020-04-16 06:50:53 -07:00
|
|
|
elm_box_pack_end(box, table);
|
|
|
|
elm_box_pack_end(box, plist);
|
2018-06-04 03:11:21 -07:00
|
|
|
|
|
|
|
evas_object_smart_callback_add(ui->btn_pid, "clicked", _btn_pid_clicked_cb, ui);
|
|
|
|
evas_object_smart_callback_add(ui->btn_uid, "clicked", _btn_uid_clicked_cb, ui);
|
|
|
|
evas_object_smart_callback_add(ui->btn_size, "clicked", _btn_size_clicked_cb, ui);
|
|
|
|
evas_object_smart_callback_add(ui->btn_rss, "clicked", _btn_rss_clicked_cb, ui);
|
|
|
|
evas_object_smart_callback_add(ui->btn_cmd, "clicked", _btn_cmd_clicked_cb, ui);
|
|
|
|
evas_object_smart_callback_add(ui->btn_state, "clicked", _btn_state_clicked_cb, ui);
|
|
|
|
evas_object_smart_callback_add(ui->btn_cpu_usage, "clicked", _btn_cpu_usage_clicked_cb, ui);
|
2020-04-17 15:49:12 -07:00
|
|
|
evas_object_smart_callback_add(ui->genlist_procs, "selected", _item_pid_clicked_cb, ui);
|
2020-04-18 05:41:25 -07:00
|
|
|
evas_object_event_callback_add(ui->genlist_procs, EVAS_CALLBACK_MOUSE_UP,
|
|
|
|
_item_pid_secondary_clicked_cb, ui);
|
2020-04-17 18:07:12 -07:00
|
|
|
evas_object_smart_callback_add(ui->genlist_procs, "unrealized", _item_unrealized_cb, ui);
|
2018-06-04 03:11:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-05-12 16:51:30 -07:00
|
|
|
_tabs_hide(Ui *ui)
|
2020-04-22 12:22:10 -07:00
|
|
|
{
|
|
|
|
ui->mem_visible = EINA_FALSE;
|
|
|
|
ui->misc_visible = EINA_FALSE;
|
|
|
|
ui->disk_visible = EINA_FALSE;
|
|
|
|
ui->cpu_visible = EINA_FALSE;
|
|
|
|
|
|
|
|
evas_object_hide(ui->entry_search);
|
|
|
|
evas_object_hide(ui->system_activity);
|
|
|
|
evas_object_hide(ui->cpu_view);
|
|
|
|
evas_object_hide(ui->mem_view);
|
|
|
|
evas_object_hide(ui->disk_view);
|
|
|
|
evas_object_hide(ui->misc_view);
|
|
|
|
}
|
|
|
|
|
2020-05-08 19:06:05 -07:00
|
|
|
static void
|
|
|
|
_transit_del_cb(void *data, Elm_Transit *transit)
|
|
|
|
{
|
|
|
|
Ui *ui = data;
|
|
|
|
|
|
|
|
ui->transit = transit = NULL;
|
|
|
|
}
|
|
|
|
|
2019-06-08 15:39:15 -07:00
|
|
|
static void
|
2020-05-08 18:17:17 -07:00
|
|
|
_tab_state_changed(Ui *ui, Evas_Object *btn_active, Evas_Object *view)
|
2019-06-08 15:39:15 -07:00
|
|
|
{
|
2020-05-08 18:17:17 -07:00
|
|
|
Elm_Transit *transit;
|
2020-05-08 19:06:05 -07:00
|
|
|
|
|
|
|
if (ui->transit) return;
|
|
|
|
|
2019-06-08 15:39:15 -07:00
|
|
|
elm_object_disabled_set(ui->btn_general, EINA_FALSE);
|
|
|
|
elm_object_disabled_set(ui->btn_cpu, EINA_FALSE);
|
|
|
|
elm_object_disabled_set(ui->btn_mem, EINA_FALSE);
|
|
|
|
elm_object_disabled_set(ui->btn_storage, EINA_FALSE);
|
|
|
|
elm_object_disabled_set(ui->btn_misc, EINA_FALSE);
|
|
|
|
elm_object_disabled_set(btn_active, EINA_TRUE);
|
2020-05-08 18:17:17 -07:00
|
|
|
|
2020-04-22 12:22:10 -07:00
|
|
|
_tabs_hide(ui);
|
2020-05-11 14:46:04 -07:00
|
|
|
|
2020-05-08 18:17:17 -07:00
|
|
|
evas_object_show(view);
|
|
|
|
|
2020-05-08 19:06:05 -07:00
|
|
|
ui->transit = transit = elm_transit_add();
|
2020-05-08 18:17:17 -07:00
|
|
|
elm_transit_object_add(transit, ui->current_view);
|
|
|
|
elm_transit_object_add(transit, view);
|
|
|
|
elm_transit_duration_set(transit, 0.5);
|
|
|
|
elm_transit_effect_blend_add(transit);
|
2020-05-08 19:06:05 -07:00
|
|
|
elm_transit_del_cb_set(transit, _transit_del_cb, ui);
|
2020-05-08 18:17:17 -07:00
|
|
|
elm_transit_go(transit);
|
2020-05-11 14:46:04 -07:00
|
|
|
|
|
|
|
ui->current_view = view;
|
2019-06-08 15:39:15 -07:00
|
|
|
}
|
|
|
|
|
2018-06-11 03:12:02 -07:00
|
|
|
static void
|
|
|
|
_tab_memory_activity_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|
|
|
{
|
2020-05-11 14:46:04 -07:00
|
|
|
Ui *ui = data;
|
2018-06-11 03:12:02 -07:00
|
|
|
|
2020-05-08 18:17:17 -07:00
|
|
|
_tab_state_changed(ui, obj, ui->mem_view);
|
2019-06-08 15:39:15 -07:00
|
|
|
|
2020-04-22 12:22:10 -07:00
|
|
|
ui->mem_visible = EINA_TRUE;
|
2018-06-11 03:12:02 -07:00
|
|
|
}
|
2018-06-10 06:09:44 -07:00
|
|
|
|
2018-06-09 03:30:07 -07:00
|
|
|
static void
|
|
|
|
_tab_system_activity_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|
|
|
{
|
2020-05-11 14:46:04 -07:00
|
|
|
Ui *ui = data;
|
2018-06-09 03:30:07 -07:00
|
|
|
|
2020-05-08 18:17:17 -07:00
|
|
|
_tab_state_changed(ui, obj, ui->system_activity);
|
2019-06-08 15:39:15 -07:00
|
|
|
|
2020-02-15 09:12:02 -08:00
|
|
|
evas_object_show(ui->entry_search);
|
2018-06-09 03:30:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_tab_disk_activity_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|
|
|
{
|
2020-05-11 14:46:04 -07:00
|
|
|
Ui *ui = data;
|
2018-06-10 06:09:44 -07:00
|
|
|
|
2020-05-08 18:17:17 -07:00
|
|
|
_tab_state_changed(ui, obj, ui->disk_view);
|
2019-06-08 15:39:15 -07:00
|
|
|
|
2020-04-22 12:22:10 -07:00
|
|
|
ui->disk_visible = EINA_TRUE;
|
2018-06-10 06:09:44 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-06-08 15:39:15 -07:00
|
|
|
_tab_misc_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
2018-06-10 06:09:44 -07:00
|
|
|
{
|
2020-05-11 14:46:04 -07:00
|
|
|
Ui *ui = data;
|
2018-06-10 06:09:44 -07:00
|
|
|
|
2020-05-08 18:17:17 -07:00
|
|
|
_tab_state_changed(ui, obj, ui->misc_view);
|
2019-06-08 15:39:15 -07:00
|
|
|
|
2020-04-22 12:22:10 -07:00
|
|
|
ui->misc_visible = EINA_TRUE;
|
2018-06-11 03:12:02 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_tab_cpu_activity_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|
|
|
{
|
2020-05-11 14:46:04 -07:00
|
|
|
Ui *ui = data;
|
2018-06-11 03:12:02 -07:00
|
|
|
|
2020-05-08 18:17:17 -07:00
|
|
|
_tab_state_changed(ui, obj, ui->cpu_view);
|
2019-06-08 15:39:15 -07:00
|
|
|
|
2020-04-22 12:22:10 -07:00
|
|
|
ui->cpu_visible = EINA_TRUE;
|
2018-06-09 03:30:07 -07:00
|
|
|
}
|
|
|
|
|
2020-02-15 07:30:31 -08:00
|
|
|
static void
|
|
|
|
_evisum_process_filter(Ui *ui, const char *text)
|
|
|
|
{
|
|
|
|
if (ui->search_text)
|
|
|
|
free(ui->search_text);
|
|
|
|
|
|
|
|
ui->search_text = strdup(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_evisum_search_keypress_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
Ui * ui;
|
|
|
|
const char *markup;
|
|
|
|
char *text;
|
|
|
|
Evas_Object *entry;
|
|
|
|
Evas_Event_Key_Down *event;
|
|
|
|
|
|
|
|
event = event_info;
|
|
|
|
entry = obj;
|
|
|
|
ui = data;
|
|
|
|
|
|
|
|
if (!event) return;
|
2020-02-15 18:03:32 -08:00
|
|
|
|
2020-05-08 13:23:49 -07:00
|
|
|
ui->skip_wait = EINA_TRUE;
|
|
|
|
|
2020-02-15 07:30:31 -08:00
|
|
|
markup = elm_object_part_text_get(entry, NULL);
|
|
|
|
text = elm_entry_markup_to_utf8(markup);
|
|
|
|
if (text)
|
|
|
|
{
|
|
|
|
_evisum_process_filter(ui, text);
|
|
|
|
free(text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-09 03:30:07 -07:00
|
|
|
static Evas_Object *
|
|
|
|
_ui_tabs_add(Evas_Object *parent, Ui *ui)
|
|
|
|
{
|
2020-02-15 18:03:32 -08:00
|
|
|
Evas_Object *table, *box, *entry, *hbox, *frame, *button;
|
2019-09-01 07:18:30 -07:00
|
|
|
Evas_Object *border;
|
2018-06-09 03:30:07 -07:00
|
|
|
|
|
|
|
ui->content = table = elm_table_add(parent);
|
|
|
|
evas_object_size_hint_weight_set(table, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(table, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
elm_object_content_set(parent, table);
|
|
|
|
evas_object_show(table);
|
|
|
|
|
|
|
|
frame = elm_frame_add(parent);
|
|
|
|
evas_object_size_hint_weight_set(frame, EVAS_HINT_EXPAND, 0);
|
|
|
|
evas_object_size_hint_align_set(frame, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2020-04-23 04:28:07 -07:00
|
|
|
elm_object_text_set(frame, _("Options"));
|
2018-06-09 11:55:04 -07:00
|
|
|
elm_object_style_set(frame, "pad_medium");
|
2018-06-09 03:30:07 -07:00
|
|
|
evas_object_show(frame);
|
|
|
|
|
|
|
|
hbox = elm_box_add(parent);
|
|
|
|
evas_object_size_hint_weight_set(hbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(hbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
elm_box_horizontal_set(hbox, EINA_TRUE);
|
|
|
|
evas_object_show(hbox);
|
|
|
|
|
2019-09-01 07:18:30 -07:00
|
|
|
border = elm_frame_add(parent);
|
|
|
|
evas_object_size_hint_weight_set(border, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(border, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
elm_object_style_set(border, "pad_small");
|
2020-05-12 13:03:26 -07:00
|
|
|
elm_box_pack_end(hbox, border);
|
|
|
|
evas_object_show(border);
|
|
|
|
|
|
|
|
border = elm_frame_add(parent);
|
|
|
|
evas_object_size_hint_weight_set(border, 0, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(border, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
elm_object_style_set(border, "pad_small");
|
2019-09-01 07:18:30 -07:00
|
|
|
evas_object_show(border);
|
|
|
|
|
2019-06-08 15:39:15 -07:00
|
|
|
ui->btn_general = button = elm_button_add(hbox);
|
|
|
|
elm_object_disabled_set(ui->btn_general, EINA_TRUE);
|
2020-02-15 07:30:31 -08:00
|
|
|
evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
2018-06-09 03:30:07 -07:00
|
|
|
evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2019-08-24 08:28:56 -07:00
|
|
|
evas_object_size_hint_min_set(button, TAB_BTN_SIZE * elm_config_scale_get(), 0);
|
2020-04-23 08:28:52 -07:00
|
|
|
elm_object_text_set(button, _("General"));
|
2018-06-09 03:30:07 -07:00
|
|
|
evas_object_show(button);
|
2019-09-01 07:18:30 -07:00
|
|
|
elm_object_content_set(border, button);
|
|
|
|
elm_box_pack_end(hbox, border);
|
2018-06-09 03:30:07 -07:00
|
|
|
evas_object_smart_callback_add(button, "clicked", _tab_system_activity_clicked_cb, ui);
|
|
|
|
|
2019-09-01 07:18:30 -07:00
|
|
|
border = elm_frame_add(parent);
|
2020-05-12 13:03:26 -07:00
|
|
|
evas_object_size_hint_weight_set(border, 0, EVAS_HINT_EXPAND);
|
2019-09-01 07:18:30 -07:00
|
|
|
evas_object_size_hint_align_set(border, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
elm_object_style_set(border, "pad_small");
|
|
|
|
evas_object_show(border);
|
|
|
|
|
2019-06-08 15:39:15 -07:00
|
|
|
ui->btn_cpu = button = elm_button_add(hbox);
|
2020-02-15 07:30:31 -08:00
|
|
|
evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
2018-06-09 03:30:07 -07:00
|
|
|
evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2019-08-24 08:28:56 -07:00
|
|
|
evas_object_size_hint_min_set(button, TAB_BTN_SIZE * elm_config_scale_get(), 0);
|
2020-04-23 04:28:07 -07:00
|
|
|
elm_object_text_set(button, _("CPU"));
|
2019-09-01 07:18:30 -07:00
|
|
|
elm_object_content_set(border, button);
|
2018-06-11 03:12:02 -07:00
|
|
|
evas_object_show(button);
|
2019-09-01 07:18:30 -07:00
|
|
|
elm_box_pack_end(hbox, border);
|
2018-06-11 03:12:02 -07:00
|
|
|
evas_object_smart_callback_add(button, "clicked", _tab_cpu_activity_clicked_cb, ui);
|
|
|
|
|
2019-09-01 07:18:30 -07:00
|
|
|
border = elm_frame_add(parent);
|
2020-05-12 13:03:26 -07:00
|
|
|
evas_object_size_hint_weight_set(border, 0, EVAS_HINT_EXPAND);
|
2019-09-01 07:18:30 -07:00
|
|
|
evas_object_size_hint_align_set(border, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
elm_object_style_set(border, "pad_small");
|
|
|
|
evas_object_show(border);
|
|
|
|
|
2019-06-08 15:39:15 -07:00
|
|
|
ui->btn_mem = button = elm_button_add(hbox);
|
2020-02-15 07:30:31 -08:00
|
|
|
evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
2018-06-11 03:12:02 -07:00
|
|
|
evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2019-08-24 08:28:56 -07:00
|
|
|
evas_object_size_hint_min_set(button, TAB_BTN_SIZE * elm_config_scale_get(), 0);
|
2020-04-23 04:28:07 -07:00
|
|
|
elm_object_text_set(button, _("Memory"));
|
2018-06-11 03:12:02 -07:00
|
|
|
evas_object_show(button);
|
2019-09-01 07:18:30 -07:00
|
|
|
elm_object_content_set(border, button);
|
|
|
|
elm_box_pack_end(hbox, border);
|
2018-06-11 03:12:02 -07:00
|
|
|
evas_object_smart_callback_add(button, "clicked", _tab_memory_activity_clicked_cb, ui);
|
|
|
|
|
2019-09-01 07:18:30 -07:00
|
|
|
border = elm_frame_add(parent);
|
2020-05-12 13:03:26 -07:00
|
|
|
evas_object_size_hint_weight_set(border, 0, EVAS_HINT_EXPAND);
|
2019-09-01 07:18:30 -07:00
|
|
|
evas_object_size_hint_align_set(border, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
elm_object_style_set(border, "pad_small");
|
|
|
|
evas_object_show(border);
|
|
|
|
|
2019-06-08 15:39:15 -07:00
|
|
|
ui->btn_storage = button = elm_button_add(hbox);
|
2020-02-15 07:30:31 -08:00
|
|
|
evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
2018-06-11 03:12:02 -07:00
|
|
|
evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2019-08-24 08:28:56 -07:00
|
|
|
evas_object_size_hint_min_set(button, TAB_BTN_SIZE * elm_config_scale_get(), 0);
|
2020-04-23 04:28:07 -07:00
|
|
|
elm_object_text_set(button, _("Storage"));
|
2018-06-09 03:30:07 -07:00
|
|
|
evas_object_show(button);
|
2019-09-01 07:18:30 -07:00
|
|
|
elm_object_content_set(border, button);
|
|
|
|
elm_box_pack_end(hbox, border);
|
2018-06-09 03:30:07 -07:00
|
|
|
evas_object_smart_callback_add(button, "clicked", _tab_disk_activity_clicked_cb, ui);
|
|
|
|
|
2019-09-01 07:18:30 -07:00
|
|
|
border = elm_frame_add(parent);
|
2020-05-12 13:03:26 -07:00
|
|
|
evas_object_size_hint_weight_set(border, 0, EVAS_HINT_EXPAND);
|
2019-09-01 07:18:30 -07:00
|
|
|
evas_object_size_hint_align_set(border, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
elm_object_style_set(border, "pad_small");
|
|
|
|
evas_object_show(border);
|
|
|
|
|
2019-06-08 15:39:15 -07:00
|
|
|
ui->btn_misc = button = elm_button_add(hbox);
|
2020-02-15 07:30:31 -08:00
|
|
|
evas_object_size_hint_weight_set(button, EVAS_HINT_FILL, EVAS_HINT_EXPAND);
|
2018-06-10 06:09:44 -07:00
|
|
|
evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2019-08-24 08:28:56 -07:00
|
|
|
evas_object_size_hint_min_set(button, TAB_BTN_SIZE * elm_config_scale_get(), 0);
|
2020-04-23 04:28:07 -07:00
|
|
|
elm_object_text_set(button, _("Misc"));
|
2018-06-10 06:09:44 -07:00
|
|
|
evas_object_show(button);
|
2019-09-01 07:18:30 -07:00
|
|
|
elm_object_content_set(border, button);
|
|
|
|
elm_box_pack_end(hbox, border);
|
2019-06-08 15:39:15 -07:00
|
|
|
evas_object_smart_callback_add(button, "clicked", _tab_misc_clicked_cb, ui);
|
2018-06-10 06:09:44 -07:00
|
|
|
|
2020-05-12 13:03:26 -07:00
|
|
|
border = elm_frame_add(parent);
|
|
|
|
evas_object_size_hint_weight_set(border, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(border, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
elm_object_style_set(border, "pad_small");
|
|
|
|
elm_box_pack_end(hbox, border);
|
|
|
|
evas_object_show(border);
|
|
|
|
|
2018-06-09 03:30:07 -07:00
|
|
|
elm_object_content_set(frame, hbox);
|
|
|
|
elm_table_pack(ui->content, frame, 0, 0, 1, 1);
|
|
|
|
|
|
|
|
hbox = elm_box_add(parent);
|
2018-06-09 11:55:04 -07:00
|
|
|
evas_object_size_hint_weight_set(hbox, EVAS_HINT_EXPAND, 0);
|
|
|
|
evas_object_size_hint_align_set(hbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2018-06-09 03:30:07 -07:00
|
|
|
elm_box_horizontal_set(hbox, EINA_TRUE);
|
|
|
|
evas_object_show(hbox);
|
|
|
|
|
2020-02-15 07:30:31 -08:00
|
|
|
box = elm_box_add(parent);
|
|
|
|
evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, 0);
|
|
|
|
evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
elm_box_horizontal_set(box, EINA_TRUE);
|
|
|
|
evas_object_show(box);
|
2018-06-09 11:55:04 -07:00
|
|
|
|
2020-02-15 18:03:32 -08:00
|
|
|
frame = elm_frame_add(parent);
|
|
|
|
evas_object_size_hint_weight_set(frame, EVAS_HINT_EXPAND, 0);
|
|
|
|
evas_object_size_hint_align_set(frame, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
elm_object_style_set(frame, "pad_small");
|
|
|
|
evas_object_show(frame);
|
|
|
|
|
2019-09-01 07:18:30 -07:00
|
|
|
border = elm_frame_add(parent);
|
2020-02-15 18:03:32 -08:00
|
|
|
evas_object_size_hint_weight_set(border, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
2019-09-01 07:18:30 -07:00
|
|
|
evas_object_size_hint_align_set(border, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
elm_object_style_set(border, "pad_small");
|
|
|
|
evas_object_show(border);
|
|
|
|
|
2020-02-15 09:12:02 -08:00
|
|
|
ui->entry_search = entry = elm_entry_add(parent);
|
2020-02-15 18:03:32 -08:00
|
|
|
evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
2020-02-15 07:30:31 -08:00
|
|
|
evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
elm_entry_single_line_set(entry, EINA_TRUE);
|
|
|
|
elm_entry_scrollable_set(entry, EINA_TRUE);
|
|
|
|
elm_entry_editable_set(entry, EINA_TRUE);
|
|
|
|
evas_object_show(entry);
|
2020-02-15 18:03:32 -08:00
|
|
|
elm_object_content_set(border, entry);
|
|
|
|
elm_box_pack_end(box, border);
|
2020-02-15 07:30:31 -08:00
|
|
|
|
2020-02-15 18:03:32 -08:00
|
|
|
border = elm_frame_add(parent);
|
|
|
|
evas_object_size_hint_weight_set(border, 0.1, 0);
|
|
|
|
evas_object_size_hint_align_set(border, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
elm_object_style_set(border, "pad_small");
|
|
|
|
evas_object_show(border);
|
2020-02-15 07:30:31 -08:00
|
|
|
|
2018-06-09 03:30:07 -07:00
|
|
|
button = elm_button_add(parent);
|
2020-02-15 18:03:32 -08:00
|
|
|
evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
2018-06-09 03:30:07 -07:00
|
|
|
evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2020-04-23 04:28:07 -07:00
|
|
|
elm_object_text_set(button, _("Close"));
|
2020-02-15 18:03:32 -08:00
|
|
|
elm_object_content_set(border, button);
|
|
|
|
elm_box_pack_end(box, border);
|
2018-06-09 03:30:07 -07:00
|
|
|
evas_object_show(button);
|
|
|
|
evas_object_smart_callback_add(button, "clicked", _btn_quit_clicked_cb, ui);
|
|
|
|
|
2020-02-15 18:03:32 -08:00
|
|
|
elm_object_content_set(frame, box);
|
|
|
|
elm_box_pack_end(hbox, frame);
|
2018-06-09 03:30:07 -07:00
|
|
|
elm_table_pack(ui->content, hbox, 0, 2, 1, 1);
|
|
|
|
|
|
|
|
return table;
|
|
|
|
}
|
|
|
|
|
2018-10-02 06:56:25 -07:00
|
|
|
static void
|
|
|
|
_evisum_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
Evas_Event_Key_Down *ev;
|
|
|
|
Ui *ui;
|
2020-02-16 11:34:41 -08:00
|
|
|
Eina_Bool control;
|
2018-10-02 06:56:25 -07:00
|
|
|
|
|
|
|
ev = event_info;
|
|
|
|
ui = data;
|
|
|
|
|
|
|
|
if (!ev || !ev->keyname)
|
|
|
|
return;
|
|
|
|
|
2020-05-08 13:23:49 -07:00
|
|
|
ui->skip_wait = EINA_TRUE;
|
|
|
|
|
2020-02-16 11:34:41 -08:00
|
|
|
if (!strcmp(ev->keyname, "Escape"))
|
|
|
|
{
|
2020-04-22 09:14:23 -07:00
|
|
|
ecore_main_loop_quit();
|
2020-02-16 11:34:41 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-04-22 14:55:22 -07:00
|
|
|
control = evas_key_modifier_is_set(ev->modifiers, "Control");
|
2020-04-24 04:33:36 -07:00
|
|
|
if (!control) return;
|
2020-04-22 14:55:22 -07:00
|
|
|
|
2020-04-14 10:24:27 -07:00
|
|
|
if (ev->keyname[0] == 'e' || ev->keyname[0] == 'E')
|
|
|
|
ui->show_self = !ui->show_self;
|
|
|
|
|
|
|
|
_config_save(ui);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_evisum_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
|
|
|
{
|
|
|
|
Ui *ui = data;
|
|
|
|
|
2020-05-08 11:08:25 -07:00
|
|
|
elm_genlist_realized_items_update(ui->genlist_procs);
|
2020-04-18 04:39:57 -07:00
|
|
|
|
2020-04-18 12:56:04 -07:00
|
|
|
_config_save(ui);
|
2018-10-02 06:56:25 -07:00
|
|
|
}
|
|
|
|
|
2020-05-13 13:55:58 -07:00
|
|
|
const char *
|
|
|
|
evisum_size_format(unsigned long value)
|
|
|
|
{
|
|
|
|
const char *s;
|
|
|
|
double res = value;
|
|
|
|
|
|
|
|
if (value > (1024 * 1024 * 1024))
|
|
|
|
{
|
|
|
|
res /= (1024 * 1024 * 1024);
|
|
|
|
s = eina_slstr_printf("%1.1f %c", res, DATA_UNIT_GB);
|
|
|
|
}
|
|
|
|
else if (value > (1024 * 1024))
|
|
|
|
{
|
|
|
|
res /= (1024 * 1024);
|
|
|
|
s = eina_slstr_printf("%1.1f %c", res, DATA_UNIT_MB);
|
|
|
|
}
|
|
|
|
else if (value > (1024))
|
|
|
|
{
|
|
|
|
res /= (1024);
|
|
|
|
s = eina_slstr_printf("%1.1f %c", res, DATA_UNIT_KB);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
s = eina_slstr_printf("%1.0f %c", res, DATA_UNIT_B);
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
_path_append(const char *path, const char *file)
|
|
|
|
{
|
|
|
|
char *concat;
|
|
|
|
int len;
|
|
|
|
char separator = '/';
|
|
|
|
|
|
|
|
len = strlen(path) + strlen(file) + 2;
|
|
|
|
concat = malloc(len * sizeof(char));
|
|
|
|
snprintf(concat, len, "%s%c%s", path, separator, file);
|
|
|
|
|
|
|
|
return concat;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
evisum_icon_path_get(const char *name)
|
|
|
|
{
|
|
|
|
char *path;
|
|
|
|
const char *icon_path, *directory = PACKAGE_DATA_DIR "/images";
|
|
|
|
icon_path = name;
|
|
|
|
|
|
|
|
path = _path_append(directory, eina_slstr_printf("%s.png", name));
|
|
|
|
if (path)
|
|
|
|
{
|
|
|
|
if (ecore_file_exists(path))
|
|
|
|
icon_path = eina_slstr_printf("%s", path);
|
|
|
|
|
|
|
|
free(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
return icon_path;
|
|
|
|
}
|
|
|
|
|
2020-02-24 09:22:22 -08:00
|
|
|
void
|
2020-05-13 05:15:58 -07:00
|
|
|
evisum_ui_shutdown(Ui *ui)
|
2020-02-24 09:22:22 -08:00
|
|
|
{
|
|
|
|
evas_object_del(ui->win);
|
|
|
|
|
2020-04-22 09:14:23 -07:00
|
|
|
if (ui->timer_pid)
|
|
|
|
ecore_timer_del(ui->timer_pid);
|
2020-02-24 09:22:22 -08:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
_proc_pid_cpu_times_free(ui);
|
|
|
|
|
2020-04-21 03:54:17 -07:00
|
|
|
if (ui->cpu_list)
|
|
|
|
eina_list_free(ui->cpu_list);
|
|
|
|
|
2020-05-18 04:16:35 -07:00
|
|
|
evisum_ui_item_cache_free(ui->cache);
|
2020-04-17 20:11:03 -07:00
|
|
|
|
2020-02-24 09:22:22 -08:00
|
|
|
eina_lock_free(&_lock);
|
|
|
|
}
|
|
|
|
|
2020-05-14 10:37:28 -07:00
|
|
|
static void
|
|
|
|
_thread_end_cb(void *data EINA_UNUSED, Ecore_Thread *thread)
|
|
|
|
{
|
|
|
|
thread = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_thread_error_cb(void *data EINA_UNUSED, Ecore_Thread *thread)
|
|
|
|
{
|
|
|
|
thread = NULL;
|
|
|
|
}
|
|
|
|
|
2020-05-13 13:55:58 -07:00
|
|
|
static void
|
2020-05-14 06:43:44 -07:00
|
|
|
_sys_info_all_poll(void *data, Ecore_Thread *thread)
|
2020-05-13 13:55:58 -07:00
|
|
|
{
|
|
|
|
Ui *ui = data;
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
2020-05-14 06:43:44 -07:00
|
|
|
Sys_Info *sysinfo = sys_info_all_get();
|
|
|
|
if (!sysinfo)
|
2020-05-13 13:55:58 -07:00
|
|
|
{
|
|
|
|
ecore_main_loop_quit();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-05-14 06:43:44 -07:00
|
|
|
ecore_thread_feedback(thread, sysinfo);
|
2020-05-13 13:55:58 -07:00
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
if (ecore_thread_check(thread)) return;
|
|
|
|
|
|
|
|
if (ui->skip_wait)
|
|
|
|
{
|
|
|
|
ui->skip_wait = EINA_FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
usleep(250000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-05-14 06:43:44 -07:00
|
|
|
_sys_info_all_poll_feedback_cb(void *data, Ecore_Thread *thread, void *msg)
|
2020-05-13 13:55:58 -07:00
|
|
|
{
|
|
|
|
Ui *ui;
|
|
|
|
Evas_Object *progress;
|
2020-05-14 06:43:44 -07:00
|
|
|
Sys_Info *sysinfo;
|
2020-05-13 13:55:58 -07:00
|
|
|
double ratio, value, cpu_usage = 0.0;
|
|
|
|
|
|
|
|
ui = data;
|
2020-05-14 06:43:44 -07:00
|
|
|
sysinfo = msg;
|
2020-05-13 13:55:58 -07:00
|
|
|
|
|
|
|
if (ecore_thread_check(thread))
|
|
|
|
goto out;
|
|
|
|
|
2020-05-14 06:43:44 -07:00
|
|
|
ui_tab_cpu_update(ui, sysinfo);
|
|
|
|
ui_tab_memory_update(ui, sysinfo);
|
2020-05-13 13:55:58 -07:00
|
|
|
ui_tab_disk_update(ui);
|
2020-05-14 06:43:44 -07:00
|
|
|
ui_tab_misc_update(ui, sysinfo);
|
2020-05-13 13:55:58 -07:00
|
|
|
|
2020-05-14 06:43:44 -07:00
|
|
|
for (int i = 0; i < sysinfo->cpu_count; i++)
|
2020-05-13 13:55:58 -07:00
|
|
|
{
|
2020-05-14 06:43:44 -07:00
|
|
|
cpu_usage += sysinfo->cores[i]->percent;
|
|
|
|
free(sysinfo->cores[i]);
|
2020-05-13 13:55:58 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
cpu_usage = cpu_usage / system_cpu_online_count_get();
|
|
|
|
|
|
|
|
elm_progressbar_value_set(ui->progress_cpu, cpu_usage / 100);
|
|
|
|
|
|
|
|
progress = ui->progress_mem;
|
2020-05-14 06:43:44 -07:00
|
|
|
ratio = sysinfo->memory.total / 100.0;
|
|
|
|
value = sysinfo->memory.used / ratio;
|
2020-05-13 13:55:58 -07:00
|
|
|
elm_progressbar_value_set(progress, value / 100);
|
|
|
|
elm_progressbar_unit_format_set(progress, eina_slstr_printf("%s / %s",
|
2020-05-14 06:43:44 -07:00
|
|
|
evisum_size_format(sysinfo->memory.used << 10),
|
|
|
|
evisum_size_format(sysinfo->memory.total << 10)));
|
2020-05-13 13:55:58 -07:00
|
|
|
out:
|
2020-05-14 06:43:44 -07:00
|
|
|
free(sysinfo->cores);
|
|
|
|
free(sysinfo);
|
2020-05-13 13:55:58 -07:00
|
|
|
}
|
|
|
|
|
2020-02-19 07:04:21 -08:00
|
|
|
static void
|
|
|
|
_ui_launch(Ui *ui)
|
|
|
|
{
|
2020-04-14 10:24:27 -07:00
|
|
|
_process_list_update(ui);
|
2020-02-19 07:04:21 -08:00
|
|
|
|
2020-05-14 06:43:44 -07:00
|
|
|
ui->thread_system =
|
|
|
|
ecore_thread_feedback_run(_sys_info_all_poll, _sys_info_all_poll_feedback_cb,
|
|
|
|
_thread_end_cb, _thread_error_cb, ui, EINA_FALSE);
|
2020-02-19 07:04:21 -08:00
|
|
|
|
2020-05-14 06:43:44 -07:00
|
|
|
ui->thread_process =
|
|
|
|
ecore_thread_feedback_run(_process_list, _process_list_feedback_cb,
|
|
|
|
_thread_end_cb, _thread_error_cb, ui, EINA_FALSE);
|
2020-02-19 07:04:21 -08:00
|
|
|
|
2020-04-14 10:24:27 -07:00
|
|
|
evas_object_event_callback_add(ui->win, EVAS_CALLBACK_RESIZE, _evisum_resize_cb, ui);
|
2020-02-19 07:04:21 -08:00
|
|
|
evas_object_event_callback_add(ui->content, EVAS_CALLBACK_KEY_DOWN, _evisum_key_down_cb, ui);
|
|
|
|
evas_object_event_callback_add(ui->entry_search, EVAS_CALLBACK_KEY_DOWN, _evisum_search_keypress_cb, ui);
|
|
|
|
}
|
|
|
|
|
2020-02-16 07:57:26 -08:00
|
|
|
static Ui *
|
|
|
|
_ui_init(Evas_Object *parent)
|
2018-06-04 03:11:21 -07:00
|
|
|
{
|
2019-09-05 14:33:38 -07:00
|
|
|
Ui *ui = calloc(1, sizeof(Ui));
|
|
|
|
if (!ui) return NULL;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2020-02-19 07:04:21 -08:00
|
|
|
/* Settings */
|
2018-06-04 03:11:21 -07:00
|
|
|
ui->win = parent;
|
|
|
|
ui->poll_delay = 3;
|
|
|
|
ui->sort_reverse = EINA_FALSE;
|
|
|
|
ui->sort_type = SORT_BY_PID;
|
|
|
|
ui->selected_pid = -1;
|
|
|
|
ui->program_pid = getpid();
|
2020-05-14 06:43:44 -07:00
|
|
|
ui->disk_visible = ui->cpu_visible = EINA_TRUE;
|
|
|
|
ui->mem_visible = ui->misc_visible = EINA_TRUE;
|
2020-02-24 09:22:22 -08:00
|
|
|
ui->cpu_times = NULL;
|
2020-04-21 03:54:17 -07:00
|
|
|
ui->cpu_list = NULL;
|
2018-06-04 03:11:21 -07:00
|
|
|
|
2020-04-20 11:50:51 -07:00
|
|
|
_ui = NULL;
|
|
|
|
_evisum_config = NULL;
|
2020-04-20 11:42:35 -07:00
|
|
|
|
2020-04-15 05:57:50 -07:00
|
|
|
_config_load(ui);
|
2020-04-14 10:24:27 -07:00
|
|
|
|
2020-02-19 07:04:21 -08:00
|
|
|
/* UI content creation */
|
2018-06-09 11:55:04 -07:00
|
|
|
_ui_tabs_add(parent, ui);
|
2019-09-05 14:33:38 -07:00
|
|
|
_ui_tab_system_add(ui);
|
2020-05-12 16:51:30 -07:00
|
|
|
|
|
|
|
ui_tab_cpu_add(ui);
|
|
|
|
ui_tab_memory_add(ui);
|
|
|
|
ui_tab_disk_add(ui);
|
|
|
|
ui_tab_misc_add(ui);
|
2018-10-02 06:56:25 -07:00
|
|
|
|
2020-05-18 04:16:35 -07:00
|
|
|
ui->cache = evisum_ui_item_cache_new(ui->genlist_procs, _item_create, 50);
|
2020-04-14 10:24:27 -07:00
|
|
|
|
2020-02-19 07:04:21 -08:00
|
|
|
return ui;
|
|
|
|
}
|
2018-06-09 03:30:07 -07:00
|
|
|
|
2020-02-19 07:04:21 -08:00
|
|
|
Ui *
|
2020-05-13 05:15:58 -07:00
|
|
|
evisum_ui_add(Evas_Object *parent)
|
2020-02-19 07:04:21 -08:00
|
|
|
{
|
|
|
|
eina_lock_new(&_lock);
|
2020-02-15 18:03:32 -08:00
|
|
|
|
2020-02-19 07:04:21 -08:00
|
|
|
/* Create our user interface. */
|
2020-04-14 10:24:27 -07:00
|
|
|
Ui *ui = _ui = _ui_init(parent);
|
2020-02-19 07:04:21 -08:00
|
|
|
if (!ui) return NULL;
|
2019-09-05 14:33:38 -07:00
|
|
|
|
2020-02-19 07:04:21 -08:00
|
|
|
/* Start polling our data */
|
|
|
|
_ui_launch(ui);
|
2018-06-16 13:31:49 -07:00
|
|
|
|
|
|
|
return ui;
|
2018-06-04 03:11:21 -07:00
|
|
|
}
|
|
|
|
|