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.
478 __EXPORT
void lttvwindow_register_traceset_notify(Tab
*tab
,
479 LttvHook hook
, gpointer hook_data
)
481 LttvAttributeValue value
;
485 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
486 "hooks/updatetraceset", 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
);
498 * Function to unregister a viewer's hook function which is used to
499 * set/update the traceset of the viewer.
500 * @param tab viewer's tab
501 * @param hook hook function of the viewer.
502 * @param hook_data hook data associated with the hook function.
505 __EXPORT
void lttvwindow_unregister_traceset_notify(Tab
*tab
,
506 LttvHook hook
, gpointer hook_data
)
508 LttvAttributeValue value
;
512 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
513 "hooks/updatetraceset", LTTV_POINTER
, &value
);
515 tmp
= (LttvHooks
*)*(value
.v_pointer
);
516 if(tmp
== NULL
) return;
517 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
521 * Function to register a hook function for a viewer be completely redrawn.
523 * @param tab viewer's tab
524 * @param hook hook function of the viewer.
525 * @param hook_data hook data associated with the hook function.
528 __EXPORT
void lttvwindow_register_redraw_notify(Tab
*tab
,
529 LttvHook hook
, gpointer hook_data
)
531 LttvAttributeValue value
;
535 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/redraw",
536 LTTV_POINTER
, &value
);
538 tmp
= (LttvHooks
*)*(value
.v_pointer
);
540 tmp
= lttv_hooks_new();
541 *(value
.v_pointer
) = tmp
;
543 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
548 * Function to unregister a hook function for a viewer be completely redrawn.
550 * @param tab viewer's tab
551 * @param hook hook function of the viewer.
552 * @param hook_data hook data associated with the hook function.
555 __EXPORT
void lttvwindow_unregister_redraw_notify(Tab
*tab
,
556 LttvHook hook
, gpointer hook_data
)
558 LttvAttributeValue value
;
562 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/redraw",
563 LTTV_POINTER
, &value
);
565 tmp
= (LttvHooks
*)*(value
.v_pointer
);
566 if(tmp
== NULL
) return;
567 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
571 * Function to register a hook function for a viewer to re-do the events
572 * requests for the needed interval.
574 * This action is typically done after a "stop".
576 * The typical hook will remove all current requests for the viewer
577 * and make requests for missing information.
579 * @param tab viewer's tab
580 * @param hook hook function of the viewer.
581 * @param hook_data hook data associated with the hook function.
584 __EXPORT
void lttvwindow_register_continue_notify(Tab
*tab
,
585 LttvHook hook
, gpointer hook_data
)
587 LttvAttributeValue value
;
591 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/continue",
592 LTTV_POINTER
, &value
);
594 tmp
= (LttvHooks
*)*(value
.v_pointer
);
596 tmp
= lttv_hooks_new();
597 *(value
.v_pointer
) = tmp
;
599 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
604 * Function to unregister a hook function for a viewer to re-do the events
605 * requests for the needed interval.
607 * @param tab viewer's tab
608 * @param hook hook function of the viewer.
609 * @param hook_data hook data associated with the hook function.
612 __EXPORT
void lttvwindow_unregister_continue_notify(Tab
*tab
,
613 LttvHook hook
, gpointer hook_data
)
615 LttvAttributeValue value
;
619 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/continue",
620 LTTV_POINTER
, &value
);
622 tmp
= (LttvHooks
*)*(value
.v_pointer
);
623 if(tmp
== NULL
) return;
624 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
629 * Function to register a hook function for a viewer to set/update its
631 * @param tab viewer's tab
632 * @param hook hook function of the viewer.
633 * @param hook_data hook data associated with the hook function.
636 __EXPORT
void lttvwindow_register_filter_notify(Tab
*tab
,
637 LttvHook hook
, gpointer hook_data
)
639 LttvAttributeValue value
;
643 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/updatefilter",
644 LTTV_POINTER
, &value
);
646 tmp
= (LttvHooks
*)*(value
.v_pointer
);
648 tmp
= lttv_hooks_new();
649 *(value
.v_pointer
) = tmp
;
651 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
656 * Function to unregister a viewer's hook function which is used to
657 * set/update the filter of the viewer.
658 * @param tab viewer's tab
659 * @param hook hook function of the viewer.
660 * @param hook_data hook data associated with the hook function.
663 __EXPORT
void lttvwindow_unregister_filter_notify(Tab
*tab
,
667 LttvAttributeValue value
;
671 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/updatefilter",
672 LTTV_POINTER
, &value
);
674 tmp
= (LttvHooks
*)*(value
.v_pointer
);
675 if(tmp
== NULL
) return;
676 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
680 * function to register a hook function for a viewer to set/update its
682 * @param tab viewer's tab
683 * @param hook hook function of the viewer.
684 * @param hook_data hook data associated with the hook function.
687 __EXPORT
void lttvwindow_register_current_time_notify(Tab
*tab
,
688 LttvHook hook
, gpointer hook_data
)
690 LttvAttributeValue value
;
694 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
695 "hooks/updatecurrenttime", LTTV_POINTER
, &value
);
697 tmp
= (LttvHooks
*)*(value
.v_pointer
);
699 tmp
= lttv_hooks_new();
700 *(value
.v_pointer
) = tmp
;
702 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
707 * function to unregister a viewer's hook function which is used to
708 * set/update the current time of the viewer.
709 * @param tab viewer's tab
710 * @param hook hook function of the viewer.
711 * @param hook_data hook data associated with the hook function.
714 __EXPORT
void lttvwindow_unregister_current_time_notify(Tab
*tab
,
715 LttvHook hook
, gpointer hook_data
)
717 LttvAttributeValue value
;
721 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
722 "hooks/updatecurrenttime", LTTV_POINTER
, &value
);
724 tmp
= (LttvHooks
*)*(value
.v_pointer
);
725 if(tmp
== NULL
) return;
726 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
730 * function to register a hook function for a viewer to set/update its
732 * @param tab viewer's tab
733 * @param hook hook function of the viewer.
734 * @param hook_data hook data associated with the hook function.
737 __EXPORT
void lttvwindow_register_current_position_notify(Tab
*tab
,
738 LttvHook hook
, gpointer hook_data
)
740 LttvAttributeValue value
;
744 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
745 "hooks/updatecurrentposition", LTTV_POINTER
, &value
);
747 tmp
= (LttvHooks
*)*(value
.v_pointer
);
749 tmp
= lttv_hooks_new();
750 *(value
.v_pointer
) = tmp
;
752 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
757 * function to unregister a viewer's hook function which is used to
758 * set/update the current position of the viewer.
759 * @param tab viewer's tab
760 * @param hook hook function of the viewer.
761 * @param hook_data hook data associated with the hook function.
764 __EXPORT
void lttvwindow_unregister_current_position_notify(Tab
*tab
,
765 LttvHook hook
, gpointer hook_data
)
767 LttvAttributeValue value
;
771 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
772 "hooks/updatecurrentposition", LTTV_POINTER
, &value
);
774 tmp
= (LttvHooks
*)*(value
.v_pointer
);
775 if(tmp
== NULL
) return;
776 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
781 * Function to register a hook function for a viewer to show
782 * the content of the viewer.
783 * @param tab viewer's tab
784 * @param hook hook function of the viewer.
785 * @param hook_data hook data associated with the hook function.
788 void lttvwindow_register_show_notify(Tab
*tab
,
789 LttvHook hook
, gpointer hook_data
)
791 LttvAttributeValue value
;
795 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/showviewer",
796 LTTV_POINTER
, &value
);
798 tmp
= (LttvHooks
*)*(value
.v_pointer
);
800 tmp
= lttv_hooks_new();
801 *(value
.v_pointer
) = tmp
;
803 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
808 * Function to unregister a viewer's hook function which is used to
809 * show the content of the viewer..
810 * @param tab viewer's tab
811 * @param hook hook function of the viewer.
812 * @param hook_data hook data associated with the hook function.
815 void lttvwindow_unregister_show_notify(Tab
*tab
,
816 LttvHook hook
, gpointer hook_data
)
818 LttvAttributeValue value
;
822 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/showviewer",
823 LTTV_POINTER
, &value
);
825 tmp
= (LttvHooks
*)*(value
.v_pointer
);
826 if(tmp
== NULL
) return;
827 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
831 * Function to register a hook function for a viewer to set/update the
832 * dividor of the hpane.
833 * @param tab viewer's tab
834 * @param hook hook function of the viewer.
835 * @param hook_data hook data associated with the hook function.
838 void lttvwindow_register_dividor(Tab
*tab
,
839 LttvHook hook
, gpointer hook_data
)
841 LttvAttributeValue value
;
845 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/hpanedividor",
846 LTTV_POINTER
, &value
);
848 tmp
= (LttvHooks
*)*(value
.v_pointer
);
850 tmp
= lttv_hooks_new();
851 *(value
.v_pointer
) = tmp
;
853 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
858 * Function to unregister a viewer's hook function which is used to
859 * set/update hpane's dividor of the viewer.
860 * It will be called by the destructor of the viewer.
861 * @param tab viewer's tab
862 * @param hook hook function of the viewer.
863 * @param hook_data hook data associated with the hook function.
866 void lttvwindow_unregister_dividor(Tab
*tab
,
867 LttvHook hook
, gpointer hook_data
)
869 LttvAttributeValue value
;
873 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/hpanedividor",
874 LTTV_POINTER
, &value
);
876 tmp
= (LttvHooks
*)*(value
.v_pointer
);
877 if(tmp
== NULL
) return;
878 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
883 * Function to set the time interval of the current tab.
884 * It will be called by a viewer's signal handle associated with
885 * the move_slider signal
886 * @param tab viewer's tab
887 * @param time_interval a pointer where time interval is stored.
890 __EXPORT
void lttvwindow_report_time_window(Tab
*tab
,
891 TimeWindow time_window
)
893 //set_time_window(tab, time_window);
894 //set_time_window_adjustment(tab, time_window);
896 time_change_manager(tab
, time_window
);
901 LttvTracesetContext
*tsc
=
902 LTTV_TRACESET_CONTEXT(tab
->traceset_info
->traceset_context
);
903 TimeInterval time_span
= tsc
->time_span
;
904 GtkAdjustment
*adjustment
= gtk_range_get_adjustment(GTK_RANGE(tab
->scrollbar
));
905 g_object_set(G_OBJECT(adjustment
),
910 ltt_time_sub(time_span
.end_time
, time_span
.start_time
))
913 ltt_time_to_double(time_window
->time_width
)
914 / SCROLL_STEP_PER_PAGE
915 , /* step increment */
917 ltt_time_to_double(time_window
->time_width
)
918 , /* page increment */
920 ltt_time_to_double(time_window
->time_width
)
923 gtk_adjustment_changed(adjustment
);
925 //g_object_set(G_OBJECT(adjustment),
927 // ltt_time_to_double(time_window->start_time)
930 /* Note : the set value will call set_time_window if scrollbar value changed
932 gtk_adjustment_set_value(adjustment
,
934 ltt_time_sub(time_window
->start_time
,
935 time_span
.start_time
))
942 * Function to set the current time of the current tab.
943 * It will be called by a viewer's signal handle associated with
944 * the button-release-event signal
945 * @param tab viewer's tab
946 * @param time a pointer where time is stored.
949 __EXPORT
void lttvwindow_report_current_time(Tab
*tab
,
952 current_time_change_manager(tab
, time
);
956 * Function to set the current event of the current tab.
957 * It will be called by a viewer's signal handle associated with
958 * the button-release-event signal
959 * @param tab viewer's tab
960 * @param time a pointer where time is stored.
963 __EXPORT
void lttvwindow_report_current_position(Tab
*tab
,
964 LttvTracesetContextPosition
*pos
)
966 current_position_change_manager(tab
, pos
);
971 * Function to set the position of the hpane's dividor (viewer).
972 * It will be called by a viewer's signal handle associated with
973 * the motion_notify_event event/signal
974 * @param tab viewer's tab
975 * @param position position of the hpane's dividor.
978 void lttvwindow_report_dividor(Tab
*tab
, gint position
)
980 LttvAttributeValue value
;
984 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/hpanedividor",
985 LTTV_POINTER
, &value
);
987 tmp
= (LttvHooks
*)*(value
.v_pointer
);
988 if(tmp
== NULL
) return;
989 lttv_hooks_call(tmp
, &position
);
993 * Function to request data in a specific time interval to the main window. The
994 * event request servicing is differed until the glib idle functions are
997 * The viewer has to provide hooks that should be associated with the event
1000 * Either start time or start position must be defined in a EventRequest
1001 * structure for it to be valid.
1003 * end_time, end_position and num_events can all be defined. The first one
1004 * to occur will be used as end criterion.
1006 * @param tab viewer's tab
1007 * @param events_requested the structure of request from.
1010 __EXPORT
void lttvwindow_events_request(Tab
*tab
,
1011 EventsRequest
*events_request
)
1013 tab
->events_requests
= g_slist_append(tab
->events_requests
, events_request
);
1015 if(!tab
->events_request_pending
)
1017 /* Redraw has +20 priority. We want to let the redraw be done while we do
1018 * our job. Mathieu : test with high prio higher than events for better
1020 /* Mathieu, 2008 : ok, finally, the control flow view needs the cell updates
1021 * to come soon enough so we can have one active cell to get the pixmap
1022 * buffer height from. Therefore, let the gdk events run before the events
1025 g_idle_add_full((G_PRIORITY_HIGH_IDLE
+ 21),
1026 //g_idle_add_full((G_PRIORITY_DEFAULT + 2),
1027 (GSourceFunc
)execute_events_requests
,
1030 tab
->events_request_pending
= TRUE
;
1036 * Function to remove data requests related to a viewer.
1038 * The existing requests's viewer gpointer is compared to the pointer
1039 * given in argument to establish which data request should be removed.
1041 * @param tab the tab the viewer belongs to.
1042 * @param viewer a pointer to the viewer data structure
1045 gint
find_viewer (const EventsRequest
*a
, gconstpointer b
)
1047 return (a
->owner
!= b
);
1051 __EXPORT
void lttvwindow_events_request_remove_all(Tab
*tab
,
1052 gconstpointer viewer
)
1054 GSList
*element
= tab
->events_requests
;
1057 g_slist_find_custom(element
, viewer
,
1058 (GCompareFunc
)find_viewer
))
1060 EventsRequest
*events_request
= (EventsRequest
*)element
->data
;
1061 // Modified so a viewer being destroyed won't have its after_request
1062 // called. Not so important anyway. Note that a viewer that call this
1063 // remove_all function will not get its after_request called.
1064 //if(events_request->servicing == TRUE) {
1065 // lttv_hooks_call(events_request->after_request, NULL);
1067 events_request_free(events_request
);
1068 //g_free(events_request);
1069 tab
->events_requests
= g_slist_remove_link(tab
->events_requests
, element
);
1070 element
= g_slist_next(element
);
1071 if(element
== NULL
) break; /* end of list */
1073 if(g_slist_length(tab
->events_requests
) == 0) {
1074 tab
->events_request_pending
= FALSE
;
1075 g_idle_remove_by_data(tab
);
1082 * Function to see if there are events request pending.
1084 * It tells if events requests are pending. Useful for checks in some events,
1085 * i.e. detailed event list scrolling.
1087 * @param tab the tab the viewer belongs to.
1088 * @param viewer a pointer to the viewer data structure
1089 * @return : TRUE is events requests are pending, else FALSE.
1092 __EXPORT gboolean
lttvwindow_events_request_pending(Tab
*tab
)
1094 GSList
*element
= tab
->events_requests
;
1096 if(element
== NULL
) return FALSE
;
1102 * Function to get the current time interval shown on the current tab.
1103 * It will be called by a viewer's hook function to update the
1104 * shown time interval of the viewer and also be called by the constructor
1106 * @param tab viewer's tab
1107 * @return time window.
1110 __EXPORT TimeWindow
lttvwindow_get_time_window(Tab
*tab
)
1112 return tab
->time_window
;
1117 * Function to get the current time/event of the current tab.
1118 * It will be called by a viewer's hook function to update the
1119 * current time/event of the viewer.
1120 * @param tab viewer's tab
1124 __EXPORT LttTime
lttvwindow_get_current_time(Tab
*tab
)
1126 return tab
->current_time
;
1131 * Function to get the filter of the current tab.
1132 * @param filter, a pointer to a filter.
1134 * returns the current filter
1136 __EXPORT LttvFilter
*lttvwindow_get_filter(Tab
*tab
)
1138 return g_object_get_data(G_OBJECT(tab
->vbox
), "filter");
1142 * Function to set the filter of the current tab.
1143 * It should be called by the filter GUI to tell the
1144 * main window to update the filter tab's lttv_filter.
1146 * This function does change the current filter, removing the
1147 * old one when necessary, and call the updatefilter hooks
1148 * of the registered viewers.
1150 * @param main_win, the main window the viewer belongs to.
1151 * @param filter, a pointer to a filter.
1153 void lttvwindow_report_filter(Tab
*tab
, LttvFilter
*filter
)
1155 LttvAttributeValue value
;
1159 //lttv_filter_destroy(tab->filter);
1160 //tab->filter = filter;
1162 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/updatefilter",
1163 LTTV_POINTER
, &value
);
1165 tmp
= (LttvHooks
*)*(value
.v_pointer
);
1166 if(tmp
== NULL
) return;
1167 lttv_hooks_call(tmp
, filter
);
1173 * Function to get the stats of the traceset
1174 * @param tab viewer's tab
1177 __EXPORT LttvTracesetStats
* lttvwindow_get_traceset_stats(Tab
*tab
)
1179 return tab
->traceset_info
->traceset_context
;
1182 __EXPORT LttvTracesetContext
* lttvwindow_get_traceset_context(Tab
*tab
)
1184 return (LttvTracesetContext
*)tab
->traceset_info
->traceset_context
;
1188 void events_request_free(EventsRequest
*events_request
)
1190 if(events_request
== NULL
) return;
1192 if(events_request
->start_position
!= NULL
)
1193 lttv_traceset_context_position_destroy(events_request
->start_position
);
1194 if(events_request
->end_position
!= NULL
)
1195 lttv_traceset_context_position_destroy(events_request
->end_position
);
1196 if(events_request
->hooks
!= NULL
) {
1197 GArray
*hooks
= events_request
->hooks
;
1198 lttv_trace_hook_remove_all(&hooks
);
1199 g_array_free(events_request
->hooks
, TRUE
);
1201 if(events_request
->before_chunk_traceset
!= NULL
)
1202 lttv_hooks_destroy(events_request
->before_chunk_traceset
);
1203 if(events_request
->before_chunk_trace
!= NULL
)
1204 lttv_hooks_destroy(events_request
->before_chunk_trace
);
1205 if(events_request
->before_chunk_tracefile
!= NULL
)
1206 lttv_hooks_destroy(events_request
->before_chunk_tracefile
);
1207 if(events_request
->event
!= NULL
)
1208 lttv_hooks_destroy(events_request
->event
);
1209 if(events_request
->event_by_id_channel
!= NULL
)
1210 lttv_hooks_by_id_channel_destroy(events_request
->event_by_id_channel
);
1211 if(events_request
->after_chunk_tracefile
!= NULL
)
1212 lttv_hooks_destroy(events_request
->after_chunk_tracefile
);
1213 if(events_request
->after_chunk_trace
!= NULL
)
1214 lttv_hooks_destroy(events_request
->after_chunk_trace
);
1215 if(events_request
->after_chunk_traceset
!= NULL
)
1216 lttv_hooks_destroy(events_request
->after_chunk_traceset
);
1217 if(events_request
->before_request
!= NULL
)
1218 lttv_hooks_destroy(events_request
->before_request
);
1219 if(events_request
->after_request
!= NULL
)
1220 lttv_hooks_destroy(events_request
->after_request
);
1222 g_free(events_request
);
1227 __EXPORT GtkWidget
*main_window_get_widget(Tab
*tab
)
1229 return tab
->mw
->mwindow
;