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);
79 void add_toolbar_constructor(MainWindow
*mw
, LttvToolbarClosure
*toolbar_c
)
81 LttvIAttribute
*attributes
= mw
->attributes
;
82 LttvAttributeValue value
;
83 LttvToolbars
* instance_toolbar
;
84 lttvwindow_viewer_constructor constructor
;
85 GtkWidget
* tool_menu_title_menu
, *new_widget
, *pixmap
;
88 g_assert(lttv_iattribute_find_by_path(attributes
,
89 "viewers/toolbar", LTTV_POINTER
, &value
));
90 if(*(value
.v_pointer
) == NULL
)
91 *(value
.v_pointer
) = lttv_toolbars_new();
92 instance_toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
94 constructor
= toolbar_c
->con
;
95 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"MToolbar1");
96 pixbuf
= gdk_pixbuf_new_from_xpm_data((const char**)toolbar_c
->pixmap
);
97 pixmap
= gtk_image_new_from_pixbuf(pixbuf
);
99 gtk_toolbar_append_element (GTK_TOOLBAR (tool_menu_title_menu
),
100 GTK_TOOLBAR_CHILD_BUTTON
,
103 toolbar_c
->tooltip
, NULL
,
105 gtk_label_set_use_underline(
106 GTK_LABEL (((GtkToolbarChild
*) (
107 g_list_last (GTK_TOOLBAR
108 (tool_menu_title_menu
)->children
)->data
))->label
),
110 gtk_container_set_border_width (GTK_CONTAINER (new_widget
), 1);
111 g_signal_connect ((gpointer
) new_widget
,
113 G_CALLBACK (insert_viewer_wrap
),
115 gtk_widget_show (new_widget
);
117 lttv_toolbars_add(instance_toolbar
, toolbar_c
->con
,
124 void add_menu_constructor(MainWindow
*mw
, LttvMenuClosure
*menu_c
)
126 LttvIAttribute
*attributes
= mw
->attributes
;
127 LttvAttributeValue value
;
128 LttvToolbars
* instance_menu
;
129 lttvwindow_viewer_constructor constructor
;
130 GtkWidget
* tool_menu_title_menu
, *new_widget
;
132 g_assert(lttv_iattribute_find_by_path(attributes
,
133 "viewers/menu", LTTV_POINTER
, &value
));
134 if(*(value
.v_pointer
) == NULL
)
135 *(value
.v_pointer
) = lttv_menus_new();
136 instance_menu
= (LttvMenus
*)*(value
.v_pointer
);
139 constructor
= menu_c
->con
;
140 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"ToolMenuTitle_menu");
142 gtk_menu_item_new_with_mnemonic (menu_c
->menu_text
);
143 gtk_container_add (GTK_CONTAINER (tool_menu_title_menu
),
145 g_signal_connect ((gpointer
) new_widget
, "activate",
146 G_CALLBACK (insert_viewer_wrap
),
148 gtk_widget_show (new_widget
);
149 lttv_menus_add(instance_menu
, menu_c
->con
,
155 void remove_toolbar_constructor(MainWindow
*mw
, lttvwindow_viewer_constructor viewer_constructor
)
157 LttvIAttribute
*attributes
= mw
->attributes
;
158 LttvAttributeValue value
;
159 LttvToolbars
* instance_toolbar
;
160 lttvwindow_viewer_constructor constructor
;
161 GtkWidget
* tool_menu_title_menu
, *widget
;
163 g_assert(lttv_iattribute_find_by_path(attributes
,
164 "viewers/toolbar", LTTV_POINTER
, &value
));
165 if(*(value
.v_pointer
) == NULL
)
166 *(value
.v_pointer
) = lttv_toolbars_new();
167 instance_toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
169 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"MToolbar1");
170 widget
= lttv_menus_remove(instance_toolbar
, viewer_constructor
);
171 gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu
),
176 void remove_menu_constructor(MainWindow
*mw
, lttvwindow_viewer_constructor viewer_constructor
)
178 LttvIAttribute
*attributes
= mw
->attributes
;
179 LttvAttributeValue value
;
180 LttvMenus
* instance_menu
;
181 lttvwindow_viewer_constructor constructor
;
182 GtkWidget
* tool_menu_title_menu
, *widget
;
183 LttvMenuClosure
*menu_item_i
;
185 g_assert(lttv_iattribute_find_by_path(attributes
,
186 "viewers/menu", LTTV_POINTER
, &value
));
187 if(*(value
.v_pointer
) == NULL
)
188 *(value
.v_pointer
) = lttv_menus_new();
189 instance_menu
= (LttvMenus
*)*(value
.v_pointer
);
191 widget
= lttv_menus_remove(instance_menu
, viewer_constructor
);
192 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"ToolMenuTitle_menu");
193 gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu
), widget
);
203 * Function to register a view constructor so that main window can generate
204 * a menu item and a toolbar item for the viewer in order to generate a new
205 * instance easily. A menu entry and toolbar item will be added to each main
208 * It should be called by init function of the module.
210 * @param menu_path path of the menu item.
211 * @param menu_text text of the menu item.
212 * @param pixmap Image shown on the toolbar item.
213 * @param tooltip tooltip of the toolbar item.
214 * @param view_constructor constructor of the viewer.
217 void lttvwindow_register_constructor
222 lttvwindow_viewer_constructor view_constructor
)
224 LttvIAttribute
*attributes_global
= LTTV_IATTRIBUTE(lttv_global_attributes());
225 LttvToolbars
* toolbar
;
227 LttvToolbarClosure toolbar_c
;
228 LttvMenuClosure menu_c
;
229 LttvAttributeValue value
;
232 g_assert(lttv_iattribute_find_by_path(attributes_global
,
233 "viewers/toolbar", LTTV_POINTER
, &value
));
234 toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
236 if(toolbar
== NULL
) {
237 toolbar
= lttv_toolbars_new();
238 *(value
.v_pointer
) = toolbar
;
240 toolbar_c
= lttv_toolbars_add(toolbar
, view_constructor
, tooltip
, pixmap
,
243 g_slist_foreach(g_main_window_list
,
244 (gpointer
)add_toolbar_constructor
,
248 if(menu_path
!= NULL
) {
249 g_assert(lttv_iattribute_find_by_path(attributes_global
,
250 "viewers/menu", LTTV_POINTER
, &value
));
251 menu
= (LttvMenus
*)*(value
.v_pointer
);
254 menu
= lttv_menus_new();
255 *(value
.v_pointer
) = menu
;
257 menu_c
= lttv_menus_add(menu
, view_constructor
, menu_path
, menu_text
,NULL
);
259 g_slist_foreach(g_main_window_list
,
260 (gpointer
)add_menu_constructor
,
267 * Function to unregister the viewer's constructor, release the space
268 * occupied by menu_path, menu_text, pixmap, tooltip and constructor of the
271 * It will be called when a module is unloaded.
273 * @param view_constructor constructor of the viewer.
277 void lttvwindow_unregister_constructor
278 (lttvwindow_viewer_constructor view_constructor
)
280 LttvIAttribute
*attributes_global
= LTTV_IATTRIBUTE(lttv_global_attributes());
281 LttvToolbars
* toolbar
;
283 LttvAttributeValue value
;
285 g_assert(lttv_iattribute_find_by_path(attributes_global
,
286 "viewers/toolbar", LTTV_POINTER
, &value
));
287 toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
289 if(toolbar
!= NULL
) {
290 g_slist_foreach(g_main_window_list
,
291 (gpointer
)remove_toolbar_constructor
,
293 lttv_toolbars_remove(toolbar
, view_constructor
);
296 g_assert(lttv_iattribute_find_by_path(attributes_global
,
297 "viewers/menu", LTTV_POINTER
, &value
));
298 menu
= (LttvMenus
*)*(value
.v_pointer
);
301 g_slist_foreach(g_main_window_list
,
302 (gpointer
)remove_menu_constructor
,
304 lttv_menus_remove(menu
, view_constructor
);
310 * Function to register a hook function for a viewer to set/update its
312 * @param tab viewer's tab
313 * @param hook hook function of the viewer.
314 * @param hook_data hook data associated with the hook function.
316 void lttvwindow_register_time_window_notify(Tab
*tab
,
317 LttvHook hook
, gpointer hook_data
)
319 LttvAttributeValue value
;
321 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
322 "hooks/updatetimewindow", LTTV_POINTER
, &value
));
323 tmp
= (LttvHooks
*)*(value
.v_pointer
);
325 tmp
= lttv_hooks_new();
326 *(value
.v_pointer
) = tmp
;
328 lttv_hooks_add(tmp
, hook
,hook_data
, LTTV_PRIO_DEFAULT
);
333 * Function to unregister a viewer's hook function which is used to
334 * set/update the time interval of the viewer.
335 * @param tab viewer's tab
336 * @param hook hook function of the viewer.
337 * @param hook_data hook data associated with the hook function.
340 void lttvwindow_unregister_time_window_notify(Tab
*tab
,
341 LttvHook hook
, gpointer hook_data
)
343 LttvAttributeValue value
;
345 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
346 "hooks/updatetimewindow", LTTV_POINTER
, &value
));
347 tmp
= (LttvHooks
*)*(value
.v_pointer
);
348 if(tmp
== NULL
) return;
349 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
353 * Function to register a hook function for a viewer to set/update its
355 * @param tab viewer's tab
356 * @param hook hook function of the viewer.
357 * @param hook_data hook data associated with the hook function.
360 void lttvwindow_register_traceset_notify(Tab
*tab
,
361 LttvHook hook
, gpointer hook_data
)
363 LttvAttributeValue value
;
365 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
366 "hooks/updatetraceset", LTTV_POINTER
, &value
));
367 tmp
= (LttvHooks
*)*(value
.v_pointer
);
369 tmp
= lttv_hooks_new();
370 *(value
.v_pointer
) = tmp
;
372 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
377 * Function to unregister a viewer's hook function which is used to
378 * set/update the traceset of the viewer.
379 * @param tab viewer's tab
380 * @param hook hook function of the viewer.
381 * @param hook_data hook data associated with the hook function.
384 void lttvwindow_unregister_traceset_notify(Tab
*tab
,
385 LttvHook hook
, gpointer hook_data
)
387 LttvAttributeValue value
;
389 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
390 "hooks/updatetraceset", LTTV_POINTER
, &value
));
391 tmp
= (LttvHooks
*)*(value
.v_pointer
);
392 if(tmp
== NULL
) return;
393 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
397 * Function to register a hook function for a viewer be completely redrawn.
399 * @param tab viewer's tab
400 * @param hook hook function of the viewer.
401 * @param hook_data hook data associated with the hook function.
404 void lttvwindow_register_redraw_notify(Tab
*tab
,
405 LttvHook hook
, gpointer hook_data
)
407 LttvAttributeValue value
;
409 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
410 "hooks/redraw", 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 hook function for a viewer be completely redrawn.
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_redraw_notify(Tab
*tab
,
429 LttvHook hook
, gpointer hook_data
)
431 LttvAttributeValue value
;
433 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
434 "hooks/redraw", 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 re-do the events
442 * requests for the needed interval.
444 * This action is typically done after a "stop".
446 * The typical hook will remove all current requests for the viewer
447 * and make requests for missing information.
449 * @param tab viewer's tab
450 * @param hook hook function of the viewer.
451 * @param hook_data hook data associated with the hook function.
454 void lttvwindow_register_continue_notify(Tab
*tab
,
455 LttvHook hook
, gpointer hook_data
)
457 LttvAttributeValue value
;
459 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
460 "hooks/continue", LTTV_POINTER
, &value
));
461 tmp
= (LttvHooks
*)*(value
.v_pointer
);
463 tmp
= lttv_hooks_new();
464 *(value
.v_pointer
) = tmp
;
466 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
471 * Function to unregister a hook function for a viewer to re-do the events
472 * requests for the needed interval.
474 * @param tab viewer's tab
475 * @param hook hook function of the viewer.
476 * @param hook_data hook data associated with the hook function.
479 void lttvwindow_unregister_continue_notify(Tab
*tab
,
480 LttvHook hook
, gpointer hook_data
)
482 LttvAttributeValue value
;
484 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
485 "hooks/continue", LTTV_POINTER
, &value
));
486 tmp
= (LttvHooks
*)*(value
.v_pointer
);
487 if(tmp
== NULL
) return;
488 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
493 * Function to register a hook function for a viewer to set/update its
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_register_filter_notify(Tab
*tab
,
501 LttvHook hook
, gpointer hook_data
)
503 LttvAttributeValue value
;
505 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
506 "hooks/updatefilter", LTTV_POINTER
, &value
));
507 tmp
= (LttvHooks
*)*(value
.v_pointer
);
509 tmp
= lttv_hooks_new();
510 *(value
.v_pointer
) = tmp
;
512 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
517 * Function to unregister a viewer's hook function which is used to
518 * set/update the filter of the viewer.
519 * @param tab viewer's tab
520 * @param hook hook function of the viewer.
521 * @param hook_data hook data associated with the hook function.
524 void lttvwindow_unregister_filter_notify(Tab
*tab
,
528 LttvAttributeValue value
;
530 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
531 "hooks/updatefilter", LTTV_POINTER
, &value
));
532 tmp
= (LttvHooks
*)*(value
.v_pointer
);
533 if(tmp
== NULL
) return;
534 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
538 * Function to register a hook function for a viewer to set/update its
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_register_current_time_notify(Tab
*tab
,
546 LttvHook hook
, gpointer hook_data
)
548 LttvAttributeValue value
;
550 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
551 "hooks/updatecurrenttime", LTTV_POINTER
, &value
));
552 tmp
= (LttvHooks
*)*(value
.v_pointer
);
554 tmp
= lttv_hooks_new();
555 *(value
.v_pointer
) = tmp
;
557 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
562 * Function to unregister a viewer's hook function which is used to
563 * set/update the current time of the viewer.
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 void lttvwindow_unregister_current_time_notify(Tab
*tab
,
570 LttvHook hook
, gpointer hook_data
)
572 LttvAttributeValue value
;
574 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
575 "hooks/updatecurrenttime", 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 show
584 * the content 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_register_show_notify(Tab
*tab
,
591 LttvHook hook
, gpointer hook_data
)
593 LttvAttributeValue value
;
595 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
596 "hooks/showviewer", 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 * show the content 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 void lttvwindow_unregister_show_notify(Tab
*tab
,
615 LttvHook hook
, gpointer hook_data
)
617 LttvAttributeValue value
;
619 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
620 "hooks/showviewer", LTTV_POINTER
, &value
));
621 tmp
= (LttvHooks
*)*(value
.v_pointer
);
622 if(tmp
== NULL
) return;
623 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
627 * Function to register a hook function for a viewer to set/update the
628 * dividor of the hpane.
629 * @param tab viewer's tab
630 * @param hook hook function of the viewer.
631 * @param hook_data hook data associated with the hook function.
634 void lttvwindow_register_dividor(Tab
*tab
,
635 LttvHook hook
, gpointer hook_data
)
637 LttvAttributeValue value
;
639 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
640 "hooks/hpanedividor", LTTV_POINTER
, &value
));
641 tmp
= (LttvHooks
*)*(value
.v_pointer
);
643 tmp
= lttv_hooks_new();
644 *(value
.v_pointer
) = tmp
;
646 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
651 * Function to unregister a viewer's hook function which is used to
652 * set/update hpane's dividor of the viewer.
653 * It will be called by the destructor 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 void lttvwindow_unregister_dividor(Tab
*tab
,
660 LttvHook hook
, gpointer hook_data
)
662 LttvAttributeValue value
;
664 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
665 "hooks/hpanedividor", LTTV_POINTER
, &value
));
666 tmp
= (LttvHooks
*)*(value
.v_pointer
);
667 if(tmp
== NULL
) return;
668 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
673 * Function to set the time interval of the current tab.
674 * It will be called by a viewer's signal handle associated with
675 * the move_slider signal
676 * @param tab viewer's tab
677 * @param time_interval a pointer where time interval is stored.
680 void lttvwindow_report_time_window(Tab
*tab
,
681 const TimeWindow
*time_window
)
683 //set_time_window(tab, time_window);
684 //set_time_window_adjustment(tab, time_window);
687 LttvTracesetContext
*tsc
=
688 LTTV_TRACESET_CONTEXT(tab
->traceset_info
->traceset_context
);
689 TimeInterval time_span
= tsc
->time_span
;
690 GtkAdjustment
*adjustment
= gtk_range_get_adjustment(GTK_RANGE(tab
->scrollbar
));
692 g_object_set(G_OBJECT(adjustment
),
694 ltt_time_to_double(time_span
.start_time
)
695 * NANOSECONDS_PER_SECOND
, /* lower */
697 ltt_time_to_double(time_span
.end_time
)
698 * NANOSECONDS_PER_SECOND
, /* upper */
700 ltt_time_to_double(time_window
->time_width
)
701 / SCROLL_STEP_PER_PAGE
702 * NANOSECONDS_PER_SECOND
, /* step increment */
704 ltt_time_to_double(time_window
->time_width
)
705 * NANOSECONDS_PER_SECOND
, /* page increment */
707 ltt_time_to_double(time_window
->time_width
)
708 * NANOSECONDS_PER_SECOND
, /* page size */
710 gtk_adjustment_changed(adjustment
);
712 //g_object_set(G_OBJECT(adjustment),
714 // ltt_time_to_double(time_window->start_time)
715 // * NANOSECONDS_PER_SECOND, /* value */
717 /* Note : the set value will call set_time_window if scrollbar value changed
719 gtk_adjustment_set_value(adjustment
,
720 ltt_time_to_double(time_window
->start_time
)
721 * NANOSECONDS_PER_SECOND
);
726 * Function to set the current time/event of the current tab.
727 * It will be called by a viewer's signal handle associated with
728 * the button-release-event signal
729 * @param tab viewer's tab
730 * @param time a pointer where time is stored.
733 void lttvwindow_report_current_time(Tab
*tab
,
736 LttvAttributeValue value
;
738 tab
->current_time
= *time
;
739 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
740 "hooks/updatecurrenttime", LTTV_POINTER
, &value
));
741 tmp
= (LttvHooks
*)*(value
.v_pointer
);
743 if(tmp
== NULL
)return;
744 lttv_hooks_call(tmp
, &tab
->current_time
);
748 * Function to set the position of the hpane's dividor (viewer).
749 * It will be called by a viewer's signal handle associated with
750 * the motion_notify_event event/signal
751 * @param tab viewer's tab
752 * @param position position of the hpane's dividor.
755 void lttvwindow_report_dividor(Tab
*tab
, gint position
)
757 LttvAttributeValue value
;
759 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
760 "hooks/hpanedividor", LTTV_POINTER
, &value
));
761 tmp
= (LttvHooks
*)*(value
.v_pointer
);
762 if(tmp
== NULL
) return;
763 lttv_hooks_call(tmp
, &position
);
767 * Function to set the focused pane (viewer).
768 * It will be called by a viewer's signal handle associated with
769 * the grab_focus signal
770 * @param tab viewer's tab
771 * @param top_widget the top widget containing all the other widgets of the
775 void lttvwindow_report_focus(Tab
*tab
, GtkWidget
*top_widget
)
778 //gtk_multi_vpaned_set_focus(tab->multivpaned,
779 // GTK_PANED(gtk_widget_get_parent(top_widget)));
784 * Function to request data in a specific time interval to the main window. The
785 * event request servicing is differed until the glib idle functions are
788 * The viewer has to provide hooks that should be associated with the event
791 * Either start time or start position must be defined in a EventRequest
792 * structure for it to be valid.
794 * end_time, end_position and num_events can all be defined. The first one
795 * to occur will be used as end criterion.
797 * @param tab viewer's tab
798 * @param events_requested the structure of request from.
801 void lttvwindow_events_request(Tab
*tab
,
802 EventsRequest
*events_request
)
804 tab
->events_requests
= g_slist_append(tab
->events_requests
, events_request
);
806 if(!tab
->events_request_pending
)
808 /* Redraw has +20 priority. We want to let the redraw be done while we do
810 g_idle_add_full((G_PRIORITY_HIGH_IDLE
+ 21),
811 (GSourceFunc
)execute_events_requests
,
814 tab
->events_request_pending
= TRUE
;
820 * Function to remove data requests related to a viewer.
822 * The existing requests's viewer gpointer is compared to the pointer
823 * given in argument to establish which data request should be removed.
825 * @param tab the tab the viewer belongs to.
826 * @param viewer a pointer to the viewer data structure
829 gint
find_viewer (const EventsRequest
*a
, gconstpointer b
)
831 return (a
->owner
!= b
);
835 void lttvwindow_events_request_remove_all(Tab
*tab
,
836 gconstpointer viewer
)
841 g_slist_find_custom(tab
->events_requests
, viewer
,
842 (GCompareFunc
)find_viewer
))
844 EventsRequest
*events_request
= (EventsRequest
*)element
->data
;
845 // Modified so a viewer being destroyed won't have its after_request
846 // called. Not so important anyway. Note that a viewer that call this
847 // remove_all function will not get its after_request called.
848 //if(events_request->servicing == TRUE) {
849 // lttv_hooks_call(events_request->after_request, NULL);
851 g_free(events_request
);
852 tab
->events_requests
= g_slist_remove_link(tab
->events_requests
, element
);
854 if(g_slist_length(tab
->events_requests
) == 0) {
855 tab
->events_request_pending
= FALSE
;
856 g_idle_remove_by_data(tab
);
864 * Function to get the current time interval shown on the current tab.
865 * It will be called by a viewer's hook function to update the
866 * shown time interval of the viewer and also be called by the constructor
868 * @param tab viewer's tab
869 * @return time window.
872 TimeWindow
lttvwindow_get_time_window(Tab
*tab
)
874 return tab
->time_window
;
880 * Function to get the current time/event of the current tab.
881 * It will be called by a viewer's hook function to update the
882 * current time/event of the viewer.
883 * @param tab viewer's tab
887 LttTime
lttvwindow_get_current_time(Tab
*tab
)
889 return tab
->current_time
;
894 * Function to get the filter of the current tab.
895 * It will be called by the constructor of the viewer and also be
896 * called by a hook funtion of the viewer to update its filter.
897 * @param tab viewer's tab
898 * @param filter, a pointer to a filter.
900 const lttv_filter
*lttvwindow_get_filter(Tab
*tab
)
903 g_warning("lttvwindow_get_filter not implemented in viewer.c");
908 * Function to get the stats of the traceset
909 * @param tab viewer's tab
912 LttvTracesetStats
* lttvwindow_get_traceset_stats(Tab
*tab
)
914 return tab
->traceset_info
->traceset_context
;
918 LttvTracesetContext
* lttvwindow_get_traceset_context(Tab
*tab
)
920 return (LttvTracesetContext
*)tab
->traceset_info
->traceset_context
;