| 1 | /* This file is part of the Linux Trace Toolkit viewer |
| 2 | * Copyright (C) 2003-2004 XangXiu Yang |
| 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., 51 Franklin Street, Fifth Floor, Boston, |
| 16 | * MA 02110-1301, USA. |
| 17 | */ |
| 18 | |
| 19 | /*! \file lttvwindow.c |
| 20 | * \brief API used by the graphical viewers to interact with their tab. |
| 21 | * |
| 22 | * Main window (gui module) is the place to contain and display viewers. |
| 23 | * Viewers (lttv plugins) interact with tab and main window through this API |
| 24 | * and events sent by gtk. |
| 25 | * This header file should be included in each graphic module. |
| 26 | * This library is used by graphical modules to interact with their tab and |
| 27 | * main window. |
| 28 | * |
| 29 | */ |
| 30 | |
| 31 | #ifdef HAVE_CONFIG_H |
| 32 | #include <config.h> |
| 33 | #endif |
| 34 | |
| 35 | #include <lttv/lttv.h> |
| 36 | #include <lttv/state.h> |
| 37 | #include <lttv/traceset.h> |
| 38 | #ifdef BABEL_CLEANUP |
| 39 | #include <lttv/stats.h> |
| 40 | #endif /* BABEL_CLEANUP */ |
| 41 | #include <lttvwindow/mainwindow.h> |
| 42 | #include <lttvwindow/mainwindow-private.h> |
| 43 | #include <lttvwindow/lttvwindow.h> |
| 44 | #include <lttvwindow/toolbar.h> |
| 45 | #include <lttvwindow/menu.h> |
| 46 | #include <lttvwindow/callbacks.h> // for execute_events_requests |
| 47 | #include <lttvwindow/support.h> |
| 48 | |
| 49 | /** |
| 50 | * Internal function parts |
| 51 | */ |
| 52 | |
| 53 | extern GSList * g_main_window_list; |
| 54 | |
| 55 | __EXPORT gint lttvwindow_preempt_count = 0; |
| 56 | |
| 57 | /* set_time_window |
| 58 | * |
| 59 | * It updates the time window of the tab, then calls the updatetimewindow |
| 60 | * hooks of each viewer. |
| 61 | * |
| 62 | * This is called whenever the scrollbar value changes. |
| 63 | */ |
| 64 | |
| 65 | void set_time_window(Tab *tab, const TimeWindow *time_window) |
| 66 | { |
| 67 | LttvAttributeValue value; |
| 68 | LttvHooks * tmp; |
| 69 | gboolean retval; |
| 70 | |
| 71 | TimeWindowNotifyData time_window_notify_data; |
| 72 | TimeWindow old_time_window = tab->time_window; |
| 73 | time_window_notify_data.old_time_window = &old_time_window; |
| 74 | tab->time_window = *time_window; |
| 75 | time_window_notify_data.new_time_window = |
| 76 | &(tab->time_window); |
| 77 | |
| 78 | retval= lttv_iattribute_find_by_path(tab->attributes, |
| 79 | "hooks/updatetimewindow", LTTV_POINTER, &value); |
| 80 | g_assert(retval); |
| 81 | tmp = (LttvHooks*)*(value.v_pointer); |
| 82 | if(tmp != NULL) lttv_hooks_call(tmp, &time_window_notify_data); |
| 83 | |
| 84 | //gtk_multi_vpaned_set_adjust(tab->multi_vpaned, new_time_window, FALSE); |
| 85 | |
| 86 | } |
| 87 | |
| 88 | /* set_current_time |
| 89 | * |
| 90 | * It updates the current time of the tab, then calls the updatetimewindow |
| 91 | * hooks of each viewer. |
| 92 | * |
| 93 | * This is called whenever the current time value changes. |
| 94 | */ |
| 95 | |
| 96 | void set_current_time(Tab *tab, const LttTime *current_time) |
| 97 | { |
| 98 | LttvAttributeValue value; |
| 99 | LttvHooks * tmp; |
| 100 | gboolean retval; |
| 101 | |
| 102 | tab->current_time = *current_time; |
| 103 | |
| 104 | retval= lttv_iattribute_find_by_path(tab->attributes, |
| 105 | "hooks/updatecurrenttime", LTTV_POINTER, &value); |
| 106 | g_assert(retval); |
| 107 | tmp = (LttvHooks*)*(value.v_pointer); |
| 108 | if(tmp != NULL) lttv_hooks_call(tmp, &tab->current_time); |
| 109 | } |
| 110 | |
| 111 | /* set_current_position |
| 112 | * |
| 113 | * It updates the current time of the tab, then calls the updatetimewindow |
| 114 | * hooks of each viewer. |
| 115 | * |
| 116 | * This is called whenever the current time value changes. |
| 117 | */ |
| 118 | |
| 119 | void set_current_position(Tab *tab, const LttvTracesetPosition *pos) |
| 120 | { |
| 121 | LttvAttributeValue value; |
| 122 | LttvHooks * tmp; |
| 123 | gboolean retval; |
| 124 | |
| 125 | tab->current_time = lttv_traceset_position_get_time(pos); |
| 126 | |
| 127 | retval= lttv_iattribute_find_by_path(tab->attributes, |
| 128 | "hooks/updatecurrentposition", LTTV_POINTER, &value); |
| 129 | g_assert(retval); |
| 130 | tmp = (LttvHooks*)*(value.v_pointer); |
| 131 | if (tmp != NULL) { |
| 132 | lttv_hooks_call(tmp, (void *) pos); |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | void add_toolbar_constructor(MainWindow *mw, LttvToolbarClosure *toolbar_c) |
| 137 | { |
| 138 | LttvIAttribute *attributes = mw->attributes; |
| 139 | LttvAttributeValue value; |
| 140 | LttvToolbars * instance_toolbar; |
| 141 | lttvwindow_viewer_constructor constructor; |
| 142 | GtkWidget * tool_menu_title_menu, *new_widget, *pixmap; |
| 143 | GdkPixbuf *pixbuf; |
| 144 | gboolean retval; |
| 145 | |
| 146 | retval= lttv_iattribute_find_by_path(attributes, "viewers/toolbar", |
| 147 | LTTV_POINTER, &value); |
| 148 | g_assert(retval); |
| 149 | if(*(value.v_pointer) == NULL) |
| 150 | *(value.v_pointer) = lttv_toolbars_new(); |
| 151 | instance_toolbar = (LttvToolbars*)*(value.v_pointer); |
| 152 | |
| 153 | constructor = toolbar_c->con; |
| 154 | tool_menu_title_menu = lookup_widget(mw->mwindow,"MToolbar1"); |
| 155 | pixbuf = gdk_pixbuf_new_from_xpm_data((const char**)toolbar_c->pixmap); |
| 156 | pixmap = gtk_image_new_from_pixbuf(pixbuf); |
| 157 | new_widget = |
| 158 | gtk_toolbar_append_element (GTK_TOOLBAR (tool_menu_title_menu), |
| 159 | GTK_TOOLBAR_CHILD_BUTTON, |
| 160 | NULL, |
| 161 | "", |
| 162 | toolbar_c->tooltip, NULL, |
| 163 | pixmap, NULL, NULL); |
| 164 | gtk_label_set_use_underline( |
| 165 | GTK_LABEL (((GtkToolbarChild*) ( |
| 166 | g_list_last (GTK_TOOLBAR |
| 167 | (tool_menu_title_menu)->children)->data))->label), |
| 168 | TRUE); |
| 169 | gtk_container_set_border_width (GTK_CONTAINER (new_widget), 1); |
| 170 | g_signal_connect ((gpointer) new_widget, |
| 171 | "clicked", |
| 172 | G_CALLBACK (insert_viewer_wrap), |
| 173 | constructor); |
| 174 | gtk_widget_show (new_widget); |
| 175 | |
| 176 | lttv_toolbars_add(instance_toolbar, toolbar_c->con, |
| 177 | toolbar_c->tooltip, |
| 178 | toolbar_c->pixmap, |
| 179 | new_widget); |
| 180 | |
| 181 | } |
| 182 | |
| 183 | void add_menu_constructor(MainWindow *mw, LttvMenuClosure *menu_c) |
| 184 | { |
| 185 | LttvIAttribute *attributes = mw->attributes; |
| 186 | LttvAttributeValue value; |
| 187 | LttvToolbars * instance_menu; |
| 188 | lttvwindow_viewer_constructor constructor; |
| 189 | GtkWidget * tool_menu_title_menu, *new_widget; |
| 190 | gboolean retval; |
| 191 | |
| 192 | retval= lttv_iattribute_find_by_path(attributes, "viewers/menu", |
| 193 | LTTV_POINTER, &value); |
| 194 | g_assert(retval); |
| 195 | if(*(value.v_pointer) == NULL) |
| 196 | *(value.v_pointer) = lttv_menus_new(); |
| 197 | instance_menu = (LttvMenus*)*(value.v_pointer); |
| 198 | |
| 199 | |
| 200 | constructor = menu_c->con; |
| 201 | tool_menu_title_menu = lookup_widget(mw->mwindow,"ToolMenuTitle_menu"); |
| 202 | new_widget = |
| 203 | gtk_menu_item_new_with_mnemonic (menu_c->menu_text); |
| 204 | gtk_container_add (GTK_CONTAINER (tool_menu_title_menu), |
| 205 | new_widget); |
| 206 | g_signal_connect ((gpointer) new_widget, "activate", |
| 207 | G_CALLBACK (insert_viewer_wrap), |
| 208 | constructor); |
| 209 | gtk_widget_show (new_widget); |
| 210 | lttv_menus_add(instance_menu, menu_c->con, |
| 211 | menu_c->menu_path, |
| 212 | menu_c->menu_text, |
| 213 | new_widget); |
| 214 | } |
| 215 | |
| 216 | void remove_toolbar_constructor(MainWindow *mw, lttvwindow_viewer_constructor viewer_constructor) |
| 217 | { |
| 218 | LttvIAttribute *attributes = mw->attributes; |
| 219 | LttvAttributeValue value; |
| 220 | LttvToolbars * instance_toolbar; |
| 221 | GtkWidget * tool_menu_title_menu, *widget; |
| 222 | gboolean retval; |
| 223 | |
| 224 | retval= lttv_iattribute_find_by_path(attributes, "viewers/toolbar", |
| 225 | LTTV_POINTER, &value); |
| 226 | g_assert(retval); |
| 227 | if(*(value.v_pointer) == NULL) |
| 228 | *(value.v_pointer) = lttv_toolbars_new(); |
| 229 | instance_toolbar = (LttvToolbars*)*(value.v_pointer); |
| 230 | |
| 231 | tool_menu_title_menu = lookup_widget(mw->mwindow,"MToolbar1"); |
| 232 | widget = lttv_menus_remove(instance_toolbar, viewer_constructor); |
| 233 | gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu), |
| 234 | widget); |
| 235 | } |
| 236 | |
| 237 | |
| 238 | void remove_menu_constructor(MainWindow *mw, lttvwindow_viewer_constructor viewer_constructor) |
| 239 | { |
| 240 | LttvIAttribute *attributes = mw->attributes; |
| 241 | LttvAttributeValue value; |
| 242 | LttvMenus * instance_menu; |
| 243 | GtkWidget * tool_menu_title_menu, *widget; |
| 244 | gboolean retval; |
| 245 | |
| 246 | retval= lttv_iattribute_find_by_path(attributes, "viewers/menu", |
| 247 | LTTV_POINTER, &value); |
| 248 | g_assert(retval); |
| 249 | if(*(value.v_pointer) == NULL) |
| 250 | *(value.v_pointer) = lttv_menus_new(); |
| 251 | instance_menu = (LttvMenus*)*(value.v_pointer); |
| 252 | |
| 253 | widget = lttv_menus_remove(instance_menu, viewer_constructor); |
| 254 | tool_menu_title_menu = lookup_widget(mw->mwindow,"ToolMenuTitle_menu"); |
| 255 | gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu), widget); |
| 256 | } |
| 257 | |
| 258 | |
| 259 | /** |
| 260 | * API parts |
| 261 | */ |
| 262 | |
| 263 | |
| 264 | /** |
| 265 | * Function to register a view constructor so that main window can generate |
| 266 | * a menu item and a toolbar item for the viewer in order to generate a new |
| 267 | * instance easily. A menu entry and toolbar item will be added to each main |
| 268 | * window. |
| 269 | * |
| 270 | * It should be called by init function of the module. |
| 271 | * |
| 272 | * @param name name of the viewer |
| 273 | * @param menu_path path of the menu item. |
| 274 | * @param menu_text text of the menu item. |
| 275 | * @param pixmap Image shown on the toolbar item. |
| 276 | * @param tooltip tooltip of the toolbar item. |
| 277 | * @param view_constructor constructor of the viewer. |
| 278 | */ |
| 279 | |
| 280 | __EXPORT void lttvwindow_register_constructor |
| 281 | (char * name, |
| 282 | char * menu_path, |
| 283 | char * menu_text, |
| 284 | char ** pixmap, |
| 285 | char * tooltip, |
| 286 | lttvwindow_viewer_constructor view_constructor) |
| 287 | { |
| 288 | LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes()); |
| 289 | LttvToolbars * toolbar; |
| 290 | LttvMenus * menu; |
| 291 | LttvToolbarClosure toolbar_c; |
| 292 | LttvMenuClosure menu_c; |
| 293 | LttvAttributeValue value; |
| 294 | gboolean retval; |
| 295 | |
| 296 | if(view_constructor == NULL) return; |
| 297 | |
| 298 | if(pixmap != NULL) { |
| 299 | retval= lttv_iattribute_find_by_path(attributes_global, "viewers/toolbar", |
| 300 | LTTV_POINTER, &value); |
| 301 | g_assert(retval); |
| 302 | toolbar = (LttvToolbars*)*(value.v_pointer); |
| 303 | |
| 304 | if(toolbar == NULL) { |
| 305 | toolbar = lttv_toolbars_new(); |
| 306 | *(value.v_pointer) = toolbar; |
| 307 | } |
| 308 | toolbar_c = lttv_toolbars_add(toolbar, view_constructor, tooltip, pixmap, |
| 309 | NULL); |
| 310 | |
| 311 | g_slist_foreach(g_main_window_list, |
| 312 | (gpointer)add_toolbar_constructor, |
| 313 | &toolbar_c); |
| 314 | } |
| 315 | |
| 316 | if(menu_path != NULL) { |
| 317 | retval= lttv_iattribute_find_by_path(attributes_global, "viewers/menu", |
| 318 | LTTV_POINTER, &value); |
| 319 | g_assert(retval); |
| 320 | menu = (LttvMenus*)*(value.v_pointer); |
| 321 | |
| 322 | if(menu == NULL) { |
| 323 | menu = lttv_menus_new(); |
| 324 | *(value.v_pointer) = menu; |
| 325 | } |
| 326 | menu_c = lttv_menus_add(menu, view_constructor, menu_path, menu_text,NULL); |
| 327 | |
| 328 | g_slist_foreach(g_main_window_list, |
| 329 | (gpointer)add_menu_constructor, |
| 330 | &menu_c); |
| 331 | } |
| 332 | { |
| 333 | LttvAttribute *attribute; |
| 334 | gboolean result; |
| 335 | |
| 336 | attribute = LTTV_ATTRIBUTE(lttv_iattribute_find_subdir( |
| 337 | LTTV_IATTRIBUTE(attributes_global), |
| 338 | LTTV_VIEWER_CONSTRUCTORS)); |
| 339 | g_assert(attribute); |
| 340 | |
| 341 | result = lttv_iattribute_find_by_path(LTTV_IATTRIBUTE(attribute), |
| 342 | name, LTTV_POINTER, &value); |
| 343 | g_assert(result); |
| 344 | |
| 345 | *(value.v_pointer) = view_constructor; |
| 346 | |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | |
| 351 | /** |
| 352 | * Function to unregister the viewer's constructor, release the space |
| 353 | * occupied by menu_path, menu_text, pixmap, tooltip and constructor of the |
| 354 | * viewer. |
| 355 | * |
| 356 | * It will be called when a module is unloaded. |
| 357 | * |
| 358 | * @param view_constructor constructor of the viewer. |
| 359 | */ |
| 360 | |
| 361 | |
| 362 | __EXPORT void lttvwindow_unregister_constructor |
| 363 | (lttvwindow_viewer_constructor view_constructor) |
| 364 | { |
| 365 | LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes()); |
| 366 | LttvToolbars * toolbar; |
| 367 | LttvMenus * menu; |
| 368 | LttvAttributeValue value; |
| 369 | gboolean is_named; |
| 370 | gboolean retval; |
| 371 | |
| 372 | retval= lttv_iattribute_find_by_path(attributes_global, "viewers/toolbar", |
| 373 | LTTV_POINTER, &value); |
| 374 | g_assert(retval); |
| 375 | toolbar = (LttvToolbars*)*(value.v_pointer); |
| 376 | |
| 377 | if(toolbar != NULL) { |
| 378 | g_slist_foreach(g_main_window_list, |
| 379 | (gpointer)remove_toolbar_constructor, |
| 380 | view_constructor); |
| 381 | lttv_toolbars_remove(toolbar, view_constructor); |
| 382 | } |
| 383 | |
| 384 | retval= lttv_iattribute_find_by_path(attributes_global, "viewers/menu", |
| 385 | LTTV_POINTER, &value); |
| 386 | g_assert(retval); |
| 387 | menu = (LttvMenus*)*(value.v_pointer); |
| 388 | |
| 389 | if(menu != NULL) { |
| 390 | g_slist_foreach(g_main_window_list, |
| 391 | (gpointer)remove_menu_constructor, |
| 392 | view_constructor); |
| 393 | lttv_menus_remove(menu, view_constructor); |
| 394 | } |
| 395 | |
| 396 | { |
| 397 | LttvAttribute *attribute; |
| 398 | attribute = LTTV_ATTRIBUTE(lttv_iattribute_find_subdir( |
| 399 | LTTV_IATTRIBUTE(attributes_global), |
| 400 | LTTV_VIEWER_CONSTRUCTORS)); |
| 401 | g_assert(attribute); |
| 402 | |
| 403 | guint num = lttv_iattribute_get_number(LTTV_IATTRIBUTE(attribute)); |
| 404 | guint i; |
| 405 | LttvAttributeName name; |
| 406 | LttvAttributeValue value; |
| 407 | LttvAttributeType type; |
| 408 | |
| 409 | for(i=0;i<num;i++) { |
| 410 | type = lttv_iattribute_get(LTTV_IATTRIBUTE(attribute), i, &name, &value, |
| 411 | &is_named); |
| 412 | g_assert(type == LTTV_POINTER); |
| 413 | if(*(value.v_pointer) == view_constructor) { |
| 414 | lttv_iattribute_remove(LTTV_IATTRIBUTE(attribute), i); |
| 415 | break; |
| 416 | } |
| 417 | } |
| 418 | } |
| 419 | } |
| 420 | |
| 421 | |
| 422 | /** |
| 423 | * Function to register a hook function for a viewer to set/update its |
| 424 | * time interval. |
| 425 | * @param tab viewer's tab |
| 426 | * @param hook hook function of the viewer. |
| 427 | * @param hook_data hook data associated with the hook function. |
| 428 | */ |
| 429 | __EXPORT void lttvwindow_register_time_window_notify(Tab *tab, |
| 430 | LttvHook hook, gpointer hook_data) |
| 431 | { |
| 432 | LttvAttributeValue value; |
| 433 | LttvHooks * tmp; |
| 434 | gboolean retval; |
| 435 | |
| 436 | retval= lttv_iattribute_find_by_path(tab->attributes, |
| 437 | "hooks/updatetimewindow", LTTV_POINTER, &value); |
| 438 | g_assert(retval); |
| 439 | tmp = (LttvHooks*)*(value.v_pointer); |
| 440 | if(tmp == NULL){ |
| 441 | tmp = lttv_hooks_new(); |
| 442 | *(value.v_pointer) = tmp; |
| 443 | } |
| 444 | lttv_hooks_add(tmp, hook,hook_data, LTTV_PRIO_DEFAULT); |
| 445 | } |
| 446 | |
| 447 | |
| 448 | /** |
| 449 | * Function to unregister a viewer's hook function which is used to |
| 450 | * set/update the time interval of the viewer. |
| 451 | * @param tab viewer's tab |
| 452 | * @param hook hook function of the viewer. |
| 453 | * @param hook_data hook data associated with the hook function. |
| 454 | */ |
| 455 | |
| 456 | __EXPORT void lttvwindow_unregister_time_window_notify(Tab *tab, |
| 457 | LttvHook hook, gpointer hook_data) |
| 458 | { |
| 459 | LttvAttributeValue value; |
| 460 | LttvHooks * tmp; |
| 461 | gboolean retval; |
| 462 | |
| 463 | retval= lttv_iattribute_find_by_path(tab->attributes, |
| 464 | "hooks/updatetimewindow", LTTV_POINTER, &value); |
| 465 | g_assert(retval); |
| 466 | tmp = (LttvHooks*)*(value.v_pointer); |
| 467 | if(tmp == NULL) return; |
| 468 | lttv_hooks_remove_data(tmp, hook, hook_data); |
| 469 | } |
| 470 | |
| 471 | /** |
| 472 | * Function to register a hook function for a viewer to set/update its |
| 473 | * allowed time span. |
| 474 | * @param tab viewer's tab |
| 475 | * @param hook hook function of the viewer. |
| 476 | * @param hook_data hook data associated with the hook function. |
| 477 | */ |
| 478 | __EXPORT void lttvwindow_register_timespan_notify(Tab *tab, |
| 479 | LttvHook hook, gpointer hook_data) |
| 480 | { |
| 481 | LttvAttributeValue value; |
| 482 | LttvHooks * tmp; |
| 483 | gboolean retval; |
| 484 | |
| 485 | retval= lttv_iattribute_find_by_path(tab->attributes, |
| 486 | "hooks/updatetimespan", LTTV_POINTER, &value); |
| 487 | g_assert(retval); |
| 488 | tmp = (LttvHooks*)*(value.v_pointer); |
| 489 | if(tmp == NULL){ |
| 490 | tmp = lttv_hooks_new(); |
| 491 | *(value.v_pointer) = tmp; |
| 492 | } |
| 493 | lttv_hooks_add(tmp, hook,hook_data, LTTV_PRIO_DEFAULT); |
| 494 | } |
| 495 | /** |
| 496 | * Function to unregister a viewer's hook function which is used to |
| 497 | * set/update the time span allowed for the viewer. |
| 498 | * @param tab viewer's tab |
| 499 | * @param hook hook function of the viewer. |
| 500 | * @param hook_data hook data associated with the hook function. |
| 501 | */ |
| 502 | |
| 503 | __EXPORT void lttvwindow_unregister_timespan_notify(Tab *tab, |
| 504 | LttvHook hook, gpointer hook_data) |
| 505 | { |
| 506 | LttvAttributeValue value; |
| 507 | LttvHooks * tmp; |
| 508 | gboolean retval; |
| 509 | |
| 510 | retval= lttv_iattribute_find_by_path(tab->attributes, |
| 511 | "hooks/updatetimespan", LTTV_POINTER, &value); |
| 512 | g_assert(retval); |
| 513 | tmp = (LttvHooks*)*(value.v_pointer); |
| 514 | if(tmp == NULL) return; |
| 515 | lttv_hooks_remove_data(tmp, hook, hook_data); |
| 516 | } |
| 517 | |
| 518 | /** |
| 519 | * Function to register a hook function for a viewer to set/update its |
| 520 | * traceset. |
| 521 | * @param tab viewer's tab |
| 522 | * @param hook hook function of the viewer. |
| 523 | * @param hook_data hook data associated with the hook function. |
| 524 | */ |
| 525 | |
| 526 | __EXPORT void lttvwindow_register_traceset_notify(Tab *tab, |
| 527 | LttvHook hook, gpointer hook_data) |
| 528 | { |
| 529 | LttvAttributeValue value; |
| 530 | LttvHooks * tmp; |
| 531 | gboolean retval; |
| 532 | |
| 533 | retval= lttv_iattribute_find_by_path(tab->attributes, |
| 534 | "hooks/updatetraceset", LTTV_POINTER, &value); |
| 535 | g_assert(retval); |
| 536 | tmp = (LttvHooks*)*(value.v_pointer); |
| 537 | if(tmp == NULL){ |
| 538 | tmp = lttv_hooks_new(); |
| 539 | *(value.v_pointer) = tmp; |
| 540 | } |
| 541 | lttv_hooks_add(tmp, hook, hook_data, LTTV_PRIO_DEFAULT); |
| 542 | } |
| 543 | |
| 544 | |
| 545 | /** |
| 546 | * Function to unregister a viewer's hook function which is used to |
| 547 | * set/update the traceset of the viewer. |
| 548 | * @param tab viewer's tab |
| 549 | * @param hook hook function of the viewer. |
| 550 | * @param hook_data hook data associated with the hook function. |
| 551 | */ |
| 552 | |
| 553 | __EXPORT void lttvwindow_unregister_traceset_notify(Tab *tab, |
| 554 | LttvHook hook, gpointer hook_data) |
| 555 | { |
| 556 | LttvAttributeValue value; |
| 557 | LttvHooks * tmp; |
| 558 | gboolean retval; |
| 559 | |
| 560 | retval= lttv_iattribute_find_by_path(tab->attributes, |
| 561 | "hooks/updatetraceset", LTTV_POINTER, &value); |
| 562 | g_assert(retval); |
| 563 | tmp = (LttvHooks*)*(value.v_pointer); |
| 564 | if(tmp == NULL) return; |
| 565 | lttv_hooks_remove_data(tmp, hook, hook_data); |
| 566 | } |
| 567 | |
| 568 | /** |
| 569 | * Function to register a hook function for a viewer be completely redrawn. |
| 570 | * |
| 571 | * @param tab viewer's tab |
| 572 | * @param hook hook function of the viewer. |
| 573 | * @param hook_data hook data associated with the hook function. |
| 574 | */ |
| 575 | |
| 576 | __EXPORT void lttvwindow_register_redraw_notify(Tab *tab, |
| 577 | LttvHook hook, gpointer hook_data) |
| 578 | { |
| 579 | LttvAttributeValue value; |
| 580 | LttvHooks * tmp; |
| 581 | gboolean retval; |
| 582 | |
| 583 | retval= lttv_iattribute_find_by_path(tab->attributes, "hooks/redraw", |
| 584 | LTTV_POINTER, &value); |
| 585 | g_assert(retval); |
| 586 | tmp = (LttvHooks*)*(value.v_pointer); |
| 587 | if(tmp == NULL){ |
| 588 | tmp = lttv_hooks_new(); |
| 589 | *(value.v_pointer) = tmp; |
| 590 | } |
| 591 | lttv_hooks_add(tmp, hook, hook_data, LTTV_PRIO_DEFAULT); |
| 592 | } |
| 593 | |
| 594 | |
| 595 | /** |
| 596 | * Function to unregister a hook function for a viewer be completely redrawn. |
| 597 | * |
| 598 | * @param tab viewer's tab |
| 599 | * @param hook hook function of the viewer. |
| 600 | * @param hook_data hook data associated with the hook function. |
| 601 | */ |
| 602 | |
| 603 | __EXPORT void lttvwindow_unregister_redraw_notify(Tab *tab, |
| 604 | LttvHook hook, gpointer hook_data) |
| 605 | { |
| 606 | LttvAttributeValue value; |
| 607 | LttvHooks * tmp; |
| 608 | gboolean retval; |
| 609 | |
| 610 | retval= lttv_iattribute_find_by_path(tab->attributes, "hooks/redraw", |
| 611 | LTTV_POINTER, &value); |
| 612 | g_assert(retval); |
| 613 | tmp = (LttvHooks*)*(value.v_pointer); |
| 614 | if(tmp == NULL) return; |
| 615 | lttv_hooks_remove_data(tmp, hook, hook_data); |
| 616 | } |
| 617 | |
| 618 | /** |
| 619 | * Function to register a hook function for a viewer to re-do the events |
| 620 | * requests for the needed interval. |
| 621 | * |
| 622 | * This action is typically done after a "stop". |
| 623 | * |
| 624 | * The typical hook will remove all current requests for the viewer |
| 625 | * and make requests for missing information. |
| 626 | * |
| 627 | * @param tab viewer's tab |
| 628 | * @param hook hook function of the viewer. |
| 629 | * @param hook_data hook data associated with the hook function. |
| 630 | */ |
| 631 | |
| 632 | __EXPORT void lttvwindow_register_continue_notify(Tab *tab, |
| 633 | LttvHook hook, gpointer hook_data) |
| 634 | { |
| 635 | LttvAttributeValue value; |
| 636 | LttvHooks * tmp; |
| 637 | gboolean retval; |
| 638 | |
| 639 | retval= lttv_iattribute_find_by_path(tab->attributes, "hooks/continue", |
| 640 | LTTV_POINTER, &value); |
| 641 | g_assert(retval); |
| 642 | tmp = (LttvHooks*)*(value.v_pointer); |
| 643 | if(tmp == NULL){ |
| 644 | tmp = lttv_hooks_new(); |
| 645 | *(value.v_pointer) = tmp; |
| 646 | } |
| 647 | lttv_hooks_add(tmp, hook, hook_data, LTTV_PRIO_DEFAULT); |
| 648 | } |
| 649 | |
| 650 | |
| 651 | /** |
| 652 | * Function to unregister a hook function for a viewer to re-do the events |
| 653 | * requests for the needed interval. |
| 654 | * |
| 655 | * @param tab viewer's tab |
| 656 | * @param hook hook function of the viewer. |
| 657 | * @param hook_data hook data associated with the hook function. |
| 658 | */ |
| 659 | |
| 660 | __EXPORT void lttvwindow_unregister_continue_notify(Tab *tab, |
| 661 | LttvHook hook, gpointer hook_data) |
| 662 | { |
| 663 | LttvAttributeValue value; |
| 664 | LttvHooks * tmp; |
| 665 | gboolean retval; |
| 666 | |
| 667 | retval= lttv_iattribute_find_by_path(tab->attributes, "hooks/continue", |
| 668 | LTTV_POINTER, &value); |
| 669 | g_assert(retval); |
| 670 | tmp = (LttvHooks*)*(value.v_pointer); |
| 671 | if(tmp == NULL) return; |
| 672 | lttv_hooks_remove_data(tmp, hook, hook_data); |
| 673 | } |
| 674 | |
| 675 | |
| 676 | /** |
| 677 | * Function to register a hook function for a viewer to set/update its |
| 678 | * filter. |
| 679 | * @param tab viewer's tab |
| 680 | * @param hook hook function of the viewer. |
| 681 | * @param hook_data hook data associated with the hook function. |
| 682 | */ |
| 683 | |
| 684 | __EXPORT void lttvwindow_register_filter_notify(Tab *tab, |
| 685 | LttvHook hook, gpointer hook_data) |
| 686 | { |
| 687 | LttvAttributeValue value; |
| 688 | LttvHooks * tmp; |
| 689 | gboolean retval; |
| 690 | |
| 691 | retval= lttv_iattribute_find_by_path(tab->attributes, "hooks/updatefilter", |
| 692 | LTTV_POINTER, &value); |
| 693 | g_assert(retval); |
| 694 | tmp = (LttvHooks*)*(value.v_pointer); |
| 695 | if(tmp == NULL){ |
| 696 | tmp = lttv_hooks_new(); |
| 697 | *(value.v_pointer) = tmp; |
| 698 | } |
| 699 | lttv_hooks_add(tmp, hook, hook_data, LTTV_PRIO_DEFAULT); |
| 700 | } |
| 701 | |
| 702 | |
| 703 | /** |
| 704 | * Function to unregister a viewer's hook function which is used to |
| 705 | * set/update the filter of the viewer. |
| 706 | * @param tab viewer's tab |
| 707 | * @param hook hook function of the viewer. |
| 708 | * @param hook_data hook data associated with the hook function. |
| 709 | */ |
| 710 | |
| 711 | __EXPORT void lttvwindow_unregister_filter_notify(Tab *tab, |
| 712 | LttvHook hook, |
| 713 | gpointer hook_data) |
| 714 | { |
| 715 | LttvAttributeValue value; |
| 716 | LttvHooks * tmp; |
| 717 | gboolean retval; |
| 718 | |
| 719 | retval= lttv_iattribute_find_by_path(tab->attributes, "hooks/updatefilter", |
| 720 | LTTV_POINTER, &value); |
| 721 | g_assert(retval); |
| 722 | tmp = (LttvHooks*)*(value.v_pointer); |
| 723 | if(tmp == NULL) return; |
| 724 | lttv_hooks_remove_data(tmp, hook, hook_data); |
| 725 | } |
| 726 | |
| 727 | /** |
| 728 | * function to register a hook function for a viewer to set/update its |
| 729 | * current time. |
| 730 | * @param tab viewer's tab |
| 731 | * @param hook hook function of the viewer. |
| 732 | * @param hook_data hook data associated with the hook function. |
| 733 | */ |
| 734 | |
| 735 | __EXPORT void lttvwindow_register_current_time_notify(Tab *tab, |
| 736 | LttvHook hook, gpointer hook_data) |
| 737 | { |
| 738 | LttvAttributeValue value; |
| 739 | LttvHooks * tmp; |
| 740 | gboolean retval; |
| 741 | |
| 742 | retval= lttv_iattribute_find_by_path(tab->attributes, |
| 743 | "hooks/updatecurrenttime", LTTV_POINTER, &value); |
| 744 | g_assert(retval); |
| 745 | tmp = (LttvHooks*)*(value.v_pointer); |
| 746 | if(tmp == NULL){ |
| 747 | tmp = lttv_hooks_new(); |
| 748 | *(value.v_pointer) = tmp; |
| 749 | } |
| 750 | lttv_hooks_add(tmp, hook, hook_data, LTTV_PRIO_DEFAULT); |
| 751 | } |
| 752 | |
| 753 | |
| 754 | /** |
| 755 | * function to unregister a viewer's hook function which is used to |
| 756 | * set/update the current time of the viewer. |
| 757 | * @param tab viewer's tab |
| 758 | * @param hook hook function of the viewer. |
| 759 | * @param hook_data hook data associated with the hook function. |
| 760 | */ |
| 761 | |
| 762 | __EXPORT void lttvwindow_unregister_current_time_notify(Tab *tab, |
| 763 | LttvHook hook, gpointer hook_data) |
| 764 | { |
| 765 | LttvAttributeValue value; |
| 766 | LttvHooks * tmp; |
| 767 | gboolean retval; |
| 768 | |
| 769 | retval= lttv_iattribute_find_by_path(tab->attributes, |
| 770 | "hooks/updatecurrenttime", LTTV_POINTER, &value); |
| 771 | g_assert(retval); |
| 772 | tmp = (LttvHooks*)*(value.v_pointer); |
| 773 | if(tmp == NULL) return; |
| 774 | lttv_hooks_remove_data(tmp, hook, hook_data); |
| 775 | } |
| 776 | |
| 777 | /** |
| 778 | * function to register a hook function for a viewer to set/update its |
| 779 | * current position. |
| 780 | * @param tab viewer's tab |
| 781 | * @param hook hook function of the viewer. |
| 782 | * @param hook_data hook data associated with the hook function. |
| 783 | */ |
| 784 | |
| 785 | __EXPORT void lttvwindow_register_current_position_notify(Tab *tab, |
| 786 | LttvHook hook, gpointer hook_data) |
| 787 | { |
| 788 | LttvAttributeValue value; |
| 789 | LttvHooks * tmp; |
| 790 | gboolean retval; |
| 791 | |
| 792 | retval= lttv_iattribute_find_by_path(tab->attributes, |
| 793 | "hooks/updatecurrentposition", LTTV_POINTER, &value); |
| 794 | g_assert(retval); |
| 795 | tmp = (LttvHooks*)*(value.v_pointer); |
| 796 | if(tmp == NULL){ |
| 797 | tmp = lttv_hooks_new(); |
| 798 | *(value.v_pointer) = tmp; |
| 799 | } |
| 800 | lttv_hooks_add(tmp, hook, hook_data, LTTV_PRIO_DEFAULT); |
| 801 | } |
| 802 | |
| 803 | |
| 804 | /** |
| 805 | * function to unregister a viewer's hook function which is used to |
| 806 | * set/update the current position of the viewer. |
| 807 | * @param tab viewer's tab |
| 808 | * @param hook hook function of the viewer. |
| 809 | * @param hook_data hook data associated with the hook function. |
| 810 | */ |
| 811 | |
| 812 | __EXPORT void lttvwindow_unregister_current_position_notify(Tab *tab, |
| 813 | LttvHook hook, gpointer hook_data) |
| 814 | { |
| 815 | LttvAttributeValue value; |
| 816 | LttvHooks * tmp; |
| 817 | gboolean retval; |
| 818 | |
| 819 | retval= lttv_iattribute_find_by_path(tab->attributes, |
| 820 | "hooks/updatecurrentposition", LTTV_POINTER, &value); |
| 821 | g_assert(retval); |
| 822 | tmp = (LttvHooks*)*(value.v_pointer); |
| 823 | if(tmp == NULL) return; |
| 824 | lttv_hooks_remove_data(tmp, hook, hook_data); |
| 825 | } |
| 826 | |
| 827 | |
| 828 | /** |
| 829 | * Function to register a hook function for a viewer to show |
| 830 | * the content of the viewer. |
| 831 | * @param tab viewer's tab |
| 832 | * @param hook hook function of the viewer. |
| 833 | * @param hook_data hook data associated with the hook function. |
| 834 | */ |
| 835 | |
| 836 | void lttvwindow_register_show_notify(Tab *tab, |
| 837 | LttvHook hook, gpointer hook_data) |
| 838 | { |
| 839 | LttvAttributeValue value; |
| 840 | LttvHooks * tmp; |
| 841 | gboolean retval; |
| 842 | |
| 843 | retval= lttv_iattribute_find_by_path(tab->attributes, "hooks/showviewer", |
| 844 | LTTV_POINTER, &value); |
| 845 | g_assert(retval); |
| 846 | tmp = (LttvHooks*)*(value.v_pointer); |
| 847 | if(tmp == NULL){ |
| 848 | tmp = lttv_hooks_new(); |
| 849 | *(value.v_pointer) = tmp; |
| 850 | } |
| 851 | lttv_hooks_add(tmp, hook, hook_data, LTTV_PRIO_DEFAULT); |
| 852 | } |
| 853 | |
| 854 | |
| 855 | /** |
| 856 | * Function to unregister a viewer's hook function which is used to |
| 857 | * show the content of the viewer.. |
| 858 | * @param tab viewer's tab |
| 859 | * @param hook hook function of the viewer. |
| 860 | * @param hook_data hook data associated with the hook function. |
| 861 | */ |
| 862 | |
| 863 | void lttvwindow_unregister_show_notify(Tab *tab, |
| 864 | LttvHook hook, gpointer hook_data) |
| 865 | { |
| 866 | LttvAttributeValue value; |
| 867 | LttvHooks * tmp; |
| 868 | gboolean retval; |
| 869 | |
| 870 | retval= lttv_iattribute_find_by_path(tab->attributes, "hooks/showviewer", |
| 871 | LTTV_POINTER, &value); |
| 872 | g_assert(retval); |
| 873 | tmp = (LttvHooks*)*(value.v_pointer); |
| 874 | if(tmp == NULL) return; |
| 875 | lttv_hooks_remove_data(tmp, hook, hook_data); |
| 876 | } |
| 877 | |
| 878 | /** |
| 879 | * Function to register a hook function for a viewer to set/update the |
| 880 | * dividor of the hpane. |
| 881 | * @param tab viewer's tab |
| 882 | * @param hook hook function of the viewer. |
| 883 | * @param hook_data hook data associated with the hook function. |
| 884 | */ |
| 885 | |
| 886 | void lttvwindow_register_dividor(Tab *tab, |
| 887 | LttvHook hook, gpointer hook_data) |
| 888 | { |
| 889 | LttvAttributeValue value; |
| 890 | LttvHooks * tmp; |
| 891 | gboolean retval; |
| 892 | |
| 893 | retval= lttv_iattribute_find_by_path(tab->attributes, "hooks/hpanedividor", |
| 894 | LTTV_POINTER, &value); |
| 895 | g_assert(retval); |
| 896 | tmp = (LttvHooks*)*(value.v_pointer); |
| 897 | if(tmp == NULL){ |
| 898 | tmp = lttv_hooks_new(); |
| 899 | *(value.v_pointer) = tmp; |
| 900 | } |
| 901 | lttv_hooks_add(tmp, hook, hook_data, LTTV_PRIO_DEFAULT); |
| 902 | } |
| 903 | |
| 904 | |
| 905 | /** |
| 906 | * Function to unregister a viewer's hook function which is used to |
| 907 | * set/update hpane's dividor of the viewer. |
| 908 | * It will be called by the destructor of the viewer. |
| 909 | * @param tab viewer's tab |
| 910 | * @param hook hook function of the viewer. |
| 911 | * @param hook_data hook data associated with the hook function. |
| 912 | */ |
| 913 | |
| 914 | void lttvwindow_unregister_dividor(Tab *tab, |
| 915 | LttvHook hook, gpointer hook_data) |
| 916 | { |
| 917 | LttvAttributeValue value; |
| 918 | LttvHooks * tmp; |
| 919 | gboolean retval; |
| 920 | |
| 921 | retval= lttv_iattribute_find_by_path(tab->attributes, "hooks/hpanedividor", |
| 922 | LTTV_POINTER, &value); |
| 923 | g_assert(retval); |
| 924 | tmp = (LttvHooks*)*(value.v_pointer); |
| 925 | if(tmp == NULL) return; |
| 926 | lttv_hooks_remove_data(tmp, hook, hook_data); |
| 927 | } |
| 928 | |
| 929 | |
| 930 | /** |
| 931 | * Function to set the time interval of the current tab. |
| 932 | * It will be called by a viewer's signal handle associated with |
| 933 | * the move_slider signal |
| 934 | * @param tab viewer's tab |
| 935 | * @param time_interval a pointer where time interval is stored. |
| 936 | */ |
| 937 | |
| 938 | __EXPORT void lttvwindow_report_time_window(Tab *tab, |
| 939 | TimeWindow time_window) |
| 940 | { |
| 941 | //set_time_window(tab, time_window); |
| 942 | //set_time_window_adjustment(tab, time_window); |
| 943 | |
| 944 | time_change_manager(tab, time_window); |
| 945 | |
| 946 | |
| 947 | #if 0 |
| 948 | /* Set scrollbar */ |
| 949 | LttvTracesetContext *tsc = |
| 950 | LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context); |
| 951 | TimeInterval time_span = tsc->time_span; |
| 952 | GtkAdjustment *adjustment = gtk_range_get_adjustment(GTK_RANGE(tab->scrollbar)); |
| 953 | g_object_set(G_OBJECT(adjustment), |
| 954 | "lower", |
| 955 | 0.0, /* lower */ |
| 956 | "upper", |
| 957 | ltt_time_to_double( |
| 958 | ltt_time_sub(time_span.end_time, time_span.start_time)) |
| 959 | , /* upper */ |
| 960 | "step_increment", |
| 961 | ltt_time_to_double(time_window->time_width) |
| 962 | / SCROLL_STEP_PER_PAGE |
| 963 | , /* step increment */ |
| 964 | "page_increment", |
| 965 | ltt_time_to_double(time_window->time_width) |
| 966 | , /* page increment */ |
| 967 | "page_size", |
| 968 | ltt_time_to_double(time_window->time_width) |
| 969 | , /* page size */ |
| 970 | NULL); |
| 971 | gtk_adjustment_changed(adjustment); |
| 972 | |
| 973 | //g_object_set(G_OBJECT(adjustment), |
| 974 | // "value", |
| 975 | // ltt_time_to_double(time_window->start_time) |
| 976 | // , /* value */ |
| 977 | // NULL); |
| 978 | /* Note : the set value will call set_time_window if scrollbar value changed |
| 979 | */ |
| 980 | gtk_adjustment_set_value(adjustment, |
| 981 | ltt_time_to_double( |
| 982 | ltt_time_sub(time_window->start_time, |
| 983 | time_span.start_time)) |
| 984 | ); |
| 985 | #endif //0 |
| 986 | } |
| 987 | |
| 988 | |
| 989 | /** |
| 990 | * Function to set the current time of the current tab. |
| 991 | * It will be called by a viewer's signal handle associated with |
| 992 | * the button-release-event signal |
| 993 | * @param tab viewer's tab |
| 994 | * @param time a pointer where time is stored. |
| 995 | */ |
| 996 | |
| 997 | __EXPORT void lttvwindow_report_current_time(Tab *tab, |
| 998 | LttTime time) |
| 999 | { |
| 1000 | current_time_change_manager(tab, time); |
| 1001 | } |
| 1002 | |
| 1003 | /** |
| 1004 | * Function to set the current event of the current tab. |
| 1005 | * It will be called by a viewer's signal handle associated with |
| 1006 | * the button-release-event signal |
| 1007 | * @param tab viewer's tab |
| 1008 | * @param time a pointer where time is stored. |
| 1009 | */ |
| 1010 | |
| 1011 | __EXPORT void lttvwindow_report_current_position(Tab *tab, |
| 1012 | LttvTracesetPosition *pos) |
| 1013 | { |
| 1014 | current_position_change_manager(tab, pos); |
| 1015 | } |
| 1016 | |
| 1017 | |
| 1018 | /** |
| 1019 | * Function to set the position of the hpane's dividor (viewer). |
| 1020 | * It will be called by a viewer's signal handle associated with |
| 1021 | * the motion_notify_event event/signal |
| 1022 | * @param tab viewer's tab |
| 1023 | * @param position position of the hpane's dividor. |
| 1024 | */ |
| 1025 | |
| 1026 | void lttvwindow_report_dividor(Tab *tab, gint position) |
| 1027 | { |
| 1028 | LttvAttributeValue value; |
| 1029 | LttvHooks * tmp; |
| 1030 | gboolean retval; |
| 1031 | |
| 1032 | retval= lttv_iattribute_find_by_path(tab->attributes, "hooks/hpanedividor", |
| 1033 | LTTV_POINTER, &value); |
| 1034 | g_assert(retval); |
| 1035 | tmp = (LttvHooks*)*(value.v_pointer); |
| 1036 | if(tmp == NULL) return; |
| 1037 | lttv_hooks_call(tmp, &position); |
| 1038 | } |
| 1039 | |
| 1040 | /** |
| 1041 | * Function to request data in a specific time interval to the main window. The |
| 1042 | * event request servicing is differed until the glib idle functions are |
| 1043 | * called. |
| 1044 | * |
| 1045 | * The viewer has to provide hooks that should be associated with the event |
| 1046 | * request. |
| 1047 | * |
| 1048 | * Either start time or start position must be defined in a EventRequest |
| 1049 | * structure for it to be valid. |
| 1050 | * |
| 1051 | * end_time, end_position and num_events can all be defined. The first one |
| 1052 | * to occur will be used as end criterion. |
| 1053 | * |
| 1054 | * @param tab viewer's tab |
| 1055 | * @param events_requested the structure of request from. |
| 1056 | */ |
| 1057 | |
| 1058 | __EXPORT void lttvwindow_events_request(Tab *tab, |
| 1059 | EventsRequest *events_request) |
| 1060 | { |
| 1061 | tab->events_requests = g_slist_append(tab->events_requests, events_request); |
| 1062 | |
| 1063 | if(!tab->events_request_pending) |
| 1064 | { |
| 1065 | /* Redraw has +20 priority. We want to let the redraw be done while we do |
| 1066 | * our job. Mathieu : test with high prio higher than events for better |
| 1067 | * scrolling. */ |
| 1068 | /* Mathieu, 2008 : ok, finally, the control flow view needs the cell updates |
| 1069 | * to come soon enough so we can have one active cell to get the pixmap |
| 1070 | * buffer height from. Therefore, let the gdk events run before the events |
| 1071 | * requests. |
| 1072 | */ |
| 1073 | g_idle_add_full((G_PRIORITY_HIGH_IDLE + 21), |
| 1074 | //g_idle_add_full((G_PRIORITY_DEFAULT + 2), |
| 1075 | (GSourceFunc)execute_events_requests, |
| 1076 | tab, |
| 1077 | NULL); |
| 1078 | tab->events_request_pending = TRUE; |
| 1079 | } |
| 1080 | } |
| 1081 | |
| 1082 | |
| 1083 | /** |
| 1084 | * Function to remove data requests related to a viewer. |
| 1085 | * |
| 1086 | * The existing requests's viewer gpointer is compared to the pointer |
| 1087 | * given in argument to establish which data request should be removed. |
| 1088 | * |
| 1089 | * @param tab the tab the viewer belongs to. |
| 1090 | * @param viewer a pointer to the viewer data structure |
| 1091 | */ |
| 1092 | |
| 1093 | gint find_viewer (const EventsRequest *a, gconstpointer b) |
| 1094 | { |
| 1095 | return (a->owner != b); |
| 1096 | } |
| 1097 | |
| 1098 | |
| 1099 | __EXPORT void lttvwindow_events_request_remove_all(Tab *tab, |
| 1100 | gconstpointer viewer) |
| 1101 | { |
| 1102 | GSList *element = tab->events_requests; |
| 1103 | |
| 1104 | while((element = |
| 1105 | g_slist_find_custom(element, viewer, |
| 1106 | (GCompareFunc)find_viewer)) |
| 1107 | != NULL) { |
| 1108 | EventsRequest *events_request = (EventsRequest *)element->data; |
| 1109 | // Modified so a viewer being destroyed won't have its after_request |
| 1110 | // called. Not so important anyway. Note that a viewer that call this |
| 1111 | // remove_all function will not get its after_request called. |
| 1112 | //if(events_request->servicing == TRUE) { |
| 1113 | // lttv_hooks_call(events_request->after_request, NULL); |
| 1114 | //} |
| 1115 | events_request_free(events_request); |
| 1116 | //g_free(events_request); |
| 1117 | tab->events_requests = g_slist_remove_link(tab->events_requests, element); |
| 1118 | element = g_slist_next(element); |
| 1119 | if(element == NULL) break; /* end of list */ |
| 1120 | } |
| 1121 | if(g_slist_length(tab->events_requests) == 0) { |
| 1122 | tab->events_request_pending = FALSE; |
| 1123 | g_idle_remove_by_data(tab); |
| 1124 | } |
| 1125 | |
| 1126 | } |
| 1127 | |
| 1128 | |
| 1129 | /** |
| 1130 | * Function to see if there are events request pending. |
| 1131 | * |
| 1132 | * It tells if events requests are pending. Useful for checks in some events, |
| 1133 | * i.e. detailed event list scrolling. |
| 1134 | * |
| 1135 | * @param tab the tab the viewer belongs to. |
| 1136 | * @param viewer a pointer to the viewer data structure |
| 1137 | * @return : TRUE is events requests are pending, else FALSE. |
| 1138 | */ |
| 1139 | |
| 1140 | __EXPORT gboolean lttvwindow_events_request_pending(Tab *tab) |
| 1141 | { |
| 1142 | GSList *element = tab->events_requests; |
| 1143 | |
| 1144 | if(element == NULL){ |
| 1145 | return FALSE; |
| 1146 | } |
| 1147 | else { |
| 1148 | return TRUE; |
| 1149 | } |
| 1150 | } |
| 1151 | |
| 1152 | |
| 1153 | /** |
| 1154 | * Function to get the current time interval shown on the current tab. |
| 1155 | * It will be called by a viewer's hook function to update the |
| 1156 | * shown time interval of the viewer and also be called by the constructor |
| 1157 | * of the viewer. |
| 1158 | * @param tab viewer's tab |
| 1159 | * @return time window. |
| 1160 | */ |
| 1161 | |
| 1162 | __EXPORT TimeWindow lttvwindow_get_time_window(Tab *tab) |
| 1163 | { |
| 1164 | return tab->time_window; |
| 1165 | } |
| 1166 | |
| 1167 | |
| 1168 | /** |
| 1169 | * Function to get the current time/event of the current tab. |
| 1170 | * It will be called by a viewer's hook function to update the |
| 1171 | * current time/event of the viewer. |
| 1172 | * @param tab viewer's tab |
| 1173 | * @return time |
| 1174 | */ |
| 1175 | |
| 1176 | __EXPORT LttTime lttvwindow_get_current_time(Tab *tab) |
| 1177 | { |
| 1178 | return tab->current_time; |
| 1179 | } |
| 1180 | |
| 1181 | |
| 1182 | /** |
| 1183 | * Function to get the filter of the current tab. |
| 1184 | * @param filter, a pointer to a filter. |
| 1185 | * |
| 1186 | * returns the current filter |
| 1187 | */ |
| 1188 | __EXPORT LttvFilter *lttvwindow_get_filter(Tab *tab) |
| 1189 | { |
| 1190 | return g_object_get_data(G_OBJECT(tab->vbox), "filter"); |
| 1191 | } |
| 1192 | |
| 1193 | /** |
| 1194 | * Function to set the filter of the current tab. |
| 1195 | * It should be called by the filter GUI to tell the |
| 1196 | * main window to update the filter tab's lttv_filter. |
| 1197 | * |
| 1198 | * This function does change the current filter, removing the |
| 1199 | * old one when necessary, and call the updatefilter hooks |
| 1200 | * of the registered viewers. |
| 1201 | * |
| 1202 | * @param main_win, the main window the viewer belongs to. |
| 1203 | * @param filter, a pointer to a filter. |
| 1204 | */ |
| 1205 | void lttvwindow_report_filter(Tab *tab, LttvFilter *filter) |
| 1206 | { |
| 1207 | LttvAttributeValue value; |
| 1208 | LttvHooks * tmp; |
| 1209 | gboolean retval; |
| 1210 | |
| 1211 | //lttv_filter_destroy(tab->filter); |
| 1212 | //tab->filter = filter; |
| 1213 | |
| 1214 | retval= lttv_iattribute_find_by_path(tab->attributes, "hooks/updatefilter", |
| 1215 | LTTV_POINTER, &value); |
| 1216 | g_assert(retval); |
| 1217 | tmp = (LttvHooks*)*(value.v_pointer); |
| 1218 | if(tmp == NULL) return; |
| 1219 | lttv_hooks_call(tmp, filter); |
| 1220 | } |
| 1221 | |
| 1222 | #ifdef BABEL_CLEANUP |
| 1223 | |
| 1224 | /** |
| 1225 | * Function to get the stats of the traceset |
| 1226 | * @param tab viewer's tab |
| 1227 | */ |
| 1228 | |
| 1229 | __EXPORT LttvTracesetStats* lttvwindow_get_traceset_stats(Tab *tab) |
| 1230 | { |
| 1231 | return tab->traceset_info->traceset_context; |
| 1232 | } |
| 1233 | #endif /*BABEL_CLEANUP*/ |
| 1234 | |
| 1235 | __EXPORT LttvTraceset *lttvwindow_get_traceset(Tab *tab) |
| 1236 | { |
| 1237 | return tab->traceset_info->traceset; |
| 1238 | } |
| 1239 | |
| 1240 | void events_request_free(EventsRequest *events_request) |
| 1241 | { |
| 1242 | |
| 1243 | if(events_request == NULL) return; |
| 1244 | |
| 1245 | if(events_request->start_position != NULL) |
| 1246 | lttv_traceset_destroy_position(events_request->start_position); |
| 1247 | if(events_request->end_position != NULL) |
| 1248 | lttv_traceset_destroy_position(events_request->end_position); |
| 1249 | #ifdef BABEL_CLEANUP |
| 1250 | if(events_request->hooks != NULL) { |
| 1251 | GArray *hooks = events_request->hooks; |
| 1252 | |
| 1253 | lttv_trace_hook_remove_all(&hooks); |
| 1254 | |
| 1255 | g_array_free(events_request->hooks, TRUE); |
| 1256 | |
| 1257 | } |
| 1258 | |
| 1259 | if(events_request->before_chunk_traceset != NULL) |
| 1260 | lttv_hooks_destroy(events_request->before_chunk_traceset); |
| 1261 | if(events_request->before_chunk_trace != NULL) |
| 1262 | lttv_hooks_destroy(events_request->before_chunk_trace); |
| 1263 | if(events_request->before_chunk_tracefile != NULL) |
| 1264 | lttv_hooks_destroy(events_request->before_chunk_tracefile); |
| 1265 | if(events_request->event != NULL) |
| 1266 | lttv_hooks_destroy(events_request->event); |
| 1267 | if(events_request->after_chunk_tracefile != NULL) |
| 1268 | lttv_hooks_destroy(events_request->after_chunk_tracefile); |
| 1269 | if(events_request->after_chunk_trace != NULL) |
| 1270 | lttv_hooks_destroy(events_request->after_chunk_trace); |
| 1271 | if(events_request->after_chunk_traceset != NULL) |
| 1272 | lttv_hooks_destroy(events_request->after_chunk_traceset); |
| 1273 | if(events_request->before_request != NULL) |
| 1274 | lttv_hooks_destroy(events_request->before_request); |
| 1275 | if(events_request->after_request != NULL) |
| 1276 | lttv_hooks_destroy(events_request->after_request); |
| 1277 | #endif /*BABEL_CLEANUP*/ |
| 1278 | g_free(events_request); |
| 1279 | |
| 1280 | |
| 1281 | } |
| 1282 | |
| 1283 | |
| 1284 | __EXPORT GtkWidget *main_window_get_widget(Tab *tab) |
| 1285 | { |
| 1286 | return tab->mw->mwindow; |
| 1287 | } |
| 1288 | |