1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 XangXiu Yang
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;
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.
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,
19 /*! \file lttvwindow.c
20 * \brief API used by the graphical viewers to interact with their tab.
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
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>
49 * Internal function parts
52 extern GSList
* g_main_window_list
;
56 * It updates the time window of the tab, then calls the updatetimewindow
57 * hooks of each viewer.
59 * This is called whenever the scrollbar value changes.
62 void set_time_window(Tab
*tab
, const TimeWindow
*time_window
)
64 LttvAttributeValue value
;
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
=
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
);
79 //gtk_multi_vpaned_set_adjust(tab->multi_vpaned, new_time_window, FALSE);
85 * It updates the current time of the tab, then calls the updatetimewindow
86 * hooks of each viewer.
88 * This is called whenever the current time value changes.
91 void set_current_time(Tab
*tab
, const LttTime
*current_time
)
93 LttvAttributeValue value
;
96 tab
->current_time
= *current_time
;
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
);
104 void add_toolbar_constructor(MainWindow
*mw
, LttvToolbarClosure
*toolbar_c
)
106 LttvIAttribute
*attributes
= mw
->attributes
;
107 LttvAttributeValue value
;
108 LttvToolbars
* instance_toolbar
;
109 lttvwindow_viewer_constructor constructor
;
110 GtkWidget
* tool_menu_title_menu
, *new_widget
, *pixmap
;
113 g_assert(lttv_iattribute_find_by_path(attributes
,
114 "viewers/toolbar", LTTV_POINTER
, &value
));
115 if(*(value
.v_pointer
) == NULL
)
116 *(value
.v_pointer
) = lttv_toolbars_new();
117 instance_toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
119 constructor
= toolbar_c
->con
;
120 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"MToolbar1");
121 pixbuf
= gdk_pixbuf_new_from_xpm_data((const char**)toolbar_c
->pixmap
);
122 pixmap
= gtk_image_new_from_pixbuf(pixbuf
);
124 gtk_toolbar_append_element (GTK_TOOLBAR (tool_menu_title_menu
),
125 GTK_TOOLBAR_CHILD_BUTTON
,
128 toolbar_c
->tooltip
, NULL
,
130 gtk_label_set_use_underline(
131 GTK_LABEL (((GtkToolbarChild
*) (
132 g_list_last (GTK_TOOLBAR
133 (tool_menu_title_menu
)->children
)->data
))->label
),
135 gtk_container_set_border_width (GTK_CONTAINER (new_widget
), 1);
136 g_signal_connect ((gpointer
) new_widget
,
138 G_CALLBACK (insert_viewer_wrap
),
140 gtk_widget_show (new_widget
);
142 lttv_toolbars_add(instance_toolbar
, toolbar_c
->con
,
149 void add_menu_constructor(MainWindow
*mw
, LttvMenuClosure
*menu_c
)
151 LttvIAttribute
*attributes
= mw
->attributes
;
152 LttvAttributeValue value
;
153 LttvToolbars
* instance_menu
;
154 lttvwindow_viewer_constructor constructor
;
155 GtkWidget
* tool_menu_title_menu
, *new_widget
;
157 g_assert(lttv_iattribute_find_by_path(attributes
,
158 "viewers/menu", LTTV_POINTER
, &value
));
159 if(*(value
.v_pointer
) == NULL
)
160 *(value
.v_pointer
) = lttv_menus_new();
161 instance_menu
= (LttvMenus
*)*(value
.v_pointer
);
164 constructor
= menu_c
->con
;
165 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"ToolMenuTitle_menu");
167 gtk_menu_item_new_with_mnemonic (menu_c
->menu_text
);
168 gtk_container_add (GTK_CONTAINER (tool_menu_title_menu
),
170 g_signal_connect ((gpointer
) new_widget
, "activate",
171 G_CALLBACK (insert_viewer_wrap
),
173 gtk_widget_show (new_widget
);
174 lttv_menus_add(instance_menu
, menu_c
->con
,
180 void remove_toolbar_constructor(MainWindow
*mw
, lttvwindow_viewer_constructor viewer_constructor
)
182 LttvIAttribute
*attributes
= mw
->attributes
;
183 LttvAttributeValue value
;
184 LttvToolbars
* instance_toolbar
;
185 lttvwindow_viewer_constructor constructor
;
186 GtkWidget
* tool_menu_title_menu
, *widget
;
188 g_assert(lttv_iattribute_find_by_path(attributes
,
189 "viewers/toolbar", LTTV_POINTER
, &value
));
190 if(*(value
.v_pointer
) == NULL
)
191 *(value
.v_pointer
) = lttv_toolbars_new();
192 instance_toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
194 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"MToolbar1");
195 widget
= lttv_menus_remove(instance_toolbar
, viewer_constructor
);
196 gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu
),
201 void remove_menu_constructor(MainWindow
*mw
, lttvwindow_viewer_constructor viewer_constructor
)
203 LttvIAttribute
*attributes
= mw
->attributes
;
204 LttvAttributeValue value
;
205 LttvMenus
* instance_menu
;
206 lttvwindow_viewer_constructor constructor
;
207 GtkWidget
* tool_menu_title_menu
, *widget
;
208 LttvMenuClosure
*menu_item_i
;
210 g_assert(lttv_iattribute_find_by_path(attributes
,
211 "viewers/menu", LTTV_POINTER
, &value
));
212 if(*(value
.v_pointer
) == NULL
)
213 *(value
.v_pointer
) = lttv_menus_new();
214 instance_menu
= (LttvMenus
*)*(value
.v_pointer
);
216 widget
= lttv_menus_remove(instance_menu
, viewer_constructor
);
217 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"ToolMenuTitle_menu");
218 gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu
), widget
);
228 * Function to register a view constructor so that main window can generate
229 * a menu item and a toolbar item for the viewer in order to generate a new
230 * instance easily. A menu entry and toolbar item will be added to each main
233 * It should be called by init function of the module.
235 * @param name name of the viewer
236 * @param menu_path path of the menu item.
237 * @param menu_text text of the menu item.
238 * @param pixmap Image shown on the toolbar item.
239 * @param tooltip tooltip of the toolbar item.
240 * @param view_constructor constructor of the viewer.
243 void lttvwindow_register_constructor
249 lttvwindow_viewer_constructor view_constructor
)
251 LttvIAttribute
*attributes_global
= LTTV_IATTRIBUTE(lttv_global_attributes());
252 LttvToolbars
* toolbar
;
254 LttvToolbarClosure toolbar_c
;
255 LttvMenuClosure menu_c
;
256 LttvAttributeValue value
;
258 if(view_constructor
== NULL
) return;
261 g_assert(lttv_iattribute_find_by_path(attributes_global
,
262 "viewers/toolbar", LTTV_POINTER
, &value
));
263 toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
265 if(toolbar
== NULL
) {
266 toolbar
= lttv_toolbars_new();
267 *(value
.v_pointer
) = toolbar
;
269 toolbar_c
= lttv_toolbars_add(toolbar
, view_constructor
, tooltip
, pixmap
,
272 g_slist_foreach(g_main_window_list
,
273 (gpointer
)add_toolbar_constructor
,
277 if(menu_path
!= NULL
) {
278 g_assert(lttv_iattribute_find_by_path(attributes_global
,
279 "viewers/menu", LTTV_POINTER
, &value
));
280 menu
= (LttvMenus
*)*(value
.v_pointer
);
283 menu
= lttv_menus_new();
284 *(value
.v_pointer
) = menu
;
286 menu_c
= lttv_menus_add(menu
, view_constructor
, menu_path
, menu_text
,NULL
);
288 g_slist_foreach(g_main_window_list
,
289 (gpointer
)add_menu_constructor
,
293 LttvAttribute
*attribute
;
295 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
296 LTTV_IATTRIBUTE(attributes_global
),
297 LTTV_VIEWER_CONSTRUCTORS
)));
299 g_assert(lttv_iattribute_find_by_path(LTTV_IATTRIBUTE(attribute
),
300 name
, LTTV_POINTER
, &value
));
302 *(value
.v_pointer
) = view_constructor
;
309 * Function to unregister the viewer's constructor, release the space
310 * occupied by menu_path, menu_text, pixmap, tooltip and constructor of the
313 * It will be called when a module is unloaded.
315 * @param view_constructor constructor of the viewer.
319 void lttvwindow_unregister_constructor
320 (lttvwindow_viewer_constructor view_constructor
)
322 LttvIAttribute
*attributes_global
= LTTV_IATTRIBUTE(lttv_global_attributes());
323 LttvToolbars
* toolbar
;
325 LttvAttributeValue value
;
327 g_assert(lttv_iattribute_find_by_path(attributes_global
,
328 "viewers/toolbar", LTTV_POINTER
, &value
));
329 toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
331 if(toolbar
!= NULL
) {
332 g_slist_foreach(g_main_window_list
,
333 (gpointer
)remove_toolbar_constructor
,
335 lttv_toolbars_remove(toolbar
, view_constructor
);
338 g_assert(lttv_iattribute_find_by_path(attributes_global
,
339 "viewers/menu", LTTV_POINTER
, &value
));
340 menu
= (LttvMenus
*)*(value
.v_pointer
);
343 g_slist_foreach(g_main_window_list
,
344 (gpointer
)remove_menu_constructor
,
346 lttv_menus_remove(menu
, view_constructor
);
350 LttvAttribute
*attribute
;
352 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
353 LTTV_IATTRIBUTE(attributes_global
),
354 LTTV_VIEWER_CONSTRUCTORS
)));
356 guint num
= lttv_iattribute_get_number(LTTV_IATTRIBUTE(attribute
));
358 LttvAttributeName name
;
359 LttvAttributeValue value
;
360 LttvAttributeType type
;
363 type
= lttv_iattribute_get(LTTV_IATTRIBUTE(attribute
), i
, &name
, &value
);
364 g_assert(type
== LTTV_POINTER
);
365 if(*(value
.v_pointer
) == view_constructor
) {
366 lttv_iattribute_remove(LTTV_IATTRIBUTE(attribute
), i
);
375 * Function to register a hook function for a viewer to set/update its
377 * @param tab viewer's tab
378 * @param hook hook function of the viewer.
379 * @param hook_data hook data associated with the hook function.
381 void lttvwindow_register_time_window_notify(Tab
*tab
,
382 LttvHook hook
, gpointer hook_data
)
384 LttvAttributeValue value
;
386 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
387 "hooks/updatetimewindow", LTTV_POINTER
, &value
));
388 tmp
= (LttvHooks
*)*(value
.v_pointer
);
390 tmp
= lttv_hooks_new();
391 *(value
.v_pointer
) = tmp
;
393 lttv_hooks_add(tmp
, hook
,hook_data
, LTTV_PRIO_DEFAULT
);
398 * Function to unregister a viewer's hook function which is used to
399 * set/update the time interval of the viewer.
400 * @param tab viewer's tab
401 * @param hook hook function of the viewer.
402 * @param hook_data hook data associated with the hook function.
405 void lttvwindow_unregister_time_window_notify(Tab
*tab
,
406 LttvHook hook
, gpointer hook_data
)
408 LttvAttributeValue value
;
410 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
411 "hooks/updatetimewindow", LTTV_POINTER
, &value
));
412 tmp
= (LttvHooks
*)*(value
.v_pointer
);
413 if(tmp
== NULL
) return;
414 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
418 * Function to register a hook function for a viewer to set/update its
420 * @param tab viewer's tab
421 * @param hook hook function of the viewer.
422 * @param hook_data hook data associated with the hook function.
425 void lttvwindow_register_traceset_notify(Tab
*tab
,
426 LttvHook hook
, gpointer hook_data
)
428 LttvAttributeValue value
;
430 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
431 "hooks/updatetraceset", LTTV_POINTER
, &value
));
432 tmp
= (LttvHooks
*)*(value
.v_pointer
);
434 tmp
= lttv_hooks_new();
435 *(value
.v_pointer
) = tmp
;
437 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
442 * Function to unregister a viewer's hook function which is used to
443 * set/update the traceset of the viewer.
444 * @param tab viewer's tab
445 * @param hook hook function of the viewer.
446 * @param hook_data hook data associated with the hook function.
449 void lttvwindow_unregister_traceset_notify(Tab
*tab
,
450 LttvHook hook
, gpointer hook_data
)
452 LttvAttributeValue value
;
454 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
455 "hooks/updatetraceset", LTTV_POINTER
, &value
));
456 tmp
= (LttvHooks
*)*(value
.v_pointer
);
457 if(tmp
== NULL
) return;
458 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
462 * Function to register a hook function for a viewer be completely redrawn.
464 * @param tab viewer's tab
465 * @param hook hook function of the viewer.
466 * @param hook_data hook data associated with the hook function.
469 void lttvwindow_register_redraw_notify(Tab
*tab
,
470 LttvHook hook
, gpointer hook_data
)
472 LttvAttributeValue value
;
474 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
475 "hooks/redraw", LTTV_POINTER
, &value
));
476 tmp
= (LttvHooks
*)*(value
.v_pointer
);
478 tmp
= lttv_hooks_new();
479 *(value
.v_pointer
) = tmp
;
481 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
486 * Function to unregister a hook function for a viewer be completely redrawn.
488 * @param tab viewer's tab
489 * @param hook hook function of the viewer.
490 * @param hook_data hook data associated with the hook function.
493 void lttvwindow_unregister_redraw_notify(Tab
*tab
,
494 LttvHook hook
, gpointer hook_data
)
496 LttvAttributeValue value
;
498 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
499 "hooks/redraw", LTTV_POINTER
, &value
));
500 tmp
= (LttvHooks
*)*(value
.v_pointer
);
501 if(tmp
== NULL
) return;
502 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
506 * Function to register a hook function for a viewer to re-do the events
507 * requests for the needed interval.
509 * This action is typically done after a "stop".
511 * The typical hook will remove all current requests for the viewer
512 * and make requests for missing information.
514 * @param tab viewer's tab
515 * @param hook hook function of the viewer.
516 * @param hook_data hook data associated with the hook function.
519 void lttvwindow_register_continue_notify(Tab
*tab
,
520 LttvHook hook
, gpointer hook_data
)
522 LttvAttributeValue value
;
524 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
525 "hooks/continue", LTTV_POINTER
, &value
));
526 tmp
= (LttvHooks
*)*(value
.v_pointer
);
528 tmp
= lttv_hooks_new();
529 *(value
.v_pointer
) = tmp
;
531 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
536 * Function to unregister a hook function for a viewer to re-do the events
537 * requests for the needed interval.
539 * @param tab viewer's tab
540 * @param hook hook function of the viewer.
541 * @param hook_data hook data associated with the hook function.
544 void lttvwindow_unregister_continue_notify(Tab
*tab
,
545 LttvHook hook
, gpointer hook_data
)
547 LttvAttributeValue value
;
549 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
550 "hooks/continue", LTTV_POINTER
, &value
));
551 tmp
= (LttvHooks
*)*(value
.v_pointer
);
552 if(tmp
== NULL
) return;
553 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
558 * Function to register a hook function for a viewer to set/update its
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.
565 void lttvwindow_register_filter_notify(Tab
*tab
,
566 LttvHook hook
, gpointer hook_data
)
568 LttvAttributeValue value
;
570 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
571 "hooks/updatefilter", LTTV_POINTER
, &value
));
572 tmp
= (LttvHooks
*)*(value
.v_pointer
);
574 tmp
= lttv_hooks_new();
575 *(value
.v_pointer
) = tmp
;
577 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
582 * Function to unregister a viewer's hook function which is used to
583 * set/update the filter of the viewer.
584 * @param tab viewer's tab
585 * @param hook hook function of the viewer.
586 * @param hook_data hook data associated with the hook function.
589 void lttvwindow_unregister_filter_notify(Tab
*tab
,
593 LttvAttributeValue value
;
595 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
596 "hooks/updatefilter", LTTV_POINTER
, &value
));
597 tmp
= (LttvHooks
*)*(value
.v_pointer
);
598 if(tmp
== NULL
) return;
599 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
603 * Function to register a hook function for a viewer to set/update its
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.
610 void lttvwindow_register_current_time_notify(Tab
*tab
,
611 LttvHook hook
, gpointer hook_data
)
613 LttvAttributeValue value
;
615 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
616 "hooks/updatecurrenttime", LTTV_POINTER
, &value
));
617 tmp
= (LttvHooks
*)*(value
.v_pointer
);
619 tmp
= lttv_hooks_new();
620 *(value
.v_pointer
) = tmp
;
622 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
627 * Function to unregister a viewer's hook function which is used to
628 * set/update the current time of the viewer.
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.
634 void lttvwindow_unregister_current_time_notify(Tab
*tab
,
635 LttvHook hook
, gpointer hook_data
)
637 LttvAttributeValue value
;
639 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
640 "hooks/updatecurrenttime", LTTV_POINTER
, &value
));
641 tmp
= (LttvHooks
*)*(value
.v_pointer
);
642 if(tmp
== NULL
) return;
643 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
648 * Function to register a hook function for a viewer to show
649 * the content 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.
655 void lttvwindow_register_show_notify(Tab
*tab
,
656 LttvHook hook
, gpointer hook_data
)
658 LttvAttributeValue value
;
660 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
661 "hooks/showviewer", LTTV_POINTER
, &value
));
662 tmp
= (LttvHooks
*)*(value
.v_pointer
);
664 tmp
= lttv_hooks_new();
665 *(value
.v_pointer
) = tmp
;
667 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
672 * Function to unregister a viewer's hook function which is used to
673 * show the content of the viewer..
674 * @param tab viewer's tab
675 * @param hook hook function of the viewer.
676 * @param hook_data hook data associated with the hook function.
679 void lttvwindow_unregister_show_notify(Tab
*tab
,
680 LttvHook hook
, gpointer hook_data
)
682 LttvAttributeValue value
;
684 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
685 "hooks/showviewer", LTTV_POINTER
, &value
));
686 tmp
= (LttvHooks
*)*(value
.v_pointer
);
687 if(tmp
== NULL
) return;
688 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
692 * Function to register a hook function for a viewer to set/update the
693 * dividor of the hpane.
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.
699 void lttvwindow_register_dividor(Tab
*tab
,
700 LttvHook hook
, gpointer hook_data
)
702 LttvAttributeValue value
;
704 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
705 "hooks/hpanedividor", LTTV_POINTER
, &value
));
706 tmp
= (LttvHooks
*)*(value
.v_pointer
);
708 tmp
= lttv_hooks_new();
709 *(value
.v_pointer
) = tmp
;
711 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
716 * Function to unregister a viewer's hook function which is used to
717 * set/update hpane's dividor of the viewer.
718 * It will be called by the destructor of the viewer.
719 * @param tab viewer's tab
720 * @param hook hook function of the viewer.
721 * @param hook_data hook data associated with the hook function.
724 void lttvwindow_unregister_dividor(Tab
*tab
,
725 LttvHook hook
, gpointer hook_data
)
727 LttvAttributeValue value
;
729 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
730 "hooks/hpanedividor", LTTV_POINTER
, &value
));
731 tmp
= (LttvHooks
*)*(value
.v_pointer
);
732 if(tmp
== NULL
) return;
733 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
738 * Function to set the time interval of the current tab.
739 * It will be called by a viewer's signal handle associated with
740 * the move_slider signal
741 * @param tab viewer's tab
742 * @param time_interval a pointer where time interval is stored.
745 void lttvwindow_report_time_window(Tab
*tab
,
746 TimeWindow time_window
)
748 //set_time_window(tab, time_window);
749 //set_time_window_adjustment(tab, time_window);
751 time_change_manager(tab
, time_window
);
756 LttvTracesetContext
*tsc
=
757 LTTV_TRACESET_CONTEXT(tab
->traceset_info
->traceset_context
);
758 TimeInterval time_span
= tsc
->time_span
;
759 GtkAdjustment
*adjustment
= gtk_range_get_adjustment(GTK_RANGE(tab
->scrollbar
));
760 g_object_set(G_OBJECT(adjustment
),
765 ltt_time_sub(time_span
.end_time
, time_span
.start_time
))
768 ltt_time_to_double(time_window
->time_width
)
769 / SCROLL_STEP_PER_PAGE
770 , /* step increment */
772 ltt_time_to_double(time_window
->time_width
)
773 , /* page increment */
775 ltt_time_to_double(time_window
->time_width
)
778 gtk_adjustment_changed(adjustment
);
780 //g_object_set(G_OBJECT(adjustment),
782 // ltt_time_to_double(time_window->start_time)
785 /* Note : the set value will call set_time_window if scrollbar value changed
787 gtk_adjustment_set_value(adjustment
,
789 ltt_time_sub(time_window
->start_time
,
790 time_span
.start_time
))
797 * Function to set the current time/event of the current tab.
798 * It will be called by a viewer's signal handle associated with
799 * the button-release-event signal
800 * @param tab viewer's tab
801 * @param time a pointer where time is stored.
804 void lttvwindow_report_current_time(Tab
*tab
,
807 LttvAttributeValue value
;
810 current_time_change_manager(tab
, time
);
814 * Function to set the position of the hpane's dividor (viewer).
815 * It will be called by a viewer's signal handle associated with
816 * the motion_notify_event event/signal
817 * @param tab viewer's tab
818 * @param position position of the hpane's dividor.
821 void lttvwindow_report_dividor(Tab
*tab
, gint position
)
823 LttvAttributeValue value
;
825 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
826 "hooks/hpanedividor", LTTV_POINTER
, &value
));
827 tmp
= (LttvHooks
*)*(value
.v_pointer
);
828 if(tmp
== NULL
) return;
829 lttv_hooks_call(tmp
, &position
);
833 * Function to request data in a specific time interval to the main window. The
834 * event request servicing is differed until the glib idle functions are
837 * The viewer has to provide hooks that should be associated with the event
840 * Either start time or start position must be defined in a EventRequest
841 * structure for it to be valid.
843 * end_time, end_position and num_events can all be defined. The first one
844 * to occur will be used as end criterion.
846 * @param tab viewer's tab
847 * @param events_requested the structure of request from.
850 void lttvwindow_events_request(Tab
*tab
,
851 EventsRequest
*events_request
)
853 tab
->events_requests
= g_slist_append(tab
->events_requests
, events_request
);
855 if(!tab
->events_request_pending
)
857 /* Redraw has +20 priority. We want to let the redraw be done while we do
859 g_idle_add_full((G_PRIORITY_HIGH_IDLE
+ 21),
860 (GSourceFunc
)execute_events_requests
,
863 tab
->events_request_pending
= TRUE
;
869 * Function to remove data requests related to a viewer.
871 * The existing requests's viewer gpointer is compared to the pointer
872 * given in argument to establish which data request should be removed.
874 * @param tab the tab the viewer belongs to.
875 * @param viewer a pointer to the viewer data structure
878 gint
find_viewer (const EventsRequest
*a
, gconstpointer b
)
880 return (a
->owner
!= b
);
884 void lttvwindow_events_request_remove_all(Tab
*tab
,
885 gconstpointer viewer
)
887 GSList
*element
= tab
->events_requests
;
890 g_slist_find_custom(element
, viewer
,
891 (GCompareFunc
)find_viewer
))
893 EventsRequest
*events_request
= (EventsRequest
*)element
->data
;
894 // Modified so a viewer being destroyed won't have its after_request
895 // called. Not so important anyway. Note that a viewer that call this
896 // remove_all function will not get its after_request called.
897 //if(events_request->servicing == TRUE) {
898 // lttv_hooks_call(events_request->after_request, NULL);
900 events_request_free(events_request
);
901 //g_free(events_request);
902 tab
->events_requests
= g_slist_remove_link(tab
->events_requests
, element
);
903 element
= g_slist_next(element
);
904 if(element
== NULL
) break; /* end of list */
906 if(g_slist_length(tab
->events_requests
) == 0) {
907 tab
->events_request_pending
= FALSE
;
908 g_idle_remove_by_data(tab
);
914 * Function to get the current time interval shown on the current tab.
915 * It will be called by a viewer's hook function to update the
916 * shown time interval of the viewer and also be called by the constructor
918 * @param tab viewer's tab
919 * @return time window.
922 TimeWindow
lttvwindow_get_time_window(Tab
*tab
)
924 return tab
->time_window
;
929 * Function to get the current time/event of the current tab.
930 * It will be called by a viewer's hook function to update the
931 * current time/event of the viewer.
932 * @param tab viewer's tab
936 LttTime
lttvwindow_get_current_time(Tab
*tab
)
938 return tab
->current_time
;
943 * Function to get the filter of the current tab.
944 * @param main_win, the main window the viewer belongs to.
945 * @param filter, a pointer to a filter.
948 LttvFilter
*lttvwindow_get_filter(Tab
*tab
)
954 * Function to set the filter of the current tab.
955 * It should be called by the filter GUI to tell the
956 * main window to update the filter tab's lttv_filter.
958 * This function does change the current filter, removing the
959 * old one when necessary, and call the updatefilter hooks
960 * of the registered viewers.
962 * @param main_win, the main window the viewer belongs to.
963 * @param filter, a pointer to a filter.
966 void lttvwindow_report_filter(Tab
*tab
, LttvFilter
*filter
)
968 LttvAttributeValue value
;
971 lttv_filter_destroy(tab
->filter
);
972 tab
->filter
= filter
;
974 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
975 "hooks/updatefilter", LTTV_POINTER
, &value
));
976 tmp
= (LttvHooks
*)*(value
.v_pointer
);
977 if(tmp
== NULL
) return;
978 lttv_hooks_call(tmp
, filter
);
984 * Function to get the stats of the traceset
985 * @param tab viewer's tab
988 LttvTracesetStats
* lttvwindow_get_traceset_stats(Tab
*tab
)
990 return tab
->traceset_info
->traceset_context
;
994 LttvTracesetContext
* lttvwindow_get_traceset_context(Tab
*tab
)
996 return (LttvTracesetContext
*)tab
->traceset_info
->traceset_context
;
1000 void events_request_free(EventsRequest
*events_request
)
1002 if(events_request
== NULL
) return;
1004 if(events_request
->start_position
!= NULL
)
1005 lttv_traceset_context_position_destroy(events_request
->start_position
);
1006 if(events_request
->end_position
!= NULL
)
1007 lttv_traceset_context_position_destroy(events_request
->end_position
);
1008 if(events_request
->hooks
!= NULL
) {
1010 GArray
*hooks
= events_request
->hooks
;
1011 for(i
=0;i
<hooks
->len
;i
++) {
1012 lttv_trace_hook_destroy(&g_array_index(hooks
, LttvTraceHook
, i
));
1014 g_array_free(events_request
->hooks
, TRUE
);
1016 if(events_request
->before_chunk_traceset
!= NULL
)
1017 lttv_hooks_destroy(events_request
->before_chunk_traceset
);
1018 if(events_request
->before_chunk_trace
!= NULL
)
1019 lttv_hooks_destroy(events_request
->before_chunk_trace
);
1020 if(events_request
->before_chunk_tracefile
!= NULL
)
1021 lttv_hooks_destroy(events_request
->before_chunk_tracefile
);
1022 if(events_request
->event
!= NULL
)
1023 lttv_hooks_destroy(events_request
->event
);
1024 if(events_request
->event_by_id
!= NULL
)
1025 lttv_hooks_by_id_destroy(events_request
->event_by_id
);
1026 if(events_request
->after_chunk_tracefile
!= NULL
)
1027 lttv_hooks_destroy(events_request
->after_chunk_tracefile
);
1028 if(events_request
->after_chunk_trace
!= NULL
)
1029 lttv_hooks_destroy(events_request
->after_chunk_trace
);
1030 if(events_request
->after_chunk_traceset
!= NULL
)
1031 lttv_hooks_destroy(events_request
->after_chunk_traceset
);
1032 if(events_request
->before_request
!= NULL
)
1033 lttv_hooks_destroy(events_request
->before_request
);
1034 if(events_request
->after_request
!= NULL
)
1035 lttv_hooks_destroy(events_request
->after_request
);
1037 g_free(events_request
);