ce0214a6 |
1 | /* This file is part of the Linux Trace Toolkit viewer |
2 | * Copyright (C) 2003-2004 Mathieu Desnoyers |
3 | * |
4 | * This program is free software; you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License Version 2 as |
6 | * published by the Free Software Foundation; |
7 | * |
8 | * This program is distributed in the hope that it will be useful, |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * GNU General Public License for more details. |
12 | * |
13 | * You should have received a copy of the GNU General Public License |
14 | * along with this program; if not, write to the Free Software |
15 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
16 | * MA 02111-1307, USA. |
17 | */ |
f0d936c0 |
18 | |
fa2c4dbe |
19 | #include <gtk/gtk.h> |
20 | #include <glib.h> |
d66666fe |
21 | |
22 | #include "processlist.h" |
23 | #include "drawitem.h" |
fa2c4dbe |
24 | |
ca0f8a8e |
25 | #define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format) |
26 | #define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format) |
27 | |
28 | |
f0d936c0 |
29 | /***************************************************************************** |
30 | * Methods to synchronize process list * |
31 | *****************************************************************************/ |
32 | |
f0d936c0 |
33 | /* Enumeration of the columns */ |
34 | enum |
35 | { |
a56a1ba4 |
36 | PROCESS_COLUMN, |
37 | PID_COLUMN, |
e92eabaf |
38 | PPID_COLUMN, |
a56a1ba4 |
39 | BIRTH_S_COLUMN, |
40 | BIRTH_NS_COLUMN, |
d0cd7f09 |
41 | TRACE_COLUMN, |
a56a1ba4 |
42 | N_COLUMNS |
f0d936c0 |
43 | }; |
44 | |
45 | |
a56a1ba4 |
46 | gint process_sort_func ( GtkTreeModel *model, |
47 | GtkTreeIter *it_a, |
48 | GtkTreeIter *it_b, |
49 | gpointer user_data) |
fa2c4dbe |
50 | { |
a56a1ba4 |
51 | GValue a, b; |
52 | |
53 | memset(&a, 0, sizeof(GValue)); |
54 | memset(&b, 0, sizeof(GValue)); |
55 | |
56 | /* Order by PID */ |
57 | gtk_tree_model_get_value( model, |
58 | it_a, |
59 | PID_COLUMN, |
60 | &a); |
61 | |
62 | gtk_tree_model_get_value( model, |
63 | it_b, |
64 | PID_COLUMN, |
65 | &b); |
66 | |
67 | if(G_VALUE_TYPE(&a) == G_TYPE_UINT |
68 | && G_VALUE_TYPE(&b) == G_TYPE_UINT ) |
69 | { |
70 | if(g_value_get_uint(&a) > g_value_get_uint(&b)) |
71 | { |
72 | g_value_unset(&a); |
73 | g_value_unset(&b); |
74 | return 1; |
75 | } |
76 | if(g_value_get_uint(&a) < g_value_get_uint(&b)) |
77 | { |
78 | g_value_unset(&a); |
79 | g_value_unset(&b); |
80 | return 0; |
81 | } |
82 | } |
83 | |
84 | g_value_unset(&a); |
85 | g_value_unset(&b); |
86 | |
87 | |
88 | /* Order by birth second */ |
89 | gtk_tree_model_get_value( model, |
90 | it_a, |
91 | BIRTH_S_COLUMN, |
92 | &a); |
93 | |
94 | gtk_tree_model_get_value( model, |
95 | it_b, |
96 | BIRTH_S_COLUMN, |
97 | &b); |
98 | |
99 | |
100 | if(G_VALUE_TYPE(&a) == G_TYPE_ULONG |
101 | && G_VALUE_TYPE(&b) == G_TYPE_ULONG ) |
102 | { |
103 | if(g_value_get_ulong(&a) > g_value_get_ulong(&b)) |
104 | { |
105 | g_value_unset(&a); |
106 | g_value_unset(&b); |
107 | return 1; |
108 | } |
109 | if(g_value_get_ulong(&a) < g_value_get_ulong(&b)) |
110 | { |
111 | g_value_unset(&a); |
112 | g_value_unset(&b); |
113 | return 0; |
114 | } |
115 | |
116 | } |
117 | |
118 | g_value_unset(&a); |
119 | g_value_unset(&b); |
120 | |
121 | /* Order by birth nanosecond */ |
122 | gtk_tree_model_get_value( model, |
123 | it_a, |
124 | BIRTH_NS_COLUMN, |
125 | &a); |
126 | |
127 | gtk_tree_model_get_value( model, |
128 | it_b, |
129 | BIRTH_NS_COLUMN, |
130 | &b); |
131 | |
132 | |
133 | if(G_VALUE_TYPE(&a) == G_TYPE_ULONG |
134 | && G_VALUE_TYPE(&b) == G_TYPE_ULONG ) |
135 | { |
136 | if(g_value_get_ulong(&a) > g_value_get_ulong(&b)) |
137 | { |
138 | g_value_unset(&a); |
139 | g_value_unset(&b); |
140 | return 1; |
141 | } |
142 | // Final condition |
143 | //if(g_value_get_ulong(&a) < g_value_get_ulong(&b)) |
144 | //{ |
145 | // g_value_unset(&a); |
146 | // g_value_unset(&b); |
147 | // return 0; |
148 | //} |
149 | |
150 | } |
151 | |
152 | g_value_unset(&a); |
153 | g_value_unset(&b); |
154 | |
d0cd7f09 |
155 | /* Order by trace_num */ |
156 | gtk_tree_model_get_value( model, |
157 | it_a, |
158 | TRACE_COLUMN, |
159 | &a); |
160 | |
161 | gtk_tree_model_get_value( model, |
162 | it_b, |
163 | TRACE_COLUMN, |
164 | &b); |
165 | |
166 | if(G_VALUE_TYPE(&a) == G_TYPE_ULONG |
167 | && G_VALUE_TYPE(&b) == G_TYPE_ULONG ) |
168 | { |
169 | if(g_value_get_ulong(&a) > g_value_get_ulong(&b)) |
170 | { |
171 | g_value_unset(&a); |
172 | g_value_unset(&b); |
173 | return 1; |
174 | } |
175 | if(g_value_get_ulong(&a) < g_value_get_ulong(&b)) |
176 | { |
177 | g_value_unset(&a); |
178 | g_value_unset(&b); |
179 | return 0; |
180 | } |
181 | |
182 | } |
183 | |
184 | |
185 | |
a56a1ba4 |
186 | return 0; |
fa2c4dbe |
187 | |
188 | } |
189 | |
fa2c4dbe |
190 | guint hash_fct(gconstpointer key) |
191 | { |
a56a1ba4 |
192 | return ((ProcessInfo*)key)->pid; |
fa2c4dbe |
193 | } |
194 | |
195 | gboolean equ_fct(gconstpointer a, gconstpointer b) |
196 | { |
a56a1ba4 |
197 | if(((ProcessInfo*)a)->pid != ((ProcessInfo*)b)->pid) |
198 | return 0; |
199 | // g_critical("compare %u and %u",((ProcessInfo*)a)->pid,((ProcessInfo*)b)->pid); |
200 | if(((ProcessInfo*)a)->birth.tv_sec != ((ProcessInfo*)b)->birth.tv_sec) |
201 | return 0; |
202 | // g_critical("compare %u and %u",((ProcessInfo*)a)->birth.tv_sec,((ProcessInfo*)b)->birth.tv_sec); |
203 | |
204 | if(((ProcessInfo*)a)->birth.tv_nsec != ((ProcessInfo*)b)->birth.tv_nsec) |
205 | return 0; |
206 | // g_critical("compare %u and %u",((ProcessInfo*)a)->birth.tv_nsec,((ProcessInfo*)b)->birth.tv_nsec); |
207 | |
d0cd7f09 |
208 | if(((ProcessInfo*)a)->trace_num != ((ProcessInfo*)b)->trace_num) |
209 | return 0; |
210 | |
a56a1ba4 |
211 | return 1; |
fa2c4dbe |
212 | } |
213 | |
4c69e0cc |
214 | void destroy_hash_key(gpointer key); |
fa2c4dbe |
215 | |
4c69e0cc |
216 | void destroy_hash_data(gpointer data); |
fa2c4dbe |
217 | |
218 | |
219 | |
220 | |
4c69e0cc |
221 | ProcessList *processlist_construct(void) |
f0d936c0 |
222 | { |
a56a1ba4 |
223 | GtkTreeViewColumn *column; |
224 | GtkCellRenderer *renderer; |
225 | |
ba90bc77 |
226 | ProcessList* process_list = g_new(ProcessList,1); |
a56a1ba4 |
227 | |
ba90bc77 |
228 | process_list->number_of_process = 0; |
a56a1ba4 |
229 | |
230 | /* Create the Process list */ |
f5d980bf |
231 | process_list->list_store = gtk_list_store_new ( N_COLUMNS, |
a56a1ba4 |
232 | G_TYPE_STRING, |
233 | G_TYPE_UINT, |
e92eabaf |
234 | G_TYPE_UINT, |
a56a1ba4 |
235 | G_TYPE_ULONG, |
d0cd7f09 |
236 | G_TYPE_ULONG, |
a56a1ba4 |
237 | G_TYPE_ULONG); |
238 | |
239 | |
f5d980bf |
240 | process_list->process_list_widget = |
a56a1ba4 |
241 | gtk_tree_view_new_with_model |
f5d980bf |
242 | (GTK_TREE_MODEL (process_list->list_store)); |
f5d980bf |
243 | g_object_unref (G_OBJECT (process_list->list_store)); |
a56a1ba4 |
244 | |
245 | gtk_tree_sortable_set_sort_func( |
f5d980bf |
246 | GTK_TREE_SORTABLE(process_list->list_store), |
a56a1ba4 |
247 | PID_COLUMN, |
248 | process_sort_func, |
249 | NULL, |
250 | NULL); |
251 | |
252 | gtk_tree_sortable_set_sort_column_id( |
f5d980bf |
253 | GTK_TREE_SORTABLE(process_list->list_store), |
a56a1ba4 |
254 | PID_COLUMN, |
255 | GTK_SORT_ASCENDING); |
256 | |
14963be0 |
257 | process_list->process_hash = g_hash_table_new_full( |
a56a1ba4 |
258 | hash_fct, equ_fct, |
259 | destroy_hash_key, destroy_hash_data |
260 | ); |
261 | |
262 | |
263 | gtk_tree_view_set_headers_visible( |
3cb8b205 |
264 | GTK_TREE_VIEW(process_list->process_list_widget), TRUE); |
a56a1ba4 |
265 | |
266 | /* Create a column, associating the "text" attribute of the |
267 | * cell_renderer to the first column of the model */ |
268 | /* Columns alignment : 0.0 : Left 0.5 : Center 1.0 : Right */ |
269 | renderer = gtk_cell_renderer_text_new (); |
270 | column = gtk_tree_view_column_new_with_attributes ( "Process", |
271 | renderer, |
272 | "text", |
273 | PROCESS_COLUMN, |
274 | NULL); |
275 | gtk_tree_view_column_set_alignment (column, 0.0); |
276 | gtk_tree_view_column_set_fixed_width (column, 45); |
277 | gtk_tree_view_append_column ( |
f5d980bf |
278 | GTK_TREE_VIEW (process_list->process_list_widget), column); |
b9a010a2 |
279 | |
280 | process_list->button = column->button; |
281 | |
a56a1ba4 |
282 | column = gtk_tree_view_column_new_with_attributes ( "PID", |
283 | renderer, |
284 | "text", |
285 | PID_COLUMN, |
286 | NULL); |
287 | gtk_tree_view_append_column ( |
f5d980bf |
288 | GTK_TREE_VIEW (process_list->process_list_widget), column); |
a56a1ba4 |
289 | |
e92eabaf |
290 | column = gtk_tree_view_column_new_with_attributes ( "PPID", |
291 | renderer, |
292 | "text", |
293 | PPID_COLUMN, |
294 | NULL); |
295 | gtk_tree_view_append_column ( |
296 | GTK_TREE_VIEW (process_list->process_list_widget), column); |
a56a1ba4 |
297 | |
298 | column = gtk_tree_view_column_new_with_attributes ( "Birth sec", |
299 | renderer, |
300 | "text", |
301 | BIRTH_S_COLUMN, |
302 | NULL); |
303 | gtk_tree_view_append_column ( |
f5d980bf |
304 | GTK_TREE_VIEW (process_list->process_list_widget), column); |
a56a1ba4 |
305 | |
306 | //gtk_tree_view_column_set_visible(column, 0); |
307 | // |
308 | column = gtk_tree_view_column_new_with_attributes ( "Birth nsec", |
309 | renderer, |
310 | "text", |
311 | BIRTH_NS_COLUMN, |
312 | NULL); |
313 | gtk_tree_view_append_column ( |
f5d980bf |
314 | GTK_TREE_VIEW (process_list->process_list_widget), column); |
a56a1ba4 |
315 | |
d0cd7f09 |
316 | column = gtk_tree_view_column_new_with_attributes ( "TRACE", |
317 | renderer, |
318 | "text", |
319 | TRACE_COLUMN, |
320 | NULL); |
321 | gtk_tree_view_append_column ( |
322 | GTK_TREE_VIEW (process_list->process_list_widget), column); |
323 | |
324 | |
a56a1ba4 |
325 | //gtk_tree_view_column_set_visible(column, 0); |
326 | |
327 | g_object_set_data_full( |
f5d980bf |
328 | G_OBJECT(process_list->process_list_widget), |
ba90bc77 |
329 | "process_list_Data", |
330 | process_list, |
a56a1ba4 |
331 | (GDestroyNotify)processlist_destroy); |
332 | |
ba90bc77 |
333 | return process_list; |
f0d936c0 |
334 | } |
b9a010a2 |
335 | |
ba90bc77 |
336 | void processlist_destroy(ProcessList *process_list) |
f0d936c0 |
337 | { |
b9a010a2 |
338 | g_debug("processlist_destroy %p", process_list); |
14963be0 |
339 | g_hash_table_destroy(process_list->process_hash); |
340 | process_list->process_hash = NULL; |
f0d936c0 |
341 | |
ba90bc77 |
342 | g_free(process_list); |
b9a010a2 |
343 | g_debug("processlist_destroy end"); |
344 | } |
345 | |
346 | static gboolean remove_hash_item(ProcessInfo *process_info, |
347 | HashedProcessData *hashed_process_data, |
348 | ProcessList *process_list) |
349 | { |
350 | GtkTreePath *tree_path; |
351 | GtkTreeIter iter; |
352 | |
353 | tree_path = gtk_tree_row_reference_get_path( |
354 | hashed_process_data->row_ref); |
355 | |
356 | gtk_tree_model_get_iter ( |
357 | GTK_TREE_MODEL(process_list->list_store), |
358 | &iter, tree_path); |
359 | |
360 | gtk_tree_path_free(tree_path); |
361 | |
362 | gtk_list_store_remove (process_list->list_store, &iter); |
363 | |
b9a010a2 |
364 | return TRUE; /* remove the element from the hash table */ |
f0d936c0 |
365 | } |
366 | |
b9a010a2 |
367 | void processlist_clear(ProcessList *process_list) |
368 | { |
369 | g_info("processlist_clear %p", process_list); |
370 | |
371 | g_hash_table_foreach_remove(process_list->process_hash, |
372 | (GHRFunc)remove_hash_item, |
373 | (gpointer)process_list); |
374 | process_list->number_of_process = 0; |
375 | } |
376 | |
377 | |
ba90bc77 |
378 | GtkWidget *processlist_get_widget(ProcessList *process_list) |
f0d936c0 |
379 | { |
f5d980bf |
380 | return process_list->process_list_widget; |
f0d936c0 |
381 | } |
382 | |
383 | |
384 | |
f5d980bf |
385 | gint get_cell_height(GtkTreeView *tree_view) |
f0d936c0 |
386 | { |
a56a1ba4 |
387 | gint height; |
f5d980bf |
388 | GtkTreeViewColumn *Column = gtk_tree_view_get_column(tree_view, 0); |
a56a1ba4 |
389 | //GList *Render_List = gtk_tree_view_column_get_cell_renderers(Column); |
390 | //GtkCellRenderer *Renderer = g_list_first(Render_List)->data; |
391 | |
392 | //g_list_free(Render_List); |
393 | gtk_tree_view_column_cell_get_size(Column, NULL, NULL, NULL, NULL, &height); |
394 | //g_critical("cell 0 height : %u",height); |
395 | |
396 | return height; |
f0d936c0 |
397 | } |
398 | |
4c69e0cc |
399 | void destroy_hash_key(gpointer key) |
f0d936c0 |
400 | { |
a56a1ba4 |
401 | g_free(key); |
fa2c4dbe |
402 | } |
403 | |
4c69e0cc |
404 | void destroy_hash_data(gpointer data) |
fa2c4dbe |
405 | { |
a56a1ba4 |
406 | g_free(data); |
fa2c4dbe |
407 | } |
408 | |
ba90bc77 |
409 | int processlist_add( ProcessList *process_list, |
a56a1ba4 |
410 | guint pid, |
e92eabaf |
411 | guint ppid, |
a56a1ba4 |
412 | LttTime *birth, |
d0cd7f09 |
413 | guint trace_num, |
51705146 |
414 | const gchar *name, |
a56a1ba4 |
415 | guint *height, |
f5d980bf |
416 | HashedProcessData **pm_hashed_process_data) |
fa2c4dbe |
417 | { |
a56a1ba4 |
418 | GtkTreeIter iter ; |
419 | ProcessInfo *Process_Info = g_new(ProcessInfo, 1); |
14963be0 |
420 | HashedProcessData *hashed_process_data = g_new(HashedProcessData, 1); |
f5d980bf |
421 | *pm_hashed_process_data = hashed_process_data; |
a56a1ba4 |
422 | |
423 | Process_Info->pid = pid; |
e92eabaf |
424 | Process_Info->ppid = ppid; |
a56a1ba4 |
425 | Process_Info->birth = *birth; |
d0cd7f09 |
426 | Process_Info->trace_num = trace_num; |
b9a010a2 |
427 | |
428 | /* When we create it from before state update, we are sure that the |
429 | * last event occured before the beginning of the global area. |
430 | * |
431 | * If it is created after state update, this value (0) will be |
432 | * overriden by the new state before anything is drawn. |
433 | */ |
434 | hashed_process_data->x = 0; |
a56a1ba4 |
435 | |
b9a010a2 |
436 | #if 0 |
14963be0 |
437 | hashed_process_data->draw_context = g_new(DrawContext, 1); |
438 | hashed_process_data->draw_context->drawable = NULL; |
439 | hashed_process_data->draw_context->gc = NULL; |
440 | hashed_process_data->draw_context->pango_layout = NULL; |
441 | hashed_process_data->draw_context->current = g_new(DrawInfo,1); |
442 | hashed_process_data->draw_context->current->over = g_new(ItemInfo,1); |
443 | hashed_process_data->draw_context->current->over->x = -1; |
444 | hashed_process_data->draw_context->current->over->y = -1; |
445 | hashed_process_data->draw_context->current->middle = g_new(ItemInfo,1); |
446 | hashed_process_data->draw_context->current->middle->x = -1; |
447 | hashed_process_data->draw_context->current->middle->y = -1; |
448 | hashed_process_data->draw_context->current->under = g_new(ItemInfo,1); |
449 | hashed_process_data->draw_context->current->under->x = -1; |
450 | hashed_process_data->draw_context->current->under->y = -1; |
451 | hashed_process_data->draw_context->current->modify_over = g_new(ItemInfo,1); |
452 | hashed_process_data->draw_context->current->modify_over->x = -1; |
453 | hashed_process_data->draw_context->current->modify_over->y = -1; |
454 | hashed_process_data->draw_context->current->modify_middle = g_new(ItemInfo,1); |
455 | hashed_process_data->draw_context->current->modify_middle->x = -1; |
456 | hashed_process_data->draw_context->current->modify_middle->y = -1; |
457 | hashed_process_data->draw_context->current->modify_under = g_new(ItemInfo,1); |
458 | hashed_process_data->draw_context->current->modify_under->x = -1; |
459 | hashed_process_data->draw_context->current->modify_under->y = -1; |
460 | hashed_process_data->draw_context->current->status = LTTV_STATE_UNNAMED; |
461 | hashed_process_data->draw_context->previous = g_new(DrawInfo,1); |
462 | hashed_process_data->draw_context->previous->over = g_new(ItemInfo,1); |
463 | hashed_process_data->draw_context->previous->over->x = -1; |
464 | hashed_process_data->draw_context->previous->over->y = -1; |
465 | hashed_process_data->draw_context->previous->middle = g_new(ItemInfo,1); |
466 | hashed_process_data->draw_context->previous->middle->x = -1; |
467 | hashed_process_data->draw_context->previous->middle->y = -1; |
468 | hashed_process_data->draw_context->previous->under = g_new(ItemInfo,1); |
469 | hashed_process_data->draw_context->previous->under->x = -1; |
470 | hashed_process_data->draw_context->previous->under->y = -1; |
471 | hashed_process_data->draw_context->previous->modify_over = g_new(ItemInfo,1); |
472 | hashed_process_data->draw_context->previous->modify_over->x = -1; |
473 | hashed_process_data->draw_context->previous->modify_over->y = -1; |
474 | hashed_process_data->draw_context->previous->modify_middle = g_new(ItemInfo,1); |
475 | hashed_process_data->draw_context->previous->modify_middle->x = -1; |
476 | hashed_process_data->draw_context->previous->modify_middle->y = -1; |
477 | hashed_process_data->draw_context->previous->modify_under = g_new(ItemInfo,1); |
478 | hashed_process_data->draw_context->previous->modify_under->x = -1; |
479 | hashed_process_data->draw_context->previous->modify_under->y = -1; |
480 | hashed_process_data->draw_context->previous->status = LTTV_STATE_UNNAMED; |
b9a010a2 |
481 | #endif //0 |
482 | |
a56a1ba4 |
483 | /* Add a new row to the model */ |
f5d980bf |
484 | gtk_list_store_append ( process_list->list_store, &iter); |
a56a1ba4 |
485 | //g_critical ( "iter before : %s", gtk_tree_path_to_string ( |
486 | // gtk_tree_model_get_path ( |
f5d980bf |
487 | // GTK_TREE_MODEL(process_list->list_store), |
a56a1ba4 |
488 | // &iter))); |
f5d980bf |
489 | gtk_list_store_set ( process_list->list_store, &iter, |
a56a1ba4 |
490 | PROCESS_COLUMN, name, |
491 | PID_COLUMN, pid, |
e92eabaf |
492 | PPID_COLUMN, ppid, |
a56a1ba4 |
493 | BIRTH_S_COLUMN, birth->tv_sec, |
494 | BIRTH_NS_COLUMN, birth->tv_nsec, |
d0cd7f09 |
495 | TRACE_COLUMN, trace_num, |
a56a1ba4 |
496 | -1); |
f5d980bf |
497 | hashed_process_data->row_ref = gtk_tree_row_reference_new ( |
498 | GTK_TREE_MODEL(process_list->list_store), |
a56a1ba4 |
499 | gtk_tree_model_get_path( |
f5d980bf |
500 | GTK_TREE_MODEL(process_list->list_store), |
a56a1ba4 |
501 | &iter)); |
14963be0 |
502 | g_hash_table_insert( process_list->process_hash, |
a56a1ba4 |
503 | (gpointer)Process_Info, |
14963be0 |
504 | (gpointer)hashed_process_data); |
a56a1ba4 |
505 | |
506 | //g_critical ( "iter after : %s", gtk_tree_path_to_string ( |
507 | // gtk_tree_model_get_path ( |
f5d980bf |
508 | // GTK_TREE_MODEL(process_list->list_store), |
a56a1ba4 |
509 | // &iter))); |
ba90bc77 |
510 | process_list->number_of_process++; |
a56a1ba4 |
511 | |
f5d980bf |
512 | *height = get_cell_height(GTK_TREE_VIEW(process_list->process_list_widget)) |
ba90bc77 |
513 | * process_list->number_of_process ; |
a56a1ba4 |
514 | |
515 | |
516 | return 0; |
517 | |
f0d936c0 |
518 | } |
519 | |
ba90bc77 |
520 | int processlist_remove( ProcessList *process_list, |
a56a1ba4 |
521 | guint pid, |
d0cd7f09 |
522 | LttTime *birth, |
523 | guint trace_num) |
f0d936c0 |
524 | { |
a56a1ba4 |
525 | ProcessInfo Process_Info; |
526 | gint *path_indices; |
14963be0 |
527 | HashedProcessData *hashed_process_data; |
a56a1ba4 |
528 | GtkTreeIter iter; |
529 | |
530 | Process_Info.pid = pid; |
531 | Process_Info.birth = *birth; |
d0cd7f09 |
532 | Process_Info.trace_num = trace_num; |
a56a1ba4 |
533 | |
534 | |
14963be0 |
535 | if(hashed_process_data = |
a56a1ba4 |
536 | (HashedProcessData*)g_hash_table_lookup( |
14963be0 |
537 | process_list->process_hash, |
a56a1ba4 |
538 | &Process_Info)) |
539 | { |
51705146 |
540 | GtkTreePath *tree_path; |
541 | |
542 | tree_path = gtk_tree_row_reference_get_path( |
543 | hashed_process_data->row_ref); |
544 | |
a56a1ba4 |
545 | gtk_tree_model_get_iter ( |
f5d980bf |
546 | GTK_TREE_MODEL(process_list->list_store), |
51705146 |
547 | &iter, tree_path); |
548 | |
549 | gtk_tree_path_free(tree_path); |
a56a1ba4 |
550 | |
f5d980bf |
551 | gtk_list_store_remove (process_list->list_store, &iter); |
e800cf84 |
552 | |
14963be0 |
553 | g_hash_table_remove(process_list->process_hash, |
a56a1ba4 |
554 | &Process_Info); |
555 | |
ba90bc77 |
556 | process_list->number_of_process--; |
a56a1ba4 |
557 | |
558 | return 0; |
559 | } else { |
560 | return 1; |
561 | } |
fa2c4dbe |
562 | } |
563 | |
564 | |
ba90bc77 |
565 | guint processlist_get_height(ProcessList *process_list) |
fa2c4dbe |
566 | { |
f5d980bf |
567 | return get_cell_height(GTK_TREE_VIEW(process_list->process_list_widget)) |
ba90bc77 |
568 | * process_list->number_of_process ; |
f0d936c0 |
569 | } |
fa2c4dbe |
570 | |
571 | |
ba90bc77 |
572 | gint processlist_get_process_pixels( ProcessList *process_list, |
d0cd7f09 |
573 | guint pid, LttTime *birth, guint trace_num, |
a56a1ba4 |
574 | guint *y, |
575 | guint *height, |
f5d980bf |
576 | HashedProcessData **pm_hashed_process_data) |
fa2c4dbe |
577 | { |
a56a1ba4 |
578 | ProcessInfo Process_Info; |
579 | gint *path_indices; |
580 | GtkTreePath *tree_path; |
14963be0 |
581 | HashedProcessData *hashed_process_data = NULL; |
a56a1ba4 |
582 | |
583 | Process_Info.pid = pid; |
584 | Process_Info.birth = *birth; |
d0cd7f09 |
585 | Process_Info.trace_num = trace_num; |
a56a1ba4 |
586 | |
14963be0 |
587 | if(hashed_process_data = |
a56a1ba4 |
588 | (HashedProcessData*)g_hash_table_lookup( |
14963be0 |
589 | process_list->process_hash, |
a56a1ba4 |
590 | &Process_Info)) |
591 | { |
592 | tree_path = gtk_tree_row_reference_get_path( |
f5d980bf |
593 | hashed_process_data->row_ref); |
a56a1ba4 |
594 | path_indices = gtk_tree_path_get_indices (tree_path); |
595 | |
596 | *height = get_cell_height( |
f5d980bf |
597 | GTK_TREE_VIEW(process_list->process_list_widget)); |
a56a1ba4 |
598 | *y = *height * path_indices[0]; |
f5d980bf |
599 | *pm_hashed_process_data = hashed_process_data; |
51705146 |
600 | gtk_tree_path_free(tree_path); |
601 | |
a56a1ba4 |
602 | return 0; |
603 | } else { |
f5d980bf |
604 | *pm_hashed_process_data = hashed_process_data; |
a56a1ba4 |
605 | return 1; |
606 | } |
fa2c4dbe |
607 | |
fa2c4dbe |
608 | } |
8b90e648 |
609 | |
610 | |
ba90bc77 |
611 | gint processlist_get_pixels_from_data( ProcessList *process_list, |
a56a1ba4 |
612 | ProcessInfo *process_info, |
14963be0 |
613 | HashedProcessData *hashed_process_data, |
a56a1ba4 |
614 | guint *y, |
615 | guint *height) |
8b90e648 |
616 | { |
a56a1ba4 |
617 | gint *path_indices; |
618 | GtkTreePath *tree_path; |
8b90e648 |
619 | |
a56a1ba4 |
620 | tree_path = gtk_tree_row_reference_get_path( |
f5d980bf |
621 | hashed_process_data->row_ref); |
a56a1ba4 |
622 | path_indices = gtk_tree_path_get_indices (tree_path); |
8b90e648 |
623 | |
a56a1ba4 |
624 | *height = get_cell_height( |
f5d980bf |
625 | GTK_TREE_VIEW(process_list->process_list_widget)); |
a56a1ba4 |
626 | *y = *height * path_indices[0]; |
51705146 |
627 | gtk_tree_path_free(tree_path); |
8b90e648 |
628 | |
a56a1ba4 |
629 | return 0; |
8b90e648 |
630 | |
631 | } |