| 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 remove toolbar from the GUI |
| 31 | * @param view_constructor constructor of the viewer. |
| 32 | */ |
| 33 | |
| 34 | void RemoveToolbar(lttv_constructor view_constructor) |
| 35 | { |
| 36 | g_printf("Toolbar for the viewer will be removed\n"); |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Function to remove menu entry from the GUI |
| 41 | * @param view_constructor constructor of the viewer. |
| 42 | */ |
| 43 | |
| 44 | void RemoveMenu(lttv_constructor view_constructor) |
| 45 | { |
| 46 | g_printf("Menu entry for the viewer will be removed\n"); |
| 47 | } |
| 48 | |
| 49 | |
| 50 | /** |
| 51 | * Function to set/update traceset for the viewers |
| 52 | * @param main_win main window |
| 53 | * @param traceset traceset of the main window. |
| 54 | */ |
| 55 | |
| 56 | void SetTraceset(mainWindow * main_win, gpointer traceset) |
| 57 | { |
| 58 | LttvHooks * tmp; |
| 59 | LttvAttributeValue value; |
| 60 | |
| 61 | g_assert(lttv_iattribute_find_by_path(main_win->Attributes, |
| 62 | "hooks/updatetraceset", LTTV_POINTER, &value)); |
| 63 | tmp = (LttvHooks*)*(value.v_pointer); |
| 64 | if(tmp == NULL)return; |
| 65 | lttv_hooks_call(tmp,traceset); |
| 66 | } |
| 67 | |
| 68 | |
| 69 | /** |
| 70 | * Function to set/update filter for the viewers |
| 71 | * @param main_win main window |
| 72 | * @param filter filter of the main window. |
| 73 | */ |
| 74 | |
| 75 | void SetFilter(mainWindow * main_win, gpointer filter) |
| 76 | { |
| 77 | LttvHooks * tmp; |
| 78 | LttvAttributeValue value; |
| 79 | |
| 80 | g_assert(lttv_iattribute_find_by_path(main_win->Attributes, |
| 81 | "hooks/updatefilter", LTTV_POINTER, &value)); |
| 82 | tmp = (LttvHooks*)*(value.v_pointer); |
| 83 | |
| 84 | if(tmp == NULL)return; |
| 85 | lttv_hooks_call(tmp,filter); |
| 86 | } |
| 87 | |
| 88 | |
| 89 | |
| 90 | /** |
| 91 | * API parts |
| 92 | */ |
| 93 | |
| 94 | /** |
| 95 | * Function to register a view constructor so that main window can generate |
| 96 | * a toolbar item for the viewer in order to generate a new instance easily. |
| 97 | * It will be called by init function of the module. |
| 98 | * @param ButtonPixmap image shown on the toolbar item. |
| 99 | * @param tooltip tooltip of the toolbar item. |
| 100 | * @param view_constructor constructor of the viewer. |
| 101 | */ |
| 102 | |
| 103 | void ToolbarItemReg(char ** pixmap, char *tooltip, lttv_constructor view_constructor) |
| 104 | { |
| 105 | LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes()); |
| 106 | LttvToolbars * toolbar; |
| 107 | LttvAttributeValue value; |
| 108 | |
| 109 | g_assert(lttv_iattribute_find_by_path(attributes_global, |
| 110 | "viewers/toolbar", LTTV_POINTER, &value)); |
| 111 | toolbar = (LttvToolbars*)*(value.v_pointer); |
| 112 | |
| 113 | if(toolbar == NULL){ |
| 114 | toolbar = lttv_toolbars_new(); |
| 115 | *(value.v_pointer) = toolbar; |
| 116 | } |
| 117 | lttv_toolbars_add(toolbar, view_constructor, tooltip, pixmap); |
| 118 | } |
| 119 | |
| 120 | |
| 121 | /** |
| 122 | * Function to unregister the viewer's constructor, release the space |
| 123 | * occupied by pixmap, tooltip and constructor of the viewer. |
| 124 | * It will be called when a module is unloaded. |
| 125 | * @param view_constructor constructor of the viewer which is used as |
| 126 | * a reference to find out where the pixmap and tooltip are. |
| 127 | */ |
| 128 | |
| 129 | void ToolbarItemUnreg(lttv_constructor view_constructor) |
| 130 | { |
| 131 | LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes()); |
| 132 | LttvToolbars * toolbar; |
| 133 | LttvAttributeValue value; |
| 134 | |
| 135 | g_assert(lttv_iattribute_find_by_path(attributes_global, |
| 136 | "viewers/toolbar", LTTV_POINTER, &value)); |
| 137 | toolbar = (LttvToolbars*)*(value.v_pointer); |
| 138 | |
| 139 | if(lttv_toolbars_remove(toolbar, view_constructor)) |
| 140 | RemoveToolbar(view_constructor); |
| 141 | } |
| 142 | |
| 143 | |
| 144 | /** |
| 145 | * Function to register a view constructor so that main window can generate |
| 146 | * a menu item for the viewer in order to generate a new instance easily. |
| 147 | * It will be called by init function of the module. |
| 148 | * @param menu_path path of the menu item. |
| 149 | * @param menu_text text of the menu item. |
| 150 | * @param view_constructor constructor of the viewer. |
| 151 | */ |
| 152 | |
| 153 | void MenuItemReg(char *menu_path, char *menu_text, lttv_constructor view_constructor) |
| 154 | { |
| 155 | LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes()); |
| 156 | LttvMenus * menu; |
| 157 | LttvAttributeValue value; |
| 158 | |
| 159 | g_assert(lttv_iattribute_find_by_path(attributes_global, |
| 160 | "viewers/menu", LTTV_POINTER, &value)); |
| 161 | menu = (LttvMenus*)*(value.v_pointer); |
| 162 | |
| 163 | if(menu == NULL){ |
| 164 | menu = lttv_menus_new(); |
| 165 | *(value.v_pointer) = menu; |
| 166 | } |
| 167 | lttv_menus_add(menu, view_constructor, menu_path, menu_text); |
| 168 | } |
| 169 | |
| 170 | /** |
| 171 | * Function to unregister the viewer's constructor, release the space |
| 172 | * occupied by menu_path, menu_text and constructor of the viewer. |
| 173 | * It will be called when a module is unloaded. |
| 174 | * @param view_constructor constructor of the viewer which is used as |
| 175 | * a reference to find out where the menu_path and menu_text are. |
| 176 | */ |
| 177 | |
| 178 | void MenuItemUnreg(lttv_constructor view_constructor) |
| 179 | { |
| 180 | LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes()); |
| 181 | LttvMenus * menu; |
| 182 | LttvAttributeValue value; |
| 183 | |
| 184 | g_assert(lttv_iattribute_find_by_path(attributes_global, |
| 185 | "viewers/menu", LTTV_POINTER, &value)); |
| 186 | menu = (LttvMenus*)*(value.v_pointer); |
| 187 | |
| 188 | if(lttv_menus_remove(menu, view_constructor)) |
| 189 | RemoveMenu(view_constructor); |
| 190 | } |
| 191 | |
| 192 | |
| 193 | /** |
| 194 | * Update the status bar whenever something changed in the viewer. |
| 195 | * @param main_win the main window the viewer belongs to. |
| 196 | * @param info the message which will be shown in the status bar. |
| 197 | */ |
| 198 | |
| 199 | void UpdateStatus(mainWindow *main_win, char *info) |
| 200 | { |
| 201 | } |
| 202 | |
| 203 | |
| 204 | /** |
| 205 | * Function to get the current time interval shown on the current tab. |
| 206 | * It will be called by a viewer's hook function to update the |
| 207 | * shown time interval of the viewer and also be called by the constructor |
| 208 | * of the viewer. |
| 209 | * @param main_win the main window the viewer belongs to. |
| 210 | * @param time_interval a pointer where time interval will be stored. |
| 211 | */ |
| 212 | |
| 213 | void GetTimeWindow(mainWindow *main_win, TimeWindow *Time_Window) |
| 214 | { |
| 215 | //Time_Window->startTime = main_win->CurrentTab->Time_Window.startTime; |
| 216 | //Time_Window->Time_Width = main_win->CurrentTab->Time_Window.Time_Width; |
| 217 | *Time_Window = main_win->CurrentTab->Time_Window; |
| 218 | } |
| 219 | |
| 220 | /** |
| 221 | * Function to get the current time interval of the current traceset. |
| 222 | * It will be called by a viewer's hook function to update the |
| 223 | * time interval of the viewer and also be called by the constructor |
| 224 | * of the viewer. |
| 225 | * @param main_win the main window the viewer belongs to. |
| 226 | * @param time_interval a pointer where time interval will be stored. |
| 227 | */ |
| 228 | |
| 229 | void getTracesetTimeSpan(mainWindow *main_win, TimeInterval *Time_Interval) |
| 230 | { |
| 231 | //Time_Window->startTime = main_win->CurrentTab->Time_Window.startTime; |
| 232 | //Time_Window->Time_Width = main_win->CurrentTab->Time_Window.Time_Width; |
| 233 | *Time_Interval = *(LTTV_TRACESET_CONTEXT(main_win->Traceset_Info->TracesetContext)->Time_Span); |
| 234 | } |
| 235 | |
| 236 | |
| 237 | |
| 238 | /** |
| 239 | * Function to set the time interval of the current tab. |
| 240 | * It will be called by a viewer's signal handle associated with |
| 241 | * the move_slider signal |
| 242 | * @param main_win the main window the viewer belongs to. |
| 243 | * @param time_interval a pointer where time interval is stored. |
| 244 | */ |
| 245 | |
| 246 | void SetTimeWindow(mainWindow *main_win, TimeWindow *Time_Window) |
| 247 | { |
| 248 | LttvAttributeValue value; |
| 249 | LttvHooks * tmp; |
| 250 | main_win->CurrentTab->Time_Window = *Time_Window; |
| 251 | g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes, |
| 252 | "hooks/updatetimewindow", LTTV_POINTER, &value)); |
| 253 | tmp = (LttvHooks*)*(value.v_pointer); |
| 254 | if(tmp == NULL) return; |
| 255 | lttv_hooks_call(tmp, Time_Window); |
| 256 | } |
| 257 | |
| 258 | |
| 259 | /** |
| 260 | * Function to get the current time/event of the current tab. |
| 261 | * It will be called by a viewer's hook function to update the |
| 262 | * current time/event of the viewer. |
| 263 | * @param main_win the main window the viewer belongs to. |
| 264 | * @param time a pointer where time will be stored. |
| 265 | */ |
| 266 | |
| 267 | void GetCurrentTime(mainWindow *main_win, LttTime *time) |
| 268 | { |
| 269 | time = &main_win->CurrentTab->currentTime; |
| 270 | } |
| 271 | |
| 272 | |
| 273 | /** |
| 274 | * Function to set the current time/event of the current tab. |
| 275 | * It will be called by a viewer's signal handle associated with |
| 276 | * the button-release-event signal |
| 277 | * @param main_win the main window the viewer belongs to. |
| 278 | * @param time a pointer where time is stored. |
| 279 | */ |
| 280 | |
| 281 | void SetCurrentTime(mainWindow *main_win, LttTime *time) |
| 282 | { |
| 283 | LttvAttributeValue value; |
| 284 | LttvHooks * tmp; |
| 285 | main_win->CurrentTab->currentTime = *time; |
| 286 | g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes, |
| 287 | "hooks/updatecurrenttime", LTTV_POINTER, &value)); |
| 288 | tmp = (LttvHooks*)*(value.v_pointer); |
| 289 | |
| 290 | if(tmp == NULL)return; |
| 291 | lttv_hooks_call(tmp, time); |
| 292 | } |
| 293 | |
| 294 | |
| 295 | /** |
| 296 | * Function to get the traceset from the current tab. |
| 297 | * It will be called by the constructor of the viewer and also be |
| 298 | * called by a hook funtion of the viewer to update its traceset. |
| 299 | * @param main_win the main window the viewer belongs to. |
| 300 | * @param traceset a pointer to a traceset. |
| 301 | */ |
| 302 | /* |
| 303 | void GetTraceset(mainWindow *main_win, Traceset *traceset) |
| 304 | { |
| 305 | } |
| 306 | */ |
| 307 | |
| 308 | /** |
| 309 | * Function to get the filter of the current tab. |
| 310 | * It will be called by the constructor of the viewer and also be |
| 311 | * called by a hook funtion of the viewer to update its filter. |
| 312 | * @param main_win, the main window the viewer belongs to. |
| 313 | * @param filter, a pointer to a filter. |
| 314 | */ |
| 315 | /* |
| 316 | void GetFilter(mainWindow *main_win, Filter *filter) |
| 317 | { |
| 318 | } |
| 319 | */ |
| 320 | |
| 321 | /** |
| 322 | * Function to register a hook function for a viewer to set/update its |
| 323 | * time interval. |
| 324 | * It will be called by the constructor of the viewer. |
| 325 | * @param hook hook function of the viewer. |
| 326 | * @param hook_data hook data associated with the hook function. |
| 327 | * @param main_win the main window the viewer belongs to. |
| 328 | */ |
| 329 | |
| 330 | void RegUpdateTimeWindow(LttvHook hook, gpointer hook_data, |
| 331 | mainWindow * main_win) |
| 332 | { |
| 333 | LttvAttributeValue value; |
| 334 | LttvHooks * tmp; |
| 335 | g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes, |
| 336 | "hooks/updatetimewindow", LTTV_POINTER, &value)); |
| 337 | tmp = (LttvHooks*)*(value.v_pointer); |
| 338 | if(tmp == NULL){ |
| 339 | tmp = lttv_hooks_new(); |
| 340 | *(value.v_pointer) = tmp; |
| 341 | } |
| 342 | lttv_hooks_add(tmp, hook,hook_data); |
| 343 | } |
| 344 | |
| 345 | |
| 346 | /** |
| 347 | * Function to unregister a viewer's hook function which is used to |
| 348 | * set/update the time interval of the viewer. |
| 349 | * It will be called by the destructor of the viewer. |
| 350 | * @param hook hook function of the viewer. |
| 351 | * @param hook_data hook data associated with the hook function. |
| 352 | * @param main_win the main window the viewer belongs to. |
| 353 | */ |
| 354 | |
| 355 | void UnregUpdateTimeWindow(LttvHook hook, gpointer hook_data, |
| 356 | mainWindow * main_win) |
| 357 | { |
| 358 | LttvAttributeValue value; |
| 359 | LttvHooks * tmp; |
| 360 | g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes, |
| 361 | "hooks/updatetimewindow", LTTV_POINTER, &value)); |
| 362 | tmp = (LttvHooks*)*(value.v_pointer); |
| 363 | if(tmp == NULL) return; |
| 364 | lttv_hooks_remove_data(tmp, hook, hook_data); |
| 365 | } |
| 366 | |
| 367 | |
| 368 | /** |
| 369 | * Function to register a hook function for a viewer to set/update its |
| 370 | * traceset. |
| 371 | * It will be called by the constructor of the viewer. |
| 372 | * @param hook hook function of the viewer. |
| 373 | * @param hook_data hook data associated with the hook function. |
| 374 | * @param main_win the main window the viewer belongs to. |
| 375 | */ |
| 376 | |
| 377 | void RegUpdateTraceset(LttvHook hook, gpointer hook_data, |
| 378 | mainWindow * main_win) |
| 379 | { |
| 380 | LttvAttributeValue value; |
| 381 | LttvHooks * tmp; |
| 382 | g_assert(lttv_iattribute_find_by_path(main_win->Attributes, |
| 383 | "hooks/updatetraceset", LTTV_POINTER, &value)); |
| 384 | tmp = (LttvHooks*)*(value.v_pointer); |
| 385 | if(tmp == NULL){ |
| 386 | tmp = lttv_hooks_new(); |
| 387 | *(value.v_pointer) = tmp; |
| 388 | } |
| 389 | lttv_hooks_add(tmp, hook, hook_data); |
| 390 | } |
| 391 | |
| 392 | |
| 393 | /** |
| 394 | * Function to unregister a viewer's hook function which is used to |
| 395 | * set/update the traceset of the viewer. |
| 396 | * It will be called by the destructor of the viewer. |
| 397 | * @param hook hook function of the viewer. |
| 398 | * @param hook_data hook data associated with the hook function. |
| 399 | * @param main_win the main window the viewer belongs to. |
| 400 | */ |
| 401 | |
| 402 | void UnregUpdateTraceset(LttvHook hook, gpointer hook_data, |
| 403 | mainWindow * main_win) |
| 404 | { |
| 405 | LttvAttributeValue value; |
| 406 | LttvHooks * tmp; |
| 407 | g_assert(lttv_iattribute_find_by_path(main_win->Attributes, |
| 408 | "hooks/updatetraceset", LTTV_POINTER, &value)); |
| 409 | tmp = (LttvHooks*)*(value.v_pointer); |
| 410 | if(tmp == NULL) return; |
| 411 | lttv_hooks_remove_data(tmp, hook, hook_data); |
| 412 | } |
| 413 | |
| 414 | |
| 415 | /** |
| 416 | * Function to register a hook function for a viewer to set/update its |
| 417 | * filter. |
| 418 | * It will be called by the constructor of the viewer. |
| 419 | * @param hook hook function of the viewer. |
| 420 | * @param hook_data hook data associated with the hook function. |
| 421 | * @param main_win the main window the viewer belongs to. |
| 422 | */ |
| 423 | |
| 424 | void RegUpdateFilter(LttvHook hook, gpointer hook_data, |
| 425 | mainWindow *main_win) |
| 426 | { |
| 427 | LttvAttributeValue value; |
| 428 | LttvHooks * tmp; |
| 429 | g_assert(lttv_iattribute_find_by_path(main_win->Attributes, |
| 430 | "hooks/updatefilter", LTTV_POINTER, &value)); |
| 431 | tmp = (LttvHooks*)*(value.v_pointer); |
| 432 | if(tmp == NULL){ |
| 433 | tmp = lttv_hooks_new(); |
| 434 | *(value.v_pointer) = tmp; |
| 435 | } |
| 436 | lttv_hooks_add(tmp, hook, hook_data); |
| 437 | } |
| 438 | |
| 439 | |
| 440 | /** |
| 441 | * Function to unregister a viewer's hook function which is used to |
| 442 | * set/update the filter of the viewer. |
| 443 | * It will be called by the destructor of the viewer. |
| 444 | * @param hook hook function of the viewer. |
| 445 | * @param hook_data hook data associated with the hook function. |
| 446 | * @param main_win the main window the viewer belongs to. |
| 447 | */ |
| 448 | |
| 449 | void UnregUpdateFilter(LttvHook hook, gpointer hook_data, |
| 450 | mainWindow * main_win) |
| 451 | { |
| 452 | LttvAttributeValue value; |
| 453 | LttvHooks * tmp; |
| 454 | g_assert(lttv_iattribute_find_by_path(main_win->Attributes, |
| 455 | "hooks/updatefilter", LTTV_POINTER, &value)); |
| 456 | tmp = (LttvHooks*)*(value.v_pointer); |
| 457 | if(tmp == NULL) return; |
| 458 | lttv_hooks_remove_data(tmp, hook, hook_data); |
| 459 | } |
| 460 | |
| 461 | |
| 462 | /** |
| 463 | * Function to register a hook function for a viewer to set/update its |
| 464 | * current time. |
| 465 | * It will be called by the constructor of the viewer. |
| 466 | * @param hook hook function of the viewer. |
| 467 | * @param hook_data hook data associated with the hook function. |
| 468 | * @param main_win the main window the viewer belongs to. |
| 469 | */ |
| 470 | |
| 471 | void RegUpdateCurrentTime(LttvHook hook, gpointer hook_data, |
| 472 | mainWindow *main_win) |
| 473 | { |
| 474 | LttvAttributeValue value; |
| 475 | LttvHooks * tmp; |
| 476 | g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes, |
| 477 | "hooks/updatecurrenttime", LTTV_POINTER, &value)); |
| 478 | tmp = (LttvHooks*)*(value.v_pointer); |
| 479 | if(tmp == NULL){ |
| 480 | tmp = lttv_hooks_new(); |
| 481 | *(value.v_pointer) = tmp; |
| 482 | } |
| 483 | lttv_hooks_add(tmp, hook, hook_data); |
| 484 | } |
| 485 | |
| 486 | |
| 487 | /** |
| 488 | * Function to unregister a viewer's hook function which is used to |
| 489 | * set/update the current time of the viewer. |
| 490 | * It will be called by the destructor of the viewer. |
| 491 | * @param hook hook function of the viewer. |
| 492 | * @param hook_data hook data associated with the hook function. |
| 493 | * @param main_win the main window the viewer belongs to. |
| 494 | */ |
| 495 | |
| 496 | void UnregUpdateCurrentTime(LttvHook hook, gpointer hook_data, |
| 497 | mainWindow * main_win) |
| 498 | { |
| 499 | LttvAttributeValue value; |
| 500 | LttvHooks * tmp; |
| 501 | g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes, |
| 502 | "hooks/updatecurrenttime", LTTV_POINTER, &value)); |
| 503 | tmp = (LttvHooks*)*(value.v_pointer); |
| 504 | if(tmp == NULL) return; |
| 505 | lttv_hooks_remove_data(tmp, hook, hook_data); |
| 506 | } |
| 507 | |
| 508 | |
| 509 | /** |
| 510 | * Function to set the focused pane (viewer). |
| 511 | * It will be called by a viewer's signal handle associated with |
| 512 | * the grab_focus signal |
| 513 | * @param main_win the main window the viewer belongs to. |
| 514 | * @param paned a pointer to a pane where the viewer is contained. |
| 515 | */ |
| 516 | |
| 517 | void SetFocusedPane(mainWindow *main_win, gpointer paned) |
| 518 | { |
| 519 | gtk_custom_set_focus((GtkWidget*)main_win->CurrentTab->custom,paned); |
| 520 | } |
| 521 | |
| 522 | |
| 523 | /** |
| 524 | * Function to register a hook function for a viewer to set/update the |
| 525 | * dividor of the hpane. |
| 526 | * It will be called by the constructor of the viewer. |
| 527 | * @param hook hook function of the viewer. |
| 528 | * @param hook_data hook data associated with the hook function. |
| 529 | * @param main_win the main window the viewer belongs to. |
| 530 | */ |
| 531 | |
| 532 | void RegUpdateDividor(LttvHook hook, gpointer hook_data, |
| 533 | mainWindow *main_win) |
| 534 | { |
| 535 | LttvAttributeValue value; |
| 536 | LttvHooks * tmp; |
| 537 | g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes, |
| 538 | "hooks/hpanedividor", LTTV_POINTER, &value)); |
| 539 | tmp = (LttvHooks*)*(value.v_pointer); |
| 540 | if(tmp == NULL){ |
| 541 | tmp = lttv_hooks_new(); |
| 542 | *(value.v_pointer) = tmp; |
| 543 | } |
| 544 | lttv_hooks_add(tmp, hook, hook_data); |
| 545 | } |
| 546 | |
| 547 | |
| 548 | /** |
| 549 | * Function to unregister a viewer's hook function which is used to |
| 550 | * set/update hpane's dividor of the viewer. |
| 551 | * It will be called by the destructor of the viewer. |
| 552 | * @param hook hook function of the viewer. |
| 553 | * @param hook_data hook data associated with the hook function. |
| 554 | * @param main_win the main window the viewer belongs to. |
| 555 | */ |
| 556 | |
| 557 | void UnregUpdateDividor(LttvHook hook, gpointer hook_data, |
| 558 | mainWindow *main_win) |
| 559 | { |
| 560 | LttvAttributeValue value; |
| 561 | LttvHooks * tmp; |
| 562 | g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes, |
| 563 | "hooks/hpanedividor", LTTV_POINTER, &value)); |
| 564 | tmp = (LttvHooks*)*(value.v_pointer); |
| 565 | if(tmp == NULL) return; |
| 566 | lttv_hooks_remove_data(tmp, hook, hook_data); |
| 567 | } |
| 568 | |
| 569 | |
| 570 | /** |
| 571 | * Function to set the position of the hpane's dividor (viewer). |
| 572 | * It will be called by a viewer's signal handle associated with |
| 573 | * the motion_notify_event event/signal |
| 574 | * @param main_win the main window the viewer belongs to. |
| 575 | * @param position position of the hpane's dividor. |
| 576 | */ |
| 577 | |
| 578 | void SetHPaneDividor(mainWindow *main_win, gint position) |
| 579 | { |
| 580 | LttvAttributeValue value; |
| 581 | LttvHooks * tmp; |
| 582 | g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes, |
| 583 | "hooks/hpanedividor", LTTV_POINTER, &value)); |
| 584 | tmp = (LttvHooks*)*(value.v_pointer); |
| 585 | if(tmp == NULL) return; |
| 586 | lttv_hooks_call(tmp, &position); |
| 587 | } |
| 588 | |
| 589 | |
| 590 | /** |
| 591 | * Function to process traceset. It will call lttv_process_trace, |
| 592 | * each view will call this api to get events. |
| 593 | * @param main_win the main window the viewer belongs to. |
| 594 | * @param start the start time of the first event to be processed. |
| 595 | * @param end the end time of the last event to be processed. |
| 596 | */ |
| 597 | |
| 598 | void processTraceset(mainWindow *main_win, LttTime start, |
| 599 | LttTime end, unsigned maxNumEvents) |
| 600 | { |
| 601 | lttv_process_trace(start, end, main_win->Traceset_Info->traceset, |
| 602 | LTTV_TRACESET_CONTEXT(main_win->Traceset_Info->TracesetContext), |
| 603 | maxNumEvents); |
| 604 | } |
| 605 | |
| 606 | /** |
| 607 | * Function to add hooks into the context of a traceset, |
| 608 | * before reading events from traceset, viewer will call this api to |
| 609 | * register hooks |
| 610 | * @param main_win the main window the viewer belongs to. |
| 611 | * @param LttvHooks hooks to be registered. |
| 612 | */ |
| 613 | |
| 614 | void contextAddHooks(mainWindow *main_win , |
| 615 | LttvHooks *before_traceset, |
| 616 | LttvHooks *after_traceset, |
| 617 | LttvHooks *check_trace, |
| 618 | LttvHooks *before_trace, |
| 619 | LttvHooks *after_trace, |
| 620 | LttvHooks *check_tracefile, |
| 621 | LttvHooks *before_tracefile, |
| 622 | LttvHooks *after_tracefile, |
| 623 | LttvHooks *check_event, |
| 624 | LttvHooks *before_event, |
| 625 | LttvHooks *after_event) |
| 626 | { |
| 627 | LttvTracesetContext * tsc = |
| 628 | LTTV_TRACESET_CONTEXT(main_win->Traceset_Info->TracesetContext); |
| 629 | lttv_traceset_context_add_hooks(tsc,before_traceset,after_traceset, |
| 630 | check_trace,before_trace,after_trace, |
| 631 | check_tracefile,before_tracefile,after_tracefile, |
| 632 | check_event,before_event, after_event); |
| 633 | } |
| 634 | |
| 635 | |
| 636 | /** |
| 637 | * Function to remove hooks from the context of a traceset, |
| 638 | * before reading events from traceset, viewer will call this api to |
| 639 | * unregister hooks |
| 640 | * @param main_win the main window the viewer belongs to. |
| 641 | * @param LttvHooks hooks to be registered. |
| 642 | */ |
| 643 | |
| 644 | void contextRemoveHooks(mainWindow *main_win , |
| 645 | LttvHooks *before_traceset, |
| 646 | LttvHooks *after_traceset, |
| 647 | LttvHooks *check_trace, |
| 648 | LttvHooks *before_trace, |
| 649 | LttvHooks *after_trace, |
| 650 | LttvHooks *check_tracefile, |
| 651 | LttvHooks *before_tracefile, |
| 652 | LttvHooks *after_tracefile, |
| 653 | LttvHooks *check_event, |
| 654 | LttvHooks *before_event, |
| 655 | LttvHooks *after_event) |
| 656 | { |
| 657 | LttvTracesetContext * tsc = |
| 658 | LTTV_TRACESET_CONTEXT(main_win->Traceset_Info->TracesetContext); |
| 659 | lttv_traceset_context_remove_hooks(tsc,before_traceset,after_traceset, |
| 660 | check_trace,before_trace,after_trace, |
| 661 | check_tracefile,before_tracefile,after_tracefile, |
| 662 | check_event,before_event, after_event); |
| 663 | } |
| 664 | |
| 665 | |
| 666 | /** |
| 667 | * Function to add/remove event hooks for state |
| 668 | * @param main_win the main window the viewer belongs to. |
| 669 | */ |
| 670 | |
| 671 | void stateAddEventHooks(mainWindow *main_win ) |
| 672 | { |
| 673 | lttv_state_add_event_hooks( |
| 674 | (LttvTracesetState*)main_win->Traceset_Info->TracesetContext); |
| 675 | } |
| 676 | |
| 677 | void stateRemoveEventHooks(mainWindow *main_win ) |
| 678 | { |
| 679 | lttv_state_remove_event_hooks( |
| 680 | (LttvTracesetState*)main_win->Traceset_Info->TracesetContext); |
| 681 | } |
| 682 | |
| 683 | |
| 684 | /** |
| 685 | * Function to add/remove event hooks for stats |
| 686 | * @param main_win the main window the viewer belongs to. |
| 687 | */ |
| 688 | |
| 689 | void statsAddEventHooks(mainWindow *main_win ) |
| 690 | { |
| 691 | lttv_stats_add_event_hooks( |
| 692 | (LttvTracesetStats*)main_win->Traceset_Info->TracesetContext); |
| 693 | } |
| 694 | |
| 695 | void statsRemoveEventHooks(mainWindow *main_win ) |
| 696 | { |
| 697 | lttv_stats_remove_event_hooks( |
| 698 | (LttvTracesetStats*)main_win->Traceset_Info->TracesetContext); |
| 699 | } |
| 700 | |
| 701 | /** |
| 702 | * Function to get the stats of the traceset |
| 703 | * @param main_win the main window the viewer belongs to. |
| 704 | */ |
| 705 | |
| 706 | LttvTracesetStats* getTracesetStats(mainWindow *main_win) |
| 707 | { |
| 708 | return main_win->Traceset_Info->TracesetContext; |
| 709 | } |