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