| 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 | */ |
| 18 | |
| 19 | #include <gtk/gtk.h> |
| 20 | #include <glib.h> |
| 21 | |
| 22 | #include "processlist.h" |
| 23 | #include "drawitem.h" |
| 24 | |
| 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 | |
| 29 | /***************************************************************************** |
| 30 | * Methods to synchronize process list * |
| 31 | *****************************************************************************/ |
| 32 | |
| 33 | /* Enumeration of the columns */ |
| 34 | enum |
| 35 | { |
| 36 | PROCESS_COLUMN, |
| 37 | PID_COLUMN, |
| 38 | BIRTH_S_COLUMN, |
| 39 | BIRTH_NS_COLUMN, |
| 40 | TRACE_COLUMN, |
| 41 | N_COLUMNS |
| 42 | }; |
| 43 | |
| 44 | |
| 45 | gint process_sort_func ( GtkTreeModel *model, |
| 46 | GtkTreeIter *it_a, |
| 47 | GtkTreeIter *it_b, |
| 48 | gpointer user_data) |
| 49 | { |
| 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 | |
| 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 | |
| 185 | return 0; |
| 186 | |
| 187 | } |
| 188 | |
| 189 | guint hash_fct(gconstpointer key) |
| 190 | { |
| 191 | return ((ProcessInfo*)key)->pid; |
| 192 | } |
| 193 | |
| 194 | gboolean equ_fct(gconstpointer a, gconstpointer b) |
| 195 | { |
| 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 | |
| 207 | if(((ProcessInfo*)a)->trace_num != ((ProcessInfo*)b)->trace_num) |
| 208 | return 0; |
| 209 | |
| 210 | return 1; |
| 211 | } |
| 212 | |
| 213 | void destroy_hash_key(gpointer key); |
| 214 | |
| 215 | void destroy_hash_data(gpointer data); |
| 216 | |
| 217 | |
| 218 | |
| 219 | |
| 220 | ProcessList *processlist_construct(void) |
| 221 | { |
| 222 | GtkTreeViewColumn *column; |
| 223 | GtkCellRenderer *renderer; |
| 224 | |
| 225 | ProcessList* process_list = g_new(ProcessList,1); |
| 226 | |
| 227 | process_list->number_of_process = 0; |
| 228 | |
| 229 | /* Create the Process list */ |
| 230 | process_list->list_store = gtk_list_store_new ( N_COLUMNS, |
| 231 | G_TYPE_STRING, |
| 232 | G_TYPE_UINT, |
| 233 | G_TYPE_ULONG, |
| 234 | G_TYPE_ULONG, |
| 235 | G_TYPE_ULONG); |
| 236 | |
| 237 | |
| 238 | process_list->process_list_widget = |
| 239 | gtk_tree_view_new_with_model |
| 240 | (GTK_TREE_MODEL (process_list->list_store)); |
| 241 | g_object_unref (G_OBJECT (process_list->list_store)); |
| 242 | |
| 243 | gtk_tree_sortable_set_sort_func( |
| 244 | GTK_TREE_SORTABLE(process_list->list_store), |
| 245 | PID_COLUMN, |
| 246 | process_sort_func, |
| 247 | NULL, |
| 248 | NULL); |
| 249 | |
| 250 | gtk_tree_sortable_set_sort_column_id( |
| 251 | GTK_TREE_SORTABLE(process_list->list_store), |
| 252 | PID_COLUMN, |
| 253 | GTK_SORT_ASCENDING); |
| 254 | |
| 255 | process_list->process_hash = g_hash_table_new_full( |
| 256 | hash_fct, equ_fct, |
| 257 | destroy_hash_key, destroy_hash_data |
| 258 | ); |
| 259 | |
| 260 | |
| 261 | gtk_tree_view_set_headers_visible( |
| 262 | GTK_TREE_VIEW(process_list->process_list_widget), TRUE); |
| 263 | |
| 264 | /* Create a column, associating the "text" attribute of the |
| 265 | * cell_renderer to the first column of the model */ |
| 266 | /* Columns alignment : 0.0 : Left 0.5 : Center 1.0 : Right */ |
| 267 | renderer = gtk_cell_renderer_text_new (); |
| 268 | column = gtk_tree_view_column_new_with_attributes ( "Process", |
| 269 | renderer, |
| 270 | "text", |
| 271 | PROCESS_COLUMN, |
| 272 | NULL); |
| 273 | gtk_tree_view_column_set_alignment (column, 0.0); |
| 274 | gtk_tree_view_column_set_fixed_width (column, 45); |
| 275 | gtk_tree_view_append_column ( |
| 276 | GTK_TREE_VIEW (process_list->process_list_widget), column); |
| 277 | |
| 278 | column = gtk_tree_view_column_new_with_attributes ( "PID", |
| 279 | renderer, |
| 280 | "text", |
| 281 | PID_COLUMN, |
| 282 | NULL); |
| 283 | gtk_tree_view_append_column ( |
| 284 | GTK_TREE_VIEW (process_list->process_list_widget), column); |
| 285 | |
| 286 | |
| 287 | column = gtk_tree_view_column_new_with_attributes ( "Birth sec", |
| 288 | renderer, |
| 289 | "text", |
| 290 | BIRTH_S_COLUMN, |
| 291 | NULL); |
| 292 | gtk_tree_view_append_column ( |
| 293 | GTK_TREE_VIEW (process_list->process_list_widget), column); |
| 294 | |
| 295 | //gtk_tree_view_column_set_visible(column, 0); |
| 296 | // |
| 297 | column = gtk_tree_view_column_new_with_attributes ( "Birth nsec", |
| 298 | renderer, |
| 299 | "text", |
| 300 | BIRTH_NS_COLUMN, |
| 301 | NULL); |
| 302 | gtk_tree_view_append_column ( |
| 303 | GTK_TREE_VIEW (process_list->process_list_widget), column); |
| 304 | |
| 305 | column = gtk_tree_view_column_new_with_attributes ( "TRACE", |
| 306 | renderer, |
| 307 | "text", |
| 308 | TRACE_COLUMN, |
| 309 | NULL); |
| 310 | gtk_tree_view_append_column ( |
| 311 | GTK_TREE_VIEW (process_list->process_list_widget), column); |
| 312 | |
| 313 | |
| 314 | //gtk_tree_view_column_set_visible(column, 0); |
| 315 | |
| 316 | g_object_set_data_full( |
| 317 | G_OBJECT(process_list->process_list_widget), |
| 318 | "process_list_Data", |
| 319 | process_list, |
| 320 | (GDestroyNotify)processlist_destroy); |
| 321 | |
| 322 | return process_list; |
| 323 | } |
| 324 | void processlist_destroy(ProcessList *process_list) |
| 325 | { |
| 326 | g_info("processlist_destroy %p", process_list); |
| 327 | g_hash_table_destroy(process_list->process_hash); |
| 328 | process_list->process_hash = NULL; |
| 329 | |
| 330 | g_free(process_list); |
| 331 | g_info("processlist_destroy end"); |
| 332 | } |
| 333 | |
| 334 | GtkWidget *processlist_get_widget(ProcessList *process_list) |
| 335 | { |
| 336 | return process_list->process_list_widget; |
| 337 | } |
| 338 | |
| 339 | |
| 340 | |
| 341 | gint get_cell_height(GtkTreeView *tree_view) |
| 342 | { |
| 343 | gint height; |
| 344 | GtkTreeViewColumn *Column = gtk_tree_view_get_column(tree_view, 0); |
| 345 | //GList *Render_List = gtk_tree_view_column_get_cell_renderers(Column); |
| 346 | //GtkCellRenderer *Renderer = g_list_first(Render_List)->data; |
| 347 | |
| 348 | //g_list_free(Render_List); |
| 349 | gtk_tree_view_column_cell_get_size(Column, NULL, NULL, NULL, NULL, &height); |
| 350 | //g_critical("cell 0 height : %u",height); |
| 351 | |
| 352 | return height; |
| 353 | } |
| 354 | |
| 355 | void destroy_hash_key(gpointer key) |
| 356 | { |
| 357 | g_free(key); |
| 358 | } |
| 359 | |
| 360 | void destroy_hash_data(gpointer data) |
| 361 | { |
| 362 | g_free(data); |
| 363 | } |
| 364 | |
| 365 | int processlist_add( ProcessList *process_list, |
| 366 | guint pid, |
| 367 | LttTime *birth, |
| 368 | guint trace_num, |
| 369 | const gchar *name, |
| 370 | guint *height, |
| 371 | HashedProcessData **pm_hashed_process_data) |
| 372 | { |
| 373 | GtkTreeIter iter ; |
| 374 | ProcessInfo *Process_Info = g_new(ProcessInfo, 1); |
| 375 | HashedProcessData *hashed_process_data = g_new(HashedProcessData, 1); |
| 376 | *pm_hashed_process_data = hashed_process_data; |
| 377 | |
| 378 | Process_Info->pid = pid; |
| 379 | Process_Info->birth = *birth; |
| 380 | Process_Info->trace_num = trace_num; |
| 381 | |
| 382 | hashed_process_data->draw_context = g_new(DrawContext, 1); |
| 383 | hashed_process_data->draw_context->drawable = NULL; |
| 384 | hashed_process_data->draw_context->gc = NULL; |
| 385 | hashed_process_data->draw_context->pango_layout = NULL; |
| 386 | hashed_process_data->draw_context->current = g_new(DrawInfo,1); |
| 387 | hashed_process_data->draw_context->current->over = g_new(ItemInfo,1); |
| 388 | hashed_process_data->draw_context->current->over->x = -1; |
| 389 | hashed_process_data->draw_context->current->over->y = -1; |
| 390 | hashed_process_data->draw_context->current->middle = g_new(ItemInfo,1); |
| 391 | hashed_process_data->draw_context->current->middle->x = -1; |
| 392 | hashed_process_data->draw_context->current->middle->y = -1; |
| 393 | hashed_process_data->draw_context->current->under = g_new(ItemInfo,1); |
| 394 | hashed_process_data->draw_context->current->under->x = -1; |
| 395 | hashed_process_data->draw_context->current->under->y = -1; |
| 396 | hashed_process_data->draw_context->current->modify_over = g_new(ItemInfo,1); |
| 397 | hashed_process_data->draw_context->current->modify_over->x = -1; |
| 398 | hashed_process_data->draw_context->current->modify_over->y = -1; |
| 399 | hashed_process_data->draw_context->current->modify_middle = g_new(ItemInfo,1); |
| 400 | hashed_process_data->draw_context->current->modify_middle->x = -1; |
| 401 | hashed_process_data->draw_context->current->modify_middle->y = -1; |
| 402 | hashed_process_data->draw_context->current->modify_under = g_new(ItemInfo,1); |
| 403 | hashed_process_data->draw_context->current->modify_under->x = -1; |
| 404 | hashed_process_data->draw_context->current->modify_under->y = -1; |
| 405 | hashed_process_data->draw_context->current->status = LTTV_STATE_UNNAMED; |
| 406 | hashed_process_data->draw_context->previous = g_new(DrawInfo,1); |
| 407 | hashed_process_data->draw_context->previous->over = g_new(ItemInfo,1); |
| 408 | hashed_process_data->draw_context->previous->over->x = -1; |
| 409 | hashed_process_data->draw_context->previous->over->y = -1; |
| 410 | hashed_process_data->draw_context->previous->middle = g_new(ItemInfo,1); |
| 411 | hashed_process_data->draw_context->previous->middle->x = -1; |
| 412 | hashed_process_data->draw_context->previous->middle->y = -1; |
| 413 | hashed_process_data->draw_context->previous->under = g_new(ItemInfo,1); |
| 414 | hashed_process_data->draw_context->previous->under->x = -1; |
| 415 | hashed_process_data->draw_context->previous->under->y = -1; |
| 416 | hashed_process_data->draw_context->previous->modify_over = g_new(ItemInfo,1); |
| 417 | hashed_process_data->draw_context->previous->modify_over->x = -1; |
| 418 | hashed_process_data->draw_context->previous->modify_over->y = -1; |
| 419 | hashed_process_data->draw_context->previous->modify_middle = g_new(ItemInfo,1); |
| 420 | hashed_process_data->draw_context->previous->modify_middle->x = -1; |
| 421 | hashed_process_data->draw_context->previous->modify_middle->y = -1; |
| 422 | hashed_process_data->draw_context->previous->modify_under = g_new(ItemInfo,1); |
| 423 | hashed_process_data->draw_context->previous->modify_under->x = -1; |
| 424 | hashed_process_data->draw_context->previous->modify_under->y = -1; |
| 425 | hashed_process_data->draw_context->previous->status = LTTV_STATE_UNNAMED; |
| 426 | |
| 427 | /* Add a new row to the model */ |
| 428 | gtk_list_store_append ( process_list->list_store, &iter); |
| 429 | //g_critical ( "iter before : %s", gtk_tree_path_to_string ( |
| 430 | // gtk_tree_model_get_path ( |
| 431 | // GTK_TREE_MODEL(process_list->list_store), |
| 432 | // &iter))); |
| 433 | gtk_list_store_set ( process_list->list_store, &iter, |
| 434 | PROCESS_COLUMN, name, |
| 435 | PID_COLUMN, pid, |
| 436 | BIRTH_S_COLUMN, birth->tv_sec, |
| 437 | BIRTH_NS_COLUMN, birth->tv_nsec, |
| 438 | TRACE_COLUMN, trace_num, |
| 439 | -1); |
| 440 | hashed_process_data->row_ref = gtk_tree_row_reference_new ( |
| 441 | GTK_TREE_MODEL(process_list->list_store), |
| 442 | gtk_tree_model_get_path( |
| 443 | GTK_TREE_MODEL(process_list->list_store), |
| 444 | &iter)); |
| 445 | g_hash_table_insert( process_list->process_hash, |
| 446 | (gpointer)Process_Info, |
| 447 | (gpointer)hashed_process_data); |
| 448 | |
| 449 | //g_critical ( "iter after : %s", gtk_tree_path_to_string ( |
| 450 | // gtk_tree_model_get_path ( |
| 451 | // GTK_TREE_MODEL(process_list->list_store), |
| 452 | // &iter))); |
| 453 | process_list->number_of_process++; |
| 454 | |
| 455 | *height = get_cell_height(GTK_TREE_VIEW(process_list->process_list_widget)) |
| 456 | * process_list->number_of_process ; |
| 457 | |
| 458 | |
| 459 | return 0; |
| 460 | |
| 461 | } |
| 462 | |
| 463 | int processlist_remove( ProcessList *process_list, |
| 464 | guint pid, |
| 465 | LttTime *birth, |
| 466 | guint trace_num) |
| 467 | { |
| 468 | ProcessInfo Process_Info; |
| 469 | gint *path_indices; |
| 470 | HashedProcessData *hashed_process_data; |
| 471 | GtkTreeIter iter; |
| 472 | |
| 473 | Process_Info.pid = pid; |
| 474 | Process_Info.birth = *birth; |
| 475 | Process_Info.trace_num = trace_num; |
| 476 | |
| 477 | |
| 478 | if(hashed_process_data = |
| 479 | (HashedProcessData*)g_hash_table_lookup( |
| 480 | process_list->process_hash, |
| 481 | &Process_Info)) |
| 482 | { |
| 483 | GtkTreePath *tree_path; |
| 484 | |
| 485 | tree_path = gtk_tree_row_reference_get_path( |
| 486 | hashed_process_data->row_ref); |
| 487 | |
| 488 | gtk_tree_model_get_iter ( |
| 489 | GTK_TREE_MODEL(process_list->list_store), |
| 490 | &iter, tree_path); |
| 491 | |
| 492 | gtk_tree_path_free(tree_path); |
| 493 | |
| 494 | gtk_list_store_remove (process_list->list_store, &iter); |
| 495 | |
| 496 | g_free(hashed_process_data->draw_context->previous->modify_under); |
| 497 | g_free(hashed_process_data->draw_context->previous->modify_middle); |
| 498 | g_free(hashed_process_data->draw_context->previous->modify_over); |
| 499 | g_free(hashed_process_data->draw_context->previous->under); |
| 500 | g_free(hashed_process_data->draw_context->previous->middle); |
| 501 | g_free(hashed_process_data->draw_context->previous->over); |
| 502 | g_free(hashed_process_data->draw_context->previous); |
| 503 | g_free(hashed_process_data->draw_context->current->modify_under); |
| 504 | g_free(hashed_process_data->draw_context->current->modify_middle); |
| 505 | g_free(hashed_process_data->draw_context->current->modify_over); |
| 506 | g_free(hashed_process_data->draw_context->current->under); |
| 507 | g_free(hashed_process_data->draw_context->current->middle); |
| 508 | g_free(hashed_process_data->draw_context->current->over); |
| 509 | g_free(hashed_process_data->draw_context->current); |
| 510 | g_free(hashed_process_data->draw_context); |
| 511 | g_free(hashed_process_data); |
| 512 | |
| 513 | g_hash_table_remove(process_list->process_hash, |
| 514 | &Process_Info); |
| 515 | |
| 516 | process_list->number_of_process--; |
| 517 | |
| 518 | return 0; |
| 519 | } else { |
| 520 | return 1; |
| 521 | } |
| 522 | } |
| 523 | |
| 524 | |
| 525 | guint processlist_get_height(ProcessList *process_list) |
| 526 | { |
| 527 | return get_cell_height(GTK_TREE_VIEW(process_list->process_list_widget)) |
| 528 | * process_list->number_of_process ; |
| 529 | } |
| 530 | |
| 531 | |
| 532 | gint processlist_get_process_pixels( ProcessList *process_list, |
| 533 | guint pid, LttTime *birth, guint trace_num, |
| 534 | guint *y, |
| 535 | guint *height, |
| 536 | HashedProcessData **pm_hashed_process_data) |
| 537 | { |
| 538 | ProcessInfo Process_Info; |
| 539 | gint *path_indices; |
| 540 | GtkTreePath *tree_path; |
| 541 | HashedProcessData *hashed_process_data = NULL; |
| 542 | |
| 543 | Process_Info.pid = pid; |
| 544 | Process_Info.birth = *birth; |
| 545 | Process_Info.trace_num = trace_num; |
| 546 | |
| 547 | if(hashed_process_data = |
| 548 | (HashedProcessData*)g_hash_table_lookup( |
| 549 | process_list->process_hash, |
| 550 | &Process_Info)) |
| 551 | { |
| 552 | tree_path = gtk_tree_row_reference_get_path( |
| 553 | hashed_process_data->row_ref); |
| 554 | path_indices = gtk_tree_path_get_indices (tree_path); |
| 555 | |
| 556 | *height = get_cell_height( |
| 557 | GTK_TREE_VIEW(process_list->process_list_widget)); |
| 558 | *y = *height * path_indices[0]; |
| 559 | *pm_hashed_process_data = hashed_process_data; |
| 560 | gtk_tree_path_free(tree_path); |
| 561 | |
| 562 | return 0; |
| 563 | } else { |
| 564 | *pm_hashed_process_data = hashed_process_data; |
| 565 | return 1; |
| 566 | } |
| 567 | |
| 568 | } |
| 569 | |
| 570 | |
| 571 | gint processlist_get_pixels_from_data( ProcessList *process_list, |
| 572 | ProcessInfo *process_info, |
| 573 | HashedProcessData *hashed_process_data, |
| 574 | guint *y, |
| 575 | guint *height) |
| 576 | { |
| 577 | gint *path_indices; |
| 578 | GtkTreePath *tree_path; |
| 579 | |
| 580 | tree_path = gtk_tree_row_reference_get_path( |
| 581 | hashed_process_data->row_ref); |
| 582 | path_indices = gtk_tree_path_get_indices (tree_path); |
| 583 | |
| 584 | *height = get_cell_height( |
| 585 | GTK_TREE_VIEW(process_list->process_list_widget)); |
| 586 | *y = *height * path_indices[0]; |
| 587 | gtk_tree_path_free(tree_path); |
| 588 | |
| 589 | return 0; |
| 590 | |
| 591 | } |