Sysinfo: Use appropriate format strings and make sure to set format

before value.
devs/devilhorns/rotation
Stephen Houston 4 years ago
parent 30a7c82320
commit 0fd5552c3b
  1. 6
      src/modules/sysinfo/cpuclock/cpuclock.c
  2. 20
      src/modules/sysinfo/memusage/memusage.c
  3. 15
      src/modules/sysinfo/netstatus/netstatus.c
  4. 11
      src/modules/sysinfo/thermal/thermal.c

@ -310,15 +310,15 @@ _cpuclock_popup_create(Instance *inst)
elm_table_pack(table, label, 0, 0, 2, 1);
evas_object_show(label);
snprintf(buf, sizeof(buf), "%1.1f %s (%d %%)", f, u,
snprintf(buf, sizeof(buf), "%1.1f %s (%d %%%%)", f, u,
inst->cfg->cpuclock.percent);
pbar = elm_progressbar_add(table);
E_EXPAND(pbar);
E_FILL(pbar);
elm_progressbar_span_size_set(pbar, 200 * e_scale);
elm_progressbar_value_set(pbar, (float)inst->cfg->cpuclock.percent / 100);
elm_progressbar_unit_format_set(pbar, buf);
elm_progressbar_value_set(pbar, (float)inst->cfg->cpuclock.percent / 100);
elm_table_pack(table, pbar, 0, 1, 2, 1);
evas_object_show(pbar);
inst->cfg->cpuclock.popup_pbar = pbar;
@ -472,7 +472,7 @@ _cpuclock_face_update_current(Instance *inst)
f /= 1000000;
u = _("GHz");
}
snprintf(buf, sizeof(buf), "%1.1f %s (%d %%)", f, u,
snprintf(buf, sizeof(buf), "%1.1f %s (%d %%%%)", f, u,
inst->cfg->cpuclock.percent);
elm_progressbar_unit_format_set(inst->cfg->cpuclock.popup_pbar, buf);
elm_progressbar_value_set(inst->cfg->cpuclock.popup_pbar,

@ -34,33 +34,33 @@ _memusage_popup_update(Instance *inst)
val_mb = inst->cfg->memusage.mem_used / 1024;
val_perc = 100 * ((float)inst->cfg->memusage.mem_used /
(float)inst->cfg->memusage.mem_total);
snprintf(buf, sizeof(buf), "%d MB (%d %%)", val_mb, val_perc);
elm_progressbar_value_set(pbar, (float)val_perc / 100);
snprintf(buf, sizeof(buf), "%d MB (%d %%%%)", val_mb, val_perc);
elm_progressbar_unit_format_set(pbar, buf);
elm_progressbar_value_set(pbar, (float)val_perc / 100);
pbar = evas_object_data_get(inst->cfg->memusage.popup, "mem_buffers_pbar");
val_mb = inst->cfg->memusage.mem_buffers / 1024;
val_perc = 100 * ((float)inst->cfg->memusage.mem_buffers /
(float)inst->cfg->memusage.mem_total);
snprintf(buf, sizeof(buf), "%d MB (%d %%)", val_mb, val_perc);
elm_progressbar_value_set(pbar, (float)val_perc / 100);
snprintf(buf, sizeof(buf), "%d MB (%d %%%%)", val_mb, val_perc);
elm_progressbar_unit_format_set(pbar, buf);
elm_progressbar_value_set(pbar, (float)val_perc / 100);
pbar = evas_object_data_get(inst->cfg->memusage.popup, "mem_cached_pbar");
val_mb = inst->cfg->memusage.mem_cached / 1024;
val_perc = 100 * ((float)inst->cfg->memusage.mem_cached /
(float)inst->cfg->memusage.mem_total);
snprintf(buf, sizeof(buf), "%d MB (%d %%)", val_mb, val_perc);
elm_progressbar_value_set(pbar, (float)val_perc / 100);
snprintf(buf, sizeof(buf), "%d MB (%d %%%%)", val_mb, val_perc);
elm_progressbar_unit_format_set(pbar, buf);
elm_progressbar_value_set(pbar, (float)val_perc / 100);
pbar = evas_object_data_get(inst->cfg->memusage.popup, "mem_shared_pbar");
val_mb = inst->cfg->memusage.mem_shared / 1024;
val_perc = 100 * ((float)inst->cfg->memusage.mem_shared /
(float)inst->cfg->memusage.mem_total);
snprintf(buf, sizeof(buf), "%d MB (%d %%)", val_mb, val_perc);
elm_progressbar_value_set(pbar, (float)val_perc / 100);
snprintf(buf, sizeof(buf), "%d MB (%d %%%%)", val_mb, val_perc);
elm_progressbar_unit_format_set(pbar, buf);
elm_progressbar_value_set(pbar, (float)val_perc / 100);
}
if (inst->cfg->memusage.swp_total)
@ -69,9 +69,9 @@ _memusage_popup_update(Instance *inst)
val_mb = inst->cfg->memusage.swp_used / 1024;
val_perc = 100 * ((float)inst->cfg->memusage.swp_used /
(float)inst->cfg->memusage.swp_total);
snprintf(buf, sizeof(buf), "%d MB (%d %%)", val_mb, val_perc);
elm_progressbar_value_set(pbar, (float)val_perc / 100);
snprintf(buf, sizeof(buf), "%d MB (%d %%%%)", val_mb, val_perc);
elm_progressbar_unit_format_set(pbar, buf);
elm_progressbar_value_set(pbar, (float)val_perc / 100);
}
}

@ -42,19 +42,19 @@ _netstatus_face_update(Thread_Config *thc)
if (thc->inst->cfg->netstatus.popup)
{
char buf[4096];
snprintf(buf, sizeof(buf), "%s (%d %%)",
snprintf(buf, sizeof(buf), "%s (%d %%%%)",
thc->inst->cfg->netstatus.instring,
thc->inst->cfg->netstatus.inpercent);
elm_progressbar_unit_format_set(thc->inst->cfg->netstatus.popup_inpbar, buf);
elm_progressbar_value_set(thc->inst->cfg->netstatus.popup_inpbar,
(float)thc->inst->cfg->netstatus.inpercent / 100);
elm_progressbar_unit_format_set(thc->inst->cfg->netstatus.popup_inpbar, buf);
memset(buf, 0x00, sizeof(buf));
snprintf(buf, sizeof(buf), "%s (%d %%)",
snprintf(buf, sizeof(buf), "%s (%d %%%%)",
thc->inst->cfg->netstatus.outstring,
thc->inst->cfg->netstatus.outpercent);
elm_progressbar_unit_format_set(thc->inst->cfg->netstatus.popup_outpbar, buf);
elm_progressbar_value_set(thc->inst->cfg->netstatus.popup_outpbar,
(float)thc->inst->cfg->netstatus.outpercent / 100);
elm_progressbar_unit_format_set(thc->inst->cfg->netstatus.popup_outpbar, buf);
}
}
@ -124,7 +124,7 @@ _netstatus_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_
elm_table_pack(table, label, 0, 1, 1, 1);
evas_object_show(label);
snprintf(buf, sizeof(buf), "%s (%d %%)",
snprintf(buf, sizeof(buf), "%s (%d %%%%)",
inst->cfg->netstatus.instring,
inst->cfg->netstatus.inpercent);
@ -132,6 +132,7 @@ _netstatus_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_
E_EXPAND(pbar);
E_FILL(pbar);
elm_progressbar_span_size_set(pbar, 200 * e_scale);
elm_progressbar_unit_format_set(pbar, buf);
elm_progressbar_value_set(pbar, (float)inst->cfg->netstatus.inpercent / 100);
elm_table_pack(table, pbar, 1, 1, 1, 1);
evas_object_show(pbar);
@ -144,7 +145,7 @@ _netstatus_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_
evas_object_show(label);
memset(buf, 0x00, sizeof(buf));
snprintf(buf, sizeof(buf), "%s (%d %%)",
snprintf(buf, sizeof(buf), "%s (%d %%%%)",
inst->cfg->netstatus.outstring,
inst->cfg->netstatus.outpercent);
@ -152,8 +153,8 @@ _netstatus_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_
E_EXPAND(pbar);
E_FILL(pbar);
elm_progressbar_span_size_set(pbar, 200 * e_scale);
elm_progressbar_value_set(pbar, (float)inst->cfg->netstatus.outpercent / 100);
elm_progressbar_unit_format_set(pbar, buf);
elm_progressbar_value_set(pbar, (float)inst->cfg->netstatus.outpercent / 100);
elm_table_pack(table, pbar, 1, 2, 1, 1);
evas_object_show(pbar);
inst->cfg->netstatus.popup_outpbar = pbar;

@ -67,13 +67,14 @@ _thermal_apply(Instance *inst, int temp)
char buf[4096];
if (inst->cfg->thermal.units == FAHRENHEIT)
snprintf(buf, sizeof(buf), "%d F (%d %%)",
snprintf(buf, sizeof(buf), "%d F (%d %%%%)",
(int)((inst->cfg->thermal.temp * 9.0 / 5.0) + 32),
inst->cfg->thermal.percent);
else
snprintf(buf, sizeof(buf), "%d C (%d %%)",
snprintf(buf, sizeof(buf), "%d C (%d %%%%)",
(int)inst->cfg->thermal.temp,
inst->cfg->thermal.percent);
elm_progressbar_unit_format_set(inst->cfg->thermal.popup_pbar, buf);
elm_progressbar_value_set(inst->cfg->thermal.popup_pbar,
(float)inst->cfg->thermal.percent / 100);
}
@ -205,19 +206,19 @@ _thermal_popup_create(Instance *inst)
evas_object_show(label);
if (inst->cfg->thermal.units == FAHRENHEIT)
snprintf(buf, sizeof(buf), "%d F (%d %%)",
snprintf(buf, sizeof(buf), "%d F (%d %%%%)",
(int)((inst->cfg->thermal.temp * 9.0 / 5.0) + 32),
inst->cfg->thermal.percent);
else
snprintf(buf, sizeof(buf), "%d C (%d %%)",
snprintf(buf, sizeof(buf), "%d C (%d %%%%)",
(int)inst->cfg->thermal.temp,
inst->cfg->thermal.percent);
pbar = elm_progressbar_add(table);
E_EXPAND(pbar); E_FILL(pbar);
elm_progressbar_span_size_set(pbar, 200 * e_scale);
elm_progressbar_value_set(pbar, (float)inst->cfg->thermal.percent / 100);
elm_progressbar_unit_format_set(pbar, buf);
elm_progressbar_value_set(pbar, (float)inst->cfg->thermal.percent / 100);
elm_table_pack(table, pbar, 0, 1, 2, 1);
evas_object_show(pbar);
inst->cfg->thermal.popup_pbar = pbar;

Loading…
Cancel
Save