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