| 1 | /*! \file gtkTraceSet.h |
| 2 | * \brief API used by the graphical viewers to interact with their top window. |
| 3 | * |
| 4 | * Main window (gui module) is the place to contain and display viewers. |
| 5 | * Viewers (lttv plugins) interacte with main window through this API and |
| 6 | * events sent by gtk. |
| 7 | * This header file should be included in each graphic module. |
| 8 | * This library is used by graphical modules to interact with the |
| 9 | * tracesetWindow. |
| 10 | * |
| 11 | */ |
| 12 | |
| 13 | #include <lttv/common.h> |
| 14 | #include <ltt/ltt.h> |
| 15 | #include <lttv/lttv.h> |
| 16 | #include <lttv/mainwindow.h> |
| 17 | #include <lttv/gtkTraceSet.h> |
| 18 | #include <lttv/processTrace.h> |
| 19 | #include <lttv/toolbar.h> |
| 20 | #include <lttv/menu.h> |
| 21 | #include <lttv/state.h> |
| 22 | #include <lttv/stats.h> |
| 23 | |
| 24 | |
| 25 | /** |
| 26 | * Internal function parts |
| 27 | */ |
| 28 | |
| 29 | /** |
| 30 | * Function to set/update traceset for the viewers |
| 31 | * @param main_win main window |
| 32 | * @param traceset traceset of the main window. |
| 33 | */ |
| 34 | |
| 35 | void SetTraceset(MainWindow * main_win, gpointer traceset) |
| 36 | { |
| 37 | LttvHooks * tmp; |
| 38 | LttvAttributeValue value; |
| 39 | |
| 40 | g_assert(lttv_iattribute_find_by_path(main_win->attributes, |
| 41 | "hooks/updatetraceset", LTTV_POINTER, &value)); |
| 42 | tmp = (LttvHooks*)*(value.v_pointer); |
| 43 | if(tmp == NULL)return; |
| 44 | lttv_hooks_call(tmp,traceset); |
| 45 | } |
| 46 | |
| 47 | |
| 48 | /** |
| 49 | * Function to set/update filter for the viewers |
| 50 | * @param main_win main window |
| 51 | * @param filter filter of the main window. |
| 52 | */ |
| 53 | |
| 54 | void SetFilter(MainWindow * main_win, gpointer filter) |
| 55 | { |
| 56 | LttvHooks * tmp; |
| 57 | LttvAttributeValue value; |
| 58 | |
| 59 | g_assert(lttv_iattribute_find_by_path(main_win->attributes, |
| 60 | "hooks/updatefilter", LTTV_POINTER, &value)); |
| 61 | tmp = (LttvHooks*)*(value.v_pointer); |
| 62 | |
| 63 | if(tmp == NULL)return; |
| 64 | lttv_hooks_call(tmp,filter); |
| 65 | } |
| 66 | |
| 67 | |
| 68 | |
| 69 | /** |
| 70 | * API parts |
| 71 | */ |
| 72 | |
| 73 | /** |
| 74 | * Function to register a view constructor so that main window can generate |
| 75 | * a toolbar item for the viewer in order to generate a new instance easily. |
| 76 | * It will be called by init function of the module. |
| 77 | * @param ButtonPixmap image shown on the toolbar item. |
| 78 | * @param tooltip tooltip of the toolbar item. |
| 79 | * @param view_constructor constructor of the viewer. |
| 80 | */ |
| 81 | |
| 82 | void toolbar_item_reg(char ** pixmap, char *tooltip, lttv_constructor view_constructor) |
| 83 | { |
| 84 | LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes()); |
| 85 | LttvToolbars * toolbar; |
| 86 | LttvAttributeValue value; |
| 87 | |
| 88 | g_assert(lttv_iattribute_find_by_path(attributes_global, |
| 89 | "viewers/toolbar", LTTV_POINTER, &value)); |
| 90 | toolbar = (LttvToolbars*)*(value.v_pointer); |
| 91 | |
| 92 | if(toolbar == NULL){ |
| 93 | toolbar = lttv_toolbars_new(); |
| 94 | *(value.v_pointer) = toolbar; |
| 95 | } |
| 96 | lttv_toolbars_add(toolbar, view_constructor, tooltip, pixmap); |
| 97 | } |
| 98 | |
| 99 | |
| 100 | /** |
| 101 | * Function to unregister the viewer's constructor, release the space |
| 102 | * occupied by pixmap, tooltip and constructor of the viewer. |
| 103 | * It will be called when a module is unloaded. |
| 104 | * @param view_constructor constructor of the viewer which is used as |
| 105 | * a reference to find out where the pixmap and tooltip are. |
| 106 | */ |
| 107 | |
| 108 | void toolbar_item_unreg(lttv_constructor view_constructor) |
| 109 | { |
| 110 | LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes()); |
| 111 | LttvToolbars * toolbar; |
| 112 | LttvAttributeValue value; |
| 113 | |
| 114 | g_assert(lttv_iattribute_find_by_path(attributes_global, |
| 115 | "viewers/toolbar", LTTV_POINTER, &value)); |
| 116 | toolbar = (LttvToolbars*)*(value.v_pointer); |
| 117 | |
| 118 | main_window_remove_toolbar_item(view_constructor); |
| 119 | |
| 120 | lttv_toolbars_remove(toolbar, view_constructor); |
| 121 | } |
| 122 | |
| 123 | |
| 124 | /** |
| 125 | * Function to register a view constructor so that main window can generate |
| 126 | * a menu item for the viewer in order to generate a new instance easily. |
| 127 | * It will be called by init function of the module. |
| 128 | * @param menu_path path of the menu item. |
| 129 | * @param menu_text text of the menu item. |
| 130 | * @param view_constructor constructor of the viewer. |
| 131 | */ |
| 132 | |
| 133 | void menu_item_reg(char *menu_path, char *menu_text, lttv_constructor view_constructor) |
| 134 | { |
| 135 | LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes()); |
| 136 | LttvMenus * menu; |
| 137 | LttvAttributeValue value; |
| 138 | |
| 139 | g_assert(lttv_iattribute_find_by_path(attributes_global, |
| 140 | "viewers/menu", LTTV_POINTER, &value)); |
| 141 | menu = (LttvMenus*)*(value.v_pointer); |
| 142 | |
| 143 | if(menu == NULL){ |
| 144 | menu = lttv_menus_new(); |
| 145 | *(value.v_pointer) = menu; |
| 146 | } |
| 147 | lttv_menus_add(menu, view_constructor, menu_path, menu_text); |
| 148 | } |
| 149 | |
| 150 | /** |
| 151 | * Function to unregister the viewer's constructor, release the space |
| 152 | * occupied by menu_path, menu_text and constructor of the viewer. |
| 153 | * It will be called when a module is unloaded. |
| 154 | * @param view_constructor constructor of the viewer which is used as |
| 155 | * a reference to find out where the menu_path and menu_text are. |
| 156 | */ |
| 157 | |
| 158 | void menu_item_unreg(lttv_constructor view_constructor) |
| 159 | { |
| 160 | LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes()); |
| 161 | LttvMenus * menu; |
| 162 | LttvAttributeValue value; |
| 163 | |
| 164 | g_assert(lttv_iattribute_find_by_path(attributes_global, |
| 165 | "viewers/menu", LTTV_POINTER, &value)); |
| 166 | menu = (LttvMenus*)*(value.v_pointer); |
| 167 | |
| 168 | main_window_remove_menu_item(view_constructor); |
| 169 | |
| 170 | lttv_menus_remove(menu, view_constructor); |
| 171 | } |
| 172 | |
| 173 | |
| 174 | /** |
| 175 | * Update the status bar whenever something changed in the viewer. |
| 176 | * @param main_win the main window the viewer belongs to. |
| 177 | * @param info the message which will be shown in the status bar. |
| 178 | */ |
| 179 | |
| 180 | void update_status(MainWindow *main_win, char *info) |
| 181 | { |
| 182 | } |
| 183 | |
| 184 | |
| 185 | /** |
| 186 | * Function to get the current time interval shown on the current tab. |
| 187 | * It will be called by a viewer's hook function to update the |
| 188 | * shown time interval of the viewer and also be called by the constructor |
| 189 | * of the viewer. |
| 190 | * @param main_win the main window the viewer belongs to. |
| 191 | * @param time_interval a pointer where time interval will be stored. |
| 192 | */ |
| 193 | |
| 194 | void get_time_window(MainWindow *main_win, TimeWindow *time_window) |
| 195 | { |
| 196 | //time_window->start_time = main_win->current_tab->time_window.start_time; |
| 197 | //time_window->time_width = main_win->current_tab->time_window.time_width; |
| 198 | *time_window = main_win->current_tab->time_window; |
| 199 | } |
| 200 | |
| 201 | /** |
| 202 | * Function to get the current time interval of the current traceset. |
| 203 | * It will be called by a viewer's hook function to update the |
| 204 | * time interval of the viewer and also be called by the constructor |
| 205 | * of the viewer. |
| 206 | * @param main_win the main window the viewer belongs to. |
| 207 | * @param time_interval a pointer where time interval will be stored. |
| 208 | */ |
| 209 | |
| 210 | void get_traceset_time_span(MainWindow *main_win, TimeInterval *time_interval) |
| 211 | { |
| 212 | //time_window->start_time = main_win->current_tab->time_window.start_time; |
| 213 | //time_window->time_width = main_win->current_tab->time_window.time_width; |
| 214 | *time_interval = *(LTTV_TRACESET_CONTEXT(main_win->current_tab->traceset_info-> |
| 215 | traceset_context)->Time_Span); |
| 216 | } |
| 217 | |
| 218 | |
| 219 | |
| 220 | /** |
| 221 | * Function to set the time interval of the current tab. |
| 222 | * It will be called by a viewer's signal handle associated with |
| 223 | * the move_slider signal |
| 224 | * @param main_win the main window the viewer belongs to. |
| 225 | * @param time_interval a pointer where time interval is stored. |
| 226 | */ |
| 227 | |
| 228 | void set_time_window(MainWindow *main_win, TimeWindow *time_window) |
| 229 | { |
| 230 | LttvAttributeValue value; |
| 231 | LttvHooks * tmp; |
| 232 | main_win->current_tab->time_window = *time_window; |
| 233 | gtk_multi_vpaned_set_scroll_value(main_win->current_tab->multi_vpaned, |
| 234 | ltt_time_to_double(time_window->start_time) |
| 235 | * NANOSECONDS_PER_SECOND ); |
| 236 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
| 237 | "hooks/updatetimewindow", LTTV_POINTER, &value)); |
| 238 | tmp = (LttvHooks*)*(value.v_pointer); |
| 239 | if(tmp == NULL) return; |
| 240 | lttv_hooks_call(tmp, time_window); |
| 241 | } |
| 242 | |
| 243 | |
| 244 | /** |
| 245 | * Function to get the current time/event of the current tab. |
| 246 | * It will be called by a viewer's hook function to update the |
| 247 | * current time/event of the viewer. |
| 248 | * @param main_win the main window the viewer belongs to. |
| 249 | * @param time a pointer where time will be stored. |
| 250 | */ |
| 251 | |
| 252 | void get_current_time(MainWindow *main_win, LttTime *time) |
| 253 | { |
| 254 | time = &main_win->current_tab->current_time; |
| 255 | } |
| 256 | |
| 257 | |
| 258 | /** |
| 259 | * Function to set the current time/event of the current tab. |
| 260 | * It will be called by a viewer's signal handle associated with |
| 261 | * the button-release-event signal |
| 262 | * @param main_win the main window the viewer belongs to. |
| 263 | * @param time a pointer where time is stored. |
| 264 | */ |
| 265 | |
| 266 | void set_current_time(MainWindow *main_win, LttTime *time) |
| 267 | { |
| 268 | LttvAttributeValue value; |
| 269 | LttvHooks * tmp; |
| 270 | main_win->current_tab->current_time = *time; |
| 271 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
| 272 | "hooks/updatecurrenttime", LTTV_POINTER, &value)); |
| 273 | tmp = (LttvHooks*)*(value.v_pointer); |
| 274 | |
| 275 | if(tmp == NULL)return; |
| 276 | lttv_hooks_call(tmp, time); |
| 277 | } |
| 278 | |
| 279 | |
| 280 | /** |
| 281 | * Function to get the traceset from the current tab. |
| 282 | * It will be called by the constructor of the viewer and also be |
| 283 | * called by a hook funtion of the viewer to update its traceset. |
| 284 | * @param main_win the main window the viewer belongs to. |
| 285 | * @param traceset a pointer to a traceset. |
| 286 | */ |
| 287 | /* |
| 288 | void get_traceset(MainWindow *main_win, Traceset *traceset) |
| 289 | { |
| 290 | } |
| 291 | */ |
| 292 | |
| 293 | /** |
| 294 | * Function to get the filter of the current tab. |
| 295 | * It will be called by the constructor of the viewer and also be |
| 296 | * called by a hook funtion of the viewer to update its filter. |
| 297 | * @param main_win, the main window the viewer belongs to. |
| 298 | * @param filter, a pointer to a filter. |
| 299 | */ |
| 300 | /* |
| 301 | void get_filter(MainWindow *main_win, Filter *filter) |
| 302 | { |
| 303 | } |
| 304 | */ |
| 305 | |
| 306 | /** |
| 307 | * Function to register a hook function for a viewer to set/update its |
| 308 | * time interval. |
| 309 | * It will be called by the constructor of the viewer. |
| 310 | * @param hook hook function of the viewer. |
| 311 | * @param hook_data hook data associated with the hook function. |
| 312 | * @param main_win the main window the viewer belongs to. |
| 313 | */ |
| 314 | |
| 315 | void reg_update_time_window(LttvHook hook, gpointer hook_data, |
| 316 | MainWindow * main_win) |
| 317 | { |
| 318 | LttvAttributeValue value; |
| 319 | LttvHooks * tmp; |
| 320 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
| 321 | "hooks/updatetimewindow", LTTV_POINTER, &value)); |
| 322 | tmp = (LttvHooks*)*(value.v_pointer); |
| 323 | if(tmp == NULL){ |
| 324 | tmp = lttv_hooks_new(); |
| 325 | *(value.v_pointer) = tmp; |
| 326 | } |
| 327 | lttv_hooks_add(tmp, hook,hook_data); |
| 328 | } |
| 329 | |
| 330 | |
| 331 | /** |
| 332 | * Function to unregister a viewer's hook function which is used to |
| 333 | * set/update the time interval of the viewer. |
| 334 | * It will be called by the destructor of the viewer. |
| 335 | * @param hook hook function of the viewer. |
| 336 | * @param hook_data hook data associated with the hook function. |
| 337 | * @param main_win the main window the viewer belongs to. |
| 338 | */ |
| 339 | |
| 340 | void unreg_update_time_window(LttvHook hook, gpointer hook_data, |
| 341 | MainWindow * main_win) |
| 342 | { |
| 343 | LttvAttributeValue value; |
| 344 | LttvHooks * tmp; |
| 345 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
| 346 | "hooks/updatetimewindow", LTTV_POINTER, &value)); |
| 347 | tmp = (LttvHooks*)*(value.v_pointer); |
| 348 | if(tmp == NULL) return; |
| 349 | lttv_hooks_remove_data(tmp, hook, hook_data); |
| 350 | } |
| 351 | |
| 352 | |
| 353 | /** |
| 354 | * Function to register a hook function for a viewer to set/update its |
| 355 | * traceset. |
| 356 | * It will be called by the constructor of the viewer. |
| 357 | * @param hook hook function of the viewer. |
| 358 | * @param hook_data hook data associated with the hook function. |
| 359 | * @param main_win the main window the viewer belongs to. |
| 360 | */ |
| 361 | |
| 362 | void reg_update_traceset(LttvHook hook, gpointer hook_data, |
| 363 | MainWindow * main_win) |
| 364 | { |
| 365 | LttvAttributeValue value; |
| 366 | LttvHooks * tmp; |
| 367 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
| 368 | "hooks/updatetraceset", LTTV_POINTER, &value)); |
| 369 | tmp = (LttvHooks*)*(value.v_pointer); |
| 370 | if(tmp == NULL){ |
| 371 | tmp = lttv_hooks_new(); |
| 372 | *(value.v_pointer) = tmp; |
| 373 | } |
| 374 | lttv_hooks_add(tmp, hook, hook_data); |
| 375 | } |
| 376 | |
| 377 | |
| 378 | /** |
| 379 | * Function to unregister a viewer's hook function which is used to |
| 380 | * set/update the traceset of the viewer. |
| 381 | * It will be called by the destructor of the viewer. |
| 382 | * @param hook hook function of the viewer. |
| 383 | * @param hook_data hook data associated with the hook function. |
| 384 | * @param main_win the main window the viewer belongs to. |
| 385 | */ |
| 386 | |
| 387 | void unreg_update_traceset(LttvHook hook, gpointer hook_data, |
| 388 | MainWindow * main_win) |
| 389 | { |
| 390 | LttvAttributeValue value; |
| 391 | LttvHooks * tmp; |
| 392 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
| 393 | "hooks/updatetraceset", LTTV_POINTER, &value)); |
| 394 | tmp = (LttvHooks*)*(value.v_pointer); |
| 395 | if(tmp == NULL) return; |
| 396 | lttv_hooks_remove_data(tmp, hook, hook_data); |
| 397 | } |
| 398 | |
| 399 | |
| 400 | /** |
| 401 | * Function to redraw each viewer belonging to the current tab |
| 402 | * @param main_win the main window the viewer belongs to. |
| 403 | */ |
| 404 | |
| 405 | void update_traceset(MainWindow * main_win) |
| 406 | { |
| 407 | LttvAttributeValue value; |
| 408 | LttvHooks * tmp; |
| 409 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
| 410 | "hooks/updatetraceset", LTTV_POINTER, &value)); |
| 411 | tmp = (LttvHooks*)*(value.v_pointer); |
| 412 | if(tmp == NULL) return; |
| 413 | lttv_hooks_call(tmp, NULL); |
| 414 | } |
| 415 | |
| 416 | |
| 417 | /** |
| 418 | * Function to register a hook function for a viewer to set/update its |
| 419 | * filter. |
| 420 | * It will be called by the constructor of the viewer. |
| 421 | * @param hook hook function of the viewer. |
| 422 | * @param hook_data hook data associated with the hook function. |
| 423 | * @param main_win the main window the viewer belongs to. |
| 424 | */ |
| 425 | |
| 426 | void reg_update_filter(LttvHook hook, gpointer hook_data, |
| 427 | MainWindow *main_win) |
| 428 | { |
| 429 | LttvAttributeValue value; |
| 430 | LttvHooks * tmp; |
| 431 | g_assert(lttv_iattribute_find_by_path(main_win->attributes, |
| 432 | "hooks/updatefilter", LTTV_POINTER, &value)); |
| 433 | tmp = (LttvHooks*)*(value.v_pointer); |
| 434 | if(tmp == NULL){ |
| 435 | tmp = lttv_hooks_new(); |
| 436 | *(value.v_pointer) = tmp; |
| 437 | } |
| 438 | lttv_hooks_add(tmp, hook, hook_data); |
| 439 | } |
| 440 | |
| 441 | |
| 442 | /** |
| 443 | * Function to unregister a viewer's hook function which is used to |
| 444 | * set/update the filter of the viewer. |
| 445 | * It will be called by the destructor of the viewer. |
| 446 | * @param hook hook function of the viewer. |
| 447 | * @param hook_data hook data associated with the hook function. |
| 448 | * @param main_win the main window the viewer belongs to. |
| 449 | */ |
| 450 | |
| 451 | void unreg_update_filter(LttvHook hook, gpointer hook_data, |
| 452 | MainWindow * main_win) |
| 453 | { |
| 454 | LttvAttributeValue value; |
| 455 | LttvHooks * tmp; |
| 456 | g_assert(lttv_iattribute_find_by_path(main_win->attributes, |
| 457 | "hooks/updatefilter", LTTV_POINTER, &value)); |
| 458 | tmp = (LttvHooks*)*(value.v_pointer); |
| 459 | if(tmp == NULL) return; |
| 460 | lttv_hooks_remove_data(tmp, hook, hook_data); |
| 461 | } |
| 462 | |
| 463 | |
| 464 | /** |
| 465 | * Function to register a hook function for a viewer to set/update its |
| 466 | * current time. |
| 467 | * It will be called by the constructor of the viewer. |
| 468 | * @param hook hook function of the viewer. |
| 469 | * @param hook_data hook data associated with the hook function. |
| 470 | * @param main_win the main window the viewer belongs to. |
| 471 | */ |
| 472 | |
| 473 | void reg_update_current_time(LttvHook hook, gpointer hook_data, |
| 474 | MainWindow *main_win) |
| 475 | { |
| 476 | LttvAttributeValue value; |
| 477 | LttvHooks * tmp; |
| 478 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
| 479 | "hooks/updatecurrenttime", LTTV_POINTER, &value)); |
| 480 | tmp = (LttvHooks*)*(value.v_pointer); |
| 481 | if(tmp == NULL){ |
| 482 | tmp = lttv_hooks_new(); |
| 483 | *(value.v_pointer) = tmp; |
| 484 | } |
| 485 | lttv_hooks_add(tmp, hook, hook_data); |
| 486 | } |
| 487 | |
| 488 | |
| 489 | /** |
| 490 | * Function to unregister a viewer's hook function which is used to |
| 491 | * set/update the current time of the viewer. |
| 492 | * It will be called by the destructor of the viewer. |
| 493 | * @param hook hook function of the viewer. |
| 494 | * @param hook_data hook data associated with the hook function. |
| 495 | * @param main_win the main window the viewer belongs to. |
| 496 | */ |
| 497 | |
| 498 | void unreg_update_current_time(LttvHook hook, gpointer hook_data, |
| 499 | MainWindow * main_win) |
| 500 | { |
| 501 | LttvAttributeValue value; |
| 502 | LttvHooks * tmp; |
| 503 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
| 504 | "hooks/updatecurrenttime", LTTV_POINTER, &value)); |
| 505 | tmp = (LttvHooks*)*(value.v_pointer); |
| 506 | if(tmp == NULL) return; |
| 507 | lttv_hooks_remove_data(tmp, hook, hook_data); |
| 508 | } |
| 509 | |
| 510 | |
| 511 | /** |
| 512 | * Function to register a hook function for a viewer to show |
| 513 | *the content of the viewer. |
| 514 | * It will be called by the constructor of the viewer. |
| 515 | * @param hook hook function of the viewer. |
| 516 | * @param hook_data hook data associated with the hook function. |
| 517 | * @param main_win the main window the viewer belongs to. |
| 518 | */ |
| 519 | |
| 520 | void reg_show_viewer(LttvHook hook, gpointer hook_data, |
| 521 | MainWindow *main_win) |
| 522 | { |
| 523 | LttvAttributeValue value; |
| 524 | LttvHooks * tmp; |
| 525 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
| 526 | "hooks/showviewer", LTTV_POINTER, &value)); |
| 527 | tmp = (LttvHooks*)*(value.v_pointer); |
| 528 | if(tmp == NULL){ |
| 529 | tmp = lttv_hooks_new(); |
| 530 | *(value.v_pointer) = tmp; |
| 531 | } |
| 532 | lttv_hooks_add(tmp, hook, hook_data); |
| 533 | } |
| 534 | |
| 535 | |
| 536 | /** |
| 537 | * Function to unregister a viewer's hook function which is used to |
| 538 | * show the content of the viewer.. |
| 539 | * It will be called by the destructor of the viewer. |
| 540 | * @param hook hook function of the viewer. |
| 541 | * @param hook_data hook data associated with the hook function. |
| 542 | * @param main_win the main window the viewer belongs to. |
| 543 | */ |
| 544 | |
| 545 | void unreg_show_viewer(LttvHook hook, gpointer hook_data, |
| 546 | MainWindow * main_win) |
| 547 | { |
| 548 | LttvAttributeValue value; |
| 549 | LttvHooks * tmp; |
| 550 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
| 551 | "hooks/showviewer", LTTV_POINTER, &value)); |
| 552 | tmp = (LttvHooks*)*(value.v_pointer); |
| 553 | if(tmp == NULL) return; |
| 554 | lttv_hooks_remove_data(tmp, hook, hook_data); |
| 555 | } |
| 556 | |
| 557 | |
| 558 | /** |
| 559 | * Function to show each viewer in the current tab. |
| 560 | * It will be called by main window after it called process_traceset |
| 561 | * @param main_win the main window the viewer belongs to. |
| 562 | */ |
| 563 | |
| 564 | void show_viewer(MainWindow *main_win) |
| 565 | { |
| 566 | LttvAttributeValue value; |
| 567 | LttvHooks * tmp; |
| 568 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
| 569 | "hooks/showviewer", LTTV_POINTER, &value)); |
| 570 | tmp = (LttvHooks*)*(value.v_pointer); |
| 571 | if(tmp == NULL) return; |
| 572 | lttv_hooks_call(tmp, NULL); |
| 573 | } |
| 574 | |
| 575 | |
| 576 | /** |
| 577 | * Function to set the focused pane (viewer). |
| 578 | * It will be called by a viewer's signal handle associated with |
| 579 | * the grab_focus signal |
| 580 | * @param main_win the main window the viewer belongs to. |
| 581 | * @param paned a pointer to a pane where the viewer is contained. |
| 582 | */ |
| 583 | |
| 584 | void set_focused_pane(MainWindow *main_win, gpointer paned) |
| 585 | { |
| 586 | gtk_multi_vpaned_set_focus((GtkWidget*)main_win->current_tab->multi_vpaned,paned); |
| 587 | } |
| 588 | |
| 589 | |
| 590 | /** |
| 591 | * Function to register a hook function for a viewer to set/update the |
| 592 | * dividor of the hpane. |
| 593 | * It will be called by the constructor of the viewer. |
| 594 | * @param hook hook function of the viewer. |
| 595 | * @param hook_data hook data associated with the hook function. |
| 596 | * @param main_win the main window the viewer belongs to. |
| 597 | */ |
| 598 | |
| 599 | void reg_update_dividor(LttvHook hook, gpointer hook_data, |
| 600 | MainWindow *main_win) |
| 601 | { |
| 602 | LttvAttributeValue value; |
| 603 | LttvHooks * tmp; |
| 604 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
| 605 | "hooks/hpanedividor", LTTV_POINTER, &value)); |
| 606 | tmp = (LttvHooks*)*(value.v_pointer); |
| 607 | if(tmp == NULL){ |
| 608 | tmp = lttv_hooks_new(); |
| 609 | *(value.v_pointer) = tmp; |
| 610 | } |
| 611 | lttv_hooks_add(tmp, hook, hook_data); |
| 612 | } |
| 613 | |
| 614 | |
| 615 | /** |
| 616 | * Function to unregister a viewer's hook function which is used to |
| 617 | * set/update hpane's dividor of the viewer. |
| 618 | * It will be called by the destructor of the viewer. |
| 619 | * @param hook hook function of the viewer. |
| 620 | * @param hook_data hook data associated with the hook function. |
| 621 | * @param main_win the main window the viewer belongs to. |
| 622 | */ |
| 623 | |
| 624 | void unreg_update_dividor(LttvHook hook, gpointer hook_data, |
| 625 | MainWindow *main_win) |
| 626 | { |
| 627 | LttvAttributeValue value; |
| 628 | LttvHooks * tmp; |
| 629 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
| 630 | "hooks/hpanedividor", LTTV_POINTER, &value)); |
| 631 | tmp = (LttvHooks*)*(value.v_pointer); |
| 632 | if(tmp == NULL) return; |
| 633 | lttv_hooks_remove_data(tmp, hook, hook_data); |
| 634 | } |
| 635 | |
| 636 | |
| 637 | /** |
| 638 | * Function to set the position of the hpane's dividor (viewer). |
| 639 | * It will be called by a viewer's signal handle associated with |
| 640 | * the motion_notify_event event/signal |
| 641 | * @param main_win the main window the viewer belongs to. |
| 642 | * @param position position of the hpane's dividor. |
| 643 | */ |
| 644 | |
| 645 | void set_hpane_dividor(MainWindow *main_win, gint position) |
| 646 | { |
| 647 | LttvAttributeValue value; |
| 648 | LttvHooks * tmp; |
| 649 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
| 650 | "hooks/hpanedividor", LTTV_POINTER, &value)); |
| 651 | tmp = (LttvHooks*)*(value.v_pointer); |
| 652 | if(tmp == NULL) return; |
| 653 | lttv_hooks_call(tmp, &position); |
| 654 | } |
| 655 | |
| 656 | |
| 657 | /** |
| 658 | * Function to process traceset. It will call lttv_process_trace, |
| 659 | * each view will call this api to get events. |
| 660 | * @param main_win the main window the viewer belongs to. |
| 661 | * @param start the start time of the first event to be processed. |
| 662 | * @param end the end time of the last event to be processed. |
| 663 | */ |
| 664 | |
| 665 | void process_traceset_api(MainWindow *main_win, LttTime start, |
| 666 | LttTime end, unsigned maxNumEvents) |
| 667 | { |
| 668 | lttv_process_traceset_seek_time( |
| 669 | LTTV_TRACESET_CONTEXT(main_win->current_tab->traceset_info-> |
| 670 | traceset_context), |
| 671 | start); |
| 672 | lttv_process_traceset( |
| 673 | LTTV_TRACESET_CONTEXT(main_win->current_tab->traceset_info-> |
| 674 | traceset_context), |
| 675 | end, |
| 676 | maxNumEvents); |
| 677 | } |
| 678 | |
| 679 | /** |
| 680 | * Function to add hooks into the context of a traceset, |
| 681 | * before reading events from traceset, viewer will call this api to |
| 682 | * register hooks |
| 683 | * @param main_win the main window the viewer belongs to. |
| 684 | * @param LttvHooks hooks to be registered. |
| 685 | */ |
| 686 | |
| 687 | void context_add_hooks_api(MainWindow *main_win , |
| 688 | LttvHooks *before_traceset, |
| 689 | LttvHooks *after_traceset, |
| 690 | LttvHooks *check_trace, |
| 691 | LttvHooks *before_trace, |
| 692 | LttvHooks *after_trace, |
| 693 | LttvHooks *check_tracefile, |
| 694 | LttvHooks *before_tracefile, |
| 695 | LttvHooks *after_tracefile, |
| 696 | LttvHooks *check_event, |
| 697 | LttvHooks *before_event, |
| 698 | LttvHooks *after_event) |
| 699 | { |
| 700 | LttvTracesetContext * tsc = |
| 701 | LTTV_TRACESET_CONTEXT(main_win->current_tab->traceset_info-> |
| 702 | traceset_context); |
| 703 | lttv_traceset_context_add_hooks(tsc,before_traceset,after_traceset, |
| 704 | check_trace,before_trace,after_trace, |
| 705 | check_tracefile,before_tracefile,after_tracefile, |
| 706 | check_event,before_event, after_event); |
| 707 | } |
| 708 | |
| 709 | |
| 710 | /** |
| 711 | * Function to remove hooks from the context of a traceset, |
| 712 | * before reading events from traceset, viewer will call this api to |
| 713 | * unregister hooks |
| 714 | * @param main_win the main window the viewer belongs to. |
| 715 | * @param LttvHooks hooks to be registered. |
| 716 | */ |
| 717 | |
| 718 | void context_remove_hooks_api(MainWindow *main_win , |
| 719 | LttvHooks *before_traceset, |
| 720 | LttvHooks *after_traceset, |
| 721 | LttvHooks *check_trace, |
| 722 | LttvHooks *before_trace, |
| 723 | LttvHooks *after_trace, |
| 724 | LttvHooks *check_tracefile, |
| 725 | LttvHooks *before_tracefile, |
| 726 | LttvHooks *after_tracefile, |
| 727 | LttvHooks *check_event, |
| 728 | LttvHooks *before_event, |
| 729 | LttvHooks *after_event) |
| 730 | { |
| 731 | LttvTracesetContext * tsc = |
| 732 | LTTV_TRACESET_CONTEXT(main_win->current_tab->traceset_info->traceset_context); |
| 733 | lttv_traceset_context_remove_hooks(tsc,before_traceset,after_traceset, |
| 734 | check_trace,before_trace,after_trace, |
| 735 | check_tracefile,before_tracefile,after_tracefile, |
| 736 | check_event,before_event, after_event); |
| 737 | } |
| 738 | |
| 739 | |
| 740 | /** |
| 741 | * Function to add/remove event hooks for state |
| 742 | * @param main_win the main window the viewer belongs to. |
| 743 | */ |
| 744 | |
| 745 | void state_add_event_hooks_api(MainWindow *main_win ) |
| 746 | { |
| 747 | lttv_state_add_event_hooks( |
| 748 | (LttvTracesetState*)main_win->current_tab->traceset_info->traceset_context); |
| 749 | } |
| 750 | |
| 751 | void state_remove_event_hooks_api(MainWindow *main_win ) |
| 752 | { |
| 753 | lttv_state_remove_event_hooks( |
| 754 | (LttvTracesetState*)main_win->current_tab->traceset_info->traceset_context); |
| 755 | } |
| 756 | |
| 757 | |
| 758 | /** |
| 759 | * Function to add/remove event hooks for stats |
| 760 | * @param main_win the main window the viewer belongs to. |
| 761 | */ |
| 762 | |
| 763 | void stats_add_event_hooks_api(MainWindow *main_win ) |
| 764 | { |
| 765 | lttv_stats_add_event_hooks( |
| 766 | (LttvTracesetStats*)main_win->current_tab->traceset_info->traceset_context); |
| 767 | } |
| 768 | |
| 769 | void stats_remove_event_hooks_api(MainWindow *main_win ) |
| 770 | { |
| 771 | lttv_stats_remove_event_hooks( |
| 772 | (LttvTracesetStats*)main_win->current_tab->traceset_info->traceset_context); |
| 773 | } |
| 774 | |
| 775 | /** |
| 776 | * Function to get the stats of the traceset |
| 777 | * @param main_win the main window the viewer belongs to. |
| 778 | */ |
| 779 | |
| 780 | LttvTracesetStats* get_traceset_stats_api(MainWindow *main_win) |
| 781 | { |
| 782 | return main_win->current_tab->traceset_info->traceset_context; |
| 783 | } |
| 784 | |
| 785 | |
| 786 | LttvTracesetContext* get_traceset_context(MainWindow *main_win) |
| 787 | { |
| 788 | return (LttvTracesetContext*)main_win->current_tab->traceset_info->traceset_context; |
| 789 | } |