ui: Redo Process Panel.
Let's create a window per-process instead of the panel. I want people to learn, let's show the manpage for the process if one exists. this is not finished.
This commit is contained in:
parent
2083660ed6
commit
a6d1da406b
|
@ -1172,7 +1172,7 @@ _linux_generic_network_status(unsigned long int *in,
|
|||
#endif
|
||||
|
||||
static void
|
||||
_network_transfer_get(results_t *results)
|
||||
_network_transfer_get(Sys_Info *results)
|
||||
{
|
||||
unsigned long first_in = 0, first_out = 0;
|
||||
unsigned long last_in = 0, last_out = 0;
|
||||
|
@ -1251,7 +1251,7 @@ system_network_transfer_get(unsigned long *incoming, unsigned long *outgoing)
|
|||
int
|
||||
system_cpu_memory_get(double *percent_cpu, long *memory_total, long *memory_used)
|
||||
{
|
||||
results_t results;
|
||||
Sys_Info results;
|
||||
|
||||
memset(&results, 0, sizeof(results));
|
||||
|
||||
|
@ -1276,22 +1276,22 @@ system_cpu_memory_get(double *percent_cpu, long *memory_total, long *memory_used
|
|||
static void *
|
||||
_network_transfer_get_thread_cb(void *arg)
|
||||
{
|
||||
results_t *results = arg;
|
||||
Sys_Info *results = arg;
|
||||
|
||||
_network_transfer_get(results);
|
||||
|
||||
return (void *)0;
|
||||
}
|
||||
|
||||
results_t *
|
||||
system_stats_get(void)
|
||||
Sys_Info *
|
||||
sys_info_all_get(void)
|
||||
{
|
||||
results_t *results;
|
||||
Sys_Info *results;
|
||||
void *ret;
|
||||
pthread_t tid;
|
||||
int error;
|
||||
|
||||
results = calloc(1, sizeof(results_t));
|
||||
results = calloc(1, sizeof(Sys_Info));
|
||||
if (!results) return NULL;
|
||||
|
||||
results->cores = _cpu_cores_state_get(&results->cpu_count);
|
||||
|
|
|
@ -47,8 +47,8 @@ typedef struct
|
|||
|
||||
#define INVALID_TEMP -999
|
||||
|
||||
typedef struct results_t results_t;
|
||||
struct results_t
|
||||
typedef struct Sys_Info Sys_Info;
|
||||
struct Sys_Info
|
||||
{
|
||||
int cpu_count;
|
||||
cpu_core_t **cores;
|
||||
|
@ -62,20 +62,8 @@ struct results_t
|
|||
int temperature;
|
||||
};
|
||||
|
||||
results_t *
|
||||
system_stats_get(void);
|
||||
|
||||
int
|
||||
system_cpu_memory_get(double *percent_cpu, long *memory_total, long *memory_used);
|
||||
|
||||
bool
|
||||
system_network_transfer_get(unsigned long *incoming, unsigned long *outgoing);
|
||||
|
||||
int
|
||||
system_temperature_cpu_get(void);
|
||||
|
||||
void
|
||||
system_power_state_get(power_t *power);
|
||||
Sys_Info *
|
||||
sys_info_all_get(void);
|
||||
|
||||
int
|
||||
system_cpu_online_count_get();
|
||||
|
|
|
@ -961,19 +961,7 @@ _item_pid_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
|
|||
if (!proc) return;
|
||||
|
||||
ui->selected_pid = proc->pid;
|
||||
ui_process_panel_update(ui);
|
||||
|
||||
if (ui->timer_pid)
|
||||
{
|
||||
ecore_timer_del(ui->timer_pid);
|
||||
ui->timer_pid = NULL;
|
||||
}
|
||||
|
||||
ui->timer_pid = ecore_timer_add(ui->poll_delay, ui_process_panel_update, ui);
|
||||
|
||||
elm_panel_toggle(ui->panel);
|
||||
evas_object_show(ui->panel);
|
||||
ui->panel_visible = EINA_TRUE;
|
||||
ui_process_win_add(proc->pid, proc->command);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1170,7 +1158,6 @@ _tabs_hide(Ui *ui)
|
|||
|
||||
evas_object_hide(ui->entry_search);
|
||||
evas_object_hide(ui->system_activity);
|
||||
evas_object_hide(ui->panel);
|
||||
evas_object_hide(ui->cpu_view);
|
||||
evas_object_hide(ui->mem_view);
|
||||
evas_object_hide(ui->disk_view);
|
||||
|
@ -1618,20 +1605,20 @@ evisum_ui_shutdown(Ui *ui)
|
|||
}
|
||||
|
||||
static void
|
||||
_system_stats(void *data, Ecore_Thread *thread)
|
||||
_sys_info_all_poll(void *data, Ecore_Thread *thread)
|
||||
{
|
||||
Ui *ui = data;
|
||||
|
||||
while (1)
|
||||
{
|
||||
results_t *results = system_stats_get();
|
||||
if (!results)
|
||||
Sys_Info *sysinfo = sys_info_all_get();
|
||||
if (!sysinfo)
|
||||
{
|
||||
ecore_main_loop_quit();
|
||||
return;
|
||||
}
|
||||
|
||||
ecore_thread_feedback(thread, results);
|
||||
ecore_thread_feedback(thread, sysinfo);
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
|
@ -1648,28 +1635,28 @@ _system_stats(void *data, Ecore_Thread *thread)
|
|||
}
|
||||
|
||||
static void
|
||||
_system_stats_feedback_cb(void *data, Ecore_Thread *thread, void *msg)
|
||||
_sys_info_all_poll_feedback_cb(void *data, Ecore_Thread *thread, void *msg)
|
||||
{
|
||||
Ui *ui;
|
||||
Evas_Object *progress;
|
||||
results_t *results;
|
||||
Sys_Info *sysinfo;
|
||||
double ratio, value, cpu_usage = 0.0;
|
||||
|
||||
ui = data;
|
||||
results = msg;
|
||||
sysinfo = msg;
|
||||
|
||||
if (ecore_thread_check(thread))
|
||||
goto out;
|
||||
|
||||
ui_tab_cpu_update(ui, results);
|
||||
ui_tab_memory_update(ui, results);
|
||||
ui_tab_cpu_update(ui, sysinfo);
|
||||
ui_tab_memory_update(ui, sysinfo);
|
||||
ui_tab_disk_update(ui);
|
||||
ui_tab_misc_update(ui, results);
|
||||
ui_tab_misc_update(ui, sysinfo);
|
||||
|
||||
for (int i = 0; i < results->cpu_count; i++)
|
||||
for (int i = 0; i < sysinfo->cpu_count; i++)
|
||||
{
|
||||
cpu_usage += results->cores[i]->percent;
|
||||
free(results->cores[i]);
|
||||
cpu_usage += sysinfo->cores[i]->percent;
|
||||
free(sysinfo->cores[i]);
|
||||
}
|
||||
|
||||
cpu_usage = cpu_usage / system_cpu_online_count_get();
|
||||
|
@ -1677,30 +1664,29 @@ _system_stats_feedback_cb(void *data, Ecore_Thread *thread, void *msg)
|
|||
elm_progressbar_value_set(ui->progress_cpu, cpu_usage / 100);
|
||||
|
||||
progress = ui->progress_mem;
|
||||
ratio = results->memory.total / 100.0;
|
||||
value = results->memory.used / ratio;
|
||||
ratio = sysinfo->memory.total / 100.0;
|
||||
value = sysinfo->memory.used / ratio;
|
||||
elm_progressbar_value_set(progress, value / 100);
|
||||
elm_progressbar_unit_format_set(progress, eina_slstr_printf("%s / %s",
|
||||
evisum_size_format(results->memory.used << 10),
|
||||
evisum_size_format(results->memory.total << 10)));
|
||||
evisum_size_format(sysinfo->memory.used << 10),
|
||||
evisum_size_format(sysinfo->memory.total << 10)));
|
||||
out:
|
||||
free(results->cores);
|
||||
free(results);
|
||||
free(sysinfo->cores);
|
||||
free(sysinfo);
|
||||
}
|
||||
|
||||
static void
|
||||
_ui_launch(Ui *ui)
|
||||
{
|
||||
ui_process_panel_update(ui);
|
||||
_process_list_update(ui);
|
||||
|
||||
ui->thread_system = ecore_thread_feedback_run(_system_stats, _system_stats_feedback_cb,
|
||||
_thread_end_cb, _thread_error_cb, ui,
|
||||
EINA_FALSE);
|
||||
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);
|
||||
|
||||
ui->thread_process = ecore_thread_feedback_run(_process_list, _process_list_feedback_cb,
|
||||
_thread_end_cb, _thread_error_cb, ui,
|
||||
EINA_FALSE);
|
||||
ui->thread_process =
|
||||
ecore_thread_feedback_run(_process_list, _process_list_feedback_cb,
|
||||
_thread_end_cb, _thread_error_cb, ui, EINA_FALSE);
|
||||
|
||||
evas_object_event_callback_add(ui->win, EVAS_CALLBACK_RESIZE, _evisum_resize_cb, ui);
|
||||
evas_object_event_callback_add(ui->content, EVAS_CALLBACK_KEY_DOWN, _evisum_key_down_cb, ui);
|
||||
|
@ -1720,8 +1706,8 @@ _ui_init(Evas_Object *parent)
|
|||
ui->sort_type = SORT_BY_PID;
|
||||
ui->selected_pid = -1;
|
||||
ui->program_pid = getpid();
|
||||
ui->panel_visible = ui->disk_visible =
|
||||
ui->cpu_visible = ui->mem_visible = ui->misc_visible = EINA_TRUE;
|
||||
ui->disk_visible = ui->cpu_visible = EINA_TRUE;
|
||||
ui->mem_visible = ui->misc_visible = EINA_TRUE;
|
||||
ui->cpu_times = NULL;
|
||||
ui->cpu_list = NULL;
|
||||
ui->item_cache = NULL;
|
||||
|
@ -1735,7 +1721,6 @@ _ui_init(Evas_Object *parent)
|
|||
_ui_tabs_add(parent, ui);
|
||||
_ui_tab_system_add(ui);
|
||||
|
||||
ui_process_panel_add(ui);
|
||||
ui_tab_cpu_add(ui);
|
||||
ui_tab_memory_add(ui);
|
||||
ui_tab_disk_add(ui);
|
||||
|
|
|
@ -62,7 +62,6 @@ typedef struct Ui
|
|||
{
|
||||
Evas_Object *win;
|
||||
Evas_Object *menu;
|
||||
Evas_Object *panel;
|
||||
Evas_Object *scroller;
|
||||
Evas_Object *content;
|
||||
Evas_Object *btn_general;
|
||||
|
@ -109,22 +108,6 @@ typedef struct Ui
|
|||
|
||||
Eina_List *item_cache;
|
||||
Evas_Object *genlist_procs;
|
||||
|
||||
Evas_Object *entry_pid_cmd;
|
||||
Evas_Object *entry_pid_cmd_args;
|
||||
Evas_Object *entry_pid_user;
|
||||
Evas_Object *entry_pid_pid;
|
||||
Evas_Object *entry_pid_uid;
|
||||
Evas_Object *entry_pid_cpu;
|
||||
Evas_Object *entry_pid_threads;
|
||||
Evas_Object *entry_pid_virt;
|
||||
Evas_Object *entry_pid_rss;
|
||||
Evas_Object *entry_pid_shared;
|
||||
Evas_Object *entry_pid_size;
|
||||
Evas_Object *entry_pid_nice;
|
||||
Evas_Object *entry_pid_pri;
|
||||
Evas_Object *entry_pid_state;
|
||||
Evas_Object *entry_pid_cpu_usage;
|
||||
Evas_Object *entry_search;
|
||||
|
||||
Ecore_Thread *thread_system;
|
||||
|
@ -141,7 +124,6 @@ typedef struct Ui
|
|||
Eina_Bool ready;
|
||||
|
||||
Eina_List *cpu_times;
|
||||
int64_t pid_cpu_time;
|
||||
|
||||
Eina_List *cpu_list;
|
||||
Evas_Object *temp_label;
|
||||
|
@ -150,7 +132,6 @@ typedef struct Ui
|
|||
|
||||
Sort_Type sort_type;
|
||||
Eina_Bool sort_reverse;
|
||||
Eina_Bool panel_visible;
|
||||
Eina_Bool searching;
|
||||
Eina_Bool show_self;
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ ui_tab_cpu_add(Ui *ui)
|
|||
}
|
||||
|
||||
void
|
||||
ui_tab_cpu_update(Ui *ui, results_t *results)
|
||||
ui_tab_cpu_update(Ui *ui, Sys_Info *sysinfo)
|
||||
{
|
||||
Eina_List *l;
|
||||
Evas_Object *pb;
|
||||
|
@ -101,12 +101,12 @@ ui_tab_cpu_update(Ui *ui, results_t *results)
|
|||
if (!ui->cpu_visible)
|
||||
return;
|
||||
|
||||
if (results->temperature != INVALID_TEMP)
|
||||
elm_object_text_set(ui->temp_label, eina_slstr_printf(_("Core at (%d °C)"), results->temperature));
|
||||
if (sysinfo->temperature != INVALID_TEMP)
|
||||
elm_object_text_set(ui->temp_label, eina_slstr_printf(_("Core at (%d °C)"), sysinfo->temperature));
|
||||
|
||||
EINA_LIST_FOREACH(ui->cpu_list, l, pb)
|
||||
{
|
||||
elm_progressbar_value_set(pb, results->cores[i]->percent / 100);
|
||||
elm_progressbar_value_set(pb, sysinfo->cores[i]->percent / 100);
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ void
|
|||
ui_tab_cpu_add(Ui *ui);
|
||||
|
||||
void
|
||||
ui_tab_cpu_update(Ui *ui, results_t *results);
|
||||
ui_tab_cpu_update(Ui *ui, Sys_Info *sysinfo);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -143,7 +143,7 @@ ui_tab_memory_add(Ui *ui)
|
|||
}
|
||||
|
||||
void
|
||||
ui_tab_memory_update(Ui *ui, results_t *results)
|
||||
ui_tab_memory_update(Ui *ui, Sys_Info *sysinfo)
|
||||
{
|
||||
Evas_Object *progress;
|
||||
double ratio, value;
|
||||
|
@ -152,52 +152,52 @@ ui_tab_memory_update(Ui *ui, results_t *results)
|
|||
return;
|
||||
|
||||
progress = ui->progress_mem_used;
|
||||
ratio = results->memory.total / 100.0;
|
||||
value = results->memory.used / ratio;
|
||||
ratio = sysinfo->memory.total / 100.0;
|
||||
value = sysinfo->memory.used / ratio;
|
||||
elm_progressbar_value_set(progress, value / 100);
|
||||
elm_progressbar_unit_format_set(progress, eina_slstr_printf("%s / %s (%1.0f %)",
|
||||
evisum_size_format(results->memory.used << 10),
|
||||
evisum_size_format(results->memory.total << 10),
|
||||
evisum_size_format(sysinfo->memory.used << 10),
|
||||
evisum_size_format(sysinfo->memory.total << 10),
|
||||
value));
|
||||
|
||||
progress = ui->progress_mem_cached;
|
||||
ratio = results->memory.total / 100.0;
|
||||
value = results->memory.cached / ratio;
|
||||
ratio = sysinfo->memory.total / 100.0;
|
||||
value = sysinfo->memory.cached / ratio;
|
||||
elm_progressbar_value_set(progress, value / 100);
|
||||
elm_progressbar_unit_format_set(progress, eina_slstr_printf("%s / %s (%1.0f %)",
|
||||
evisum_size_format(results->memory.cached << 10),
|
||||
evisum_size_format(results->memory.total << 10),
|
||||
evisum_size_format(sysinfo->memory.cached << 10),
|
||||
evisum_size_format(sysinfo->memory.total << 10),
|
||||
value));
|
||||
|
||||
progress = ui->progress_mem_buffered;
|
||||
ratio = results->memory.total / 100.0;
|
||||
value = results->memory.buffered / ratio;
|
||||
ratio = sysinfo->memory.total / 100.0;
|
||||
value = sysinfo->memory.buffered / ratio;
|
||||
elm_progressbar_value_set(progress, value / 100);
|
||||
elm_progressbar_unit_format_set(progress, eina_slstr_printf("%s / %s (%1.0f %)",
|
||||
evisum_size_format(results->memory.buffered << 10),
|
||||
evisum_size_format(results->memory.total << 10),
|
||||
evisum_size_format(sysinfo->memory.buffered << 10),
|
||||
evisum_size_format(sysinfo->memory.total << 10),
|
||||
value));
|
||||
|
||||
progress = ui->progress_mem_shared;
|
||||
ratio = results->memory.total / 100.0;
|
||||
value = results->memory.shared / ratio;
|
||||
ratio = sysinfo->memory.total / 100.0;
|
||||
value = sysinfo->memory.shared / ratio;
|
||||
elm_progressbar_value_set(progress, value / 100);
|
||||
elm_progressbar_unit_format_set(progress, eina_slstr_printf("%s / %s (%1.0f %)",
|
||||
evisum_size_format(results->memory.shared << 10),
|
||||
evisum_size_format(results->memory.total << 10),
|
||||
evisum_size_format(sysinfo->memory.shared << 10),
|
||||
evisum_size_format(sysinfo->memory.total << 10),
|
||||
value));
|
||||
|
||||
progress = ui->progress_mem_swap;
|
||||
if (results->memory.swap_total)
|
||||
if (sysinfo->memory.swap_total)
|
||||
{
|
||||
ratio = results->memory.swap_total / 100.0;
|
||||
value = results->memory.swap_used / ratio;
|
||||
ratio = sysinfo->memory.swap_total / 100.0;
|
||||
value = sysinfo->memory.swap_used / ratio;
|
||||
}
|
||||
else value = 0.0;
|
||||
elm_progressbar_value_set(progress, value / 100);
|
||||
elm_progressbar_unit_format_set(progress, eina_slstr_printf("%s / %s (%1.0f %)",
|
||||
evisum_size_format(results->memory.swap_used << 10),
|
||||
evisum_size_format(results->memory.swap_total << 10),
|
||||
evisum_size_format(sysinfo->memory.swap_used << 10),
|
||||
evisum_size_format(sysinfo->memory.swap_total << 10),
|
||||
value));
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,6 @@ void
|
|||
ui_tab_memory_add(Ui *ui);
|
||||
|
||||
void
|
||||
ui_tab_memory_update(Ui *ui, results_t *results);
|
||||
ui_tab_memory_update(Ui *ui, Sys_Info *sysinfo);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -196,7 +196,7 @@ ui_tab_misc_add(Ui *ui)
|
|||
}
|
||||
|
||||
void
|
||||
ui_tab_misc_update(Ui *ui, results_t *results)
|
||||
ui_tab_misc_update(Ui *ui, Sys_Info *sysinfo)
|
||||
{
|
||||
Evas_Object *box, *frame;
|
||||
|
||||
|
@ -210,9 +210,9 @@ ui_tab_misc_update(Ui *ui, results_t *results)
|
|||
evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_show(box);
|
||||
|
||||
_battery_usage_add(box, &results->power);
|
||||
_network_usage_add(ui, box, results->incoming, EINA_TRUE);
|
||||
_network_usage_add(ui, box, results->outgoing, EINA_FALSE);
|
||||
_battery_usage_add(box, &sysinfo->power);
|
||||
_network_usage_add(ui, box, sysinfo->incoming, EINA_TRUE);
|
||||
_network_usage_add(ui, box, sysinfo->outgoing, EINA_FALSE);
|
||||
|
||||
frame = elm_frame_add(ui->misc_activity);
|
||||
evas_object_size_hint_align_set(frame, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
|
|
|
@ -8,6 +8,6 @@ void
|
|||
ui_tab_misc_add(Ui *ui);
|
||||
|
||||
void
|
||||
ui_tab_misc_update(Ui *ui, results_t *results);
|
||||
ui_tab_misc_update(Ui *ui, Sys_Info *sysinfo);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,87 +1,48 @@
|
|||
#include "ui_process.h"
|
||||
#include "../system/process.h"
|
||||
|
||||
static void
|
||||
_list_item_del_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
Eina_List *
|
||||
_exe_response(const char *command)
|
||||
{
|
||||
pid_t *pid = data;
|
||||
FILE *p;
|
||||
Eina_List *lines;
|
||||
char buf[8192];
|
||||
|
||||
free(pid);
|
||||
p = popen(command, "r");
|
||||
if (!p)
|
||||
return NULL;
|
||||
|
||||
lines = NULL;
|
||||
|
||||
while ((fgets(buf, sizeof(buf), p)) != NULL)
|
||||
{
|
||||
lines = eina_list_append(lines, elm_entry_markup_to_utf8(buf));
|
||||
}
|
||||
|
||||
static int
|
||||
_sort_by_pid(const void *p1, const void *p2)
|
||||
{
|
||||
const Proc_Info *inf1, *inf2;
|
||||
pclose(p);
|
||||
|
||||
inf1 = p1; inf2 = p2;
|
||||
|
||||
return inf1->pid - inf2->pid;
|
||||
return lines;
|
||||
}
|
||||
|
||||
static void
|
||||
_process_panel_pids_update(Ui *ui)
|
||||
static Eina_Bool
|
||||
_proc_info_update(void *data)
|
||||
{
|
||||
Proc_Info *proc;
|
||||
Elm_Widget_Item *item;
|
||||
Eina_List *list;
|
||||
pid_t *pid;
|
||||
|
||||
if (!ui->panel_visible)
|
||||
return;
|
||||
|
||||
elm_list_clear(ui->list_pid);
|
||||
|
||||
list = proc_info_all_get();
|
||||
list = eina_list_sort(list, eina_list_count(list), _sort_by_pid);
|
||||
|
||||
EINA_LIST_FREE(list, proc)
|
||||
{
|
||||
pid = malloc(sizeof(pid_t));
|
||||
*pid = proc->pid;
|
||||
|
||||
item = elm_list_item_append(ui->list_pid, eina_slstr_printf("%d", proc->pid), NULL, NULL, NULL, pid);
|
||||
elm_object_item_del_cb_set(item, _list_item_del_cb);
|
||||
proc_info_free(proc);
|
||||
}
|
||||
|
||||
elm_list_go(ui->list_pid);
|
||||
|
||||
if (list)
|
||||
eina_list_free(list);
|
||||
}
|
||||
|
||||
Eina_Bool
|
||||
ui_process_panel_update(void *data)
|
||||
{
|
||||
Ui *ui;
|
||||
const Eina_List *l, *list;
|
||||
Elm_Widget_Item *it;
|
||||
Ui_Process *ui;
|
||||
struct passwd *pwd_entry;
|
||||
Proc_Info *proc;
|
||||
double cpu_usage = 0.0;
|
||||
|
||||
ui = data;
|
||||
|
||||
if (!ui->timer_pid)
|
||||
ui->timer_pid = ecore_timer_add(ui->poll_delay, _proc_info_update, ui);
|
||||
|
||||
proc = proc_info_by_pid(ui->selected_pid);
|
||||
if (!proc)
|
||||
{
|
||||
_process_panel_pids_update(ui);
|
||||
return ECORE_CALLBACK_CANCEL;
|
||||
}
|
||||
|
||||
list = elm_list_items_get(ui->list_pid);
|
||||
EINA_LIST_FOREACH(list, l, it)
|
||||
{
|
||||
pid_t *pid = elm_object_item_data_get(it);
|
||||
if (pid && *pid == ui->selected_pid)
|
||||
{
|
||||
elm_list_item_selected_set(it, EINA_TRUE);
|
||||
elm_list_item_bring_in(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
elm_object_text_set(ui->entry_pid_cmd, proc->command);
|
||||
pwd_entry = getpwuid(proc->uid);
|
||||
if (pwd_entry)
|
||||
|
@ -120,42 +81,6 @@ ui_process_panel_update(void *data)
|
|||
return ECORE_CALLBACK_RENEW;
|
||||
}
|
||||
|
||||
static void
|
||||
_process_panel_list_selected_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Elm_Object_Item *it;
|
||||
Ui *ui;
|
||||
const char *text;
|
||||
|
||||
ui = data;
|
||||
|
||||
it = elm_list_selected_item_get(obj);
|
||||
text = elm_object_item_text_get(it);
|
||||
|
||||
if (ui->timer_pid)
|
||||
{
|
||||
ecore_timer_del(ui->timer_pid);
|
||||
ui->timer_pid = NULL;
|
||||
}
|
||||
|
||||
ui->selected_pid = atoi(text);
|
||||
ui->pid_cpu_time = 0;
|
||||
|
||||
ui_process_panel_update(ui);
|
||||
|
||||
ui->timer_pid = ecore_timer_add(ui->poll_delay, ui_process_panel_update, ui);
|
||||
|
||||
elm_scroller_page_bring_in(ui->scroller, 0, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
_panel_scrolled_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ui *ui = data;
|
||||
|
||||
ui->panel_visible = !ui->panel_visible;
|
||||
}
|
||||
|
||||
static void
|
||||
_btn_start_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
|
@ -189,57 +114,17 @@ _btn_kill_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info
|
|||
kill(ui->selected_pid, SIGKILL);
|
||||
}
|
||||
|
||||
void
|
||||
ui_process_panel_add(Ui *ui)
|
||||
static Evas_Object *
|
||||
_process_tab_add(Evas_Object *parent, Ui_Process *ui)
|
||||
{
|
||||
Evas_Object *parent, *panel, *hbox, *frame, *scroller, *table;
|
||||
Evas_Object *label, *list, *entry, *button, *border;
|
||||
Evas_Object *hbox, *scroller, *table;
|
||||
Evas_Object *label, *entry, *button, *border;
|
||||
int i = 0;
|
||||
|
||||
parent = ui->content;
|
||||
|
||||
ui->panel = panel = elm_panel_add(parent);
|
||||
evas_object_size_hint_weight_set(panel, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(panel, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_panel_orient_set(panel, ELM_PANEL_ORIENT_BOTTOM);
|
||||
elm_panel_toggle(panel);
|
||||
elm_object_content_set(ui->win, panel);
|
||||
evas_object_hide(panel);
|
||||
evas_object_smart_callback_add(ui->panel, "scroll", _panel_scrolled_cb, ui);
|
||||
|
||||
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);
|
||||
elm_object_content_set(panel, hbox);
|
||||
evas_object_show(hbox);
|
||||
|
||||
frame = elm_frame_add(hbox);
|
||||
evas_object_size_hint_weight_set(frame, 0.2, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(frame, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_object_text_set(frame, "PID");
|
||||
elm_box_pack_end(hbox, frame);
|
||||
evas_object_show(frame);
|
||||
|
||||
ui->list_pid = list = elm_list_add(frame);
|
||||
evas_object_size_hint_weight_set(list, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_size_hint_align_set(list, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_scroller_gravity_set(list, 0.5, 0.0);
|
||||
evas_object_show(list);
|
||||
evas_object_smart_callback_add(ui->list_pid, "selected", _process_panel_list_selected_cb, ui);
|
||||
elm_object_content_set(frame, list);
|
||||
|
||||
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);
|
||||
elm_object_text_set(frame, _("Process Statistics"));
|
||||
elm_box_pack_end(hbox, frame);
|
||||
evas_object_show(frame);
|
||||
|
||||
table = elm_table_add(frame);
|
||||
evas_object_size_hint_weight_set(table, 0.5, EVAS_HINT_EXPAND);
|
||||
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);
|
||||
evas_object_show(table);
|
||||
evas_object_show(ui->content);
|
||||
|
||||
scroller = elm_scroller_add(parent);
|
||||
evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
|
@ -247,8 +132,6 @@ ui_process_panel_add(Ui *ui)
|
|||
elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_ON);
|
||||
evas_object_show(scroller);
|
||||
elm_object_content_set(scroller, table);
|
||||
elm_object_content_set(frame, scroller);
|
||||
elm_box_pack_end(hbox, frame);
|
||||
|
||||
label = elm_label_add(parent);
|
||||
elm_object_text_set(label, _("Command:"));
|
||||
|
@ -529,5 +412,210 @@ ui_process_panel_add(Ui *ui)
|
|||
evas_object_show(button);
|
||||
elm_object_content_set(border, button);
|
||||
evas_object_smart_callback_add(button, "clicked", _btn_kill_clicked_cb, ui);
|
||||
|
||||
return scroller;
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_threads_tab_add(Evas_Object *parent)
|
||||
{
|
||||
Evas_Object *box, *entry;
|
||||
|
||||
box = elm_box_add(parent);
|
||||
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);
|
||||
|
||||
entry = elm_entry_add(box);
|
||||
evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_entry_single_line_set(entry, EINA_FALSE);
|
||||
elm_entry_editable_set(entry, EINA_FALSE);
|
||||
elm_entry_scrollable_set(entry, EINA_TRUE);
|
||||
elm_object_text_set(entry, "threashdjh");
|
||||
evas_object_show(entry);
|
||||
|
||||
elm_box_pack_end(box, entry);
|
||||
|
||||
return box;
|
||||
}
|
||||
|
||||
|
||||
static Evas_Object *
|
||||
_info_tab_add(Evas_Object *parent, const char *cmd)
|
||||
{
|
||||
Evas_Object *box, *entry;
|
||||
|
||||
box = elm_box_add(parent);
|
||||
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);
|
||||
|
||||
entry = elm_entry_add(box);
|
||||
evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_entry_single_line_set(entry, EINA_FALSE);
|
||||
elm_entry_line_wrap_set(entry, ELM_WRAP_NONE);
|
||||
elm_entry_editable_set(entry, EINA_FALSE);
|
||||
elm_entry_scrollable_set(entry, EINA_TRUE);
|
||||
evas_object_show(entry);
|
||||
|
||||
Eina_List *lines = _exe_response(eina_slstr_printf("man %s", cmd));
|
||||
if (lines)
|
||||
{
|
||||
Eina_Strbuf *buf = eina_strbuf_new();
|
||||
eina_strbuf_append(buf, "<code>");
|
||||
char *line;
|
||||
EINA_LIST_FREE(lines, line)
|
||||
{
|
||||
eina_strbuf_append_printf(buf, "%s<br>", line);
|
||||
free(line);
|
||||
}
|
||||
|
||||
eina_list_free(lines);
|
||||
eina_strbuf_append(buf, "<code>");
|
||||
elm_object_text_set(entry, eina_strbuf_string_get(buf));
|
||||
eina_strbuf_free(buf);
|
||||
}
|
||||
|
||||
elm_box_pack_end(box, entry);
|
||||
|
||||
return box;
|
||||
}
|
||||
|
||||
static void
|
||||
_hide_all(Ui_Process *ui)
|
||||
{
|
||||
evas_object_hide(ui->main_view);
|
||||
evas_object_hide(ui->info_view);
|
||||
evas_object_hide(ui->thread_view);
|
||||
}
|
||||
|
||||
static void
|
||||
_btn_process_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ui_Process *ui;
|
||||
|
||||
ui = data;
|
||||
|
||||
_hide_all(ui);
|
||||
evas_object_show(ui->main_view);
|
||||
}
|
||||
|
||||
static void
|
||||
_btn_threads_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ui_Process *ui;
|
||||
|
||||
ui = data;
|
||||
|
||||
_hide_all(ui);
|
||||
evas_object_show(ui->thread_view);
|
||||
}
|
||||
|
||||
static void
|
||||
_btn_info_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ui_Process *ui;
|
||||
|
||||
ui = data;
|
||||
|
||||
_hide_all(ui);
|
||||
evas_object_show(ui->info_view);
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_tabs_add(Evas_Object *parent, Ui_Process *ui)
|
||||
{
|
||||
Evas_Object *hbox, *btn;
|
||||
|
||||
hbox = elm_box_add(parent);
|
||||
evas_object_size_hint_weight_set(hbox, EVAS_HINT_EXPAND, 0);
|
||||
evas_object_size_hint_align_set(hbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_box_horizontal_set(hbox, EINA_TRUE);
|
||||
evas_object_show(hbox);
|
||||
|
||||
btn = elm_button_add(parent);
|
||||
evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_object_text_set(btn, _("Process"));
|
||||
evas_object_show(btn);
|
||||
elm_box_pack_end(hbox, btn);
|
||||
evas_object_smart_callback_add(btn, "clicked", _btn_process_clicked_cb, ui);
|
||||
|
||||
btn = elm_button_add(parent);
|
||||
evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_object_text_set(btn, _("Threads"));
|
||||
evas_object_show(btn);
|
||||
elm_box_pack_end(hbox, btn);
|
||||
evas_object_smart_callback_add(btn, "clicked", _btn_threads_clicked_cb, ui);
|
||||
|
||||
btn = elm_button_add(parent);
|
||||
evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_object_text_set(btn, _("Information"));
|
||||
evas_object_show(btn);
|
||||
elm_box_pack_end(hbox, btn);
|
||||
evas_object_smart_callback_add(btn, "clicked", _btn_info_clicked_cb, ui);
|
||||
|
||||
return hbox;
|
||||
}
|
||||
|
||||
static void
|
||||
_win_del_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Evas_Object *win;
|
||||
Ui_Process *ui;
|
||||
|
||||
ui = data;
|
||||
win = obj;
|
||||
|
||||
if (ui->timer_pid)
|
||||
ecore_timer_del(ui->timer_pid);
|
||||
|
||||
evas_object_del(win);
|
||||
}
|
||||
|
||||
void
|
||||
ui_process_win_add(int pid, const char *cmd)
|
||||
{
|
||||
Evas_Object *win, *ic, *box, *tabs;
|
||||
|
||||
win = elm_win_util_standard_add("evisum", eina_slstr_printf("Evisum: %s", cmd));
|
||||
ic = elm_icon_add(win);
|
||||
elm_icon_standard_set(ic, "evisum");
|
||||
elm_win_icon_object_set(win, ic);
|
||||
Ui_Process *ui = calloc(1, sizeof(Ui_Process));
|
||||
ui->selected_pid = pid;
|
||||
ui->poll_delay = 3.0;
|
||||
|
||||
tabs = _tabs_add(win, ui);
|
||||
|
||||
box = elm_box_add(win);
|
||||
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);
|
||||
elm_box_pack_end(box, tabs);
|
||||
|
||||
ui->content = elm_table_add(box);
|
||||
evas_object_size_hint_weight_set(ui->content, 0.5, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(ui->content, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_show(ui->content);
|
||||
|
||||
ui->main_view = _process_tab_add(win, ui);
|
||||
ui->thread_view = _threads_tab_add(win);
|
||||
ui->info_view = _info_tab_add(win, cmd);
|
||||
|
||||
elm_table_pack(ui->content, ui->info_view, 0, 0, 1, 1);
|
||||
elm_table_pack(ui->content, ui->main_view, 0, 0, 1, 1);
|
||||
elm_table_pack(ui->content, ui->thread_view, 0, 0, 1, 1);
|
||||
|
||||
elm_box_pack_end(box, ui->content);
|
||||
elm_object_content_set(win, box);
|
||||
evas_object_smart_callback_add(win, "delete,request", _win_del_cb, ui);
|
||||
elm_win_center(win, EINA_TRUE, EINA_TRUE);
|
||||
evas_object_resize(win, 640, 480);
|
||||
evas_object_show(win);
|
||||
|
||||
_proc_info_update(ui);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,10 +3,37 @@
|
|||
|
||||
#include "ui.h"
|
||||
|
||||
void
|
||||
ui_process_panel_add(Ui *ui);
|
||||
typedef struct _Ui_Process {
|
||||
Evas_Object *content;
|
||||
|
||||
Eina_Bool
|
||||
ui_process_panel_update(void *data);
|
||||
Evas_Object *main_view;
|
||||
Evas_Object *info_view;
|
||||
Evas_Object *thread_view;
|
||||
|
||||
Evas_Object *entry_pid_cmd;
|
||||
Evas_Object *entry_pid_cmd_args;
|
||||
Evas_Object *entry_pid_user;
|
||||
Evas_Object *entry_pid_pid;
|
||||
Evas_Object *entry_pid_uid;
|
||||
Evas_Object *entry_pid_cpu;
|
||||
Evas_Object *entry_pid_threads;
|
||||
Evas_Object *entry_pid_virt;
|
||||
Evas_Object *entry_pid_rss;
|
||||
Evas_Object *entry_pid_shared;
|
||||
Evas_Object *entry_pid_size;
|
||||
Evas_Object *entry_pid_nice;
|
||||
Evas_Object *entry_pid_pri;
|
||||
Evas_Object *entry_pid_state;
|
||||
Evas_Object *entry_pid_cpu_usage;
|
||||
|
||||
int poll_delay;
|
||||
int selected_pid;
|
||||
int64_t pid_cpu_time;
|
||||
|
||||
Ecore_Timer *timer_pid;
|
||||
} Ui_Process;
|
||||
|
||||
void
|
||||
ui_process_win_add(int pid, const char *cmd);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue