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 menu_path path of the menu item.
232 * @param menu_text text of the menu item.
233 * @param pixmap Image shown on the toolbar item.
234 * @param tooltip tooltip of the toolbar item.
235 * @param view_constructor constructor of the viewer.
238 void lttvwindow_register_constructor
243 lttvwindow_viewer_constructor view_constructor
)
245 LttvIAttribute
*attributes_global
= LTTV_IATTRIBUTE(lttv_global_attributes());
246 LttvToolbars
* toolbar
;
248 LttvToolbarClosure toolbar_c
;
249 LttvMenuClosure menu_c
;
250 LttvAttributeValue value
;
253 g_assert(lttv_iattribute_find_by_path(attributes_global
,
254 "viewers/toolbar", LTTV_POINTER
, &value
));
255 toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
257 if(toolbar
== NULL
) {
258 toolbar
= lttv_toolbars_new();
259 *(value
.v_pointer
) = toolbar
;
261 toolbar_c
= lttv_toolbars_add(toolbar
, view_constructor
, tooltip
, pixmap
,
264 g_slist_foreach(g_main_window_list
,
265 (gpointer
)add_toolbar_constructor
,
269 if(menu_path
!= NULL
) {
270 g_assert(lttv_iattribute_find_by_path(attributes_global
,
271 "viewers/menu", LTTV_POINTER
, &value
));
272 menu
= (LttvMenus
*)*(value
.v_pointer
);
275 menu
= lttv_menus_new();
276 *(value
.v_pointer
) = menu
;
278 menu_c
= lttv_menus_add(menu
, view_constructor
, menu_path
, menu_text
,NULL
);
280 g_slist_foreach(g_main_window_list
,
281 (gpointer
)add_menu_constructor
,
288 * Function to unregister the viewer's constructor, release the space
289 * occupied by menu_path, menu_text, pixmap, tooltip and constructor of the
292 * It will be called when a module is unloaded.
294 * @param view_constructor constructor of the viewer.
298 void lttvwindow_unregister_constructor
299 (lttvwindow_viewer_constructor view_constructor
)
301 LttvIAttribute
*attributes_global
= LTTV_IATTRIBUTE(lttv_global_attributes());
302 LttvToolbars
* toolbar
;
304 LttvAttributeValue value
;
306 g_assert(lttv_iattribute_find_by_path(attributes_global
,
307 "viewers/toolbar", LTTV_POINTER
, &value
));
308 toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
310 if(toolbar
!= NULL
) {
311 g_slist_foreach(g_main_window_list
,
312 (gpointer
)remove_toolbar_constructor
,
314 lttv_toolbars_remove(toolbar
, view_constructor
);
317 g_assert(lttv_iattribute_find_by_path(attributes_global
,
318 "viewers/menu", LTTV_POINTER
, &value
));
319 menu
= (LttvMenus
*)*(value
.v_pointer
);
322 g_slist_foreach(g_main_window_list
,
323 (gpointer
)remove_menu_constructor
,
325 lttv_menus_remove(menu
, view_constructor
);
331 * Function to register a hook function for a viewer to set/update its
333 * @param tab viewer's tab
334 * @param hook hook function of the viewer.
335 * @param hook_data hook data associated with the hook function.
337 void lttvwindow_register_time_window_notify(Tab
*tab
,
338 LttvHook hook
, gpointer hook_data
)
340 LttvAttributeValue value
;
342 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
343 "hooks/updatetimewindow", LTTV_POINTER
, &value
));
344 tmp
= (LttvHooks
*)*(value
.v_pointer
);
346 tmp
= lttv_hooks_new();
347 *(value
.v_pointer
) = tmp
;
349 lttv_hooks_add(tmp
, hook
,hook_data
, LTTV_PRIO_DEFAULT
);
354 * Function to unregister a viewer's hook function which is used to
355 * set/update the time interval of the viewer.
356 * @param tab viewer's tab
357 * @param hook hook function of the viewer.
358 * @param hook_data hook data associated with the hook function.
361 void lttvwindow_unregister_time_window_notify(Tab
*tab
,
362 LttvHook hook
, gpointer hook_data
)
364 LttvAttributeValue value
;
366 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
367 "hooks/updatetimewindow", LTTV_POINTER
, &value
));
368 tmp
= (LttvHooks
*)*(value
.v_pointer
);
369 if(tmp
== NULL
) return;
370 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
374 * Function to register a hook function for a viewer to set/update its
376 * @param tab viewer's tab
377 * @param hook hook function of the viewer.
378 * @param hook_data hook data associated with the hook function.
381 void lttvwindow_register_traceset_notify(Tab
*tab
,
382 LttvHook hook
, gpointer hook_data
)
384 LttvAttributeValue value
;
386 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
387 "hooks/updatetraceset", LTTV_POINTER
, &value
));
388 tmp
= (LttvHooks
*)*(value
.v_pointer
);
390 tmp
= lttv_hooks_new();
391 *(value
.v_pointer
) = tmp
;
393 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
398 * Function to unregister a viewer's hook function which is used to
399 * set/update the traceset of the viewer.
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.
405 void lttvwindow_unregister_traceset_notify(Tab
*tab
,
406 LttvHook hook
, gpointer hook_data
)
408 LttvAttributeValue value
;
410 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
411 "hooks/updatetraceset", LTTV_POINTER
, &value
));
412 tmp
= (LttvHooks
*)*(value
.v_pointer
);
413 if(tmp
== NULL
) return;
414 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
418 * Function to register a hook function for a viewer be completely redrawn.
420 * @param tab viewer's tab
421 * @param hook hook function of the viewer.
422 * @param hook_data hook data associated with the hook function.
425 void lttvwindow_register_redraw_notify(Tab
*tab
,
426 LttvHook hook
, gpointer hook_data
)
428 LttvAttributeValue value
;
430 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
431 "hooks/redraw", LTTV_POINTER
, &value
));
432 tmp
= (LttvHooks
*)*(value
.v_pointer
);
434 tmp
= lttv_hooks_new();
435 *(value
.v_pointer
) = tmp
;
437 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
442 * Function to unregister a hook function for a viewer be completely redrawn.
444 * @param tab viewer's tab
445 * @param hook hook function of the viewer.
446 * @param hook_data hook data associated with the hook function.
449 void lttvwindow_unregister_redraw_notify(Tab
*tab
,
450 LttvHook hook
, gpointer hook_data
)
452 LttvAttributeValue value
;
454 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
455 "hooks/redraw", LTTV_POINTER
, &value
));
456 tmp
= (LttvHooks
*)*(value
.v_pointer
);
457 if(tmp
== NULL
) return;
458 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
462 * Function to register a hook function for a viewer to re-do the events
463 * requests for the needed interval.
465 * This action is typically done after a "stop".
467 * The typical hook will remove all current requests for the viewer
468 * and make requests for missing information.
470 * @param tab viewer's tab
471 * @param hook hook function of the viewer.
472 * @param hook_data hook data associated with the hook function.
475 void lttvwindow_register_continue_notify(Tab
*tab
,
476 LttvHook hook
, gpointer hook_data
)
478 LttvAttributeValue value
;
480 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
481 "hooks/continue", LTTV_POINTER
, &value
));
482 tmp
= (LttvHooks
*)*(value
.v_pointer
);
484 tmp
= lttv_hooks_new();
485 *(value
.v_pointer
) = tmp
;
487 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
492 * Function to unregister a hook function for a viewer to re-do the events
493 * requests for the needed interval.
495 * @param tab viewer's tab
496 * @param hook hook function of the viewer.
497 * @param hook_data hook data associated with the hook function.
500 void lttvwindow_unregister_continue_notify(Tab
*tab
,
501 LttvHook hook
, gpointer hook_data
)
503 LttvAttributeValue value
;
505 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
506 "hooks/continue", LTTV_POINTER
, &value
));
507 tmp
= (LttvHooks
*)*(value
.v_pointer
);
508 if(tmp
== NULL
) return;
509 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
514 * Function to register a hook function for a viewer to set/update its
516 * @param tab viewer's tab
517 * @param hook hook function of the viewer.
518 * @param hook_data hook data associated with the hook function.
521 void lttvwindow_register_filter_notify(Tab
*tab
,
522 LttvHook hook
, gpointer hook_data
)
524 LttvAttributeValue value
;
526 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
527 "hooks/updatefilter", LTTV_POINTER
, &value
));
528 tmp
= (LttvHooks
*)*(value
.v_pointer
);
530 tmp
= lttv_hooks_new();
531 *(value
.v_pointer
) = tmp
;
533 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
538 * Function to unregister a viewer's hook function which is used to
539 * set/update the filter of the viewer.
540 * @param tab viewer's tab
541 * @param hook hook function of the viewer.
542 * @param hook_data hook data associated with the hook function.
545 void lttvwindow_unregister_filter_notify(Tab
*tab
,
549 LttvAttributeValue value
;
551 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
552 "hooks/updatefilter", LTTV_POINTER
, &value
));
553 tmp
= (LttvHooks
*)*(value
.v_pointer
);
554 if(tmp
== NULL
) return;
555 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
559 * Function to register a hook function for a viewer to set/update its
561 * @param tab viewer's tab
562 * @param hook hook function of the viewer.
563 * @param hook_data hook data associated with the hook function.
566 void lttvwindow_register_current_time_notify(Tab
*tab
,
567 LttvHook hook
, gpointer hook_data
)
569 LttvAttributeValue value
;
571 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
572 "hooks/updatecurrenttime", LTTV_POINTER
, &value
));
573 tmp
= (LttvHooks
*)*(value
.v_pointer
);
575 tmp
= lttv_hooks_new();
576 *(value
.v_pointer
) = tmp
;
578 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
583 * Function to unregister a viewer's hook function which is used to
584 * set/update the current time of the viewer.
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 void lttvwindow_unregister_current_time_notify(Tab
*tab
,
591 LttvHook hook
, gpointer hook_data
)
593 LttvAttributeValue value
;
595 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
596 "hooks/updatecurrenttime", LTTV_POINTER
, &value
));
597 tmp
= (LttvHooks
*)*(value
.v_pointer
);
598 if(tmp
== NULL
) return;
599 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
604 * Function to register a hook function for a viewer to show
605 * the content of the viewer.
606 * @param tab viewer's tab
607 * @param hook hook function of the viewer.
608 * @param hook_data hook data associated with the hook function.
611 void lttvwindow_register_show_notify(Tab
*tab
,
612 LttvHook hook
, gpointer hook_data
)
614 LttvAttributeValue value
;
616 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
617 "hooks/showviewer", LTTV_POINTER
, &value
));
618 tmp
= (LttvHooks
*)*(value
.v_pointer
);
620 tmp
= lttv_hooks_new();
621 *(value
.v_pointer
) = tmp
;
623 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
628 * Function to unregister a viewer's hook function which is used to
629 * show the content of the viewer..
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 void lttvwindow_unregister_show_notify(Tab
*tab
,
636 LttvHook hook
, gpointer hook_data
)
638 LttvAttributeValue value
;
640 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
641 "hooks/showviewer", LTTV_POINTER
, &value
));
642 tmp
= (LttvHooks
*)*(value
.v_pointer
);
643 if(tmp
== NULL
) return;
644 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
648 * Function to register a hook function for a viewer to set/update the
649 * dividor of the hpane.
650 * @param tab viewer's tab
651 * @param hook hook function of the viewer.
652 * @param hook_data hook data associated with the hook function.
655 void lttvwindow_register_dividor(Tab
*tab
,
656 LttvHook hook
, gpointer hook_data
)
658 LttvAttributeValue value
;
660 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
661 "hooks/hpanedividor", LTTV_POINTER
, &value
));
662 tmp
= (LttvHooks
*)*(value
.v_pointer
);
664 tmp
= lttv_hooks_new();
665 *(value
.v_pointer
) = tmp
;
667 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
672 * Function to unregister a viewer's hook function which is used to
673 * set/update hpane's dividor of the viewer.
674 * It will be called by the destructor of the viewer.
675 * @param tab viewer's tab
676 * @param hook hook function of the viewer.
677 * @param hook_data hook data associated with the hook function.
680 void lttvwindow_unregister_dividor(Tab
*tab
,
681 LttvHook hook
, gpointer hook_data
)
683 LttvAttributeValue value
;
685 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
686 "hooks/hpanedividor", LTTV_POINTER
, &value
));
687 tmp
= (LttvHooks
*)*(value
.v_pointer
);
688 if(tmp
== NULL
) return;
689 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
694 * Function to set the time interval of the current tab.
695 * It will be called by a viewer's signal handle associated with
696 * the move_slider signal
697 * @param tab viewer's tab
698 * @param time_interval a pointer where time interval is stored.
701 void lttvwindow_report_time_window(Tab
*tab
,
702 TimeWindow time_window
)
704 //set_time_window(tab, time_window);
705 //set_time_window_adjustment(tab, time_window);
707 time_change_manager(tab
, time_window
);
712 LttvTracesetContext
*tsc
=
713 LTTV_TRACESET_CONTEXT(tab
->traceset_info
->traceset_context
);
714 TimeInterval time_span
= tsc
->time_span
;
715 GtkAdjustment
*adjustment
= gtk_range_get_adjustment(GTK_RANGE(tab
->scrollbar
));
716 g_object_set(G_OBJECT(adjustment
),
721 ltt_time_sub(time_span
.end_time
, time_span
.start_time
))
722 * NANOSECONDS_PER_SECOND
, /* upper */
724 ltt_time_to_double(time_window
->time_width
)
725 / SCROLL_STEP_PER_PAGE
726 * NANOSECONDS_PER_SECOND
, /* step increment */
728 ltt_time_to_double(time_window
->time_width
)
729 * NANOSECONDS_PER_SECOND
, /* page increment */
731 ltt_time_to_double(time_window
->time_width
)
732 * NANOSECONDS_PER_SECOND
, /* page size */
734 gtk_adjustment_changed(adjustment
);
736 //g_object_set(G_OBJECT(adjustment),
738 // ltt_time_to_double(time_window->start_time)
739 // * NANOSECONDS_PER_SECOND, /* value */
741 /* Note : the set value will call set_time_window if scrollbar value changed
743 gtk_adjustment_set_value(adjustment
,
745 ltt_time_sub(time_window
->start_time
,
746 time_span
.start_time
))
747 * NANOSECONDS_PER_SECOND
);
753 * Function to set the current time/event of the current tab.
754 * It will be called by a viewer's signal handle associated with
755 * the button-release-event signal
756 * @param tab viewer's tab
757 * @param time a pointer where time is stored.
760 void lttvwindow_report_current_time(Tab
*tab
,
763 LttvAttributeValue value
;
766 current_time_change_manager(tab
, time
);
770 * Function to set the position of the hpane's dividor (viewer).
771 * It will be called by a viewer's signal handle associated with
772 * the motion_notify_event event/signal
773 * @param tab viewer's tab
774 * @param position position of the hpane's dividor.
777 void lttvwindow_report_dividor(Tab
*tab
, gint position
)
779 LttvAttributeValue value
;
781 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
782 "hooks/hpanedividor", LTTV_POINTER
, &value
));
783 tmp
= (LttvHooks
*)*(value
.v_pointer
);
784 if(tmp
== NULL
) return;
785 lttv_hooks_call(tmp
, &position
);
789 * Function to request data in a specific time interval to the main window. The
790 * event request servicing is differed until the glib idle functions are
793 * The viewer has to provide hooks that should be associated with the event
796 * Either start time or start position must be defined in a EventRequest
797 * structure for it to be valid.
799 * end_time, end_position and num_events can all be defined. The first one
800 * to occur will be used as end criterion.
802 * @param tab viewer's tab
803 * @param events_requested the structure of request from.
806 void lttvwindow_events_request(Tab
*tab
,
807 EventsRequest
*events_request
)
809 tab
->events_requests
= g_slist_append(tab
->events_requests
, events_request
);
811 if(!tab
->events_request_pending
)
813 /* Redraw has +20 priority. We want to let the redraw be done while we do
815 g_idle_add_full((G_PRIORITY_HIGH_IDLE
+ 21),
816 (GSourceFunc
)execute_events_requests
,
819 tab
->events_request_pending
= TRUE
;
825 * Function to remove data requests related to a viewer.
827 * The existing requests's viewer gpointer is compared to the pointer
828 * given in argument to establish which data request should be removed.
830 * @param tab the tab the viewer belongs to.
831 * @param viewer a pointer to the viewer data structure
834 gint
find_viewer (const EventsRequest
*a
, gconstpointer b
)
836 return (a
->owner
!= b
);
840 void lttvwindow_events_request_remove_all(Tab
*tab
,
841 gconstpointer viewer
)
846 g_slist_find_custom(tab
->events_requests
, viewer
,
847 (GCompareFunc
)find_viewer
))
849 EventsRequest
*events_request
= (EventsRequest
*)element
->data
;
850 // Modified so a viewer being destroyed won't have its after_request
851 // called. Not so important anyway. Note that a viewer that call this
852 // remove_all function will not get its after_request called.
853 //if(events_request->servicing == TRUE) {
854 // lttv_hooks_call(events_request->after_request, NULL);
856 g_free(events_request
);
857 tab
->events_requests
= g_slist_remove_link(tab
->events_requests
, element
);
859 if(g_slist_length(tab
->events_requests
) == 0) {
860 tab
->events_request_pending
= FALSE
;
861 g_idle_remove_by_data(tab
);
869 * Function to get the current time interval shown on the current tab.
870 * It will be called by a viewer's hook function to update the
871 * shown time interval of the viewer and also be called by the constructor
873 * @param tab viewer's tab
874 * @return time window.
877 TimeWindow
lttvwindow_get_time_window(Tab
*tab
)
879 return tab
->time_window
;
885 * Function to get the current time/event of the current tab.
886 * It will be called by a viewer's hook function to update the
887 * current time/event of the viewer.
888 * @param tab viewer's tab
892 LttTime
lttvwindow_get_current_time(Tab
*tab
)
894 return tab
->current_time
;
899 * Function to get the filter of the current tab.
900 * It will be called by the constructor of the viewer and also be
901 * called by a hook funtion of the viewer to update its filter.
902 * @param tab viewer's tab
903 * @param filter, a pointer to a filter.
905 const lttv_filter
*lttvwindow_get_filter(Tab
*tab
)
908 g_warning("lttvwindow_get_filter not implemented in viewer.c");
913 * Function to get the stats of the traceset
914 * @param tab viewer's tab
917 LttvTracesetStats
* lttvwindow_get_traceset_stats(Tab
*tab
)
919 return tab
->traceset_info
->traceset_context
;
923 LttvTracesetContext
* lttvwindow_get_traceset_context(Tab
*tab
)
925 return (LttvTracesetContext
*)tab
->traceset_info
->traceset_context
;