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>
46 * Internal function parts
49 extern GSList
* g_main_window_list
;
51 void set_time_window_adjustment(Tab
*tab
, const TimeWindow
* new_time_window
)
53 gtk_multi_vpaned_set_adjust(tab
->multi_vpaned
, new_time_window
, FALSE
);
57 void set_time_window(Tab
*tab
, const TimeWindow
*time_window
)
59 LttvAttributeValue value
;
62 TimeWindowNotifyData time_window_notify_data
;
63 TimeWindow old_time_window
= tab
->time_window
;
64 time_window_notify_data
.old_time_window
= &old_time_window
;
65 tab
->time_window
= *time_window
;
66 time_window_notify_data
.new_time_window
=
69 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
70 "hooks/updatetimewindow", LTTV_POINTER
, &value
));
71 tmp
= (LttvHooks
*)*(value
.v_pointer
);
72 if(tmp
== NULL
) return;
73 lttv_hooks_call(tmp
, &time_window_notify_data
);
78 void add_toolbar_constructor(MainWindow
*mw
, LttvToolbarClosure
*toolbar_c
)
80 LttvIAttribute
*attributes
= mw
->attributes
;
81 LttvAttributeValue value
;
82 LttvToolbars
* instance_toolbar
;
83 lttvwindow_viewer_constructor constructor
;
84 GtkWidget
* tool_menu_title_menu
, *new_widget
, *pixmap
;
87 g_assert(lttv_iattribute_find_by_path(attributes
,
88 "viewers/toolbar", LTTV_POINTER
, &value
));
89 if(*(value
.v_pointer
) == NULL
)
90 *(value
.v_pointer
) = lttv_toolbars_new();
91 instance_toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
93 constructor
= toolbar_c
->con
;
94 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"MToolbar1");
95 pixbuf
= gdk_pixbuf_new_from_xpm_data((const char**)toolbar_c
->pixmap
);
96 pixmap
= gtk_image_new_from_pixbuf(pixbuf
);
98 gtk_toolbar_append_element (GTK_TOOLBAR (tool_menu_title_menu
),
99 GTK_TOOLBAR_CHILD_BUTTON
,
102 toolbar_c
->tooltip
, NULL
,
104 gtk_label_set_use_underline(
105 GTK_LABEL (((GtkToolbarChild
*) (
106 g_list_last (GTK_TOOLBAR
107 (tool_menu_title_menu
)->children
)->data
))->label
),
109 gtk_container_set_border_width (GTK_CONTAINER (new_widget
), 1);
110 g_signal_connect ((gpointer
) new_widget
,
112 G_CALLBACK (insert_viewer_wrap
),
114 gtk_widget_show (new_widget
);
116 lttv_toolbars_add(instance_toolbar
, toolbar_c
->con
,
123 void add_menu_constructor(MainWindow
*mw
, LttvMenuClosure
*menu_c
)
125 LttvIAttribute
*attributes
= mw
->attributes
;
126 LttvAttributeValue value
;
127 LttvToolbars
* instance_menu
;
128 lttvwindow_viewer_constructor constructor
;
129 GtkWidget
* tool_menu_title_menu
, *new_widget
;
131 g_assert(lttv_iattribute_find_by_path(attributes
,
132 "viewers/menu", LTTV_POINTER
, &value
));
133 if(*(value
.v_pointer
) == NULL
)
134 *(value
.v_pointer
) = lttv_menus_new();
135 instance_menu
= (LttvMenus
*)*(value
.v_pointer
);
138 constructor
= menu_c
->con
;
139 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"ToolMenuTitle_menu");
141 gtk_menu_item_new_with_mnemonic (menu_c
->menu_text
);
142 gtk_container_add (GTK_CONTAINER (tool_menu_title_menu
),
144 g_signal_connect ((gpointer
) new_widget
, "activate",
145 G_CALLBACK (insert_viewer_wrap
),
147 gtk_widget_show (new_widget
);
148 lttv_menus_add(instance_menu
, menu_c
->con
,
154 void remove_toolbar_constructor(MainWindow
*mw
, lttvwindow_viewer_constructor viewer_constructor
)
156 LttvIAttribute
*attributes
= mw
->attributes
;
157 LttvAttributeValue value
;
158 LttvToolbars
* instance_toolbar
;
159 lttvwindow_viewer_constructor constructor
;
160 GtkWidget
* tool_menu_title_menu
, *widget
;
162 g_assert(lttv_iattribute_find_by_path(attributes
,
163 "viewers/toolbar", LTTV_POINTER
, &value
));
164 if(*(value
.v_pointer
) == NULL
)
165 *(value
.v_pointer
) = lttv_toolbars_new();
166 instance_toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
168 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"MToolbar1");
169 widget
= lttv_menus_remove(instance_toolbar
, viewer_constructor
);
170 gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu
),
175 void remove_menu_constructor(MainWindow
*mw
, lttvwindow_viewer_constructor viewer_constructor
)
177 LttvIAttribute
*attributes
= mw
->attributes
;
178 LttvAttributeValue value
;
179 LttvMenus
* instance_menu
;
180 lttvwindow_viewer_constructor constructor
;
181 GtkWidget
* tool_menu_title_menu
, *widget
;
182 LttvMenuClosure
*menu_item_i
;
184 g_assert(lttv_iattribute_find_by_path(attributes
,
185 "viewers/menu", LTTV_POINTER
, &value
));
186 if(*(value
.v_pointer
) == NULL
)
187 *(value
.v_pointer
) = lttv_menus_new();
188 instance_menu
= (LttvMenus
*)*(value
.v_pointer
);
190 widget
= lttv_menus_remove(instance_menu
, viewer_constructor
);
191 tool_menu_title_menu
= lookup_widget(mw
->mwindow
,"ToolMenuTitle_menu");
192 gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu
), widget
);
202 * Function to register a view constructor so that main window can generate
203 * a menu item and a toolbar item for the viewer in order to generate a new
204 * instance easily. A menu entry and toolbar item will be added to each main
207 * It should be called by init function of the module.
209 * @param menu_path path of the menu item.
210 * @param menu_text text of the menu item.
211 * @param pixmap Image shown on the toolbar item.
212 * @param tooltip tooltip of the toolbar item.
213 * @param view_constructor constructor of the viewer.
216 void lttvwindow_register_constructor
221 lttvwindow_viewer_constructor view_constructor
)
223 LttvIAttribute
*attributes_global
= LTTV_IATTRIBUTE(lttv_global_attributes());
224 LttvToolbars
* toolbar
;
226 LttvToolbarClosure toolbar_c
;
227 LttvMenuClosure menu_c
;
228 LttvAttributeValue value
;
231 g_assert(lttv_iattribute_find_by_path(attributes_global
,
232 "viewers/toolbar", LTTV_POINTER
, &value
));
233 toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
235 if(toolbar
== NULL
) {
236 toolbar
= lttv_toolbars_new();
237 *(value
.v_pointer
) = toolbar
;
239 toolbar_c
= lttv_toolbars_add(toolbar
, view_constructor
, tooltip
, pixmap
,
242 g_slist_foreach(g_main_window_list
,
243 (gpointer
)add_toolbar_constructor
,
247 if(menu_path
!= NULL
) {
248 g_assert(lttv_iattribute_find_by_path(attributes_global
,
249 "viewers/menu", LTTV_POINTER
, &value
));
250 menu
= (LttvMenus
*)*(value
.v_pointer
);
253 menu
= lttv_menus_new();
254 *(value
.v_pointer
) = menu
;
256 menu_c
= lttv_menus_add(menu
, view_constructor
, menu_path
, menu_text
,NULL
);
258 g_slist_foreach(g_main_window_list
,
259 (gpointer
)add_menu_constructor
,
266 * Function to unregister the viewer's constructor, release the space
267 * occupied by menu_path, menu_text, pixmap, tooltip and constructor of the
270 * It will be called when a module is unloaded.
272 * @param view_constructor constructor of the viewer.
276 void lttvwindow_unregister_constructor
277 (lttvwindow_viewer_constructor view_constructor
)
279 LttvIAttribute
*attributes_global
= LTTV_IATTRIBUTE(lttv_global_attributes());
280 LttvToolbars
* toolbar
;
282 LttvAttributeValue value
;
284 g_assert(lttv_iattribute_find_by_path(attributes_global
,
285 "viewers/toolbar", LTTV_POINTER
, &value
));
286 toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
288 if(toolbar
!= NULL
) {
289 g_slist_foreach(g_main_window_list
,
290 (gpointer
)remove_toolbar_constructor
,
292 lttv_toolbars_remove(toolbar
, view_constructor
);
295 g_assert(lttv_iattribute_find_by_path(attributes_global
,
296 "viewers/menu", LTTV_POINTER
, &value
));
297 menu
= (LttvMenus
*)*(value
.v_pointer
);
300 g_slist_foreach(g_main_window_list
,
301 (gpointer
)remove_menu_constructor
,
303 lttv_menus_remove(menu
, view_constructor
);
309 * Function to register a hook function for a viewer to set/update its
311 * @param tab viewer's tab
312 * @param hook hook function of the viewer.
313 * @param hook_data hook data associated with the hook function.
315 void lttvwindow_register_time_window_notify(Tab
*tab
,
316 LttvHook hook
, gpointer hook_data
)
318 LttvAttributeValue value
;
320 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
321 "hooks/updatetimewindow", LTTV_POINTER
, &value
));
322 tmp
= (LttvHooks
*)*(value
.v_pointer
);
324 tmp
= lttv_hooks_new();
325 *(value
.v_pointer
) = tmp
;
327 lttv_hooks_add(tmp
, hook
,hook_data
, LTTV_PRIO_DEFAULT
);
332 * Function to unregister a viewer's hook function which is used to
333 * set/update the time interval of the viewer.
334 * @param tab viewer's tab
335 * @param hook hook function of the viewer.
336 * @param hook_data hook data associated with the hook function.
339 void lttvwindow_unregister_time_window_notify(Tab
*tab
,
340 LttvHook hook
, gpointer hook_data
)
342 LttvAttributeValue value
;
344 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
345 "hooks/updatetimewindow", LTTV_POINTER
, &value
));
346 tmp
= (LttvHooks
*)*(value
.v_pointer
);
347 if(tmp
== NULL
) return;
348 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
352 * Function to register a hook function for a viewer to set/update its
354 * @param tab viewer's tab
355 * @param hook hook function of the viewer.
356 * @param hook_data hook data associated with the hook function.
359 void lttvwindow_register_traceset_notify(Tab
*tab
,
360 LttvHook hook
, gpointer hook_data
)
362 LttvAttributeValue value
;
364 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
365 "hooks/updatetraceset", LTTV_POINTER
, &value
));
366 tmp
= (LttvHooks
*)*(value
.v_pointer
);
368 tmp
= lttv_hooks_new();
369 *(value
.v_pointer
) = tmp
;
371 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
376 * Function to unregister a viewer's hook function which is used to
377 * set/update the traceset of the viewer.
378 * @param tab viewer's tab
379 * @param hook hook function of the viewer.
380 * @param hook_data hook data associated with the hook function.
383 void lttvwindow_unregister_traceset_notify(Tab
*tab
,
384 LttvHook hook
, gpointer hook_data
)
386 LttvAttributeValue value
;
388 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
389 "hooks/updatetraceset", LTTV_POINTER
, &value
));
390 tmp
= (LttvHooks
*)*(value
.v_pointer
);
391 if(tmp
== NULL
) return;
392 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
396 * Function to register a hook function for a viewer be completely redrawn.
398 * @param tab viewer's tab
399 * @param hook hook function of the viewer.
400 * @param hook_data hook data associated with the hook function.
403 void lttvwindow_register_redraw_notify(Tab
*tab
,
404 LttvHook hook
, gpointer hook_data
)
406 LttvAttributeValue value
;
408 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
409 "hooks/redraw", LTTV_POINTER
, &value
));
410 tmp
= (LttvHooks
*)*(value
.v_pointer
);
412 tmp
= lttv_hooks_new();
413 *(value
.v_pointer
) = tmp
;
415 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
420 * Function to unregister a hook function for a viewer be completely redrawn.
422 * @param tab viewer's tab
423 * @param hook hook function of the viewer.
424 * @param hook_data hook data associated with the hook function.
427 void lttvwindow_unregister_redraw_notify(Tab
*tab
,
428 LttvHook hook
, gpointer hook_data
)
430 LttvAttributeValue value
;
432 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
433 "hooks/redraw", LTTV_POINTER
, &value
));
434 tmp
= (LttvHooks
*)*(value
.v_pointer
);
435 if(tmp
== NULL
) return;
436 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
440 * Function to register a hook function for a viewer to re-do the events
441 * requests for the needed interval.
443 * This action is typically done after a "stop".
445 * The typical hook will remove all current requests for the viewer
446 * and make requests for missing information.
448 * @param tab viewer's tab
449 * @param hook hook function of the viewer.
450 * @param hook_data hook data associated with the hook function.
453 void lttvwindow_register_continue_notify(Tab
*tab
,
454 LttvHook hook
, gpointer hook_data
)
456 LttvAttributeValue value
;
458 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
459 "hooks/continue", LTTV_POINTER
, &value
));
460 tmp
= (LttvHooks
*)*(value
.v_pointer
);
462 tmp
= lttv_hooks_new();
463 *(value
.v_pointer
) = tmp
;
465 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
470 * Function to unregister a hook function for a viewer to re-do the events
471 * requests for the needed interval.
473 * @param tab viewer's tab
474 * @param hook hook function of the viewer.
475 * @param hook_data hook data associated with the hook function.
478 void lttvwindow_unregister_continue_notify(Tab
*tab
,
479 LttvHook hook
, gpointer hook_data
)
481 LttvAttributeValue value
;
483 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
484 "hooks/continue", LTTV_POINTER
, &value
));
485 tmp
= (LttvHooks
*)*(value
.v_pointer
);
486 if(tmp
== NULL
) return;
487 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
492 * Function to register a hook function for a viewer to set/update its
494 * @param tab viewer's tab
495 * @param hook hook function of the viewer.
496 * @param hook_data hook data associated with the hook function.
499 void lttvwindow_register_filter_notify(Tab
*tab
,
500 LttvHook hook
, gpointer hook_data
)
502 LttvAttributeValue value
;
504 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
505 "hooks/updatefilter", LTTV_POINTER
, &value
));
506 tmp
= (LttvHooks
*)*(value
.v_pointer
);
508 tmp
= lttv_hooks_new();
509 *(value
.v_pointer
) = tmp
;
511 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
516 * Function to unregister a viewer's hook function which is used to
517 * set/update the filter of the viewer.
518 * @param tab viewer's tab
519 * @param hook hook function of the viewer.
520 * @param hook_data hook data associated with the hook function.
523 void lttvwindow_unregister_filter_notify(Tab
*tab
,
527 LttvAttributeValue value
;
529 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
530 "hooks/updatefilter", LTTV_POINTER
, &value
));
531 tmp
= (LttvHooks
*)*(value
.v_pointer
);
532 if(tmp
== NULL
) return;
533 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
537 * Function to register a hook function for a viewer to set/update its
539 * @param tab viewer's tab
540 * @param hook hook function of the viewer.
541 * @param hook_data hook data associated with the hook function.
544 void lttvwindow_register_current_time_notify(Tab
*tab
,
545 LttvHook hook
, gpointer hook_data
)
547 LttvAttributeValue value
;
549 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
550 "hooks/updatecurrenttime", LTTV_POINTER
, &value
));
551 tmp
= (LttvHooks
*)*(value
.v_pointer
);
553 tmp
= lttv_hooks_new();
554 *(value
.v_pointer
) = tmp
;
556 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
561 * Function to unregister a viewer's hook function which is used to
562 * set/update the current time of the viewer.
563 * @param tab viewer's tab
564 * @param hook hook function of the viewer.
565 * @param hook_data hook data associated with the hook function.
568 void lttvwindow_unregister_current_time_notify(Tab
*tab
,
569 LttvHook hook
, gpointer hook_data
)
571 LttvAttributeValue value
;
573 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
574 "hooks/updatecurrenttime", LTTV_POINTER
, &value
));
575 tmp
= (LttvHooks
*)*(value
.v_pointer
);
576 if(tmp
== NULL
) return;
577 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
582 * Function to register a hook function for a viewer to show
583 * the content of the viewer.
584 * @param tab viewer's tab
585 * @param hook hook function of the viewer.
586 * @param hook_data hook data associated with the hook function.
589 void lttvwindow_register_show_notify(Tab
*tab
,
590 LttvHook hook
, gpointer hook_data
)
592 LttvAttributeValue value
;
594 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
595 "hooks/showviewer", LTTV_POINTER
, &value
));
596 tmp
= (LttvHooks
*)*(value
.v_pointer
);
598 tmp
= lttv_hooks_new();
599 *(value
.v_pointer
) = tmp
;
601 lttv_hooks_add(tmp
, hook
, hook_data
, LTTV_PRIO_DEFAULT
);
606 * Function to unregister a viewer's hook function which is used to
607 * show the content of the viewer..
608 * @param tab viewer's tab
609 * @param hook hook function of the viewer.
610 * @param hook_data hook data associated with the hook function.
613 void lttvwindow_unregister_show_notify(Tab
*tab
,
614 LttvHook hook
, gpointer hook_data
)
616 LttvAttributeValue value
;
618 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
619 "hooks/showviewer", 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 the
627 * dividor of the hpane.
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_dividor(Tab
*tab
,
634 LttvHook hook
, gpointer hook_data
)
636 LttvAttributeValue value
;
638 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
639 "hooks/hpanedividor", 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 hpane's dividor of the viewer.
652 * It will be called by the destructor of the viewer.
653 * @param tab viewer's tab
654 * @param hook hook function of the viewer.
655 * @param hook_data hook data associated with the hook function.
658 void lttvwindow_unregister_dividor(Tab
*tab
,
659 LttvHook hook
, gpointer hook_data
)
661 LttvAttributeValue value
;
663 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
664 "hooks/hpanedividor", LTTV_POINTER
, &value
));
665 tmp
= (LttvHooks
*)*(value
.v_pointer
);
666 if(tmp
== NULL
) return;
667 lttv_hooks_remove_data(tmp
, hook
, hook_data
);
672 * Update the status bar whenever something changed in the viewer.
673 * @param tab viewer's tab
674 * @param info the message which will be shown in the status bar.
677 void lttvwindow_report_status(Tab
*tab
, const char *info
)
680 g_warning("update_status not implemented in viewer.c");
681 // Use tab->mw for status
685 * Function to set the time interval of the current tab.
686 * It will be called by a viewer's signal handle associated with
687 * the move_slider signal
688 * @param tab viewer's tab
689 * @param time_interval a pointer where time interval is stored.
692 void lttvwindow_report_time_window(Tab
*tab
,
693 const TimeWindow
*time_window
)
695 set_time_window(tab
, time_window
);
696 set_time_window_adjustment(tab
, time_window
);
701 * Function to set the current time/event of the current tab.
702 * It will be called by a viewer's signal handle associated with
703 * the button-release-event signal
704 * @param tab viewer's tab
705 * @param time a pointer where time is stored.
708 void lttvwindow_report_current_time(Tab
*tab
,
711 LttvAttributeValue value
;
713 tab
->current_time
= *time
;
714 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
715 "hooks/updatecurrenttime", LTTV_POINTER
, &value
));
716 tmp
= (LttvHooks
*)*(value
.v_pointer
);
718 if(tmp
== NULL
)return;
719 lttv_hooks_call(tmp
, &tab
->current_time
);
723 * Function to set the position of the hpane's dividor (viewer).
724 * It will be called by a viewer's signal handle associated with
725 * the motion_notify_event event/signal
726 * @param tab viewer's tab
727 * @param position position of the hpane's dividor.
730 void lttvwindow_report_dividor(Tab
*tab
, gint position
)
732 LttvAttributeValue value
;
734 g_assert(lttv_iattribute_find_by_path(tab
->attributes
,
735 "hooks/hpanedividor", LTTV_POINTER
, &value
));
736 tmp
= (LttvHooks
*)*(value
.v_pointer
);
737 if(tmp
== NULL
) return;
738 lttv_hooks_call(tmp
, &position
);
742 * Function to set the focused pane (viewer).
743 * It will be called by a viewer's signal handle associated with
744 * the grab_focus signal
745 * @param tab viewer's tab
746 * @param top_widget the top widget containing all the other widgets of the
750 void lttvwindow_report_focus(Tab
*tab
, GtkWidget
*top_widget
)
752 gtk_multi_vpaned_set_focus((GtkWidget
*)tab
->multi_vpaned
,
753 GTK_PANED(gtk_widget_get_parent(top_widget
)));
758 * Function to request data in a specific time interval to the main window. The
759 * event request servicing is differed until the glib idle functions are
762 * The viewer has to provide hooks that should be associated with the event
765 * Either start time or start position must be defined in a EventRequest
766 * structure for it to be valid.
768 * end_time, end_position and num_events can all be defined. The first one
769 * to occur will be used as end criterion.
771 * @param tab viewer's tab
772 * @param events_requested the structure of request from.
775 void lttvwindow_events_request(Tab
*tab
,
776 EventsRequest
*events_request
)
778 tab
->events_requests
= g_slist_append(tab
->events_requests
, events_request
);
780 if(!tab
->events_request_pending
)
782 /* Redraw has +20 priority. We want to let the redraw be done while we do
784 g_idle_add_full((G_PRIORITY_HIGH_IDLE
+ 21),
785 (GSourceFunc
)execute_events_requests
,
788 tab
->events_request_pending
= TRUE
;
794 * Function to remove data requests related to a viewer.
796 * The existing requests's viewer gpointer is compared to the pointer
797 * given in argument to establish which data request should be removed.
799 * @param tab the tab the viewer belongs to.
800 * @param viewer a pointer to the viewer data structure
803 gint
find_viewer (const EventsRequest
*a
, gconstpointer b
)
805 return (a
->owner
!= b
);
809 void lttvwindow_events_request_remove_all(Tab
*tab
,
810 gconstpointer viewer
)
815 g_slist_find_custom(tab
->events_requests
, viewer
,
816 (GCompareFunc
)find_viewer
))
818 EventsRequest
*events_request
= (EventsRequest
*)element
->data
;
819 if(events_request
->servicing
== TRUE
) {
820 lttv_hooks_call(events_request
->after_request
, NULL
);
822 g_free(events_request
);
823 tab
->events_requests
= g_slist_remove_link(tab
->events_requests
, element
);
831 * Function to get the current time interval shown on the current tab.
832 * It will be called by a viewer's hook function to update the
833 * shown time interval of the viewer and also be called by the constructor
835 * @param tab viewer's tab
836 * @return time window.
839 TimeWindow
lttvwindow_get_time_window(Tab
*tab
)
841 return tab
->time_window
;
847 * Function to get the current time/event of the current tab.
848 * It will be called by a viewer's hook function to update the
849 * current time/event of the viewer.
850 * @param tab viewer's tab
854 LttTime
lttvwindow_get_current_time(Tab
*tab
)
856 return tab
->current_time
;
861 * Function to get the filter of the current tab.
862 * It will be called by the constructor of the viewer and also be
863 * called by a hook funtion of the viewer to update its filter.
864 * @param tab viewer's tab
865 * @param filter, a pointer to a filter.
867 const lttv_filter
*lttvwindow_get_filter(Tab
*tab
)
870 g_warning("lttvwindow_get_filter not implemented in viewer.c");
875 * Function to get the stats of the traceset
876 * @param tab viewer's tab
879 LttvTracesetStats
* lttvwindow_get_traceset_stats(Tab
*tab
)
881 return tab
->traceset_info
->traceset_context
;
885 LttvTracesetContext
* lttvwindow_get_traceset_context(Tab
*tab
)
887 return (LttvTracesetContext
*)tab
->traceset_info
->traceset_context
;