1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 XangXiu Yang
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License Version 2 as
6 * published by the Free Software Foundation;
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
19 /*! \file lttvwindow.c
20 * \brief API used by the graphical viewers to interact with their tab.
22 * Main window (gui module) is the place to contain and display viewers.
23 * Viewers (lttv plugins) interact with tab and main window through this API
24 * and events sent by gtk.
25 * This header file should be included in each graphic module.
26 * This library is used by graphical modules to interact with their tab and
36 #include <lttv/lttv.h>
37 #include <lttv/state.h>
38 #include <lttv/stats.h>
39 #include <lttv/tracecontext.h>
40 #include <lttvwindow/mainwindow.h>
41 #include <lttvwindow/mainwindow-private.h>
42 #include <lttvwindow/lttvwindow.h>
43 #include <lttvwindow/toolbar.h>
44 #include <lttvwindow/menu.h>
45 #include <lttvwindow/callbacks.h> // for execute_events_requests
46 #include <lttvwindow/support.h>
49 * Internal function parts
52 extern GSList
* g_main_window_list
;
54 __EXPORT gint lttvwindow_preempt_count
= 0;
58 * It updates the time window of the tab, then calls the updatetimewindow
59 * hooks of each viewer.
61 * This is called whenever the scrollbar value changes.
64 void set_time_window(Tab
*tab
, const TimeWindow
*time_window
)
66 LttvAttributeValue value
;
70 TimeWindowNotifyData time_window_notify_data
;
71 TimeWindow old_time_window
= tab
->time_window
;
72 time_window_notify_data
.old_time_window
= &old_time_window
;
73 tab
->time_window
= *time_window
;
74 time_window_notify_data
.new_time_window
=
77 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
78 "hooks/updatetimewindow", LTTV_POINTER
, &value
);
80 tmp
= (LttvHooks
*)*(value
.v_pointer
);
81 if(tmp
!= NULL
) lttv_hooks_call(tmp
, &time_window_notify_data
);
83 //gtk_multi_vpaned_set_adjust(tab->multi_vpaned, new_time_window, FALSE);
89 * It updates the current time of the tab, then calls the updatetimewindow
90 * hooks of each viewer.
92 * This is called whenever the current time value changes.
95 void set_current_time(Tab
*tab
, const LttTime
*current_time
)
97 LttvAttributeValue value
;
101 tab
->current_time
= *current_time
;
103 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
104 "hooks/updatecurrenttime", LTTV_POINTER
, &value
);
106 tmp
= (LttvHooks
*)*(value
.v_pointer
);
107 if(tmp
!= NULL
) lttv_hooks_call(tmp
, &tab
->current_time
);
110 /* set_current_position
112 * It updates the current time of the tab, then calls the updatetimewindow
113 * hooks of each viewer.
115 * This is called whenever the current time value changes.
118 void set_current_position(Tab
*tab
, const LttvTracesetContextPosition
*pos
)
120 LttvAttributeValue value
;
124 tab
->current_time
= lttv_traceset_context_position_get_time(pos
);
126 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
127 "hooks/updatecurrentposition", LTTV_POINTER
, &value
);
129 tmp
= (LttvHooks
*)*(value
.v_pointer
);
131 lttv_hooks_call(tmp
, (void *) pos
);
135 void add_toolbar_constructor(MainWindow
*mw
, LttvToolbarClosure
*toolbar_c
)
137 LttvIAttribute
*attributes
= mw
->attributes
;
138 LttvAttributeValue value
;
139 LttvToolbars
* instance_toolbar
;
140 lttvwindow_viewer_constructor constructor
;
141 GtkWidget
* tool_menu_title_menu
, *new_widget
, *pixmap
;
145 retval
= lttv_iattribute_find_by_path(attributes
, "viewers/toolbar",
146 LTTV_POINTER
, &value
);
148 if(*(value
.v_pointer
) == NULL
)
149 *(value
.v_pointer
) = lttv_toolbars_new();
150 instance_toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
152 constructor
= toolbar_c
->con
;
153 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"MToolbar1");
154 pixbuf
= gdk_pixbuf_new_from_xpm_data((const char**)toolbar_c
->pixmap
);
155 pixmap
= gtk_image_new_from_pixbuf(pixbuf
);
157 gtk_toolbar_append_element (GTK_TOOLBAR (tool_menu_title_menu
),
158 GTK_TOOLBAR_CHILD_BUTTON
,
161 toolbar_c
->tooltip
, NULL
,
163 gtk_label_set_use_underline(
164 GTK_LABEL (((GtkToolbarChild
*) (
165 g_list_last (GTK_TOOLBAR
166 (tool_menu_title_menu
)->children
)->data
))->label
),
168 gtk_container_set_border_width (GTK_CONTAINER (new_widget
), 1);
169 g_signal_connect ((gpointer
) new_widget
,
171 G_CALLBACK (insert_viewer_wrap
),
173 gtk_widget_show (new_widget
);
175 lttv_toolbars_add(instance_toolbar
, toolbar_c
->con
,
182 void add_menu_constructor(MainWindow
*mw
, LttvMenuClosure
*menu_c
)
184 LttvIAttribute
*attributes
= mw
->attributes
;
185 LttvAttributeValue value
;
186 LttvToolbars
* instance_menu
;
187 lttvwindow_viewer_constructor constructor
;
188 GtkWidget
* tool_menu_title_menu
, *new_widget
;
191 retval
= lttv_iattribute_find_by_path(attributes
, "viewers/menu",
192 LTTV_POINTER
, &value
);
194 if(*(value
.v_pointer
) == NULL
)
195 *(value
.v_pointer
) = lttv_menus_new();
196 instance_menu
= (LttvMenus
*)*(value
.v_pointer
);
199 constructor
= menu_c
->con
;
200 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"ToolMenuTitle_menu");
202 gtk_menu_item_new_with_mnemonic (menu_c
->menu_text
);
203 gtk_container_add (GTK_CONTAINER (tool_menu_title_menu
),
205 g_signal_connect ((gpointer
) new_widget
, "activate",
206 G_CALLBACK (insert_viewer_wrap
),
208 gtk_widget_show (new_widget
);
209 lttv_menus_add(instance_menu
, menu_c
->con
,
215 void remove_toolbar_constructor(MainWindow
*mw
, lttvwindow_viewer_constructor viewer_constructor
)
217 LttvIAttribute
*attributes
= mw
->attributes
;
218 LttvAttributeValue value
;
219 LttvToolbars
* instance_toolbar
;
220 GtkWidget
* tool_menu_title_menu
, *widget
;
223 retval
= lttv_iattribute_find_by_path(attributes
, "viewers/toolbar",
224 LTTV_POINTER
, &value
);
226 if(*(value
.v_pointer
) == NULL
)
227 *(value
.v_pointer
) = lttv_toolbars_new();
228 instance_toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
230 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"MToolbar1");
231 widget
= lttv_menus_remove(instance_toolbar
, viewer_constructor
);
232 gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu
),
237 void remove_menu_constructor(MainWindow
*mw
, lttvwindow_viewer_constructor viewer_constructor
)
239 LttvIAttribute
*attributes
= mw
->attributes
;
240 LttvAttributeValue value
;
241 LttvMenus
* instance_menu
;
242 GtkWidget
* tool_menu_title_menu
, *widget
;
245 retval
= lttv_iattribute_find_by_path(attributes
, "viewers/menu",
246 LTTV_POINTER
, &value
);
248 if(*(value
.v_pointer
) == NULL
)
249 *(value
.v_pointer
) = lttv_menus_new();
250 instance_menu
= (LttvMenus
*)*(value
.v_pointer
);
252 widget
= lttv_menus_remove(instance_menu
, viewer_constructor
);
253 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"ToolMenuTitle_menu");
254 gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu
), widget
);
264 * Function to register a view constructor so that main window can generate
265 * a menu item and a toolbar item for the viewer in order to generate a new
266 * instance easily. A menu entry and toolbar item will be added to each main
269 * It should be called by init function of the module.
271 * @param name name of the viewer
272 * @param menu_path path of the menu item.
273 * @param menu_text text of the menu item.
274 * @param pixmap Image shown on the toolbar item.
275 * @param tooltip tooltip of the toolbar item.
276 * @param view_constructor constructor of the viewer.
279 __EXPORT
void lttvwindow_register_constructor
285 lttvwindow_viewer_constructor view_constructor
)
287 LttvIAttribute
*attributes_global
= LTTV_IATTRIBUTE(lttv_global_attributes());
288 LttvToolbars
* toolbar
;
290 LttvToolbarClosure toolbar_c
;
291 LttvMenuClosure menu_c
;
292 LttvAttributeValue value
;
295 if(view_constructor
== NULL
) return;
298 retval
= lttv_iattribute_find_by_path(attributes_global
, "viewers/toolbar",
299 LTTV_POINTER
, &value
);
301 toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
303 if(toolbar
== NULL
) {
304 toolbar
= lttv_toolbars_new();
305 *(value
.v_pointer
) = toolbar
;
307 toolbar_c
= lttv_toolbars_add(toolbar
, view_constructor
, tooltip
, pixmap
,
310 g_slist_foreach(g_main_window_list
,
311 (gpointer
)add_toolbar_constructor
,
315 if(menu_path
!= NULL
) {
316 retval
= lttv_iattribute_find_by_path(attributes_global
, "viewers/menu",
317 LTTV_POINTER
, &value
);
319 menu
= (LttvMenus
*)*(value
.v_pointer
);
322 menu
= lttv_menus_new();
323 *(value
.v_pointer
) = menu
;
325 menu_c
= lttv_menus_add(menu
, view_constructor
, menu_path
, menu_text
,NULL
);
327 g_slist_foreach(g_main_window_list
,
328 (gpointer
)add_menu_constructor
,
332 LttvAttribute
*attribute
;
335 attribute
= LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
336 LTTV_IATTRIBUTE(attributes_global
),
337 LTTV_VIEWER_CONSTRUCTORS
));
340 result
= lttv_iattribute_find_by_path(LTTV_IATTRIBUTE(attribute
),
341 name
, LTTV_POINTER
, &value
);
344 *(value
.v_pointer
) = view_constructor
;
351 * Function to unregister the viewer's constructor, release the space
352 * occupied by menu_path, menu_text, pixmap, tooltip and constructor of the
355 * It will be called when a module is unloaded.
357 * @param view_constructor constructor of the viewer.
361 __EXPORT
void lttvwindow_unregister_constructor
362 (lttvwindow_viewer_constructor view_constructor
)
364 LttvIAttribute
*attributes_global
= LTTV_IATTRIBUTE(lttv_global_attributes());
365 LttvToolbars
* toolbar
;
367 LttvAttributeValue value
;
371 retval
= lttv_iattribute_find_by_path(attributes_global
, "viewers/toolbar",
372 LTTV_POINTER
, &value
);
374 toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
376 if(toolbar
!= NULL
) {
377 g_slist_foreach(g_main_window_list
,
378 (gpointer
)remove_toolbar_constructor
,
380 lttv_toolbars_remove(toolbar
, view_constructor
);
383 retval
= lttv_iattribute_find_by_path(attributes_global
, "viewers/menu",
384 LTTV_POINTER
, &value
);
386 menu
= (LttvMenus
*)*(value
.v_pointer
);
389 g_slist_foreach(g_main_window_list
,
390 (gpointer
)remove_menu_constructor
,
392 lttv_menus_remove(menu
, view_constructor
);
396 LttvAttribute
*attribute
;
397 attribute
= LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
398 LTTV_IATTRIBUTE(attributes_global
),
399 LTTV_VIEWER_CONSTRUCTORS
));
402 guint num
= lttv_iattribute_get_number(LTTV_IATTRIBUTE(attribute
));
404 LttvAttributeName name
;
405 LttvAttributeValue value
;
406 LttvAttributeType type
;
409 type
= lttv_iattribute_get(LTTV_IATTRIBUTE(attribute
), i
, &name
, &value
,
411 g_assert(type
== LTTV_POINTER
);
412 if(*(value
.v_pointer
) == view_constructor
) {
413 lttv_iattribute_remove(LTTV_IATTRIBUTE(attribute
), i
);
422 * Function to register a hook function for a viewer to set/update its
424 * @param tab viewer's tab
425 * @param hook hook function of the viewer.
426 * @param hook_data hook data associated with the hook function.
428 __EXPORT
void lttvwindow_register_time_window_notify(Tab
*tab
,
429 LttvHook hook
, gpointer hook_data
)
431 LttvAttributeValue value
;
435 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
436 "hooks/updatetimewindow", LTTV_POINTER
, &value
);
438 tmp
= (LttvHooks
*)*(value
.v_pointer
);
440 tmp
= lttv_hooks_new();
441 *(value
.v_pointer
) = tmp
;
443 lttv_hooks_add(tmp
, hook
,hook_data
, LTTV_PRIO_DEFAULT
);
448 * Function to unregister a viewer's hook function which is used to
449 * set/update the time interval of the viewer.
450 * @param tab viewer's tab
451 * @param hook hook function of the viewer.
452 * @param hook_data hook data associated with the hook function.
455 __EXPORT
void lttvwindow_unregister_time_window_notify(Tab
*tab
,
456 LttvHook hook
, gpointer hook_data
)
458 LttvAttributeValue value
;
462 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
463 "hooks/updatetimewindow", LTTV_POINTER
, &value
);
465 tmp
= (LttvHooks
*)*(value
.v_pointer
);
466 if(tmp
== NULL
) return;
467 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
471 * Function to register a hook function for a viewer to set/update its
473 * @param tab viewer's tab
474 * @param hook hook function of the viewer.
475 * @param hook_data hook data associated with the hook function.
477 __EXPORT
void lttvwindow_register_timespan_notify(Tab
*tab
,
478 LttvHook hook
, gpointer hook_data
)
480 LttvAttributeValue value
;
484 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
485 "hooks/updatetimespan", LTTV_POINTER
, &value
);
487 tmp
= (LttvHooks
*)*(value
.v_pointer
);
489 tmp
= lttv_hooks_new();
490 *(value
.v_pointer
) = tmp
;
492 lttv_hooks_add(tmp
, hook
,hook_data
, LTTV_PRIO_DEFAULT
);
495 * Function to unregister a viewer's hook function which is used to
496 * set/update the time span allowed for the viewer.
497 * @param tab viewer's tab
498 * @param hook hook function of the viewer.
499 * @param hook_data hook data associated with the hook function.
502 __EXPORT
void lttvwindow_unregister_timespan_notify(Tab
*tab
,
503 LttvHook hook
, gpointer hook_data
)
505 LttvAttributeValue value
;
509 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
510 "hooks/updatetimespan", LTTV_POINTER
, &value
);
512 tmp
= (LttvHooks
*)*(value
.v_pointer
);
513 if(tmp
== NULL
) return;
514 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
518 * Function to register a hook function for a viewer to set/update its
520 * @param tab viewer's tab
521 * @param hook hook function of the viewer.
522 * @param hook_data hook data associated with the hook function.
525 __EXPORT
void lttvwindow_register_traceset_notify(Tab
*tab
,
526 LttvHook hook
, gpointer hook_data
)
528 LttvAttributeValue value
;
532 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
533 "hooks/updatetraceset", LTTV_POINTER
, &value
);
535 tmp
= (LttvHooks
*)*(value
.v_pointer
);
537 tmp
= lttv_hooks_new();
538 *(value
.v_pointer
) = tmp
;
540 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
545 * Function to unregister a viewer's hook function which is used to
546 * set/update the traceset of the viewer.
547 * @param tab viewer's tab
548 * @param hook hook function of the viewer.
549 * @param hook_data hook data associated with the hook function.
552 __EXPORT
void lttvwindow_unregister_traceset_notify(Tab
*tab
,
553 LttvHook hook
, gpointer hook_data
)
555 LttvAttributeValue value
;
559 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
560 "hooks/updatetraceset", LTTV_POINTER
, &value
);
562 tmp
= (LttvHooks
*)*(value
.v_pointer
);
563 if(tmp
== NULL
) return;
564 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
568 * Function to register a hook function for a viewer be completely redrawn.
570 * @param tab viewer's tab
571 * @param hook hook function of the viewer.
572 * @param hook_data hook data associated with the hook function.
575 __EXPORT
void lttvwindow_register_redraw_notify(Tab
*tab
,
576 LttvHook hook
, gpointer hook_data
)
578 LttvAttributeValue value
;
582 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/redraw",
583 LTTV_POINTER
, &value
);
585 tmp
= (LttvHooks
*)*(value
.v_pointer
);
587 tmp
= lttv_hooks_new();
588 *(value
.v_pointer
) = tmp
;
590 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
595 * Function to unregister a hook function for a viewer be completely redrawn.
597 * @param tab viewer's tab
598 * @param hook hook function of the viewer.
599 * @param hook_data hook data associated with the hook function.
602 __EXPORT
void lttvwindow_unregister_redraw_notify(Tab
*tab
,
603 LttvHook hook
, gpointer hook_data
)
605 LttvAttributeValue value
;
609 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/redraw",
610 LTTV_POINTER
, &value
);
612 tmp
= (LttvHooks
*)*(value
.v_pointer
);
613 if(tmp
== NULL
) return;
614 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
618 * Function to register a hook function for a viewer to re-do the events
619 * requests for the needed interval.
621 * This action is typically done after a "stop".
623 * The typical hook will remove all current requests for the viewer
624 * and make requests for missing information.
626 * @param tab viewer's tab
627 * @param hook hook function of the viewer.
628 * @param hook_data hook data associated with the hook function.
631 __EXPORT
void lttvwindow_register_continue_notify(Tab
*tab
,
632 LttvHook hook
, gpointer hook_data
)
634 LttvAttributeValue value
;
638 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/continue",
639 LTTV_POINTER
, &value
);
641 tmp
= (LttvHooks
*)*(value
.v_pointer
);
643 tmp
= lttv_hooks_new();
644 *(value
.v_pointer
) = tmp
;
646 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
651 * Function to unregister a hook function for a viewer to re-do the events
652 * requests for the needed interval.
654 * @param tab viewer's tab
655 * @param hook hook function of the viewer.
656 * @param hook_data hook data associated with the hook function.
659 __EXPORT
void lttvwindow_unregister_continue_notify(Tab
*tab
,
660 LttvHook hook
, gpointer hook_data
)
662 LttvAttributeValue value
;
666 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/continue",
667 LTTV_POINTER
, &value
);
669 tmp
= (LttvHooks
*)*(value
.v_pointer
);
670 if(tmp
== NULL
) return;
671 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
676 * Function to register a hook function for a viewer to set/update its
678 * @param tab viewer's tab
679 * @param hook hook function of the viewer.
680 * @param hook_data hook data associated with the hook function.
683 __EXPORT
void lttvwindow_register_filter_notify(Tab
*tab
,
684 LttvHook hook
, gpointer hook_data
)
686 LttvAttributeValue value
;
690 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/updatefilter",
691 LTTV_POINTER
, &value
);
693 tmp
= (LttvHooks
*)*(value
.v_pointer
);
695 tmp
= lttv_hooks_new();
696 *(value
.v_pointer
) = tmp
;
698 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
703 * Function to unregister a viewer's hook function which is used to
704 * set/update the filter of the viewer.
705 * @param tab viewer's tab
706 * @param hook hook function of the viewer.
707 * @param hook_data hook data associated with the hook function.
710 __EXPORT
void lttvwindow_unregister_filter_notify(Tab
*tab
,
714 LttvAttributeValue value
;
718 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/updatefilter",
719 LTTV_POINTER
, &value
);
721 tmp
= (LttvHooks
*)*(value
.v_pointer
);
722 if(tmp
== NULL
) return;
723 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
727 * function to register a hook function for a viewer to set/update its
729 * @param tab viewer's tab
730 * @param hook hook function of the viewer.
731 * @param hook_data hook data associated with the hook function.
734 __EXPORT
void lttvwindow_register_current_time_notify(Tab
*tab
,
735 LttvHook hook
, gpointer hook_data
)
737 LttvAttributeValue value
;
741 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
742 "hooks/updatecurrenttime", LTTV_POINTER
, &value
);
744 tmp
= (LttvHooks
*)*(value
.v_pointer
);
746 tmp
= lttv_hooks_new();
747 *(value
.v_pointer
) = tmp
;
749 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
754 * function to unregister a viewer's hook function which is used to
755 * set/update the current time of the viewer.
756 * @param tab viewer's tab
757 * @param hook hook function of the viewer.
758 * @param hook_data hook data associated with the hook function.
761 __EXPORT
void lttvwindow_unregister_current_time_notify(Tab
*tab
,
762 LttvHook hook
, gpointer hook_data
)
764 LttvAttributeValue value
;
768 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
769 "hooks/updatecurrenttime", LTTV_POINTER
, &value
);
771 tmp
= (LttvHooks
*)*(value
.v_pointer
);
772 if(tmp
== NULL
) return;
773 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
777 * function to register a hook function for a viewer to set/update its
779 * @param tab viewer's tab
780 * @param hook hook function of the viewer.
781 * @param hook_data hook data associated with the hook function.
784 __EXPORT
void lttvwindow_register_current_position_notify(Tab
*tab
,
785 LttvHook hook
, gpointer hook_data
)
787 LttvAttributeValue value
;
791 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
792 "hooks/updatecurrentposition", LTTV_POINTER
, &value
);
794 tmp
= (LttvHooks
*)*(value
.v_pointer
);
796 tmp
= lttv_hooks_new();
797 *(value
.v_pointer
) = tmp
;
799 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
804 * function to unregister a viewer's hook function which is used to
805 * set/update the current position of the viewer.
806 * @param tab viewer's tab
807 * @param hook hook function of the viewer.
808 * @param hook_data hook data associated with the hook function.
811 __EXPORT
void lttvwindow_unregister_current_position_notify(Tab
*tab
,
812 LttvHook hook
, gpointer hook_data
)
814 LttvAttributeValue value
;
818 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
819 "hooks/updatecurrentposition", LTTV_POINTER
, &value
);
821 tmp
= (LttvHooks
*)*(value
.v_pointer
);
822 if(tmp
== NULL
) return;
823 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
828 * Function to register a hook function for a viewer to show
829 * the content of the viewer.
830 * @param tab viewer's tab
831 * @param hook hook function of the viewer.
832 * @param hook_data hook data associated with the hook function.
835 void lttvwindow_register_show_notify(Tab
*tab
,
836 LttvHook hook
, gpointer hook_data
)
838 LttvAttributeValue value
;
842 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/showviewer",
843 LTTV_POINTER
, &value
);
845 tmp
= (LttvHooks
*)*(value
.v_pointer
);
847 tmp
= lttv_hooks_new();
848 *(value
.v_pointer
) = tmp
;
850 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
855 * Function to unregister a viewer's hook function which is used to
856 * show the content of the viewer..
857 * @param tab viewer's tab
858 * @param hook hook function of the viewer.
859 * @param hook_data hook data associated with the hook function.
862 void lttvwindow_unregister_show_notify(Tab
*tab
,
863 LttvHook hook
, gpointer hook_data
)
865 LttvAttributeValue value
;
869 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/showviewer",
870 LTTV_POINTER
, &value
);
872 tmp
= (LttvHooks
*)*(value
.v_pointer
);
873 if(tmp
== NULL
) return;
874 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
878 * Function to register a hook function for a viewer to set/update the
879 * dividor of the hpane.
880 * @param tab viewer's tab
881 * @param hook hook function of the viewer.
882 * @param hook_data hook data associated with the hook function.
885 void lttvwindow_register_dividor(Tab
*tab
,
886 LttvHook hook
, gpointer hook_data
)
888 LttvAttributeValue value
;
892 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/hpanedividor",
893 LTTV_POINTER
, &value
);
895 tmp
= (LttvHooks
*)*(value
.v_pointer
);
897 tmp
= lttv_hooks_new();
898 *(value
.v_pointer
) = tmp
;
900 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
905 * Function to unregister a viewer's hook function which is used to
906 * set/update hpane's dividor of the viewer.
907 * It will be called by the destructor of the viewer.
908 * @param tab viewer's tab
909 * @param hook hook function of the viewer.
910 * @param hook_data hook data associated with the hook function.
913 void lttvwindow_unregister_dividor(Tab
*tab
,
914 LttvHook hook
, gpointer hook_data
)
916 LttvAttributeValue value
;
920 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/hpanedividor",
921 LTTV_POINTER
, &value
);
923 tmp
= (LttvHooks
*)*(value
.v_pointer
);
924 if(tmp
== NULL
) return;
925 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
930 * Function to set the time interval of the current tab.
931 * It will be called by a viewer's signal handle associated with
932 * the move_slider signal
933 * @param tab viewer's tab
934 * @param time_interval a pointer where time interval is stored.
937 __EXPORT
void lttvwindow_report_time_window(Tab
*tab
,
938 TimeWindow time_window
)
940 //set_time_window(tab, time_window);
941 //set_time_window_adjustment(tab, time_window);
943 time_change_manager(tab
, time_window
);
948 LttvTracesetContext
*tsc
=
949 LTTV_TRACESET_CONTEXT(tab
->traceset_info
->traceset_context
);
950 TimeInterval time_span
= tsc
->time_span
;
951 GtkAdjustment
*adjustment
= gtk_range_get_adjustment(GTK_RANGE(tab
->scrollbar
));
952 g_object_set(G_OBJECT(adjustment
),
957 ltt_time_sub(time_span
.end_time
, time_span
.start_time
))
960 ltt_time_to_double(time_window
->time_width
)
961 / SCROLL_STEP_PER_PAGE
962 , /* step increment */
964 ltt_time_to_double(time_window
->time_width
)
965 , /* page increment */
967 ltt_time_to_double(time_window
->time_width
)
970 gtk_adjustment_changed(adjustment
);
972 //g_object_set(G_OBJECT(adjustment),
974 // ltt_time_to_double(time_window->start_time)
977 /* Note : the set value will call set_time_window if scrollbar value changed
979 gtk_adjustment_set_value(adjustment
,
981 ltt_time_sub(time_window
->start_time
,
982 time_span
.start_time
))
989 * Function to set the current time of the current tab.
990 * It will be called by a viewer's signal handle associated with
991 * the button-release-event signal
992 * @param tab viewer's tab
993 * @param time a pointer where time is stored.
996 __EXPORT
void lttvwindow_report_current_time(Tab
*tab
,
999 current_time_change_manager(tab
, time
);
1003 * Function to set the current event of the current tab.
1004 * It will be called by a viewer's signal handle associated with
1005 * the button-release-event signal
1006 * @param tab viewer's tab
1007 * @param time a pointer where time is stored.
1010 __EXPORT
void lttvwindow_report_current_position(Tab
*tab
,
1011 LttvTracesetContextPosition
*pos
)
1013 current_position_change_manager(tab
, pos
);
1018 * Function to set the position of the hpane's dividor (viewer).
1019 * It will be called by a viewer's signal handle associated with
1020 * the motion_notify_event event/signal
1021 * @param tab viewer's tab
1022 * @param position position of the hpane's dividor.
1025 void lttvwindow_report_dividor(Tab
*tab
, gint position
)
1027 LttvAttributeValue value
;
1031 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/hpanedividor",
1032 LTTV_POINTER
, &value
);
1034 tmp
= (LttvHooks
*)*(value
.v_pointer
);
1035 if(tmp
== NULL
) return;
1036 lttv_hooks_call(tmp
, &position
);
1040 * Function to request data in a specific time interval to the main window. The
1041 * event request servicing is differed until the glib idle functions are
1044 * The viewer has to provide hooks that should be associated with the event
1047 * Either start time or start position must be defined in a EventRequest
1048 * structure for it to be valid.
1050 * end_time, end_position and num_events can all be defined. The first one
1051 * to occur will be used as end criterion.
1053 * @param tab viewer's tab
1054 * @param events_requested the structure of request from.
1057 __EXPORT
void lttvwindow_events_request(Tab
*tab
,
1058 EventsRequest
*events_request
)
1060 tab
->events_requests
= g_slist_append(tab
->events_requests
, events_request
);
1062 if(!tab
->events_request_pending
)
1064 /* Redraw has +20 priority. We want to let the redraw be done while we do
1065 * our job. Mathieu : test with high prio higher than events for better
1067 /* Mathieu, 2008 : ok, finally, the control flow view needs the cell updates
1068 * to come soon enough so we can have one active cell to get the pixmap
1069 * buffer height from. Therefore, let the gdk events run before the events
1072 g_idle_add_full((G_PRIORITY_HIGH_IDLE
+ 21),
1073 //g_idle_add_full((G_PRIORITY_DEFAULT + 2),
1074 (GSourceFunc
)execute_events_requests
,
1077 tab
->events_request_pending
= TRUE
;
1083 * Function to remove data requests related to a viewer.
1085 * The existing requests's viewer gpointer is compared to the pointer
1086 * given in argument to establish which data request should be removed.
1088 * @param tab the tab the viewer belongs to.
1089 * @param viewer a pointer to the viewer data structure
1092 gint
find_viewer (const EventsRequest
*a
, gconstpointer b
)
1094 return (a
->owner
!= b
);
1098 __EXPORT
void lttvwindow_events_request_remove_all(Tab
*tab
,
1099 gconstpointer viewer
)
1101 GSList
*element
= tab
->events_requests
;
1104 g_slist_find_custom(element
, viewer
,
1105 (GCompareFunc
)find_viewer
))
1107 EventsRequest
*events_request
= (EventsRequest
*)element
->data
;
1108 // Modified so a viewer being destroyed won't have its after_request
1109 // called. Not so important anyway. Note that a viewer that call this
1110 // remove_all function will not get its after_request called.
1111 //if(events_request->servicing == TRUE) {
1112 // lttv_hooks_call(events_request->after_request, NULL);
1114 events_request_free(events_request
);
1115 //g_free(events_request);
1116 tab
->events_requests
= g_slist_remove_link(tab
->events_requests
, element
);
1117 element
= g_slist_next(element
);
1118 if(element
== NULL
) break; /* end of list */
1120 if(g_slist_length(tab
->events_requests
) == 0) {
1121 tab
->events_request_pending
= FALSE
;
1122 g_idle_remove_by_data(tab
);
1129 * Function to see if there are events request pending.
1131 * It tells if events requests are pending. Useful for checks in some events,
1132 * i.e. detailed event list scrolling.
1134 * @param tab the tab the viewer belongs to.
1135 * @param viewer a pointer to the viewer data structure
1136 * @return : TRUE is events requests are pending, else FALSE.
1139 __EXPORT gboolean
lttvwindow_events_request_pending(Tab
*tab
)
1141 GSList
*element
= tab
->events_requests
;
1143 if(element
== NULL
) return FALSE
;
1149 * Function to get the current time interval shown on the current tab.
1150 * It will be called by a viewer's hook function to update the
1151 * shown time interval of the viewer and also be called by the constructor
1153 * @param tab viewer's tab
1154 * @return time window.
1157 __EXPORT TimeWindow
lttvwindow_get_time_window(Tab
*tab
)
1159 return tab
->time_window
;
1164 * Function to get the current time/event of the current tab.
1165 * It will be called by a viewer's hook function to update the
1166 * current time/event of the viewer.
1167 * @param tab viewer's tab
1171 __EXPORT LttTime
lttvwindow_get_current_time(Tab
*tab
)
1173 return tab
->current_time
;
1178 * Function to get the filter of the current tab.
1179 * @param filter, a pointer to a filter.
1181 * returns the current filter
1183 __EXPORT LttvFilter
*lttvwindow_get_filter(Tab
*tab
)
1185 return g_object_get_data(G_OBJECT(tab
->vbox
), "filter");
1189 * Function to set the filter of the current tab.
1190 * It should be called by the filter GUI to tell the
1191 * main window to update the filter tab's lttv_filter.
1193 * This function does change the current filter, removing the
1194 * old one when necessary, and call the updatefilter hooks
1195 * of the registered viewers.
1197 * @param main_win, the main window the viewer belongs to.
1198 * @param filter, a pointer to a filter.
1200 void lttvwindow_report_filter(Tab
*tab
, LttvFilter
*filter
)
1202 LttvAttributeValue value
;
1206 //lttv_filter_destroy(tab->filter);
1207 //tab->filter = filter;
1209 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/updatefilter",
1210 LTTV_POINTER
, &value
);
1212 tmp
= (LttvHooks
*)*(value
.v_pointer
);
1213 if(tmp
== NULL
) return;
1214 lttv_hooks_call(tmp
, filter
);
1220 * Function to get the stats of the traceset
1221 * @param tab viewer's tab
1224 __EXPORT LttvTracesetStats
* lttvwindow_get_traceset_stats(Tab
*tab
)
1226 return tab
->traceset_info
->traceset_context
;
1229 __EXPORT LttvTracesetContext
* lttvwindow_get_traceset_context(Tab
*tab
)
1231 return (LttvTracesetContext
*)tab
->traceset_info
->traceset_context
;
1235 void events_request_free(EventsRequest
*events_request
)
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
);
1274 __EXPORT GtkWidget
*main_window_get_widget(Tab
*tab
)
1276 return tab
->mw
->mwindow
;