ui: tidy and man page tidy

This commit is contained in:
Alastair Poole 2020-12-24 08:55:14 +00:00
parent 57663dd0b2
commit b36da60b16
3 changed files with 103 additions and 93 deletions

View File

@ -709,7 +709,7 @@ static Evas_Object *
_process_tab_add(Evas_Object *parent, Ui_Data *pd)
{
Evas_Object *fr, *hbox, *tbl;
Evas_Object *lb, *entry, *button, *border, *ic;
Evas_Object *lb, *entry, *btn, *pad, *ic;
Evas_Object *rec;
Proc_Info *proc;
int i = 0;
@ -847,73 +847,73 @@ _process_tab_add(Evas_Object *parent, Ui_Data *pd)
evas_object_show(hbox);
elm_table_pack(tbl, hbox, 1, i, 2, 1);
border = elm_frame_add(parent);
evas_object_size_hint_weight_set(border, EXPAND, EXPAND);
elm_object_style_set(border, "pad_small");
evas_object_show(border);
elm_box_pack_end(hbox, border);
border = elm_frame_add(parent);
evas_object_size_hint_weight_set(border, EXPAND, EXPAND);
elm_object_style_set(border, "pad_small");
evas_object_show(border);
elm_box_pack_end(hbox, border);
pad = elm_frame_add(parent);
evas_object_size_hint_weight_set(pad, EXPAND, EXPAND);
elm_object_style_set(pad, "pad_small");
evas_object_show(pad);
elm_box_pack_end(hbox, pad);
pad = elm_frame_add(parent);
evas_object_size_hint_weight_set(pad, EXPAND, EXPAND);
elm_object_style_set(pad, "pad_small");
evas_object_show(pad);
elm_box_pack_end(hbox, pad);
button = elm_button_add(parent);
evas_object_size_hint_align_set(button, FILL, FILL);
evas_object_size_hint_weight_set(button, EXPAND, EXPAND);
elm_object_text_set(button, _("Stop"));
evas_object_smart_callback_add(button, "clicked", _btn_stop_clicked_cb, pd);
evas_object_show(button);
pd->btn_stop = button;
btn = elm_button_add(parent);
evas_object_size_hint_align_set(btn, FILL, FILL);
evas_object_size_hint_weight_set(btn, EXPAND, EXPAND);
elm_object_text_set(btn, _("Stop"));
evas_object_smart_callback_add(btn, "clicked", _btn_stop_clicked_cb, pd);
evas_object_show(btn);
pd->btn_stop = btn;
ic = elm_icon_add(button);
ic = elm_icon_add(btn);
elm_icon_standard_set(ic, evisum_icon_path_get("stop"));
elm_object_part_content_set(button, "icon", ic);
elm_object_part_content_set(btn, "icon", ic);
evas_object_show(ic);
elm_box_pack_end(hbox, button);
elm_box_pack_end(hbox, btn);
button = elm_button_add(parent);
evas_object_size_hint_align_set(button, FILL, FILL);
evas_object_size_hint_weight_set(button, EXPAND, EXPAND);
elm_object_text_set(button, _("Start"));
evas_object_smart_callback_add(button, "clicked", _btn_start_clicked_cb, pd);
evas_object_show(button);
pd->btn_start = button;
btn = elm_button_add(parent);
evas_object_size_hint_align_set(btn, FILL, FILL);
evas_object_size_hint_weight_set(btn, EXPAND, EXPAND);
elm_object_text_set(btn, _("Start"));
evas_object_smart_callback_add(btn, "clicked", _btn_start_clicked_cb, pd);
evas_object_show(btn);
pd->btn_start = btn;
ic = elm_icon_add(button);
ic = elm_icon_add(btn);
elm_icon_standard_set(ic, evisum_icon_path_get("start"));
elm_object_part_content_set(button, "icon", ic);
elm_object_part_content_set(btn, "icon", ic);
evas_object_show(ic);
elm_box_pack_end(hbox, button);
elm_box_pack_end(hbox, btn);
button = elm_button_add(parent);
evas_object_size_hint_align_set(button, FILL, FILL);
evas_object_size_hint_weight_set(button, EXPAND, EXPAND);
elm_object_text_set(button, _("Kill"));
evas_object_smart_callback_add(button, "clicked", _btn_kill_clicked_cb, pd);
evas_object_show(button);
pd->btn_kill = button;
btn = elm_button_add(parent);
evas_object_size_hint_align_set(btn, FILL, FILL);
evas_object_size_hint_weight_set(btn, EXPAND, EXPAND);
elm_object_text_set(btn, _("Kill"));
evas_object_smart_callback_add(btn, "clicked", _btn_kill_clicked_cb, pd);
evas_object_show(btn);
pd->btn_kill = btn;
ic = elm_icon_add(button);
ic = elm_icon_add(btn);
elm_icon_standard_set(ic, evisum_icon_path_get("kill"));
elm_object_part_content_set(button, "icon", ic);
elm_object_part_content_set(btn, "icon", ic);
evas_object_show(ic);
elm_box_pack_end(hbox, button);
elm_box_pack_end(hbox, btn);
return fr;
}
static void
_btn_icon_state_set(Evas_Object *button, Eina_Bool reverse)
_btn_icon_state_set(Evas_Object *btn, Eina_Bool reverse)
{
Evas_Object *icon = elm_icon_add(button);
Evas_Object *icon = elm_icon_add(btn);
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"));
elm_object_part_content_set(button, "icon", icon);
elm_object_part_content_set(btn, "icon", icon);
evas_object_color_set(icon, 255, 255, 255, 255);
evas_object_show(icon);
@ -1106,6 +1106,8 @@ static Evas_Object *
_info_tab_add(Evas_Object *parent, Ui_Data *pd)
{
Evas_Object *fr, *box, *entry;
Evas_Object *tb;
int sz;
fr = elm_frame_add(parent);
evas_object_size_hint_weight_set(fr, EXPAND, EXPAND);
@ -1128,6 +1130,11 @@ _info_tab_add(Evas_Object *parent, Ui_Data *pd)
evas_object_show(entry);
elm_box_pack_end(box, entry);
tb = elm_entry_textblock_get(entry);
sz = evisum_ui_textblock_font_size_get(tb);
evisum_ui_textblock_font_size_set(tb, sz - 2);
return fr;
}
@ -1197,8 +1204,9 @@ _btn_info_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
if (pd->info_init) return;
setenv("MANWIDTH", "80", 1);
if (pd->selected_cmd && pd->selected_cmd[0] && !strchr(pd->selected_cmd, ' '))
lines =_exe_response(eina_slstr_printf("man %s | col -b", pd->selected_cmd));
lines =_exe_response(eina_slstr_printf("man %s | col -bx", pd->selected_cmd));
if (!lines)
{
@ -1218,7 +1226,7 @@ _btn_info_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
int n = 1;
Eina_Strbuf *buf = eina_strbuf_new();
eina_strbuf_append(buf, "<code>");
eina_strbuf_append(buf,"<code>");
n = 1;
EINA_LIST_FREE(lines, line)
@ -1232,6 +1240,7 @@ _btn_info_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
eina_strbuf_free(buf);
}
unsetenv("MANWIDTH");
pd->info_init = EINA_TRUE;
}

View File

@ -10,9 +10,9 @@ static Eina_Hash *_icon_cache = NULL;
Evas_Object *
evisum_ui_tab_add(Evas_Object *parent, Evas_Object **alias, const char *text,
Evas_Smart_Cb clicked_cb, void *data)
Evas_Smart_Cb clicked_cb, void *data)
{
Evas_Object *tbl, *rect, *button, *label;
Evas_Object *tbl, *rect, *btn, *lb;
tbl = elm_table_add(parent);
evas_object_size_hint_weight_set(tbl, EXPAND, EXPAND);
@ -25,34 +25,34 @@ evisum_ui_tab_add(Evas_Object *parent, Evas_Object **alias, const char *text,
TAB_BTN_WIDTH * elm_config_scale_get(),
TAB_BTN_HEIGHT * elm_config_scale_get());
button = elm_button_add(parent);
evas_object_size_hint_weight_set(button, EXPAND, EXPAND);
evas_object_size_hint_align_set(button, FILL, FILL);
evas_object_show(button);
evas_object_smart_callback_add(button, "clicked", clicked_cb, data);
btn = elm_button_add(parent);
evas_object_size_hint_weight_set(btn, EXPAND, EXPAND);
evas_object_size_hint_align_set(btn, FILL, FILL);
evas_object_show(btn);
evas_object_smart_callback_add(btn, "clicked", clicked_cb, data);
label = elm_label_add(parent);
evas_object_size_hint_weight_set(label, EXPAND, EXPAND);
evas_object_size_hint_align_set(label, FILL, FILL);
evas_object_show(label);
elm_object_text_set(label,
lb = elm_label_add(parent);
evas_object_size_hint_weight_set(lb, EXPAND, EXPAND);
evas_object_size_hint_align_set(lb, FILL, FILL);
evas_object_show(lb);
elm_object_text_set(lb,
eina_slstr_printf("%s", text));
elm_layout_content_set(button, "elm.swallow.content", label);
elm_layout_content_set(btn, "elm.swallow.content", lb);
elm_table_pack(tbl, rect, 0, 0, 1, 1);
elm_table_pack(tbl, button, 0, 0, 1, 1);
elm_table_pack(tbl, btn, 0, 0, 1, 1);
if (alias)
*alias = button;
*alias = btn;
return tbl;
}
Evas_Object *
evisum_ui_button_add(Evas_Object *parent, Evas_Object **alias, const char *text,
const char *icon, Evas_Smart_Cb clicked_cb, void *data)
evisum_ui_btn_add(Evas_Object *parent, Evas_Object **alias, const char *text,
const char *icon, Evas_Smart_Cb clicked_cb, void *data)
{
Evas_Object *tbl, *rect, *button, *label, *hbx, *ic;
Evas_Object *tbl, *rect, *btn, *lb, *hbx, *ic;
tbl = elm_table_add(parent);
evas_object_size_hint_weight_set(tbl, EXPAND, EXPAND);
@ -65,11 +65,11 @@ evisum_ui_button_add(Evas_Object *parent, Evas_Object **alias, const char *text,
BTN_WIDTH * elm_config_scale_get(),
BTN_HEIGHT * elm_config_scale_get());
button = elm_button_add(parent);
evas_object_size_hint_weight_set(button, EXPAND, EXPAND);
evas_object_size_hint_align_set(button, FILL, FILL);
evas_object_show(button);
evas_object_smart_callback_add(button, "clicked", clicked_cb, data);
btn = elm_button_add(parent);
evas_object_size_hint_weight_set(btn, EXPAND, EXPAND);
evas_object_size_hint_align_set(btn, FILL, FILL);
evas_object_show(btn);
evas_object_smart_callback_add(btn, "clicked", clicked_cb, data);
hbx = elm_box_add(parent);
elm_box_horizontal_set(hbx, EINA_TRUE);
@ -85,21 +85,21 @@ evisum_ui_button_add(Evas_Object *parent, Evas_Object **alias, const char *text,
elm_box_pack_end(hbx, ic);
label = elm_label_add(parent);
evas_object_size_hint_weight_set(label, 1.0, EXPAND);
evas_object_size_hint_align_set(label, FILL, FILL);
evas_object_show(label);
elm_object_text_set(label,
lb = elm_label_add(parent);
evas_object_size_hint_weight_set(lb, 1.0, EXPAND);
evas_object_size_hint_align_set(lb, FILL, FILL);
evas_object_show(lb);
elm_object_text_set(lb,
eina_slstr_printf("%s", text));
elm_box_pack_end(hbx, label);
elm_layout_content_set(button, "elm.swallow.content", hbx);
elm_box_pack_end(hbx, lb);
elm_layout_content_set(btn, "elm.swallow.content", hbx);
elm_table_pack(tbl, rect, 0, 0, 1, 1);
elm_table_pack(tbl, button, 0, 0, 1, 1);
elm_table_pack(tbl, btn, 0, 0, 1, 1);
if (alias)
*alias = button;
*alias = btn;
return tbl;
}
@ -236,7 +236,7 @@ evisum_ui_textblock_font_size_set(Evas_Object *tb, int new_size)
ts = evas_textblock_style_new();
evas_textblock_style_set(ts,
eina_slstr_printf("DEFAULT='font_size=%d'", new_size));
eina_slstr_printf("font='monospace' DEFAULT='font_size=%d'", new_size));
evas_object_textblock_style_user_push(tb, ts);
}
@ -287,7 +287,7 @@ evisum_child_window_show(Evas_Object *parent, Evas_Object *win)
typedef struct {
Ui *ui;
Evas_Object *label;
Evas_Object *lb;
Evas_Object *win;
Evas_Object *bg;
Evas_Object *im;
@ -335,7 +335,7 @@ _about_resize_cb(void *data, Evas *e, Evas_Object *obj EINA_UNUSED,
{
Animate_Data *ad = data;
evas_object_hide(ad->label);
evas_object_hide(ad->lb);
}
static Eina_Bool
@ -351,9 +351,9 @@ about_anim(void *data)
evas_object_geometry_get(ad->bg, NULL, NULL, &w, &h);
if (w <= 0 || h <= 0) return EINA_TRUE;
evas_object_geometry_get(ad->label, &x, NULL, &ow, &oh);
evas_object_move(ad->label, x, ad->pos);
evas_object_show(ad->label);
evas_object_geometry_get(ad->lb, &x, NULL, &ow, &oh);
evas_object_move(ad->lb, x, ad->pos);
evas_object_show(ad->lb);
ad->pos--;
@ -395,7 +395,7 @@ evisum_about_window_show(void *data)
{
Ui *ui;
Animate_Data *about;
Evas_Object *win, *bg, *tbl, *version, *label, *btn, *im;
Evas_Object *win, *bg, *tbl, *version, *lb, *btn, *im;
Evas_Object *hbx, *rec, *br;
Evas_Coord x, y, w, h;
Evas_Coord iw, ih;
@ -444,10 +444,10 @@ evisum_about_window_show(void *data)
elm_win_resize_object_add(tbl, win);
elm_table_align_set(tbl, 0, 0);
label = elm_label_add(win);
evas_object_size_hint_align_set(label, 0.0, 0.5);
evas_object_size_hint_weight_set(label, EXPAND, 0);
elm_object_text_set(label, copyright);
lb = elm_label_add(win);
evas_object_size_hint_align_set(lb, 0.0, 0.5);
evas_object_size_hint_weight_set(lb, EXPAND, 0);
elm_object_text_set(lb, copyright);
evas_object_geometry_get(win, &x, &y, &w, &h);
@ -462,7 +462,7 @@ evisum_about_window_show(void *data)
about = malloc(sizeof(Animate_Data));
about->win = win;
about->bg = bg;
about->label = label;
about->lb = lb;
about->pos = elm_config_scale_get() * 320;
about->ui = ui;
about->im = im;
@ -522,7 +522,7 @@ evisum_about_window_show(void *data)
evas_object_smart_callback_add(btn, "clicked", _btn_close_cb, about);
elm_table_pack(tbl, label, 0, 1, 1, 1);
elm_table_pack(tbl, lb, 0, 1, 1, 1);
elm_table_pack(tbl, im, 0, 1, 1, 1);
elm_table_pack(tbl, rec, 0, 0, 1, 1);
elm_table_pack(tbl, hbx, 0, 0, 1, 1);

View File

@ -10,6 +10,7 @@ _man2entry(const char *text)
int i = 0, len = strlen(text) + 1;
str = malloc(len);
if (!str) return NULL;
p = text;
while (*p)
@ -58,8 +59,8 @@ _evisum_docs(void)
{
const char *txt =
"<b>Congratulations you found the documentation!</b><br><br>"
"Control + K - Toggle kernel threads. <br>"
"Control + E - Show Self. <br>";
"<br>"
"There isn't any!.<br>";
return txt;
}