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
;
56 * It updates the time window of the tab, then calls the updatetimewindow
57 * hooks of each viewer.
59 * This is called whenever the scrollbar value changes.
62 void set_time_window(Tab
*tab
, const TimeWindow
*time_window
)
64 LttvAttributeValue value
;
67 TimeWindowNotifyData time_window_notify_data
;
68 TimeWindow old_time_window
= tab
->time_window
;
69 time_window_notify_data
.old_time_window
= &old_time_window
;
70 tab
->time_window
= *time_window
;
71 time_window_notify_data
.new_time_window
=
74 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
75 "hooks/updatetimewindow", LTTV_POINTER
, &value
));
76 tmp
= (LttvHooks
*)*(value
.v_pointer
);
77 if(tmp
!= NULL
) lttv_hooks_call(tmp
, &time_window_notify_data
);
79 //gtk_multi_vpaned_set_adjust(tab->multi_vpaned, new_time_window, FALSE);
85 * It updates the current time of the tab, then calls the updatetimewindow
86 * hooks of each viewer.
88 * This is called whenever the current time value changes.
91 void set_current_time(Tab
*tab
, const LttTime
*current_time
)
93 LttvAttributeValue value
;
96 tab
->current_time
= *current_time
;
98 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
99 "hooks/updatecurrenttime", LTTV_POINTER
, &value
));
100 tmp
= (LttvHooks
*)*(value
.v_pointer
);
101 if(tmp
!= NULL
) lttv_hooks_call(tmp
, &tab
->current_time
);
104 /* set_current_position
106 * It updates the current time of the tab, then calls the updatetimewindow
107 * hooks of each viewer.
109 * This is called whenever the current time value changes.
112 void set_current_position(Tab
*tab
, const LttvTracesetContextPosition
*pos
)
114 LttvAttributeValue value
;
117 tab
->current_time
= lttv_traceset_context_position_get_time(pos
);
119 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
120 "hooks/updatecurrentposition", LTTV_POINTER
, &value
));
121 tmp
= (LttvHooks
*)*(value
.v_pointer
);
122 if(tmp
!= NULL
) lttv_hooks_call(tmp
, pos
);
125 void add_toolbar_constructor(MainWindow
*mw
, LttvToolbarClosure
*toolbar_c
)
127 LttvIAttribute
*attributes
= mw
->attributes
;
128 LttvAttributeValue value
;
129 LttvToolbars
* instance_toolbar
;
130 lttvwindow_viewer_constructor constructor
;
131 GtkWidget
* tool_menu_title_menu
, *new_widget
, *pixmap
;
134 g_assert(lttv_iattribute_find_by_path(attributes
,
135 "viewers/toolbar", LTTV_POINTER
, &value
));
136 if(*(value
.v_pointer
) == NULL
)
137 *(value
.v_pointer
) = lttv_toolbars_new();
138 instance_toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
140 constructor
= toolbar_c
->con
;
141 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"MToolbar1");
142 pixbuf
= gdk_pixbuf_new_from_xpm_data((const char**)toolbar_c
->pixmap
);
143 pixmap
= gtk_image_new_from_pixbuf(pixbuf
);
145 gtk_toolbar_append_element (GTK_TOOLBAR (tool_menu_title_menu
),
146 GTK_TOOLBAR_CHILD_BUTTON
,
149 toolbar_c
->tooltip
, NULL
,
151 gtk_label_set_use_underline(
152 GTK_LABEL (((GtkToolbarChild
*) (
153 g_list_last (GTK_TOOLBAR
154 (tool_menu_title_menu
)->children
)->data
))->label
),
156 gtk_container_set_border_width (GTK_CONTAINER (new_widget
), 1);
157 g_signal_connect ((gpointer
) new_widget
,
159 G_CALLBACK (insert_viewer_wrap
),
161 gtk_widget_show (new_widget
);
163 lttv_toolbars_add(instance_toolbar
, toolbar_c
->con
,
170 void add_menu_constructor(MainWindow
*mw
, LttvMenuClosure
*menu_c
)
172 LttvIAttribute
*attributes
= mw
->attributes
;
173 LttvAttributeValue value
;
174 LttvToolbars
* instance_menu
;
175 lttvwindow_viewer_constructor constructor
;
176 GtkWidget
* tool_menu_title_menu
, *new_widget
;
178 g_assert(lttv_iattribute_find_by_path(attributes
,
179 "viewers/menu", LTTV_POINTER
, &value
));
180 if(*(value
.v_pointer
) == NULL
)
181 *(value
.v_pointer
) = lttv_menus_new();
182 instance_menu
= (LttvMenus
*)*(value
.v_pointer
);
185 constructor
= menu_c
->con
;
186 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"ToolMenuTitle_menu");
188 gtk_menu_item_new_with_mnemonic (menu_c
->menu_text
);
189 gtk_container_add (GTK_CONTAINER (tool_menu_title_menu
),
191 g_signal_connect ((gpointer
) new_widget
, "activate",
192 G_CALLBACK (insert_viewer_wrap
),
194 gtk_widget_show (new_widget
);
195 lttv_menus_add(instance_menu
, menu_c
->con
,
201 void remove_toolbar_constructor(MainWindow
*mw
, lttvwindow_viewer_constructor viewer_constructor
)
203 LttvIAttribute
*attributes
= mw
->attributes
;
204 LttvAttributeValue value
;
205 LttvToolbars
* instance_toolbar
;
206 lttvwindow_viewer_constructor constructor
;
207 GtkWidget
* tool_menu_title_menu
, *widget
;
209 g_assert(lttv_iattribute_find_by_path(attributes
,
210 "viewers/toolbar", LTTV_POINTER
, &value
));
211 if(*(value
.v_pointer
) == NULL
)
212 *(value
.v_pointer
) = lttv_toolbars_new();
213 instance_toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
215 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"MToolbar1");
216 widget
= lttv_menus_remove(instance_toolbar
, viewer_constructor
);
217 gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu
),
222 void remove_menu_constructor(MainWindow
*mw
, lttvwindow_viewer_constructor viewer_constructor
)
224 LttvIAttribute
*attributes
= mw
->attributes
;
225 LttvAttributeValue value
;
226 LttvMenus
* instance_menu
;
227 lttvwindow_viewer_constructor constructor
;
228 GtkWidget
* tool_menu_title_menu
, *widget
;
229 LttvMenuClosure
*menu_item_i
;
231 g_assert(lttv_iattribute_find_by_path(attributes
,
232 "viewers/menu", LTTV_POINTER
, &value
));
233 if(*(value
.v_pointer
) == NULL
)
234 *(value
.v_pointer
) = lttv_menus_new();
235 instance_menu
= (LttvMenus
*)*(value
.v_pointer
);
237 widget
= lttv_menus_remove(instance_menu
, viewer_constructor
);
238 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"ToolMenuTitle_menu");
239 gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu
), widget
);
249 * Function to register a view constructor so that main window can generate
250 * a menu item and a toolbar item for the viewer in order to generate a new
251 * instance easily. A menu entry and toolbar item will be added to each main
254 * It should be called by init function of the module.
256 * @param name name of the viewer
257 * @param menu_path path of the menu item.
258 * @param menu_text text of the menu item.
259 * @param pixmap Image shown on the toolbar item.
260 * @param tooltip tooltip of the toolbar item.
261 * @param view_constructor constructor of the viewer.
264 void lttvwindow_register_constructor
270 lttvwindow_viewer_constructor view_constructor
)
272 LttvIAttribute
*attributes_global
= LTTV_IATTRIBUTE(lttv_global_attributes());
273 LttvToolbars
* toolbar
;
275 LttvToolbarClosure toolbar_c
;
276 LttvMenuClosure menu_c
;
277 LttvAttributeValue value
;
279 if(view_constructor
== NULL
) return;
282 g_assert(lttv_iattribute_find_by_path(attributes_global
,
283 "viewers/toolbar", LTTV_POINTER
, &value
));
284 toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
286 if(toolbar
== NULL
) {
287 toolbar
= lttv_toolbars_new();
288 *(value
.v_pointer
) = toolbar
;
290 toolbar_c
= lttv_toolbars_add(toolbar
, view_constructor
, tooltip
, pixmap
,
293 g_slist_foreach(g_main_window_list
,
294 (gpointer
)add_toolbar_constructor
,
298 if(menu_path
!= NULL
) {
299 g_assert(lttv_iattribute_find_by_path(attributes_global
,
300 "viewers/menu", LTTV_POINTER
, &value
));
301 menu
= (LttvMenus
*)*(value
.v_pointer
);
304 menu
= lttv_menus_new();
305 *(value
.v_pointer
) = menu
;
307 menu_c
= lttv_menus_add(menu
, view_constructor
, menu_path
, menu_text
,NULL
);
309 g_slist_foreach(g_main_window_list
,
310 (gpointer
)add_menu_constructor
,
314 LttvAttribute
*attribute
;
316 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
317 LTTV_IATTRIBUTE(attributes_global
),
318 LTTV_VIEWER_CONSTRUCTORS
)));
320 g_assert(lttv_iattribute_find_by_path(LTTV_IATTRIBUTE(attribute
),
321 name
, LTTV_POINTER
, &value
));
323 *(value
.v_pointer
) = view_constructor
;
330 * Function to unregister the viewer's constructor, release the space
331 * occupied by menu_path, menu_text, pixmap, tooltip and constructor of the
334 * It will be called when a module is unloaded.
336 * @param view_constructor constructor of the viewer.
340 void lttvwindow_unregister_constructor
341 (lttvwindow_viewer_constructor view_constructor
)
343 LttvIAttribute
*attributes_global
= LTTV_IATTRIBUTE(lttv_global_attributes());
344 LttvToolbars
* toolbar
;
346 LttvAttributeValue value
;
349 g_assert(lttv_iattribute_find_by_path(attributes_global
,
350 "viewers/toolbar", LTTV_POINTER
, &value
));
351 toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
353 if(toolbar
!= NULL
) {
354 g_slist_foreach(g_main_window_list
,
355 (gpointer
)remove_toolbar_constructor
,
357 lttv_toolbars_remove(toolbar
, view_constructor
);
360 g_assert(lttv_iattribute_find_by_path(attributes_global
,
361 "viewers/menu", LTTV_POINTER
, &value
));
362 menu
= (LttvMenus
*)*(value
.v_pointer
);
365 g_slist_foreach(g_main_window_list
,
366 (gpointer
)remove_menu_constructor
,
368 lttv_menus_remove(menu
, view_constructor
);
372 LttvAttribute
*attribute
;
374 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
375 LTTV_IATTRIBUTE(attributes_global
),
376 LTTV_VIEWER_CONSTRUCTORS
)));
378 guint num
= lttv_iattribute_get_number(LTTV_IATTRIBUTE(attribute
));
380 LttvAttributeName name
;
381 LttvAttributeValue value
;
382 LttvAttributeType type
;
385 type
= lttv_iattribute_get(LTTV_IATTRIBUTE(attribute
), i
, &name
, &value
,
387 g_assert(type
== LTTV_POINTER
);
388 if(*(value
.v_pointer
) == view_constructor
) {
389 lttv_iattribute_remove(LTTV_IATTRIBUTE(attribute
), i
);
398 * Function to register a hook function for a viewer to set/update its
400 * @param tab viewer's tab
401 * @param hook hook function of the viewer.
402 * @param hook_data hook data associated with the hook function.
404 void lttvwindow_register_time_window_notify(Tab
*tab
,
405 LttvHook hook
, gpointer hook_data
)
407 LttvAttributeValue value
;
409 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
410 "hooks/updatetimewindow", LTTV_POINTER
, &value
));
411 tmp
= (LttvHooks
*)*(value
.v_pointer
);
413 tmp
= lttv_hooks_new();
414 *(value
.v_pointer
) = tmp
;
416 lttv_hooks_add(tmp
, hook
,hook_data
, LTTV_PRIO_DEFAULT
);
421 * Function to unregister a viewer's hook function which is used to
422 * set/update the time interval of the viewer.
423 * @param tab viewer's tab
424 * @param hook hook function of the viewer.
425 * @param hook_data hook data associated with the hook function.
428 void lttvwindow_unregister_time_window_notify(Tab
*tab
,
429 LttvHook hook
, gpointer hook_data
)
431 LttvAttributeValue value
;
433 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
434 "hooks/updatetimewindow", LTTV_POINTER
, &value
));
435 tmp
= (LttvHooks
*)*(value
.v_pointer
);
436 if(tmp
== NULL
) return;
437 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
441 * Function to register a hook function for a viewer to set/update its
443 * @param tab viewer's tab
444 * @param hook hook function of the viewer.
445 * @param hook_data hook data associated with the hook function.
448 void lttvwindow_register_traceset_notify(Tab
*tab
,
449 LttvHook hook
, gpointer hook_data
)
451 LttvAttributeValue value
;
453 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
454 "hooks/updatetraceset", LTTV_POINTER
, &value
));
455 tmp
= (LttvHooks
*)*(value
.v_pointer
);
457 tmp
= lttv_hooks_new();
458 *(value
.v_pointer
) = tmp
;
460 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
465 * Function to unregister a viewer's hook function which is used to
466 * set/update the traceset of the viewer.
467 * @param tab viewer's tab
468 * @param hook hook function of the viewer.
469 * @param hook_data hook data associated with the hook function.
472 void lttvwindow_unregister_traceset_notify(Tab
*tab
,
473 LttvHook hook
, gpointer hook_data
)
475 LttvAttributeValue value
;
477 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
478 "hooks/updatetraceset", LTTV_POINTER
, &value
));
479 tmp
= (LttvHooks
*)*(value
.v_pointer
);
480 if(tmp
== NULL
) return;
481 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
485 * Function to register a hook function for a viewer be completely redrawn.
487 * @param tab viewer's tab
488 * @param hook hook function of the viewer.
489 * @param hook_data hook data associated with the hook function.
492 void lttvwindow_register_redraw_notify(Tab
*tab
,
493 LttvHook hook
, gpointer hook_data
)
495 LttvAttributeValue value
;
497 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
498 "hooks/redraw", LTTV_POINTER
, &value
));
499 tmp
= (LttvHooks
*)*(value
.v_pointer
);
501 tmp
= lttv_hooks_new();
502 *(value
.v_pointer
) = tmp
;
504 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
509 * Function to unregister a hook function for a viewer be completely redrawn.
511 * @param tab viewer's tab
512 * @param hook hook function of the viewer.
513 * @param hook_data hook data associated with the hook function.
516 void lttvwindow_unregister_redraw_notify(Tab
*tab
,
517 LttvHook hook
, gpointer hook_data
)
519 LttvAttributeValue value
;
521 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
522 "hooks/redraw", LTTV_POINTER
, &value
));
523 tmp
= (LttvHooks
*)*(value
.v_pointer
);
524 if(tmp
== NULL
) return;
525 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
529 * Function to register a hook function for a viewer to re-do the events
530 * requests for the needed interval.
532 * This action is typically done after a "stop".
534 * The typical hook will remove all current requests for the viewer
535 * and make requests for missing information.
537 * @param tab viewer's tab
538 * @param hook hook function of the viewer.
539 * @param hook_data hook data associated with the hook function.
542 void lttvwindow_register_continue_notify(Tab
*tab
,
543 LttvHook hook
, gpointer hook_data
)
545 LttvAttributeValue value
;
547 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
548 "hooks/continue", LTTV_POINTER
, &value
));
549 tmp
= (LttvHooks
*)*(value
.v_pointer
);
551 tmp
= lttv_hooks_new();
552 *(value
.v_pointer
) = tmp
;
554 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
559 * Function to unregister a hook function for a viewer to re-do the events
560 * requests for the needed interval.
562 * @param tab viewer's tab
563 * @param hook hook function of the viewer.
564 * @param hook_data hook data associated with the hook function.
567 void lttvwindow_unregister_continue_notify(Tab
*tab
,
568 LttvHook hook
, gpointer hook_data
)
570 LttvAttributeValue value
;
572 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
573 "hooks/continue", LTTV_POINTER
, &value
));
574 tmp
= (LttvHooks
*)*(value
.v_pointer
);
575 if(tmp
== NULL
) return;
576 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
581 * Function to register a hook function for a viewer to set/update its
583 * @param tab viewer's tab
584 * @param hook hook function of the viewer.
585 * @param hook_data hook data associated with the hook function.
588 void lttvwindow_register_filter_notify(Tab
*tab
,
589 LttvHook hook
, gpointer hook_data
)
591 LttvAttributeValue value
;
593 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
594 "hooks/updatefilter", LTTV_POINTER
, &value
));
595 tmp
= (LttvHooks
*)*(value
.v_pointer
);
597 tmp
= lttv_hooks_new();
598 *(value
.v_pointer
) = tmp
;
600 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
605 * Function to unregister a viewer's hook function which is used to
606 * set/update the filter of the viewer.
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 void lttvwindow_unregister_filter_notify(Tab
*tab
,
616 LttvAttributeValue value
;
618 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
619 "hooks/updatefilter", LTTV_POINTER
, &value
));
620 tmp
= (LttvHooks
*)*(value
.v_pointer
);
621 if(tmp
== NULL
) return;
622 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
626 * function to register a hook function for a viewer to set/update its
628 * @param tab viewer's tab
629 * @param hook hook function of the viewer.
630 * @param hook_data hook data associated with the hook function.
633 void lttvwindow_register_current_time_notify(Tab
*tab
,
634 LttvHook hook
, gpointer hook_data
)
636 LttvAttributeValue value
;
638 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
639 "hooks/updatecurrenttime", LTTV_POINTER
, &value
));
640 tmp
= (LttvHooks
*)*(value
.v_pointer
);
642 tmp
= lttv_hooks_new();
643 *(value
.v_pointer
) = tmp
;
645 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
650 * function to unregister a viewer's hook function which is used to
651 * set/update the current time of the viewer.
652 * @param tab viewer's tab
653 * @param hook hook function of the viewer.
654 * @param hook_data hook data associated with the hook function.
657 void lttvwindow_unregister_current_time_notify(Tab
*tab
,
658 LttvHook hook
, gpointer hook_data
)
660 LttvAttributeValue value
;
662 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
663 "hooks/updatecurrenttime", LTTV_POINTER
, &value
));
664 tmp
= (LttvHooks
*)*(value
.v_pointer
);
665 if(tmp
== NULL
) return;
666 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
670 * function to register a hook function for a viewer to set/update its
672 * @param tab viewer's tab
673 * @param hook hook function of the viewer.
674 * @param hook_data hook data associated with the hook function.
677 void lttvwindow_register_current_position_notify(Tab
*tab
,
678 LttvHook hook
, gpointer hook_data
)
680 LttvAttributeValue value
;
682 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
683 "hooks/updatecurrentposition", LTTV_POINTER
, &value
));
684 tmp
= (LttvHooks
*)*(value
.v_pointer
);
686 tmp
= lttv_hooks_new();
687 *(value
.v_pointer
) = tmp
;
689 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
694 * function to unregister a viewer's hook function which is used to
695 * set/update the current position of the viewer.
696 * @param tab viewer's tab
697 * @param hook hook function of the viewer.
698 * @param hook_data hook data associated with the hook function.
701 void lttvwindow_unregister_current_position_notify(Tab
*tab
,
702 LttvHook hook
, gpointer hook_data
)
704 LttvAttributeValue value
;
706 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
707 "hooks/updatecurrentposition", LTTV_POINTER
, &value
));
708 tmp
= (LttvHooks
*)*(value
.v_pointer
);
709 if(tmp
== NULL
) return;
710 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
715 * Function to register a hook function for a viewer to show
716 * the content of the viewer.
717 * @param tab viewer's tab
718 * @param hook hook function of the viewer.
719 * @param hook_data hook data associated with the hook function.
722 void lttvwindow_register_show_notify(Tab
*tab
,
723 LttvHook hook
, gpointer hook_data
)
725 LttvAttributeValue value
;
727 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
728 "hooks/showviewer", LTTV_POINTER
, &value
));
729 tmp
= (LttvHooks
*)*(value
.v_pointer
);
731 tmp
= lttv_hooks_new();
732 *(value
.v_pointer
) = tmp
;
734 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
739 * Function to unregister a viewer's hook function which is used to
740 * show the content of the viewer..
741 * @param tab viewer's tab
742 * @param hook hook function of the viewer.
743 * @param hook_data hook data associated with the hook function.
746 void lttvwindow_unregister_show_notify(Tab
*tab
,
747 LttvHook hook
, gpointer hook_data
)
749 LttvAttributeValue value
;
751 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
752 "hooks/showviewer", LTTV_POINTER
, &value
));
753 tmp
= (LttvHooks
*)*(value
.v_pointer
);
754 if(tmp
== NULL
) return;
755 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
759 * Function to register a hook function for a viewer to set/update the
760 * dividor of the hpane.
761 * @param tab viewer's tab
762 * @param hook hook function of the viewer.
763 * @param hook_data hook data associated with the hook function.
766 void lttvwindow_register_dividor(Tab
*tab
,
767 LttvHook hook
, gpointer hook_data
)
769 LttvAttributeValue value
;
771 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
772 "hooks/hpanedividor", LTTV_POINTER
, &value
));
773 tmp
= (LttvHooks
*)*(value
.v_pointer
);
775 tmp
= lttv_hooks_new();
776 *(value
.v_pointer
) = tmp
;
778 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
783 * Function to unregister a viewer's hook function which is used to
784 * set/update hpane's dividor of the viewer.
785 * It will be called by the destructor of the viewer.
786 * @param tab viewer's tab
787 * @param hook hook function of the viewer.
788 * @param hook_data hook data associated with the hook function.
791 void lttvwindow_unregister_dividor(Tab
*tab
,
792 LttvHook hook
, gpointer hook_data
)
794 LttvAttributeValue value
;
796 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
797 "hooks/hpanedividor", LTTV_POINTER
, &value
));
798 tmp
= (LttvHooks
*)*(value
.v_pointer
);
799 if(tmp
== NULL
) return;
800 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
805 * Function to set the time interval of the current tab.
806 * It will be called by a viewer's signal handle associated with
807 * the move_slider signal
808 * @param tab viewer's tab
809 * @param time_interval a pointer where time interval is stored.
812 void lttvwindow_report_time_window(Tab
*tab
,
813 TimeWindow time_window
)
815 //set_time_window(tab, time_window);
816 //set_time_window_adjustment(tab, time_window);
818 time_change_manager(tab
, time_window
);
823 LttvTracesetContext
*tsc
=
824 LTTV_TRACESET_CONTEXT(tab
->traceset_info
->traceset_context
);
825 TimeInterval time_span
= tsc
->time_span
;
826 GtkAdjustment
*adjustment
= gtk_range_get_adjustment(GTK_RANGE(tab
->scrollbar
));
827 g_object_set(G_OBJECT(adjustment
),
832 ltt_time_sub(time_span
.end_time
, time_span
.start_time
))
835 ltt_time_to_double(time_window
->time_width
)
836 / SCROLL_STEP_PER_PAGE
837 , /* step increment */
839 ltt_time_to_double(time_window
->time_width
)
840 , /* page increment */
842 ltt_time_to_double(time_window
->time_width
)
845 gtk_adjustment_changed(adjustment
);
847 //g_object_set(G_OBJECT(adjustment),
849 // ltt_time_to_double(time_window->start_time)
852 /* Note : the set value will call set_time_window if scrollbar value changed
854 gtk_adjustment_set_value(adjustment
,
856 ltt_time_sub(time_window
->start_time
,
857 time_span
.start_time
))
864 * Function to set the current time of the current tab.
865 * It will be called by a viewer's signal handle associated with
866 * the button-release-event signal
867 * @param tab viewer's tab
868 * @param time a pointer where time is stored.
871 void lttvwindow_report_current_time(Tab
*tab
,
874 LttvAttributeValue value
;
877 current_time_change_manager(tab
, time
);
881 * Function to set the current event of the current tab.
882 * It will be called by a viewer's signal handle associated with
883 * the button-release-event signal
884 * @param tab viewer's tab
885 * @param time a pointer where time is stored.
888 void lttvwindow_report_current_position(Tab
*tab
,
889 LttvTracesetContextPosition
*pos
)
891 LttvAttributeValue value
;
894 current_position_change_manager(tab
, pos
);
899 * Function to set the position of the hpane's dividor (viewer).
900 * It will be called by a viewer's signal handle associated with
901 * the motion_notify_event event/signal
902 * @param tab viewer's tab
903 * @param position position of the hpane's dividor.
906 void lttvwindow_report_dividor(Tab
*tab
, gint position
)
908 LttvAttributeValue value
;
910 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
911 "hooks/hpanedividor", LTTV_POINTER
, &value
));
912 tmp
= (LttvHooks
*)*(value
.v_pointer
);
913 if(tmp
== NULL
) return;
914 lttv_hooks_call(tmp
, &position
);
918 * Function to request data in a specific time interval to the main window. The
919 * event request servicing is differed until the glib idle functions are
922 * The viewer has to provide hooks that should be associated with the event
925 * Either start time or start position must be defined in a EventRequest
926 * structure for it to be valid.
928 * end_time, end_position and num_events can all be defined. The first one
929 * to occur will be used as end criterion.
931 * @param tab viewer's tab
932 * @param events_requested the structure of request from.
935 void lttvwindow_events_request(Tab
*tab
,
936 EventsRequest
*events_request
)
938 tab
->events_requests
= g_slist_append(tab
->events_requests
, events_request
);
940 if(!tab
->events_request_pending
)
942 /* Redraw has +20 priority. We want to let the redraw be done while we do
943 * our job. Mathieu : test with high prio higher than events for better
945 //g_idle_add_full((G_PRIORITY_HIGH_IDLE + 21),
946 g_idle_add_full((G_PRIORITY_DEFAULT
+ 2),
947 (GSourceFunc
)execute_events_requests
,
950 tab
->events_request_pending
= TRUE
;
956 * Function to remove data requests related to a viewer.
958 * The existing requests's viewer gpointer is compared to the pointer
959 * given in argument to establish which data request should be removed.
961 * @param tab the tab the viewer belongs to.
962 * @param viewer a pointer to the viewer data structure
965 gint
find_viewer (const EventsRequest
*a
, gconstpointer b
)
967 return (a
->owner
!= b
);
971 void lttvwindow_events_request_remove_all(Tab
*tab
,
972 gconstpointer viewer
)
974 GSList
*element
= tab
->events_requests
;
977 g_slist_find_custom(element
, viewer
,
978 (GCompareFunc
)find_viewer
))
980 EventsRequest
*events_request
= (EventsRequest
*)element
->data
;
981 // Modified so a viewer being destroyed won't have its after_request
982 // called. Not so important anyway. Note that a viewer that call this
983 // remove_all function will not get its after_request called.
984 //if(events_request->servicing == TRUE) {
985 // lttv_hooks_call(events_request->after_request, NULL);
987 events_request_free(events_request
);
988 //g_free(events_request);
989 tab
->events_requests
= g_slist_remove_link(tab
->events_requests
, element
);
990 element
= g_slist_next(element
);
991 if(element
== NULL
) break; /* end of list */
993 if(g_slist_length(tab
->events_requests
) == 0) {
994 tab
->events_request_pending
= FALSE
;
995 g_idle_remove_by_data(tab
);
1002 * Function to see if there are events request pending.
1004 * It tells if events requests are pending. Useful for checks in some events,
1005 * i.e. detailed event list scrolling.
1007 * @param tab the tab the viewer belongs to.
1008 * @param viewer a pointer to the viewer data structure
1009 * @return : TRUE is events requests are pending, else FALSE.
1012 gboolean
lttvwindow_events_request_pending(Tab
*tab
)
1014 GSList
*element
= tab
->events_requests
;
1016 if(element
== NULL
) return FALSE
;
1024 * Function to get the current time interval shown on the current tab.
1025 * It will be called by a viewer's hook function to update the
1026 * shown time interval of the viewer and also be called by the constructor
1028 * @param tab viewer's tab
1029 * @return time window.
1032 TimeWindow
lttvwindow_get_time_window(Tab
*tab
)
1034 return tab
->time_window
;
1039 * Function to get the current time/event of the current tab.
1040 * It will be called by a viewer's hook function to update the
1041 * current time/event of the viewer.
1042 * @param tab viewer's tab
1046 LttTime
lttvwindow_get_current_time(Tab
*tab
)
1048 return tab
->current_time
;
1053 * Function to get the filter of the current tab.
1054 * @param filter, a pointer to a filter.
1056 * returns the current filter
1058 LttvFilter
*lttvwindow_get_filter(Tab
*tab
)
1064 * Function to set the filter of the current tab.
1065 * It should be called by the filter GUI to tell the
1066 * main window to update the filter tab's lttv_filter.
1068 * This function does change the current filter, removing the
1069 * old one when necessary, and call the updatefilter hooks
1070 * of the registered viewers.
1072 * @param main_win, the main window the viewer belongs to.
1073 * @param filter, a pointer to a filter.
1076 void lttvwindow_report_filter(Tab
*tab
, LttvFilter
*filter
)
1078 LttvAttributeValue value
;
1081 lttv_filter_destroy(tab
->filter
);
1082 tab
->filter
= filter
;
1084 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
1085 "hooks/updatefilter", LTTV_POINTER
, &value
));
1086 tmp
= (LttvHooks
*)*(value
.v_pointer
);
1087 if(tmp
== NULL
) return;
1088 lttv_hooks_call(tmp
, filter
);
1094 * Function to get the stats of the traceset
1095 * @param tab viewer's tab
1098 LttvTracesetStats
* lttvwindow_get_traceset_stats(Tab
*tab
)
1100 return tab
->traceset_info
->traceset_context
;
1104 LttvTracesetContext
* lttvwindow_get_traceset_context(Tab
*tab
)
1106 return (LttvTracesetContext
*)tab
->traceset_info
->traceset_context
;
1110 void events_request_free(EventsRequest
*events_request
)
1112 if(events_request
== NULL
) return;
1114 if(events_request
->start_position
!= NULL
)
1115 lttv_traceset_context_position_destroy(events_request
->start_position
);
1116 if(events_request
->end_position
!= NULL
)
1117 lttv_traceset_context_position_destroy(events_request
->end_position
);
1118 if(events_request
->hooks
!= NULL
) {
1120 GArray
*hooks
= events_request
->hooks
;
1121 for(i
=0;i
<hooks
->len
;i
++) {
1122 lttv_trace_hook_destroy(&g_array_index(hooks
, LttvTraceHook
, i
));
1124 g_array_free(events_request
->hooks
, TRUE
);
1126 if(events_request
->before_chunk_traceset
!= NULL
)
1127 lttv_hooks_destroy(events_request
->before_chunk_traceset
);
1128 if(events_request
->before_chunk_trace
!= NULL
)
1129 lttv_hooks_destroy(events_request
->before_chunk_trace
);
1130 if(events_request
->before_chunk_tracefile
!= NULL
)
1131 lttv_hooks_destroy(events_request
->before_chunk_tracefile
);
1132 if(events_request
->event
!= NULL
)
1133 lttv_hooks_destroy(events_request
->event
);
1134 if(events_request
->event_by_id
!= NULL
)
1135 lttv_hooks_by_id_destroy(events_request
->event_by_id
);
1136 if(events_request
->after_chunk_tracefile
!= NULL
)
1137 lttv_hooks_destroy(events_request
->after_chunk_tracefile
);
1138 if(events_request
->after_chunk_trace
!= NULL
)
1139 lttv_hooks_destroy(events_request
->after_chunk_trace
);
1140 if(events_request
->after_chunk_traceset
!= NULL
)
1141 lttv_hooks_destroy(events_request
->after_chunk_traceset
);
1142 if(events_request
->before_request
!= NULL
)
1143 lttv_hooks_destroy(events_request
->before_request
);
1144 if(events_request
->after_request
!= NULL
)
1145 lttv_hooks_destroy(events_request
->after_request
);
1147 g_free(events_request
);
1152 GtkWidget
*main_window_get_widget(Tab
*tab
)
1154 return tab
->mw
->mwindow
;