netstar pushed a commit to branch master.

http://git.enlightenment.org/apps/evisum.git/commit/?id=c5b32b94752c6ced5ceb65a288e85b79daad842f

commit c5b32b94752c6ced5ceb65a288e85b79daad842f
Author: Alastair Poole <nets...@gmail.com>
Date:   Sun Feb 7 12:58:54 2021 +0000

    summary:
---
 src/bin/system/process.c     | 13 ++++++--
 src/bin/system/process.h     |  1 +
 src/bin/ui/ui_process_list.c | 75 ++++++++++++++++++++++++++++++++++++--------
 3 files changed, 74 insertions(+), 15 deletions(-)

diff --git a/src/bin/system/process.c b/src/bin/system/process.c
index f1d67fa..184a92c 100644
--- a/src/bin/system/process.c
+++ b/src/bin/system/process.c
@@ -330,6 +330,7 @@ _process_list_linux_get(void)
         p->cpu_id = st.psr;
         p->start = st.start_time;
         p->run_time = st.run_time;
+       if (toupper(st.state) == 'S') p->ssleep = 1;
         state = _process_state_name(st.state);
         snprintf(p->state, sizeof(p->state), "%s", state);
         p->cpu_time = st.utime + st.stime;
@@ -369,6 +370,7 @@ _proc_thread_info(Proc_Info *p)
         Proc_Info *t = calloc(1, sizeof(Proc_Info));
         if (!t) continue;
         t->cpu_id = st.psr;
+       if (toupper(st.state) == 'S') p->ssleep = 1;
         state = _process_state_name(st.state);
         snprintf(t->state, sizeof(t->state), "%s", state);
         t->cpu_time = st.utime + st.stime;
@@ -405,6 +407,7 @@ proc_info_by_pid(int pid)
    p->cpu_id = st.psr;
    p->start = st.start_time;
    p->run_time = st.run_time;
+   if (toupper(st.state) == 'S') p->ssleep = 1;
    state = _process_state_name(st.state);
    snprintf(p->state, sizeof(p->state), "%s", state);
    p->cpu_time = st.utime + st.stime;
@@ -440,7 +443,10 @@ _proc_get(Proc_Info *p, struct kinfo_proc *kp)
    p->run_time = kp->p_uutime_sec + kp->p_ustime_sec +
                  (kp->p_uutime_usec / 1000000) + (kp->p_ustime_usec / 1000000);
    if (kp->p_stat == SSLEEP)
-     state = kp->p_wmesg;
+     {
+        state = kp->p_wmesg;
+        p->ssleep = 1;
+     }
    else
      state = _process_state_name(kp->p_stat);
    snprintf(p->state, sizeof(p->state), "%s", state);
@@ -909,7 +915,10 @@ _proc_thread_info(struct kinfo_proc *kp, Eina_Bool 
is_thread)
        (usage->ru_stime.tv_sec * 1000000) + usage->ru_stime.tv_usec) / 10000;
    p->run_time = (kp->ki_runtime + 500000) / 1000000;
    if (kp->ki_stat == SSLEEP)
-     state = kp->ki_wmesg;
+     {
+        state = kp->ki_wmesg;
+        p->ssleep = 1;
+     }
    else
      state = _process_state_name(kp->ki_stat);
    snprintf(p->state, sizeof(p->state), "%s", state);
diff --git a/src/bin/system/process.h b/src/bin/system/process.h
index 6c18dce..20229e4 100644
--- a/src/bin/system/process.h
+++ b/src/bin/system/process.h
@@ -30,6 +30,7 @@ typedef struct _Proc_Info
 
    char       *command;
    char       *arguments;
+   int         ssleep;
    char        state[32];
 
    short       is_kernel;
diff --git a/src/bin/ui/ui_process_list.c b/src/bin/ui/ui_process_list.c
index b812929..a246c73 100644
--- a/src/bin/ui/ui_process_list.c
+++ b/src/bin/ui/ui_process_list.c
@@ -68,6 +68,15 @@ typedef struct
    Evas_Object            *btn_state;
    Evas_Object            *btn_time;
    Evas_Object            *btn_cpu_usage;
+
+   struct
+   {
+      Evas_Object         *lb;
+      int                  total;
+      int                  running;
+      int                  sleeping;
+      int                  stopped;
+   } summary;
 } Ui_Data;
 
 static Ui_Data *_pd = NULL;
@@ -436,6 +445,17 @@ _bring_in(void *data)
    return 0;
 }
 
+static void
+_update_summary(Ui_Data *pd)
+{
+   const char *txt =
+      eina_slstr_printf("%i processes: %i running, %i sleeping, %i stopped.",
+                        pd->summary.total, pd->summary.running,
+                        pd->summary.sleeping, pd->summary.stopped);
+
+   elm_object_text_set(pd->summary.lb, txt);
+}
+
 static Eina_List *
 _process_list_sort(Eina_List *list, Ui_Data *pd)
 {
@@ -485,6 +505,9 @@ _process_list_search_trim(Eina_List *list, Ui_Data *pd)
    Proc_Info *proc;
    Ui *ui = pd->ui;
 
+   pd->summary.total = pd->summary.running = pd->summary.sleeping = 0;
+   pd->summary.stopped = 0;
+
    EINA_LIST_FOREACH_SAFE(list, l, l_next, proc)
      {
         if ((proc->pid == ui->program_pid) ||
@@ -516,6 +539,12 @@ _process_list_search_trim(Eina_List *list, Ui_Data *pd)
                       eina_hash_add(pd->cpu_times, &id, cpu_time);
                    }
               }
+           pd->summary.total++;
+           if ((!strcmp(proc->state, "run")) || (!strcmp(proc->state, 
"onproc")))
+              pd->summary.running++;
+           pd->summary.sleeping += proc->ssleep;
+           if (!strcmp(proc->state, "stop"))
+              pd->summary.stopped++;
          }
      }
 
@@ -586,11 +615,14 @@ _process_list_feedback_cb(void *data, Ecore_Thread 
*thread EINA_UNUSED,
    Eina_List *list;
    Proc_Info *proc;
    Elm_Object_Item *it;
+   int n;
 
    pd = data;
    list = msg;
 
-   _genlist_ensure_n_items(pd->genlist, eina_list_count(list), &pd->itc);
+   n = eina_list_count(list);
+
+   _genlist_ensure_n_items(pd->genlist, n, &pd->itc);
 
    it = elm_genlist_first_item_get(pd->genlist);
    EINA_LIST_FREE(list, proc)
@@ -611,9 +643,11 @@ _process_list_feedback_cb(void *data, Ecore_Thread *thread 
EINA_UNUSED,
 
    elm_genlist_realized_items_update(pd->genlist);
 
+   _update_summary(pd);
+
 #if DIRTY_GENLIST_HACK
    Eina_List *real = elm_genlist_realized_items_get(pd->genlist);
-   int n = eina_list_count(pd->cache->active);
+   n = eina_list_count(pd->cache->active);
    if (n > eina_list_count(real) * 2)
      {
         evisum_ui_item_cache_steal(pd->cache, real);
@@ -1126,6 +1160,7 @@ static Evas_Object *
 _ui_content_system_add(Ui_Data *pd, Evas_Object *parent)
 {
    Evas_Object *tb, *btn, *list, *rec;
+   Evas_Object *fr, *lb;
    Ui *ui = pd->ui;
    int i = 0;
 
@@ -1148,7 +1183,7 @@ _ui_content_system_add(Ui_Data *pd, Evas_Object *parent)
             (ui->proc.sort_type == SORT_BY_CMD ?
             ui->proc.sort_reverse : 0),
             ui->proc.sort_type == SORT_BY_CMD);
-   evas_object_size_hint_weight_set(btn, 1.0, 0);
+   evas_object_size_hint_weight_set(btn, 1.0, 1.0);
    evas_object_size_hint_align_set(btn, FILL, FILL);
    elm_object_text_set(btn, _("command"));
    evas_object_show(btn);
@@ -1161,7 +1196,7 @@ _ui_content_system_add(Ui_Data *pd, Evas_Object *parent)
             (ui->proc.sort_type == SORT_BY_UID ?
             ui->proc.sort_reverse : 0),
             ui->proc.sort_type == SORT_BY_UID);
-   evas_object_size_hint_weight_set(btn, 1.0, 0);
+   evas_object_size_hint_weight_set(btn, 1.0, 1.0);
    evas_object_size_hint_align_set(btn, FILL, FILL);
    elm_object_text_set(btn, _("user"));
    evas_object_show(btn);
@@ -1177,7 +1212,7 @@ _ui_content_system_add(Ui_Data *pd, Evas_Object *parent)
             (ui->proc.sort_type == SORT_BY_PID ?
             ui->proc.sort_reverse : 0),
             ui->proc.sort_type == SORT_BY_PID);
-   evas_object_size_hint_weight_set(btn, 1.0, 0);
+   evas_object_size_hint_weight_set(btn, 1.0, 1.0);
    evas_object_size_hint_align_set(btn, FILL, FILL);
    elm_object_text_set(btn, _("pid"));
    evas_object_show(btn);
@@ -1192,7 +1227,7 @@ _ui_content_system_add(Ui_Data *pd, Evas_Object *parent)
             (ui->proc.sort_type == SORT_BY_THREADS ?
             ui->proc.sort_reverse : 0),
             ui->proc.sort_type == SORT_BY_THREADS);
-   evas_object_size_hint_weight_set(btn, 1.0, 0);
+   evas_object_size_hint_weight_set(btn, 1.0, 1.0);
    evas_object_size_hint_align_set(btn, FILL, FILL);
    elm_object_text_set(btn, _("thr"));
    evas_object_show(btn);
@@ -1207,7 +1242,7 @@ _ui_content_system_add(Ui_Data *pd, Evas_Object *parent)
             (ui->proc.sort_type == SORT_BY_PRI ?
             ui->proc.sort_reverse : 0),
             ui->proc.sort_type == SORT_BY_PRI);
-   evas_object_size_hint_weight_set(btn, 1.0, 0);
+   evas_object_size_hint_weight_set(btn, 1.0, 1.0);
    evas_object_size_hint_align_set(btn, FILL, FILL);
    elm_object_text_set(btn, _("prio"));
    evas_object_show(btn);
@@ -1222,7 +1257,7 @@ _ui_content_system_add(Ui_Data *pd, Evas_Object *parent)
             (ui->proc.sort_type == SORT_BY_NICE ?
             ui->proc.sort_reverse : 0),
             ui->proc.sort_type == SORT_BY_NICE);
-   evas_object_size_hint_weight_set(btn, 1.0, 0);
+   evas_object_size_hint_weight_set(btn, 1.0, 1.0);
    evas_object_size_hint_align_set(btn, FILL, FILL);
    elm_object_text_set(btn, _("nice"));
    evas_object_show(btn);
@@ -1237,7 +1272,7 @@ _ui_content_system_add(Ui_Data *pd, Evas_Object *parent)
             (ui->proc.sort_type == SORT_BY_SIZE ?
             ui->proc.sort_reverse : 0),
             ui->proc.sort_type == SORT_BY_SIZE);
-   evas_object_size_hint_weight_set(btn, 1.0, 0);
+   evas_object_size_hint_weight_set(btn, 1.0, 1.0);
    evas_object_size_hint_align_set(btn, FILL, FILL);
    elm_object_text_set(btn, _("size"));
    evas_object_show(btn);
@@ -1252,7 +1287,7 @@ _ui_content_system_add(Ui_Data *pd, Evas_Object *parent)
             (ui->proc.sort_type == SORT_BY_RSS ?
             ui->proc.sort_reverse : 0),
             ui->proc.sort_type == SORT_BY_RSS);
-   evas_object_size_hint_weight_set(btn, 1.0, 0);
+   evas_object_size_hint_weight_set(btn, 1.0, 1.0);
    evas_object_size_hint_align_set(btn, FILL, FILL);
    elm_object_text_set(btn, _("res"));
    evas_object_show(btn);
@@ -1267,7 +1302,7 @@ _ui_content_system_add(Ui_Data *pd, Evas_Object *parent)
             (ui->proc.sort_type == SORT_BY_STATE ?
             ui->proc.sort_reverse : 0),
             ui->proc.sort_type == SORT_BY_STATE);
-   evas_object_size_hint_weight_set(btn, 1.0, 0);
+   evas_object_size_hint_weight_set(btn, 1.0, 1.0);
    evas_object_size_hint_align_set(btn, FILL, FILL);
    elm_object_text_set(btn, _("state"));
    evas_object_show(btn);
@@ -1282,7 +1317,7 @@ _ui_content_system_add(Ui_Data *pd, Evas_Object *parent)
             (ui->proc.sort_type == SORT_BY_TIME ?
             ui->proc.sort_reverse : 0),
             ui->proc.sort_type == SORT_BY_TIME);
-   evas_object_size_hint_weight_set(btn, 1.0, 0);
+   evas_object_size_hint_weight_set(btn, 1.0, 1.0);
    evas_object_size_hint_align_set(btn, FILL, FILL);
    elm_object_text_set(btn, _("time"));
    evas_object_show(btn);
@@ -1297,7 +1332,7 @@ _ui_content_system_add(Ui_Data *pd, Evas_Object *parent)
             (ui->proc.sort_type == SORT_BY_CPU_USAGE ?
             ui->proc.sort_reverse : 0),
             ui->proc.sort_type == SORT_BY_CPU_USAGE);
-   evas_object_size_hint_weight_set(btn, 1.0, 0);
+   evas_object_size_hint_weight_set(btn, 1.0, 1.0);
    evas_object_size_hint_align_set(btn, FILL, FILL);
    elm_object_text_set(btn, _("cpu %"));
    evas_object_show(btn);
@@ -1334,6 +1369,20 @@ _ui_content_system_add(Ui_Data *pd, Evas_Object *parent)
    evas_object_smart_callback_add(pd->genlist, "unrealized",
                                   _item_unrealized_cb, pd);
 
+   fr = elm_frame_add(parent);
+   elm_object_style_set(fr, "pad_small");
+   evas_object_size_hint_weight_set(fr, EXPAND, 0);
+   evas_object_size_hint_align_set(fr, 0, FILL);
+   evas_object_show(fr);
+
+   pd->summary.lb = lb = elm_label_add(fr);
+   evas_object_size_hint_weight_set(lb, EXPAND, 0);
+   evas_object_size_hint_align_set(lb, 0.0, FILL);
+   evas_object_show(lb);
+
+   elm_object_content_set(fr, lb);
+   elm_table_pack(tb, fr, 0, 3, i, 1);
+
    return tb;
 }
 

-- 


Reply via email to