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>
39 #include <lttv/stats.h>
40 #endif /* BABEL_CLEANUP */
41 #include <lttvwindow/mainwindow.h>
42 #include <lttvwindow/mainwindow-private.h>
43 #include <lttvwindow/lttvwindow.h>
44 #include <lttvwindow/toolbar.h>
45 #include <lttvwindow/menu.h>
46 #include <lttvwindow/callbacks.h> // for execute_events_requests
47 #include <lttvwindow/support.h>
50 * Internal function parts
53 extern GSList
* g_main_window_list
;
55 __EXPORT gint lttvwindow_preempt_count
= 0;
59 * It updates the time window of the tab, then calls the updatetimewindow
60 * hooks of each viewer.
62 * This is called whenever the scrollbar value changes.
65 void set_time_window(Tab
*tab
, const TimeWindow
*time_window
)
67 LttvAttributeValue value
;
71 TimeWindowNotifyData time_window_notify_data
;
72 TimeWindow old_time_window
= tab
->time_window
;
73 time_window_notify_data
.old_time_window
= &old_time_window
;
74 tab
->time_window
= *time_window
;
75 time_window_notify_data
.new_time_window
=
78 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
79 "hooks/updatetimewindow", LTTV_POINTER
, &value
);
81 tmp
= (LttvHooks
*)*(value
.v_pointer
);
82 if(tmp
!= NULL
) lttv_hooks_call(tmp
, &time_window_notify_data
);
84 //gtk_multi_vpaned_set_adjust(tab->multi_vpaned, new_time_window, FALSE);
90 * It updates the current time of the tab, then calls the updatetimewindow
91 * hooks of each viewer.
93 * This is called whenever the current time value changes.
96 void set_current_time(Tab
*tab
, const LttTime
*current_time
)
98 LttvAttributeValue value
;
102 tab
->current_time
= *current_time
;
104 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
105 "hooks/updatecurrenttime", LTTV_POINTER
, &value
);
107 tmp
= (LttvHooks
*)*(value
.v_pointer
);
108 if(tmp
!= NULL
) lttv_hooks_call(tmp
, &tab
->current_time
);
111 /* set_current_position
113 * It updates the current time of the tab, then calls the updatetimewindow
114 * hooks of each viewer.
116 * This is called whenever the current time value changes.
119 void set_current_position(Tab
*tab
, const LttvTracesetPosition
*pos
)
123 LttvAttributeValue value
;
127 tab
->current_time
= lttv_traceset_context_position_get_time(pos
);
129 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
130 "hooks/updatecurrentposition", LTTV_POINTER
, &value
);
132 tmp
= (LttvHooks
*)*(value
.v_pointer
);
134 lttv_hooks_call(tmp
, (void *) pos
);
136 #endif /*BABEL_CLEANUP*/
139 void add_toolbar_constructor(MainWindow
*mw
, LttvToolbarClosure
*toolbar_c
)
141 LttvIAttribute
*attributes
= mw
->attributes
;
142 LttvAttributeValue value
;
143 LttvToolbars
* instance_toolbar
;
144 lttvwindow_viewer_constructor constructor
;
145 GtkWidget
* tool_menu_title_menu
, *new_widget
, *pixmap
;
149 retval
= lttv_iattribute_find_by_path(attributes
, "viewers/toolbar",
150 LTTV_POINTER
, &value
);
152 if(*(value
.v_pointer
) == NULL
)
153 *(value
.v_pointer
) = lttv_toolbars_new();
154 instance_toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
156 constructor
= toolbar_c
->con
;
157 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"MToolbar1");
158 pixbuf
= gdk_pixbuf_new_from_xpm_data((const char**)toolbar_c
->pixmap
);
159 pixmap
= gtk_image_new_from_pixbuf(pixbuf
);
161 gtk_toolbar_append_element (GTK_TOOLBAR (tool_menu_title_menu
),
162 GTK_TOOLBAR_CHILD_BUTTON
,
165 toolbar_c
->tooltip
, NULL
,
167 gtk_label_set_use_underline(
168 GTK_LABEL (((GtkToolbarChild
*) (
169 g_list_last (GTK_TOOLBAR
170 (tool_menu_title_menu
)->children
)->data
))->label
),
172 gtk_container_set_border_width (GTK_CONTAINER (new_widget
), 1);
173 g_signal_connect ((gpointer
) new_widget
,
175 G_CALLBACK (insert_viewer_wrap
),
177 gtk_widget_show (new_widget
);
179 lttv_toolbars_add(instance_toolbar
, toolbar_c
->con
,
186 void add_menu_constructor(MainWindow
*mw
, LttvMenuClosure
*menu_c
)
188 LttvIAttribute
*attributes
= mw
->attributes
;
189 LttvAttributeValue value
;
190 LttvToolbars
* instance_menu
;
191 lttvwindow_viewer_constructor constructor
;
192 GtkWidget
* tool_menu_title_menu
, *new_widget
;
195 retval
= lttv_iattribute_find_by_path(attributes
, "viewers/menu",
196 LTTV_POINTER
, &value
);
198 if(*(value
.v_pointer
) == NULL
)
199 *(value
.v_pointer
) = lttv_menus_new();
200 instance_menu
= (LttvMenus
*)*(value
.v_pointer
);
203 constructor
= menu_c
->con
;
204 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"ToolMenuTitle_menu");
206 gtk_menu_item_new_with_mnemonic (menu_c
->menu_text
);
207 gtk_container_add (GTK_CONTAINER (tool_menu_title_menu
),
209 g_signal_connect ((gpointer
) new_widget
, "activate",
210 G_CALLBACK (insert_viewer_wrap
),
212 gtk_widget_show (new_widget
);
213 lttv_menus_add(instance_menu
, menu_c
->con
,
219 void remove_toolbar_constructor(MainWindow
*mw
, lttvwindow_viewer_constructor viewer_constructor
)
221 LttvIAttribute
*attributes
= mw
->attributes
;
222 LttvAttributeValue value
;
223 LttvToolbars
* instance_toolbar
;
224 GtkWidget
* tool_menu_title_menu
, *widget
;
227 retval
= lttv_iattribute_find_by_path(attributes
, "viewers/toolbar",
228 LTTV_POINTER
, &value
);
230 if(*(value
.v_pointer
) == NULL
)
231 *(value
.v_pointer
) = lttv_toolbars_new();
232 instance_toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
234 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"MToolbar1");
235 widget
= lttv_menus_remove(instance_toolbar
, viewer_constructor
);
236 gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu
),
241 void remove_menu_constructor(MainWindow
*mw
, lttvwindow_viewer_constructor viewer_constructor
)
243 LttvIAttribute
*attributes
= mw
->attributes
;
244 LttvAttributeValue value
;
245 LttvMenus
* instance_menu
;
246 GtkWidget
* tool_menu_title_menu
, *widget
;
249 retval
= lttv_iattribute_find_by_path(attributes
, "viewers/menu",
250 LTTV_POINTER
, &value
);
252 if(*(value
.v_pointer
) == NULL
)
253 *(value
.v_pointer
) = lttv_menus_new();
254 instance_menu
= (LttvMenus
*)*(value
.v_pointer
);
256 widget
= lttv_menus_remove(instance_menu
, viewer_constructor
);
257 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"ToolMenuTitle_menu");
258 gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu
), widget
);
268 * Function to register a view constructor so that main window can generate
269 * a menu item and a toolbar item for the viewer in order to generate a new
270 * instance easily. A menu entry and toolbar item will be added to each main
273 * It should be called by init function of the module.
275 * @param name name of the viewer
276 * @param menu_path path of the menu item.
277 * @param menu_text text of the menu item.
278 * @param pixmap Image shown on the toolbar item.
279 * @param tooltip tooltip of the toolbar item.
280 * @param view_constructor constructor of the viewer.
283 __EXPORT
void lttvwindow_register_constructor
289 lttvwindow_viewer_constructor view_constructor
)
291 LttvIAttribute
*attributes_global
= LTTV_IATTRIBUTE(lttv_global_attributes());
292 LttvToolbars
* toolbar
;
294 LttvToolbarClosure toolbar_c
;
295 LttvMenuClosure menu_c
;
296 LttvAttributeValue value
;
299 if(view_constructor
== NULL
) return;
302 retval
= lttv_iattribute_find_by_path(attributes_global
, "viewers/toolbar",
303 LTTV_POINTER
, &value
);
305 toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
307 if(toolbar
== NULL
) {
308 toolbar
= lttv_toolbars_new();
309 *(value
.v_pointer
) = toolbar
;
311 toolbar_c
= lttv_toolbars_add(toolbar
, view_constructor
, tooltip
, pixmap
,
314 g_slist_foreach(g_main_window_list
,
315 (gpointer
)add_toolbar_constructor
,
319 if(menu_path
!= NULL
) {
320 retval
= lttv_iattribute_find_by_path(attributes_global
, "viewers/menu",
321 LTTV_POINTER
, &value
);
323 menu
= (LttvMenus
*)*(value
.v_pointer
);
326 menu
= lttv_menus_new();
327 *(value
.v_pointer
) = menu
;
329 menu_c
= lttv_menus_add(menu
, view_constructor
, menu_path
, menu_text
,NULL
);
331 g_slist_foreach(g_main_window_list
,
332 (gpointer
)add_menu_constructor
,
336 LttvAttribute
*attribute
;
339 attribute
= LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
340 LTTV_IATTRIBUTE(attributes_global
),
341 LTTV_VIEWER_CONSTRUCTORS
));
344 result
= lttv_iattribute_find_by_path(LTTV_IATTRIBUTE(attribute
),
345 name
, LTTV_POINTER
, &value
);
348 *(value
.v_pointer
) = view_constructor
;
355 * Function to unregister the viewer's constructor, release the space
356 * occupied by menu_path, menu_text, pixmap, tooltip and constructor of the
359 * It will be called when a module is unloaded.
361 * @param view_constructor constructor of the viewer.
365 __EXPORT
void lttvwindow_unregister_constructor
366 (lttvwindow_viewer_constructor view_constructor
)
368 LttvIAttribute
*attributes_global
= LTTV_IATTRIBUTE(lttv_global_attributes());
369 LttvToolbars
* toolbar
;
371 LttvAttributeValue value
;
375 retval
= lttv_iattribute_find_by_path(attributes_global
, "viewers/toolbar",
376 LTTV_POINTER
, &value
);
378 toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
380 if(toolbar
!= NULL
) {
381 g_slist_foreach(g_main_window_list
,
382 (gpointer
)remove_toolbar_constructor
,
384 lttv_toolbars_remove(toolbar
, view_constructor
);
387 retval
= lttv_iattribute_find_by_path(attributes_global
, "viewers/menu",
388 LTTV_POINTER
, &value
);
390 menu
= (LttvMenus
*)*(value
.v_pointer
);
393 g_slist_foreach(g_main_window_list
,
394 (gpointer
)remove_menu_constructor
,
396 lttv_menus_remove(menu
, view_constructor
);
400 LttvAttribute
*attribute
;
401 attribute
= LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
402 LTTV_IATTRIBUTE(attributes_global
),
403 LTTV_VIEWER_CONSTRUCTORS
));
406 guint num
= lttv_iattribute_get_number(LTTV_IATTRIBUTE(attribute
));
408 LttvAttributeName name
;
409 LttvAttributeValue value
;
410 LttvAttributeType type
;
413 type
= lttv_iattribute_get(LTTV_IATTRIBUTE(attribute
), i
, &name
, &value
,
415 g_assert(type
== LTTV_POINTER
);
416 if(*(value
.v_pointer
) == view_constructor
) {
417 lttv_iattribute_remove(LTTV_IATTRIBUTE(attribute
), i
);
426 * Function to register a hook function for a viewer to set/update its
428 * @param tab viewer's tab
429 * @param hook hook function of the viewer.
430 * @param hook_data hook data associated with the hook function.
432 __EXPORT
void lttvwindow_register_time_window_notify(Tab
*tab
,
433 LttvHook hook
, gpointer hook_data
)
435 LttvAttributeValue value
;
439 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
440 "hooks/updatetimewindow", LTTV_POINTER
, &value
);
442 tmp
= (LttvHooks
*)*(value
.v_pointer
);
444 tmp
= lttv_hooks_new();
445 *(value
.v_pointer
) = tmp
;
447 lttv_hooks_add(tmp
, hook
,hook_data
, LTTV_PRIO_DEFAULT
);
452 * Function to unregister a viewer's hook function which is used to
453 * set/update the time interval of the viewer.
454 * @param tab viewer's tab
455 * @param hook hook function of the viewer.
456 * @param hook_data hook data associated with the hook function.
459 __EXPORT
void lttvwindow_unregister_time_window_notify(Tab
*tab
,
460 LttvHook hook
, gpointer hook_data
)
462 LttvAttributeValue value
;
466 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
467 "hooks/updatetimewindow", LTTV_POINTER
, &value
);
469 tmp
= (LttvHooks
*)*(value
.v_pointer
);
470 if(tmp
== NULL
) return;
471 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
475 * Function to register a hook function for a viewer to set/update its
477 * @param tab viewer's tab
478 * @param hook hook function of the viewer.
479 * @param hook_data hook data associated with the hook function.
481 __EXPORT
void lttvwindow_register_timespan_notify(Tab
*tab
,
482 LttvHook hook
, gpointer hook_data
)
484 LttvAttributeValue value
;
488 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
489 "hooks/updatetimespan", LTTV_POINTER
, &value
);
491 tmp
= (LttvHooks
*)*(value
.v_pointer
);
493 tmp
= lttv_hooks_new();
494 *(value
.v_pointer
) = tmp
;
496 lttv_hooks_add(tmp
, hook
,hook_data
, LTTV_PRIO_DEFAULT
);
499 * Function to unregister a viewer's hook function which is used to
500 * set/update the time span allowed for the viewer.
501 * @param tab viewer's tab
502 * @param hook hook function of the viewer.
503 * @param hook_data hook data associated with the hook function.
506 __EXPORT
void lttvwindow_unregister_timespan_notify(Tab
*tab
,
507 LttvHook hook
, gpointer hook_data
)
509 LttvAttributeValue value
;
513 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
514 "hooks/updatetimespan", LTTV_POINTER
, &value
);
516 tmp
= (LttvHooks
*)*(value
.v_pointer
);
517 if(tmp
== NULL
) return;
518 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
522 * Function to register a hook function for a viewer to set/update its
524 * @param tab viewer's tab
525 * @param hook hook function of the viewer.
526 * @param hook_data hook data associated with the hook function.
529 __EXPORT
void lttvwindow_register_traceset_notify(Tab
*tab
,
530 LttvHook hook
, gpointer hook_data
)
532 LttvAttributeValue value
;
536 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
537 "hooks/updatetraceset", LTTV_POINTER
, &value
);
539 tmp
= (LttvHooks
*)*(value
.v_pointer
);
541 tmp
= lttv_hooks_new();
542 *(value
.v_pointer
) = tmp
;
544 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
549 * Function to unregister a viewer's hook function which is used to
550 * set/update the traceset of the viewer.
551 * @param tab viewer's tab
552 * @param hook hook function of the viewer.
553 * @param hook_data hook data associated with the hook function.
556 __EXPORT
void lttvwindow_unregister_traceset_notify(Tab
*tab
,
557 LttvHook hook
, gpointer hook_data
)
559 LttvAttributeValue value
;
563 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
564 "hooks/updatetraceset", LTTV_POINTER
, &value
);
566 tmp
= (LttvHooks
*)*(value
.v_pointer
);
567 if(tmp
== NULL
) return;
568 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
572 * Function to register a hook function for a viewer be completely redrawn.
574 * @param tab viewer's tab
575 * @param hook hook function of the viewer.
576 * @param hook_data hook data associated with the hook function.
579 __EXPORT
void lttvwindow_register_redraw_notify(Tab
*tab
,
580 LttvHook hook
, gpointer hook_data
)
582 LttvAttributeValue value
;
586 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/redraw",
587 LTTV_POINTER
, &value
);
589 tmp
= (LttvHooks
*)*(value
.v_pointer
);
591 tmp
= lttv_hooks_new();
592 *(value
.v_pointer
) = tmp
;
594 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
599 * Function to unregister a hook function for a viewer be completely redrawn.
601 * @param tab viewer's tab
602 * @param hook hook function of the viewer.
603 * @param hook_data hook data associated with the hook function.
606 __EXPORT
void lttvwindow_unregister_redraw_notify(Tab
*tab
,
607 LttvHook hook
, gpointer hook_data
)
609 LttvAttributeValue value
;
613 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/redraw",
614 LTTV_POINTER
, &value
);
616 tmp
= (LttvHooks
*)*(value
.v_pointer
);
617 if(tmp
== NULL
) return;
618 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
622 * Function to register a hook function for a viewer to re-do the events
623 * requests for the needed interval.
625 * This action is typically done after a "stop".
627 * The typical hook will remove all current requests for the viewer
628 * and make requests for missing information.
630 * @param tab viewer's tab
631 * @param hook hook function of the viewer.
632 * @param hook_data hook data associated with the hook function.
635 __EXPORT
void lttvwindow_register_continue_notify(Tab
*tab
,
636 LttvHook hook
, gpointer hook_data
)
638 LttvAttributeValue value
;
642 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/continue",
643 LTTV_POINTER
, &value
);
645 tmp
= (LttvHooks
*)*(value
.v_pointer
);
647 tmp
= lttv_hooks_new();
648 *(value
.v_pointer
) = tmp
;
650 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
655 * Function to unregister a hook function for a viewer to re-do the events
656 * requests for the needed interval.
658 * @param tab viewer's tab
659 * @param hook hook function of the viewer.
660 * @param hook_data hook data associated with the hook function.
663 __EXPORT
void lttvwindow_unregister_continue_notify(Tab
*tab
,
664 LttvHook hook
, gpointer hook_data
)
666 LttvAttributeValue value
;
670 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/continue",
671 LTTV_POINTER
, &value
);
673 tmp
= (LttvHooks
*)*(value
.v_pointer
);
674 if(tmp
== NULL
) return;
675 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
680 * Function to register a hook function for a viewer to set/update its
682 * @param tab viewer's tab
683 * @param hook hook function of the viewer.
684 * @param hook_data hook data associated with the hook function.
687 __EXPORT
void lttvwindow_register_filter_notify(Tab
*tab
,
688 LttvHook hook
, gpointer hook_data
)
690 LttvAttributeValue value
;
694 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/updatefilter",
695 LTTV_POINTER
, &value
);
697 tmp
= (LttvHooks
*)*(value
.v_pointer
);
699 tmp
= lttv_hooks_new();
700 *(value
.v_pointer
) = tmp
;
702 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
707 * Function to unregister a viewer's hook function which is used to
708 * set/update the filter of the viewer.
709 * @param tab viewer's tab
710 * @param hook hook function of the viewer.
711 * @param hook_data hook data associated with the hook function.
714 __EXPORT
void lttvwindow_unregister_filter_notify(Tab
*tab
,
718 LttvAttributeValue value
;
722 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/updatefilter",
723 LTTV_POINTER
, &value
);
725 tmp
= (LttvHooks
*)*(value
.v_pointer
);
726 if(tmp
== NULL
) return;
727 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
731 * function to register a hook function for a viewer to set/update its
733 * @param tab viewer's tab
734 * @param hook hook function of the viewer.
735 * @param hook_data hook data associated with the hook function.
738 __EXPORT
void lttvwindow_register_current_time_notify(Tab
*tab
,
739 LttvHook hook
, gpointer hook_data
)
741 LttvAttributeValue value
;
745 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
746 "hooks/updatecurrenttime", LTTV_POINTER
, &value
);
748 tmp
= (LttvHooks
*)*(value
.v_pointer
);
750 tmp
= lttv_hooks_new();
751 *(value
.v_pointer
) = tmp
;
753 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
758 * function to unregister a viewer's hook function which is used to
759 * set/update the current time of the viewer.
760 * @param tab viewer's tab
761 * @param hook hook function of the viewer.
762 * @param hook_data hook data associated with the hook function.
765 __EXPORT
void lttvwindow_unregister_current_time_notify(Tab
*tab
,
766 LttvHook hook
, gpointer hook_data
)
768 LttvAttributeValue value
;
772 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
773 "hooks/updatecurrenttime", LTTV_POINTER
, &value
);
775 tmp
= (LttvHooks
*)*(value
.v_pointer
);
776 if(tmp
== NULL
) return;
777 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
781 * function to register a hook function for a viewer to set/update its
783 * @param tab viewer's tab
784 * @param hook hook function of the viewer.
785 * @param hook_data hook data associated with the hook function.
788 __EXPORT
void lttvwindow_register_current_position_notify(Tab
*tab
,
789 LttvHook hook
, gpointer hook_data
)
791 LttvAttributeValue value
;
795 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
796 "hooks/updatecurrentposition", LTTV_POINTER
, &value
);
798 tmp
= (LttvHooks
*)*(value
.v_pointer
);
800 tmp
= lttv_hooks_new();
801 *(value
.v_pointer
) = tmp
;
803 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
808 * function to unregister a viewer's hook function which is used to
809 * set/update the current position of the viewer.
810 * @param tab viewer's tab
811 * @param hook hook function of the viewer.
812 * @param hook_data hook data associated with the hook function.
815 __EXPORT
void lttvwindow_unregister_current_position_notify(Tab
*tab
,
816 LttvHook hook
, gpointer hook_data
)
818 LttvAttributeValue value
;
822 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
823 "hooks/updatecurrentposition", LTTV_POINTER
, &value
);
825 tmp
= (LttvHooks
*)*(value
.v_pointer
);
826 if(tmp
== NULL
) return;
827 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
832 * Function to register a hook function for a viewer to show
833 * the content of the viewer.
834 * @param tab viewer's tab
835 * @param hook hook function of the viewer.
836 * @param hook_data hook data associated with the hook function.
839 void lttvwindow_register_show_notify(Tab
*tab
,
840 LttvHook hook
, gpointer hook_data
)
842 LttvAttributeValue value
;
846 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/showviewer",
847 LTTV_POINTER
, &value
);
849 tmp
= (LttvHooks
*)*(value
.v_pointer
);
851 tmp
= lttv_hooks_new();
852 *(value
.v_pointer
) = tmp
;
854 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
859 * Function to unregister a viewer's hook function which is used to
860 * show the content of the viewer..
861 * @param tab viewer's tab
862 * @param hook hook function of the viewer.
863 * @param hook_data hook data associated with the hook function.
866 void lttvwindow_unregister_show_notify(Tab
*tab
,
867 LttvHook hook
, gpointer hook_data
)
869 LttvAttributeValue value
;
873 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/showviewer",
874 LTTV_POINTER
, &value
);
876 tmp
= (LttvHooks
*)*(value
.v_pointer
);
877 if(tmp
== NULL
) return;
878 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
882 * Function to register a hook function for a viewer to set/update the
883 * dividor of the hpane.
884 * @param tab viewer's tab
885 * @param hook hook function of the viewer.
886 * @param hook_data hook data associated with the hook function.
889 void lttvwindow_register_dividor(Tab
*tab
,
890 LttvHook hook
, gpointer hook_data
)
892 LttvAttributeValue value
;
896 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/hpanedividor",
897 LTTV_POINTER
, &value
);
899 tmp
= (LttvHooks
*)*(value
.v_pointer
);
901 tmp
= lttv_hooks_new();
902 *(value
.v_pointer
) = tmp
;
904 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
909 * Function to unregister a viewer's hook function which is used to
910 * set/update hpane's dividor of the viewer.
911 * It will be called by the destructor of the viewer.
912 * @param tab viewer's tab
913 * @param hook hook function of the viewer.
914 * @param hook_data hook data associated with the hook function.
917 void lttvwindow_unregister_dividor(Tab
*tab
,
918 LttvHook hook
, gpointer hook_data
)
920 LttvAttributeValue value
;
924 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/hpanedividor",
925 LTTV_POINTER
, &value
);
927 tmp
= (LttvHooks
*)*(value
.v_pointer
);
928 if(tmp
== NULL
) return;
929 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
934 * Function to set the time interval of the current tab.
935 * It will be called by a viewer's signal handle associated with
936 * the move_slider signal
937 * @param tab viewer's tab
938 * @param time_interval a pointer where time interval is stored.
941 __EXPORT
void lttvwindow_report_time_window(Tab
*tab
,
942 TimeWindow time_window
)
944 //set_time_window(tab, time_window);
945 //set_time_window_adjustment(tab, time_window);
947 time_change_manager(tab
, time_window
);
952 LttvTracesetContext
*tsc
=
953 LTTV_TRACESET_CONTEXT(tab
->traceset_info
->traceset_context
);
954 TimeInterval time_span
= tsc
->time_span
;
955 GtkAdjustment
*adjustment
= gtk_range_get_adjustment(GTK_RANGE(tab
->scrollbar
));
956 g_object_set(G_OBJECT(adjustment
),
961 ltt_time_sub(time_span
.end_time
, time_span
.start_time
))
964 ltt_time_to_double(time_window
->time_width
)
965 / SCROLL_STEP_PER_PAGE
966 , /* step increment */
968 ltt_time_to_double(time_window
->time_width
)
969 , /* page increment */
971 ltt_time_to_double(time_window
->time_width
)
974 gtk_adjustment_changed(adjustment
);
976 //g_object_set(G_OBJECT(adjustment),
978 // ltt_time_to_double(time_window->start_time)
981 /* Note : the set value will call set_time_window if scrollbar value changed
983 gtk_adjustment_set_value(adjustment
,
985 ltt_time_sub(time_window
->start_time
,
986 time_span
.start_time
))
993 * Function to set the current time of the current tab.
994 * It will be called by a viewer's signal handle associated with
995 * the button-release-event signal
996 * @param tab viewer's tab
997 * @param time a pointer where time is stored.
1000 __EXPORT
void lttvwindow_report_current_time(Tab
*tab
,
1003 current_time_change_manager(tab
, time
);
1007 * Function to set the current event of the current tab.
1008 * It will be called by a viewer's signal handle associated with
1009 * the button-release-event signal
1010 * @param tab viewer's tab
1011 * @param time a pointer where time is stored.
1014 __EXPORT
void lttvwindow_report_current_position(Tab
*tab
,
1015 LttvTracesetPosition
*pos
)
1017 current_position_change_manager(tab
, pos
);
1022 * Function to set the position of the hpane's dividor (viewer).
1023 * It will be called by a viewer's signal handle associated with
1024 * the motion_notify_event event/signal
1025 * @param tab viewer's tab
1026 * @param position position of the hpane's dividor.
1029 void lttvwindow_report_dividor(Tab
*tab
, gint position
)
1031 LttvAttributeValue value
;
1035 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/hpanedividor",
1036 LTTV_POINTER
, &value
);
1038 tmp
= (LttvHooks
*)*(value
.v_pointer
);
1039 if(tmp
== NULL
) return;
1040 lttv_hooks_call(tmp
, &position
);
1044 * Function to request data in a specific time interval to the main window. The
1045 * event request servicing is differed until the glib idle functions are
1048 * The viewer has to provide hooks that should be associated with the event
1051 * Either start time or start position must be defined in a EventRequest
1052 * structure for it to be valid.
1054 * end_time, end_position and num_events can all be defined. The first one
1055 * to occur will be used as end criterion.
1057 * @param tab viewer's tab
1058 * @param events_requested the structure of request from.
1061 __EXPORT
void lttvwindow_events_request(Tab
*tab
,
1062 EventsRequest
*events_request
)
1064 tab
->events_requests
= g_slist_append(tab
->events_requests
, events_request
);
1066 if(!tab
->events_request_pending
)
1068 /* Redraw has +20 priority. We want to let the redraw be done while we do
1069 * our job. Mathieu : test with high prio higher than events for better
1071 /* Mathieu, 2008 : ok, finally, the control flow view needs the cell updates
1072 * to come soon enough so we can have one active cell to get the pixmap
1073 * buffer height from. Therefore, let the gdk events run before the events
1076 g_idle_add_full((G_PRIORITY_HIGH_IDLE
+ 21),
1077 //g_idle_add_full((G_PRIORITY_DEFAULT + 2),
1078 (GSourceFunc
)execute_events_requests
,
1081 tab
->events_request_pending
= TRUE
;
1087 * Function to remove data requests related to a viewer.
1089 * The existing requests's viewer gpointer is compared to the pointer
1090 * given in argument to establish which data request should be removed.
1092 * @param tab the tab the viewer belongs to.
1093 * @param viewer a pointer to the viewer data structure
1096 gint
find_viewer (const EventsRequest
*a
, gconstpointer b
)
1098 return (a
->owner
!= b
);
1102 __EXPORT
void lttvwindow_events_request_remove_all(Tab
*tab
,
1103 gconstpointer viewer
)
1105 GSList
*element
= tab
->events_requests
;
1108 g_slist_find_custom(element
, viewer
,
1109 (GCompareFunc
)find_viewer
))
1111 EventsRequest
*events_request
= (EventsRequest
*)element
->data
;
1112 // Modified so a viewer being destroyed won't have its after_request
1113 // called. Not so important anyway. Note that a viewer that call this
1114 // remove_all function will not get its after_request called.
1115 //if(events_request->servicing == TRUE) {
1116 // lttv_hooks_call(events_request->after_request, NULL);
1118 events_request_free(events_request
);
1119 //g_free(events_request);
1120 tab
->events_requests
= g_slist_remove_link(tab
->events_requests
, element
);
1121 element
= g_slist_next(element
);
1122 if(element
== NULL
) break; /* end of list */
1124 if(g_slist_length(tab
->events_requests
) == 0) {
1125 tab
->events_request_pending
= FALSE
;
1126 g_idle_remove_by_data(tab
);
1133 * Function to see if there are events request pending.
1135 * It tells if events requests are pending. Useful for checks in some events,
1136 * i.e. detailed event list scrolling.
1138 * @param tab the tab the viewer belongs to.
1139 * @param viewer a pointer to the viewer data structure
1140 * @return : TRUE is events requests are pending, else FALSE.
1143 __EXPORT gboolean
lttvwindow_events_request_pending(Tab
*tab
)
1145 GSList
*element
= tab
->events_requests
;
1147 if(element
== NULL
) return FALSE
;
1153 * Function to get the current time interval shown on the current tab.
1154 * It will be called by a viewer's hook function to update the
1155 * shown time interval of the viewer and also be called by the constructor
1157 * @param tab viewer's tab
1158 * @return time window.
1161 __EXPORT TimeWindow
lttvwindow_get_time_window(Tab
*tab
)
1163 return tab
->time_window
;
1168 * Function to get the current time/event of the current tab.
1169 * It will be called by a viewer's hook function to update the
1170 * current time/event of the viewer.
1171 * @param tab viewer's tab
1175 __EXPORT LttTime
lttvwindow_get_current_time(Tab
*tab
)
1177 return tab
->current_time
;
1182 * Function to get the filter of the current tab.
1183 * @param filter, a pointer to a filter.
1185 * returns the current filter
1187 __EXPORT LttvFilter
*lttvwindow_get_filter(Tab
*tab
)
1189 return g_object_get_data(G_OBJECT(tab
->vbox
), "filter");
1193 * Function to set the filter of the current tab.
1194 * It should be called by the filter GUI to tell the
1195 * main window to update the filter tab's lttv_filter.
1197 * This function does change the current filter, removing the
1198 * old one when necessary, and call the updatefilter hooks
1199 * of the registered viewers.
1201 * @param main_win, the main window the viewer belongs to.
1202 * @param filter, a pointer to a filter.
1204 void lttvwindow_report_filter(Tab
*tab
, LttvFilter
*filter
)
1206 LttvAttributeValue value
;
1210 //lttv_filter_destroy(tab->filter);
1211 //tab->filter = filter;
1213 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/updatefilter",
1214 LTTV_POINTER
, &value
);
1216 tmp
= (LttvHooks
*)*(value
.v_pointer
);
1217 if(tmp
== NULL
) return;
1218 lttv_hooks_call(tmp
, filter
);
1221 #ifdef BABEL_CLEANUP
1224 * Function to get the stats of the traceset
1225 * @param tab viewer's tab
1228 __EXPORT LttvTracesetStats
* lttvwindow_get_traceset_stats(Tab
*tab
)
1230 return tab
->traceset_info
->traceset_context
;
1232 #endif /*BABEL_CLEANUP*/
1234 void events_request_free(EventsRequest
*events_request
)
1236 #ifdef BABEL_CLEANUP
1237 if(events_request
== NULL
) return;
1239 if(events_request
->start_position
!= NULL
)
1240 lttv_traceset_context_position_destroy(events_request
->start_position
);
1241 if(events_request
->end_position
!= NULL
)
1242 lttv_traceset_context_position_destroy(events_request
->end_position
);
1243 if(events_request
->hooks
!= NULL
) {
1244 GArray
*hooks
= events_request
->hooks
;
1245 lttv_trace_hook_remove_all(&hooks
);
1246 g_array_free(events_request
->hooks
, TRUE
);
1248 if(events_request
->before_chunk_traceset
!= NULL
)
1249 lttv_hooks_destroy(events_request
->before_chunk_traceset
);
1250 if(events_request
->before_chunk_trace
!= NULL
)
1251 lttv_hooks_destroy(events_request
->before_chunk_trace
);
1252 if(events_request
->before_chunk_tracefile
!= NULL
)
1253 lttv_hooks_destroy(events_request
->before_chunk_tracefile
);
1254 if(events_request
->event
!= NULL
)
1255 lttv_hooks_destroy(events_request
->event
);
1256 if(events_request
->event_by_id_channel
!= NULL
)
1257 lttv_hooks_by_id_channel_destroy(events_request
->event_by_id_channel
);
1258 if(events_request
->after_chunk_tracefile
!= NULL
)
1259 lttv_hooks_destroy(events_request
->after_chunk_tracefile
);
1260 if(events_request
->after_chunk_trace
!= NULL
)
1261 lttv_hooks_destroy(events_request
->after_chunk_trace
);
1262 if(events_request
->after_chunk_traceset
!= NULL
)
1263 lttv_hooks_destroy(events_request
->after_chunk_traceset
);
1264 if(events_request
->before_request
!= NULL
)
1265 lttv_hooks_destroy(events_request
->before_request
);
1266 if(events_request
->after_request
!= NULL
)
1267 lttv_hooks_destroy(events_request
->after_request
);
1269 g_free(events_request
);
1270 #endif /*BABEL_CLEANUP*/
1274 __EXPORT GtkWidget
*main_window_get_widget(Tab
*tab
)
1276 return tab
->mw
->mwindow
;