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
);
130 if(tmp
!= NULL
) lttv_hooks_call(tmp
, pos
);
133 void add_toolbar_constructor(MainWindow
*mw
, LttvToolbarClosure
*toolbar_c
)
135 LttvIAttribute
*attributes
= mw
->attributes
;
136 LttvAttributeValue value
;
137 LttvToolbars
* instance_toolbar
;
138 lttvwindow_viewer_constructor constructor
;
139 GtkWidget
* tool_menu_title_menu
, *new_widget
, *pixmap
;
143 retval
= lttv_iattribute_find_by_path(attributes
, "viewers/toolbar",
144 LTTV_POINTER
, &value
);
146 if(*(value
.v_pointer
) == NULL
)
147 *(value
.v_pointer
) = lttv_toolbars_new();
148 instance_toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
150 constructor
= toolbar_c
->con
;
151 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"MToolbar1");
152 pixbuf
= gdk_pixbuf_new_from_xpm_data((const char**)toolbar_c
->pixmap
);
153 pixmap
= gtk_image_new_from_pixbuf(pixbuf
);
155 gtk_toolbar_append_element (GTK_TOOLBAR (tool_menu_title_menu
),
156 GTK_TOOLBAR_CHILD_BUTTON
,
159 toolbar_c
->tooltip
, NULL
,
161 gtk_label_set_use_underline(
162 GTK_LABEL (((GtkToolbarChild
*) (
163 g_list_last (GTK_TOOLBAR
164 (tool_menu_title_menu
)->children
)->data
))->label
),
166 gtk_container_set_border_width (GTK_CONTAINER (new_widget
), 1);
167 g_signal_connect ((gpointer
) new_widget
,
169 G_CALLBACK (insert_viewer_wrap
),
171 gtk_widget_show (new_widget
);
173 lttv_toolbars_add(instance_toolbar
, toolbar_c
->con
,
180 void add_menu_constructor(MainWindow
*mw
, LttvMenuClosure
*menu_c
)
182 LttvIAttribute
*attributes
= mw
->attributes
;
183 LttvAttributeValue value
;
184 LttvToolbars
* instance_menu
;
185 lttvwindow_viewer_constructor constructor
;
186 GtkWidget
* tool_menu_title_menu
, *new_widget
;
189 retval
= lttv_iattribute_find_by_path(attributes
, "viewers/menu",
190 LTTV_POINTER
, &value
);
192 if(*(value
.v_pointer
) == NULL
)
193 *(value
.v_pointer
) = lttv_menus_new();
194 instance_menu
= (LttvMenus
*)*(value
.v_pointer
);
197 constructor
= menu_c
->con
;
198 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"ToolMenuTitle_menu");
200 gtk_menu_item_new_with_mnemonic (menu_c
->menu_text
);
201 gtk_container_add (GTK_CONTAINER (tool_menu_title_menu
),
203 g_signal_connect ((gpointer
) new_widget
, "activate",
204 G_CALLBACK (insert_viewer_wrap
),
206 gtk_widget_show (new_widget
);
207 lttv_menus_add(instance_menu
, menu_c
->con
,
213 void remove_toolbar_constructor(MainWindow
*mw
, lttvwindow_viewer_constructor viewer_constructor
)
215 LttvIAttribute
*attributes
= mw
->attributes
;
216 LttvAttributeValue value
;
217 LttvToolbars
* instance_toolbar
;
218 GtkWidget
* tool_menu_title_menu
, *widget
;
221 retval
= lttv_iattribute_find_by_path(attributes
, "viewers/toolbar",
222 LTTV_POINTER
, &value
);
224 if(*(value
.v_pointer
) == NULL
)
225 *(value
.v_pointer
) = lttv_toolbars_new();
226 instance_toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
228 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"MToolbar1");
229 widget
= lttv_menus_remove(instance_toolbar
, viewer_constructor
);
230 gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu
),
235 void remove_menu_constructor(MainWindow
*mw
, lttvwindow_viewer_constructor viewer_constructor
)
237 LttvIAttribute
*attributes
= mw
->attributes
;
238 LttvAttributeValue value
;
239 LttvMenus
* instance_menu
;
240 GtkWidget
* tool_menu_title_menu
, *widget
;
243 retval
= lttv_iattribute_find_by_path(attributes
, "viewers/menu",
244 LTTV_POINTER
, &value
);
246 if(*(value
.v_pointer
) == NULL
)
247 *(value
.v_pointer
) = lttv_menus_new();
248 instance_menu
= (LttvMenus
*)*(value
.v_pointer
);
250 widget
= lttv_menus_remove(instance_menu
, viewer_constructor
);
251 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"ToolMenuTitle_menu");
252 gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu
), widget
);
262 * Function to register a view constructor so that main window can generate
263 * a menu item and a toolbar item for the viewer in order to generate a new
264 * instance easily. A menu entry and toolbar item will be added to each main
267 * It should be called by init function of the module.
269 * @param name name of the viewer
270 * @param menu_path path of the menu item.
271 * @param menu_text text of the menu item.
272 * @param pixmap Image shown on the toolbar item.
273 * @param tooltip tooltip of the toolbar item.
274 * @param view_constructor constructor of the viewer.
277 __EXPORT
void lttvwindow_register_constructor
283 lttvwindow_viewer_constructor view_constructor
)
285 LttvIAttribute
*attributes_global
= LTTV_IATTRIBUTE(lttv_global_attributes());
286 LttvToolbars
* toolbar
;
288 LttvToolbarClosure toolbar_c
;
289 LttvMenuClosure menu_c
;
290 LttvAttributeValue value
;
293 if(view_constructor
== NULL
) return;
296 retval
= lttv_iattribute_find_by_path(attributes_global
, "viewers/toolbar",
297 LTTV_POINTER
, &value
);
299 toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
301 if(toolbar
== NULL
) {
302 toolbar
= lttv_toolbars_new();
303 *(value
.v_pointer
) = toolbar
;
305 toolbar_c
= lttv_toolbars_add(toolbar
, view_constructor
, tooltip
, pixmap
,
308 g_slist_foreach(g_main_window_list
,
309 (gpointer
)add_toolbar_constructor
,
313 if(menu_path
!= NULL
) {
314 retval
= lttv_iattribute_find_by_path(attributes_global
, "viewers/menu",
315 LTTV_POINTER
, &value
);
317 menu
= (LttvMenus
*)*(value
.v_pointer
);
320 menu
= lttv_menus_new();
321 *(value
.v_pointer
) = menu
;
323 menu_c
= lttv_menus_add(menu
, view_constructor
, menu_path
, menu_text
,NULL
);
325 g_slist_foreach(g_main_window_list
,
326 (gpointer
)add_menu_constructor
,
330 LttvAttribute
*attribute
;
333 attribute
= LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
334 LTTV_IATTRIBUTE(attributes_global
),
335 LTTV_VIEWER_CONSTRUCTORS
));
338 result
= lttv_iattribute_find_by_path(LTTV_IATTRIBUTE(attribute
),
339 name
, LTTV_POINTER
, &value
);
342 *(value
.v_pointer
) = view_constructor
;
349 * Function to unregister the viewer's constructor, release the space
350 * occupied by menu_path, menu_text, pixmap, tooltip and constructor of the
353 * It will be called when a module is unloaded.
355 * @param view_constructor constructor of the viewer.
359 __EXPORT
void lttvwindow_unregister_constructor
360 (lttvwindow_viewer_constructor view_constructor
)
362 LttvIAttribute
*attributes_global
= LTTV_IATTRIBUTE(lttv_global_attributes());
363 LttvToolbars
* toolbar
;
365 LttvAttributeValue value
;
369 retval
= lttv_iattribute_find_by_path(attributes_global
, "viewers/toolbar",
370 LTTV_POINTER
, &value
);
372 toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
374 if(toolbar
!= NULL
) {
375 g_slist_foreach(g_main_window_list
,
376 (gpointer
)remove_toolbar_constructor
,
378 lttv_toolbars_remove(toolbar
, view_constructor
);
381 retval
= lttv_iattribute_find_by_path(attributes_global
, "viewers/menu",
382 LTTV_POINTER
, &value
);
384 menu
= (LttvMenus
*)*(value
.v_pointer
);
387 g_slist_foreach(g_main_window_list
,
388 (gpointer
)remove_menu_constructor
,
390 lttv_menus_remove(menu
, view_constructor
);
394 LttvAttribute
*attribute
;
395 attribute
= LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
396 LTTV_IATTRIBUTE(attributes_global
),
397 LTTV_VIEWER_CONSTRUCTORS
));
400 guint num
= lttv_iattribute_get_number(LTTV_IATTRIBUTE(attribute
));
402 LttvAttributeName name
;
403 LttvAttributeValue value
;
404 LttvAttributeType type
;
407 type
= lttv_iattribute_get(LTTV_IATTRIBUTE(attribute
), i
, &name
, &value
,
409 g_assert(type
== LTTV_POINTER
);
410 if(*(value
.v_pointer
) == view_constructor
) {
411 lttv_iattribute_remove(LTTV_IATTRIBUTE(attribute
), i
);
420 * Function to register a hook function for a viewer to set/update its
422 * @param tab viewer's tab
423 * @param hook hook function of the viewer.
424 * @param hook_data hook data associated with the hook function.
426 __EXPORT
void lttvwindow_register_time_window_notify(Tab
*tab
,
427 LttvHook hook
, gpointer hook_data
)
429 LttvAttributeValue value
;
433 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
434 "hooks/updatetimewindow", LTTV_POINTER
, &value
);
436 tmp
= (LttvHooks
*)*(value
.v_pointer
);
438 tmp
= lttv_hooks_new();
439 *(value
.v_pointer
) = tmp
;
441 lttv_hooks_add(tmp
, hook
,hook_data
, LTTV_PRIO_DEFAULT
);
446 * Function to unregister a viewer's hook function which is used to
447 * set/update the time interval of the viewer.
448 * @param tab viewer's tab
449 * @param hook hook function of the viewer.
450 * @param hook_data hook data associated with the hook function.
453 __EXPORT
void lttvwindow_unregister_time_window_notify(Tab
*tab
,
454 LttvHook hook
, gpointer hook_data
)
456 LttvAttributeValue value
;
460 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
461 "hooks/updatetimewindow", LTTV_POINTER
, &value
);
463 tmp
= (LttvHooks
*)*(value
.v_pointer
);
464 if(tmp
== NULL
) return;
465 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
469 * Function to register a hook function for a viewer to set/update its
471 * @param tab viewer's tab
472 * @param hook hook function of the viewer.
473 * @param hook_data hook data associated with the hook function.
476 __EXPORT
void lttvwindow_register_traceset_notify(Tab
*tab
,
477 LttvHook hook
, gpointer hook_data
)
479 LttvAttributeValue value
;
483 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
484 "hooks/updatetraceset", LTTV_POINTER
, &value
);
486 tmp
= (LttvHooks
*)*(value
.v_pointer
);
488 tmp
= lttv_hooks_new();
489 *(value
.v_pointer
) = tmp
;
491 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 traceset of 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_traceset_notify(Tab
*tab
,
504 LttvHook hook
, gpointer hook_data
)
506 LttvAttributeValue value
;
510 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
511 "hooks/updatetraceset", 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 be completely redrawn.
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_redraw_notify(Tab
*tab
,
527 LttvHook hook
, gpointer hook_data
)
529 LttvAttributeValue value
;
533 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/redraw",
534 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 hook function for a viewer be completely redrawn.
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_redraw_notify(Tab
*tab
,
554 LttvHook hook
, gpointer hook_data
)
556 LttvAttributeValue value
;
560 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/redraw",
561 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 to re-do the events
570 * requests for the needed interval.
572 * This action is typically done after a "stop".
574 * The typical hook will remove all current requests for the viewer
575 * and make requests for missing information.
577 * @param tab viewer's tab
578 * @param hook hook function of the viewer.
579 * @param hook_data hook data associated with the hook function.
582 __EXPORT
void lttvwindow_register_continue_notify(Tab
*tab
,
583 LttvHook hook
, gpointer hook_data
)
585 LttvAttributeValue value
;
589 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/continue",
590 LTTV_POINTER
, &value
);
592 tmp
= (LttvHooks
*)*(value
.v_pointer
);
594 tmp
= lttv_hooks_new();
595 *(value
.v_pointer
) = tmp
;
597 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
602 * Function to unregister a hook function for a viewer to re-do the events
603 * requests for the needed interval.
605 * @param tab viewer's tab
606 * @param hook hook function of the viewer.
607 * @param hook_data hook data associated with the hook function.
610 __EXPORT
void lttvwindow_unregister_continue_notify(Tab
*tab
,
611 LttvHook hook
, gpointer hook_data
)
613 LttvAttributeValue value
;
617 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/continue",
618 LTTV_POINTER
, &value
);
620 tmp
= (LttvHooks
*)*(value
.v_pointer
);
621 if(tmp
== NULL
) return;
622 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
627 * Function to register a hook function for a viewer to set/update its
629 * @param tab viewer's tab
630 * @param hook hook function of the viewer.
631 * @param hook_data hook data associated with the hook function.
634 __EXPORT
void lttvwindow_register_filter_notify(Tab
*tab
,
635 LttvHook hook
, gpointer hook_data
)
637 LttvAttributeValue value
;
641 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/updatefilter",
642 LTTV_POINTER
, &value
);
644 tmp
= (LttvHooks
*)*(value
.v_pointer
);
646 tmp
= lttv_hooks_new();
647 *(value
.v_pointer
) = tmp
;
649 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
654 * Function to unregister a viewer's hook function which is used to
655 * set/update the filter of the viewer.
656 * @param tab viewer's tab
657 * @param hook hook function of the viewer.
658 * @param hook_data hook data associated with the hook function.
661 __EXPORT
void lttvwindow_unregister_filter_notify(Tab
*tab
,
665 LttvAttributeValue value
;
669 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/updatefilter",
670 LTTV_POINTER
, &value
);
672 tmp
= (LttvHooks
*)*(value
.v_pointer
);
673 if(tmp
== NULL
) return;
674 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
678 * function to register a hook function for a viewer to set/update its
680 * @param tab viewer's tab
681 * @param hook hook function of the viewer.
682 * @param hook_data hook data associated with the hook function.
685 __EXPORT
void lttvwindow_register_current_time_notify(Tab
*tab
,
686 LttvHook hook
, gpointer hook_data
)
688 LttvAttributeValue value
;
692 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
693 "hooks/updatecurrenttime", LTTV_POINTER
, &value
);
695 tmp
= (LttvHooks
*)*(value
.v_pointer
);
697 tmp
= lttv_hooks_new();
698 *(value
.v_pointer
) = tmp
;
700 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
705 * function to unregister a viewer's hook function which is used to
706 * set/update the current time of the viewer.
707 * @param tab viewer's tab
708 * @param hook hook function of the viewer.
709 * @param hook_data hook data associated with the hook function.
712 __EXPORT
void lttvwindow_unregister_current_time_notify(Tab
*tab
,
713 LttvHook hook
, gpointer hook_data
)
715 LttvAttributeValue value
;
719 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
720 "hooks/updatecurrenttime", 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_position_notify(Tab
*tab
,
736 LttvHook hook
, gpointer hook_data
)
738 LttvAttributeValue value
;
742 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
743 "hooks/updatecurrentposition", 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 position 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_position_notify(Tab
*tab
,
763 LttvHook hook
, gpointer hook_data
)
765 LttvAttributeValue value
;
769 retval
= lttv_iattribute_find_by_path(tab
->attributes
,
770 "hooks/updatecurrentposition", LTTV_POINTER
, &value
);
772 tmp
= (LttvHooks
*)*(value
.v_pointer
);
773 if(tmp
== NULL
) return;
774 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
779 * Function to register a hook function for a viewer to show
780 * the content of the viewer.
781 * @param tab viewer's tab
782 * @param hook hook function of the viewer.
783 * @param hook_data hook data associated with the hook function.
786 void lttvwindow_register_show_notify(Tab
*tab
,
787 LttvHook hook
, gpointer hook_data
)
789 LttvAttributeValue value
;
793 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/showviewer",
794 LTTV_POINTER
, &value
);
796 tmp
= (LttvHooks
*)*(value
.v_pointer
);
798 tmp
= lttv_hooks_new();
799 *(value
.v_pointer
) = tmp
;
801 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
806 * Function to unregister a viewer's hook function which is used to
807 * show the content of the viewer..
808 * @param tab viewer's tab
809 * @param hook hook function of the viewer.
810 * @param hook_data hook data associated with the hook function.
813 void lttvwindow_unregister_show_notify(Tab
*tab
,
814 LttvHook hook
, gpointer hook_data
)
816 LttvAttributeValue value
;
820 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/showviewer",
821 LTTV_POINTER
, &value
);
823 tmp
= (LttvHooks
*)*(value
.v_pointer
);
824 if(tmp
== NULL
) return;
825 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
829 * Function to register a hook function for a viewer to set/update the
830 * dividor of the hpane.
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_dividor(Tab
*tab
,
837 LttvHook hook
, gpointer hook_data
)
839 LttvAttributeValue value
;
843 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/hpanedividor",
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 * set/update hpane's dividor of the viewer.
858 * It will be called by the destructor of the viewer.
859 * @param tab viewer's tab
860 * @param hook hook function of the viewer.
861 * @param hook_data hook data associated with the hook function.
864 void lttvwindow_unregister_dividor(Tab
*tab
,
865 LttvHook hook
, gpointer hook_data
)
867 LttvAttributeValue value
;
871 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/hpanedividor",
872 LTTV_POINTER
, &value
);
874 tmp
= (LttvHooks
*)*(value
.v_pointer
);
875 if(tmp
== NULL
) return;
876 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
881 * Function to set the time interval of the current tab.
882 * It will be called by a viewer's signal handle associated with
883 * the move_slider signal
884 * @param tab viewer's tab
885 * @param time_interval a pointer where time interval is stored.
888 __EXPORT
void lttvwindow_report_time_window(Tab
*tab
,
889 TimeWindow time_window
)
891 //set_time_window(tab, time_window);
892 //set_time_window_adjustment(tab, time_window);
894 time_change_manager(tab
, time_window
);
899 LttvTracesetContext
*tsc
=
900 LTTV_TRACESET_CONTEXT(tab
->traceset_info
->traceset_context
);
901 TimeInterval time_span
= tsc
->time_span
;
902 GtkAdjustment
*adjustment
= gtk_range_get_adjustment(GTK_RANGE(tab
->scrollbar
));
903 g_object_set(G_OBJECT(adjustment
),
908 ltt_time_sub(time_span
.end_time
, time_span
.start_time
))
911 ltt_time_to_double(time_window
->time_width
)
912 / SCROLL_STEP_PER_PAGE
913 , /* step increment */
915 ltt_time_to_double(time_window
->time_width
)
916 , /* page increment */
918 ltt_time_to_double(time_window
->time_width
)
921 gtk_adjustment_changed(adjustment
);
923 //g_object_set(G_OBJECT(adjustment),
925 // ltt_time_to_double(time_window->start_time)
928 /* Note : the set value will call set_time_window if scrollbar value changed
930 gtk_adjustment_set_value(adjustment
,
932 ltt_time_sub(time_window
->start_time
,
933 time_span
.start_time
))
940 * Function to set the current time of the current tab.
941 * It will be called by a viewer's signal handle associated with
942 * the button-release-event signal
943 * @param tab viewer's tab
944 * @param time a pointer where time is stored.
947 __EXPORT
void lttvwindow_report_current_time(Tab
*tab
,
950 current_time_change_manager(tab
, time
);
954 * Function to set the current event of the current tab.
955 * It will be called by a viewer's signal handle associated with
956 * the button-release-event signal
957 * @param tab viewer's tab
958 * @param time a pointer where time is stored.
961 __EXPORT
void lttvwindow_report_current_position(Tab
*tab
,
962 LttvTracesetContextPosition
*pos
)
964 current_position_change_manager(tab
, pos
);
969 * Function to set the position of the hpane's dividor (viewer).
970 * It will be called by a viewer's signal handle associated with
971 * the motion_notify_event event/signal
972 * @param tab viewer's tab
973 * @param position position of the hpane's dividor.
976 void lttvwindow_report_dividor(Tab
*tab
, gint position
)
978 LttvAttributeValue value
;
982 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/hpanedividor",
983 LTTV_POINTER
, &value
);
985 tmp
= (LttvHooks
*)*(value
.v_pointer
);
986 if(tmp
== NULL
) return;
987 lttv_hooks_call(tmp
, &position
);
991 * Function to request data in a specific time interval to the main window. The
992 * event request servicing is differed until the glib idle functions are
995 * The viewer has to provide hooks that should be associated with the event
998 * Either start time or start position must be defined in a EventRequest
999 * structure for it to be valid.
1001 * end_time, end_position and num_events can all be defined. The first one
1002 * to occur will be used as end criterion.
1004 * @param tab viewer's tab
1005 * @param events_requested the structure of request from.
1008 __EXPORT
void lttvwindow_events_request(Tab
*tab
,
1009 EventsRequest
*events_request
)
1011 tab
->events_requests
= g_slist_append(tab
->events_requests
, events_request
);
1013 if(!tab
->events_request_pending
)
1015 /* Redraw has +20 priority. We want to let the redraw be done while we do
1016 * our job. Mathieu : test with high prio higher than events for better
1018 /* Mathieu, 2008 : ok, finally, the control flow view needs the cell updates
1019 * to come soon enough so we can have one active cell to get the pixmap
1020 * buffer height from. Therefore, let the gdk events run before the events
1023 g_idle_add_full((G_PRIORITY_HIGH_IDLE
+ 21),
1024 //g_idle_add_full((G_PRIORITY_DEFAULT + 2),
1025 (GSourceFunc
)execute_events_requests
,
1028 tab
->events_request_pending
= TRUE
;
1034 * Function to remove data requests related to a viewer.
1036 * The existing requests's viewer gpointer is compared to the pointer
1037 * given in argument to establish which data request should be removed.
1039 * @param tab the tab the viewer belongs to.
1040 * @param viewer a pointer to the viewer data structure
1043 gint
find_viewer (const EventsRequest
*a
, gconstpointer b
)
1045 return (a
->owner
!= b
);
1049 __EXPORT
void lttvwindow_events_request_remove_all(Tab
*tab
,
1050 gconstpointer viewer
)
1052 GSList
*element
= tab
->events_requests
;
1055 g_slist_find_custom(element
, viewer
,
1056 (GCompareFunc
)find_viewer
))
1058 EventsRequest
*events_request
= (EventsRequest
*)element
->data
;
1059 // Modified so a viewer being destroyed won't have its after_request
1060 // called. Not so important anyway. Note that a viewer that call this
1061 // remove_all function will not get its after_request called.
1062 //if(events_request->servicing == TRUE) {
1063 // lttv_hooks_call(events_request->after_request, NULL);
1065 events_request_free(events_request
);
1066 //g_free(events_request);
1067 tab
->events_requests
= g_slist_remove_link(tab
->events_requests
, element
);
1068 element
= g_slist_next(element
);
1069 if(element
== NULL
) break; /* end of list */
1071 if(g_slist_length(tab
->events_requests
) == 0) {
1072 tab
->events_request_pending
= FALSE
;
1073 g_idle_remove_by_data(tab
);
1080 * Function to see if there are events request pending.
1082 * It tells if events requests are pending. Useful for checks in some events,
1083 * i.e. detailed event list scrolling.
1085 * @param tab the tab the viewer belongs to.
1086 * @param viewer a pointer to the viewer data structure
1087 * @return : TRUE is events requests are pending, else FALSE.
1090 __EXPORT gboolean
lttvwindow_events_request_pending(Tab
*tab
)
1092 GSList
*element
= tab
->events_requests
;
1094 if(element
== NULL
) return FALSE
;
1100 * Function to get the current time interval shown on the current tab.
1101 * It will be called by a viewer's hook function to update the
1102 * shown time interval of the viewer and also be called by the constructor
1104 * @param tab viewer's tab
1105 * @return time window.
1108 __EXPORT TimeWindow
lttvwindow_get_time_window(Tab
*tab
)
1110 return tab
->time_window
;
1115 * Function to get the current time/event of the current tab.
1116 * It will be called by a viewer's hook function to update the
1117 * current time/event of the viewer.
1118 * @param tab viewer's tab
1122 __EXPORT LttTime
lttvwindow_get_current_time(Tab
*tab
)
1124 return tab
->current_time
;
1129 * Function to get the filter of the current tab.
1130 * @param filter, a pointer to a filter.
1132 * returns the current filter
1134 __EXPORT LttvFilter
*lttvwindow_get_filter(Tab
*tab
)
1136 return g_object_get_data(G_OBJECT(tab
->vbox
), "filter");
1140 * Function to set the filter of the current tab.
1141 * It should be called by the filter GUI to tell the
1142 * main window to update the filter tab's lttv_filter.
1144 * This function does change the current filter, removing the
1145 * old one when necessary, and call the updatefilter hooks
1146 * of the registered viewers.
1148 * @param main_win, the main window the viewer belongs to.
1149 * @param filter, a pointer to a filter.
1151 void lttvwindow_report_filter(Tab
*tab
, LttvFilter
*filter
)
1153 LttvAttributeValue value
;
1157 //lttv_filter_destroy(tab->filter);
1158 //tab->filter = filter;
1160 retval
= lttv_iattribute_find_by_path(tab
->attributes
, "hooks/updatefilter",
1161 LTTV_POINTER
, &value
);
1163 tmp
= (LttvHooks
*)*(value
.v_pointer
);
1164 if(tmp
== NULL
) return;
1165 lttv_hooks_call(tmp
, filter
);
1171 * Function to get the stats of the traceset
1172 * @param tab viewer's tab
1175 __EXPORT LttvTracesetStats
* lttvwindow_get_traceset_stats(Tab
*tab
)
1177 return tab
->traceset_info
->traceset_context
;
1180 __EXPORT LttvTracesetContext
* lttvwindow_get_traceset_context(Tab
*tab
)
1182 return (LttvTracesetContext
*)tab
->traceset_info
->traceset_context
;
1186 void events_request_free(EventsRequest
*events_request
)
1188 if(events_request
== NULL
) return;
1190 if(events_request
->start_position
!= NULL
)
1191 lttv_traceset_context_position_destroy(events_request
->start_position
);
1192 if(events_request
->end_position
!= NULL
)
1193 lttv_traceset_context_position_destroy(events_request
->end_position
);
1194 if(events_request
->hooks
!= NULL
) {
1195 GArray
*hooks
= events_request
->hooks
;
1196 lttv_trace_hook_remove_all(&hooks
);
1197 g_array_free(events_request
->hooks
, TRUE
);
1199 if(events_request
->before_chunk_traceset
!= NULL
)
1200 lttv_hooks_destroy(events_request
->before_chunk_traceset
);
1201 if(events_request
->before_chunk_trace
!= NULL
)
1202 lttv_hooks_destroy(events_request
->before_chunk_trace
);
1203 if(events_request
->before_chunk_tracefile
!= NULL
)
1204 lttv_hooks_destroy(events_request
->before_chunk_tracefile
);
1205 if(events_request
->event
!= NULL
)
1206 lttv_hooks_destroy(events_request
->event
);
1207 if(events_request
->event_by_id_channel
!= NULL
)
1208 lttv_hooks_by_id_channel_destroy(events_request
->event_by_id_channel
);
1209 if(events_request
->after_chunk_tracefile
!= NULL
)
1210 lttv_hooks_destroy(events_request
->after_chunk_tracefile
);
1211 if(events_request
->after_chunk_trace
!= NULL
)
1212 lttv_hooks_destroy(events_request
->after_chunk_trace
);
1213 if(events_request
->after_chunk_traceset
!= NULL
)
1214 lttv_hooks_destroy(events_request
->after_chunk_traceset
);
1215 if(events_request
->before_request
!= NULL
)
1216 lttv_hooks_destroy(events_request
->before_request
);
1217 if(events_request
->after_request
!= NULL
)
1218 lttv_hooks_destroy(events_request
->after_request
);
1220 g_free(events_request
);
1225 __EXPORT GtkWidget
*main_window_get_widget(Tab
*tab
)
1227 return tab
->mw
->mwindow
;