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
;
69 TimeWindowNotifyData time_window_notify_data
;
70 TimeWindow old_time_window
= tab
->time_window
;
71 time_window_notify_data
.old_time_window
= &old_time_window
;
72 tab
->time_window
= *time_window
;
73 time_window_notify_data
.new_time_window
=
76 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
77 "hooks/updatetimewindow", LTTV_POINTER
, &value
));
78 tmp
= (LttvHooks
*)*(value
.v_pointer
);
79 if(tmp
!= NULL
) lttv_hooks_call(tmp
, &time_window_notify_data
);
81 //gtk_multi_vpaned_set_adjust(tab->multi_vpaned, new_time_window, FALSE);
87 * It updates the current time of the tab, then calls the updatetimewindow
88 * hooks of each viewer.
90 * This is called whenever the current time value changes.
93 void set_current_time(Tab
*tab
, const LttTime
*current_time
)
95 LttvAttributeValue value
;
98 tab
->current_time
= *current_time
;
100 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
101 "hooks/updatecurrenttime", LTTV_POINTER
, &value
));
102 tmp
= (LttvHooks
*)*(value
.v_pointer
);
103 if(tmp
!= NULL
) lttv_hooks_call(tmp
, &tab
->current_time
);
106 /* set_current_position
108 * It updates the current time of the tab, then calls the updatetimewindow
109 * hooks of each viewer.
111 * This is called whenever the current time value changes.
114 void set_current_position(Tab
*tab
, const LttvTracesetContextPosition
*pos
)
116 LttvAttributeValue value
;
119 tab
->current_time
= lttv_traceset_context_position_get_time(pos
);
121 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
122 "hooks/updatecurrentposition", LTTV_POINTER
, &value
));
123 tmp
= (LttvHooks
*)*(value
.v_pointer
);
124 if(tmp
!= NULL
) lttv_hooks_call(tmp
, pos
);
127 void add_toolbar_constructor(MainWindow
*mw
, LttvToolbarClosure
*toolbar_c
)
129 LttvIAttribute
*attributes
= mw
->attributes
;
130 LttvAttributeValue value
;
131 LttvToolbars
* instance_toolbar
;
132 lttvwindow_viewer_constructor constructor
;
133 GtkWidget
* tool_menu_title_menu
, *new_widget
, *pixmap
;
136 g_assert(lttv_iattribute_find_by_path(attributes
,
137 "viewers/toolbar", LTTV_POINTER
, &value
));
138 if(*(value
.v_pointer
) == NULL
)
139 *(value
.v_pointer
) = lttv_toolbars_new();
140 instance_toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
142 constructor
= toolbar_c
->con
;
143 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"MToolbar1");
144 pixbuf
= gdk_pixbuf_new_from_xpm_data((const char**)toolbar_c
->pixmap
);
145 pixmap
= gtk_image_new_from_pixbuf(pixbuf
);
147 gtk_toolbar_append_element (GTK_TOOLBAR (tool_menu_title_menu
),
148 GTK_TOOLBAR_CHILD_BUTTON
,
151 toolbar_c
->tooltip
, NULL
,
153 gtk_label_set_use_underline(
154 GTK_LABEL (((GtkToolbarChild
*) (
155 g_list_last (GTK_TOOLBAR
156 (tool_menu_title_menu
)->children
)->data
))->label
),
158 gtk_container_set_border_width (GTK_CONTAINER (new_widget
), 1);
159 g_signal_connect ((gpointer
) new_widget
,
161 G_CALLBACK (insert_viewer_wrap
),
163 gtk_widget_show (new_widget
);
165 lttv_toolbars_add(instance_toolbar
, toolbar_c
->con
,
172 void add_menu_constructor(MainWindow
*mw
, LttvMenuClosure
*menu_c
)
174 LttvIAttribute
*attributes
= mw
->attributes
;
175 LttvAttributeValue value
;
176 LttvToolbars
* instance_menu
;
177 lttvwindow_viewer_constructor constructor
;
178 GtkWidget
* tool_menu_title_menu
, *new_widget
;
180 g_assert(lttv_iattribute_find_by_path(attributes
,
181 "viewers/menu", LTTV_POINTER
, &value
));
182 if(*(value
.v_pointer
) == NULL
)
183 *(value
.v_pointer
) = lttv_menus_new();
184 instance_menu
= (LttvMenus
*)*(value
.v_pointer
);
187 constructor
= menu_c
->con
;
188 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"ToolMenuTitle_menu");
190 gtk_menu_item_new_with_mnemonic (menu_c
->menu_text
);
191 gtk_container_add (GTK_CONTAINER (tool_menu_title_menu
),
193 g_signal_connect ((gpointer
) new_widget
, "activate",
194 G_CALLBACK (insert_viewer_wrap
),
196 gtk_widget_show (new_widget
);
197 lttv_menus_add(instance_menu
, menu_c
->con
,
203 void remove_toolbar_constructor(MainWindow
*mw
, lttvwindow_viewer_constructor viewer_constructor
)
205 LttvIAttribute
*attributes
= mw
->attributes
;
206 LttvAttributeValue value
;
207 LttvToolbars
* instance_toolbar
;
208 GtkWidget
* tool_menu_title_menu
, *widget
;
210 g_assert(lttv_iattribute_find_by_path(attributes
,
211 "viewers/toolbar", LTTV_POINTER
, &value
));
212 if(*(value
.v_pointer
) == NULL
)
213 *(value
.v_pointer
) = lttv_toolbars_new();
214 instance_toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
216 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"MToolbar1");
217 widget
= lttv_menus_remove(instance_toolbar
, viewer_constructor
);
218 gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu
),
223 void remove_menu_constructor(MainWindow
*mw
, lttvwindow_viewer_constructor viewer_constructor
)
225 LttvIAttribute
*attributes
= mw
->attributes
;
226 LttvAttributeValue value
;
227 LttvMenus
* instance_menu
;
228 GtkWidget
* tool_menu_title_menu
, *widget
;
230 g_assert(lttv_iattribute_find_by_path(attributes
,
231 "viewers/menu", LTTV_POINTER
, &value
));
232 if(*(value
.v_pointer
) == NULL
)
233 *(value
.v_pointer
) = lttv_menus_new();
234 instance_menu
= (LttvMenus
*)*(value
.v_pointer
);
236 widget
= lttv_menus_remove(instance_menu
, viewer_constructor
);
237 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"ToolMenuTitle_menu");
238 gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu
), widget
);
248 * Function to register a view constructor so that main window can generate
249 * a menu item and a toolbar item for the viewer in order to generate a new
250 * instance easily. A menu entry and toolbar item will be added to each main
253 * It should be called by init function of the module.
255 * @param name name of the viewer
256 * @param menu_path path of the menu item.
257 * @param menu_text text of the menu item.
258 * @param pixmap Image shown on the toolbar item.
259 * @param tooltip tooltip of the toolbar item.
260 * @param view_constructor constructor of the viewer.
263 __EXPORT
void lttvwindow_register_constructor
269 lttvwindow_viewer_constructor view_constructor
)
271 LttvIAttribute
*attributes_global
= LTTV_IATTRIBUTE(lttv_global_attributes());
272 LttvToolbars
* toolbar
;
274 LttvToolbarClosure toolbar_c
;
275 LttvMenuClosure menu_c
;
276 LttvAttributeValue value
;
278 if(view_constructor
== NULL
) return;
281 g_assert(lttv_iattribute_find_by_path(attributes_global
,
282 "viewers/toolbar", LTTV_POINTER
, &value
));
283 toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
285 if(toolbar
== NULL
) {
286 toolbar
= lttv_toolbars_new();
287 *(value
.v_pointer
) = toolbar
;
289 toolbar_c
= lttv_toolbars_add(toolbar
, view_constructor
, tooltip
, pixmap
,
292 g_slist_foreach(g_main_window_list
,
293 (gpointer
)add_toolbar_constructor
,
297 if(menu_path
!= NULL
) {
298 g_assert(lttv_iattribute_find_by_path(attributes_global
,
299 "viewers/menu", LTTV_POINTER
, &value
));
300 menu
= (LttvMenus
*)*(value
.v_pointer
);
303 menu
= lttv_menus_new();
304 *(value
.v_pointer
) = menu
;
306 menu_c
= lttv_menus_add(menu
, view_constructor
, menu_path
, menu_text
,NULL
);
308 g_slist_foreach(g_main_window_list
,
309 (gpointer
)add_menu_constructor
,
313 LttvAttribute
*attribute
;
316 attribute
= LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
317 LTTV_IATTRIBUTE(attributes_global
),
318 LTTV_VIEWER_CONSTRUCTORS
));
321 result
= lttv_iattribute_find_by_path(LTTV_IATTRIBUTE(attribute
),
322 name
, LTTV_POINTER
, &value
);
325 *(value
.v_pointer
) = view_constructor
;
332 * Function to unregister the viewer's constructor, release the space
333 * occupied by menu_path, menu_text, pixmap, tooltip and constructor of the
336 * It will be called when a module is unloaded.
338 * @param view_constructor constructor of the viewer.
342 __EXPORT
void lttvwindow_unregister_constructor
343 (lttvwindow_viewer_constructor view_constructor
)
345 LttvIAttribute
*attributes_global
= LTTV_IATTRIBUTE(lttv_global_attributes());
346 LttvToolbars
* toolbar
;
348 LttvAttributeValue value
;
351 g_assert(lttv_iattribute_find_by_path(attributes_global
,
352 "viewers/toolbar", LTTV_POINTER
, &value
));
353 toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
355 if(toolbar
!= NULL
) {
356 g_slist_foreach(g_main_window_list
,
357 (gpointer
)remove_toolbar_constructor
,
359 lttv_toolbars_remove(toolbar
, view_constructor
);
362 g_assert(lttv_iattribute_find_by_path(attributes_global
,
363 "viewers/menu", LTTV_POINTER
, &value
));
364 menu
= (LttvMenus
*)*(value
.v_pointer
);
367 g_slist_foreach(g_main_window_list
,
368 (gpointer
)remove_menu_constructor
,
370 lttv_menus_remove(menu
, view_constructor
);
374 LttvAttribute
*attribute
;
375 attribute
= LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
376 LTTV_IATTRIBUTE(attributes_global
),
377 LTTV_VIEWER_CONSTRUCTORS
));
380 guint num
= lttv_iattribute_get_number(LTTV_IATTRIBUTE(attribute
));
382 LttvAttributeName name
;
383 LttvAttributeValue value
;
384 LttvAttributeType type
;
387 type
= lttv_iattribute_get(LTTV_IATTRIBUTE(attribute
), i
, &name
, &value
,
389 g_assert(type
== LTTV_POINTER
);
390 if(*(value
.v_pointer
) == view_constructor
) {
391 lttv_iattribute_remove(LTTV_IATTRIBUTE(attribute
), i
);
400 * Function to register a hook function for a viewer to set/update its
402 * @param tab viewer's tab
403 * @param hook hook function of the viewer.
404 * @param hook_data hook data associated with the hook function.
406 __EXPORT
void lttvwindow_register_time_window_notify(Tab
*tab
,
407 LttvHook hook
, gpointer hook_data
)
409 LttvAttributeValue value
;
411 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
412 "hooks/updatetimewindow", LTTV_POINTER
, &value
));
413 tmp
= (LttvHooks
*)*(value
.v_pointer
);
415 tmp
= lttv_hooks_new();
416 *(value
.v_pointer
) = tmp
;
418 lttv_hooks_add(tmp
, hook
,hook_data
, LTTV_PRIO_DEFAULT
);
423 * Function to unregister a viewer's hook function which is used to
424 * set/update the time interval of the viewer.
425 * @param tab viewer's tab
426 * @param hook hook function of the viewer.
427 * @param hook_data hook data associated with the hook function.
430 __EXPORT
void lttvwindow_unregister_time_window_notify(Tab
*tab
,
431 LttvHook hook
, gpointer hook_data
)
433 LttvAttributeValue value
;
435 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
436 "hooks/updatetimewindow", LTTV_POINTER
, &value
));
437 tmp
= (LttvHooks
*)*(value
.v_pointer
);
438 if(tmp
== NULL
) return;
439 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
443 * Function to register a hook function for a viewer to set/update its
445 * @param tab viewer's tab
446 * @param hook hook function of the viewer.
447 * @param hook_data hook data associated with the hook function.
450 __EXPORT
void lttvwindow_register_traceset_notify(Tab
*tab
,
451 LttvHook hook
, gpointer hook_data
)
453 LttvAttributeValue value
;
455 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
456 "hooks/updatetraceset", LTTV_POINTER
, &value
));
457 tmp
= (LttvHooks
*)*(value
.v_pointer
);
459 tmp
= lttv_hooks_new();
460 *(value
.v_pointer
) = tmp
;
462 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
467 * Function to unregister a viewer's hook function which is used to
468 * set/update the traceset of the viewer.
469 * @param tab viewer's tab
470 * @param hook hook function of the viewer.
471 * @param hook_data hook data associated with the hook function.
474 __EXPORT
void lttvwindow_unregister_traceset_notify(Tab
*tab
,
475 LttvHook hook
, gpointer hook_data
)
477 LttvAttributeValue value
;
479 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
480 "hooks/updatetraceset", LTTV_POINTER
, &value
));
481 tmp
= (LttvHooks
*)*(value
.v_pointer
);
482 if(tmp
== NULL
) return;
483 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
487 * Function to register a hook function for a viewer be completely redrawn.
489 * @param tab viewer's tab
490 * @param hook hook function of the viewer.
491 * @param hook_data hook data associated with the hook function.
494 __EXPORT
void lttvwindow_register_redraw_notify(Tab
*tab
,
495 LttvHook hook
, gpointer hook_data
)
497 LttvAttributeValue value
;
499 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
500 "hooks/redraw", LTTV_POINTER
, &value
));
501 tmp
= (LttvHooks
*)*(value
.v_pointer
);
503 tmp
= lttv_hooks_new();
504 *(value
.v_pointer
) = tmp
;
506 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
511 * Function to unregister a hook function for a viewer be completely redrawn.
513 * @param tab viewer's tab
514 * @param hook hook function of the viewer.
515 * @param hook_data hook data associated with the hook function.
518 __EXPORT
void lttvwindow_unregister_redraw_notify(Tab
*tab
,
519 LttvHook hook
, gpointer hook_data
)
521 LttvAttributeValue value
;
523 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
524 "hooks/redraw", LTTV_POINTER
, &value
));
525 tmp
= (LttvHooks
*)*(value
.v_pointer
);
526 if(tmp
== NULL
) return;
527 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
531 * Function to register a hook function for a viewer to re-do the events
532 * requests for the needed interval.
534 * This action is typically done after a "stop".
536 * The typical hook will remove all current requests for the viewer
537 * and make requests for missing information.
539 * @param tab viewer's tab
540 * @param hook hook function of the viewer.
541 * @param hook_data hook data associated with the hook function.
544 __EXPORT
void lttvwindow_register_continue_notify(Tab
*tab
,
545 LttvHook hook
, gpointer hook_data
)
547 LttvAttributeValue value
;
549 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
550 "hooks/continue", LTTV_POINTER
, &value
));
551 tmp
= (LttvHooks
*)*(value
.v_pointer
);
553 tmp
= lttv_hooks_new();
554 *(value
.v_pointer
) = tmp
;
556 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
561 * Function to unregister a hook function for a viewer to re-do the events
562 * requests for the needed interval.
564 * @param tab viewer's tab
565 * @param hook hook function of the viewer.
566 * @param hook_data hook data associated with the hook function.
569 __EXPORT
void lttvwindow_unregister_continue_notify(Tab
*tab
,
570 LttvHook hook
, gpointer hook_data
)
572 LttvAttributeValue value
;
574 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
575 "hooks/continue", LTTV_POINTER
, &value
));
576 tmp
= (LttvHooks
*)*(value
.v_pointer
);
577 if(tmp
== NULL
) return;
578 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
583 * Function to register a hook function for a viewer to set/update its
585 * @param tab viewer's tab
586 * @param hook hook function of the viewer.
587 * @param hook_data hook data associated with the hook function.
590 __EXPORT
void lttvwindow_register_filter_notify(Tab
*tab
,
591 LttvHook hook
, gpointer hook_data
)
593 LttvAttributeValue value
;
595 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
596 "hooks/updatefilter", LTTV_POINTER
, &value
));
597 tmp
= (LttvHooks
*)*(value
.v_pointer
);
599 tmp
= lttv_hooks_new();
600 *(value
.v_pointer
) = tmp
;
602 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
607 * Function to unregister a viewer's hook function which is used to
608 * set/update the filter of the viewer.
609 * @param tab viewer's tab
610 * @param hook hook function of the viewer.
611 * @param hook_data hook data associated with the hook function.
614 __EXPORT
void lttvwindow_unregister_filter_notify(Tab
*tab
,
618 LttvAttributeValue value
;
620 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
621 "hooks/updatefilter", LTTV_POINTER
, &value
));
622 tmp
= (LttvHooks
*)*(value
.v_pointer
);
623 if(tmp
== NULL
) return;
624 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
628 * function to register a hook function for a viewer to set/update its
630 * @param tab viewer's tab
631 * @param hook hook function of the viewer.
632 * @param hook_data hook data associated with the hook function.
635 __EXPORT
void lttvwindow_register_current_time_notify(Tab
*tab
,
636 LttvHook hook
, gpointer hook_data
)
638 LttvAttributeValue value
;
640 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
641 "hooks/updatecurrenttime", LTTV_POINTER
, &value
));
642 tmp
= (LttvHooks
*)*(value
.v_pointer
);
644 tmp
= lttv_hooks_new();
645 *(value
.v_pointer
) = tmp
;
647 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
652 * function to unregister a viewer's hook function which is used to
653 * set/update the current time of the viewer.
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_current_time_notify(Tab
*tab
,
660 LttvHook hook
, gpointer hook_data
)
662 LttvAttributeValue value
;
664 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
665 "hooks/updatecurrenttime", LTTV_POINTER
, &value
));
666 tmp
= (LttvHooks
*)*(value
.v_pointer
);
667 if(tmp
== NULL
) return;
668 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
672 * function to register a hook function for a viewer to set/update its
674 * @param tab viewer's tab
675 * @param hook hook function of the viewer.
676 * @param hook_data hook data associated with the hook function.
679 __EXPORT
void lttvwindow_register_current_position_notify(Tab
*tab
,
680 LttvHook hook
, gpointer hook_data
)
682 LttvAttributeValue value
;
684 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
685 "hooks/updatecurrentposition", LTTV_POINTER
, &value
));
686 tmp
= (LttvHooks
*)*(value
.v_pointer
);
688 tmp
= lttv_hooks_new();
689 *(value
.v_pointer
) = tmp
;
691 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
696 * function to unregister a viewer's hook function which is used to
697 * set/update the current position of the viewer.
698 * @param tab viewer's tab
699 * @param hook hook function of the viewer.
700 * @param hook_data hook data associated with the hook function.
703 __EXPORT
void lttvwindow_unregister_current_position_notify(Tab
*tab
,
704 LttvHook hook
, gpointer hook_data
)
706 LttvAttributeValue value
;
708 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
709 "hooks/updatecurrentposition", LTTV_POINTER
, &value
));
710 tmp
= (LttvHooks
*)*(value
.v_pointer
);
711 if(tmp
== NULL
) return;
712 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
717 * Function to register a hook function for a viewer to show
718 * the content of the viewer.
719 * @param tab viewer's tab
720 * @param hook hook function of the viewer.
721 * @param hook_data hook data associated with the hook function.
724 void lttvwindow_register_show_notify(Tab
*tab
,
725 LttvHook hook
, gpointer hook_data
)
727 LttvAttributeValue value
;
729 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
730 "hooks/showviewer", LTTV_POINTER
, &value
));
731 tmp
= (LttvHooks
*)*(value
.v_pointer
);
733 tmp
= lttv_hooks_new();
734 *(value
.v_pointer
) = tmp
;
736 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
741 * Function to unregister a viewer's hook function which is used to
742 * show the content of the viewer..
743 * @param tab viewer's tab
744 * @param hook hook function of the viewer.
745 * @param hook_data hook data associated with the hook function.
748 void lttvwindow_unregister_show_notify(Tab
*tab
,
749 LttvHook hook
, gpointer hook_data
)
751 LttvAttributeValue value
;
753 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
754 "hooks/showviewer", LTTV_POINTER
, &value
));
755 tmp
= (LttvHooks
*)*(value
.v_pointer
);
756 if(tmp
== NULL
) return;
757 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
761 * Function to register a hook function for a viewer to set/update the
762 * dividor of the hpane.
763 * @param tab viewer's tab
764 * @param hook hook function of the viewer.
765 * @param hook_data hook data associated with the hook function.
768 void lttvwindow_register_dividor(Tab
*tab
,
769 LttvHook hook
, gpointer hook_data
)
771 LttvAttributeValue value
;
773 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
774 "hooks/hpanedividor", LTTV_POINTER
, &value
));
775 tmp
= (LttvHooks
*)*(value
.v_pointer
);
777 tmp
= lttv_hooks_new();
778 *(value
.v_pointer
) = tmp
;
780 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
785 * Function to unregister a viewer's hook function which is used to
786 * set/update hpane's dividor of the viewer.
787 * It will be called by the destructor of the viewer.
788 * @param tab viewer's tab
789 * @param hook hook function of the viewer.
790 * @param hook_data hook data associated with the hook function.
793 void lttvwindow_unregister_dividor(Tab
*tab
,
794 LttvHook hook
, gpointer hook_data
)
796 LttvAttributeValue value
;
798 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
799 "hooks/hpanedividor", LTTV_POINTER
, &value
));
800 tmp
= (LttvHooks
*)*(value
.v_pointer
);
801 if(tmp
== NULL
) return;
802 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
807 * Function to set the time interval of the current tab.
808 * It will be called by a viewer's signal handle associated with
809 * the move_slider signal
810 * @param tab viewer's tab
811 * @param time_interval a pointer where time interval is stored.
814 __EXPORT
void lttvwindow_report_time_window(Tab
*tab
,
815 TimeWindow time_window
)
817 //set_time_window(tab, time_window);
818 //set_time_window_adjustment(tab, time_window);
820 time_change_manager(tab
, time_window
);
825 LttvTracesetContext
*tsc
=
826 LTTV_TRACESET_CONTEXT(tab
->traceset_info
->traceset_context
);
827 TimeInterval time_span
= tsc
->time_span
;
828 GtkAdjustment
*adjustment
= gtk_range_get_adjustment(GTK_RANGE(tab
->scrollbar
));
829 g_object_set(G_OBJECT(adjustment
),
834 ltt_time_sub(time_span
.end_time
, time_span
.start_time
))
837 ltt_time_to_double(time_window
->time_width
)
838 / SCROLL_STEP_PER_PAGE
839 , /* step increment */
841 ltt_time_to_double(time_window
->time_width
)
842 , /* page increment */
844 ltt_time_to_double(time_window
->time_width
)
847 gtk_adjustment_changed(adjustment
);
849 //g_object_set(G_OBJECT(adjustment),
851 // ltt_time_to_double(time_window->start_time)
854 /* Note : the set value will call set_time_window if scrollbar value changed
856 gtk_adjustment_set_value(adjustment
,
858 ltt_time_sub(time_window
->start_time
,
859 time_span
.start_time
))
866 * Function to set the current time of the current tab.
867 * It will be called by a viewer's signal handle associated with
868 * the button-release-event signal
869 * @param tab viewer's tab
870 * @param time a pointer where time is stored.
873 __EXPORT
void lttvwindow_report_current_time(Tab
*tab
,
876 current_time_change_manager(tab
, time
);
880 * Function to set the current event of the current tab.
881 * It will be called by a viewer's signal handle associated with
882 * the button-release-event signal
883 * @param tab viewer's tab
884 * @param time a pointer where time is stored.
887 __EXPORT
void lttvwindow_report_current_position(Tab
*tab
,
888 LttvTracesetContextPosition
*pos
)
890 current_position_change_manager(tab
, pos
);
895 * Function to set the position of the hpane's dividor (viewer).
896 * It will be called by a viewer's signal handle associated with
897 * the motion_notify_event event/signal
898 * @param tab viewer's tab
899 * @param position position of the hpane's dividor.
902 void lttvwindow_report_dividor(Tab
*tab
, gint position
)
904 LttvAttributeValue value
;
906 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
907 "hooks/hpanedividor", LTTV_POINTER
, &value
));
908 tmp
= (LttvHooks
*)*(value
.v_pointer
);
909 if(tmp
== NULL
) return;
910 lttv_hooks_call(tmp
, &position
);
914 * Function to request data in a specific time interval to the main window. The
915 * event request servicing is differed until the glib idle functions are
918 * The viewer has to provide hooks that should be associated with the event
921 * Either start time or start position must be defined in a EventRequest
922 * structure for it to be valid.
924 * end_time, end_position and num_events can all be defined. The first one
925 * to occur will be used as end criterion.
927 * @param tab viewer's tab
928 * @param events_requested the structure of request from.
931 __EXPORT
void lttvwindow_events_request(Tab
*tab
,
932 EventsRequest
*events_request
)
934 tab
->events_requests
= g_slist_append(tab
->events_requests
, events_request
);
936 if(!tab
->events_request_pending
)
938 /* Redraw has +20 priority. We want to let the redraw be done while we do
939 * our job. Mathieu : test with high prio higher than events for better
941 //g_idle_add_full((G_PRIORITY_HIGH_IDLE + 21),
942 g_idle_add_full((G_PRIORITY_DEFAULT
+ 2),
943 (GSourceFunc
)execute_events_requests
,
946 tab
->events_request_pending
= TRUE
;
952 * Function to remove data requests related to a viewer.
954 * The existing requests's viewer gpointer is compared to the pointer
955 * given in argument to establish which data request should be removed.
957 * @param tab the tab the viewer belongs to.
958 * @param viewer a pointer to the viewer data structure
961 gint
find_viewer (const EventsRequest
*a
, gconstpointer b
)
963 return (a
->owner
!= b
);
967 __EXPORT
void lttvwindow_events_request_remove_all(Tab
*tab
,
968 gconstpointer viewer
)
970 GSList
*element
= tab
->events_requests
;
973 g_slist_find_custom(element
, viewer
,
974 (GCompareFunc
)find_viewer
))
976 EventsRequest
*events_request
= (EventsRequest
*)element
->data
;
977 // Modified so a viewer being destroyed won't have its after_request
978 // called. Not so important anyway. Note that a viewer that call this
979 // remove_all function will not get its after_request called.
980 //if(events_request->servicing == TRUE) {
981 // lttv_hooks_call(events_request->after_request, NULL);
983 events_request_free(events_request
);
984 //g_free(events_request);
985 tab
->events_requests
= g_slist_remove_link(tab
->events_requests
, element
);
986 element
= g_slist_next(element
);
987 if(element
== NULL
) break; /* end of list */
989 if(g_slist_length(tab
->events_requests
) == 0) {
990 tab
->events_request_pending
= FALSE
;
991 g_idle_remove_by_data(tab
);
998 * Function to see if there are events request pending.
1000 * It tells if events requests are pending. Useful for checks in some events,
1001 * i.e. detailed event list scrolling.
1003 * @param tab the tab the viewer belongs to.
1004 * @param viewer a pointer to the viewer data structure
1005 * @return : TRUE is events requests are pending, else FALSE.
1008 __EXPORT gboolean
lttvwindow_events_request_pending(Tab
*tab
)
1010 GSList
*element
= tab
->events_requests
;
1012 if(element
== NULL
) return FALSE
;
1018 * Function to get the current time interval shown on the current tab.
1019 * It will be called by a viewer's hook function to update the
1020 * shown time interval of the viewer and also be called by the constructor
1022 * @param tab viewer's tab
1023 * @return time window.
1026 __EXPORT TimeWindow
lttvwindow_get_time_window(Tab
*tab
)
1028 return tab
->time_window
;
1033 * Function to get the current time/event of the current tab.
1034 * It will be called by a viewer's hook function to update the
1035 * current time/event of the viewer.
1036 * @param tab viewer's tab
1040 __EXPORT LttTime
lttvwindow_get_current_time(Tab
*tab
)
1042 return tab
->current_time
;
1047 * Function to get the filter of the current tab.
1048 * @param filter, a pointer to a filter.
1050 * returns the current filter
1052 __EXPORT LttvFilter
*lttvwindow_get_filter(Tab
*tab
)
1054 return g_object_get_data(G_OBJECT(tab
->vbox
), "filter");
1058 * Function to set the filter of the current tab.
1059 * It should be called by the filter GUI to tell the
1060 * main window to update the filter tab's lttv_filter.
1062 * This function does change the current filter, removing the
1063 * old one when necessary, and call the updatefilter hooks
1064 * of the registered viewers.
1066 * @param main_win, the main window the viewer belongs to.
1067 * @param filter, a pointer to a filter.
1069 void lttvwindow_report_filter(Tab
*tab
, LttvFilter
*filter
)
1071 LttvAttributeValue value
;
1074 //lttv_filter_destroy(tab->filter);
1075 //tab->filter = filter;
1077 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
1078 "hooks/updatefilter", LTTV_POINTER
, &value
));
1079 tmp
= (LttvHooks
*)*(value
.v_pointer
);
1080 if(tmp
== NULL
) return;
1081 lttv_hooks_call(tmp
, filter
);
1087 * Function to get the stats of the traceset
1088 * @param tab viewer's tab
1091 __EXPORT LttvTracesetStats
* lttvwindow_get_traceset_stats(Tab
*tab
)
1093 return tab
->traceset_info
->traceset_context
;
1096 __EXPORT LttvTracesetContext
* lttvwindow_get_traceset_context(Tab
*tab
)
1098 return (LttvTracesetContext
*)tab
->traceset_info
->traceset_context
;
1102 void events_request_free(EventsRequest
*events_request
)
1104 if(events_request
== NULL
) return;
1106 if(events_request
->start_position
!= NULL
)
1107 lttv_traceset_context_position_destroy(events_request
->start_position
);
1108 if(events_request
->end_position
!= NULL
)
1109 lttv_traceset_context_position_destroy(events_request
->end_position
);
1110 if(events_request
->hooks
!= NULL
) {
1112 GArray
*hooks
= events_request
->hooks
;
1113 lttv_trace_hook_remove_all(&hooks
);
1114 g_array_free(events_request
->hooks
, TRUE
);
1116 if(events_request
->before_chunk_traceset
!= NULL
)
1117 lttv_hooks_destroy(events_request
->before_chunk_traceset
);
1118 if(events_request
->before_chunk_trace
!= NULL
)
1119 lttv_hooks_destroy(events_request
->before_chunk_trace
);
1120 if(events_request
->before_chunk_tracefile
!= NULL
)
1121 lttv_hooks_destroy(events_request
->before_chunk_tracefile
);
1122 if(events_request
->event
!= NULL
)
1123 lttv_hooks_destroy(events_request
->event
);
1124 if(events_request
->event_by_id
!= NULL
)
1125 lttv_hooks_by_id_destroy(events_request
->event_by_id
);
1126 if(events_request
->after_chunk_tracefile
!= NULL
)
1127 lttv_hooks_destroy(events_request
->after_chunk_tracefile
);
1128 if(events_request
->after_chunk_trace
!= NULL
)
1129 lttv_hooks_destroy(events_request
->after_chunk_trace
);
1130 if(events_request
->after_chunk_traceset
!= NULL
)
1131 lttv_hooks_destroy(events_request
->after_chunk_traceset
);
1132 if(events_request
->before_request
!= NULL
)
1133 lttv_hooks_destroy(events_request
->before_request
);
1134 if(events_request
->after_request
!= NULL
)
1135 lttv_hooks_destroy(events_request
->after_request
);
1137 g_free(events_request
);
1142 __EXPORT GtkWidget
*main_window_get_widget(Tab
*tab
)
1144 return tab
->mw
->mwindow
;