From 3931125e54252397dff2a44da83335f20e8e508a Mon Sep 17 00:00:00 2001 From: Alastair Poole Date: Wed, 3 Mar 2021 18:48:44 +0000 Subject: [PATCH] procview: horrrible naming but no block --- src/bin/ui/ui_process_view.c | 123 ++++++++++++++++++----------------- 1 file changed, 63 insertions(+), 60 deletions(-) diff --git a/src/bin/ui/ui_process_view.c b/src/bin/ui/ui_process_view.c index 97d8a33..953ccd4 100644 --- a/src/bin/ui/ui_process_view.c +++ b/src/bin/ui/ui_process_view.c @@ -835,6 +835,67 @@ _run_time_string(int64_t secs) return strdup(buf); } +static void +_manual_cb(void *data, Ecore_Thread *thread) +{ + Eina_List *lines; + char *line; + char buf[4096]; + int n = 1; + Ui_Data *pd = data; + + setenv("MANWIDTH", "75", 1); + + ecore_thread_feedback(thread, strdup("")); + snprintf(buf, sizeof(buf), "man %s | col -bx", pd->selected_cmd); + lines = _exe_response(buf); + if (!lines) + { + snprintf(buf, sizeof(buf), _("No documentation found for %s."), + pd->selected_cmd); + ecore_thread_feedback(thread, strdup(buf)); + } + + EINA_LIST_FREE(lines, line) + { + if (n++ > 1) + { + snprintf(buf, sizeof(buf), "%s
", line); + ecore_thread_feedback(thread, strdup(buf)); + } + free(line); + } + + ecore_thread_feedback(thread, strdup("
")); + + unsetenv("MANWIDTH"); + pd->manual.init = 1; +} + +static void +_manual_feedback_cb(void *data, Ecore_Thread *thread, void *msgdata) +{ + Ui_Data *pd = data; + Evas_Object *ent = pd->manual.entry; + char *s = msgdata; + + elm_entry_entry_append(ent, s); + + free(s); +} + +static void +_manual_init(Ui_Data *pd) +{ + if ((!pd->selected_cmd) || (!pd->selected_cmd[0]) || (strchr(pd->selected_cmd, ' '))) + return; + + ecore_thread_feedback_run(_manual_cb, + _manual_feedback_cb, + NULL, NULL, pd, 1); +} + + static void _general_view_update(Ui_Data *pd, Proc_Info *proc) { @@ -1548,66 +1609,9 @@ _tab_manual_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED, pd = data; _tab_change(pd, pd->manual_view, obj); elm_object_focus_set(pd->tab_general, 1); -} + if (pd->manual.init) return; -static void -_manual_get_cb(void *data, Ecore_Thread *thread) -{ - Eina_List *lines; - char *line; - char buf[4096]; - int n = 1; - Ui_Data *pd = data; - - setenv("MANWIDTH", "75", 1); - - ecore_thread_feedback(thread, strdup("")); - snprintf(buf, sizeof(buf), "man %s | col -bx", pd->selected_cmd); - lines = _exe_response(buf); - if (!lines) - { - snprintf(buf, sizeof(buf), _("No documentation found for %s."), - pd->selected_cmd); - ecore_thread_feedback(thread, strdup(buf)); - } - - EINA_LIST_FREE(lines, line) - { - if (n++ > 1) - { - snprintf(buf, sizeof(buf), "%s
", line); - ecore_thread_feedback(thread, strdup(buf)); - } - free(line); - } - - ecore_thread_feedback(thread, strdup("
")); - - unsetenv("MANWIDTH"); - pd->manual.init = 1; -} - -static void -_manual_feedback_cb(void *data, Ecore_Thread *thread, void *msgdata) -{ - Ui_Data *pd = data; - Evas_Object *ent = pd->manual.entry; - char *s = msgdata; - - elm_entry_entry_append(ent, s); - - free(s); -} - -static void -_manual_init(Ui_Data *pd) -{ - if ((!pd->selected_cmd) || (!pd->selected_cmd[0]) || (strchr(pd->selected_cmd, ' '))) - return; - - ecore_thread_feedback_run(_manual_cb, - _manual_feedback_cb, - NULL, NULL, pd, 1); + _manual_init(pd); } static Evas_Object * @@ -1827,7 +1831,6 @@ ui_process_view_win_add(int pid, Evisum_Proc_Action action) elm_win_center(win, 1, 1); evas_object_show(win); - _manual_init(pd); _action_do(pd, action); pd->threads.cache = evisum_ui_item_cache_new(pd->threads.glist,