|
|
|
#include "config.h"
|
|
|
|
#include "evisum_config.h"
|
|
|
|
|
|
|
|
#include "ui.h"
|
|
|
|
#include "ui/ui_process_list.h"
|
|
|
|
#include "ui/ui_process_view.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/resource.h>
|
|
|
|
#include <pwd.h>
|
|
|
|
|
|
|
|
#define PROGRESS_CUSTOM_FORMAT 0
|
|
|
|
#define DIRTY_GENLIST_HACK 1
|
|
|
|
|
|
|
|
extern int EVISUM_EVENT_CONFIG_CHANGED;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
Sort_Type type;
|
|
|
|
int (*sort_cb)(const void *p1, const void *p2);
|
|
|
|
} Sorter;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
Ecore_Thread *thread;
|
|
|
|
Evisum_Ui_Cache *cache;
|
|
|
|
Ecore_Event_Handler *handler[2];
|
|
|
|
Eina_Bool skip_wait;
|
|
|
|
|
|
|
|
Sorter sorters[SORT_BY_MAX];
|
|
|
|
Eina_Hash *cpu_times;
|
|
|
|
|
|
|
|
Ui *ui;
|
|
|
|
|
|
|
|
Ecore_Timer *resize_timer;
|
|
|
|
|
|
|
|
Evas_Object *win;
|
|
|
|
Evas_Object *main_menu;
|
|
|
|
Evas_Object *menu;
|
|
|
|
|
|
|
|
pid_t selected_pid;
|
|
|
|
char search[16];
|
|
|
|
int search_len;
|
|
|
|
|
|
|
|
Ecore_Timer *timer_search;
|
|
|
|
Evas_Object *entry_pop;
|
|
|
|
Evas_Object *entry;
|
|
|
|
Eina_Bool entry_visible;
|
|
|
|
|
|
|
|
Evas_Object *scroller;
|
|
|
|
Evas_Object *genlist;
|
|
|
|
Elm_Genlist_Item_Class itc;
|
|
|
|
|
|
|
|
Evas_Object *btn_menu;
|
|
|
|
|
|
|
|
Evas_Object *btn_pid;
|
|
|
|
Evas_Object *btn_uid;
|
|
|
|
Evas_Object *btn_cmd;
|
|
|
|
Evas_Object *btn_pri;
|
|
|
|
Evas_Object *btn_nice;
|
|
|
|
Evas_Object *btn_size;
|
|
|
|
Evas_Object *btn_rss;
|
|
|
|
Evas_Object *btn_state;
|
|
|
|
Evas_Object *btn_threads;
|
|
|
|
Evas_Object *btn_cpu_n;
|
|
|
|
Evas_Object *btn_cpu_usage;
|
|
|
|
} Ui_Data;
|
|
|
|
|
|
|
|
#define PAD_W 2
|
|
|
|
|
|
|
|
static Ui_Data *_pd = NULL;
|
|
|
|
|
|
|
|
#if PROGRESS_CUSTOM_FORMAT
|
|
|
|
|
|
|
|
static double _cpu_usage = 0.0;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static int
|
|
|
|
_sort_by_pid(const void *p1, const void *p2)
|
|
|
|
{
|
|
|
|
const Proc_Info *inf1, *inf2;
|
|
|
|
|
|
|
|
inf1 = p1; inf2 = p2;
|
|
|
|
|
|
|
|
return inf1->pid - inf2->pid;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_sort_by_uid(const void *p1, const void *p2)
|
|
|
|
{
|
|
|
|
const Proc_Info *inf1, *inf2;
|
|
|
|
|
|
|
|
inf1 = p1; inf2 = p2;
|
|
|
|
|
|
|
|
return inf1->uid - inf2->uid;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_sort_by_nice(const void *p1, const void *p2)
|
|
|
|
{
|
|
|
|
const Proc_Info *inf1, *inf2;
|
|
|
|
|
|
|
|
inf1 = p1; inf2 = p2;
|
|
|
|
|
|
|
|
return inf1->nice - inf2->nice;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_sort_by_pri(const void *p1, const void *p2)
|
|
|
|
{
|
|
|
|
const Proc_Info *inf1, *inf2;
|
|
|
|
|
|
|
|
inf1 = p1; inf2 = p2;
|
|
|
|
|
|
|
|
return inf1->priority - inf2->priority;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_sort_by_cpu(const void *p1, const void *p2)
|
|
|
|
{
|
|
|
|
const Proc_Info *inf1, *inf2;
|
|
|
|
|
|
|
|
inf1 = p1; inf2 = p2;
|
|
|
|
|
|
|
|
return inf1->cpu_id - inf2->cpu_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_sort_by_threads(const void *p1, const void *p2)
|
|
|
|
{
|
|
|
|
const Proc_Info *inf1, *inf2;
|
|
|
|
|
|
|
|
inf1 = p1; inf2 = p2;
|
|
|
|
|
|
|
|
return inf1->numthreads - inf2->numthreads;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_sort_by_size(const void *p1, const void *p2)
|
|
|
|
{
|
|
|
|
const Proc_Info *inf1, *inf2;
|
|
|
|
int64_t size1, size2;
|
|
|
|
|
|
|
|
inf1 = p1; inf2 = p2;
|
|
|
|
|
|
|
|
size1 = inf1->mem_size;
|
|
|
|
size2 = inf2->mem_size;
|
|
|
|
|
|
|
|
if (size1 > size2)
|
|
|
|
return 1;
|
|
|
|
if (size1 < size2)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_sort_by_rss(const void *p1, const void *p2)
|
|
|
|
{
|
|
|
|
const Proc_Info *inf1, *inf2;
|
|
|
|
int64_t size1, size2;
|
|
|
|
|
|
|
|
inf1 = p1; inf2 = p2;
|
|
|
|
|
|
|
|
size1 = inf1->mem_rss;
|
|
|
|
size2 = inf2->mem_rss;
|
|
|
|
|
|
|
|
if (size1 > size2)
|
|
|
|
return 1;
|
|
|
|
if (size1 < size2)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_sort_by_cpu_usage(const void *p1, const void *p2)
|
|
|
|
{
|
|
|
|
const Proc_Info *inf1, *inf2;
|
|
|
|
double one, two;
|
|
|
|
|
|
|
|
inf1 = p1; inf2 = p2;
|
|
|
|
|
|
|
|
one = inf1->cpu_usage;
|
|
|
|
two = inf2->cpu_usage;
|
|
|
|
|
|
|
|
if (one > two)
|
|
|
|
return 1;
|
|
|
|
else if (one < two)
|
|
|
|
return -1;
|
|
|
|
else return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_sort_by_cmd(const void *p1, const void *p2)
|
|
|
|
{
|
|
|
|
const Proc_Info *inf1, *inf2;
|
|
|
|
|
|
|
|
inf1 = p1; inf2 = p2;
|
|
|
|
|
|
|
|
return strcasecmp(inf1->command, inf2->command);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_sort_by_state(const void *p1, const void *p2)
|
|
|
|
{
|
|
|
|
const Proc_Info *inf1, *inf2;
|
|
|
|
|
|
|
|
inf1 = p1; inf2 = p2;
|
|
|
|
|
|
|
|
return strcmp(inf1->state, inf2->state);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_item_unrealized_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Evas_Object *o;
|
|
|
|
Ui_Data *pd;
|
|
|
|
Eina_List *contents = NULL;
|
|
|
|
|
|
|
|
pd = data;
|
|
|
|
|
|
|
|
elm_genlist_item_all_contents_unset(event_info, &contents);
|
|
|
|
|
|
|
|
EINA_LIST_FREE(contents, o)
|
|
|
|
{
|
|
|
|
if (!evisum_ui_item_cache_item_release(pd->cache, o))
|
|
|
|
{
|
|
|
|
evas_object_del(o);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_item_del(void *data, Evas_Object *obj EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Proc_Info *proc = data;
|
|
|
|
proc_info_free(proc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
|
|
|
_item_column_add(Evas_Object *tbl, const char *text, int col)
|
|
|
|
{
|
|
|
|
Evas_Object *rec, *lb;
|
|
|
|
|
|
|
|
lb = elm_label_add(tbl);
|
|
|
|
evas_object_data_set(tbl, text, lb);
|
|
|
|
evas_object_size_hint_align_set(lb, FILL, FILL);
|
|
|
|
evas_object_size_hint_weight_set(lb, EXPAND, EXPAND);
|
|
|
|
evas_object_show(lb);
|
|
|
|
|
|
|
|
rec = evas_object_rectangle_add(tbl);
|
|
|
|
evas_object_data_set(lb, "rec", rec);
|
|
|
|
|
|
|
|
elm_table_pack(tbl, rec, col, 0, 1, 1);
|
|
|
|
elm_table_pack(tbl, lb, col, 0, 1, 1);
|
|
|
|
|
|
|
|
return lb;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if PROGRESS_CUSTOM_FORMAT
|
|
|
|
static char *
|
|
|
|
_pb_format_cb(double val)
|
|
|
|
{
|
|
|
|
static char buf[32];
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%1.1f %%", _cpu_usage);
|
|
|
|
|
|
|
|
return strdup(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_pb_format_free_cb(char *str)
|
|
|
|
{
|
|
|
|
free(str);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static Evas_Object *
|
|
|
|
_item_create(Evas_Object *parent)
|
|
|
|
{
|
|
|
|
Evas_Object *obj, *tbl, *lb, *ic, *rec;
|
|
|
|
Evas_Object *hbx, *pb;
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
obj = parent;
|
|
|
|
|
|
|
|
tbl = elm_table_add(obj);
|
|
|
|
evas_object_size_hint_align_set(tbl, FILL, 0);
|
|
|
|
evas_object_size_hint_weight_set(tbl, EXPAND, EXPAND);
|
|
|
|
|
|
|
|
hbx = elm_box_add(tbl);
|
|
|
|
elm_box_horizontal_set(hbx, 1);
|
|
|
|
evas_object_size_hint_align_set(hbx, 0.0, FILL);
|
|
|
|
evas_object_size_hint_weight_set(hbx, EXPAND, EXPAND);
|
|
|
|
evas_object_show(hbx);
|
|
|
|
|
|
|
|
ic = elm_icon_add(tbl);
|
|
|
|
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
|
|
|
|
evas_object_size_hint_align_set(ic, FILL, FILL);
|
|
|
|
evas_object_size_hint_min_set(ic, ELM_SCALE_SIZE(16), ELM_SCALE_SIZE(16));
|
|
|
|
evas_object_size_hint_max_set(ic, ELM_SCALE_SIZE(16), ELM_SCALE_SIZE(16));
|
|
|
|
evas_object_show(ic);
|
|
|
|
evas_object_data_set(tbl, "icon", ic);
|
|
|
|
elm_box_pack_end(hbx, ic);
|
|
|
|
elm_table_pack(tbl, hbx, i, 0, 1, 1);
|
|
|
|
|
|
|
|
rec = evas_object_rectangle_add(tbl);
|
|
|
|
evas_object_size_hint_min_set(rec, 6, 1);
|
|
|
|
elm_box_pack_end(hbx, rec);
|
|
|
|
|
|
|
|
rec = evas_object_rectangle_add(tbl);
|
|
|
|
evas_object_data_set(ic, "rec", rec);
|
|
|
|
elm_table_pack(tbl, rec, i++, 0, 1, 1);
|
|
|
|
|
|
|
|
lb = elm_label_add(tbl);
|
|
|
|
evas_object_size_hint_weight_set(lb, 0, EXPAND);
|
|
|
|
evas_object_data_set(tbl, "proc_cmd", lb);
|
|
|
|
evas_object_data_set(lb, "hbx", hbx);
|
|
|
|
evas_object_show(lb);
|
|
|
|
elm_box_pack_end(hbx, lb);
|
|
|
|
|
|
|
|
rec = evas_object_rectangle_add(tbl);
|
|
|
|
evas_object_size_hint_min_set(rec, 4, 1);
|
|
|
|
elm_box_pack_end(hbx, rec);
|
|
|
|
|
|
|
|
lb = _item_column_add(tbl, "proc_pid", i++);
|
|
|
|
evas_object_size_hint_align_set(lb, 0.0, FILL);
|
|
|
|
lb = _item_column_add(tbl, "proc_prio", i++);
|
|
|
|
evas_object_size_hint_align_set(lb, 1.0, FILL);
|
|
|
|
lb = _item_column_add(tbl, "proc_nice", i++);
|
|
|
|
evas_object_size_hint_align_set(lb, 1.0, FILL);
|
|
|
|
lb =_item_column_add(tbl, "proc_uid", i++);
|
|
|
|
evas_object_size_hint_align_set(lb, 1.0, FILL);
|
|
|
|
lb = _item_column_add(tbl, "proc_size", i++);
|
|
|
|
evas_object_size_hint_align_set(lb, 1.0, FILL);
|
|
|
|
lb = _item_column_add(tbl, "proc_rss", i++);
|
|
|
|
evas_object_size_hint_align_set(lb, 1.0, FILL);
|
|
|
|
lb = _item_column_add(tbl, "proc_threads", i++);
|
|
|
|
evas_object_size_hint_align_set(lb, 1.0, FILL);
|
|
|
|
lb = _item_column_add(tbl, "proc_cpuid", i++);
|
|
|
|
evas_object_size_hint_align_set(lb, 1.0, FILL);
|
|
|
|
lb = _item_column_add(tbl, "proc_state", i++);
|
|
|
|
evas_object_size_hint_align_set(lb, 0.5, FILL);
|
|
|
|
|
|
|
|
pb = elm_progressbar_add(hbx);
|
|
|
|
evas_object_size_hint_weight_set(pb, EXPAND, EXPAND);
|
|
|
|
evas_object_size_hint_align_set(pb, FILL, FILL);
|
|
|
|
elm_progressbar_unit_format_set(pb, "%1.1f %%");
|
|
|
|
#if PROGRESS_CUSTOM_FORMAT
|
|
|
|
elm_progressbar_unit_format_function_set(pb, _pb_format_cb, _pb_format_free_cb);
|
|
|
|
#endif
|
|
|
|
elm_table_pack(tbl, pb, i++, 0, 1, 1);
|
|
|
|
evas_object_data_set(tbl, "proc_cpu_usage", pb);
|
|
|
|
|
|
|
|
return tbl;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
|
|
|
_content_get(void *data, Evas_Object *obj, const char *source)
|
|
|
|
{
|
|
|
|
Proc_Info *proc;
|
|
|
|
struct passwd *pwd_entry;
|
|
|
|
Evas_Object *rec, *lb, *o, *hbx, *pb;
|
|
|
|
char buf[128];
|
|
|
|
Evas_Coord w, ow;
|
|
|
|
Ui_Data *pd = _pd;
|
|
|
|
|
|
|
|
proc = (void *) data;
|
|
|
|
|
|
|
|
if (strcmp(source, "elm.swallow.content")) return NULL;
|
|
|
|
if (!proc) return NULL;
|
|
|
|
|
|
|
|
Item_Cache *it = evisum_ui_item_cache_item_get(pd->cache);
|
|
|
|
if (!it)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Error: Object cache creation failed.\n");
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
evas_object_geometry_get(pd->btn_pid, NULL, NULL, &w, NULL);
|
|
|
|
lb = evas_object_data_get(it->obj, "proc_pid");
|
|
|
|
snprintf(buf, sizeof(buf), "%d", proc->pid);
|
|
|
|
if (strcmp(buf, elm_object_text_get(lb)))
|
|
|
|
{
|
|
|
|
elm_object_text_set(lb, buf);
|
|
|
|
evas_object_geometry_get(lb, NULL, NULL, &ow, NULL);
|
|
|
|
if (ow > w)
|
|
|
|
{
|
|
|
|
evas_object_size_hint_min_set(pd->btn_pid, w, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rec = evas_object_data_get(lb, "rec");
|
|
|
|
evas_object_size_hint_min_set(rec, w, 1);
|
|
|
|
evas_object_show(lb);
|
|
|
|
|
|
|
|
evas_object_geometry_get(pd->btn_pri, NULL, NULL, &w, NULL);
|
|
|
|
lb = evas_object_data_get(it->obj, "proc_prio");
|
|
|
|
snprintf(buf, sizeof(buf), "%d", proc->priority);
|
|
|
|
if (strcmp(buf, elm_object_text_get(lb)))
|
|
|
|
elm_object_text_set(lb, buf);
|
|
|
|
rec = evas_object_data_get(lb, "rec");
|
|
|
|
evas_object_size_hint_min_set(rec, w, 1);
|
|
|
|
evas_object_show(lb);
|
|
|
|
|
|
|
|
evas_object_geometry_get(pd->btn_nice, NULL, NULL, &w, NULL);
|
|
|
|
lb = evas_object_data_get(it->obj, "proc_nice");
|
|
|
|
snprintf(buf, sizeof(buf), "%d", proc->nice);
|
|
|
|
if (strcmp(buf, elm_object_text_get(lb)))
|
|
|
|
elm_object_text_set(lb, buf);
|
|
|
|
rec = evas_object_data_get(lb, "rec");
|
|
|
|
evas_object_size_hint_min_set(rec, w, 1);
|
|
|
|
evas_object_show(lb);
|
|
|
|
|
|
|
|
evas_object_geometry_get(pd->btn_uid, NULL, NULL, &w, NULL);
|
|
|
|
w += PAD_W;
|
|
|
|
lb = evas_object_data_get(it->obj, "proc_uid");
|
|
|
|
pwd_entry = getpwuid(proc->uid);
|
|
|
|
if (pwd_entry)
|
|
|
|
snprintf(buf, sizeof(buf), "%s", pwd_entry->pw_name);
|
|
|
|
else
|
|
|
|
snprintf(buf, sizeof(buf), "%i", proc->uid);
|
|
|
|
if (strcmp(buf, elm_object_text_get(lb)))
|
|
|
|
{
|
|
|
|
elm_object_text_set(lb, buf);
|
|
|
|
evas_object_geometry_get(lb, NULL, NULL, &ow, NULL);
|
|
|
|
if (ow > w)
|
|
|
|
{
|
|
|
|
evas_object_size_hint_min_set(pd->btn_uid, w, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rec = evas_object_data_get(lb, "rec");
|
|
|
|
evas_object_size_hint_min_set(rec, w, 1);
|
|
|
|
evas_object_show(lb);
|
|
|
|
|
|
|
|
evas_object_geometry_get(pd->btn_size, NULL, NULL, &w, NULL);
|
|
|
|
w += PAD_W;
|
|
|
|
lb = evas_object_data_get(it->obj, "proc_size");
|
|
|
|
snprintf(buf, sizeof(buf), "%s", evisum_size_format(proc->mem_size));
|
|
|
|
if (strcmp(buf, elm_object_text_get(lb)))
|
|
|
|
{
|
|
|
|
elm_object_text_set(lb, buf);
|
|
|
|
evas_object_geometry_get(lb, NULL, NULL, &ow, NULL);
|
|
|
|
if (ow > w)
|
|
|
|
{
|
|
|
|
evas_object_size_hint_min_set(pd->btn_size, w, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rec = evas_object_data_get(lb, "rec");
|
|
|
|
evas_object_size_hint_min_set(rec, w, 1);
|
|
|
|
evas_object_show(lb);
|
|
|
|
|
|
|
|
evas_object_geometry_get(pd->btn_rss, NULL, NULL, &w, NULL);
|
|
|
|
w += PAD_W;
|
|
|
|
lb = evas_object_data_get(it->obj, "proc_rss");
|
|
|
|
snprintf(buf, sizeof(buf), "%s", evisum_size_format(proc->mem_rss));
|
|
|
|
if (strcmp(buf, elm_object_text_get(lb)))
|
|
|
|
{
|
|
|
|
elm_object_text_set(lb, buf);
|
|
|
|
evas_object_geometry_get(lb, NULL, NULL, &ow, NULL);
|
|
|
|
if (ow > w)
|
|
|
|
{
|
|
|
|
evas_object_size_hint_min_set(pd->btn_rss, w, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rec = evas_object_data_get(lb, "rec");
|
|
|
|
evas_object_size_hint_min_set(rec, w, 1);
|
|
|
|
evas_object_show(lb);
|
|
|
|
|
|
|
|
evas_object_geometry_get(pd->btn_menu, NULL, NULL, &ow, NULL);
|
|
|
|
evas_object_geometry_get(pd->btn_cmd, NULL, NULL, &w, NULL);
|
|
|
|
w += ow;
|
|
|
|
lb = evas_object_data_get(it->obj, "proc_cmd");
|
|
|
|
snprintf(buf, sizeof(buf), "%s", proc->command);
|
|
|
|
if (strcmp(buf, elm_object_text_get(lb)))
|
|
|
|
elm_object_text_set(lb, buf);
|
|
|
|
hbx = evas_object_data_get(lb, "hbx");
|
|
|
|
evas_object_geometry_get(hbx, NULL, NULL, &ow, NULL);
|
|
|
|
if (ow > w)
|
|
|
|
{
|
|
|
|
evas_object_size_hint_min_set(pd->btn_cmd, w, 1);
|
|
|
|
}
|
|
|
|
rec = evas_object_data_get(lb, "rec");
|
|
|
|
evas_object_size_hint_min_set(rec, w, 1);
|
|
|
|
evas_object_show(lb);
|
|
|
|
elm_box_recalculate(hbx);
|
|
|
|
|
|
|
|
o = evas_object_data_get(it->obj, "icon");
|
|
|
|
const char *new = evisum_icon_path_get(evisum_icon_cache_find(proc));
|
|
|
|
const char *old = NULL;
|
|
|
|
elm_image_file_get(o, &old, NULL);
|
|
|
|
if (!old || strcmp(old, new))
|
|
|
|
elm_icon_standard_set(o, new);
|
|
|
|
rec = evas_object_data_get(o, "rec");
|
|
|
|
evas_object_size_hint_min_set(rec, w, 1);
|
|
|
|
evas_object_show(o);
|
|
|
|
|
|
|
|
evas_object_geometry_get(pd->btn_cpu_n, NULL, NULL, &w, NULL);
|
|
|
|
lb = evas_object_data_get(it->obj, "proc_cpuid");
|
|
|
|
snprintf(buf, sizeof(buf), "%d", proc->cpu_id);
|
|
|
|
if (strcmp(buf, elm_object_text_get(lb)))
|
|
|
|
elm_object_text_set(lb, buf);
|
|
|
|
rec = evas_object_data_get(lb, "rec");
|
|
|
|
evas_object_size_hint_min_set(rec, w, 1);
|
|
|
|
evas_object_show(lb);
|
|
|
|
|
|
|
|
evas_object_geometry_get(pd->btn_threads, NULL, NULL, &w, NULL);
|
|
|
|
lb = evas_object_data_get(it->obj, "proc_threads");
|
|
|
|
snprintf(buf, sizeof(buf), "%d", proc->numthreads);
|
|
|
|
if (strcmp(buf, elm_object_text_get(lb)))
|
|
|
|
elm_object_text_set(lb, buf);
|
|
|
|
rec = evas_object_data_get(lb, "rec");
|
|
|
|
evas_object_size_hint_min_set(rec, w, 1);
|
|
|
|
evas_object_show(lb);
|
|
|
|
|
|
|
|
evas_object_geometry_get(pd->btn_state, NULL, NULL, &w, NULL);
|
|
|
|
lb = evas_object_data_get(it->obj, "proc_state");
|
|
|
|
snprintf(buf, sizeof(buf), "%s", proc->state);
|
|
|
|
if (strcmp(buf, elm_object_text_get(lb)))
|
|
|
|
elm_object_text_set(lb, buf);
|
|
|
|
rec = evas_object_data_get(lb, "rec");
|
|
|
|
evas_object_size_hint_min_set(rec, w, 1);
|
|
|
|
evas_object_show(lb);
|
|
|
|
|
|
|
|
pb = evas_object_data_get(it->obj, "proc_cpu_usage");
|
|
|
|
#if PROGRESS_CUSTOM_FORMAT
|
|
|
|
_cpu_usage = proc->cpu_usage;
|
|
|
|
#endif
|
|
|
|
double value = proc->cpu_usage / 100.0;
|
|
|
|
double last = elm_progressbar_value_get(pb);
|
|
|
|
if (!EINA_DBL_EQ(value, last))
|
|
|
|
elm_progressbar_value_set(pb, proc->cpu_usage / 100.0);
|
|
|
|
evas_object_show(pb);
|
|
|
|
|
|
|
|
return it->obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_genlist_ensure_n_items(Evas_Object *genlist, unsigned int items,
|
|
|
|
Elm_Genlist_Item_Class *itc)
|
|
|
|
{
|
|
|
|
Elm_Object_Item *it;
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
elm_object_item_del(it);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (items == existing) return;
|
|
|
|
|
|
|
|
for (i = existing; i < items; i++)
|
|
|
|
{
|
|
|
|
elm_genlist_item_append(genlist, itc, NULL, NULL,
|
|
|
|
ELM_GENLIST_ITEM_NONE, NULL, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_show_items(void *data)
|
|
|
|
{
|
|
|
|
Ui_Data *pd = data;
|
|
|
|
|
|
|
|
evas_object_show(pd->genlist);
|
|
|
|
elm_genlist_realized_items_update(pd->genlist);
|
|
|
|
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_bring_in(void *data)
|
|
|
|
{
|
|
|
|
Ui_Data *pd;
|
|
|
|
int h_page, v_page;
|
|
|
|
|
|
|
|
pd = data;
|
|
|
|
elm_scroller_gravity_set(pd->scroller, 0.0, 0.0);
|
|
|
|
elm_scroller_last_page_get(pd->scroller, &h_page, &v_page);
|
|
|
|
elm_scroller_page_bring_in(pd->scroller, h_page, v_page);
|
|
|
|
|
|
|
|
ecore_timer_add(2.0, _show_items, pd);
|
|
|
|
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_process_list_cancel_cb(void *data, Ecore_Thread *thread)
|
|
|
|
{
|
|
|
|
Ui_Data *pd = data;
|
|
|
|
|
|
|
|
(void) pd;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_List *
|
|
|
|
_process_list_sort(Eina_List *list, Ui_Data *pd)
|
|
|
|
{
|
|
|
|
Ui *ui;
|
|
|
|
Sorter s;
|
|
|
|
ui = pd->ui;
|
|
|
|
|
|
|
|
s = pd->sorters[ui->proc.sort_type];
|
|
|
|
|
|
|
|
list = eina_list_sort(list, eina_list_count(list), s.sort_cb);
|
|
|
|
|
|
|
|
if (ui->proc.sort_reverse)
|
|
|
|
list = eina_list_reverse(list);
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_List *
|
|
|
|
_process_list_uid_trim(Eina_List *list, uid_t uid)
|
|
|
|
{
|
|
|
|
Proc_Info *proc;
|
|
|
|
Eina_List *l, *l_next;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH_SAFE(list, l, l_next, proc)
|
|
|
|
{
|
|
|
|
if (proc->uid != uid)
|
|
|
|
{
|
|
|
|
proc_info_free(proc);
|
|
|
|
list = eina_list_remove_list(list, l);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_cpu_times_free_cb(void *data)
|
|
|
|
{
|
|
|
|
int64_t *cpu_time = data;
|
|
|
|
free(cpu_time);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_List *
|
|
|
|
_process_list_search_trim(Eina_List *list, Ui_Data *pd)
|
|
|
|
{
|
|
|
|
Ui *ui;
|
|
|
|
Eina_List *l, *l_next;
|
|
|
|
Proc_Info *proc;
|
|
|
|
int64_t id;
|
|
|
|
|
|
|
|
ui = pd->ui;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH_SAFE(list, l, l_next, proc)
|
|
|
|
{
|
|
|
|
if ((pd->search_len && (strncasecmp(proc->command, pd->search, pd->search_len))) ||
|
|
|
|
(proc->pid == ui->program_pid))
|
|
|
|
{
|
|
|
|
proc_info_free(proc);
|
|
|
|
list = eina_list_remove_list(list, l);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int64_t *cpu_time;
|
|
|
|
|
|
|
|
id = proc->pid;
|
|
|
|
if (!(cpu_time = eina_hash_find(pd->cpu_times, &id)))
|
|
|
|
{
|
|
|
|
cpu_time = malloc(sizeof(int64_t));
|
|
|
|
*cpu_time = proc->cpu_time;
|
|
|
|
eina_hash_add(pd->cpu_times, &id, cpu_time);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (*cpu_time)
|
|
|
|
proc->cpu_usage = (double) (proc->cpu_time - *cpu_time) /
|
|
|
|
pd->ui->proc.poll_delay;
|
|
|
|
*cpu_time = proc->cpu_time;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_List *
|
|
|
|
_process_list_get(Ui_Data *pd)
|
|
|
|
{
|
|
|
|
Eina_List *list;
|
|
|
|
Ui *ui;
|
|
|
|
|
|
|
|
ui = pd->ui;
|
|
|
|
|
|
|
|
list = proc_info_all_get();
|
|
|
|
|
|
|
|
if (ui->proc.show_user)
|
|
|
|
list = _process_list_uid_trim(list, getuid());
|
|
|
|
|
|
|
|
list = _process_list_search_trim(list, pd);
|
|
|
|
list = _process_list_sort(list, pd);
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_process_list(void *data, Ecore_Thread *thread)
|
|
|
|
{
|
|
|
|
Ui_Data *pd;
|
|
|
|
Eina_List *list;
|
|
|
|
Ui *ui;
|
|
|
|
Proc_Info *proc;
|
|
|
|
int i, delay = 1;
|
|
|
|
|
|
|
|
pd = data;
|
|
|
|
ui = pd->ui;
|
|
|
|
|
|
|
|
while (!ecore_thread_check(thread))
|
|
|
|
{
|
|
|
|
for (i = 0; i < delay * 8; i++)
|
|
|
|
{
|
|
|
|
if (ecore_thread_check(thread)) return;
|
|
|
|
|
|
|
|
if (pd->skip_wait)
|
|
|
|
{
|
|
|
|
pd->skip_wait = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
usleep(125000);
|
|
|
|
}
|
|
|
|
list = _process_list_get(pd);
|
|
|
|
if (!pd->skip_wait)
|
|
|
|
ecore_thread_feedback(thread, list);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EINA_LIST_FREE(list, proc)
|
|
|
|
proc_info_free(proc);
|
|
|
|
}
|
|
|
|
|
|
|
|
delay = ui->proc.poll_delay;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_process_list_feedback_cb(void *data, Ecore_Thread *thread EINA_UNUSED,
|
|
|
|
void *msg EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Ui_Data *pd;
|
|
|
|
Eina_List *list;
|
|
|
|
Proc_Info *proc;
|
|
|
|
Elm_Object_Item *it;
|
|
|
|
|
|
|
|
pd = data;
|
|
|
|
list = msg;
|
|
|
|
|
|
|
|
_genlist_ensure_n_items(pd->genlist, eina_list_count(list), &pd->itc);
|
|
|
|
|
|
|
|
it = elm_genlist_first_item_get(pd->genlist);
|
|
|
|
EINA_LIST_FREE(list, proc)
|
|
|
|
{
|
|
|
|
if (!it)
|
|
|
|
proc_info_free(proc);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Proc_Info *prev = elm_object_item_data_get(it);
|
|
|
|
if (prev)
|
|
|
|
proc_info_free(prev);
|
|
|
|
|
|
|
|
elm_object_item_data_set(it, proc);
|
|
|
|
|
|
|
|
it = elm_genlist_item_next_get(it);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
elm_genlist_realized_items_update(pd->genlist);
|
|
|
|
|
|
|
|
#if DIRTY_GENLIST_HACK
|
|
|
|
Eina_List *real = elm_genlist_realized_items_get(pd->genlist);
|
|
|
|
int n = eina_list_count(pd->cache->active);
|
|
|
|
if (n > eina_list_count(real) * 2)
|
|
|
|
{
|
|
|
|
evisum_ui_item_cache_steal(pd->cache, real);
|
|
|
|
pd->skip_wait = 1;
|
|
|
|
}
|
|
|
|
eina_list_free(real);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
printf("active %d and inactive %d\n",
|
|
|
|
eina_list_count(pd->cache->active),
|
|
|
|
eina_list_count(pd->cache->inactive));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_process_list_update(Ui_Data *pd)
|
|
|
|
{
|
|
|
|
pd->skip_wait = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_btn_icon_state_update(Evas_Object *btn, Eina_Bool reverse)
|
|
|
|
{
|
|
|
|
Evas_Object *icon = elm_icon_add(btn);
|
|
|
|
|
|
|
|
if (reverse)
|
|
|
|
elm_icon_standard_set(icon, evisum_icon_path_get("go-down"));
|
|
|
|
else
|
|
|
|
elm_icon_standard_set(icon, evisum_icon_path_get("go-up"));
|
|
|
|
|
|
|
|
elm_object_part_content_set(btn, "icon", icon);
|
|