| 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 lttvviewer.c |
| 20 | * \brief API used by the graphical viewers to interact with their top window. |
| 21 | * |
| 22 | * Main window (gui module) is the place to contain and display viewers. |
| 23 | * Viewers (lttv plugins) interacte with main window through this API and |
| 24 | * 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 the |
| 27 | * tracesetWindow. |
| 28 | * |
| 29 | */ |
| 30 | |
| 31 | #include <ltt/ltt.h> |
| 32 | #include <lttv/lttv.h> |
| 33 | #include <lttv/state.h> |
| 34 | #include <lttv/stats.h> |
| 35 | #include <lttv/tracecontext.h> |
| 36 | #include <lttvwindow/common.h> |
| 37 | #include <lttvwindow/mainwindow.h> |
| 38 | #include <lttvwindow/viewer.h> |
| 39 | #include <lttvwindow/toolbar.h> |
| 40 | #include <lttvwindow/menu.h> |
| 41 | #include <lttvwindow/callbacks.h> // for execute_time_requests |
| 42 | |
| 43 | |
| 44 | /** |
| 45 | * Internal function parts |
| 46 | */ |
| 47 | |
| 48 | /** |
| 49 | * Function to set/update traceset for the viewers |
| 50 | * @param main_win main window |
| 51 | * @param traceset traceset of the main window. |
| 52 | * return value : |
| 53 | * -1 : error |
| 54 | * 0 : traceset updated |
| 55 | * 1 : no traceset hooks to update; not an error. |
| 56 | */ |
| 57 | |
| 58 | int SetTraceset(MainWindow * main_win, gpointer traceset) |
| 59 | { |
| 60 | LttvHooks * tmp; |
| 61 | LttvAttributeValue value; |
| 62 | |
| 63 | if( lttv_iattribute_find_by_path(main_win->attributes, |
| 64 | "hooks/updatetraceset", LTTV_POINTER, &value) != 0) |
| 65 | return -1; |
| 66 | |
| 67 | tmp = (LttvHooks*)*(value.v_pointer); |
| 68 | if(tmp == NULL) return 1; |
| 69 | |
| 70 | |
| 71 | lttv_hooks_call(tmp,traceset); |
| 72 | |
| 73 | return 0; |
| 74 | } |
| 75 | |
| 76 | |
| 77 | /** |
| 78 | * Function to set/update filter for the viewers |
| 79 | * @param main_win main window |
| 80 | * @param filter filter of the main window. |
| 81 | * return value : |
| 82 | * -1 : error |
| 83 | * 0 : filters updated |
| 84 | * 1 : no filter hooks to update; not an error. |
| 85 | */ |
| 86 | |
| 87 | int SetFilter(MainWindow * main_win, gpointer filter) |
| 88 | { |
| 89 | LttvHooks * tmp; |
| 90 | LttvAttributeValue value; |
| 91 | |
| 92 | if(lttv_iattribute_find_by_path(main_win->attributes, |
| 93 | "hooks/updatefilter", LTTV_POINTER, &value) != 0) |
| 94 | return -1; |
| 95 | |
| 96 | tmp = (LttvHooks*)*(value.v_pointer); |
| 97 | |
| 98 | if(tmp == NULL) return 1; |
| 99 | lttv_hooks_call(tmp,filter); |
| 100 | |
| 101 | return 0; |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * Function to redraw each viewer belonging to the current tab |
| 106 | * @param main_win the main window the viewer belongs to. |
| 107 | */ |
| 108 | |
| 109 | void update_traceset(MainWindow * main_win) |
| 110 | { |
| 111 | LttvAttributeValue value; |
| 112 | LttvHooks * tmp; |
| 113 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
| 114 | "hooks/updatetraceset", LTTV_POINTER, &value)); |
| 115 | tmp = (LttvHooks*)*(value.v_pointer); |
| 116 | if(tmp == NULL) return; |
| 117 | lttv_hooks_call(tmp, NULL); |
| 118 | } |
| 119 | |
| 120 | void set_time_window_adjustment(MainWindow * main_win, const TimeWindow* new_time_window) |
| 121 | { |
| 122 | gtk_multi_vpaned_set_adjust(main_win->current_tab->multi_vpaned, new_time_window, FALSE); |
| 123 | } |
| 124 | |
| 125 | |
| 126 | void set_time_window(MainWindow * main_win, const TimeWindow *time_window) |
| 127 | { |
| 128 | LttvAttributeValue value; |
| 129 | LttvHooks * tmp; |
| 130 | |
| 131 | TimeWindowNotifyData time_window_notify_data; |
| 132 | TimeWindow old_time_window = main_win->current_tab->time_window; |
| 133 | time_window_notify_data.old_time_window = &old_time_window; |
| 134 | main_win->current_tab->time_window = *time_window; |
| 135 | time_window_notify_data.new_time_window = |
| 136 | &(main_win->current_tab->time_window); |
| 137 | |
| 138 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
| 139 | "hooks/updatetimewindow", LTTV_POINTER, &value)); |
| 140 | tmp = (LttvHooks*)*(value.v_pointer); |
| 141 | if(tmp == NULL) return; |
| 142 | lttv_hooks_call(tmp, &time_window_notify_data); |
| 143 | |
| 144 | |
| 145 | } |
| 146 | |
| 147 | /** |
| 148 | * API parts |
| 149 | */ |
| 150 | |
| 151 | |
| 152 | /** |
| 153 | * Function to register a view constructor so that main window can generate |
| 154 | * a menu item and a toolbar item for the viewer in order to generate a new |
| 155 | * instance easily. A menu entry and toolbar item will be added to each main |
| 156 | * window. |
| 157 | * |
| 158 | * It should be called by init function of the module. |
| 159 | * |
| 160 | * @param menu_path path of the menu item. |
| 161 | * @param menu_text text of the menu item. |
| 162 | * @param pixmap Image shown on the toolbar item. |
| 163 | * @param tooltip tooltip of the toolbar item. |
| 164 | * @param view_constructor constructor of the viewer. |
| 165 | */ |
| 166 | |
| 167 | void lttvwindow_register_constructor |
| 168 | (char * menu_path, |
| 169 | char * menu_text, |
| 170 | char ** pixmap, |
| 171 | char * tooltip, |
| 172 | lttvwindow_viewer_constructor view_constructor) |
| 173 | { |
| 174 | LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes()); |
| 175 | LttvToolbars * toolbar; |
| 176 | LttvMenus * menu; |
| 177 | LttvAttributeValue value; |
| 178 | |
| 179 | if(pixmap != NULL) { |
| 180 | g_assert(lttv_iattribute_find_by_path(attributes_global, |
| 181 | "viewers/toolbar", LTTV_POINTER, &value)); |
| 182 | toolbar = (LttvToolbars*)*(value.v_pointer); |
| 183 | |
| 184 | if(toolbar == NULL) { |
| 185 | toolbar = lttv_toolbars_new(); |
| 186 | *(value.v_pointer) = toolbar; |
| 187 | } |
| 188 | lttv_toolbars_add(toolbar, view_constructor, tooltip, pixmap); |
| 189 | main_window_add_toolbars_item(toolbar, view_constructor, tooltip, pixmap); |
| 190 | } |
| 191 | |
| 192 | if(menu_path != NULL) { |
| 193 | g_assert(lttv_iattribute_find_by_path(attributes_global, |
| 194 | "viewers/menu", LTTV_POINTER, &value)); |
| 195 | menu = (LttvMenus*)*(value.v_pointer); |
| 196 | |
| 197 | if(menu == NULL) { |
| 198 | menu = lttv_menus_new(); |
| 199 | *(value.v_pointer) = menu; |
| 200 | } |
| 201 | lttv_menus_add(menu, view_constructor, menu_path, menu_text); |
| 202 | main_window_add_menu_item(menu, view_constructor, menu_path, menu_text); |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | |
| 207 | /** |
| 208 | * Function to unregister the viewer's constructor, release the space |
| 209 | * occupied by menu_path, menu_text, pixmap, tooltip and constructor of the |
| 210 | * viewer. |
| 211 | * |
| 212 | * It will be called when a module is unloaded. |
| 213 | * |
| 214 | * @param view_constructor constructor of the viewer. |
| 215 | */ |
| 216 | |
| 217 | |
| 218 | void lttvwindow_unregister_constructor |
| 219 | (lttvwindow_viewer_constructor view_constructor) |
| 220 | { |
| 221 | LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes()); |
| 222 | LttvToolbars * toolbar; |
| 223 | LttvMenus * menu; |
| 224 | LttvAttributeValue value; |
| 225 | |
| 226 | g_assert(lttv_iattribute_find_by_path(attributes_global, |
| 227 | "viewers/toolbar", LTTV_POINTER, &value)); |
| 228 | toolbar = (LttvToolbars*)*(value.v_pointer); |
| 229 | |
| 230 | if(toolbar != NULL) { |
| 231 | main_window_remove_toolbar_item(view_constructor); |
| 232 | lttv_toolbars_remove(toolbar, view_constructor); |
| 233 | } |
| 234 | |
| 235 | g_assert(lttv_iattribute_find_by_path(attributes_global, |
| 236 | "viewers/menu", LTTV_POINTER, &value)); |
| 237 | menu = (LttvMenus*)*(value.v_pointer); |
| 238 | |
| 239 | if(menu != NULL) { |
| 240 | main_window_remove_menu_item(view_constructor); |
| 241 | lttv_menus_remove(menu, view_constructor); |
| 242 | } |
| 243 | |
| 244 | |
| 245 | } |
| 246 | |
| 247 | |
| 248 | /** |
| 249 | * Function to register a hook function for a viewer to set/update its |
| 250 | * time interval. |
| 251 | * @param hook hook function of the viewer. |
| 252 | * @param hook_data hook data associated with the hook function. |
| 253 | * @param main_win the main window the viewer belongs to. |
| 254 | */ |
| 255 | void lttvwindow_register_time_window_notify(MainWindow * main_win, |
| 256 | LttvHook hook, gpointer hook_data) |
| 257 | { |
| 258 | LttvAttributeValue value; |
| 259 | LttvHooks * tmp; |
| 260 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
| 261 | "hooks/updatetimewindow", LTTV_POINTER, &value)); |
| 262 | tmp = (LttvHooks*)*(value.v_pointer); |
| 263 | if(tmp == NULL){ |
| 264 | tmp = lttv_hooks_new(); |
| 265 | *(value.v_pointer) = tmp; |
| 266 | } |
| 267 | lttv_hooks_add(tmp, hook,hook_data); |
| 268 | } |
| 269 | |
| 270 | |
| 271 | /** |
| 272 | * Function to unregister a viewer's hook function which is used to |
| 273 | * set/update the time interval of the viewer. |
| 274 | * @param hook hook function of the viewer. |
| 275 | * @param hook_data hook data associated with the hook function. |
| 276 | * @param main_win the main window the viewer belongs to. |
| 277 | */ |
| 278 | |
| 279 | void lttvwindow_unregister_time_window_notify(MainWindow * main_win, |
| 280 | LttvHook hook, gpointer hook_data) |
| 281 | { |
| 282 | LttvAttributeValue value; |
| 283 | LttvHooks * tmp; |
| 284 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
| 285 | "hooks/updatetimewindow", LTTV_POINTER, &value)); |
| 286 | tmp = (LttvHooks*)*(value.v_pointer); |
| 287 | if(tmp == NULL) return; |
| 288 | lttv_hooks_remove_data(tmp, hook, hook_data); |
| 289 | } |
| 290 | |
| 291 | /** |
| 292 | * Function to register a hook function for a viewer to set/update its |
| 293 | * traceset. |
| 294 | * @param hook hook function of the viewer. |
| 295 | * @param hook_data hook data associated with the hook function. |
| 296 | * @param main_win the main window the viewer belongs to. |
| 297 | */ |
| 298 | |
| 299 | void lttvwindow_register_traceset_notify(MainWindow * main_win, |
| 300 | LttvHook hook, gpointer hook_data) |
| 301 | { |
| 302 | LttvAttributeValue value; |
| 303 | LttvHooks * tmp; |
| 304 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
| 305 | "hooks/updatetraceset", LTTV_POINTER, &value)); |
| 306 | tmp = (LttvHooks*)*(value.v_pointer); |
| 307 | if(tmp == NULL){ |
| 308 | tmp = lttv_hooks_new(); |
| 309 | *(value.v_pointer) = tmp; |
| 310 | } |
| 311 | lttv_hooks_add(tmp, hook, hook_data); |
| 312 | } |
| 313 | |
| 314 | |
| 315 | /** |
| 316 | * Function to unregister a viewer's hook function which is used to |
| 317 | * set/update the traceset of the viewer. |
| 318 | * @param hook hook function of the viewer. |
| 319 | * @param hook_data hook data associated with the hook function. |
| 320 | * @param main_win the main window the viewer belongs to. |
| 321 | */ |
| 322 | |
| 323 | void lttvwindow_unregister_traceset_notify(MainWindow * main_win, |
| 324 | LttvHook hook, gpointer hook_data) |
| 325 | { |
| 326 | LttvAttributeValue value; |
| 327 | LttvHooks * tmp; |
| 328 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
| 329 | "hooks/updatetraceset", LTTV_POINTER, &value)); |
| 330 | tmp = (LttvHooks*)*(value.v_pointer); |
| 331 | if(tmp == NULL) return; |
| 332 | lttv_hooks_remove_data(tmp, hook, hook_data); |
| 333 | } |
| 334 | |
| 335 | /** |
| 336 | * Function to register a hook function for a viewer to set/update its |
| 337 | * filter. |
| 338 | * @param hook hook function of the viewer. |
| 339 | * @param hook_data hook data associated with the hook function. |
| 340 | * @param main_win the main window the viewer belongs to. |
| 341 | */ |
| 342 | |
| 343 | void lttvwindow_register_filter_notify(MainWindow *main_win, |
| 344 | LttvHook hook, gpointer hook_data) |
| 345 | { |
| 346 | LttvAttributeValue value; |
| 347 | LttvHooks * tmp; |
| 348 | g_assert(lttv_iattribute_find_by_path(main_win->attributes, |
| 349 | "hooks/updatefilter", LTTV_POINTER, &value)); |
| 350 | tmp = (LttvHooks*)*(value.v_pointer); |
| 351 | if(tmp == NULL){ |
| 352 | tmp = lttv_hooks_new(); |
| 353 | *(value.v_pointer) = tmp; |
| 354 | } |
| 355 | lttv_hooks_add(tmp, hook, hook_data); |
| 356 | } |
| 357 | |
| 358 | |
| 359 | /** |
| 360 | * Function to unregister a viewer's hook function which is used to |
| 361 | * set/update the filter of the viewer. |
| 362 | * @param hook hook function of the viewer. |
| 363 | * @param hook_data hook data associated with the hook function. |
| 364 | * @param main_win the main window the viewer belongs to. |
| 365 | */ |
| 366 | |
| 367 | void lttvwindow_unregister_filter_notify(MainWindow * main_win, |
| 368 | LttvHook hook, |
| 369 | gpointer hook_data) |
| 370 | { |
| 371 | LttvAttributeValue value; |
| 372 | LttvHooks * tmp; |
| 373 | g_assert(lttv_iattribute_find_by_path(main_win->attributes, |
| 374 | "hooks/updatefilter", LTTV_POINTER, &value)); |
| 375 | tmp = (LttvHooks*)*(value.v_pointer); |
| 376 | if(tmp == NULL) return; |
| 377 | lttv_hooks_remove_data(tmp, hook, hook_data); |
| 378 | } |
| 379 | |
| 380 | /** |
| 381 | * Function to register a hook function for a viewer to set/update its |
| 382 | * current time. |
| 383 | * @param hook hook function of the viewer. |
| 384 | * @param hook_data hook data associated with the hook function. |
| 385 | * @param main_win the main window the viewer belongs to. |
| 386 | */ |
| 387 | |
| 388 | void lttvwindow_register_current_time_notify(MainWindow *main_win, |
| 389 | LttvHook hook, gpointer hook_data) |
| 390 | { |
| 391 | LttvAttributeValue value; |
| 392 | LttvHooks * tmp; |
| 393 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
| 394 | "hooks/updatecurrenttime", LTTV_POINTER, &value)); |
| 395 | tmp = (LttvHooks*)*(value.v_pointer); |
| 396 | if(tmp == NULL){ |
| 397 | tmp = lttv_hooks_new(); |
| 398 | *(value.v_pointer) = tmp; |
| 399 | } |
| 400 | lttv_hooks_add(tmp, hook, hook_data); |
| 401 | } |
| 402 | |
| 403 | |
| 404 | /** |
| 405 | * Function to unregister a viewer's hook function which is used to |
| 406 | * set/update the current time of the viewer. |
| 407 | * @param hook hook function of the viewer. |
| 408 | * @param hook_data hook data associated with the hook function. |
| 409 | * @param main_win the main window the viewer belongs to. |
| 410 | */ |
| 411 | |
| 412 | void lttvwindow_unregister_current_time_notify(MainWindow * main_win, |
| 413 | LttvHook hook, gpointer hook_data) |
| 414 | { |
| 415 | LttvAttributeValue value; |
| 416 | LttvHooks * tmp; |
| 417 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
| 418 | "hooks/updatecurrenttime", LTTV_POINTER, &value)); |
| 419 | tmp = (LttvHooks*)*(value.v_pointer); |
| 420 | if(tmp == NULL) return; |
| 421 | lttv_hooks_remove_data(tmp, hook, hook_data); |
| 422 | } |
| 423 | |
| 424 | |
| 425 | /** |
| 426 | * Function to register a hook function for a viewer to show |
| 427 | * the content of the viewer. |
| 428 | * @param hook hook function of the viewer. |
| 429 | * @param hook_data hook data associated with the hook function. |
| 430 | * @param main_win the main window the viewer belongs to. |
| 431 | */ |
| 432 | |
| 433 | void lttvwindow_register_show_notify(MainWindow *main_win, |
| 434 | LttvHook hook, gpointer hook_data) |
| 435 | { |
| 436 | LttvAttributeValue value; |
| 437 | LttvHooks * tmp; |
| 438 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
| 439 | "hooks/showviewer", LTTV_POINTER, &value)); |
| 440 | tmp = (LttvHooks*)*(value.v_pointer); |
| 441 | if(tmp == NULL){ |
| 442 | tmp = lttv_hooks_new(); |
| 443 | *(value.v_pointer) = tmp; |
| 444 | } |
| 445 | lttv_hooks_add(tmp, hook, hook_data); |
| 446 | } |
| 447 | |
| 448 | |
| 449 | /** |
| 450 | * Function to unregister a viewer's hook function which is used to |
| 451 | * show the content of the viewer.. |
| 452 | * @param hook hook function of the viewer. |
| 453 | * @param hook_data hook data associated with the hook function. |
| 454 | * @param main_win the main window the viewer belongs to. |
| 455 | */ |
| 456 | |
| 457 | void lttvwindow_unregister_show_notify(MainWindow * main_win, |
| 458 | LttvHook hook, gpointer hook_data) |
| 459 | { |
| 460 | LttvAttributeValue value; |
| 461 | LttvHooks * tmp; |
| 462 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
| 463 | "hooks/showviewer", LTTV_POINTER, &value)); |
| 464 | tmp = (LttvHooks*)*(value.v_pointer); |
| 465 | if(tmp == NULL) return; |
| 466 | lttv_hooks_remove_data(tmp, hook, hook_data); |
| 467 | } |
| 468 | |
| 469 | /** |
| 470 | * Function to register a hook function for a viewer to set/update the |
| 471 | * dividor of the hpane. |
| 472 | * @param hook hook function of the viewer. |
| 473 | * @param hook_data hook data associated with the hook function. |
| 474 | * @param main_win the main window the viewer belongs to. |
| 475 | */ |
| 476 | |
| 477 | void lttvwindow_register_dividor(MainWindow *main_win, |
| 478 | LttvHook hook, gpointer hook_data) |
| 479 | { |
| 480 | LttvAttributeValue value; |
| 481 | LttvHooks * tmp; |
| 482 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
| 483 | "hooks/hpanedividor", LTTV_POINTER, &value)); |
| 484 | tmp = (LttvHooks*)*(value.v_pointer); |
| 485 | if(tmp == NULL){ |
| 486 | tmp = lttv_hooks_new(); |
| 487 | *(value.v_pointer) = tmp; |
| 488 | } |
| 489 | lttv_hooks_add(tmp, hook, hook_data); |
| 490 | } |
| 491 | |
| 492 | |
| 493 | /** |
| 494 | * Function to unregister a viewer's hook function which is used to |
| 495 | * set/update hpane's dividor of the viewer. |
| 496 | * It will be called by the destructor of the viewer. |
| 497 | * @param hook hook function of the viewer. |
| 498 | * @param hook_data hook data associated with the hook function. |
| 499 | * @param main_win the main window the viewer belongs to. |
| 500 | */ |
| 501 | |
| 502 | void lttvwindow_unregister_dividor(MainWindow *main_win, |
| 503 | LttvHook hook, gpointer hook_data) |
| 504 | { |
| 505 | LttvAttributeValue value; |
| 506 | LttvHooks * tmp; |
| 507 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
| 508 | "hooks/hpanedividor", LTTV_POINTER, &value)); |
| 509 | tmp = (LttvHooks*)*(value.v_pointer); |
| 510 | if(tmp == NULL) return; |
| 511 | lttv_hooks_remove_data(tmp, hook, hook_data); |
| 512 | } |
| 513 | |
| 514 | |
| 515 | /** |
| 516 | * Update the status bar whenever something changed in the viewer. |
| 517 | * @param main_win the main window the viewer belongs to. |
| 518 | * @param info the message which will be shown in the status bar. |
| 519 | */ |
| 520 | |
| 521 | void lttvwindow_report_status(MainWindow *main_win, const char *info) |
| 522 | { |
| 523 | //FIXME |
| 524 | g_warning("update_status not implemented in viewer.c"); |
| 525 | } |
| 526 | |
| 527 | /** |
| 528 | * Function to set the time interval of the current tab. |
| 529 | * It will be called by a viewer's signal handle associated with |
| 530 | * the move_slider signal |
| 531 | * @param main_win the main window the viewer belongs to. |
| 532 | * @param time_interval a pointer where time interval is stored. |
| 533 | */ |
| 534 | |
| 535 | void lttvwindow_report_time_window(MainWindow *main_win, |
| 536 | const TimeWindow *time_window) |
| 537 | { |
| 538 | set_time_window(main_win, time_window); |
| 539 | set_time_window_adjustment(main_win, time_window); |
| 540 | } |
| 541 | |
| 542 | |
| 543 | /** |
| 544 | * Function to set the current time/event of the current tab. |
| 545 | * It will be called by a viewer's signal handle associated with |
| 546 | * the button-release-event signal |
| 547 | * @param main_win the main window the viewer belongs to. |
| 548 | * @param time a pointer where time is stored. |
| 549 | */ |
| 550 | |
| 551 | void lttvwindow_report_current_time(MainWindow *main_win, |
| 552 | const LttTime *time) |
| 553 | { |
| 554 | LttvAttributeValue value; |
| 555 | LttvHooks * tmp; |
| 556 | main_win->current_tab->current_time = *time; |
| 557 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
| 558 | "hooks/updatecurrenttime", LTTV_POINTER, &value)); |
| 559 | tmp = (LttvHooks*)*(value.v_pointer); |
| 560 | |
| 561 | if(tmp == NULL)return; |
| 562 | lttv_hooks_call(tmp, &main_win->current_tab->current_time); |
| 563 | } |
| 564 | |
| 565 | /** |
| 566 | * Function to set the position of the hpane's dividor (viewer). |
| 567 | * It will be called by a viewer's signal handle associated with |
| 568 | * the motion_notify_event event/signal |
| 569 | * @param main_win the main window the viewer belongs to. |
| 570 | * @param position position of the hpane's dividor. |
| 571 | */ |
| 572 | |
| 573 | void lttvwindow_report_dividor(MainWindow *main_win, gint position) |
| 574 | { |
| 575 | LttvAttributeValue value; |
| 576 | LttvHooks * tmp; |
| 577 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
| 578 | "hooks/hpanedividor", LTTV_POINTER, &value)); |
| 579 | tmp = (LttvHooks*)*(value.v_pointer); |
| 580 | if(tmp == NULL) return; |
| 581 | lttv_hooks_call(tmp, &position); |
| 582 | } |
| 583 | |
| 584 | /** |
| 585 | * Function to set the focused pane (viewer). |
| 586 | * It will be called by a viewer's signal handle associated with |
| 587 | * the grab_focus signal |
| 588 | * @param main_win the main window the viewer belongs to. |
| 589 | * @param top_widget the top widget containing all the other widgets of the |
| 590 | * viewer. |
| 591 | */ |
| 592 | |
| 593 | void lttvwindow_report_focus(MainWindow *main_win, GtkWidget *top_widget) |
| 594 | { |
| 595 | gtk_multi_vpaned_set_focus((GtkWidget*)main_win->current_tab->multi_vpaned, |
| 596 | gtk_widget_get_parent(top_widget)); |
| 597 | } |
| 598 | |
| 599 | |
| 600 | /** |
| 601 | * Function to request data in a specific time interval to the main window. |
| 602 | * The main window will use this time interval and the others present |
| 603 | * to get the data from the process trace. |
| 604 | * @param main_win the main window the viewer belongs to. |
| 605 | * @param paned a pointer to a pane where the viewer is contained. |
| 606 | */ |
| 607 | |
| 608 | void lttvwindow_time_interval_request(MainWindow *main_win, |
| 609 | TimeWindow time_requested, guint num_events, |
| 610 | LttvHook after_process_traceset, |
| 611 | gpointer after_process_traceset_data) |
| 612 | { |
| 613 | TimeRequest time_request; |
| 614 | |
| 615 | time_request.time_window = time_requested; |
| 616 | time_request.num_events = num_events; |
| 617 | time_request.after_hook = after_process_traceset; |
| 618 | time_request.after_hook_data = after_process_traceset_data; |
| 619 | |
| 620 | g_array_append_val(main_win->current_tab->time_requests, time_request); |
| 621 | |
| 622 | if(!main_win->current_tab->time_request_pending) |
| 623 | { |
| 624 | /* Redraw has +20 priority. We want a prio higher than that, so +19 */ |
| 625 | g_idle_add_full((G_PRIORITY_HIGH_IDLE + 19), |
| 626 | (GSourceFunc)execute_time_requests, |
| 627 | main_win, |
| 628 | NULL); |
| 629 | main_win->current_tab->time_request_pending = TRUE; |
| 630 | } |
| 631 | } |
| 632 | |
| 633 | /** |
| 634 | * Function to get the current time interval shown on the current tab. |
| 635 | * It will be called by a viewer's hook function to update the |
| 636 | * shown time interval of the viewer and also be called by the constructor |
| 637 | * of the viewer. |
| 638 | * @param main_win the main window the viewer belongs to. |
| 639 | * @param time_interval a pointer where time interval will be stored. |
| 640 | */ |
| 641 | |
| 642 | const TimeWindow *lttvwindow_get_time_window(MainWindow *main_win) |
| 643 | { |
| 644 | //time_window->start_time = main_win->current_tab->time_window.start_time; |
| 645 | //time_window->time_width = main_win->current_tab->time_window.time_width; |
| 646 | return &(main_win->current_tab->time_window); |
| 647 | |
| 648 | } |
| 649 | |
| 650 | |
| 651 | /** |
| 652 | * Function to get the current time/event of the current tab. |
| 653 | * It will be called by a viewer's hook function to update the |
| 654 | * current time/event of the viewer. |
| 655 | * @param main_win the main window the viewer belongs to. |
| 656 | * @param time a pointer where time will be stored. |
| 657 | */ |
| 658 | |
| 659 | const LttTime *lttvwindow_get_current_time(MainWindow *main_win) |
| 660 | { |
| 661 | return &(main_win->current_tab->current_time); |
| 662 | } |
| 663 | |
| 664 | |
| 665 | /** |
| 666 | * Function to get the filter of the current tab. |
| 667 | * It will be called by the constructor of the viewer and also be |
| 668 | * called by a hook funtion of the viewer to update its filter. |
| 669 | * @param main_win, the main window the viewer belongs to. |
| 670 | * @param filter, a pointer to a filter. |
| 671 | */ |
| 672 | const lttv_filter *lttvwindow_get_filter(MainWindow *main_win) |
| 673 | { |
| 674 | //FIXME |
| 675 | g_warning("lttvwindow_get_filter not implemented in viewer.c"); |
| 676 | } |
| 677 | |
| 678 | |
| 679 | /** |
| 680 | * Function to get the stats of the traceset |
| 681 | * @param main_win the main window the viewer belongs to. |
| 682 | */ |
| 683 | |
| 684 | LttvTracesetStats* lttvwindow_get_traceset_stats(MainWindow *main_win) |
| 685 | { |
| 686 | return main_win->current_tab->traceset_info->traceset_context; |
| 687 | } |
| 688 | |
| 689 | |
| 690 | LttvTracesetContext* lttvwindow_get_traceset_context(MainWindow *main_win) |
| 691 | { |
| 692 | return (LttvTracesetContext*)main_win->current_tab->traceset_info->traceset_context; |
| 693 | } |