win: More descriptive struct.

Win Data / Data / Program Data ? Private Data ?
This commit is contained in:
Alastair Poole 2021-03-29 10:10:51 +01:00
parent 726a705275
commit 5b08043f8b
5 changed files with 995 additions and 995 deletions

View File

@ -18,23 +18,23 @@ typedef struct
Eina_Bool skip_wait;
Evisum_Ui *ui;
} Data;
} Win_Data;
static void
_item_unrealized_cb(void *data, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Data *pd;
Win_Data *wd;
Evas_Object *o;
Eina_List *contents = NULL;
pd = data;
wd = data;
elm_genlist_item_all_contents_unset(event_info, &contents);
EINA_LIST_FREE(contents, o)
{
evisum_ui_item_cache_item_release(pd->cache, o);
evisum_ui_item_cache_item_release(wd->cache, o);
}
}
@ -102,77 +102,77 @@ _content_get(void *data, Evas_Object *obj, const char *source)
{
Evas_Object *lb, *r, *pb;
Evas_Coord w, ow;
Data *pd;
Win_Data *wd;
File_System *inf = data;
if (!inf) return NULL;
if (strcmp(source, "elm.swallow.content")) return NULL;
pd = evas_object_data_get(obj, "private");
if (!pd) return NULL;
wd = evas_object_data_get(obj, "private");
if (!wd) return NULL;
Item_Cache *it = evisum_ui_item_cache_item_get(pd->cache);
Item_Cache *it = evisum_ui_item_cache_item_get(wd->cache);
if (!it)
{
fprintf(stderr, "Error: Object cache creation failed.\n");
exit(-1);
}
evas_object_geometry_get(pd->btn_device, NULL, NULL, &w, NULL);
evas_object_geometry_get(wd->btn_device, NULL, NULL, &w, NULL);
lb = evas_object_data_get(it->obj, "device");
elm_object_text_set(lb, eina_slstr_printf("%s", inf->path));
evas_object_geometry_get(lb, NULL, NULL, &ow, NULL);
if (ow > w) evas_object_size_hint_min_set(pd->btn_device, w, 1);
if (ow > w) evas_object_size_hint_min_set(wd->btn_device, w, 1);
r = evas_object_data_get(lb, "rec");
evas_object_size_hint_min_set(r, w, 1);
evas_object_show(lb);
evas_object_geometry_get(pd->btn_mount, NULL, NULL, &w, NULL);
evas_object_geometry_get(wd->btn_mount, NULL, NULL, &w, NULL);
lb = evas_object_data_get(it->obj, "mount");
elm_object_text_set(lb, eina_slstr_printf("%s", inf->mount));
evas_object_geometry_get(lb, NULL, NULL, &ow, NULL);
if (ow > w) evas_object_size_hint_min_set(pd->btn_mount, w, 1);
if (ow > w) evas_object_size_hint_min_set(wd->btn_mount, w, 1);
r = evas_object_data_get(lb, "rec");
evas_object_size_hint_min_set(r, w, 1);
evas_object_show(lb);
evas_object_geometry_get(pd->btn_fs, NULL, NULL, &w, NULL);
evas_object_geometry_get(wd->btn_fs, NULL, NULL, &w, NULL);
lb = evas_object_data_get(it->obj, "fs");
elm_object_text_set(lb, eina_slstr_printf("%s", inf->type_name));
evas_object_geometry_get(lb, NULL, NULL, &ow, NULL);
if (ow > w) evas_object_size_hint_min_set(pd->btn_fs, w, 1);
if (ow > w) evas_object_size_hint_min_set(wd->btn_fs, w, 1);
r = evas_object_data_get(lb, "rec");
evas_object_size_hint_min_set(r, w, 1);
evas_object_show(lb);
evas_object_geometry_get(pd->btn_total, NULL, NULL, &w, NULL);
evas_object_geometry_get(wd->btn_total, NULL, NULL, &w, NULL);
lb = evas_object_data_get(it->obj, "total");
elm_object_text_set(lb, eina_slstr_printf("%s", evisum_size_format(inf->usage.total)));
evas_object_geometry_get(lb, NULL, NULL, &ow, NULL);
if (ow > w) evas_object_size_hint_min_set(pd->btn_total, w, 1);
if (ow > w) evas_object_size_hint_min_set(wd->btn_total, w, 1);
r = evas_object_data_get(lb, "rec");
evas_object_size_hint_min_set(r, w, 1);
evas_object_show(lb);
evas_object_geometry_get(pd->btn_used, NULL, NULL, &w, NULL);
evas_object_geometry_get(wd->btn_used, NULL, NULL, &w, NULL);
lb = evas_object_data_get(it->obj, "used");
elm_object_text_set(lb, eina_slstr_printf("%s", evisum_size_format(inf->usage.used)));
evas_object_geometry_get(lb, NULL, NULL, &ow, NULL);
if (ow > w) evas_object_size_hint_min_set(pd->btn_used, ow, 1);
if (ow > w) evas_object_size_hint_min_set(wd->btn_used, ow, 1);
r = evas_object_data_get(lb, "rec");
evas_object_size_hint_min_set(r, w, 1);
evas_object_show(lb);
evas_object_geometry_get(pd->btn_free, NULL, NULL, &w, NULL);
evas_object_geometry_get(wd->btn_free, NULL, NULL, &w, NULL);
lb = evas_object_data_get(it->obj, "free");
int64_t avail = inf->usage.total - inf->usage.used;
elm_object_text_set(lb, eina_slstr_printf("%s", evisum_size_format(avail)));
evas_object_geometry_get(lb, NULL, NULL, &ow, NULL);
if (ow > w) evas_object_size_hint_min_set(pd->btn_free, ow, 1);
if (ow > w) evas_object_size_hint_min_set(wd->btn_free, ow, 1);
r = evas_object_data_get(lb, "rec");
evas_object_size_hint_min_set(r, w, 1);
evas_object_show(lb);
evas_object_geometry_get(pd->btn_usage, NULL, NULL, &w, NULL);
evas_object_geometry_get(wd->btn_usage, NULL, NULL, &w, NULL);
pb = evas_object_data_get(it->obj, "usage");
elm_progressbar_value_set(pb, (double) (inf->usage.used / (inf->usage.total / 100.0) / 100.0));
evas_object_show(pb);
@ -218,15 +218,15 @@ _glist_ensure_n_items(Evas_Object *glist, unsigned int items)
static void
_disks_poll(void *data, Ecore_Thread *thread)
{
Data *pd = data;
Win_Data *wd = data;
while (!ecore_thread_check(thread))
{
for (int i = 0; i < 8; i++)
{
if (pd->skip_wait)
if (wd->skip_wait)
{
pd->skip_wait = 0;
wd->skip_wait = 0;
break;
}
if (ecore_thread_check(thread))
@ -242,19 +242,19 @@ _disks_poll_feedback_cb(void *data, Ecore_Thread *thread, void *msgdata)
{
Elm_Object_Item *it;
File_System *fs;
Data *pd;
Win_Data *wd;
Eina_List *mounted;
pd = data;
wd = data;
mounted = msgdata;
if (pd->sort_cb)
mounted = eina_list_sort(mounted, eina_list_count(mounted), pd->sort_cb);
if (pd->sort_reverse) mounted = eina_list_reverse(mounted);
if (wd->sort_cb)
mounted = eina_list_sort(mounted, eina_list_count(mounted), wd->sort_cb);
if (wd->sort_reverse) mounted = eina_list_reverse(mounted);
_glist_ensure_n_items(pd->glist, eina_list_count(mounted));
_glist_ensure_n_items(wd->glist, eina_list_count(mounted));
it = elm_genlist_first_item_get(pd->glist);
it = elm_genlist_first_item_get(wd->glist);
EINA_LIST_FREE(mounted, fs)
{
File_System *prev = elm_object_item_data_get(it);
@ -263,39 +263,39 @@ _disks_poll_feedback_cb(void *data, Ecore_Thread *thread, void *msgdata)
elm_genlist_item_update(it);
it = elm_genlist_item_next_get(it);
}
elm_genlist_realized_items_update(pd->glist);
elm_genlist_realized_items_update(wd->glist);
}
static void
_disks_poll_update(Data *pd)
_disks_poll_update(Win_Data *wd)
{
pd->skip_wait = 1;
wd->skip_wait = 1;
}
static void
_win_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Evas_Event_Key_Down *ev;
Data *pd;
Win_Data *wd;
pd = data;
wd = data;
ev = event_info;
if (!ev || !ev->keyname)
return;
if (!strcmp(ev->keyname, "Escape"))
evas_object_del(pd->ui->disk.win);
evas_object_del(wd->ui->disk.win);
}
static void
_win_move_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
{
Data *pd;
Win_Data *wd;
Evisum_Ui *ui;
pd = data;
ui = pd->ui;
wd = data;
ui = wd->ui;
evas_object_geometry_get(obj, &ui->disk.x, &ui->disk.y, NULL, NULL);
}
@ -304,18 +304,18 @@ static void
_win_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Data *pd;
Win_Data *wd;
Evisum_Ui *ui;
pd = data;
ui = pd->ui;
wd = data;
ui = wd->ui;
evisum_ui_config_save(ui);
ecore_thread_cancel(pd->thread);
ecore_thread_wait(pd->thread, 0.5);
ecore_thread_cancel(wd->thread);
ecore_thread_wait(wd->thread, 0.5);
evisum_ui_item_cache_free(pd->cache);
free(pd);
evisum_ui_item_cache_free(wd->cache);
free(wd);
ui->disk.win = NULL;
}
@ -437,107 +437,107 @@ static void
_btn_device_clicked_cb(void *data EINA_UNUSED, Evas_Object *obj,
void *event_info EINA_UNUSED)
{
Data *pd = data;
Win_Data *wd = data;
if (pd->sort_cb == _sort_by_device)
pd->sort_reverse = !pd->sort_reverse;
if (wd->sort_cb == _sort_by_device)
wd->sort_reverse = !wd->sort_reverse;
pd->sort_cb = _sort_by_device;
_btn_icon_state_set(obj, pd->sort_reverse);
_disks_poll_update(pd);
wd->sort_cb = _sort_by_device;
_btn_icon_state_set(obj, wd->sort_reverse);
_disks_poll_update(wd);
}
static void
_btn_mount_clicked_cb(void *data EINA_UNUSED, Evas_Object *obj,
void *event_info EINA_UNUSED)
{
Data *pd = data;
Win_Data *wd = data;
if (pd->sort_cb == _sort_by_mount)
pd->sort_reverse = !pd->sort_reverse;
if (wd->sort_cb == _sort_by_mount)
wd->sort_reverse = !wd->sort_reverse;
pd->sort_cb = _sort_by_mount;
_btn_icon_state_set(obj, pd->sort_reverse);
_disks_poll_update(pd);
wd->sort_cb = _sort_by_mount;
_btn_icon_state_set(obj, wd->sort_reverse);
_disks_poll_update(wd);
}
static void
_btn_fs_clicked_cb(void *data EINA_UNUSED, Evas_Object *obj,
void *event_info EINA_UNUSED)
{
Data *pd = data;
Win_Data *wd = data;
if (pd->sort_cb == _sort_by_type)
pd->sort_reverse = !pd->sort_reverse;
if (wd->sort_cb == _sort_by_type)
wd->sort_reverse = !wd->sort_reverse;
pd->sort_cb = _sort_by_type;
_btn_icon_state_set(obj, pd->sort_reverse);
_disks_poll_update(pd);
wd->sort_cb = _sort_by_type;
_btn_icon_state_set(obj, wd->sort_reverse);
_disks_poll_update(wd);
}
static void
_btn_used_clicked_cb(void *data EINA_UNUSED, Evas_Object *obj,
void *event_info EINA_UNUSED)
{
Data *pd = data;
Win_Data *wd = data;
if (pd->sort_cb == _sort_by_used)
pd->sort_reverse = !pd->sort_reverse;
if (wd->sort_cb == _sort_by_used)
wd->sort_reverse = !wd->sort_reverse;
pd->sort_cb = _sort_by_used;
_btn_icon_state_set(obj, pd->sort_reverse);
_disks_poll_update(pd);
wd->sort_cb = _sort_by_used;
_btn_icon_state_set(obj, wd->sort_reverse);
_disks_poll_update(wd);
}
static void
_btn_free_clicked_cb(void *data EINA_UNUSED, Evas_Object *obj,
void *event_info EINA_UNUSED)
{
Data *pd = data;
Win_Data *wd = data;
if (pd->sort_cb == _sort_by_free)
pd->sort_reverse = !pd->sort_reverse;
if (wd->sort_cb == _sort_by_free)
wd->sort_reverse = !wd->sort_reverse;
pd->sort_cb = _sort_by_free;
_btn_icon_state_set(obj, pd->sort_reverse);
_disks_poll_update(pd);
wd->sort_cb = _sort_by_free;
_btn_icon_state_set(obj, wd->sort_reverse);
_disks_poll_update(wd);
}
static void
_btn_total_clicked_cb(void *data EINA_UNUSED, Evas_Object *obj,
void *event_info EINA_UNUSED)
{
Data *pd = data;
Win_Data *wd = data;
if (pd->sort_cb == _sort_by_total)
pd->sort_reverse = !pd->sort_reverse;
if (wd->sort_cb == _sort_by_total)
wd->sort_reverse = !wd->sort_reverse;
pd->sort_cb = _sort_by_total;
_btn_icon_state_set(obj, pd->sort_reverse);
_disks_poll_update(pd);
wd->sort_cb = _sort_by_total;
_btn_icon_state_set(obj, wd->sort_reverse);
_disks_poll_update(wd);
}
static void
_btn_usage_clicked_cb(void *data EINA_UNUSED, Evas_Object *obj,
void *event_info EINA_UNUSED)
{
Data *pd = data;
Win_Data *wd = data;
if (pd->sort_cb == _sort_by_cpu_usage)
pd->sort_reverse = !pd->sort_reverse;
if (wd->sort_cb == _sort_by_cpu_usage)
wd->sort_reverse = !wd->sort_reverse;
pd->sort_cb = _sort_by_cpu_usage;
_btn_icon_state_set(obj, pd->sort_reverse);
_disks_poll_update(pd);
wd->sort_cb = _sort_by_cpu_usage;
_btn_icon_state_set(obj, wd->sort_reverse);
_disks_poll_update(wd);
}
static void
_win_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Data *pd = data;
Evisum_Ui *ui = pd->ui;
Win_Data *wd = data;
Evisum_Ui *ui = wd->ui;
_disks_poll_update(pd);
_disks_poll_update(wd);
evas_object_geometry_get(obj, NULL, NULL, &ui->disk.width, &ui->disk.height);
}
@ -568,9 +568,9 @@ ui_disk_win_add(Evisum_Ui *ui)
evas_object_size_hint_weight_set(win, EXPAND, EXPAND);
evas_object_size_hint_align_set(win, FILL, FILL);
Data *pd = calloc(1, sizeof(Data));
pd->ui = ui;
pd->skip_wait = 1;
Win_Data *wd = calloc(1, sizeof(Win_Data));
wd->ui = ui;
wd->skip_wait = 1;
tb = elm_table_add(win);
evas_object_size_hint_weight_set(tb, EXPAND, EXPAND);
@ -582,71 +582,71 @@ ui_disk_win_add(Evisum_Ui *ui)
evas_object_size_hint_max_set(rec, -1, ELM_SCALE_SIZE(LIST_BTN_HEIGHT));
elm_table_pack(tb, rec, i++, 0, 1, 1);
pd->btn_device = btn = elm_button_add(win);
wd->btn_device = btn = elm_button_add(win);
evas_object_size_hint_weight_set(btn, EXPAND, EXPAND);
evas_object_size_hint_align_set(btn, FILL, FILL);
elm_object_text_set(btn, _("device"));
evas_object_smart_callback_add(btn, "clicked", _btn_device_clicked_cb, pd);
evas_object_smart_callback_add(btn, "clicked", _btn_device_clicked_cb, wd);
_btn_icon_state_set(btn, 0);
elm_table_pack(tb, btn, i++, 0, 1, 1);
evas_object_show(btn);
pd->btn_mount = btn = elm_button_add(win);
wd->btn_mount = btn = elm_button_add(win);
evas_object_size_hint_weight_set(btn, EXPAND, EXPAND);
evas_object_size_hint_align_set(btn, FILL, FILL);
elm_object_text_set(btn, _("mount"));
evas_object_smart_callback_add(btn, "clicked", _btn_mount_clicked_cb, pd);
evas_object_smart_callback_add(btn, "clicked", _btn_mount_clicked_cb, wd);
_btn_icon_state_set(btn, 0);
elm_table_pack(tb, btn, i++, 0, 1, 1);
evas_object_show(btn);
pd->btn_fs = btn = elm_button_add(win);
wd->btn_fs = btn = elm_button_add(win);
evas_object_size_hint_weight_set(btn, EXPAND, EXPAND);
evas_object_size_hint_align_set(btn, FILL, FILL);
elm_object_text_set(btn, _("type"));
evas_object_smart_callback_add(btn, "clicked", _btn_fs_clicked_cb, pd);
evas_object_smart_callback_add(btn, "clicked", _btn_fs_clicked_cb, wd);
_btn_icon_state_set(btn, 0);
elm_table_pack(tb, btn, i++, 0, 1, 1);
evas_object_show(btn);
pd->btn_total = btn = elm_button_add(win);
wd->btn_total = btn = elm_button_add(win);
evas_object_size_hint_weight_set(btn, 0, EXPAND);
evas_object_size_hint_align_set(btn, FILL, FILL);
elm_object_text_set(btn, _("total"));
evas_object_smart_callback_add(btn, "clicked", _btn_total_clicked_cb, pd);
evas_object_smart_callback_add(btn, "clicked", _btn_total_clicked_cb, wd);
_btn_icon_state_set(btn, 0);
rec = _btn_min_size(btn);
elm_table_pack(tb, rec, i, i, 1, 1);
elm_table_pack(tb, btn, i++, 0, 1, 1);
evas_object_show(btn);
pd->btn_used = btn = elm_button_add(win);
wd->btn_used = btn = elm_button_add(win);
evas_object_size_hint_weight_set(btn, 0, EXPAND);
evas_object_size_hint_align_set(btn, FILL, FILL);
elm_object_text_set(btn, _("used"));
evas_object_smart_callback_add(btn, "clicked", _btn_used_clicked_cb, pd);
evas_object_smart_callback_add(btn, "clicked", _btn_used_clicked_cb, wd);
_btn_icon_state_set(btn, 0);
rec = _btn_min_size(btn);
elm_table_pack(tb, rec, i, i, 1, 1);
elm_table_pack(tb, btn, i++, 0, 1, 1);
evas_object_show(btn);
pd->btn_free = btn = elm_button_add(win);
wd->btn_free = btn = elm_button_add(win);
evas_object_size_hint_weight_set(btn, 0, EXPAND);
evas_object_size_hint_align_set(btn, FILL, FILL);
elm_object_text_set(btn, _("free"));
evas_object_smart_callback_add(btn, "clicked", _btn_free_clicked_cb, pd);
evas_object_smart_callback_add(btn, "clicked", _btn_free_clicked_cb, wd);
_btn_icon_state_set(btn, 0);
rec = _btn_min_size(btn);
elm_table_pack(tb, rec, i, i, 1, 1);
elm_table_pack(tb, btn, i++, 0, 1, 1);
evas_object_show(btn);
pd->btn_usage = btn = elm_button_add(win);
wd->btn_usage = btn = elm_button_add(win);
evas_object_size_hint_weight_set(btn, EXPAND, EXPAND);
evas_object_size_hint_align_set(btn, FILL, FILL);
elm_object_text_set(btn, _("usage"));
evas_object_smart_callback_add(btn, "clicked", _btn_usage_clicked_cb, pd);
evas_object_smart_callback_add(btn, "clicked", _btn_usage_clicked_cb, wd);
_btn_icon_state_set(btn, 0);
elm_table_pack(tb, btn, i++, 0, 1, 1);
evas_object_show(btn);
@ -656,19 +656,19 @@ ui_disk_win_add(Evisum_Ui *ui)
evas_object_size_hint_align_set(scr, FILL, FILL);
elm_scroller_policy_set(scr,
ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
pd->glist = glist = elm_genlist_add(win);
wd->glist = glist = elm_genlist_add(win);
elm_object_focus_allow_set(glist, 0);
evas_object_data_set(glist, "private", pd);
evas_object_data_set(glist, "private", wd);
elm_genlist_select_mode_set(glist, ELM_OBJECT_SELECT_MODE_NONE);
evas_object_size_hint_weight_set(glist, EXPAND, EXPAND);
evas_object_size_hint_align_set(glist, FILL, FILL);
evas_object_smart_callback_add(glist, "unrealized", _item_unrealized_cb, pd);
evas_object_smart_callback_add(glist, "unrealized", _item_unrealized_cb, wd);
elm_genlist_homogeneous_set(glist, 1);
evas_object_show(glist);
elm_object_content_set(scr, glist);
evas_object_show(scr);
pd->cache = evisum_ui_item_cache_new(glist, _item_create, 10);
wd->cache = evisum_ui_item_cache_new(glist, _item_create, 10);
elm_table_pack(tb, scr, 0, 2, 8, 2);
elm_object_content_set(win, tb);
@ -683,16 +683,16 @@ ui_disk_win_add(Evisum_Ui *ui)
else
elm_win_center(win, 1, 1);
evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, _win_del_cb, pd);
evas_object_event_callback_add(win, EVAS_CALLBACK_MOVE, _win_move_cb, pd);
evas_object_event_callback_add(win, EVAS_CALLBACK_RESIZE, _win_resize_cb, pd);
evas_object_event_callback_add(tb, EVAS_CALLBACK_KEY_DOWN, _win_key_down_cb, pd);
evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, _win_del_cb, wd);
evas_object_event_callback_add(win, EVAS_CALLBACK_MOVE, _win_move_cb, wd);
evas_object_event_callback_add(win, EVAS_CALLBACK_RESIZE, _win_resize_cb, wd);
evas_object_event_callback_add(tb, EVAS_CALLBACK_KEY_DOWN, _win_key_down_cb, wd);
evas_object_show(win);
pd->thread = ecore_thread_feedback_run(_disks_poll,
wd->thread = ecore_thread_feedback_run(_disks_poll,
_disks_poll_feedback_cb,
NULL,
NULL,
pd, 1);
wd, 1);
}

View File

@ -9,7 +9,7 @@ typedef struct
Elm_Genlist_Item_Class *itc, *itc2;
Evisum_Ui *ui;
} Data;
} Win_Data;
typedef struct
{
@ -30,7 +30,7 @@ typedef struct
} Network_Interface;
static void
_interface_gone(net_iface_t **ifaces, int n, Eina_List *list, Data *pd)
_interface_gone(net_iface_t **ifaces, int n, Eina_List *list, Win_Data *wd)
{
Eina_List *l;
Network_Interface *iface;
@ -55,7 +55,7 @@ _interface_gone(net_iface_t **ifaces, int n, Eina_List *list, Data *pd)
static void
_network_update(void *data, Ecore_Thread *thread)
{
Data *pd = data;
Win_Data *wd = data;
Eina_List *interfaces = NULL;
Network_Interface *iface;
@ -64,7 +64,7 @@ _network_update(void *data, Ecore_Thread *thread)
int n;
net_iface_t *nwif, **ifaces = system_network_ifaces_get(&n);
_interface_gone(ifaces, n, interfaces, pd);
_interface_gone(ifaces, n, interfaces, wd);
for (int i = 0; i < n; i++)
{
@ -222,14 +222,14 @@ _network_update_feedback_cb(void *data, Ecore_Thread *thread, void *msgdata EINA
{
Eina_List *interfaces;
Network_Interface *iface;
Data *pd;
Win_Data *wd;
Evas_Object *obj;
Eina_List *l, *l2;
char *s;
Eina_Strbuf *buf;
interfaces = msgdata;
pd = data;
wd = data;
buf = eina_strbuf_new();
@ -242,10 +242,10 @@ _network_update_feedback_cb(void *data, Ecore_Thread *thread, void *msgdata EINA
free(iface);
interfaces = eina_list_remove_list(interfaces, l);
}
else if (iface->is_new)
else if (iface->is_new)
{
iface->it = elm_genlist_item_append(pd->glist, pd->itc2, iface->name, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
iface->it2 = elm_genlist_item_append(pd->glist, pd->itc, iface, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
iface->it = elm_genlist_item_append(wd->glist, wd->itc2, iface->name, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
iface->it2 = elm_genlist_item_append(wd->glist, wd->itc, iface, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
}
else
{
@ -282,26 +282,26 @@ static void
_win_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Evas_Event_Key_Down *ev;
Data *pd;
Win_Data *wd;
pd = data;
wd = data;
ev = event_info;
if (!ev || !ev->keyname)
return;
if (!strcmp(ev->keyname, "Escape"))
evas_object_del(pd->ui->network.win);
evas_object_del(wd->ui->network.win);
}
static void
_win_move_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
{
Data *pd;
Win_Data *wd;
Evisum_Ui *ui;
pd = data;
ui = pd->ui;
wd = data;
ui = wd->ui;
evas_object_geometry_get(obj, &ui->network.x, &ui->network.y, NULL, NULL);
}
@ -310,24 +310,24 @@ static void
_win_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Data *pd = data;
Evisum_Ui *ui = pd->ui;
Win_Data *wd = data;
Evisum_Ui *ui = wd->ui;
elm_genlist_item_class_free(pd->itc);
elm_genlist_item_class_free(pd->itc2);
elm_genlist_item_class_free(wd->itc);
elm_genlist_item_class_free(wd->itc2);
evisum_ui_config_save(ui);
ecore_thread_cancel(pd->thread);
ecore_thread_wait(pd->thread, 0.5);
ecore_thread_cancel(wd->thread);
ecore_thread_wait(wd->thread, 0.5);
ui->network.win = NULL;
free(pd);
free(wd);
}
static void
_win_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Data *pd = data;
Evisum_Ui *ui = pd->ui;
Win_Data *wd = data;
Evisum_Ui *ui = wd->ui;
evas_object_geometry_get(obj, NULL, NULL, &ui->network.width, &ui->network.height);
}
@ -344,24 +344,24 @@ ui_network_win_add(Evisum_Ui *ui)
return;
}
Data *pd = calloc(1, sizeof(Data));
if (!pd) return;
pd->ui = ui;
Win_Data *wd = calloc(1, sizeof(Win_Data));
if (!wd) return;
wd->ui = ui;
ui->network.win = pd->win = win = elm_win_util_standard_add("evisum", _("Network"));
ui->network.win = wd->win = win = elm_win_util_standard_add("evisum", _("Network"));
elm_win_autodel_set(win, 1);
evas_object_size_hint_weight_set(win, EXPAND, EXPAND);
evas_object_size_hint_align_set(win, FILL, FILL);
evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, _win_del_cb, pd);
evas_object_event_callback_add(win, EVAS_CALLBACK_MOVE, _win_move_cb, pd);
evas_object_event_callback_add(win, EVAS_CALLBACK_RESIZE, _win_resize_cb, pd);
evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, _win_del_cb, wd);
evas_object_event_callback_add(win, EVAS_CALLBACK_MOVE, _win_move_cb, wd);
evas_object_event_callback_add(win, EVAS_CALLBACK_RESIZE, _win_resize_cb, wd);
bx = elm_box_add(win);
evas_object_size_hint_weight_set(bx, 1.0, 1.0);
evas_object_size_hint_align_set(bx, FILL, FILL);
evas_object_event_callback_add(bx, EVAS_CALLBACK_KEY_DOWN, _win_key_down_cb, pd);
evas_object_event_callback_add(bx, EVAS_CALLBACK_KEY_DOWN, _win_key_down_cb, wd);
pd->glist = glist = elm_genlist_add(win);
wd->glist = glist = elm_genlist_add(win);
elm_genlist_homogeneous_set(glist, 1);
evas_object_size_hint_weight_set(glist, 1.0, 1.0);
evas_object_size_hint_align_set(glist, FILL, FILL);
@ -370,7 +370,7 @@ ui_network_win_add(Evisum_Ui *ui)
evas_object_show(glist);
itc = elm_genlist_item_class_new();
pd->itc = itc;
wd->itc = itc;
itc->item_style = "full";
itc->func.text_get = NULL;
itc->func.content_get = _iface_obj_add;
@ -379,7 +379,7 @@ ui_network_win_add(Evisum_Ui *ui)
itc->func.del = NULL;
itc = elm_genlist_item_class_new();
pd->itc2 = itc;
wd->itc2 = itc;
itc->item_style = "group_index";
itc->func.text_get = _text_get;
itc->func.content_get = NULL;
@ -402,10 +402,10 @@ ui_network_win_add(Evisum_Ui *ui)
evas_object_show(win);
pd->thread = ecore_thread_feedback_run(_network_update,
wd->thread = ecore_thread_feedback_run(_network_update,
_network_update_feedback_cb,
NULL,
NULL,
pd, 1);
wd, 1);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -16,7 +16,7 @@ typedef struct
Eina_Bool skip_wait;
Evisum_Ui *ui;
} Data;
} Win_Data;
typedef struct
{
@ -28,7 +28,7 @@ typedef struct
power_t power;
double thermal_temp;
Eina_Bool thermal_valid;
} Sensor_Data;
} Sensor_Win_Data;
static void
_name_set(char *buf, size_t len, sensor_t *s)
@ -54,7 +54,7 @@ _sort_cb(const void *p1, const void *p2)
}
static void
_sensors_refresh(Data *pd)
_sensors_refresh(Win_Data *wd)
{
sensor_t **sensors;
int n;
@ -63,43 +63,43 @@ _sensors_refresh(Data *pd)
if (!sensors) return;
for (int i = 0; i < n; i++)
pd->sensors = eina_list_append(pd->sensors, sensors[i]);
wd->sensors = eina_list_append(wd->sensors, sensors[i]);
free(sensors);
pd->sensors = eina_list_sort(pd->sensors, n, _sort_cb);
wd->sensors = eina_list_sort(wd->sensors, n, _sort_cb);
elm_genlist_clear(pd->glist);
elm_genlist_clear(wd->glist);
}
static void
_sensors_update(void *data, Ecore_Thread *thread)
{
Data *pd = data;
Win_Data *wd = data;
Sensor_Data *msg = malloc(sizeof(Data));
Sensor_Win_Data *msg = malloc(sizeof(Win_Data));
if (!msg) return;
while (!ecore_thread_check(thread))
{
system_power_state_get(&msg->power);
if (pd->sensor)
if (wd->sensor)
{
if (!system_sensor_thermal_get(pd->sensor))
if (!system_sensor_thermal_get(wd->sensor))
msg->thermal_valid = 0;
else
{
msg->thermal_valid = 1;
msg->thermal_temp = pd->sensor->value;
msg->thermal_temp = wd->sensor->value;
}
}
ecore_thread_feedback(thread, msg);
for (int i = 0; i < 8; i++)
{
if (pd->skip_wait || ecore_thread_check(thread)) break;
if (wd->skip_wait || ecore_thread_check(thread)) break;
usleep(250000);
}
pd->skip_wait = 0;
wd->skip_wait = 0;
}
free(msg);
}
@ -107,33 +107,33 @@ _sensors_update(void *data, Ecore_Thread *thread)
static void
_sensors_update_feedback_cb(void *data, Ecore_Thread *thread, void *msgdata)
{
Sensor_Data *msg;
Data *pd;
Sensor_Win_Data *msg;
Win_Data *wd;
sensor_t *s;
Eina_List *l;
int i = 0;
msg = msgdata;
pd = data;
wd = data;
EINA_LIST_FREE(pd->sensors, s)
elm_genlist_item_append(pd->glist, pd->itc, s,
EINA_LIST_FREE(wd->sensors, s)
elm_genlist_item_append(wd->glist, wd->itc, s,
NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
if (msg->thermal_valid && pd->sensor)
if (msg->thermal_valid && wd->sensor)
{
elm_progressbar_value_set(pd->thermal_pb, msg->thermal_temp / 100);
elm_object_tooltip_text_set(pd->thermal_pb, pd->sensor->name);
elm_progressbar_value_set(wd->thermal_pb, msg->thermal_temp / 100);
elm_object_tooltip_text_set(wd->thermal_pb, wd->sensor->name);
}
if (pd->power_ic)
if (wd->power_ic)
{
if (msg->power.have_ac)
elm_icon_standard_set(pd->power_ic, evisum_icon_path_get("on"));
elm_icon_standard_set(wd->power_ic, evisum_icon_path_get("on"));
else
elm_icon_standard_set(pd->power_ic, evisum_icon_path_get("off"));
evas_object_show(pd->power_ic);
elm_icon_standard_set(wd->power_ic, evisum_icon_path_get("off"));
evas_object_show(wd->power_ic);
}
l = eina_list_nth_list(pd->batteries, 0);
l = eina_list_nth_list(wd->batteries, 0);
while (l && msg->power.battery_count)
{
if (msg->power.batteries[i]->present)
@ -163,18 +163,18 @@ _item_del(void *data, Evas_Object *obj)
static void
_glist_item_pressed_cb(void *data, Evas_Object *obj, void *event_info)
{
Data *pd;
Win_Data *wd;
Elm_Object_Item *it;
sensor_t *s;
char buf[64];
pd = data;
wd = data;
it = event_info;
pd->sensor = s = elm_object_item_data_get(it);
wd->sensor = s = elm_object_item_data_get(it);
_name_set(buf, sizeof(buf), s);
elm_object_text_set(obj, buf);
pd->skip_wait = 1;
wd->skip_wait = 1;
}
static char *
@ -196,26 +196,26 @@ static void
_win_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Evas_Event_Key_Down *ev;
Data *pd;
Win_Data *wd;
pd = data;
wd = data;
ev = event_info;
if (!ev || !ev->keyname)
return;
if (!strcmp(ev->keyname, "Escape"))
evas_object_del(pd->ui->sensors.win);
evas_object_del(wd->ui->sensors.win);
}
static void
_win_move_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
{
Data *pd;
Win_Data *wd;
Evisum_Ui *ui;
pd = data;
ui = pd->ui;
wd = data;
ui = wd->ui;
evas_object_geometry_get(obj, &ui->sensors.x, &ui->sensors.y, NULL, NULL);
}
@ -225,25 +225,25 @@ _win_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Bat *bat;
Data *pd = data;
Evisum_Ui *ui = pd->ui;
Win_Data *wd = data;
Evisum_Ui *ui = wd->ui;
evisum_ui_config_save(ui);
ecore_thread_cancel(pd->thread);
ecore_thread_wait(pd->thread, 0.5);
ecore_thread_cancel(wd->thread);
ecore_thread_wait(wd->thread, 0.5);
ui->sensors.win = NULL;
EINA_LIST_FREE(pd->batteries, bat)
EINA_LIST_FREE(wd->batteries, bat)
free(bat);
elm_genlist_item_class_free(pd->itc);
free(pd);
elm_genlist_item_class_free(wd->itc);
free(wd);
}
static void
_win_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Data *pd = data;
Evisum_Ui *ui = pd->ui;
Win_Data *wd = data;
Evisum_Ui *ui = wd->ui;
evas_object_geometry_get(obj, NULL, NULL, &ui->sensors.width, &ui->sensors.height);
}
@ -263,18 +263,18 @@ ui_sensors_win_add(Evisum_Ui *ui)
return;
}
Data *pd = calloc(1, sizeof(Data));
if (!pd) return;
pd->ui = ui;
Win_Data *wd = calloc(1, sizeof(Win_Data));
if (!wd) return;
wd->ui = ui;
ui->sensors.win = win = elm_win_util_standard_add("evisum", _("Sensors"));
elm_win_autodel_set(win, 1);
evas_object_size_hint_weight_set(win, EXPAND, EXPAND);
evas_object_size_hint_align_set(win, FILL, FILL);
evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, _win_del_cb, pd);
evas_object_event_callback_add(win, EVAS_CALLBACK_MOVE, _win_move_cb, pd);
evas_object_event_callback_add(win, EVAS_CALLBACK_RESIZE, _win_resize_cb, pd);
evas_object_event_callback_add(win, EVAS_CALLBACK_KEY_DOWN, _win_key_down_cb, pd);
evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, _win_del_cb, wd);
evas_object_event_callback_add(win, EVAS_CALLBACK_MOVE, _win_move_cb, wd);
evas_object_event_callback_add(win, EVAS_CALLBACK_RESIZE, _win_resize_cb, wd);
evas_object_event_callback_add(win, EVAS_CALLBACK_KEY_DOWN, _win_key_down_cb, wd);
content = elm_box_add(win);
evas_object_size_hint_weight_set(content, EXPAND, EXPAND);
@ -314,7 +314,7 @@ ui_sensors_win_add(Evisum_Ui *ui)
if (!i)
{
pd->power_ic = ic = elm_icon_add(win);
wd->power_ic = ic = elm_icon_add(win);
evas_object_size_hint_min_set(ic, ELM_SCALE_SIZE(16), ELM_SCALE_SIZE(16));
evas_object_size_hint_align_set(ic, 1.0, 0.5);
elm_table_pack(tbl, ic, 0, j, 1, 1);
@ -326,12 +326,12 @@ ui_sensors_win_add(Evisum_Ui *ui)
elm_table_pack(tbl, pb, 1, j++, 1, 1);
evas_object_show(pb);
pd->batteries = eina_list_append(pd->batteries, bat);
wd->batteries = eina_list_append(wd->batteries, bat);
}
system_power_state_free(&power);
pd->thermal_pb = pb = elm_progressbar_add(win);
wd->thermal_pb = pb = elm_progressbar_add(win);
evas_object_size_hint_weight_set(pb, EXPAND, 0);
evas_object_size_hint_align_set(pb, FILL, FILL);
elm_progressbar_unit_format_set(pb, "%1.1f°C");
@ -341,12 +341,12 @@ ui_sensors_win_add(Evisum_Ui *ui)
evas_object_size_hint_align_set(bx, FILL, FILL);
evas_object_show(bx);
pd->glist = glist = elm_genlist_add(win);
wd->glist = glist = elm_genlist_add(win);
evas_object_size_hint_weight_set(glist, EXPAND, EXPAND);
evas_object_size_hint_align_set(glist, FILL, FILL);
elm_object_text_set(glist, _("Select..."));
elm_genlist_multi_select_set(glist, 0);
evas_object_smart_callback_add(glist, "selected", _glist_item_pressed_cb, pd);
evas_object_smart_callback_add(glist, "selected", _glist_item_pressed_cb, wd);
elm_object_focus_allow_set(glist, 0);
elm_box_pack_end(bx, glist);
@ -363,12 +363,12 @@ ui_sensors_win_add(Evisum_Ui *ui)
elm_box_pack_end(content, fr);
evas_object_show(fr);
pd->itc = elm_genlist_item_class_new();
pd->itc->item_style = "no_icon";
pd->itc->func.content_get = NULL;
pd->itc->func.text_get = _text_get;
pd->itc->func.filter_get = NULL;
pd->itc->func.del = _item_del;
wd->itc = elm_genlist_item_class_new();
wd->itc->item_style = "no_icon";
wd->itc->func.content_get = NULL;
wd->itc->func.text_get = _text_get;
wd->itc->func.filter_get = NULL;
wd->itc->func.del = _item_del;
if ((ui->sensors.width > 0) && (ui->sensors.height > 0))
evas_object_resize(win, ui->sensors.width, ui->sensors.height);
@ -382,12 +382,12 @@ ui_sensors_win_add(Evisum_Ui *ui)
evas_object_show(win);
_sensors_refresh(pd);
_sensors_refresh(wd);
pd->thread = ecore_thread_feedback_run(_sensors_update,
wd->thread = ecore_thread_feedback_run(_sensors_update,
_sensors_update_feedback_cb,
NULL,
NULL,
pd, 1);
wd, 1);
}