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, |
38 | BIRTH_S_COLUMN, |
39 | BIRTH_NS_COLUMN, |
d0cd7f09 |
40 | TRACE_COLUMN, |
a56a1ba4 |
41 | N_COLUMNS |
f0d936c0 |
42 | }; |
43 | |
44 | |
a56a1ba4 |
45 | gint process_sort_func ( GtkTreeModel *model, |
46 | GtkTreeIter *it_a, |
47 | GtkTreeIter *it_b, |
48 | gpointer user_data) |
fa2c4dbe |
49 | { |
a56a1ba4 |
50 | GValue a, b; |
51 | |
52 | memset(&a, 0, sizeof(GValue)); |
53 | memset(&b, 0, sizeof(GValue)); |
54 | |
55 | /* Order by PID */ |
56 | gtk_tree_model_get_value( model, |
57 | it_a, |
58 | PID_COLUMN, |
59 | &a); |
60 | |
61 | gtk_tree_model_get_value( model, |
62 | it_b, |
63 | PID_COLUMN, |
64 | &b); |
65 | |
66 | if(G_VALUE_TYPE(&a) == G_TYPE_UINT |
67 | && G_VALUE_TYPE(&b) == G_TYPE_UINT ) |
68 | { |
69 | if(g_value_get_uint(&a) > g_value_get_uint(&b)) |
70 | { |
71 | g_value_unset(&a); |
72 | g_value_unset(&b); |
73 | return 1; |
74 | } |
75 | if(g_value_get_uint(&a) < g_value_get_uint(&b)) |
76 | { |
77 | g_value_unset(&a); |
78 | g_value_unset(&b); |
79 | return 0; |
80 | } |
81 | } |
82 | |
83 | g_value_unset(&a); |
84 | g_value_unset(&b); |
85 | |
86 | |
87 | /* Order by birth second */ |
88 | gtk_tree_model_get_value( model, |
89 | it_a, |
90 | BIRTH_S_COLUMN, |
91 | &a); |
92 | |
93 | gtk_tree_model_get_value( model, |
94 | it_b, |
95 | BIRTH_S_COLUMN, |
96 | &b); |
97 | |
98 | |
99 | if(G_VALUE_TYPE(&a) == G_TYPE_ULONG |
100 | && G_VALUE_TYPE(&b) == G_TYPE_ULONG ) |
101 | { |
102 | if(g_value_get_ulong(&a) > g_value_get_ulong(&b)) |
103 | { |
104 | g_value_unset(&a); |
105 | g_value_unset(&b); |
106 | return 1; |
107 | } |
108 | if(g_value_get_ulong(&a) < g_value_get_ulong(&b)) |
109 | { |
110 | g_value_unset(&a); |
111 | g_value_unset(&b); |
112 | return 0; |
113 | } |
114 | |
115 | } |
116 | |
117 | g_value_unset(&a); |
118 | g_value_unset(&b); |
119 | |
120 | /* Order by birth nanosecond */ |
121 | gtk_tree_model_get_value( model, |
122 | it_a, |
123 | BIRTH_NS_COLUMN, |
124 | &a); |
125 | |
126 | gtk_tree_model_get_value( model, |
127 | it_b, |
128 | BIRTH_NS_COLUMN, |
129 | &b); |
130 | |
131 | |
132 | if(G_VALUE_TYPE(&a) == G_TYPE_ULONG |
133 | && G_VALUE_TYPE(&b) == G_TYPE_ULONG ) |
134 | { |
135 | if(g_value_get_ulong(&a) > g_value_get_ulong(&b)) |
136 | { |
137 | g_value_unset(&a); |
138 | g_value_unset(&b); |
139 | return 1; |
140 | } |
141 | // Final condition |
142 | //if(g_value_get_ulong(&a) < g_value_get_ulong(&b)) |
143 | //{ |
144 | // g_value_unset(&a); |
145 | // g_value_unset(&b); |
146 | // return 0; |
147 | //} |
148 | |
149 | } |
150 | |
151 | g_value_unset(&a); |
152 | g_value_unset(&b); |
153 | |
d0cd7f09 |
154 | /* Order by trace_num */ |
155 | gtk_tree_model_get_value( model, |
156 | it_a, |
157 | TRACE_COLUMN, |
158 | &a); |
159 | |
160 | gtk_tree_model_get_value( model, |
161 | it_b, |
162 | TRACE_COLUMN, |
163 | &b); |
164 | |
165 | if(G_VALUE_TYPE(&a) == G_TYPE_ULONG |
166 | && G_VALUE_TYPE(&b) == G_TYPE_ULONG ) |
167 | { |
168 | if(g_value_get_ulong(&a) > g_value_get_ulong(&b)) |
169 | { |
170 | g_value_unset(&a); |
171 | g_value_unset(&b); |
172 | return 1; |
173 | } |
174 | if(g_value_get_ulong(&a) < g_value_get_ulong(&b)) |
175 | { |
176 | g_value_unset(&a); |
177 | g_value_unset(&b); |
178 | return 0; |
179 | } |
180 | |
181 | } |
182 | |
183 | |
184 | |
a56a1ba4 |
185 | return 0; |
fa2c4dbe |
186 | |
187 | } |
188 | |
fa2c4dbe |
189 | guint hash_fct(gconstpointer key) |
190 | { |
a56a1ba4 |
191 | return ((ProcessInfo*)key)->pid; |
fa2c4dbe |
192 | } |
193 | |
194 | gboolean equ_fct(gconstpointer a, gconstpointer b) |
195 | { |
a56a1ba4 |
196 | if(((ProcessInfo*)a)->pid != ((ProcessInfo*)b)->pid) |
197 | return 0; |
198 | // g_critical("compare %u and %u",((ProcessInfo*)a)->pid,((ProcessInfo*)b)->pid); |
199 | if(((ProcessInfo*)a)->birth.tv_sec != ((ProcessInfo*)b)->birth.tv_sec) |
200 | return 0; |
201 | // g_critical("compare %u and %u",((ProcessInfo*)a)->birth.tv_sec,((ProcessInfo*)b)->birth.tv_sec); |
202 | |
203 | if(((ProcessInfo*)a)->birth.tv_nsec != ((ProcessInfo*)b)->birth.tv_nsec) |
204 | return 0; |
205 | // g_critical("compare %u and %u",((ProcessInfo*)a)->birth.tv_nsec,((ProcessInfo*)b)->birth.tv_nsec); |
206 | |
d0cd7f09 |
207 | if(((ProcessInfo*)a)->trace_num != ((ProcessInfo*)b)->trace_num) |
208 | return 0; |
209 | |
a56a1ba4 |
210 | return 1; |
fa2c4dbe |
211 | } |
212 | |
4c69e0cc |
213 | void destroy_hash_key(gpointer key); |
fa2c4dbe |
214 | |
4c69e0cc |
215 | void destroy_hash_data(gpointer data); |
fa2c4dbe |
216 | |
217 | |
218 | |
219 | |
4c69e0cc |
220 | ProcessList *processlist_construct(void) |
f0d936c0 |
221 | { |
a56a1ba4 |
222 | GtkTreeViewColumn *column; |
223 | GtkCellRenderer *renderer; |
224 | |
ba90bc77 |
225 | ProcessList* process_list = g_new(ProcessList,1); |
a56a1ba4 |
226 | |
ba90bc77 |
227 | process_list->number_of_process = 0; |
a56a1ba4 |
228 | |
229 | /* Create the Process list */ |
f5d980bf |
230 | process_list->list_store = gtk_list_store_new ( N_COLUMNS, |
a56a1ba4 |
231 | G_TYPE_STRING, |
232 | G_TYPE_UINT, |
233 | G_TYPE_ULONG, |
d0cd7f09 |
234 | G_TYPE_ULONG, |
a56a1ba4 |
235 | G_TYPE_ULONG); |
236 | |
237 | |
f5d980bf |
238 | process_list->process_list_widget = |
a56a1ba4 |
239 | gtk_tree_view_new_with_model |
f5d980bf |
240 | (GTK_TREE_MODEL (process_list->list_store)); |
a56a1ba4 |
241 | |
f5d980bf |
242 | g_object_unref (G_OBJECT (process_list->list_store)); |
a56a1ba4 |
243 | |
244 | gtk_tree_sortable_set_sort_func( |
f5d980bf |
245 | GTK_TREE_SORTABLE(process_list->list_store), |
a56a1ba4 |
246 | PID_COLUMN, |
247 | process_sort_func, |
248 | NULL, |
249 | NULL); |
250 | |
251 | gtk_tree_sortable_set_sort_column_id( |
f5d980bf |
252 | GTK_TREE_SORTABLE(process_list->list_store), |
a56a1ba4 |
253 | PID_COLUMN, |
254 | GTK_SORT_ASCENDING); |
255 | |
14963be0 |
256 | process_list->process_hash = g_hash_table_new_full( |
a56a1ba4 |
257 | hash_fct, equ_fct, |
258 | destroy_hash_key, destroy_hash_data |
259 | ); |
260 | |
261 | |
262 | gtk_tree_view_set_headers_visible( |
3cb8b205 |
263 | GTK_TREE_VIEW(process_list->process_list_widget), TRUE); |
a56a1ba4 |
264 | |
265 | /* Create a column, associating the "text" attribute of the |
266 | * cell_renderer to the first column of the model */ |
267 | /* Columns alignment : 0.0 : Left 0.5 : Center 1.0 : Right */ |
268 | renderer = gtk_cell_renderer_text_new (); |
269 | column = gtk_tree_view_column_new_with_attributes ( "Process", |
270 | renderer, |
271 | "text", |
272 | PROCESS_COLUMN, |
273 | NULL); |
274 | gtk_tree_view_column_set_alignment (column, 0.0); |
275 | gtk_tree_view_column_set_fixed_width (column, 45); |
276 | gtk_tree_view_append_column ( |
f5d980bf |
277 | GTK_TREE_VIEW (process_list->process_list_widget), column); |
a56a1ba4 |
278 | |
279 | column = gtk_tree_view_column_new_with_attributes ( "PID", |
280 | renderer, |
281 | "text", |
282 | PID_COLUMN, |
283 | NULL); |
284 | gtk_tree_view_append_column ( |
f5d980bf |
285 | GTK_TREE_VIEW (process_list->process_list_widget), column); |
a56a1ba4 |
286 | |
287 | |
288 | column = gtk_tree_view_column_new_with_attributes ( "Birth sec", |
289 | renderer, |
290 | "text", |
291 | BIRTH_S_COLUMN, |
292 | NULL); |
293 | gtk_tree_view_append_column ( |
f5d980bf |
294 | GTK_TREE_VIEW (process_list->process_list_widget), column); |
a56a1ba4 |
295 | |
296 | //gtk_tree_view_column_set_visible(column, 0); |
297 | // |
298 | column = gtk_tree_view_column_new_with_attributes ( "Birth nsec", |
299 | renderer, |
300 | "text", |
301 | BIRTH_NS_COLUMN, |
302 | NULL); |
303 | gtk_tree_view_append_column ( |
f5d980bf |
304 | GTK_TREE_VIEW (process_list->process_list_widget), column); |
a56a1ba4 |
305 | |
d0cd7f09 |
306 | column = gtk_tree_view_column_new_with_attributes ( "TRACE", |
307 | renderer, |
308 | "text", |
309 | TRACE_COLUMN, |
310 | NULL); |
311 | gtk_tree_view_append_column ( |
312 | GTK_TREE_VIEW (process_list->process_list_widget), column); |
313 | |
314 | |
a56a1ba4 |
315 | //gtk_tree_view_column_set_visible(column, 0); |
316 | |
317 | g_object_set_data_full( |
f5d980bf |
318 | G_OBJECT(process_list->process_list_widget), |
ba90bc77 |
319 | "process_list_Data", |
320 | process_list, |
a56a1ba4 |
321 | (GDestroyNotify)processlist_destroy); |
322 | |
ba90bc77 |
323 | return process_list; |
f0d936c0 |
324 | } |
ba90bc77 |
325 | void processlist_destroy(ProcessList *process_list) |
f0d936c0 |
326 | { |
ca0f8a8e |
327 | g_info("processlist_destroy %p", process_list); |
14963be0 |
328 | g_hash_table_destroy(process_list->process_hash); |
329 | process_list->process_hash = NULL; |
f0d936c0 |
330 | |
ba90bc77 |
331 | g_free(process_list); |
ca0f8a8e |
332 | g_info("processlist_destroy end"); |
f0d936c0 |
333 | } |
334 | |
ba90bc77 |
335 | GtkWidget *processlist_get_widget(ProcessList *process_list) |
f0d936c0 |
336 | { |
f5d980bf |
337 | return process_list->process_list_widget; |
f0d936c0 |
338 | } |
339 | |
340 | |
341 | |
f5d980bf |
342 | gint get_cell_height(GtkTreeView *tree_view) |
f0d936c0 |
343 | { |
a56a1ba4 |
344 | gint height; |
f5d980bf |
345 | GtkTreeViewColumn *Column = gtk_tree_view_get_column(tree_view, 0); |
a56a1ba4 |
346 | //GList *Render_List = gtk_tree_view_column_get_cell_renderers(Column); |
347 | //GtkCellRenderer *Renderer = g_list_first(Render_List)->data; |
348 | |
349 | //g_list_free(Render_List); |
350 | gtk_tree_view_column_cell_get_size(Column, NULL, NULL, NULL, NULL, &height); |
351 | //g_critical("cell 0 height : %u",height); |
352 | |
353 | return height; |
f0d936c0 |
354 | } |
355 | |
4c69e0cc |
356 | void destroy_hash_key(gpointer key) |
f0d936c0 |
357 | { |
a56a1ba4 |
358 | g_free(key); |
fa2c4dbe |
359 | } |
360 | |
4c69e0cc |
361 | void destroy_hash_data(gpointer data) |
fa2c4dbe |
362 | { |
a56a1ba4 |
363 | g_free(data); |
fa2c4dbe |
364 | } |
365 | |
ba90bc77 |
366 | int processlist_add( ProcessList *process_list, |
a56a1ba4 |
367 | guint pid, |
368 | LttTime *birth, |
d0cd7f09 |
369 | guint trace_num, |
a56a1ba4 |
370 | gchar *name, |
371 | guint *height, |
f5d980bf |
372 | HashedProcessData **pm_hashed_process_data) |
fa2c4dbe |
373 | { |
a56a1ba4 |
374 | GtkTreeIter iter ; |
375 | ProcessInfo *Process_Info = g_new(ProcessInfo, 1); |
14963be0 |
376 | HashedProcessData *hashed_process_data = g_new(HashedProcessData, 1); |
f5d980bf |
377 | *pm_hashed_process_data = hashed_process_data; |
a56a1ba4 |
378 | |
379 | Process_Info->pid = pid; |
380 | Process_Info->birth = *birth; |
d0cd7f09 |
381 | Process_Info->trace_num = trace_num; |
a56a1ba4 |
382 | |
14963be0 |
383 | hashed_process_data->draw_context = g_new(DrawContext, 1); |
384 | hashed_process_data->draw_context->drawable = NULL; |
385 | hashed_process_data->draw_context->gc = NULL; |
386 | hashed_process_data->draw_context->pango_layout = NULL; |
387 | hashed_process_data->draw_context->current = g_new(DrawInfo,1); |
388 | hashed_process_data->draw_context->current->over = g_new(ItemInfo,1); |
389 | hashed_process_data->draw_context->current->over->x = -1; |
390 | hashed_process_data->draw_context->current->over->y = -1; |
391 | hashed_process_data->draw_context->current->middle = g_new(ItemInfo,1); |
392 | hashed_process_data->draw_context->current->middle->x = -1; |
393 | hashed_process_data->draw_context->current->middle->y = -1; |
394 | hashed_process_data->draw_context->current->under = g_new(ItemInfo,1); |
395 | hashed_process_data->draw_context->current->under->x = -1; |
396 | hashed_process_data->draw_context->current->under->y = -1; |
397 | hashed_process_data->draw_context->current->modify_over = g_new(ItemInfo,1); |
398 | hashed_process_data->draw_context->current->modify_over->x = -1; |
399 | hashed_process_data->draw_context->current->modify_over->y = -1; |
400 | hashed_process_data->draw_context->current->modify_middle = g_new(ItemInfo,1); |
401 | hashed_process_data->draw_context->current->modify_middle->x = -1; |
402 | hashed_process_data->draw_context->current->modify_middle->y = -1; |
403 | hashed_process_data->draw_context->current->modify_under = g_new(ItemInfo,1); |
404 | hashed_process_data->draw_context->current->modify_under->x = -1; |
405 | hashed_process_data->draw_context->current->modify_under->y = -1; |
406 | hashed_process_data->draw_context->current->status = LTTV_STATE_UNNAMED; |
407 | hashed_process_data->draw_context->previous = g_new(DrawInfo,1); |
408 | hashed_process_data->draw_context->previous->over = g_new(ItemInfo,1); |
409 | hashed_process_data->draw_context->previous->over->x = -1; |
410 | hashed_process_data->draw_context->previous->over->y = -1; |
411 | hashed_process_data->draw_context->previous->middle = g_new(ItemInfo,1); |
412 | hashed_process_data->draw_context->previous->middle->x = -1; |
413 | hashed_process_data->draw_context->previous->middle->y = -1; |
414 | hashed_process_data->draw_context->previous->under = g_new(ItemInfo,1); |
415 | hashed_process_data->draw_context->previous->under->x = -1; |
416 | hashed_process_data->draw_context->previous->under->y = -1; |
417 | hashed_process_data->draw_context->previous->modify_over = g_new(ItemInfo,1); |
418 | hashed_process_data->draw_context->previous->modify_over->x = -1; |
419 | hashed_process_data->draw_context->previous->modify_over->y = -1; |
420 | hashed_process_data->draw_context->previous->modify_middle = g_new(ItemInfo,1); |
421 | hashed_process_data->draw_context->previous->modify_middle->x = -1; |
422 | hashed_process_data->draw_context->previous->modify_middle->y = -1; |
423 | hashed_process_data->draw_context->previous->modify_under = g_new(ItemInfo,1); |
424 | hashed_process_data->draw_context->previous->modify_under->x = -1; |
425 | hashed_process_data->draw_context->previous->modify_under->y = -1; |
426 | hashed_process_data->draw_context->previous->status = LTTV_STATE_UNNAMED; |
a56a1ba4 |
427 | |
428 | /* Add a new row to the model */ |
f5d980bf |
429 | gtk_list_store_append ( process_list->list_store, &iter); |
a56a1ba4 |
430 | //g_critical ( "iter before : %s", gtk_tree_path_to_string ( |
431 | // gtk_tree_model_get_path ( |
f5d980bf |
432 | // GTK_TREE_MODEL(process_list->list_store), |
a56a1ba4 |
433 | // &iter))); |
f5d980bf |
434 | gtk_list_store_set ( process_list->list_store, &iter, |
a56a1ba4 |
435 | PROCESS_COLUMN, name, |
436 | PID_COLUMN, pid, |
437 | BIRTH_S_COLUMN, birth->tv_sec, |
438 | BIRTH_NS_COLUMN, birth->tv_nsec, |
d0cd7f09 |
439 | TRACE_COLUMN, trace_num, |
a56a1ba4 |
440 | -1); |
f5d980bf |
441 | hashed_process_data->row_ref = gtk_tree_row_reference_new ( |
442 | GTK_TREE_MODEL(process_list->list_store), |
a56a1ba4 |
443 | gtk_tree_model_get_path( |
f5d980bf |
444 | GTK_TREE_MODEL(process_list->list_store), |
a56a1ba4 |
445 | &iter)); |
14963be0 |
446 | g_hash_table_insert( process_list->process_hash, |
a56a1ba4 |
447 | (gpointer)Process_Info, |
14963be0 |
448 | (gpointer)hashed_process_data); |
a56a1ba4 |
449 | |
450 | //g_critical ( "iter after : %s", gtk_tree_path_to_string ( |
451 | // gtk_tree_model_get_path ( |
f5d980bf |
452 | // GTK_TREE_MODEL(process_list->list_store), |
a56a1ba4 |
453 | // &iter))); |
ba90bc77 |
454 | process_list->number_of_process++; |
a56a1ba4 |
455 | |
f5d980bf |
456 | *height = get_cell_height(GTK_TREE_VIEW(process_list->process_list_widget)) |
ba90bc77 |
457 | * process_list->number_of_process ; |
a56a1ba4 |
458 | |
459 | |
460 | return 0; |
461 | |
f0d936c0 |
462 | } |
463 | |
ba90bc77 |
464 | int processlist_remove( ProcessList *process_list, |
a56a1ba4 |
465 | guint pid, |
d0cd7f09 |
466 | LttTime *birth, |
467 | guint trace_num) |
f0d936c0 |
468 | { |
a56a1ba4 |
469 | ProcessInfo Process_Info; |
470 | gint *path_indices; |
14963be0 |
471 | HashedProcessData *hashed_process_data; |
a56a1ba4 |
472 | GtkTreeIter iter; |
473 | |
474 | Process_Info.pid = pid; |
475 | Process_Info.birth = *birth; |
d0cd7f09 |
476 | Process_Info.trace_num = trace_num; |
a56a1ba4 |
477 | |
478 | |
14963be0 |
479 | if(hashed_process_data = |
a56a1ba4 |
480 | (HashedProcessData*)g_hash_table_lookup( |
14963be0 |
481 | process_list->process_hash, |
a56a1ba4 |
482 | &Process_Info)) |
483 | { |
484 | gtk_tree_model_get_iter ( |
f5d980bf |
485 | GTK_TREE_MODEL(process_list->list_store), |
a56a1ba4 |
486 | &iter, |
487 | gtk_tree_row_reference_get_path( |
f5d980bf |
488 | (GtkTreeRowReference*)hashed_process_data->row_ref) |
a56a1ba4 |
489 | ); |
490 | |
f5d980bf |
491 | gtk_list_store_remove (process_list->list_store, &iter); |
a56a1ba4 |
492 | |
14963be0 |
493 | g_free(hashed_process_data->draw_context->previous->modify_under); |
494 | g_free(hashed_process_data->draw_context->previous->modify_middle); |
495 | g_free(hashed_process_data->draw_context->previous->modify_over); |
496 | g_free(hashed_process_data->draw_context->previous->under); |
497 | g_free(hashed_process_data->draw_context->previous->middle); |
498 | g_free(hashed_process_data->draw_context->previous->over); |
499 | g_free(hashed_process_data->draw_context->previous); |
500 | g_free(hashed_process_data->draw_context->current->modify_under); |
501 | g_free(hashed_process_data->draw_context->current->modify_middle); |
502 | g_free(hashed_process_data->draw_context->current->modify_over); |
503 | g_free(hashed_process_data->draw_context->current->under); |
504 | g_free(hashed_process_data->draw_context->current->middle); |
505 | g_free(hashed_process_data->draw_context->current->over); |
506 | g_free(hashed_process_data->draw_context->current); |
507 | g_free(hashed_process_data->draw_context); |
508 | g_free(hashed_process_data); |
509 | |
510 | g_hash_table_remove(process_list->process_hash, |
a56a1ba4 |
511 | &Process_Info); |
512 | |
ba90bc77 |
513 | process_list->number_of_process--; |
a56a1ba4 |
514 | |
515 | return 0; |
516 | } else { |
517 | return 1; |
518 | } |
fa2c4dbe |
519 | } |
520 | |
521 | |
ba90bc77 |
522 | guint processlist_get_height(ProcessList *process_list) |
fa2c4dbe |
523 | { |
f5d980bf |
524 | return get_cell_height(GTK_TREE_VIEW(process_list->process_list_widget)) |
ba90bc77 |
525 | * process_list->number_of_process ; |
f0d936c0 |
526 | } |
fa2c4dbe |
527 | |
528 | |
ba90bc77 |
529 | gint processlist_get_process_pixels( ProcessList *process_list, |
d0cd7f09 |
530 | guint pid, LttTime *birth, guint trace_num, |
a56a1ba4 |
531 | guint *y, |
532 | guint *height, |
f5d980bf |
533 | HashedProcessData **pm_hashed_process_data) |
fa2c4dbe |
534 | { |
a56a1ba4 |
535 | ProcessInfo Process_Info; |
536 | gint *path_indices; |
537 | GtkTreePath *tree_path; |
14963be0 |
538 | HashedProcessData *hashed_process_data = NULL; |
a56a1ba4 |
539 | |
540 | Process_Info.pid = pid; |
541 | Process_Info.birth = *birth; |
d0cd7f09 |
542 | Process_Info.trace_num = trace_num; |
a56a1ba4 |
543 | |
14963be0 |
544 | if(hashed_process_data = |
a56a1ba4 |
545 | (HashedProcessData*)g_hash_table_lookup( |
14963be0 |
546 | process_list->process_hash, |
a56a1ba4 |
547 | &Process_Info)) |
548 | { |
549 | tree_path = gtk_tree_row_reference_get_path( |
f5d980bf |
550 | hashed_process_data->row_ref); |
a56a1ba4 |
551 | path_indices = gtk_tree_path_get_indices (tree_path); |
552 | |
553 | *height = get_cell_height( |
f5d980bf |
554 | GTK_TREE_VIEW(process_list->process_list_widget)); |
a56a1ba4 |
555 | *y = *height * path_indices[0]; |
f5d980bf |
556 | *pm_hashed_process_data = hashed_process_data; |
a56a1ba4 |
557 | return 0; |
558 | } else { |
f5d980bf |
559 | *pm_hashed_process_data = hashed_process_data; |
a56a1ba4 |
560 | return 1; |
561 | } |
fa2c4dbe |
562 | |
fa2c4dbe |
563 | } |
8b90e648 |
564 | |
565 | |
ba90bc77 |
566 | gint processlist_get_pixels_from_data( ProcessList *process_list, |
a56a1ba4 |
567 | ProcessInfo *process_info, |
14963be0 |
568 | HashedProcessData *hashed_process_data, |
a56a1ba4 |
569 | guint *y, |
570 | guint *height) |
8b90e648 |
571 | { |
a56a1ba4 |
572 | gint *path_indices; |
573 | GtkTreePath *tree_path; |
8b90e648 |
574 | |
a56a1ba4 |
575 | tree_path = gtk_tree_row_reference_get_path( |
f5d980bf |
576 | hashed_process_data->row_ref); |
a56a1ba4 |
577 | path_indices = gtk_tree_path_get_indices (tree_path); |
8b90e648 |
578 | |
a56a1ba4 |
579 | *height = get_cell_height( |
f5d980bf |
580 | GTK_TREE_VIEW(process_list->process_list_widget)); |
a56a1ba4 |
581 | *y = *height * path_indices[0]; |
8b90e648 |
582 | |
a56a1ba4 |
583 | return 0; |
8b90e648 |
584 | |
585 | } |