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/traceset.h>
40 #include <lttv/stats.h>
41 #endif /* BABEL_CLEANUP */
42 #include <lttvwindow/mainwindow.h>
43 #include <lttvwindow/mainwindow-private.h>
44 #include <lttvwindow/lttvwindow.h>
45 #include <lttvwindow/toolbar.h>
46 #include <lttvwindow/menu.h>
47 #include <lttvwindow/callbacks.h> // for execute_events_requests
48 #include <lttvwindow/support.h>
51 * Internal function parts
54 extern GSList
* g_main_window_list
;
56 __EXPORT gint lttvwindow_preempt_count
= 0;
60 * It updates the time window of the tab, then calls the updatetimewindow
61 * hooks of each viewer.
63 * This is called whenever the scrollbar value changes.
66 void set_time_window(Tab
*tab
, const TimeWindow
*time_window
)
68 LttvAttributeValue value
;
72 TimeWindowNotifyData time_window_notify_data
;
73 TimeWindow old_time_window
= tab
->time_window
;
74 time_window_notify_data
.old_time_window
= &old_time_window
;
75 tab
->time_window
= *time_window
;
76 time_window_notify_data
.new_time_window
=
79 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
80 "hooks/updatetimewindow", LTTV_POINTER
, &value
);
82 tmp
= (LttvHooks
*)*(value
.v_pointer
);
83 if(tmp
!= NULL
) lttv_hooks_call(tmp
, &time_window_notify_data
);
85 //gtk_multi_vpaned_set_adjust(tab->multi_vpaned, new_time_window, FALSE);
91 * It updates the current time of the tab, then calls the updatetimewindow
92 * hooks of each viewer.
94 * This is called whenever the current time value changes.
97 void set_current_time(Tab
*tab
, const LttTime
*current_time
)
99 LttvAttributeValue value
;
103 tab
->current_time
= *current_time
;
105 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
106 "hooks/updatecurrenttime", LTTV_POINTER
, &value
);
108 tmp
= (LttvHooks
*)*(value
.v_pointer
);
109 if(tmp
!= NULL
) lttv_hooks_call(tmp
, &tab
->current_time
);
112 /* set_current_position
114 * It updates the current time of the tab, then calls the updatetimewindow
115 * hooks of each viewer.
117 * This is called whenever the current time value changes.
120 void set_current_position(Tab
*tab
, const LttvTracesetPosition
*pos
)
122 LttvAttributeValue value
;
126 tab
->current_time
= lttv_traceset_position_get_time(pos
);
128 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
129 "hooks/updatecurrentposition", LTTV_POINTER
, &value
);
131 tmp
= (LttvHooks
*)*(value
.v_pointer
);
133 lttv_hooks_call(tmp
, (void *) pos
);
137 void add_toolbar_constructor(MainWindow
*mw
, LttvToolbarClosure
*toolbar_c
)
139 LttvIAttribute
*attributes
= mw
->attributes
;
140 LttvAttributeValue value
;
141 LttvToolbars
* instance_toolbar
;
142 lttvwindow_viewer_constructor constructor
;
143 GtkWidget
* tool_menu_title_menu
, *new_widget
, *pixmap
;
147 retval
= lttv_iattribute_find_by_path(attributes
, "viewers/toolbar",
148 LTTV_POINTER
, &value
);
150 if(*(value
.v_pointer
) == NULL
)
151 *(value
.v_pointer
) = lttv_toolbars_new();
152 instance_toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
154 constructor
= toolbar_c
->con
;
155 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"MToolbar1");
156 pixbuf
= gdk_pixbuf_new_from_xpm_data((const char**)toolbar_c
->pixmap
);
157 pixmap
= gtk_image_new_from_pixbuf(pixbuf
);
159 gtk_toolbar_append_element (GTK_TOOLBAR (tool_menu_title_menu
),
160 GTK_TOOLBAR_CHILD_BUTTON
,
163 toolbar_c
->tooltip
, NULL
,
165 gtk_label_set_use_underline(
166 GTK_LABEL (((GtkToolbarChild
*) (
167 g_list_last (GTK_TOOLBAR
168 (tool_menu_title_menu
)->children
)->data
))->label
),
170 gtk_container_set_border_width (GTK_CONTAINER (new_widget
), 1);
171 g_signal_connect ((gpointer
) new_widget
,
173 G_CALLBACK (insert_viewer_wrap
),
175 gtk_widget_show (new_widget
);
177 lttv_toolbars_add(instance_toolbar
, toolbar_c
->con
,
184 void add_menu_constructor(MainWindow
*mw
, LttvMenuClosure
*menu_c
)
186 LttvIAttribute
*attributes
= mw
->attributes
;
187 LttvAttributeValue value
;
188 LttvToolbars
* instance_menu
;
189 lttvwindow_viewer_constructor constructor
;
190 GtkWidget
* tool_menu_title_menu
, *new_widget
;
193 retval
= lttv_iattribute_find_by_path(attributes
, "viewers/menu",
194 LTTV_POINTER
, &value
);
196 if(*(value
.v_pointer
) == NULL
)
197 *(value
.v_pointer
) = lttv_menus_new();
198 instance_menu
= (LttvMenus
*)*(value
.v_pointer
);
201 constructor
= menu_c
->con
;
202 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"ToolMenuTitle_menu");
204 gtk_menu_item_new_with_mnemonic (menu_c
->menu_text
);
205 gtk_container_add (GTK_CONTAINER (tool_menu_title_menu
),
207 g_signal_connect ((gpointer
) new_widget
, "activate",
208 G_CALLBACK (insert_viewer_wrap
),
210 gtk_widget_show (new_widget
);
211 lttv_menus_add(instance_menu
, menu_c
->con
,
217 void remove_toolbar_constructor(MainWindow
*mw
, lttvwindow_viewer_constructor viewer_constructor
)
219 LttvIAttribute
*attributes
= mw
->attributes
;
220 LttvAttributeValue value
;
221 LttvToolbars
* instance_toolbar
;
222 GtkWidget
* tool_menu_title_menu
, *widget
;
225 retval
= lttv_iattribute_find_by_path(attributes
, "viewers/toolbar",
226 LTTV_POINTER
, &value
);
228 if(*(value
.v_pointer
) == NULL
)
229 *(value
.v_pointer
) = lttv_toolbars_new();
230 instance_toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
232 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"MToolbar1");
233 widget
= lttv_menus_remove(instance_toolbar
, viewer_constructor
);
234 gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu
),
239 void remove_menu_constructor(MainWindow
*mw
, lttvwindow_viewer_constructor viewer_constructor
)
241 LttvIAttribute
*attributes
= mw
->attributes
;
242 LttvAttributeValue value
;
243 LttvMenus
* instance_menu
;
244 GtkWidget
* tool_menu_title_menu
, *widget
;
247 retval
= lttv_iattribute_find_by_path(attributes
, "viewers/menu",
248 LTTV_POINTER
, &value
);
250 if(*(value
.v_pointer
) == NULL
)
251 *(value
.v_pointer
) = lttv_menus_new();
252 instance_menu
= (LttvMenus
*)*(value
.v_pointer
);
254 widget
= lttv_menus_remove(instance_menu
, viewer_constructor
);
255 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"ToolMenuTitle_menu");
256 gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu
), widget
);
266 * Function to register a view constructor so that main window can generate
267 * a menu item and a toolbar item for the viewer in order to generate a new
268 * instance easily. A menu entry and toolbar item will be added to each main
271 * It should be called by init function of the module.
273 * @param name name of the viewer
274 * @param menu_path path of the menu item.
275 * @param menu_text text of the menu item.
276 * @param pixmap Image shown on the toolbar item.
277 * @param tooltip tooltip of the toolbar item.
278 * @param view_constructor constructor of the viewer.
281 __EXPORT
void lttvwindow_register_constructor
287 lttvwindow_viewer_constructor view_constructor
)
289 LttvIAttribute
*attributes_global
= LTTV_IATTRIBUTE(lttv_global_attributes());
290 LttvToolbars
* toolbar
;
292 LttvToolbarClosure toolbar_c
;
293 LttvMenuClosure menu_c
;
294 LttvAttributeValue value
;
297 if(view_constructor
== NULL
) return;
300 retval
= lttv_iattribute_find_by_path(attributes_global
, "viewers/toolbar",
301 LTTV_POINTER
, &value
);
303 toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
305 if(toolbar
== NULL
) {
306 toolbar
= lttv_toolbars_new();
307 *(value
.v_pointer
) = toolbar
;
309 toolbar_c
= lttv_toolbars_add(toolbar
, view_constructor
, tooltip
, pixmap
,
312 g_slist_foreach(g_main_window_list
,
313 (gpointer
)add_toolbar_constructor
,
317 if(menu_path
!= NULL
) {
318 retval
= lttv_iattribute_find_by_path(attributes_global
, "viewers/menu",
319 LTTV_POINTER
, &value
);
321 menu
= (LttvMenus
*)*(value
.v_pointer
);
324 menu
= lttv_menus_new();
325 *(value
.v_pointer
) = menu
;
327 menu_c
= lttv_menus_add(menu
, view_constructor
, menu_path
, menu_text
,NULL
);
329 g_slist_foreach(g_main_window_list
,
330 (gpointer
)add_menu_constructor
,
334 LttvAttribute
*attribute
;
337 attribute
= LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
338 LTTV_IATTRIBUTE(attributes_global
),
339 LTTV_VIEWER_CONSTRUCTORS
));
342 result
= lttv_iattribute_find_by_path(LTTV_IATTRIBUTE(attribute
),
343 name
, LTTV_POINTER
, &value
);
346 *(value
.v_pointer
) = view_constructor
;
353 * Function to unregister the viewer's constructor, release the space
354 * occupied by menu_path, menu_text, pixmap, tooltip and constructor of the
357 * It will be called when a module is unloaded.
359 * @param view_constructor constructor of the viewer.
363 __EXPORT
void lttvwindow_unregister_constructor
364 (lttvwindow_viewer_constructor view_constructor
)
366 LttvIAttribute
*attributes_global
= LTTV_IATTRIBUTE(lttv_global_attributes());
367 LttvToolbars
* toolbar
;
369 LttvAttributeValue value
;
373 retval
= lttv_iattribute_find_by_path(attributes_global
, "viewers/toolbar",
374 LTTV_POINTER
, &value
);
376 toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
378 if(toolbar
!= NULL
) {
379 g_slist_foreach(g_main_window_list
,
380 (gpointer
)remove_toolbar_constructor
,
382 lttv_toolbars_remove(toolbar
, view_constructor
);
385 retval
= lttv_iattribute_find_by_path(attributes_global
, "viewers/menu",
386 LTTV_POINTER
, &value
);
388 menu
= (LttvMenus
*)*(value
.v_pointer
);
391 g_slist_foreach(g_main_window_list
,
392 (gpointer
)remove_menu_constructor
,
394 lttv_menus_remove(menu
, view_constructor
);
398 LttvAttribute
*attribute
;
399 attribute
= LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
400 LTTV_IATTRIBUTE(attributes_global
),
401 LTTV_VIEWER_CONSTRUCTORS
));
404 guint num
= lttv_iattribute_get_number(LTTV_IATTRIBUTE(attribute
));
406 LttvAttributeName name
;
407 LttvAttributeValue value
;
408 LttvAttributeType type
;
411 type
= lttv_iattribute_get(LTTV_IATTRIBUTE(attribute
), i
, &name
, &value
,
413 g_assert(type
== LTTV_POINTER
);
414 if(*(value
.v_pointer
) == view_constructor
) {
415 lttv_iattribute_remove(LTTV_IATTRIBUTE(attribute
), i
);
424 * Function to register a hook function for a viewer to set/update its
426 * @param tab viewer's tab
427 * @param hook hook function of the viewer.
428 * @param hook_data hook data associated with the hook function.
430 __EXPORT
void lttvwindow_register_time_window_notify(Tab
*tab
,
431 LttvHook hook
, gpointer hook_data
)
433 LttvAttributeValue value
;
437 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
438 "hooks/updatetimewindow", LTTV_POINTER
, &value
);
440 tmp
= (LttvHooks
*)*(value
.v_pointer
);
442 tmp
= lttv_hooks_new();
443 *(value
.v_pointer
) = tmp
;
445 lttv_hooks_add(tmp
, hook
,hook_data
, LTTV_PRIO_DEFAULT
);
450 * Function to unregister a viewer's hook function which is used to
451 * set/update the time interval of the viewer.
452 * @param tab viewer's tab
453 * @param hook hook function of the viewer.
454 * @param hook_data hook data associated with the hook function.
457 __EXPORT
void lttvwindow_unregister_time_window_notify(Tab
*tab
,
458 LttvHook hook
, gpointer hook_data
)
460 LttvAttributeValue value
;
464 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
465 "hooks/updatetimewindow", LTTV_POINTER
, &value
);
467 tmp
= (LttvHooks
*)*(value
.v_pointer
);
468 if(tmp
== NULL
) return;
469 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
473 * Function to register a hook function for a viewer to set/update its
475 * @param tab viewer's tab
476 * @param hook hook function of the viewer.
477 * @param hook_data hook data associated with the hook function.
479 __EXPORT
void lttvwindow_register_timespan_notify(Tab
*tab
,
480 LttvHook hook
, gpointer hook_data
)
482 LttvAttributeValue value
;
486 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
487 "hooks/updatetimespan", LTTV_POINTER
, &value
);
489 tmp
= (LttvHooks
*)*(value
.v_pointer
);
491 tmp
= lttv_hooks_new();
492 *(value
.v_pointer
) = tmp
;
494 lttv_hooks_add(tmp
, hook
,hook_data
, LTTV_PRIO_DEFAULT
);
497 * Function to unregister a viewer's hook function which is used to
498 * set/update the time span allowed for the viewer.
499 * @param tab viewer's tab
500 * @param hook hook function of the viewer.
501 * @param hook_data hook data associated with the hook function.
504 __EXPORT
void lttvwindow_unregister_timespan_notify(Tab
*tab
,
505 LttvHook hook
, gpointer hook_data
)
507 LttvAttributeValue value
;
511 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
512 "hooks/updatetimespan", LTTV_POINTER
, &value
);
514 tmp
= (LttvHooks
*)*(value
.v_pointer
);
515 if(tmp
== NULL
) return;
516 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
520 * Function to register a hook function for a viewer to set/update its
522 * @param tab viewer's tab
523 * @param hook hook function of the viewer.
524 * @param hook_data hook data associated with the hook function.
527 __EXPORT
void lttvwindow_register_traceset_notify(Tab
*tab
,
528 LttvHook hook
, gpointer hook_data
)
530 LttvAttributeValue value
;
534 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
535 "hooks/updatetraceset", LTTV_POINTER
, &value
);
537 tmp
= (LttvHooks
*)*(value
.v_pointer
);
539 tmp
= lttv_hooks_new();
540 *(value
.v_pointer
) = tmp
;
542 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
547 * Function to unregister a viewer's hook function which is used to
548 * set/update the traceset of the viewer.
549 * @param tab viewer's tab
550 * @param hook hook function of the viewer.
551 * @param hook_data hook data associated with the hook function.
554 __EXPORT
void lttvwindow_unregister_traceset_notify(Tab
*tab
,
555 LttvHook hook
, gpointer hook_data
)
557 LttvAttributeValue value
;
561 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
562 "hooks/updatetraceset", LTTV_POINTER
, &value
);
564 tmp
= (LttvHooks
*)*(value
.v_pointer
);
565 if(tmp
== NULL
) return;
566 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
570 * Function to register a hook function for a viewer be completely redrawn.
572 * @param tab viewer's tab
573 * @param hook hook function of the viewer.
574 * @param hook_data hook data associated with the hook function.
577 __EXPORT
void lttvwindow_register_redraw_notify(Tab
*tab
,
578 LttvHook hook
, gpointer hook_data
)
580 LttvAttributeValue value
;
584 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/redraw",
585 LTTV_POINTER
, &value
);
587 tmp
= (LttvHooks
*)*(value
.v_pointer
);
589 tmp
= lttv_hooks_new();
590 *(value
.v_pointer
) = tmp
;
592 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
597 * Function to unregister a hook function for a viewer be completely redrawn.
599 * @param tab viewer's tab
600 * @param hook hook function of the viewer.
601 * @param hook_data hook data associated with the hook function.
604 __EXPORT
void lttvwindow_unregister_redraw_notify(Tab
*tab
,
605 LttvHook hook
, gpointer hook_data
)
607 LttvAttributeValue value
;
611 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/redraw",
612 LTTV_POINTER
, &value
);
614 tmp
= (LttvHooks
*)*(value
.v_pointer
);
615 if(tmp
== NULL
) return;
616 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
620 * Function to register a hook function for a viewer to re-do the events
621 * requests for the needed interval.
623 * This action is typically done after a "stop".
625 * The typical hook will remove all current requests for the viewer
626 * and make requests for missing information.
628 * @param tab viewer's tab
629 * @param hook hook function of the viewer.
630 * @param hook_data hook data associated with the hook function.
633 __EXPORT
void lttvwindow_register_continue_notify(Tab
*tab
,
634 LttvHook hook
, gpointer hook_data
)
636 LttvAttributeValue value
;
640 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/continue",
641 LTTV_POINTER
, &value
);
643 tmp
= (LttvHooks
*)*(value
.v_pointer
);
645 tmp
= lttv_hooks_new();
646 *(value
.v_pointer
) = tmp
;
648 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
653 * Function to unregister a hook function for a viewer to re-do the events
654 * requests for the needed interval.
656 * @param tab viewer's tab
657 * @param hook hook function of the viewer.
658 * @param hook_data hook data associated with the hook function.
661 __EXPORT
void lttvwindow_unregister_continue_notify(Tab
*tab
,
662 LttvHook hook
, gpointer hook_data
)
664 LttvAttributeValue value
;
668 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/continue",
669 LTTV_POINTER
, &value
);
671 tmp
= (LttvHooks
*)*(value
.v_pointer
);
672 if(tmp
== NULL
) return;
673 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
678 * Function to register a hook function for a viewer to set/update its
680 * @param tab viewer's tab
681 * @param hook hook function of the viewer.
682 * @param hook_data hook data associated with the hook function.
685 __EXPORT
void lttvwindow_register_filter_notify(Tab
*tab
,
686 LttvHook hook
, gpointer hook_data
)
688 LttvAttributeValue value
;
692 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/updatefilter",
693 LTTV_POINTER
, &value
);
695 tmp
= (LttvHooks
*)*(value
.v_pointer
);
697 tmp
= lttv_hooks_new();
698 *(value
.v_pointer
) = tmp
;
700 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
705 * Function to unregister a viewer's hook function which is used to
706 * set/update the filter of the viewer.
707 * @param tab viewer's tab
708 * @param hook hook function of the viewer.
709 * @param hook_data hook data associated with the hook function.
712 __EXPORT
void lttvwindow_unregister_filter_notify(Tab
*tab
,
716 LttvAttributeValue value
;
720 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/updatefilter",
721 LTTV_POINTER
, &value
);
723 tmp
= (LttvHooks
*)*(value
.v_pointer
);
724 if(tmp
== NULL
) return;
725 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
729 * function to register a hook function for a viewer to set/update its
731 * @param tab viewer's tab
732 * @param hook hook function of the viewer.
733 * @param hook_data hook data associated with the hook function.
736 __EXPORT
void lttvwindow_register_current_time_notify(Tab
*tab
,
737 LttvHook hook
, gpointer hook_data
)
739 LttvAttributeValue value
;
743 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
744 "hooks/updatecurrenttime", LTTV_POINTER
, &value
);
746 tmp
= (LttvHooks
*)*(value
.v_pointer
);
748 tmp
= lttv_hooks_new();
749 *(value
.v_pointer
) = tmp
;
751 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
756 * function to unregister a viewer's hook function which is used to
757 * set/update the current time of the viewer.
758 * @param tab viewer's tab
759 * @param hook hook function of the viewer.
760 * @param hook_data hook data associated with the hook function.
763 __EXPORT
void lttvwindow_unregister_current_time_notify(Tab
*tab
,
764 LttvHook hook
, gpointer hook_data
)
766 LttvAttributeValue value
;
770 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
771 "hooks/updatecurrenttime", LTTV_POINTER
, &value
);
773 tmp
= (LttvHooks
*)*(value
.v_pointer
);
774 if(tmp
== NULL
) return;
775 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
779 * function to register a hook function for a viewer to set/update its
781 * @param tab viewer's tab
782 * @param hook hook function of the viewer.
783 * @param hook_data hook data associated with the hook function.
786 __EXPORT
void lttvwindow_register_current_position_notify(Tab
*tab
,
787 LttvHook hook
, gpointer hook_data
)
789 LttvAttributeValue value
;
793 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
794 "hooks/updatecurrentposition", LTTV_POINTER
, &value
);
796 tmp
= (LttvHooks
*)*(value
.v_pointer
);
798 tmp
= lttv_hooks_new();
799 *(value
.v_pointer
) = tmp
;
801 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
806 * function to unregister a viewer's hook function which is used to
807 * set/update the current position of the viewer.
808 * @param tab viewer's tab
809 * @param hook hook function of the viewer.
810 * @param hook_data hook data associated with the hook function.
813 __EXPORT
void lttvwindow_unregister_current_position_notify(Tab
*tab
,
814 LttvHook hook
, gpointer hook_data
)
816 LttvAttributeValue value
;
820 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
821 "hooks/updatecurrentposition", LTTV_POINTER
, &value
);
823 tmp
= (LttvHooks
*)*(value
.v_pointer
);
824 if(tmp
== NULL
) return;
825 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
830 * Function to register a hook function for a viewer to show
831 * the content of the viewer.
832 * @param tab viewer's tab
833 * @param hook hook function of the viewer.
834 * @param hook_data hook data associated with the hook function.
837 void lttvwindow_register_show_notify(Tab
*tab
,
838 LttvHook hook
, gpointer hook_data
)
840 LttvAttributeValue value
;
844 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/showviewer",
845 LTTV_POINTER
, &value
);
847 tmp
= (LttvHooks
*)*(value
.v_pointer
);
849 tmp
= lttv_hooks_new();
850 *(value
.v_pointer
) = tmp
;
852 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
857 * Function to unregister a viewer's hook function which is used to
858 * show the content of the viewer..
859 * @param tab viewer's tab
860 * @param hook hook function of the viewer.
861 * @param hook_data hook data associated with the hook function.
864 void lttvwindow_unregister_show_notify(Tab
*tab
,
865 LttvHook hook
, gpointer hook_data
)
867 LttvAttributeValue value
;
871 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/showviewer",
872 LTTV_POINTER
, &value
);
874 tmp
= (LttvHooks
*)*(value
.v_pointer
);
875 if(tmp
== NULL
) return;
876 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
880 * Function to register a hook function for a viewer to set/update the
881 * dividor of the hpane.
882 * @param tab viewer's tab
883 * @param hook hook function of the viewer.
884 * @param hook_data hook data associated with the hook function.
887 void lttvwindow_register_dividor(Tab
*tab
,
888 LttvHook hook
, gpointer hook_data
)
890 LttvAttributeValue value
;
894 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/hpanedividor",
895 LTTV_POINTER
, &value
);
897 tmp
= (LttvHooks
*)*(value
.v_pointer
);
899 tmp
= lttv_hooks_new();
900 *(value
.v_pointer
) = tmp
;
902 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
907 * Function to unregister a viewer's hook function which is used to
908 * set/update hpane's dividor of the viewer.
909 * It will be called by the destructor of the viewer.
910 * @param tab viewer's tab
911 * @param hook hook function of the viewer.
912 * @param hook_data hook data associated with the hook function.
915 void lttvwindow_unregister_dividor(Tab
*tab
,
916 LttvHook hook
, gpointer hook_data
)
918 LttvAttributeValue value
;
922 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/hpanedividor",
923 LTTV_POINTER
, &value
);
925 tmp
= (LttvHooks
*)*(value
.v_pointer
);
926 if(tmp
== NULL
) return;
927 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
932 * Function to set the time interval of the current tab.
933 * It will be called by a viewer's signal handle associated with
934 * the move_slider signal
935 * @param tab viewer's tab
936 * @param time_interval a pointer where time interval is stored.
939 __EXPORT
void lttvwindow_report_time_window(Tab
*tab
,
940 TimeWindow time_window
)
942 //set_time_window(tab, time_window);
943 //set_time_window_adjustment(tab, time_window);
945 time_change_manager(tab
, time_window
);
950 LttvTracesetContext
*tsc
=
951 LTTV_TRACESET_CONTEXT(tab
->traceset_info
->traceset_context
);
952 TimeInterval time_span
= tsc
->time_span
;
953 GtkAdjustment
*adjustment
= gtk_range_get_adjustment(GTK_RANGE(tab
->scrollbar
));
954 g_object_set(G_OBJECT(adjustment
),
959 ltt_time_sub(time_span
.end_time
, time_span
.start_time
))
962 ltt_time_to_double(time_window
->time_width
)
963 / SCROLL_STEP_PER_PAGE
964 , /* step increment */
966 ltt_time_to_double(time_window
->time_width
)
967 , /* page increment */
969 ltt_time_to_double(time_window
->time_width
)
972 gtk_adjustment_changed(adjustment
);
974 //g_object_set(G_OBJECT(adjustment),
976 // ltt_time_to_double(time_window->start_time)
979 /* Note : the set value will call set_time_window if scrollbar value changed
981 gtk_adjustment_set_value(adjustment
,
983 ltt_time_sub(time_window
->start_time
,
984 time_span
.start_time
))
991 * Function to set the current time of the current tab.
992 * It will be called by a viewer's signal handle associated with
993 * the button-release-event signal
994 * @param tab viewer's tab
995 * @param time a pointer where time is stored.
998 __EXPORT
void lttvwindow_report_current_time(Tab
*tab
,
1001 current_time_change_manager(tab
, time
);
1005 * Function to set the current event of the current tab.
1006 * It will be called by a viewer's signal handle associated with
1007 * the button-release-event signal
1008 * @param tab viewer's tab
1009 * @param time a pointer where time is stored.
1012 __EXPORT
void lttvwindow_report_current_position(Tab
*tab
,
1013 LttvTracesetPosition
*pos
)
1015 current_position_change_manager(tab
, pos
);
1020 * Function to set the position of the hpane's dividor (viewer).
1021 * It will be called by a viewer's signal handle associated with
1022 * the motion_notify_event event/signal
1023 * @param tab viewer's tab
1024 * @param position position of the hpane's dividor.
1027 void lttvwindow_report_dividor(Tab
*tab
, gint position
)
1029 LttvAttributeValue value
;
1033 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/hpanedividor",
1034 LTTV_POINTER
, &value
);
1036 tmp
= (LttvHooks
*)*(value
.v_pointer
);
1037 if(tmp
== NULL
) return;
1038 lttv_hooks_call(tmp
, &position
);
1042 * Function to request data in a specific time interval to the main window. The
1043 * event request servicing is differed until the glib idle functions are
1046 * The viewer has to provide hooks that should be associated with the event
1049 * Either start time or start position must be defined in a EventRequest
1050 * structure for it to be valid.
1052 * end_time, end_position and num_events can all be defined. The first one
1053 * to occur will be used as end criterion.
1055 * @param tab viewer's tab
1056 * @param events_requested the structure of request from.
1059 __EXPORT
void lttvwindow_events_request(Tab
*tab
,
1060 EventsRequest
*events_request
)
1062 tab
->events_requests
= g_slist_append(tab
->events_requests
, events_request
);
1064 if(!tab
->events_request_pending
)
1066 /* Redraw has +20 priority. We want to let the redraw be done while we do
1067 * our job. Mathieu : test with high prio higher than events for better
1069 /* Mathieu, 2008 : ok, finally, the control flow view needs the cell updates
1070 * to come soon enough so we can have one active cell to get the pixmap
1071 * buffer height from. Therefore, let the gdk events run before the events
1074 g_idle_add_full((G_PRIORITY_HIGH_IDLE
+ 21),
1075 //g_idle_add_full((G_PRIORITY_DEFAULT + 2),
1076 (GSourceFunc
)execute_events_requests
,
1079 tab
->events_request_pending
= TRUE
;
1085 * Function to remove data requests related to a viewer.
1087 * The existing requests's viewer gpointer is compared to the pointer
1088 * given in argument to establish which data request should be removed.
1090 * @param tab the tab the viewer belongs to.
1091 * @param viewer a pointer to the viewer data structure
1094 gint
find_viewer (const EventsRequest
*a
, gconstpointer b
)
1096 return (a
->owner
!= b
);
1100 __EXPORT
void lttvwindow_events_request_remove_all(Tab
*tab
,
1101 gconstpointer viewer
)
1103 GSList
*element
= tab
->events_requests
;
1106 g_slist_find_custom(element
, viewer
,
1107 (GCompareFunc
)find_viewer
))
1109 EventsRequest
*events_request
= (EventsRequest
*)element
->data
;
1110 // Modified so a viewer being destroyed won't have its after_request
1111 // called. Not so important anyway. Note that a viewer that call this
1112 // remove_all function will not get its after_request called.
1113 //if(events_request->servicing == TRUE) {
1114 // lttv_hooks_call(events_request->after_request, NULL);
1116 events_request_free(events_request
);
1117 //g_free(events_request);
1118 tab
->events_requests
= g_slist_remove_link(tab
->events_requests
, element
);
1119 element
= g_slist_next(element
);
1120 if(element
== NULL
) break; /* end of list */
1122 if(g_slist_length(tab
->events_requests
) == 0) {
1123 tab
->events_request_pending
= FALSE
;
1124 g_idle_remove_by_data(tab
);
1131 * Function to see if there are events request pending.
1133 * It tells if events requests are pending. Useful for checks in some events,
1134 * i.e. detailed event list scrolling.
1136 * @param tab the tab the viewer belongs to.
1137 * @param viewer a pointer to the viewer data structure
1138 * @return : TRUE is events requests are pending, else FALSE.
1141 __EXPORT gboolean
lttvwindow_events_request_pending(Tab
*tab
)
1143 GSList
*element
= tab
->events_requests
;
1145 if(element
== NULL
){
1155 * Function to get the current time interval shown on the current tab.
1156 * It will be called by a viewer's hook function to update the
1157 * shown time interval of the viewer and also be called by the constructor
1159 * @param tab viewer's tab
1160 * @return time window.
1163 __EXPORT TimeWindow
lttvwindow_get_time_window(Tab
*tab
)
1165 return tab
->time_window
;
1170 * Function to get the current time/event of the current tab.
1171 * It will be called by a viewer's hook function to update the
1172 * current time/event of the viewer.
1173 * @param tab viewer's tab
1177 __EXPORT LttTime
lttvwindow_get_current_time(Tab
*tab
)
1179 return tab
->current_time
;
1184 * Function to get the filter of the current tab.
1185 * @param filter, a pointer to a filter.
1187 * returns the current filter
1189 __EXPORT LttvFilter
*lttvwindow_get_filter(Tab
*tab
)
1191 return g_object_get_data(G_OBJECT(tab
->vbox
), "filter");
1195 * Function to set the filter of the current tab.
1196 * It should be called by the filter GUI to tell the
1197 * main window to update the filter tab's lttv_filter.
1199 * This function does change the current filter, removing the
1200 * old one when necessary, and call the updatefilter hooks
1201 * of the registered viewers.
1203 * @param main_win, the main window the viewer belongs to.
1204 * @param filter, a pointer to a filter.
1206 void lttvwindow_report_filter(Tab
*tab
, LttvFilter
*filter
)
1208 LttvAttributeValue value
;
1212 //lttv_filter_destroy(tab->filter);
1213 //tab->filter = filter;
1215 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/updatefilter",
1216 LTTV_POINTER
, &value
);
1218 tmp
= (LttvHooks
*)*(value
.v_pointer
);
1219 if(tmp
== NULL
) return;
1220 lttv_hooks_call(tmp
, filter
);
1223 #ifdef BABEL_CLEANUP
1226 * Function to get the stats of the traceset
1227 * @param tab viewer's tab
1230 __EXPORT LttvTracesetStats
* lttvwindow_get_traceset_stats(Tab
*tab
)
1232 return tab
->traceset_info
->traceset_context
;
1234 #endif /*BABEL_CLEANUP*/
1236 __EXPORT LttvTraceset
*lttvwindow_get_traceset(Tab
*tab
)
1238 return tab
->traceset_info
->traceset
;
1241 void events_request_free(EventsRequest
*events_request
)
1244 if(events_request
== NULL
) return;
1246 if(events_request
->start_position
!= NULL
)
1247 lttv_traceset_destroy_position(events_request
->start_position
);
1248 if(events_request
->end_position
!= NULL
)
1249 lttv_traceset_destroy_position(events_request
->end_position
);
1250 #ifdef BABEL_CLEANUP
1251 if(events_request
->hooks
!= NULL
) {
1252 GArray
*hooks
= events_request
->hooks
;
1254 lttv_trace_hook_remove_all(&hooks
);
1256 g_array_free(events_request
->hooks
, TRUE
);
1260 if(events_request
->before_chunk_traceset
!= NULL
)
1261 lttv_hooks_destroy(events_request
->before_chunk_traceset
);
1262 if(events_request
->before_chunk_trace
!= NULL
)
1263 lttv_hooks_destroy(events_request
->before_chunk_trace
);
1264 if(events_request
->before_chunk_tracefile
!= NULL
)
1265 lttv_hooks_destroy(events_request
->before_chunk_tracefile
);
1266 if(events_request
->event
!= NULL
)
1267 lttv_hooks_destroy(events_request
->event
);
1268 if(events_request
->after_chunk_tracefile
!= NULL
)
1269 lttv_hooks_destroy(events_request
->after_chunk_tracefile
);
1270 if(events_request
->after_chunk_trace
!= NULL
)
1271 lttv_hooks_destroy(events_request
->after_chunk_trace
);
1272 if(events_request
->after_chunk_traceset
!= NULL
)
1273 lttv_hooks_destroy(events_request
->after_chunk_traceset
);
1274 if(events_request
->before_request
!= NULL
)
1275 lttv_hooks_destroy(events_request
->before_request
);
1276 if(events_request
->after_request
!= NULL
)
1277 lttv_hooks_destroy(events_request
->after_request
);
1278 #endif /*BABEL_CLEANUP*/
1279 g_free(events_request
);
1285 __EXPORT GtkWidget
*main_window_get_widget(Tab
*tab
)
1287 return tab
->mw
->mwindow
;