netstar pushed a commit to branch master.

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

commit 561b42e953a51a3c804c05ec1732be1a304a13b2
Author: Alastair Poole <nets...@gmail.com>
Date:   Sat Nov 7 02:14:13 2020 +0000

    process_view: pstree sort by age and refresh on tab change.
---
 src/bin/ui/ui_process_view.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/bin/ui/ui_process_view.c b/src/bin/ui/ui_process_view.c
index 366ffbf..b8a3952 100644
--- a/src/bin/ui/ui_process_view.c
+++ b/src/bin/ui/ui_process_view.c
@@ -206,7 +206,7 @@ _genlist_ensure_n_items(Evas_Object *genlist, unsigned int 
items)
    for (i = existing; i < items; i++)
      {
         elm_genlist_item_append(genlist, itc, NULL, NULL,
-                        ELM_GENLIST_ITEM_NONE, NULL, NULL);
+                                ELM_GENLIST_ITEM_NONE, NULL, NULL);
      }
 
    elm_genlist_item_class_free(itc);
@@ -412,6 +412,14 @@ _tree_del(void *data, Evas_Object *obj EINA_UNUSED)
    proc_info_free(proc);
 }
 
+static int
+_sort_by_age(const void *p1, const void *p2)
+{
+   const Proc_Info *c1 = p1, *c2 = p2;
+
+   return c1->start - c2->start;
+}
+
 static void
 _tree_populate(Evas_Object *genlist_tree, Elm_Object_Item *parent, Eina_List 
*children)
 {
@@ -433,7 +441,10 @@ _tree_populate(Evas_Object *genlist_tree, Elm_Object_Item 
*parent, Eina_List *ch
                       child->children ? ELM_GENLIST_ITEM_TREE : 
ELM_GENLIST_ITEM_NONE, NULL, NULL);
         elm_genlist_item_update(it);
         if (child->children)
-          _tree_populate(genlist_tree, it, child->children);
+          {
+             child->children = eina_list_sort(child->children, 
eina_list_count(child->children), _sort_by_age);
+             _tree_populate(genlist_tree, it, child->children);
+          }
      }
 
    elm_genlist_item_class_free(itc);
@@ -446,6 +457,8 @@ _tree_view_update(void *data)
    Proc_Info *child;
    Ui_Process *ui = data;
 
+   elm_genlist_clear(ui->genlist_tree);
+
    if (ui->selected_pid == 0) return EINA_FALSE;
 
    children = proc_info_pid_children_get(ui->selected_pid);
@@ -453,6 +466,7 @@ _tree_view_update(void *data)
      {
         if (child->pid == ui->selected_pid)
           {
+             child->children = eina_list_sort(child->children, 
eina_list_count(child->children), _sort_by_age);
              _tree_populate(ui->genlist_tree, NULL, child->children);
              break;
           }
@@ -1072,6 +1086,7 @@ _btn_tree_clicked_cb(void *data, Evas_Object *obj 
EINA_UNUSED,
 
    ui = data;
 
+   _tree_view_update(ui);
    _hide_all(ui, obj);
    evas_object_show(ui->tree_view);
 }
@@ -1224,7 +1239,6 @@ _win_del_cb(void *data, Evas_Object *obj EINA_UNUSED,
    ui  = data;
    win = obj;
 
-
    if (ui->hash_cpu_times)
      eina_hash_free(ui->hash_cpu_times);
    if (ui->timer_pid)

-- 


Reply via email to