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
32 #include <lttv/lttv.h>
33 #include <lttv/state.h>
34 #include <lttv/stats.h>
35 #include <lttv/tracecontext.h>
36 #include <lttvwindow/mainwindow.h>
37 #include <lttvwindow/mainwindow-private.h>
38 #include <lttvwindow/lttvwindow.h>
39 #include <lttvwindow/toolbar.h>
40 #include <lttvwindow/menu.h>
41 #include <lttvwindow/callbacks.h> // for execute_events_requests
42 #include <lttvwindow/support.h>
45 * Internal function parts
48 extern GSList
* g_main_window_list
;
52 * It updates the time window of the tab, then calls the updatetimewindow
53 * hooks of each viewer.
55 * This is called whenever the scrollbar value changes.
58 void set_time_window(Tab
*tab
, const TimeWindow
*time_window
)
60 LttvAttributeValue value
;
63 TimeWindowNotifyData time_window_notify_data
;
64 TimeWindow old_time_window
= tab
->time_window
;
65 time_window_notify_data
.old_time_window
= &old_time_window
;
66 tab
->time_window
= *time_window
;
67 time_window_notify_data
.new_time_window
=
70 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
71 "hooks/updatetimewindow", LTTV_POINTER
, &value
));
72 tmp
= (LttvHooks
*)*(value
.v_pointer
);
73 if(tmp
!= NULL
) lttv_hooks_call(tmp
, &time_window_notify_data
);
75 //gtk_multi_vpaned_set_adjust(tab->multi_vpaned, new_time_window, FALSE);
81 * It updates the current time of the tab, then calls the updatetimewindow
82 * hooks of each viewer.
84 * This is called whenever the current time value changes.
87 void set_current_time(Tab
*tab
, const LttTime
*current_time
)
89 LttvAttributeValue value
;
92 tab
->current_time
= *current_time
;
94 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
95 "hooks/updatecurrenttime", LTTV_POINTER
, &value
));
96 tmp
= (LttvHooks
*)*(value
.v_pointer
);
97 if(tmp
!= NULL
) lttv_hooks_call(tmp
, &tab
->current_time
);
100 void add_toolbar_constructor(MainWindow
*mw
, LttvToolbarClosure
*toolbar_c
)
102 LttvIAttribute
*attributes
= mw
->attributes
;
103 LttvAttributeValue value
;
104 LttvToolbars
* instance_toolbar
;
105 lttvwindow_viewer_constructor constructor
;
106 GtkWidget
* tool_menu_title_menu
, *new_widget
, *pixmap
;
109 g_assert(lttv_iattribute_find_by_path(attributes
,
110 "viewers/toolbar", LTTV_POINTER
, &value
));
111 if(*(value
.v_pointer
) == NULL
)
112 *(value
.v_pointer
) = lttv_toolbars_new();
113 instance_toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
115 constructor
= toolbar_c
->con
;
116 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"MToolbar1");
117 pixbuf
= gdk_pixbuf_new_from_xpm_data((const char**)toolbar_c
->pixmap
);
118 pixmap
= gtk_image_new_from_pixbuf(pixbuf
);
120 gtk_toolbar_append_element (GTK_TOOLBAR (tool_menu_title_menu
),
121 GTK_TOOLBAR_CHILD_BUTTON
,
124 toolbar_c
->tooltip
, NULL
,
126 gtk_label_set_use_underline(
127 GTK_LABEL (((GtkToolbarChild
*) (
128 g_list_last (GTK_TOOLBAR
129 (tool_menu_title_menu
)->children
)->data
))->label
),
131 gtk_container_set_border_width (GTK_CONTAINER (new_widget
), 1);
132 g_signal_connect ((gpointer
) new_widget
,
134 G_CALLBACK (insert_viewer_wrap
),
136 gtk_widget_show (new_widget
);
138 lttv_toolbars_add(instance_toolbar
, toolbar_c
->con
,
145 void add_menu_constructor(MainWindow
*mw
, LttvMenuClosure
*menu_c
)
147 LttvIAttribute
*attributes
= mw
->attributes
;
148 LttvAttributeValue value
;
149 LttvToolbars
* instance_menu
;
150 lttvwindow_viewer_constructor constructor
;
151 GtkWidget
* tool_menu_title_menu
, *new_widget
;
153 g_assert(lttv_iattribute_find_by_path(attributes
,
154 "viewers/menu", LTTV_POINTER
, &value
));
155 if(*(value
.v_pointer
) == NULL
)
156 *(value
.v_pointer
) = lttv_menus_new();
157 instance_menu
= (LttvMenus
*)*(value
.v_pointer
);
160 constructor
= menu_c
->con
;
161 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"ToolMenuTitle_menu");
163 gtk_menu_item_new_with_mnemonic (menu_c
->menu_text
);
164 gtk_container_add (GTK_CONTAINER (tool_menu_title_menu
),
166 g_signal_connect ((gpointer
) new_widget
, "activate",
167 G_CALLBACK (insert_viewer_wrap
),
169 gtk_widget_show (new_widget
);
170 lttv_menus_add(instance_menu
, menu_c
->con
,
176 void remove_toolbar_constructor(MainWindow
*mw
, lttvwindow_viewer_constructor viewer_constructor
)
178 LttvIAttribute
*attributes
= mw
->attributes
;
179 LttvAttributeValue value
;
180 LttvToolbars
* instance_toolbar
;
181 lttvwindow_viewer_constructor constructor
;
182 GtkWidget
* tool_menu_title_menu
, *widget
;
184 g_assert(lttv_iattribute_find_by_path(attributes
,
185 "viewers/toolbar", LTTV_POINTER
, &value
));
186 if(*(value
.v_pointer
) == NULL
)
187 *(value
.v_pointer
) = lttv_toolbars_new();
188 instance_toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
190 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"MToolbar1");
191 widget
= lttv_menus_remove(instance_toolbar
, viewer_constructor
);
192 gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu
),
197 void remove_menu_constructor(MainWindow
*mw
, lttvwindow_viewer_constructor viewer_constructor
)
199 LttvIAttribute
*attributes
= mw
->attributes
;
200 LttvAttributeValue value
;
201 LttvMenus
* instance_menu
;
202 lttvwindow_viewer_constructor constructor
;
203 GtkWidget
* tool_menu_title_menu
, *widget
;
204 LttvMenuClosure
*menu_item_i
;
206 g_assert(lttv_iattribute_find_by_path(attributes
,
207 "viewers/menu", LTTV_POINTER
, &value
));
208 if(*(value
.v_pointer
) == NULL
)
209 *(value
.v_pointer
) = lttv_menus_new();
210 instance_menu
= (LttvMenus
*)*(value
.v_pointer
);
212 widget
= lttv_menus_remove(instance_menu
, viewer_constructor
);
213 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"ToolMenuTitle_menu");
214 gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu
), widget
);
224 * Function to register a view constructor so that main window can generate
225 * a menu item and a toolbar item for the viewer in order to generate a new
226 * instance easily. A menu entry and toolbar item will be added to each main
229 * It should be called by init function of the module.
231 * @param name name of the viewer
232 * @param menu_path path of the menu item.
233 * @param menu_text text of the menu item.
234 * @param pixmap Image shown on the toolbar item.
235 * @param tooltip tooltip of the toolbar item.
236 * @param view_constructor constructor of the viewer.
239 void lttvwindow_register_constructor
245 lttvwindow_viewer_constructor view_constructor
)
247 LttvIAttribute
*attributes_global
= LTTV_IATTRIBUTE(lttv_global_attributes());
248 LttvToolbars
* toolbar
;
250 LttvToolbarClosure toolbar_c
;
251 LttvMenuClosure menu_c
;
252 LttvAttributeValue value
;
254 if(view_constructor
== NULL
) return;
257 g_assert(lttv_iattribute_find_by_path(attributes_global
,
258 "viewers/toolbar", LTTV_POINTER
, &value
));
259 toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
261 if(toolbar
== NULL
) {
262 toolbar
= lttv_toolbars_new();
263 *(value
.v_pointer
) = toolbar
;
265 toolbar_c
= lttv_toolbars_add(toolbar
, view_constructor
, tooltip
, pixmap
,
268 g_slist_foreach(g_main_window_list
,
269 (gpointer
)add_toolbar_constructor
,
273 if(menu_path
!= NULL
) {
274 g_assert(lttv_iattribute_find_by_path(attributes_global
,
275 "viewers/menu", LTTV_POINTER
, &value
));
276 menu
= (LttvMenus
*)*(value
.v_pointer
);
279 menu
= lttv_menus_new();
280 *(value
.v_pointer
) = menu
;
282 menu_c
= lttv_menus_add(menu
, view_constructor
, menu_path
, menu_text
,NULL
);
284 g_slist_foreach(g_main_window_list
,
285 (gpointer
)add_menu_constructor
,
289 LttvAttribute
*attribute
;
291 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
292 LTTV_IATTRIBUTE(attributes_global
),
293 LTTV_VIEWER_CONSTRUCTORS
)));
295 g_assert(lttv_iattribute_find_by_path(LTTV_IATTRIBUTE(attribute
),
296 name
, LTTV_POINTER
, &value
));
298 *(value
.v_pointer
) = view_constructor
;
305 * Function to unregister the viewer's constructor, release the space
306 * occupied by menu_path, menu_text, pixmap, tooltip and constructor of the
309 * It will be called when a module is unloaded.
311 * @param view_constructor constructor of the viewer.
315 void lttvwindow_unregister_constructor
316 (lttvwindow_viewer_constructor view_constructor
)
318 LttvIAttribute
*attributes_global
= LTTV_IATTRIBUTE(lttv_global_attributes());
319 LttvToolbars
* toolbar
;
321 LttvAttributeValue value
;
323 g_assert(lttv_iattribute_find_by_path(attributes_global
,
324 "viewers/toolbar", LTTV_POINTER
, &value
));
325 toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
327 if(toolbar
!= NULL
) {
328 g_slist_foreach(g_main_window_list
,
329 (gpointer
)remove_toolbar_constructor
,
331 lttv_toolbars_remove(toolbar
, view_constructor
);
334 g_assert(lttv_iattribute_find_by_path(attributes_global
,
335 "viewers/menu", LTTV_POINTER
, &value
));
336 menu
= (LttvMenus
*)*(value
.v_pointer
);
339 g_slist_foreach(g_main_window_list
,
340 (gpointer
)remove_menu_constructor
,
342 lttv_menus_remove(menu
, view_constructor
);
346 LttvAttribute
*attribute
;
348 LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
349 LTTV_IATTRIBUTE(attributes_global
),
350 LTTV_VIEWER_CONSTRUCTORS
)));
352 guint num
= lttv_iattribute_get_number(LTTV_IATTRIBUTE(attribute
));
354 LttvAttributeName name
;
355 LttvAttributeValue value
;
356 LttvAttributeType type
;
359 type
= lttv_iattribute_get(LTTV_IATTRIBUTE(attribute
), i
, &name
, &value
);
360 g_assert(type
== LTTV_POINTER
);
361 if(*(value
.v_pointer
) == view_constructor
) {
362 lttv_iattribute_remove(LTTV_IATTRIBUTE(attribute
), i
);
371 * Function to register a hook function for a viewer to set/update its
373 * @param tab viewer's tab
374 * @param hook hook function of the viewer.
375 * @param hook_data hook data associated with the hook function.
377 void lttvwindow_register_time_window_notify(Tab
*tab
,
378 LttvHook hook
, gpointer hook_data
)
380 LttvAttributeValue value
;
382 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
383 "hooks/updatetimewindow", LTTV_POINTER
, &value
));
384 tmp
= (LttvHooks
*)*(value
.v_pointer
);
386 tmp
= lttv_hooks_new();
387 *(value
.v_pointer
) = tmp
;
389 lttv_hooks_add(tmp
, hook
,hook_data
, LTTV_PRIO_DEFAULT
);
394 * Function to unregister a viewer's hook function which is used to
395 * set/update the time interval of the viewer.
396 * @param tab viewer's tab
397 * @param hook hook function of the viewer.
398 * @param hook_data hook data associated with the hook function.
401 void lttvwindow_unregister_time_window_notify(Tab
*tab
,
402 LttvHook hook
, gpointer hook_data
)
404 LttvAttributeValue value
;
406 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
407 "hooks/updatetimewindow", LTTV_POINTER
, &value
));
408 tmp
= (LttvHooks
*)*(value
.v_pointer
);
409 if(tmp
== NULL
) return;
410 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
414 * Function to register a hook function for a viewer to set/update its
416 * @param tab viewer's tab
417 * @param hook hook function of the viewer.
418 * @param hook_data hook data associated with the hook function.
421 void lttvwindow_register_traceset_notify(Tab
*tab
,
422 LttvHook hook
, gpointer hook_data
)
424 LttvAttributeValue value
;
426 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
427 "hooks/updatetraceset", LTTV_POINTER
, &value
));
428 tmp
= (LttvHooks
*)*(value
.v_pointer
);
430 tmp
= lttv_hooks_new();
431 *(value
.v_pointer
) = tmp
;
433 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
438 * Function to unregister a viewer's hook function which is used to
439 * set/update the traceset of the viewer.
440 * @param tab viewer's tab
441 * @param hook hook function of the viewer.
442 * @param hook_data hook data associated with the hook function.
445 void lttvwindow_unregister_traceset_notify(Tab
*tab
,
446 LttvHook hook
, gpointer hook_data
)
448 LttvAttributeValue value
;
450 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
451 "hooks/updatetraceset", LTTV_POINTER
, &value
));
452 tmp
= (LttvHooks
*)*(value
.v_pointer
);
453 if(tmp
== NULL
) return;
454 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
458 * Function to register a hook function for a viewer be completely redrawn.
460 * @param tab viewer's tab
461 * @param hook hook function of the viewer.
462 * @param hook_data hook data associated with the hook function.
465 void lttvwindow_register_redraw_notify(Tab
*tab
,
466 LttvHook hook
, gpointer hook_data
)
468 LttvAttributeValue value
;
470 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
471 "hooks/redraw", LTTV_POINTER
, &value
));
472 tmp
= (LttvHooks
*)*(value
.v_pointer
);
474 tmp
= lttv_hooks_new();
475 *(value
.v_pointer
) = tmp
;
477 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
482 * Function to unregister a hook function for a viewer be completely redrawn.
484 * @param tab viewer's tab
485 * @param hook hook function of the viewer.
486 * @param hook_data hook data associated with the hook function.
489 void lttvwindow_unregister_redraw_notify(Tab
*tab
,
490 LttvHook hook
, gpointer hook_data
)
492 LttvAttributeValue value
;
494 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
495 "hooks/redraw", LTTV_POINTER
, &value
));
496 tmp
= (LttvHooks
*)*(value
.v_pointer
);
497 if(tmp
== NULL
) return;
498 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
502 * Function to register a hook function for a viewer to re-do the events
503 * requests for the needed interval.
505 * This action is typically done after a "stop".
507 * The typical hook will remove all current requests for the viewer
508 * and make requests for missing information.
510 * @param tab viewer's tab
511 * @param hook hook function of the viewer.
512 * @param hook_data hook data associated with the hook function.
515 void lttvwindow_register_continue_notify(Tab
*tab
,
516 LttvHook hook
, gpointer hook_data
)
518 LttvAttributeValue value
;
520 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
521 "hooks/continue", LTTV_POINTER
, &value
));
522 tmp
= (LttvHooks
*)*(value
.v_pointer
);
524 tmp
= lttv_hooks_new();
525 *(value
.v_pointer
) = tmp
;
527 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
532 * Function to unregister a hook function for a viewer to re-do the events
533 * requests for the needed interval.
535 * @param tab viewer's tab
536 * @param hook hook function of the viewer.
537 * @param hook_data hook data associated with the hook function.
540 void lttvwindow_unregister_continue_notify(Tab
*tab
,
541 LttvHook hook
, gpointer hook_data
)
543 LttvAttributeValue value
;
545 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
546 "hooks/continue", LTTV_POINTER
, &value
));
547 tmp
= (LttvHooks
*)*(value
.v_pointer
);
548 if(tmp
== NULL
) return;
549 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
554 * Function to register a hook function for a viewer to set/update its
556 * @param tab viewer's tab
557 * @param hook hook function of the viewer.
558 * @param hook_data hook data associated with the hook function.
561 void lttvwindow_register_filter_notify(Tab
*tab
,
562 LttvHook hook
, gpointer hook_data
)
564 LttvAttributeValue value
;
566 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
567 "hooks/updatefilter", LTTV_POINTER
, &value
));
568 tmp
= (LttvHooks
*)*(value
.v_pointer
);
570 tmp
= lttv_hooks_new();
571 *(value
.v_pointer
) = tmp
;
573 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
578 * Function to unregister a viewer's hook function which is used to
579 * set/update the filter of the viewer.
580 * @param tab viewer's tab
581 * @param hook hook function of the viewer.
582 * @param hook_data hook data associated with the hook function.
585 void lttvwindow_unregister_filter_notify(Tab
*tab
,
589 LttvAttributeValue value
;
591 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
592 "hooks/updatefilter", LTTV_POINTER
, &value
));
593 tmp
= (LttvHooks
*)*(value
.v_pointer
);
594 if(tmp
== NULL
) return;
595 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
599 * Function to register a hook function for a viewer to set/update its
601 * @param tab viewer's tab
602 * @param hook hook function of the viewer.
603 * @param hook_data hook data associated with the hook function.
606 void lttvwindow_register_current_time_notify(Tab
*tab
,
607 LttvHook hook
, gpointer hook_data
)
609 LttvAttributeValue value
;
611 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
612 "hooks/updatecurrenttime", LTTV_POINTER
, &value
));
613 tmp
= (LttvHooks
*)*(value
.v_pointer
);
615 tmp
= lttv_hooks_new();
616 *(value
.v_pointer
) = tmp
;
618 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
623 * Function to unregister a viewer's hook function which is used to
624 * set/update the current time of the viewer.
625 * @param tab viewer's tab
626 * @param hook hook function of the viewer.
627 * @param hook_data hook data associated with the hook function.
630 void lttvwindow_unregister_current_time_notify(Tab
*tab
,
631 LttvHook hook
, gpointer hook_data
)
633 LttvAttributeValue value
;
635 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
636 "hooks/updatecurrenttime", LTTV_POINTER
, &value
));
637 tmp
= (LttvHooks
*)*(value
.v_pointer
);
638 if(tmp
== NULL
) return;
639 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
644 * Function to register a hook function for a viewer to show
645 * the content of the viewer.
646 * @param tab viewer's tab
647 * @param hook hook function of the viewer.
648 * @param hook_data hook data associated with the hook function.
651 void lttvwindow_register_show_notify(Tab
*tab
,
652 LttvHook hook
, gpointer hook_data
)
654 LttvAttributeValue value
;
656 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
657 "hooks/showviewer", LTTV_POINTER
, &value
));
658 tmp
= (LttvHooks
*)*(value
.v_pointer
);
660 tmp
= lttv_hooks_new();
661 *(value
.v_pointer
) = tmp
;
663 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
668 * Function to unregister a viewer's hook function which is used to
669 * show the content of the viewer..
670 * @param tab viewer's tab
671 * @param hook hook function of the viewer.
672 * @param hook_data hook data associated with the hook function.
675 void lttvwindow_unregister_show_notify(Tab
*tab
,
676 LttvHook hook
, gpointer hook_data
)
678 LttvAttributeValue value
;
680 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
681 "hooks/showviewer", LTTV_POINTER
, &value
));
682 tmp
= (LttvHooks
*)*(value
.v_pointer
);
683 if(tmp
== NULL
) return;
684 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
688 * Function to register a hook function for a viewer to set/update the
689 * dividor of the hpane.
690 * @param tab viewer's tab
691 * @param hook hook function of the viewer.
692 * @param hook_data hook data associated with the hook function.
695 void lttvwindow_register_dividor(Tab
*tab
,
696 LttvHook hook
, gpointer hook_data
)
698 LttvAttributeValue value
;
700 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
701 "hooks/hpanedividor", LTTV_POINTER
, &value
));
702 tmp
= (LttvHooks
*)*(value
.v_pointer
);
704 tmp
= lttv_hooks_new();
705 *(value
.v_pointer
) = tmp
;
707 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
712 * Function to unregister a viewer's hook function which is used to
713 * set/update hpane's dividor of the viewer.
714 * It will be called by the destructor of the viewer.
715 * @param tab viewer's tab
716 * @param hook hook function of the viewer.
717 * @param hook_data hook data associated with the hook function.
720 void lttvwindow_unregister_dividor(Tab
*tab
,
721 LttvHook hook
, gpointer hook_data
)
723 LttvAttributeValue value
;
725 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
726 "hooks/hpanedividor", LTTV_POINTER
, &value
));
727 tmp
= (LttvHooks
*)*(value
.v_pointer
);
728 if(tmp
== NULL
) return;
729 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
734 * Function to set the time interval of the current tab.
735 * It will be called by a viewer's signal handle associated with
736 * the move_slider signal
737 * @param tab viewer's tab
738 * @param time_interval a pointer where time interval is stored.
741 void lttvwindow_report_time_window(Tab
*tab
,
742 TimeWindow time_window
)
744 //set_time_window(tab, time_window);
745 //set_time_window_adjustment(tab, time_window);
747 time_change_manager(tab
, time_window
);
752 LttvTracesetContext
*tsc
=
753 LTTV_TRACESET_CONTEXT(tab
->traceset_info
->traceset_context
);
754 TimeInterval time_span
= tsc
->time_span
;
755 GtkAdjustment
*adjustment
= gtk_range_get_adjustment(GTK_RANGE(tab
->scrollbar
));
756 g_object_set(G_OBJECT(adjustment
),
761 ltt_time_sub(time_span
.end_time
, time_span
.start_time
))
764 ltt_time_to_double(time_window
->time_width
)
765 / SCROLL_STEP_PER_PAGE
766 , /* step increment */
768 ltt_time_to_double(time_window
->time_width
)
769 , /* page increment */
771 ltt_time_to_double(time_window
->time_width
)
774 gtk_adjustment_changed(adjustment
);
776 //g_object_set(G_OBJECT(adjustment),
778 // ltt_time_to_double(time_window->start_time)
781 /* Note : the set value will call set_time_window if scrollbar value changed
783 gtk_adjustment_set_value(adjustment
,
785 ltt_time_sub(time_window
->start_time
,
786 time_span
.start_time
))
793 * Function to set the current time/event of the current tab.
794 * It will be called by a viewer's signal handle associated with
795 * the button-release-event signal
796 * @param tab viewer's tab
797 * @param time a pointer where time is stored.
800 void lttvwindow_report_current_time(Tab
*tab
,
803 LttvAttributeValue value
;
806 current_time_change_manager(tab
, time
);
810 * Function to set the position of the hpane's dividor (viewer).
811 * It will be called by a viewer's signal handle associated with
812 * the motion_notify_event event/signal
813 * @param tab viewer's tab
814 * @param position position of the hpane's dividor.
817 void lttvwindow_report_dividor(Tab
*tab
, gint position
)
819 LttvAttributeValue value
;
821 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
822 "hooks/hpanedividor", LTTV_POINTER
, &value
));
823 tmp
= (LttvHooks
*)*(value
.v_pointer
);
824 if(tmp
== NULL
) return;
825 lttv_hooks_call(tmp
, &position
);
829 * Function to request data in a specific time interval to the main window. The
830 * event request servicing is differed until the glib idle functions are
833 * The viewer has to provide hooks that should be associated with the event
836 * Either start time or start position must be defined in a EventRequest
837 * structure for it to be valid.
839 * end_time, end_position and num_events can all be defined. The first one
840 * to occur will be used as end criterion.
842 * @param tab viewer's tab
843 * @param events_requested the structure of request from.
846 void lttvwindow_events_request(Tab
*tab
,
847 EventsRequest
*events_request
)
849 tab
->events_requests
= g_slist_append(tab
->events_requests
, events_request
);
851 if(!tab
->events_request_pending
)
853 /* Redraw has +20 priority. We want to let the redraw be done while we do
855 g_idle_add_full((G_PRIORITY_HIGH_IDLE
+ 21),
856 (GSourceFunc
)execute_events_requests
,
859 tab
->events_request_pending
= TRUE
;
865 * Function to remove data requests related to a viewer.
867 * The existing requests's viewer gpointer is compared to the pointer
868 * given in argument to establish which data request should be removed.
870 * @param tab the tab the viewer belongs to.
871 * @param viewer a pointer to the viewer data structure
874 gint
find_viewer (const EventsRequest
*a
, gconstpointer b
)
876 return (a
->owner
!= b
);
880 void lttvwindow_events_request_remove_all(Tab
*tab
,
881 gconstpointer viewer
)
883 GSList
*element
= tab
->events_requests
;
886 g_slist_find_custom(element
, viewer
,
887 (GCompareFunc
)find_viewer
))
889 EventsRequest
*events_request
= (EventsRequest
*)element
->data
;
890 // Modified so a viewer being destroyed won't have its after_request
891 // called. Not so important anyway. Note that a viewer that call this
892 // remove_all function will not get its after_request called.
893 //if(events_request->servicing == TRUE) {
894 // lttv_hooks_call(events_request->after_request, NULL);
896 g_free(events_request
);
897 tab
->events_requests
= g_slist_remove_link(tab
->events_requests
, element
);
898 element
= g_slist_next(element
);
899 if(element
== NULL
) break; /* end of list */
901 if(g_slist_length(tab
->events_requests
) == 0) {
902 tab
->events_request_pending
= FALSE
;
903 g_idle_remove_by_data(tab
);
909 * Function to get the current time interval shown on the current tab.
910 * It will be called by a viewer's hook function to update the
911 * shown time interval of the viewer and also be called by the constructor
913 * @param tab viewer's tab
914 * @return time window.
917 TimeWindow
lttvwindow_get_time_window(Tab
*tab
)
919 return tab
->time_window
;
924 * Function to get the current time/event of the current tab.
925 * It will be called by a viewer's hook function to update the
926 * current time/event of the viewer.
927 * @param tab viewer's tab
931 LttTime
lttvwindow_get_current_time(Tab
*tab
)
933 return tab
->current_time
;
938 * Function to get the filter of the current tab.
939 * @param main_win, the main window the viewer belongs to.
940 * @param filter, a pointer to a filter.
943 LttvFilter
*lttvwindow_get_filter(Tab
*tab
)
949 * Function to set the filter of the current tab.
950 * It should be called by the filter GUI to tell the
951 * main window to update the filter tab's lttv_filter.
953 * This function does change the current filter, removing the
954 * old one when necessary, and call the updatefilter hooks
955 * of the registered viewers.
957 * @param main_win, the main window the viewer belongs to.
958 * @param filter, a pointer to a filter.
961 void lttvwindow_report_filter(Tab
*tab
, LttvFilter
*filter
)
963 LttvAttributeValue value
;
966 lttv_filter_destroy(tab
->filter
);
967 tab
->filter
= filter
;
969 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
970 "hooks/updatefilter", LTTV_POINTER
, &value
));
971 tmp
= (LttvHooks
*)*(value
.v_pointer
);
972 if(tmp
== NULL
) return;
973 lttv_hooks_call(tmp
, &position
);
979 * Function to get the stats of the traceset
980 * @param tab viewer's tab
983 LttvTracesetStats
* lttvwindow_get_traceset_stats(Tab
*tab
)
985 return tab
->traceset_info
->traceset_context
;
989 LttvTracesetContext
* lttvwindow_get_traceset_context(Tab
*tab
)
991 return (LttvTracesetContext
*)tab
->traceset_info
->traceset_context
;