upt-gui: use value (not string) for sorting
Stefan Schuermans

Stefan Schuermans commited on 2020-05-24 10:50:21
Showing 2 changed files, with 39 additions and 16 deletions.

... ...
@@ -17,14 +17,22 @@
17 17
       <!-- column-name proc_id -->
18 18
       <column type="gint"/>
19 19
       <!-- column-name begin_timestamp -->
20
+      <column type="gdouble"/>
21
+      <!-- column-name begin_timestamp_text -->
20 22
       <column type="gchararray"/>
21 23
       <!-- column-name end_timestamp -->
24
+      <column type="gdouble"/>
25
+      <!-- column-name end_timestamp_text -->
22 26
       <column type="gchararray"/>
23 27
       <!-- column-name cmdline -->
24 28
       <column type="gchararray"/>
25 29
       <!-- column-name cpu_time -->
30
+      <column type="gdouble"/>
31
+      <!-- column-name cpu_time_text -->
26 32
       <column type="gchararray"/>
27 33
       <!-- column-name max_rss_kb -->
34
+      <column type="gint"/>
35
+      <!-- column-name max_rss_kb_text -->
28 36
       <column type="gchararray"/>
29 37
     </columns>
30 38
   </object>
... ...
@@ -76,7 +84,7 @@
76 84
                         <child>
77 85
                           <object class="GtkCellRendererText" id="ProcessesBeginText"/>
78 86
                           <attributes>
79
-                            <attribute name="text">1</attribute>
87
+                            <attribute name="text">2</attribute>
80 88
                           </attributes>
81 89
                         </child>
82 90
                       </object>
... ...
@@ -89,11 +97,11 @@
89 97
                         <property name="clickable">True</property>
90 98
                         <property name="reorderable">True</property>
91 99
                         <property name="sort_indicator">True</property>
92
-                        <property name="sort_column_id">2</property>
100
+                        <property name="sort_column_id">3</property>
93 101
                         <child>
94 102
                           <object class="GtkCellRendererText" id="ProcessesEndText"/>
95 103
                           <attributes>
96
-                            <attribute name="text">2</attribute>
104
+                            <attribute name="text">4</attribute>
97 105
                           </attributes>
98 106
                         </child>
99 107
                       </object>
... ...
@@ -106,11 +114,11 @@
106 114
                         <property name="clickable">True</property>
107 115
                         <property name="reorderable">True</property>
108 116
                         <property name="sort_indicator">True</property>
109
-                        <property name="sort_column_id">3</property>
117
+                        <property name="sort_column_id">5</property>
110 118
                         <child>
111 119
                           <object class="GtkCellRendererText" id="ProcessesCommandText"/>
112 120
                           <attributes>
113
-                            <attribute name="text">3</attribute>
121
+                            <attribute name="text">5</attribute>
114 122
                           </attributes>
115 123
                         </child>
116 124
                       </object>
... ...
@@ -123,11 +131,11 @@
123 131
                         <property name="clickable">True</property>
124 132
                         <property name="reorderable">True</property>
125 133
                         <property name="sort_indicator">True</property>
126
-                        <property name="sort_column_id">4</property>
134
+                        <property name="sort_column_id">6</property>
127 135
                         <child>
128 136
                           <object class="GtkCellRendererText" id="ProcessesCpuTimeText"/>
129 137
                           <attributes>
130
-                            <attribute name="text">4</attribute>
138
+                            <attribute name="text">7</attribute>
131 139
                           </attributes>
132 140
                         </child>
133 141
                       </object>
... ...
@@ -140,11 +148,11 @@
140 148
                         <property name="clickable">True</property>
141 149
                         <property name="reorderable">True</property>
142 150
                         <property name="sort_indicator">True</property>
143
-                        <property name="sort_column_id">5</property>
151
+                        <property name="sort_column_id">8</property>
144 152
                         <child>
145 153
                           <object class="GtkCellRendererText" id="ProcessesMemoryText"/>
146 154
                           <attributes>
147
-                            <attribute name="text">5</attribute>
155
+                            <attribute name="text">9</attribute>
148 156
                           </attributes>
149 157
                         </child>
150 158
                       </object>
... ...
@@ -99,11 +99,15 @@ class UptGui:
99 99
     DETAIL_KEY = 1
100 100
     DETAIL_VALUE = 2
101 101
     PROC_PROC_ID = 0
102
-    PROC_BEGIN = 1
103
-    PROC_END = 2
104
-    PROC_CMDLINE = 3
105
-    PROC_CPU_TIME = 4
106
-    PROC_MAX_RSS_KB = 5
102
+    PROC_BEGIN_TIMESTAMP = 1
103
+    PROC_BEGIN_TIMESTAMP_TEXT = 2
104
+    PROC_END_TIMESTAMP = 3
105
+    PROC_END_TIMESTAMP_TEXT = 4
106
+    PROC_CMDLINE = 5
107
+    PROC_CPU_TIME = 6
108
+    PROC_CPU_TIME_TEXT = 7
109
+    PROC_MAX_RSS_KB = 8
110
+    PROC_MAX_RSS_KB_TEXT = 9
107 111
 
108 112
     def __init__(self, proto_filename):
109 113
         """
... ...
@@ -217,16 +221,27 @@ class UptGui:
217 221
             proc_iter = self.widProcessesTree.append(parent_iter)
218 222
             self.widProcessesTree.set_value(proc_iter, self.PROC_PROC_ID,
219 223
                                             proc.proc_id)
224
+            self.widProcessesTree.set_value(proc_iter,
225
+                                            self.PROC_BEGIN_TIMESTAMP,
226
+                                            proc.begin_timestamp)
220 227
             self.widProcessesTree.set_value(
221
-                proc_iter, self.PROC_BEGIN,
228
+                proc_iter, self.PROC_BEGIN_TIMESTAMP_TEXT,
222 229
                 timestamp2str(proc.begin_timestamp))
223
-            self.widProcessesTree.set_value(proc_iter, self.PROC_END,
230
+            self.widProcessesTree.set_value(proc_iter, self.PROC_END_TIMESTAMP,
231
+                                            proc.end_timestamp)
232
+            self.widProcessesTree.set_value(proc_iter,
233
+                                            self.PROC_END_TIMESTAMP_TEXT,
224 234
                                             timestamp2str(proc.end_timestamp))
225 235
             self.widProcessesTree.set_value(proc_iter, self.PROC_CMDLINE,
226 236
                                             cmdline2str(proc.cmdline))
227 237
             self.widProcessesTree.set_value(proc_iter, self.PROC_CPU_TIME,
238
+                                            proc.cpu_time)
239
+            self.widProcessesTree.set_value(proc_iter, self.PROC_CPU_TIME_TEXT,
228 240
                                             duration2str(proc.cpu_time))
229 241
             self.widProcessesTree.set_value(proc_iter, self.PROC_MAX_RSS_KB,
242
+                                            proc.max_rss_kb)
243
+            self.widProcessesTree.set_value(proc_iter,
244
+                                            self.PROC_MAX_RSS_KB_TEXT,
230 245
                                             kb2str(proc.max_rss_kb))
231 246
             to_be_output.append((proc.children, proc_iter))
232 247
         # show all processes
233 248