small tidy: makes editing easier.

If someone wants to split each window out or have an idea wtf is
happening this makes more sense...just..
This commit is contained in:
Alastair Poole 2020-10-03 11:35:36 +01:00
parent 3f9a131554
commit 45a1eef26f
7 changed files with 97 additions and 123 deletions

View File

@ -70,16 +70,6 @@
#include "machine/sensors.bogox"
#include "machine/network.bogox"
static void *
_network_transfer_get_thread_cb(void *arg)
{
network_t *usage = arg;
system_network_transfer_get(usage);
return NULL;
}
void
system_info_all_free(Sys_Info *info)
{
@ -118,9 +108,6 @@ Sys_Info *
system_info_all_get(void)
{
Sys_Info *info;
void *ret;
pthread_t tid;
int error;
info = calloc(1, sizeof(Sys_Info));
if (!info) return NULL;
@ -129,19 +116,9 @@ system_info_all_get(void)
system_memory_usage_get(&info->memory);
error = pthread_create(&tid, NULL, _network_transfer_get_thread_cb,
&info->network_usage);
if (error)
system_network_transfer_get(&info->network_usage);
system_power_state_get(&info->power);
info->sensors = system_sensors_thermal_get(&info->sensor_count);
if (!error)
{
ret = NULL;
pthread_join(tid, ret);
}
info->sensors = system_sensors_thermal_get(&info->sensor_count);
return info;
}

View File

@ -646,30 +646,22 @@ _process_list(void *data, Ecore_Thread *thread)
}
}
Evas_Object *_selected;
static void
_btn_icon_state_update(Evas_Object *button, Eina_Bool reverse)
{
Evas_Object *icon = elm_icon_add(button);
if (_selected)
evas_object_color_set(_selected, 255, 255, 255, 255);
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"));
_selected = icon;
evas_object_color_set(_selected, 255, 255, 255, 255);
elm_object_part_content_set(button, "icon", icon);
evas_object_show(icon);
}
static void
_btn_icon_state_init(Evas_Object *button, Eina_Bool reverse, Eina_Bool selected)
_btn_icon_state_init(Evas_Object *button, Eina_Bool reverse, Eina_Bool selected EINA_UNUSED)
{
Evas_Object *icon = elm_icon_add(button);
@ -678,14 +670,6 @@ _btn_icon_state_init(Evas_Object *button, Eina_Bool reverse, Eina_Bool selected)
else
elm_icon_standard_set(icon, evisum_icon_path_get("go-up"));
if (!selected)
evas_object_color_set(icon, 255, 255, 255, 255);
else
{
_selected = icon;
evas_object_color_set(icon, 255, 255, 255, 255);
}
elm_object_part_content_set(button, "icon", icon);
evas_object_show(icon);
}
@ -1580,9 +1564,6 @@ evisum_ui_shutdown(Ui *ui)
evas_object_del(ui->win);
if (ui->timer_pid)
ecore_timer_del(ui->timer_pid);
if (ui->thread_system)
ecore_thread_cancel(ui->thread_system);
@ -1595,14 +1576,14 @@ evisum_ui_shutdown(Ui *ui)
if (ui->thread_process)
ecore_thread_wait(ui->thread_process, 1.0);
if (ui->win_cpu)
evas_object_smart_callback_call(ui->win_cpu, "delete,request", NULL);
if (ui->win_mem)
evas_object_smart_callback_call(ui->win_mem, "delete,request", NULL);
if (ui->win_disk)
evas_object_smart_callback_call(ui->win_disk, "delete,request", NULL);
if (ui->win_misc)
evas_object_smart_callback_call(ui->win_misc, "delete,request", NULL);
if (ui->cpu.win)
evas_object_smart_callback_call(ui->cpu.win, "delete,request", NULL);
if (ui->mem.win)
evas_object_smart_callback_call(ui->mem.win, "delete,request", NULL);
if (ui->disk.win)
evas_object_smart_callback_call(ui->disk.win, "delete,request", NULL);
if (ui->misc.win)
evas_object_smart_callback_call(ui->misc.win, "delete,request", NULL);
if (ui->win_about)
evas_object_smart_callback_call(ui->win_about, "delete,request", NULL);
@ -1682,7 +1663,7 @@ _system_info_all_poll_feedback_cb(void *data, Ecore_Thread *thread, void *msg)
ui->cpu_usage = cpu_usage;
if (ui->zfs_mounted)
if (ui->mem.zfs_mounted)
info->memory.used += info->memory.zfs_arc_used;
pb = ui->progress_mem;
@ -1692,8 +1673,6 @@ _system_info_all_poll_feedback_cb(void *data, Ecore_Thread *thread, void *msg)
elm_progressbar_unit_format_set(pb, eina_slstr_printf("%s / %s",
evisum_size_format(info->memory.used),
evisum_size_format(info->memory.total)));
ui->network_usage = info->network_usage;
out:
system_info_all_free(info);
}
@ -1733,6 +1712,12 @@ _ui_launch(Ui *ui)
ecore_event_handler_add(ELM_EVENT_CONFIG_ALL_CHANGED, _elm_config_change_cb, ui);
}
static void
_ui_init_system_probe(Ui *ui)
{
ui->mem.zfs_mounted = file_system_in_use("ZFS");
}
static Ui *
_ui_init(Evas_Object *parent)
{
@ -1748,11 +1733,10 @@ _ui_init(Evas_Object *parent)
ui->cpu_times = NULL;
ui->cpu_list = NULL;
ui->zfs_mounted = file_system_in_use("ZFS");
_ui_init_system_probe(ui);
_ui = NULL;
_evisum_config = NULL;
_selected = NULL;
_config_load(ui);

View File

@ -39,15 +39,8 @@ typedef struct Ui
Evas_Object *scroller;
Evas_Object *content;
Evas_Object *win_cpu;
Evas_Object *win_mem;
Evas_Object *win_disk;
Evas_Object *win_misc;
Evas_Object *win_about;
Evas_Object *disk_activity;
Evas_Object *misc_activity;
Evas_Object *progress_cpu;
Evas_Object *progress_mem;
@ -65,12 +58,35 @@ typedef struct Ui
Ecore_Thread *thread_system;
Ecore_Thread *thread_process;
Ecore_Thread *thread_cpu;
Ecore_Timer *timer_pid;
Ecore_Timer *timer_memory;
Ecore_Timer *timer_disk;
Ecore_Timer *timer_misc;
struct
{
Evas_Object *win;
Ecore_Thread *thread;
} cpu;
struct
{
Evas_Object *win;
Ecore_Timer *timer;
Eina_Bool zfs_mounted;
} mem;
struct
{
Evas_Object *win;
Evas_Object *box;
Ecore_Timer *timer;
} disk;
struct
{
Evas_Object *win;
Evas_Object *box;
Evas_Object *timer;
uint64_t incoming_max;
uint64_t outgoing_max;
} misc;
pid_t selected_pid;
pid_t program_pid;
@ -91,11 +107,6 @@ typedef struct Ui
Eina_Bool shutdown_now;
Ecore_Animator *animator;
Eina_Bool zfs_mounted;
uint64_t incoming_max;
uint64_t outgoing_max;
network_t network_usage;
uint8_t cpu_usage;
} Ui;

View File

@ -250,10 +250,10 @@ _win_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void
// on deletion of window, cancel thread, free animate data and set cpu
// dialog handle to null
ecore_thread_cancel(ui->thread_cpu);
ecore_thread_wait(ui->thread_cpu, 0.5);
ecore_thread_cancel(ui->cpu.thread);
ecore_thread_wait(ui->cpu.thread, 0.5);
free(ad);
ui->win_cpu = NULL;
ui->cpu.win = NULL;
}
static void
@ -467,10 +467,10 @@ _graph(Ui *ui, Evas_Object *parent)
evas_object_smart_callback_add(check, "changed", _check_changed_cb, ad);
// since win is on auto-delete, just listen for when it is deleted,
// whatever the cause/reason
evas_object_event_callback_add(ui->win_cpu, EVAS_CALLBACK_DEL, _win_del_cb, ad);
evas_object_event_callback_add(ui->cpu.win, EVAS_CALLBACK_DEL, _win_del_cb, ad);
// run a feedback thread that sends feedback to the mainloop
ui->thread_cpu = ecore_thread_feedback_run(_core_times_main_cb,
ui->cpu.thread = ecore_thread_feedback_run(_core_times_main_cb,
_core_times_feedback_cb,
NULL,
NULL,
@ -482,13 +482,13 @@ ui_win_cpu_add(Ui *ui)
{
Evas_Object *win, *box, *scroller;
if (ui->win_cpu)
if (ui->cpu.win)
{
elm_win_raise(ui->win_cpu);
elm_win_raise(ui->cpu.win);
return;
}
ui->win_cpu = win = elm_win_util_standard_add("evisum",
ui->cpu.win = win = elm_win_util_standard_add("evisum",
_("CPU Usage"));
elm_win_autodel_set(win, EINA_TRUE);
evas_object_size_hint_weight_set(win, EXPAND, EXPAND);

View File

@ -76,7 +76,7 @@ _ui_item_disk_add(Ui *ui, File_System *inf)
type = file_system_name_by_id(inf->type);
if (!type) type = "unknown";
parent = ui->disk_activity;
parent = ui->disk.box;
frame = elm_frame_add(parent);
evas_object_size_hint_align_set(frame, FILL, 0);
@ -190,7 +190,7 @@ _disks_poll_timer_cb(void *data)
{
item = _ui_item_disk_add(ui, fs);
eina_hash_add(_mounted, eina_slstr_printf("%s:%s", fs->path, fs->mount), item);
elm_box_pack_end(ui->disk_activity, item->parent);
elm_box_pack_end(ui->disk.box, item->parent);
}
file_system_info_free(fs);
}
@ -208,13 +208,13 @@ _disks_poll_timer_cb(void *data)
file_system_info_free(fs);
else
{
elm_box_unpack(ui->disk_activity, item->parent);
elm_box_unpack(ui->disk.box, item->parent);
evas_object_del(item->parent);
eina_hash_del(_mounted, NULL, item);
}
}
eina_iterator_free(it);
elm_box_recalculate(ui->disk_activity);
elm_box_recalculate(ui->disk.box);
return EINA_TRUE;
}
@ -225,15 +225,15 @@ _win_del_cb(void *data, Evas_Object *obj EINA_UNUSED,
{
Ui *ui = data;
if (ui->timer_disk)
ecore_timer_del(ui->timer_disk);
ui->timer_disk = NULL;
if (ui->disk.timer)
ecore_timer_del(ui->disk.timer);
ui->disk.timer = NULL;
eina_hash_free(_mounted);
_mounted = NULL;
evas_object_del(obj);
ui->win_disk = NULL;
ui->disk.win = NULL;
}
void
@ -242,15 +242,15 @@ ui_win_disk_add(Ui *ui)
Evas_Object *win, *box, *vbox, *scroller;
Evas_Object *table, *rect;
if (ui->win_disk)
if (ui->disk.win)
{
elm_win_raise(ui->win_disk);
elm_win_raise(ui->disk.win);
return;
}
_mounted = eina_hash_string_superfast_new(_hash_free_cb);
ui->win_disk = win = elm_win_util_standard_add("evisum",
ui->disk.win = win = elm_win_util_standard_add("evisum",
_("Storage"));
evas_object_size_hint_weight_set(win, EXPAND, EXPAND);
evas_object_size_hint_align_set(win, FILL, FILL);
@ -261,7 +261,7 @@ ui_win_disk_add(Ui *ui)
evas_object_size_hint_align_set(box, FILL, FILL);
evas_object_show(box);
ui->disk_activity = vbox = elm_box_add(win);
ui->disk.box = vbox = elm_box_add(win);
evas_object_size_hint_weight_set(vbox, EXPAND, 0.0);
evas_object_size_hint_align_set(vbox, FILL, 0.5);
evas_object_show(vbox);
@ -294,6 +294,6 @@ ui_win_disk_add(Ui *ui)
_disks_poll_timer_cb(ui);
ui->timer_disk = ecore_timer_add(3.0, _disks_poll_timer_cb, ui);
ui->disk.timer = ecore_timer_add(3.0, _disks_poll_timer_cb, ui);
}

View File

@ -109,14 +109,14 @@ _win_del_cb(void *data, Evas_Object *obj,
Widgets *widgets;
Ui *ui = data;
ecore_timer_del(ui->timer_memory);
ui->timer_memory = NULL;
ecore_timer_del(ui->mem.timer);
ui->mem.timer = NULL;
widgets = evas_object_data_get(obj, "widgets");
if (widgets) free(widgets);
evas_object_del(obj);
ui->win_mem = NULL;
ui->mem.win = NULL;
}
void
@ -125,16 +125,16 @@ ui_win_memory_add(Ui *ui)
Evas_Object *win, *frame, *pb;
Evas_Object *border, *rect, *label, *table;
if (ui->win_mem)
if (ui->mem.win)
{
elm_win_raise(ui->win_mem);
elm_win_raise(ui->mem.win);
return;
}
Widgets *widgets = calloc(1, sizeof(Widgets));
if (!widgets) return;
ui->win_mem = win = elm_win_util_standard_add("evisum",
ui->mem.win = win = elm_win_util_standard_add("evisum",
_("Memory Usage"));
evas_object_size_hint_weight_set(win, EXPAND, EXPAND);
evas_object_size_hint_align_set(win, FILL, FILL);
@ -205,5 +205,5 @@ ui_win_memory_add(Ui *ui)
_memory_update(widgets);
ui->timer_memory = ecore_timer_add(ui->poll_delay, _memory_update, widgets);
ui->mem.timer = ecore_timer_add(ui->poll_delay, _memory_update, widgets);
}

View File

@ -212,15 +212,15 @@ _network_usage_add(Ui *ui, Evas_Object *box, uint64_t bytes, Eina_Bool incoming)
{
if (incoming)
{
if (ui->incoming_max < bytes)
ui->incoming_max = bytes;
elm_progressbar_value_set(pb, (double) bytes / ui->incoming_max);
if (ui->misc.incoming_max < bytes)
ui->misc.incoming_max = bytes;
elm_progressbar_value_set(pb, (double) bytes / ui->misc.incoming_max);
}
else
{
if (ui->outgoing_max < bytes)
ui->outgoing_max = bytes;
elm_progressbar_value_set(pb, (double) bytes / ui->outgoing_max);
if (ui->misc.outgoing_max < bytes)
ui->misc.outgoing_max = bytes;
elm_progressbar_value_set(pb, (double) bytes / ui->misc.outgoing_max);
}
}
@ -283,19 +283,21 @@ _misc_update(void *data)
power_t power;
sensor_t **sensors;
int sensor_count = 0;
network_t usage;
Evas_Object *box, *frame;
ui = data;
elm_box_clear(ui->misc_activity);
elm_box_clear(ui->misc.box);
box = elm_box_add(ui->misc_activity);
box = elm_box_add(ui->misc.box);
evas_object_size_hint_align_set(box, FILL, FILL);
evas_object_size_hint_weight_set(box, EXPAND, EXPAND);
evas_object_show(box);
_network_usage_add(ui, box, ui->network_usage.incoming, EINA_TRUE);
_network_usage_add(ui, box, ui->network_usage.outgoing, EINA_FALSE);
system_network_transfer_get(&usage);
_network_usage_add(ui, box, usage.incoming, EINA_TRUE);
_network_usage_add(ui, box, usage.outgoing, EINA_FALSE);
_separator_add(box);
memset(&power, 0, sizeof(power));
@ -313,13 +315,13 @@ _misc_update(void *data)
_misc_free(&power, sensors, sensor_count);
frame = elm_frame_add(ui->misc_activity);
frame = elm_frame_add(ui->misc.box);
evas_object_size_hint_align_set(frame, FILL, FILL);
evas_object_size_hint_weight_set(frame, EXPAND, EXPAND);
elm_object_style_set(frame, "pad_huge");
evas_object_show(frame);
elm_object_content_set(frame, box);
elm_box_pack_end(ui->misc_activity, frame);
elm_box_pack_end(ui->misc.box, frame);
return EINA_TRUE;
}
@ -330,12 +332,12 @@ _win_del_cb(void *data, Evas_Object *obj EINA_UNUSED,
{
Ui *ui = data;
if (ui->timer_misc)
ecore_timer_del(ui->timer_misc);
ui->timer_misc = NULL;
if (ui->misc.timer)
ecore_timer_del(ui->misc.timer);
ui->misc.timer = NULL;
evas_object_del(obj);
ui->win_misc = NULL;
ui->misc.win = NULL;
}
void
@ -344,13 +346,13 @@ ui_win_misc_add(Ui *ui)
Evas_Object *win, *box, *hbox, *frame, *scroller;
Evas_Object *table, *border, *rect;
if (ui->win_misc)
if (ui->misc.win)
{
elm_win_raise(ui->win_misc);
elm_win_raise(ui->misc.win);
return;
}
ui->win_misc = win = elm_win_util_standard_add("evisum", _("Misc"));
ui->misc.win = win = elm_win_util_standard_add("evisum", _("Misc"));
evas_object_size_hint_weight_set(win, EXPAND, EXPAND);
evas_object_size_hint_align_set(win, FILL, FILL);
evisum_ui_background_random_add(win, evisum_ui_effects_enabled_get());
@ -360,7 +362,7 @@ ui_win_misc_add(Ui *ui)
evas_object_size_hint_align_set(box, FILL, FILL);
evas_object_hide(box);
ui->misc_activity = hbox = elm_box_add(box);
ui->misc.box = hbox = elm_box_add(box);
evas_object_size_hint_weight_set(hbox, EXPAND, EXPAND);
evas_object_size_hint_align_set(hbox, FILL, FILL);
evas_object_show(hbox);
@ -407,6 +409,6 @@ ui_win_misc_add(Ui *ui)
_misc_update(ui);
ui->timer_misc = ecore_timer_add(3.0, _misc_update, ui);
ui->misc.timer = ecore_timer_add(3.0, _misc_update, ui);
}