ui: rename

This commit is contained in:
Alastair Poole 2020-06-17 22:34:25 +01:00
parent edd8923326
commit 461c34fc0d
9 changed files with 191 additions and 193 deletions

View File

@ -629,9 +629,9 @@ swap_out:
} }
static void static void
_sensors_thermal_get(Sys_Info *sysinfo) _sensors_thermal_get(Sys_Info *info)
{ {
sensor_t **sensors = sysinfo->sensors; sensor_t **sensors = info->sensors;
#if defined(__OpenBSD__) #if defined(__OpenBSD__)
sensor_t *sensor; sensor_t *sensor;
int mibs[5] = { CTL_HW, HW_SENSORS, 0, 0, 0 }; int mibs[5] = { CTL_HW, HW_SENSORS, 0, 0, 0 };
@ -667,8 +667,8 @@ _sensors_thermal_get(Sys_Info *sysinfo)
if (snsr.type != SENSOR_TEMP) if (snsr.type != SENSOR_TEMP)
continue; continue;
sensors = realloc(sensors, 1 + sysinfo->sensor_count * sizeof(sensor_t *)); sensors = realloc(sensors, 1 + info->sensor_count * sizeof(sensor_t *));
sensors[sysinfo->sensor_count++] = sensor = calloc(1, sizeof(sensor_t)); sensors[info->sensor_count++] = sensor = calloc(1, sizeof(sensor_t));
sensor->name = strdup(snsrdev.xname); sensor->name = strdup(snsrdev.xname);
sensor->value = (snsr.value - 273150000) / 1000000.0; // (uK -> C) sensor->value = (snsr.value - 273150000) / 1000000.0; // (uK -> C)
} }
@ -679,8 +679,8 @@ _sensors_thermal_get(Sys_Info *sysinfo)
if ((sysctlbyname("hw.acpi.thermal.tz0.temperature", &value, &len, NULL, 0)) != -1) if ((sysctlbyname("hw.acpi.thermal.tz0.temperature", &value, &len, NULL, 0)) != -1)
{ {
sensors = realloc(sensors, 1 + sysinfo->sensor_count * sizeof(sensor_t *)); sensors = realloc(sensors, 1 + info->sensor_count * sizeof(sensor_t *));
sensors[sysinfo->sensor_count++] = sensor = calloc(1, sizeof(sensor_t)); sensors[info->sensor_count++] = sensor = calloc(1, sizeof(sensor_t));
sensor->name = strdup("hw.acpi.thermal.tz0"); sensor->name = strdup("hw.acpi.thermal.tz0");
sensor->value = (float) (value - 2732) / 10; sensor->value = (float) (value - 2732) / 10;
} }
@ -704,8 +704,8 @@ _sensors_thermal_get(Sys_Info *sysinfo)
if (type) if (type)
{ {
sensors = sensors =
realloc(sensors, 1 + sysinfo->sensor_count * sizeof(sensor_t *)); realloc(sensors, 1 + info->sensor_count * sizeof(sensor_t *));
sensors[sysinfo->sensor_count++] = sensors[info->sensor_count++] =
sensor = calloc(1, sizeof(sensor_t)); sensor = calloc(1, sizeof(sensor_t));
sensor->name = strdup(dh->d_name); sensor->name = strdup(dh->d_name);
@ -727,7 +727,7 @@ _sensors_thermal_get(Sys_Info *sysinfo)
closedir(dir); closedir(dir);
#elif defined(__MacOS__) #elif defined(__MacOS__)
#endif #endif
sysinfo->sensors = sensors; info->sensors = sensors;
} }
static int static int
@ -1150,7 +1150,7 @@ _linux_generic_network_status(unsigned long int *in,
#endif #endif
static void static void
_network_transfer_get(Sys_Info *sysinfo) _network_transfer_get(Sys_Info *info)
{ {
unsigned long first_in = 0, first_out = 0; unsigned long first_in = 0, first_out = 0;
unsigned long last_in = 0, last_out = 0; unsigned long last_in = 0, last_out = 0;
@ -1167,76 +1167,76 @@ _network_transfer_get(Sys_Info *sysinfo)
usleep(1000000); usleep(1000000);
_freebsd_generic_network_status(&last_in, &last_out); _freebsd_generic_network_status(&last_in, &last_out);
#endif #endif
sysinfo->incoming = last_in - first_in; info->incoming = last_in - first_in;
sysinfo->outgoing = last_out - first_out; info->outgoing = last_out - first_out;
} }
static void * static void *
_network_transfer_get_thread_cb(void *arg) _network_transfer_get_thread_cb(void *arg)
{ {
Sys_Info *sysinfo = arg; Sys_Info *info = arg;
_network_transfer_get(sysinfo); _network_transfer_get(info);
return (void *)0; return (void *)0;
} }
void void
sys_info_all_free(Sys_Info *sysinfo) sys_info_all_free(Sys_Info *info)
{ {
sensor_t *snsr; sensor_t *snsr;
int i; int i;
for (i = 0; i < sysinfo->cpu_count; i++) for (i = 0; i < info->cpu_count; i++)
{ {
free(sysinfo->cores[i]); free(info->cores[i]);
} }
free(sysinfo->cores); free(info->cores);
for (i = 0; i < sysinfo->sensor_count; i++) for (i = 0; i < info->sensor_count; i++)
{ {
snsr = sysinfo->sensors[i]; snsr = info->sensors[i];
if (snsr->name) free(snsr->name); if (snsr->name) free(snsr->name);
free(snsr); free(snsr);
} }
if (sysinfo->sensors) if (info->sensors)
free(sysinfo->sensors); free(info->sensors);
for (i = 0; i < sysinfo->power.battery_count; i++) for (i = 0; i < info->power.battery_count; i++)
{ {
if (sysinfo->power.battery_names[i]) if (info->power.battery_names[i])
free(sysinfo->power.battery_names[i]); free(info->power.battery_names[i]);
free(sysinfo->power.batteries[i]); free(info->power.batteries[i]);
} }
if (sysinfo->power.batteries) if (info->power.batteries)
free(sysinfo->power.batteries); free(info->power.batteries);
free(sysinfo); free(info);
} }
Sys_Info * Sys_Info *
sys_info_all_get(void) sys_info_all_get(void)
{ {
Sys_Info *sysinfo; Sys_Info *info;
void *ret; void *ret;
pthread_t tid; pthread_t tid;
int error; int error;
sysinfo = calloc(1, sizeof(Sys_Info)); info = calloc(1, sizeof(Sys_Info));
if (!sysinfo) return NULL; if (!info) return NULL;
sysinfo->cores = _cpu_cores_state_get(&sysinfo->cpu_count); info->cores = _cpu_cores_state_get(&info->cpu_count);
_memory_usage_get(&sysinfo->memory); _memory_usage_get(&info->memory);
error = pthread_create(&tid, NULL, _network_transfer_get_thread_cb, sysinfo); error = pthread_create(&tid, NULL, _network_transfer_get_thread_cb, info);
if (error) if (error)
_network_transfer_get(sysinfo); _network_transfer_get(info);
if (_power_battery_count_get(&sysinfo->power)) if (_power_battery_count_get(&info->power))
_power_state_get(&sysinfo->power); _power_state_get(&info->power);
_sensors_thermal_get(sysinfo); _sensors_thermal_get(info);
if (!error) if (!error)
{ {
@ -1244,6 +1244,6 @@ sys_info_all_get(void)
pthread_join(tid, ret); pthread_join(tid, ret);
} }
return sysinfo; return info;
} }

View File

@ -906,7 +906,7 @@ static void
_ui_tab_system_add(Ui *ui) _ui_tab_system_add(Ui *ui)
{ {
Evas_Object *parent, *box, *hbox, *frame, *table; Evas_Object *parent, *box, *hbox, *frame, *table;
Evas_Object *progress, *button, *plist; Evas_Object *pb, *button, *plist;
int i = 0; int i = 0;
parent = ui->content; parent = ui->content;
@ -931,13 +931,13 @@ _ui_tab_system_add(Ui *ui)
evas_object_show(frame); evas_object_show(frame);
elm_box_pack_end(hbox, frame); elm_box_pack_end(hbox, frame);
ui->progress_cpu = progress = elm_progressbar_add(parent); ui->progress_cpu = pb = elm_progressbar_add(parent);
evas_object_size_hint_align_set(progress, FILL, FILL); evas_object_size_hint_align_set(pb, FILL, FILL);
evas_object_size_hint_weight_set(progress, EXPAND, EXPAND); evas_object_size_hint_weight_set(pb, EXPAND, EXPAND);
elm_progressbar_span_size_set(progress, 1.0); elm_progressbar_span_size_set(pb, 1.0);
elm_progressbar_unit_format_set(progress, "%1.2f%%"); elm_progressbar_unit_format_set(pb, "%1.2f%%");
elm_object_content_set(frame, progress); elm_object_content_set(frame, pb);
evas_object_show(progress); evas_object_show(pb);
frame = elm_frame_add(hbox); frame = elm_frame_add(hbox);
evas_object_size_hint_weight_set(frame, EXPAND, EXPAND); evas_object_size_hint_weight_set(frame, EXPAND, EXPAND);
@ -946,12 +946,12 @@ _ui_tab_system_add(Ui *ui)
evas_object_show(frame); evas_object_show(frame);
elm_box_pack_end(hbox, frame); elm_box_pack_end(hbox, frame);
ui->progress_mem = progress = elm_progressbar_add(parent); ui->progress_mem = pb = elm_progressbar_add(parent);
evas_object_size_hint_align_set(progress, FILL, FILL); evas_object_size_hint_align_set(pb, FILL, FILL);
evas_object_size_hint_weight_set(progress, EXPAND, EXPAND); evas_object_size_hint_weight_set(pb, EXPAND, EXPAND);
elm_progressbar_span_size_set(progress, 1.0); elm_progressbar_span_size_set(pb, 1.0);
evas_object_show(progress); evas_object_show(pb);
elm_object_content_set(frame, progress); elm_object_content_set(frame, pb);
table = elm_table_add(parent); table = elm_table_add(parent);
evas_object_size_hint_weight_set(table, EXPAND, 0); evas_object_size_hint_weight_set(table, EXPAND, 0);
@ -1541,14 +1541,14 @@ _sys_info_all_poll(void *data, Ecore_Thread *thread)
while (1) while (1)
{ {
Sys_Info *sysinfo = sys_info_all_get(); Sys_Info *info = sys_info_all_get();
if (!sysinfo) if (!info)
{ {
ecore_main_loop_quit(); ecore_main_loop_quit();
return; return;
} }
ecore_thread_feedback(thread, sysinfo); ecore_thread_feedback(thread, info);
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
{ {
@ -1568,24 +1568,24 @@ static void
_sys_info_all_poll_feedback_cb(void *data, Ecore_Thread *thread, void *msg) _sys_info_all_poll_feedback_cb(void *data, Ecore_Thread *thread, void *msg)
{ {
Ui *ui; Ui *ui;
Evas_Object *progress; Evas_Object *pb;
Sys_Info *sysinfo; Sys_Info *info;
double ratio, value, cpu_usage = 0.0; double ratio, value, cpu_usage = 0.0;
ui = data; ui = data;
sysinfo = msg; info = msg;
if (ecore_thread_check(thread)) if (ecore_thread_check(thread))
goto out; goto out;
ui_tab_cpu_update(ui, sysinfo); ui_tab_cpu_update(ui, info);
ui_tab_memory_update(ui, sysinfo); ui_tab_memory_update(ui, info);
ui_tab_disk_update(ui); ui_tab_disk_update(ui);
ui_tab_misc_update(ui, sysinfo); ui_tab_misc_update(ui, info);
for (int i = 0; i < sysinfo->cpu_count; i++) for (int i = 0; i < info->cpu_count; i++)
{ {
cpu_usage += sysinfo->cores[i]->percent; cpu_usage += info->cores[i]->percent;
} }
cpu_usage = cpu_usage / system_cpu_online_count_get(); cpu_usage = cpu_usage / system_cpu_online_count_get();
@ -1593,17 +1593,17 @@ _sys_info_all_poll_feedback_cb(void *data, Ecore_Thread *thread, void *msg)
elm_progressbar_value_set(ui->progress_cpu, cpu_usage / 100); elm_progressbar_value_set(ui->progress_cpu, cpu_usage / 100);
if (ui->zfs_mounted) if (ui->zfs_mounted)
sysinfo->memory.used += sysinfo->memory.zfs_arc_used; info->memory.used += info->memory.zfs_arc_used;
progress = ui->progress_mem; pb = ui->progress_mem;
ratio = sysinfo->memory.total / 100.0; ratio = info->memory.total / 100.0;
value = sysinfo->memory.used / ratio; value = info->memory.used / ratio;
elm_progressbar_value_set(progress, value / 100); elm_progressbar_value_set(pb, value / 100);
elm_progressbar_unit_format_set(progress, eina_slstr_printf("%s / %s", elm_progressbar_unit_format_set(pb, eina_slstr_printf("%s / %s",
evisum_size_format(sysinfo->memory.used), evisum_size_format(info->memory.used),
evisum_size_format(sysinfo->memory.total))); evisum_size_format(info->memory.total)));
out: out:
sys_info_all_free(sysinfo); sys_info_all_free(info);
} }
static void static void

View File

@ -4,7 +4,7 @@ void
ui_tab_cpu_add(Ui *ui) ui_tab_cpu_add(Ui *ui)
{ {
Evas_Object *parent, *box, *hbox, *frame, *label, *scroller; Evas_Object *parent, *box, *hbox, *frame, *label, *scroller;
Evas_Object *progress; Evas_Object *pb;
unsigned int cpu_count; unsigned int cpu_count;
parent = ui->content; parent = ui->content;
@ -65,25 +65,25 @@ ui_tab_cpu_add(Ui *ui)
evas_object_show(frame); evas_object_show(frame);
elm_object_style_set(frame, "pad_large"); elm_object_style_set(frame, "pad_large");
progress = elm_progressbar_add(frame); pb = elm_progressbar_add(frame);
evas_object_size_hint_align_set(progress, FILL, FILL); evas_object_size_hint_align_set(pb, FILL, FILL);
evas_object_size_hint_weight_set(progress, EXPAND, EXPAND); evas_object_size_hint_weight_set(pb, EXPAND, EXPAND);
elm_progressbar_span_size_set(progress, 1.0); elm_progressbar_span_size_set(pb, 1.0);
elm_progressbar_unit_format_set(progress, "%1.2f%%"); elm_progressbar_unit_format_set(pb, "%1.2f%%");
evas_object_show(progress); evas_object_show(pb);
elm_progressbar_value_set(progress, 0.0); elm_progressbar_value_set(pb, 0.0);
elm_object_content_set(frame, progress); elm_object_content_set(frame, pb);
elm_box_pack_end(box, frame); elm_box_pack_end(box, frame);
ui->cpu_list = eina_list_append(ui->cpu_list, progress); ui->cpu_list = eina_list_append(ui->cpu_list, pb);
} }
elm_box_pack_end(ui->cpu_activity, box); elm_box_pack_end(ui->cpu_activity, box);
} }
void void
ui_tab_cpu_update(Ui *ui, Sys_Info *sysinfo) ui_tab_cpu_update(Ui *ui, Sys_Info *info)
{ {
Eina_List *l; Eina_List *l;
Evas_Object *pb; Evas_Object *pb;
@ -94,7 +94,7 @@ ui_tab_cpu_update(Ui *ui, Sys_Info *sysinfo)
EINA_LIST_FOREACH(ui->cpu_list, l, pb) EINA_LIST_FOREACH(ui->cpu_list, l, pb)
{ {
elm_progressbar_value_set(pb, sysinfo->cores[i]->percent / 100); elm_progressbar_value_set(pb, info->cores[i]->percent / 100);
++i; ++i;
} }
} }

View File

@ -8,7 +8,7 @@ void
ui_tab_cpu_add(Ui *ui); ui_tab_cpu_add(Ui *ui);
void void
ui_tab_cpu_update(Ui *ui, Sys_Info *sysinfo); ui_tab_cpu_update(Ui *ui, Sys_Info *info);
#endif #endif

View File

@ -40,7 +40,7 @@ ui_tab_disk_add(Ui *ui)
static void static void
_ui_disk_add(Ui *ui, Filesystem_Info *inf) _ui_disk_add(Ui *ui, Filesystem_Info *inf)
{ {
Evas_Object *box, *frame, *progress, *label; Evas_Object *box, *frame, *pb, *label;
const char *type; const char *type;
double ratio, value; double ratio, value;
@ -66,19 +66,19 @@ _ui_disk_add(Ui *ui, Filesystem_Info *inf)
evas_object_show(label); evas_object_show(label);
elm_box_pack_end(box, label); elm_box_pack_end(box, label);
progress = elm_progressbar_add(box); pb = elm_progressbar_add(box);
evas_object_size_hint_align_set(progress, FILL, FILL); evas_object_size_hint_align_set(pb, FILL, FILL);
evas_object_size_hint_weight_set(progress, EXPAND, EXPAND); evas_object_size_hint_weight_set(pb, EXPAND, EXPAND);
elm_progressbar_span_size_set(progress, 1.0); elm_progressbar_span_size_set(pb, 1.0);
evas_object_show(progress); evas_object_show(pb);
ratio = inf->usage.total / 100.0; ratio = inf->usage.total / 100.0;
value = inf->usage.used / ratio; value = inf->usage.used / ratio;
if (inf->usage.used == 0 && inf->usage.total == 0) if (inf->usage.used == 0 && inf->usage.total == 0)
elm_progressbar_value_set(progress, 1.0); elm_progressbar_value_set(pb, 1.0);
else else
elm_progressbar_value_set(progress, value / 100.0); elm_progressbar_value_set(pb, value / 100.0);
frame = elm_frame_add(ui->misc_activity); frame = elm_frame_add(ui->misc_activity);
evas_object_size_hint_align_set(frame, FILL, FILL); evas_object_size_hint_align_set(frame, FILL, FILL);
@ -86,7 +86,7 @@ _ui_disk_add(Ui *ui, Filesystem_Info *inf)
elm_object_style_set(frame, "pad_large"); elm_object_style_set(frame, "pad_large");
evas_object_show(frame); evas_object_show(frame);
elm_box_pack_end(box, progress); elm_box_pack_end(box, pb);
elm_object_content_set(frame, box); elm_object_content_set(frame, box);
elm_box_pack_end(ui->disk_activity, frame); elm_box_pack_end(ui->disk_activity, frame);
} }

View File

@ -15,19 +15,19 @@ _label_mem(Evas_Object *parent, const char *text)
static Evas_Object * static Evas_Object *
_progress_add(Evas_Object *parent) _progress_add(Evas_Object *parent)
{ {
Evas_Object *progress = elm_progressbar_add(parent); Evas_Object *pb = elm_progressbar_add(parent);
evas_object_size_hint_align_set(progress, FILL, FILL); evas_object_size_hint_align_set(pb, FILL, FILL);
evas_object_size_hint_weight_set(progress, EXPAND, EXPAND); evas_object_size_hint_weight_set(pb, EXPAND, EXPAND);
elm_progressbar_span_size_set(progress, 1.0); elm_progressbar_span_size_set(pb, 1.0);
evas_object_show(progress); evas_object_show(pb);
return progress; return pb;
} }
void void
ui_tab_memory_add(Ui *ui) ui_tab_memory_add(Ui *ui)
{ {
Evas_Object *parent, *box, *hbox, *frame, *progress, *scroller; Evas_Object *parent, *box, *hbox, *frame, *pb, *scroller;
Evas_Object *label, *table; Evas_Object *label, *table;
parent = ui->content; parent = ui->content;
@ -92,29 +92,29 @@ ui_tab_memory_add(Ui *ui)
evas_object_show(table); evas_object_show(table);
label = _label_mem(box, _("Used")); label = _label_mem(box, _("Used"));
ui->progress_mem_used = progress = _progress_add(table); ui->progress_mem_used = pb = _progress_add(table);
elm_table_pack(table, label, 0, 0, 1, 1); elm_table_pack(table, label, 0, 0, 1, 1);
elm_table_pack(table, progress, 1, 0, 1, 1); elm_table_pack(table, pb, 1, 0, 1, 1);
label = _label_mem(box, _("Cached")); label = _label_mem(box, _("Cached"));
ui->progress_mem_cached = progress = _progress_add(table); ui->progress_mem_cached = pb = _progress_add(table);
elm_table_pack(table, label, 0, 1, 1, 1); elm_table_pack(table, label, 0, 1, 1, 1);
elm_table_pack(table, progress, 1, 1, 1, 1); elm_table_pack(table, pb, 1, 1, 1, 1);
label = _label_mem(box, _("Buffered")); label = _label_mem(box, _("Buffered"));
ui->progress_mem_buffered = progress = _progress_add(table); ui->progress_mem_buffered = pb = _progress_add(table);
elm_table_pack(table, label, 0, 2, 1, 1); elm_table_pack(table, label, 0, 2, 1, 1);
elm_table_pack(table, progress, 1, 2, 1, 1); elm_table_pack(table, pb, 1, 2, 1, 1);
label = _label_mem(box, _("Shared")); label = _label_mem(box, _("Shared"));
ui->progress_mem_shared = progress = _progress_add(table); ui->progress_mem_shared = pb = _progress_add(table);
elm_table_pack(table, label, 0, 3, 1, 1); elm_table_pack(table, label, 0, 3, 1, 1);
elm_table_pack(table, progress, 1, 3, 1, 1); elm_table_pack(table, pb, 1, 3, 1, 1);
label = _label_mem(box, _("Swapped")); label = _label_mem(box, _("Swapped"));
ui->progress_mem_swap = progress = _progress_add(frame); ui->progress_mem_swap = pb = _progress_add(frame);
elm_table_pack(table, label, 0, 4, 1, 1); elm_table_pack(table, label, 0, 4, 1, 1);
elm_table_pack(table, progress, 1, 4, 1, 1); elm_table_pack(table, pb, 1, 4, 1, 1);
frame = elm_frame_add(ui->mem_activity); frame = elm_frame_add(ui->mem_activity);
evas_object_size_hint_weight_set(frame, EXPAND, EXPAND); evas_object_size_hint_weight_set(frame, EXPAND, EXPAND);
@ -128,70 +128,70 @@ ui_tab_memory_add(Ui *ui)
} }
void void
ui_tab_memory_update(Ui *ui, Sys_Info *sysinfo) ui_tab_memory_update(Ui *ui, Sys_Info *info)
{ {
Evas_Object *progress; Evas_Object *pb;
double ratio, value; double ratio, value;
if (!ui->mem_visible) if (!ui->mem_visible)
return; return;
if (ui->zfs_mounted) if (ui->zfs_mounted)
sysinfo->memory.used += sysinfo->memory.zfs_arc_used; info->memory.used += info->memory.zfs_arc_used;
progress = ui->progress_mem_used; pb = ui->progress_mem_used;
ratio = sysinfo->memory.total / 100.0; ratio = info->memory.total / 100.0;
value = sysinfo->memory.used / ratio; value = info->memory.used / ratio;
elm_progressbar_value_set(progress, value / 100); elm_progressbar_value_set(pb, value / 100);
elm_progressbar_unit_format_set(progress, elm_progressbar_unit_format_set(pb,
eina_slstr_printf("%s / %s (%1.0f &#37;)", eina_slstr_printf("%s / %s (%1.0f &#37;)",
evisum_size_format(sysinfo->memory.used), evisum_size_format(info->memory.used),
evisum_size_format(sysinfo->memory.total), evisum_size_format(info->memory.total),
value)); value));
progress = ui->progress_mem_cached; pb = ui->progress_mem_cached;
ratio = sysinfo->memory.total / 100.0; ratio = info->memory.total / 100.0;
value = sysinfo->memory.cached / ratio; value = info->memory.cached / ratio;
elm_progressbar_value_set(progress, value / 100); elm_progressbar_value_set(pb, value / 100);
elm_progressbar_unit_format_set(progress, elm_progressbar_unit_format_set(pb,
eina_slstr_printf("%s / %s (%1.0f &#37;)", eina_slstr_printf("%s / %s (%1.0f &#37;)",
evisum_size_format(sysinfo->memory.cached), evisum_size_format(info->memory.cached),
evisum_size_format(sysinfo->memory.total), evisum_size_format(info->memory.total),
value)); value));
progress = ui->progress_mem_buffered; pb = ui->progress_mem_buffered;
ratio = sysinfo->memory.total / 100.0; ratio = info->memory.total / 100.0;
value = sysinfo->memory.buffered / ratio; value = info->memory.buffered / ratio;
elm_progressbar_value_set(progress, value / 100); elm_progressbar_value_set(pb, value / 100);
elm_progressbar_unit_format_set(progress, elm_progressbar_unit_format_set(pb,
eina_slstr_printf("%s / %s (%1.0f &#37;)", eina_slstr_printf("%s / %s (%1.0f &#37;)",
evisum_size_format(sysinfo->memory.buffered), evisum_size_format(info->memory.buffered),
evisum_size_format(sysinfo->memory.total), evisum_size_format(info->memory.total),
value)); value));
progress = ui->progress_mem_shared; pb = ui->progress_mem_shared;
ratio = sysinfo->memory.total / 100.0; ratio = info->memory.total / 100.0;
value = sysinfo->memory.shared / ratio; value = info->memory.shared / ratio;
elm_progressbar_value_set(progress, value / 100); elm_progressbar_value_set(pb, value / 100);
elm_progressbar_unit_format_set(progress, elm_progressbar_unit_format_set(pb,
eina_slstr_printf("%s / %s (%1.0f &#37;)", eina_slstr_printf("%s / %s (%1.0f &#37;)",
evisum_size_format(sysinfo->memory.shared), evisum_size_format(info->memory.shared),
evisum_size_format(sysinfo->memory.total), evisum_size_format(info->memory.total),
value)); value));
progress = ui->progress_mem_swap; pb = ui->progress_mem_swap;
if (sysinfo->memory.swap_total) if (info->memory.swap_total)
{ {
ratio = sysinfo->memory.swap_total / 100.0; ratio = info->memory.swap_total / 100.0;
value = sysinfo->memory.swap_used / ratio; value = info->memory.swap_used / ratio;
} }
else value = 0.0; else value = 0.0;
elm_progressbar_value_set(progress, value / 100); elm_progressbar_value_set(pb, value / 100);
elm_progressbar_unit_format_set(progress, elm_progressbar_unit_format_set(pb,
eina_slstr_printf("%s / %s (%1.0f &#37;)", eina_slstr_printf("%s / %s (%1.0f &#37;)",
evisum_size_format(sysinfo->memory.swap_used), evisum_size_format(info->memory.swap_used),
evisum_size_format(sysinfo->memory.swap_total), evisum_size_format(info->memory.swap_total),
value)); value));
} }

View File

@ -8,6 +8,6 @@ void
ui_tab_memory_add(Ui *ui); ui_tab_memory_add(Ui *ui);
void void
ui_tab_memory_update(Ui *ui, Sys_Info *sysinfo); ui_tab_memory_update(Ui *ui, Sys_Info *info);
#endif #endif

View File

@ -3,7 +3,7 @@
static Eina_Bool static Eina_Bool
_battery_usage_add(Evas_Object *box, power_t *power) _battery_usage_add(Evas_Object *box, power_t *power)
{ {
Evas_Object *frame, *vbox, *hbox, *progress, *ic, *label; Evas_Object *frame, *vbox, *hbox, *pb, *ic, *label;
const char *fmt; const char *fmt;
for (int i = 0; i < power->battery_count; i++) for (int i = 0; i < power->battery_count; i++)
@ -48,16 +48,16 @@ _battery_usage_add(Evas_Object *box, power_t *power)
evas_object_show(ic); evas_object_show(ic);
elm_box_pack_end(hbox, ic); elm_box_pack_end(hbox, ic);
progress = elm_progressbar_add(frame); pb = elm_progressbar_add(frame);
evas_object_size_hint_align_set(progress, FILL, FILL); evas_object_size_hint_align_set(pb, FILL, FILL);
evas_object_size_hint_weight_set(progress, EXPAND, EXPAND); evas_object_size_hint_weight_set(pb, EXPAND, EXPAND);
elm_progressbar_span_size_set(progress, 1.0); elm_progressbar_span_size_set(pb, 1.0);
elm_progressbar_unit_format_set(progress, "%1.0f%%"); elm_progressbar_unit_format_set(pb, "%1.0f%%");
elm_progressbar_value_set(progress, elm_progressbar_value_set(pb,
(double) power->batteries[i]->percent / 100); (double) power->batteries[i]->percent / 100);
evas_object_show(progress); evas_object_show(pb);
elm_box_pack_end(hbox, progress); elm_box_pack_end(hbox, pb);
elm_box_pack_end(vbox, hbox); elm_box_pack_end(vbox, hbox);
elm_object_content_set(frame, vbox); elm_object_content_set(frame, vbox);
elm_box_pack_end(box, frame); elm_box_pack_end(box, frame);
@ -67,14 +67,14 @@ _battery_usage_add(Evas_Object *box, power_t *power)
} }
static Eina_Bool static Eina_Bool
_sensor_usage_add(Evas_Object *box, Sys_Info *sysinfo) _sensor_usage_add(Evas_Object *box, Sys_Info *info)
{ {
Evas_Object *frame, *vbox, *hbox, *progress, *ic, *label; Evas_Object *frame, *vbox, *hbox, *pb, *ic, *label;
sensor_t *snsr; sensor_t *snsr;
for (int i = 0; i < sysinfo->sensor_count; i++) for (int i = 0; i < info->sensor_count; i++)
{ {
snsr = sysinfo->sensors[i]; snsr = info->sensors[i];
frame = elm_frame_add(box); frame = elm_frame_add(box);
evas_object_size_hint_align_set(frame, FILL, FILL); evas_object_size_hint_align_set(frame, FILL, FILL);
@ -109,22 +109,22 @@ _sensor_usage_add(Evas_Object *box, Sys_Info *sysinfo)
evas_object_show(ic); evas_object_show(ic);
elm_box_pack_end(hbox, ic); elm_box_pack_end(hbox, ic);
progress = elm_progressbar_add(frame); pb = elm_progressbar_add(frame);
evas_object_size_hint_align_set(progress, FILL, FILL); evas_object_size_hint_align_set(pb, FILL, FILL);
evas_object_size_hint_weight_set(progress, EXPAND, EXPAND); evas_object_size_hint_weight_set(pb, EXPAND, EXPAND);
elm_progressbar_span_size_set(progress, 1.0); elm_progressbar_span_size_set(pb, 1.0);
elm_progressbar_unit_format_set(progress, "%1.0f°C"); elm_progressbar_unit_format_set(pb, "%1.0f°C");
elm_progressbar_value_set(progress, elm_progressbar_value_set(pb,
(double) snsr->value / 100); (double) snsr->value / 100);
evas_object_show(progress); evas_object_show(pb);
elm_box_pack_end(hbox, progress); elm_box_pack_end(hbox, pb);
elm_box_pack_end(vbox, hbox); elm_box_pack_end(vbox, hbox);
elm_object_content_set(frame, vbox); elm_object_content_set(frame, vbox);
elm_box_pack_end(box, frame); elm_box_pack_end(box, frame);
} }
return !!sysinfo->sensor_count; return !!info->sensor_count;
} }
static char * static char *
@ -149,7 +149,7 @@ _network_transfer_format(double rate)
static void static void
_network_usage_add(Ui *ui, Evas_Object *box, uint64_t bytes, Eina_Bool incoming) _network_usage_add(Ui *ui, Evas_Object *box, uint64_t bytes, Eina_Bool incoming)
{ {
Evas_Object *vbox, *hbox, *label, *progress, *ic; Evas_Object *vbox, *hbox, *label, *pb, *ic;
char *tmp; char *tmp;
vbox = elm_box_add(box); vbox = elm_box_add(box);
@ -181,18 +181,18 @@ _network_usage_add(Ui *ui, Evas_Object *box, uint64_t bytes, Eina_Bool incoming)
evas_object_show(ic); evas_object_show(ic);
elm_box_pack_end(hbox, ic); elm_box_pack_end(hbox, ic);
progress = elm_progressbar_add(box); pb = elm_progressbar_add(box);
evas_object_size_hint_align_set(progress, FILL, FILL); evas_object_size_hint_align_set(pb, FILL, FILL);
evas_object_size_hint_weight_set(progress, EXPAND, EXPAND); evas_object_size_hint_weight_set(pb, EXPAND, EXPAND);
elm_progressbar_span_size_set(progress, 1.0); elm_progressbar_span_size_set(pb, 1.0);
evas_object_show(progress); evas_object_show(pb);
elm_box_pack_end(hbox, progress); elm_box_pack_end(hbox, pb);
elm_box_pack_end(vbox, hbox); elm_box_pack_end(vbox, hbox);
tmp = _network_transfer_format(bytes); tmp = _network_transfer_format(bytes);
if (tmp) if (tmp)
{ {
elm_progressbar_unit_format_set(progress, tmp); elm_progressbar_unit_format_set(pb, tmp);
free(tmp); free(tmp);
} }
@ -202,15 +202,13 @@ _network_usage_add(Ui *ui, Evas_Object *box, uint64_t bytes, Eina_Bool incoming)
{ {
if (ui->incoming_max < bytes) if (ui->incoming_max < bytes)
ui->incoming_max = bytes; ui->incoming_max = bytes;
elm_progressbar_value_set(progress, elm_progressbar_value_set(pb, (double) bytes / ui->incoming_max);
(double) bytes / ui->incoming_max);
} }
else else
{ {
if (ui->outgoing_max < bytes) if (ui->outgoing_max < bytes)
ui->outgoing_max = bytes; ui->outgoing_max = bytes;
elm_progressbar_value_set(progress, elm_progressbar_value_set(pb, (double) bytes / ui->outgoing_max);
(double) bytes / ui->outgoing_max);
} }
} }
@ -275,7 +273,7 @@ ui_tab_misc_add(Ui *ui)
} }
void void
ui_tab_misc_update(Ui *ui, Sys_Info *sysinfo) ui_tab_misc_update(Ui *ui, Sys_Info *info)
{ {
Evas_Object *box, *frame; Evas_Object *box, *frame;
@ -289,12 +287,12 @@ ui_tab_misc_update(Ui *ui, Sys_Info *sysinfo)
evas_object_size_hint_weight_set(box, EXPAND, EXPAND); evas_object_size_hint_weight_set(box, EXPAND, EXPAND);
evas_object_show(box); evas_object_show(box);
_network_usage_add(ui, box, sysinfo->incoming, EINA_TRUE); _network_usage_add(ui, box, info->incoming, EINA_TRUE);
_network_usage_add(ui, box, sysinfo->outgoing, EINA_FALSE); _network_usage_add(ui, box, info->outgoing, EINA_FALSE);
_separator_add(box); _separator_add(box);
if (_battery_usage_add(box, &sysinfo->power)) if (_battery_usage_add(box, &info->power))
_separator_add(box); _separator_add(box);
if (_sensor_usage_add(box, sysinfo)) if (_sensor_usage_add(box, info))
_separator_add(box); _separator_add(box);
frame = elm_frame_add(ui->misc_activity); frame = elm_frame_add(ui->misc_activity);

View File

@ -8,6 +8,6 @@ void
ui_tab_misc_add(Ui *ui); ui_tab_misc_add(Ui *ui);
void void
ui_tab_misc_update(Ui *ui, Sys_Info *sysinfo); ui_tab_misc_update(Ui *ui, Sys_Info *info);
#endif #endif