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
35 #include <lttv/lttv.h>
36 #include <lttv/state.h>
37 #include <lttv/traceset.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
)
121 LttvAttributeValue value
;
125 tab
->current_time
= lttv_traceset_position_get_time(pos
);
127 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
128 "hooks/updatecurrentposition", LTTV_POINTER
, &value
);
130 tmp
= (LttvHooks
*)*(value
.v_pointer
);
132 lttv_hooks_call(tmp
, (void *) pos
);
136 void add_toolbar_constructor(MainWindow
*mw
, LttvToolbarClosure
*toolbar_c
)
138 LttvIAttribute
*attributes
= mw
->attributes
;
139 LttvAttributeValue value
;
140 LttvToolbars
* instance_toolbar
;
141 lttvwindow_viewer_constructor constructor
;
142 GtkWidget
* tool_menu_title_menu
, *new_widget
, *pixmap
;
146 retval
= lttv_iattribute_find_by_path(attributes
, "viewers/toolbar",
147 LTTV_POINTER
, &value
);
149 if(*(value
.v_pointer
) == NULL
)
150 *(value
.v_pointer
) = lttv_toolbars_new();
151 instance_toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
153 constructor
= toolbar_c
->con
;
154 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"MToolbar1");
155 pixbuf
= gdk_pixbuf_new_from_xpm_data((const char**)toolbar_c
->pixmap
);
156 pixmap
= gtk_image_new_from_pixbuf(pixbuf
);
158 gtk_toolbar_append_element (GTK_TOOLBAR (tool_menu_title_menu
),
159 GTK_TOOLBAR_CHILD_BUTTON
,
162 toolbar_c
->tooltip
, NULL
,
164 gtk_label_set_use_underline(
165 GTK_LABEL (((GtkToolbarChild
*) (
166 g_list_last (GTK_TOOLBAR
167 (tool_menu_title_menu
)->children
)->data
))->label
),
169 gtk_container_set_border_width (GTK_CONTAINER (new_widget
), 1);
170 g_signal_connect ((gpointer
) new_widget
,
172 G_CALLBACK (insert_viewer_wrap
),
174 gtk_widget_show (new_widget
);
176 lttv_toolbars_add(instance_toolbar
, toolbar_c
->con
,
183 void add_menu_constructor(MainWindow
*mw
, LttvMenuClosure
*menu_c
)
185 LttvIAttribute
*attributes
= mw
->attributes
;
186 LttvAttributeValue value
;
187 LttvToolbars
* instance_menu
;
188 lttvwindow_viewer_constructor constructor
;
189 GtkWidget
* tool_menu_title_menu
, *new_widget
;
192 retval
= lttv_iattribute_find_by_path(attributes
, "viewers/menu",
193 LTTV_POINTER
, &value
);
195 if(*(value
.v_pointer
) == NULL
)
196 *(value
.v_pointer
) = lttv_menus_new();
197 instance_menu
= (LttvMenus
*)*(value
.v_pointer
);
200 constructor
= menu_c
->con
;
201 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"ToolMenuTitle_menu");
203 gtk_menu_item_new_with_mnemonic (menu_c
->menu_text
);
204 gtk_container_add (GTK_CONTAINER (tool_menu_title_menu
),
206 g_signal_connect ((gpointer
) new_widget
, "activate",
207 G_CALLBACK (insert_viewer_wrap
),
209 gtk_widget_show (new_widget
);
210 lttv_menus_add(instance_menu
, menu_c
->con
,
216 void remove_toolbar_constructor(MainWindow
*mw
, lttvwindow_viewer_constructor viewer_constructor
)
218 LttvIAttribute
*attributes
= mw
->attributes
;
219 LttvAttributeValue value
;
220 LttvToolbars
* instance_toolbar
;
221 GtkWidget
* tool_menu_title_menu
, *widget
;
224 retval
= lttv_iattribute_find_by_path(attributes
, "viewers/toolbar",
225 LTTV_POINTER
, &value
);
227 if(*(value
.v_pointer
) == NULL
)
228 *(value
.v_pointer
) = lttv_toolbars_new();
229 instance_toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
231 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"MToolbar1");
232 widget
= lttv_menus_remove(instance_toolbar
, viewer_constructor
);
233 gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu
),
238 void remove_menu_constructor(MainWindow
*mw
, lttvwindow_viewer_constructor viewer_constructor
)
240 LttvIAttribute
*attributes
= mw
->attributes
;
241 LttvAttributeValue value
;
242 LttvMenus
* instance_menu
;
243 GtkWidget
* tool_menu_title_menu
, *widget
;
246 retval
= lttv_iattribute_find_by_path(attributes
, "viewers/menu",
247 LTTV_POINTER
, &value
);
249 if(*(value
.v_pointer
) == NULL
)
250 *(value
.v_pointer
) = lttv_menus_new();
251 instance_menu
= (LttvMenus
*)*(value
.v_pointer
);
253 widget
= lttv_menus_remove(instance_menu
, viewer_constructor
);
254 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"ToolMenuTitle_menu");
255 gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu
), widget
);
265 * Function to register a view constructor so that main window can generate
266 * a menu item and a toolbar item for the viewer in order to generate a new
267 * instance easily. A menu entry and toolbar item will be added to each main
270 * It should be called by init function of the module.
272 * @param name name of the viewer
273 * @param menu_path path of the menu item.
274 * @param menu_text text of the menu item.
275 * @param pixmap Image shown on the toolbar item.
276 * @param tooltip tooltip of the toolbar item.
277 * @param view_constructor constructor of the viewer.
280 __EXPORT
void lttvwindow_register_constructor
286 lttvwindow_viewer_constructor view_constructor
)
288 LttvIAttribute
*attributes_global
= LTTV_IATTRIBUTE(lttv_global_attributes());
289 LttvToolbars
* toolbar
;
291 LttvToolbarClosure toolbar_c
;
292 LttvMenuClosure menu_c
;
293 LttvAttributeValue value
;
296 if(view_constructor
== NULL
) return;
299 retval
= lttv_iattribute_find_by_path(attributes_global
, "viewers/toolbar",
300 LTTV_POINTER
, &value
);
302 toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
304 if(toolbar
== NULL
) {
305 toolbar
= lttv_toolbars_new();
306 *(value
.v_pointer
) = toolbar
;
308 toolbar_c
= lttv_toolbars_add(toolbar
, view_constructor
, tooltip
, pixmap
,
311 g_slist_foreach(g_main_window_list
,
312 (gpointer
)add_toolbar_constructor
,
316 if(menu_path
!= NULL
) {
317 retval
= lttv_iattribute_find_by_path(attributes_global
, "viewers/menu",
318 LTTV_POINTER
, &value
);
320 menu
= (LttvMenus
*)*(value
.v_pointer
);
323 menu
= lttv_menus_new();
324 *(value
.v_pointer
) = menu
;
326 menu_c
= lttv_menus_add(menu
, view_constructor
, menu_path
, menu_text
,NULL
);
328 g_slist_foreach(g_main_window_list
,
329 (gpointer
)add_menu_constructor
,
333 LttvAttribute
*attribute
;
336 attribute
= LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
337 LTTV_IATTRIBUTE(attributes_global
),
338 LTTV_VIEWER_CONSTRUCTORS
));
341 result
= lttv_iattribute_find_by_path(LTTV_IATTRIBUTE(attribute
),
342 name
, LTTV_POINTER
, &value
);
345 *(value
.v_pointer
) = view_constructor
;
352 * Function to unregister the viewer's constructor, release the space
353 * occupied by menu_path, menu_text, pixmap, tooltip and constructor of the
356 * It will be called when a module is unloaded.
358 * @param view_constructor constructor of the viewer.
362 __EXPORT
void lttvwindow_unregister_constructor
363 (lttvwindow_viewer_constructor view_constructor
)
365 LttvIAttribute
*attributes_global
= LTTV_IATTRIBUTE(lttv_global_attributes());
366 LttvToolbars
* toolbar
;
368 LttvAttributeValue value
;
372 retval
= lttv_iattribute_find_by_path(attributes_global
, "viewers/toolbar",
373 LTTV_POINTER
, &value
);
375 toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
377 if(toolbar
!= NULL
) {
378 g_slist_foreach(g_main_window_list
,
379 (gpointer
)remove_toolbar_constructor
,
381 lttv_toolbars_remove(toolbar
, view_constructor
);
384 retval
= lttv_iattribute_find_by_path(attributes_global
, "viewers/menu",
385 LTTV_POINTER
, &value
);
387 menu
= (LttvMenus
*)*(value
.v_pointer
);
390 g_slist_foreach(g_main_window_list
,
391 (gpointer
)remove_menu_constructor
,
393 lttv_menus_remove(menu
, view_constructor
);
397 LttvAttribute
*attribute
;
398 attribute
= LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
399 LTTV_IATTRIBUTE(attributes_global
),
400 LTTV_VIEWER_CONSTRUCTORS
));
403 guint num
= lttv_iattribute_get_number(LTTV_IATTRIBUTE(attribute
));
405 LttvAttributeName name
;
406 LttvAttributeValue value
;
407 LttvAttributeType type
;
410 type
= lttv_iattribute_get(LTTV_IATTRIBUTE(attribute
), i
, &name
, &value
,
412 g_assert(type
== LTTV_POINTER
);
413 if(*(value
.v_pointer
) == view_constructor
) {
414 lttv_iattribute_remove(LTTV_IATTRIBUTE(attribute
), i
);
423 * Function to register a hook function for a viewer to set/update its
425 * @param tab viewer's tab
426 * @param hook hook function of the viewer.
427 * @param hook_data hook data associated with the hook function.
429 __EXPORT
void lttvwindow_register_time_window_notify(Tab
*tab
,
430 LttvHook hook
, gpointer hook_data
)
432 LttvAttributeValue value
;
436 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
437 "hooks/updatetimewindow", LTTV_POINTER
, &value
);
439 tmp
= (LttvHooks
*)*(value
.v_pointer
);
441 tmp
= lttv_hooks_new();
442 *(value
.v_pointer
) = tmp
;
444 lttv_hooks_add(tmp
, hook
,hook_data
, LTTV_PRIO_DEFAULT
);
449 * Function to unregister a viewer's hook function which is used to
450 * set/update the time interval of the viewer.
451 * @param tab viewer's tab
452 * @param hook hook function of the viewer.
453 * @param hook_data hook data associated with the hook function.
456 __EXPORT
void lttvwindow_unregister_time_window_notify(Tab
*tab
,
457 LttvHook hook
, gpointer hook_data
)
459 LttvAttributeValue value
;
463 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
464 "hooks/updatetimewindow", LTTV_POINTER
, &value
);
466 tmp
= (LttvHooks
*)*(value
.v_pointer
);
467 if(tmp
== NULL
) return;
468 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
472 * Function to register a hook function for a viewer to set/update its
474 * @param tab viewer's tab
475 * @param hook hook function of the viewer.
476 * @param hook_data hook data associated with the hook function.
478 __EXPORT
void lttvwindow_register_timespan_notify(Tab
*tab
,
479 LttvHook hook
, gpointer hook_data
)
481 LttvAttributeValue value
;
485 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
486 "hooks/updatetimespan", LTTV_POINTER
, &value
);
488 tmp
= (LttvHooks
*)*(value
.v_pointer
);
490 tmp
= lttv_hooks_new();
491 *(value
.v_pointer
) = tmp
;
493 lttv_hooks_add(tmp
, hook
,hook_data
, LTTV_PRIO_DEFAULT
);
496 * Function to unregister a viewer's hook function which is used to
497 * set/update the time span allowed for the viewer.
498 * @param tab viewer's tab
499 * @param hook hook function of the viewer.
500 * @param hook_data hook data associated with the hook function.
503 __EXPORT
void lttvwindow_unregister_timespan_notify(Tab
*tab
,
504 LttvHook hook
, gpointer hook_data
)
506 LttvAttributeValue value
;
510 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
511 "hooks/updatetimespan", LTTV_POINTER
, &value
);
513 tmp
= (LttvHooks
*)*(value
.v_pointer
);
514 if(tmp
== NULL
) return;
515 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
519 * Function to register a hook function for a viewer to set/update its
521 * @param tab viewer's tab
522 * @param hook hook function of the viewer.
523 * @param hook_data hook data associated with the hook function.
526 __EXPORT
void lttvwindow_register_traceset_notify(Tab
*tab
,
527 LttvHook hook
, gpointer hook_data
)
529 LttvAttributeValue value
;
533 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
534 "hooks/updatetraceset", LTTV_POINTER
, &value
);
536 tmp
= (LttvHooks
*)*(value
.v_pointer
);
538 tmp
= lttv_hooks_new();
539 *(value
.v_pointer
) = tmp
;
541 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
546 * Function to unregister a viewer's hook function which is used to
547 * set/update the traceset of the viewer.
548 * @param tab viewer's tab
549 * @param hook hook function of the viewer.
550 * @param hook_data hook data associated with the hook function.
553 __EXPORT
void lttvwindow_unregister_traceset_notify(Tab
*tab
,
554 LttvHook hook
, gpointer hook_data
)
556 LttvAttributeValue value
;
560 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
561 "hooks/updatetraceset", LTTV_POINTER
, &value
);
563 tmp
= (LttvHooks
*)*(value
.v_pointer
);
564 if(tmp
== NULL
) return;
565 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
569 * Function to register a hook function for a viewer be completely redrawn.
571 * @param tab viewer's tab
572 * @param hook hook function of the viewer.
573 * @param hook_data hook data associated with the hook function.
576 __EXPORT
void lttvwindow_register_redraw_notify(Tab
*tab
,
577 LttvHook hook
, gpointer hook_data
)
579 LttvAttributeValue value
;
583 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/redraw",
584 LTTV_POINTER
, &value
);
586 tmp
= (LttvHooks
*)*(value
.v_pointer
);
588 tmp
= lttv_hooks_new();
589 *(value
.v_pointer
) = tmp
;
591 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
596 * Function to unregister a hook function for a viewer be completely redrawn.
598 * @param tab viewer's tab
599 * @param hook hook function of the viewer.
600 * @param hook_data hook data associated with the hook function.
603 __EXPORT
void lttvwindow_unregister_redraw_notify(Tab
*tab
,
604 LttvHook hook
, gpointer hook_data
)
606 LttvAttributeValue value
;
610 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/redraw",
611 LTTV_POINTER
, &value
);
613 tmp
= (LttvHooks
*)*(value
.v_pointer
);
614 if(tmp
== NULL
) return;
615 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
619 * Function to register a hook function for a viewer to re-do the events
620 * requests for the needed interval.
622 * This action is typically done after a "stop".
624 * The typical hook will remove all current requests for the viewer
625 * and make requests for missing information.
627 * @param tab viewer's tab
628 * @param hook hook function of the viewer.
629 * @param hook_data hook data associated with the hook function.
632 __EXPORT
void lttvwindow_register_continue_notify(Tab
*tab
,
633 LttvHook hook
, gpointer hook_data
)
635 LttvAttributeValue value
;
639 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/continue",
640 LTTV_POINTER
, &value
);
642 tmp
= (LttvHooks
*)*(value
.v_pointer
);
644 tmp
= lttv_hooks_new();
645 *(value
.v_pointer
) = tmp
;
647 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
652 * Function to unregister a hook function for a viewer to re-do the events
653 * requests for the needed interval.
655 * @param tab viewer's tab
656 * @param hook hook function of the viewer.
657 * @param hook_data hook data associated with the hook function.
660 __EXPORT
void lttvwindow_unregister_continue_notify(Tab
*tab
,
661 LttvHook hook
, gpointer hook_data
)
663 LttvAttributeValue value
;
667 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/continue",
668 LTTV_POINTER
, &value
);
670 tmp
= (LttvHooks
*)*(value
.v_pointer
);
671 if(tmp
== NULL
) return;
672 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
677 * Function to register a hook function for a viewer to set/update its
679 * @param tab viewer's tab
680 * @param hook hook function of the viewer.
681 * @param hook_data hook data associated with the hook function.
684 __EXPORT
void lttvwindow_register_filter_notify(Tab
*tab
,
685 LttvHook hook
, gpointer hook_data
)
687 LttvAttributeValue value
;
691 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/updatefilter",
692 LTTV_POINTER
, &value
);
694 tmp
= (LttvHooks
*)*(value
.v_pointer
);
696 tmp
= lttv_hooks_new();
697 *(value
.v_pointer
) = tmp
;
699 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
704 * Function to unregister a viewer's hook function which is used to
705 * set/update the filter of the viewer.
706 * @param tab viewer's tab
707 * @param hook hook function of the viewer.
708 * @param hook_data hook data associated with the hook function.
711 __EXPORT
void lttvwindow_unregister_filter_notify(Tab
*tab
,
715 LttvAttributeValue value
;
719 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/updatefilter",
720 LTTV_POINTER
, &value
);
722 tmp
= (LttvHooks
*)*(value
.v_pointer
);
723 if(tmp
== NULL
) return;
724 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
728 * function to register a hook function for a viewer to set/update its
730 * @param tab viewer's tab
731 * @param hook hook function of the viewer.
732 * @param hook_data hook data associated with the hook function.
735 __EXPORT
void lttvwindow_register_current_time_notify(Tab
*tab
,
736 LttvHook hook
, gpointer hook_data
)
738 LttvAttributeValue value
;
742 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
743 "hooks/updatecurrenttime", LTTV_POINTER
, &value
);
745 tmp
= (LttvHooks
*)*(value
.v_pointer
);
747 tmp
= lttv_hooks_new();
748 *(value
.v_pointer
) = tmp
;
750 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
755 * function to unregister a viewer's hook function which is used to
756 * set/update the current time of the viewer.
757 * @param tab viewer's tab
758 * @param hook hook function of the viewer.
759 * @param hook_data hook data associated with the hook function.
762 __EXPORT
void lttvwindow_unregister_current_time_notify(Tab
*tab
,
763 LttvHook hook
, gpointer hook_data
)
765 LttvAttributeValue value
;
769 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
770 "hooks/updatecurrenttime", LTTV_POINTER
, &value
);
772 tmp
= (LttvHooks
*)*(value
.v_pointer
);
773 if(tmp
== NULL
) return;
774 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
778 * function to register a hook function for a viewer to set/update its
780 * @param tab viewer's tab
781 * @param hook hook function of the viewer.
782 * @param hook_data hook data associated with the hook function.
785 __EXPORT
void lttvwindow_register_current_position_notify(Tab
*tab
,
786 LttvHook hook
, gpointer hook_data
)
788 LttvAttributeValue value
;
792 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
793 "hooks/updatecurrentposition", LTTV_POINTER
, &value
);
795 tmp
= (LttvHooks
*)*(value
.v_pointer
);
797 tmp
= lttv_hooks_new();
798 *(value
.v_pointer
) = tmp
;
800 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
805 * function to unregister a viewer's hook function which is used to
806 * set/update the current position of the viewer.
807 * @param tab viewer's tab
808 * @param hook hook function of the viewer.
809 * @param hook_data hook data associated with the hook function.
812 __EXPORT
void lttvwindow_unregister_current_position_notify(Tab
*tab
,
813 LttvHook hook
, gpointer hook_data
)
815 LttvAttributeValue value
;
819 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
820 "hooks/updatecurrentposition", LTTV_POINTER
, &value
);
822 tmp
= (LttvHooks
*)*(value
.v_pointer
);
823 if(tmp
== NULL
) return;
824 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
829 * Function to register a hook function for a viewer to show
830 * the content of the viewer.
831 * @param tab viewer's tab
832 * @param hook hook function of the viewer.
833 * @param hook_data hook data associated with the hook function.
836 void lttvwindow_register_show_notify(Tab
*tab
,
837 LttvHook hook
, gpointer hook_data
)
839 LttvAttributeValue value
;
843 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/showviewer",
844 LTTV_POINTER
, &value
);
846 tmp
= (LttvHooks
*)*(value
.v_pointer
);
848 tmp
= lttv_hooks_new();
849 *(value
.v_pointer
) = tmp
;
851 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
856 * Function to unregister a viewer's hook function which is used to
857 * show the content of the viewer..
858 * @param tab viewer's tab
859 * @param hook hook function of the viewer.
860 * @param hook_data hook data associated with the hook function.
863 void lttvwindow_unregister_show_notify(Tab
*tab
,
864 LttvHook hook
, gpointer hook_data
)
866 LttvAttributeValue value
;
870 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/showviewer",
871 LTTV_POINTER
, &value
);
873 tmp
= (LttvHooks
*)*(value
.v_pointer
);
874 if(tmp
== NULL
) return;
875 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
879 * Function to register a hook function for a viewer to set/update the
880 * dividor of the hpane.
881 * @param tab viewer's tab
882 * @param hook hook function of the viewer.
883 * @param hook_data hook data associated with the hook function.
886 void lttvwindow_register_dividor(Tab
*tab
,
887 LttvHook hook
, gpointer hook_data
)
889 LttvAttributeValue value
;
893 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/hpanedividor",
894 LTTV_POINTER
, &value
);
896 tmp
= (LttvHooks
*)*(value
.v_pointer
);
898 tmp
= lttv_hooks_new();
899 *(value
.v_pointer
) = tmp
;
901 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
906 * Function to unregister a viewer's hook function which is used to
907 * set/update hpane's dividor of the viewer.
908 * It will be called by the destructor of the viewer.
909 * @param tab viewer's tab
910 * @param hook hook function of the viewer.
911 * @param hook_data hook data associated with the hook function.
914 void lttvwindow_unregister_dividor(Tab
*tab
,
915 LttvHook hook
, gpointer hook_data
)
917 LttvAttributeValue value
;
921 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/hpanedividor",
922 LTTV_POINTER
, &value
);
924 tmp
= (LttvHooks
*)*(value
.v_pointer
);
925 if(tmp
== NULL
) return;
926 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
931 * Function to set the time interval of the current tab.
932 * It will be called by a viewer's signal handle associated with
933 * the move_slider signal
934 * @param tab viewer's tab
935 * @param time_interval a pointer where time interval is stored.
938 __EXPORT
void lttvwindow_report_time_window(Tab
*tab
,
939 TimeWindow time_window
)
941 //set_time_window(tab, time_window);
942 //set_time_window_adjustment(tab, time_window);
944 time_change_manager(tab
, time_window
);
949 LttvTracesetContext
*tsc
=
950 LTTV_TRACESET_CONTEXT(tab
->traceset_info
->traceset_context
);
951 TimeInterval time_span
= tsc
->time_span
;
952 GtkAdjustment
*adjustment
= gtk_range_get_adjustment(GTK_RANGE(tab
->scrollbar
));
953 g_object_set(G_OBJECT(adjustment
),
958 ltt_time_sub(time_span
.end_time
, time_span
.start_time
))
961 ltt_time_to_double(time_window
->time_width
)
962 / SCROLL_STEP_PER_PAGE
963 , /* step increment */
965 ltt_time_to_double(time_window
->time_width
)
966 , /* page increment */
968 ltt_time_to_double(time_window
->time_width
)
971 gtk_adjustment_changed(adjustment
);
973 //g_object_set(G_OBJECT(adjustment),
975 // ltt_time_to_double(time_window->start_time)
978 /* Note : the set value will call set_time_window if scrollbar value changed
980 gtk_adjustment_set_value(adjustment
,
982 ltt_time_sub(time_window
->start_time
,
983 time_span
.start_time
))
990 * Function to set the current time of the current tab.
991 * It will be called by a viewer's signal handle associated with
992 * the button-release-event signal
993 * @param tab viewer's tab
994 * @param time a pointer where time is stored.
997 __EXPORT
void lttvwindow_report_current_time(Tab
*tab
,
1000 current_time_change_manager(tab
, time
);
1004 * Function to set the current event of the current tab.
1005 * It will be called by a viewer's signal handle associated with
1006 * the button-release-event signal
1007 * @param tab viewer's tab
1008 * @param time a pointer where time is stored.
1011 __EXPORT
void lttvwindow_report_current_position(Tab
*tab
,
1012 LttvTracesetPosition
*pos
)
1014 current_position_change_manager(tab
, pos
);
1019 * Function to set the position of the hpane's dividor (viewer).
1020 * It will be called by a viewer's signal handle associated with
1021 * the motion_notify_event event/signal
1022 * @param tab viewer's tab
1023 * @param position position of the hpane's dividor.
1026 void lttvwindow_report_dividor(Tab
*tab
, gint position
)
1028 LttvAttributeValue value
;
1032 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/hpanedividor",
1033 LTTV_POINTER
, &value
);
1035 tmp
= (LttvHooks
*)*(value
.v_pointer
);
1036 if(tmp
== NULL
) return;
1037 lttv_hooks_call(tmp
, &position
);
1041 * Function to request data in a specific time interval to the main window. The
1042 * event request servicing is differed until the glib idle functions are
1045 * The viewer has to provide hooks that should be associated with the event
1048 * Either start time or start position must be defined in a EventRequest
1049 * structure for it to be valid.
1051 * end_time, end_position and num_events can all be defined. The first one
1052 * to occur will be used as end criterion.
1054 * @param tab viewer's tab
1055 * @param events_requested the structure of request from.
1058 __EXPORT
void lttvwindow_events_request(Tab
*tab
,
1059 EventsRequest
*events_request
)
1061 tab
->events_requests
= g_slist_append(tab
->events_requests
, events_request
);
1063 if(!tab
->events_request_pending
)
1065 /* Redraw has +20 priority. We want to let the redraw be done while we do
1066 * our job. Mathieu : test with high prio higher than events for better
1068 /* Mathieu, 2008 : ok, finally, the control flow view needs the cell updates
1069 * to come soon enough so we can have one active cell to get the pixmap
1070 * buffer height from. Therefore, let the gdk events run before the events
1073 g_idle_add_full((G_PRIORITY_HIGH_IDLE
+ 21),
1074 //g_idle_add_full((G_PRIORITY_DEFAULT + 2),
1075 (GSourceFunc
)execute_events_requests
,
1078 tab
->events_request_pending
= TRUE
;
1084 * Function to remove data requests related to a viewer.
1086 * The existing requests's viewer gpointer is compared to the pointer
1087 * given in argument to establish which data request should be removed.
1089 * @param tab the tab the viewer belongs to.
1090 * @param viewer a pointer to the viewer data structure
1093 gint
find_viewer (const EventsRequest
*a
, gconstpointer b
)
1095 return (a
->owner
!= b
);
1099 __EXPORT
void lttvwindow_events_request_remove_all(Tab
*tab
,
1100 gconstpointer viewer
)
1102 GSList
*element
= tab
->events_requests
;
1105 g_slist_find_custom(element
, viewer
,
1106 (GCompareFunc
)find_viewer
))
1108 EventsRequest
*events_request
= (EventsRequest
*)element
->data
;
1109 // Modified so a viewer being destroyed won't have its after_request
1110 // called. Not so important anyway. Note that a viewer that call this
1111 // remove_all function will not get its after_request called.
1112 //if(events_request->servicing == TRUE) {
1113 // lttv_hooks_call(events_request->after_request, NULL);
1115 events_request_free(events_request
);
1116 //g_free(events_request);
1117 tab
->events_requests
= g_slist_remove_link(tab
->events_requests
, element
);
1118 element
= g_slist_next(element
);
1119 if(element
== NULL
) break; /* end of list */
1121 if(g_slist_length(tab
->events_requests
) == 0) {
1122 tab
->events_request_pending
= FALSE
;
1123 g_idle_remove_by_data(tab
);
1130 * Function to see if there are events request pending.
1132 * It tells if events requests are pending. Useful for checks in some events,
1133 * i.e. detailed event list scrolling.
1135 * @param tab the tab the viewer belongs to.
1136 * @param viewer a pointer to the viewer data structure
1137 * @return : TRUE is events requests are pending, else FALSE.
1140 __EXPORT gboolean
lttvwindow_events_request_pending(Tab
*tab
)
1142 GSList
*element
= tab
->events_requests
;
1144 if(element
== NULL
){
1154 * Function to get the current time interval shown on the current tab.
1155 * It will be called by a viewer's hook function to update the
1156 * shown time interval of the viewer and also be called by the constructor
1158 * @param tab viewer's tab
1159 * @return time window.
1162 __EXPORT TimeWindow
lttvwindow_get_time_window(Tab
*tab
)
1164 return tab
->time_window
;
1169 * Function to get the current time/event of the current tab.
1170 * It will be called by a viewer's hook function to update the
1171 * current time/event of the viewer.
1172 * @param tab viewer's tab
1176 __EXPORT LttTime
lttvwindow_get_current_time(Tab
*tab
)
1178 return tab
->current_time
;
1183 * Function to get the filter of the current tab.
1184 * @param filter, a pointer to a filter.
1186 * returns the current filter
1188 __EXPORT LttvFilter
*lttvwindow_get_filter(Tab
*tab
)
1190 return g_object_get_data(G_OBJECT(tab
->vbox
), "filter");
1194 * Function to set the filter of the current tab.
1195 * It should be called by the filter GUI to tell the
1196 * main window to update the filter tab's lttv_filter.
1198 * This function does change the current filter, removing the
1199 * old one when necessary, and call the updatefilter hooks
1200 * of the registered viewers.
1202 * @param main_win, the main window the viewer belongs to.
1203 * @param filter, a pointer to a filter.
1205 void lttvwindow_report_filter(Tab
*tab
, LttvFilter
*filter
)
1207 LttvAttributeValue value
;
1211 //lttv_filter_destroy(tab->filter);
1212 //tab->filter = filter;
1214 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/updatefilter",
1215 LTTV_POINTER
, &value
);
1217 tmp
= (LttvHooks
*)*(value
.v_pointer
);
1218 if(tmp
== NULL
) return;
1219 lttv_hooks_call(tmp
, filter
);
1222 #ifdef BABEL_CLEANUP
1225 * Function to get the stats of the traceset
1226 * @param tab viewer's tab
1229 __EXPORT LttvTracesetStats
* lttvwindow_get_traceset_stats(Tab
*tab
)
1231 return tab
->traceset_info
->traceset_context
;
1233 #endif /*BABEL_CLEANUP*/
1235 __EXPORT LttvTraceset
*lttvwindow_get_traceset(Tab
*tab
)
1237 return tab
->traceset_info
->traceset
;
1240 void events_request_free(EventsRequest
*events_request
)
1243 if(events_request
== NULL
) return;
1245 if(events_request
->start_position
!= NULL
)
1246 lttv_traceset_destroy_position(events_request
->start_position
);
1247 if(events_request
->end_position
!= NULL
)
1248 lttv_traceset_destroy_position(events_request
->end_position
);
1249 #ifdef BABEL_CLEANUP
1250 if(events_request
->hooks
!= NULL
) {
1251 GArray
*hooks
= events_request
->hooks
;
1253 lttv_trace_hook_remove_all(&hooks
);
1255 g_array_free(events_request
->hooks
, TRUE
);
1259 if(events_request
->before_chunk_traceset
!= NULL
)
1260 lttv_hooks_destroy(events_request
->before_chunk_traceset
);
1261 if(events_request
->before_chunk_trace
!= NULL
)
1262 lttv_hooks_destroy(events_request
->before_chunk_trace
);
1263 if(events_request
->before_chunk_tracefile
!= NULL
)
1264 lttv_hooks_destroy(events_request
->before_chunk_tracefile
);
1265 if(events_request
->event
!= NULL
)
1266 lttv_hooks_destroy(events_request
->event
);
1267 if(events_request
->after_chunk_tracefile
!= NULL
)
1268 lttv_hooks_destroy(events_request
->after_chunk_tracefile
);
1269 if(events_request
->after_chunk_trace
!= NULL
)
1270 lttv_hooks_destroy(events_request
->after_chunk_trace
);
1271 if(events_request
->after_chunk_traceset
!= NULL
)
1272 lttv_hooks_destroy(events_request
->after_chunk_traceset
);
1273 if(events_request
->before_request
!= NULL
)
1274 lttv_hooks_destroy(events_request
->before_request
);
1275 if(events_request
->after_request
!= NULL
)
1276 lttv_hooks_destroy(events_request
->after_request
);
1277 #endif /*BABEL_CLEANUP*/
1278 g_free(events_request
);
1284 __EXPORT GtkWidget
*main_window_get_widget(Tab
*tab
)
1286 return tab
->mw
->mwindow
;