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