added API for calculators (module which calculate trace information)
[lttv.git] / ltt / branches / poly / lttv / modules / gui / lttvwindow / lttvwindow / lttvwindow.c
CommitLineData
501e4e70 1/* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 XangXiu Yang
3 *
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;
7 *
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.
12 *
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,
16 * MA 02111-1307, USA.
17 */
18
19/*! \file lttvwindow.c
20 * \brief API used by the graphical viewers to interact with their tab.
21 *
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
27 * main window.
28 *
29 */
30
31#include <ltt/ltt.h>
32#include <lttv/lttv.h>
33#include <lttv/state.h>
34#include <lttv/stats.h>
35#include <lttv/tracecontext.h>
501e4e70 36#include <lttvwindow/mainwindow.h>
2d262115 37#include <lttvwindow/mainwindow-private.h>
501e4e70 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>
43
44
45/**
46 * Internal function parts
47 */
48
49extern GSList * g_main_window_list;
50
51/**
52 * Function to set/update traceset for the viewers
53 * @param tab viewer's tab
54 * @param traceset traceset of the main window.
55 * return value :
56 * -1 : error
57 * 0 : traceset updated
58 * 1 : no traceset hooks to update; not an error.
59 */
60
2d262115 61int SetTraceset(Tab * tab, LttvTraceset *traceset)
501e4e70 62{
63 LttvHooks * tmp;
64 LttvAttributeValue value;
65
66 if( lttv_iattribute_find_by_path(tab->attributes,
67 "hooks/updatetraceset", LTTV_POINTER, &value) != 0)
68 return -1;
69
70 tmp = (LttvHooks*)*(value.v_pointer);
71 if(tmp == NULL) return 1;
72
73
74 lttv_hooks_call(tmp,traceset);
75
76 return 0;
77}
78
79
80/**
81 * Function to set/update filter for the viewers
82 * @param tab viewer's tab
83 * @param filter filter of the main window.
84 * return value :
85 * -1 : error
86 * 0 : filters updated
87 * 1 : no filter hooks to update; not an error.
88 */
89
90int SetFilter(Tab * tab, gpointer filter)
91{
92 LttvHooks * tmp;
93 LttvAttributeValue value;
94
95 if(lttv_iattribute_find_by_path(tab->attributes,
96 "hooks/updatefilter", LTTV_POINTER, &value) != 0)
97 return -1;
98
99 tmp = (LttvHooks*)*(value.v_pointer);
100
101 if(tmp == NULL) return 1;
102 lttv_hooks_call(tmp,filter);
103
104 return 0;
105}
106
107/**
108 * Function to redraw each viewer belonging to the current tab
109 * @param tab viewer's tab
110 */
111
112void update_traceset(Tab *tab)
113{
114 LttvAttributeValue value;
115 LttvHooks * tmp;
116 g_assert(lttv_iattribute_find_by_path(tab->attributes,
117 "hooks/updatetraceset", LTTV_POINTER, &value));
118 tmp = (LttvHooks*)*(value.v_pointer);
119 if(tmp == NULL) return;
120 lttv_hooks_call(tmp, NULL);
121}
122
123void set_time_window_adjustment(Tab *tab, const TimeWindow* new_time_window)
124{
125 gtk_multi_vpaned_set_adjust(tab->multi_vpaned, new_time_window, FALSE);
126}
127
128
129void set_time_window(Tab *tab, const TimeWindow *time_window)
130{
131 LttvAttributeValue value;
132 LttvHooks * tmp;
133
134 TimeWindowNotifyData time_window_notify_data;
135 TimeWindow old_time_window = tab->time_window;
136 time_window_notify_data.old_time_window = &old_time_window;
137 tab->time_window = *time_window;
138 time_window_notify_data.new_time_window =
139 &(tab->time_window);
140
141 g_assert(lttv_iattribute_find_by_path(tab->attributes,
142 "hooks/updatetimewindow", LTTV_POINTER, &value));
143 tmp = (LttvHooks*)*(value.v_pointer);
144 if(tmp == NULL) return;
145 lttv_hooks_call(tmp, &time_window_notify_data);
146
147
148}
149
150void add_toolbar_constructor(MainWindow *mw, LttvToolbarClosure *toolbar_c)
151{
152 LttvIAttribute *attributes = mw->attributes;
153 LttvAttributeValue value;
154 LttvToolbars * instance_toolbar;
155 lttvwindow_viewer_constructor constructor;
156 GtkWidget * tool_menu_title_menu, *new_widget, *pixmap;
157 GdkPixbuf *pixbuf;
158
159 g_assert(lttv_iattribute_find_by_path(attributes,
160 "viewers/toolbar", LTTV_POINTER, &value));
161 if(*(value.v_pointer) == NULL)
162 *(value.v_pointer) = lttv_toolbars_new();
163 instance_toolbar = (LttvToolbars*)*(value.v_pointer);
164
165 constructor = toolbar_c->con;
166 tool_menu_title_menu = lookup_widget(mw->mwindow,"MToolbar1");
167 pixbuf = gdk_pixbuf_new_from_xpm_data((const char**)toolbar_c->pixmap);
168 pixmap = gtk_image_new_from_pixbuf(pixbuf);
169 new_widget =
170 gtk_toolbar_append_element (GTK_TOOLBAR (tool_menu_title_menu),
171 GTK_TOOLBAR_CHILD_BUTTON,
172 NULL,
173 "",
174 toolbar_c->tooltip, NULL,
175 pixmap, NULL, NULL);
176 gtk_label_set_use_underline(
177 GTK_LABEL (((GtkToolbarChild*) (
178 g_list_last (GTK_TOOLBAR
179 (tool_menu_title_menu)->children)->data))->label),
180 TRUE);
181 gtk_container_set_border_width (GTK_CONTAINER (new_widget), 1);
182 g_signal_connect ((gpointer) new_widget,
183 "clicked",
184 G_CALLBACK (insert_viewer_wrap),
185 constructor);
186 gtk_widget_show (new_widget);
187
188 lttv_toolbars_add(instance_toolbar, toolbar_c->con,
189 toolbar_c->tooltip,
190 toolbar_c->pixmap,
191 new_widget);
192
193}
194
195void add_menu_constructor(MainWindow *mw, LttvMenuClosure *menu_c)
196{
197 LttvIAttribute *attributes = mw->attributes;
198 LttvAttributeValue value;
199 LttvToolbars * instance_menu;
200 lttvwindow_viewer_constructor constructor;
201 GtkWidget * tool_menu_title_menu, *new_widget;
202
203 g_assert(lttv_iattribute_find_by_path(attributes,
204 "viewers/menu", LTTV_POINTER, &value));
205 if(*(value.v_pointer) == NULL)
206 *(value.v_pointer) = lttv_menus_new();
207 instance_menu = (LttvMenus*)*(value.v_pointer);
208
209
210 constructor = menu_c->con;
211 tool_menu_title_menu = lookup_widget(mw->mwindow,"ToolMenuTitle_menu");
212 new_widget =
213 gtk_menu_item_new_with_mnemonic (menu_c->menu_text);
214 gtk_container_add (GTK_CONTAINER (tool_menu_title_menu),
215 new_widget);
216 g_signal_connect ((gpointer) new_widget, "activate",
217 G_CALLBACK (insert_viewer_wrap),
218 constructor);
219 gtk_widget_show (new_widget);
220 lttv_menus_add(instance_menu, menu_c->con,
221 menu_c->menu_path,
222 menu_c->menu_text,
223 new_widget);
224}
225
226void remove_toolbar_constructor(MainWindow *mw, lttvwindow_viewer_constructor viewer_constructor)
227{
228 LttvIAttribute *attributes = mw->attributes;
229 LttvAttributeValue value;
230 LttvToolbars * instance_toolbar;
231 lttvwindow_viewer_constructor constructor;
232 GtkWidget * tool_menu_title_menu, *widget;
233
234 g_assert(lttv_iattribute_find_by_path(attributes,
235 "viewers/toolbar", LTTV_POINTER, &value));
236 if(*(value.v_pointer) == NULL)
237 *(value.v_pointer) = lttv_toolbars_new();
238 instance_toolbar = (LttvToolbars*)*(value.v_pointer);
239
240 tool_menu_title_menu = lookup_widget(mw->mwindow,"MToolbar1");
241 widget = lttv_menus_remove(instance_toolbar, viewer_constructor);
242 gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu),
243 widget);
244}
245
246
247void remove_menu_constructor(MainWindow *mw, lttvwindow_viewer_constructor viewer_constructor)
248{
249 LttvIAttribute *attributes = mw->attributes;
250 LttvAttributeValue value;
251 LttvMenus * instance_menu;
252 lttvwindow_viewer_constructor constructor;
253 GtkWidget * tool_menu_title_menu, *widget;
254 LttvMenuClosure *menu_item_i;
255
256 g_assert(lttv_iattribute_find_by_path(attributes,
257 "viewers/menu", LTTV_POINTER, &value));
258 if(*(value.v_pointer) == NULL)
259 *(value.v_pointer) = lttv_menus_new();
260 instance_menu = (LttvMenus*)*(value.v_pointer);
261
262 widget = lttv_menus_remove(instance_menu, viewer_constructor);
263 tool_menu_title_menu = lookup_widget(mw->mwindow,"ToolMenuTitle_menu");
264 gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu), widget);
265}
266
267
268/**
269 * API parts
270 */
271
272
273/**
274 * Function to register a view constructor so that main window can generate
275 * a menu item and a toolbar item for the viewer in order to generate a new
276 * instance easily. A menu entry and toolbar item will be added to each main
277 * window.
278 *
279 * It should be called by init function of the module.
280 *
281 * @param menu_path path of the menu item.
282 * @param menu_text text of the menu item.
283 * @param pixmap Image shown on the toolbar item.
284 * @param tooltip tooltip of the toolbar item.
285 * @param view_constructor constructor of the viewer.
286 */
287
288void lttvwindow_register_constructor
289 (char * menu_path,
290 char * menu_text,
291 char ** pixmap,
292 char * tooltip,
293 lttvwindow_viewer_constructor view_constructor)
294{
295 LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes());
296 LttvToolbars * toolbar;
297 LttvMenus * menu;
298 LttvToolbarClosure toolbar_c;
299 LttvMenuClosure menu_c;
300 LttvAttributeValue value;
301
302 if(pixmap != NULL) {
303 g_assert(lttv_iattribute_find_by_path(attributes_global,
304 "viewers/toolbar", LTTV_POINTER, &value));
305 toolbar = (LttvToolbars*)*(value.v_pointer);
306
307 if(toolbar == NULL) {
308 toolbar = lttv_toolbars_new();
309 *(value.v_pointer) = toolbar;
310 }
311 toolbar_c = lttv_toolbars_add(toolbar, view_constructor, tooltip, pixmap,
312 NULL);
313
314 g_slist_foreach(g_main_window_list,
315 (gpointer)add_toolbar_constructor,
316 &toolbar_c);
317 }
318
319 if(menu_path != NULL) {
320 g_assert(lttv_iattribute_find_by_path(attributes_global,
321 "viewers/menu", LTTV_POINTER, &value));
322 menu = (LttvMenus*)*(value.v_pointer);
323
324 if(menu == NULL) {
325 menu = lttv_menus_new();
326 *(value.v_pointer) = menu;
327 }
328 menu_c = lttv_menus_add(menu, view_constructor, menu_path, menu_text,NULL);
329
330 g_slist_foreach(g_main_window_list,
331 (gpointer)add_menu_constructor,
332 &menu_c);
333 }
334}
335
336
337/**
338 * Function to unregister the viewer's constructor, release the space
339 * occupied by menu_path, menu_text, pixmap, tooltip and constructor of the
340 * viewer.
341 *
342 * It will be called when a module is unloaded.
343 *
344 * @param view_constructor constructor of the viewer.
345 */
346
347
348void lttvwindow_unregister_constructor
349 (lttvwindow_viewer_constructor view_constructor)
350{
351 LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes());
352 LttvToolbars * toolbar;
353 LttvMenus * menu;
354 LttvAttributeValue value;
355
356 g_assert(lttv_iattribute_find_by_path(attributes_global,
357 "viewers/toolbar", LTTV_POINTER, &value));
358 toolbar = (LttvToolbars*)*(value.v_pointer);
359
360 if(toolbar != NULL) {
361 g_slist_foreach(g_main_window_list,
362 (gpointer)remove_toolbar_constructor,
363 view_constructor);
364 lttv_toolbars_remove(toolbar, view_constructor);
365 }
366
367 g_assert(lttv_iattribute_find_by_path(attributes_global,
368 "viewers/menu", LTTV_POINTER, &value));
369 menu = (LttvMenus*)*(value.v_pointer);
370
371 if(menu != NULL) {
372 g_slist_foreach(g_main_window_list,
373 (gpointer)remove_menu_constructor,
374 view_constructor);
375 lttv_menus_remove(menu, view_constructor);
376 }
377}
378
379
380/**
381 * Function to register a hook function for a viewer to set/update its
382 * time interval.
383 * @param tab viewer's tab
384 * @param hook hook function of the viewer.
385 * @param hook_data hook data associated with the hook function.
386 */
387void lttvwindow_register_time_window_notify(Tab *tab,
388 LttvHook hook, gpointer hook_data)
389{
390 LttvAttributeValue value;
391 LttvHooks * tmp;
392 g_assert(lttv_iattribute_find_by_path(tab->attributes,
393 "hooks/updatetimewindow", LTTV_POINTER, &value));
394 tmp = (LttvHooks*)*(value.v_pointer);
395 if(tmp == NULL){
396 tmp = lttv_hooks_new();
397 *(value.v_pointer) = tmp;
398 }
399 lttv_hooks_add(tmp, hook,hook_data, LTTV_PRIO_DEFAULT);
400}
401
402
403/**
404 * Function to unregister a viewer's hook function which is used to
405 * set/update the time interval of the viewer.
406 * @param tab viewer's tab
407 * @param hook hook function of the viewer.
408 * @param hook_data hook data associated with the hook function.
409 */
410
411void lttvwindow_unregister_time_window_notify(Tab *tab,
412 LttvHook hook, gpointer hook_data)
413{
414 LttvAttributeValue value;
415 LttvHooks * tmp;
416 g_assert(lttv_iattribute_find_by_path(tab->attributes,
417 "hooks/updatetimewindow", LTTV_POINTER, &value));
418 tmp = (LttvHooks*)*(value.v_pointer);
419 if(tmp == NULL) return;
420 lttv_hooks_remove_data(tmp, hook, hook_data);
421}
422
423/**
424 * Function to register a hook function for a viewer to set/update its
425 * traceset.
426 * @param tab viewer's tab
427 * @param hook hook function of the viewer.
428 * @param hook_data hook data associated with the hook function.
429 */
430
431void lttvwindow_register_traceset_notify(Tab *tab,
432 LttvHook hook, gpointer hook_data)
433{
434 LttvAttributeValue value;
435 LttvHooks * tmp;
436 g_assert(lttv_iattribute_find_by_path(tab->attributes,
437 "hooks/updatetraceset", LTTV_POINTER, &value));
438 tmp = (LttvHooks*)*(value.v_pointer);
439 if(tmp == NULL){
440 tmp = lttv_hooks_new();
441 *(value.v_pointer) = tmp;
442 }
443 lttv_hooks_add(tmp, hook, hook_data, LTTV_PRIO_DEFAULT);
444}
445
446
447/**
448 * Function to unregister a viewer's hook function which is used to
449 * set/update the traceset of the viewer.
450 * @param tab viewer's tab
451 * @param hook hook function of the viewer.
452 * @param hook_data hook data associated with the hook function.
453 */
454
455void lttvwindow_unregister_traceset_notify(Tab *tab,
456 LttvHook hook, gpointer hook_data)
457{
458 LttvAttributeValue value;
459 LttvHooks * tmp;
460 g_assert(lttv_iattribute_find_by_path(tab->attributes,
461 "hooks/updatetraceset", LTTV_POINTER, &value));
462 tmp = (LttvHooks*)*(value.v_pointer);
463 if(tmp == NULL) return;
464 lttv_hooks_remove_data(tmp, hook, hook_data);
465}
466
467/**
468 * Function to register a hook function for a viewer to set/update its
469 * filter.
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.
473 */
474
475void lttvwindow_register_filter_notify(Tab *tab,
476 LttvHook hook, gpointer hook_data)
477{
478 LttvAttributeValue value;
479 LttvHooks * tmp;
480 g_assert(lttv_iattribute_find_by_path(tab->attributes,
481 "hooks/updatefilter", LTTV_POINTER, &value));
482 tmp = (LttvHooks*)*(value.v_pointer);
483 if(tmp == NULL){
484 tmp = lttv_hooks_new();
485 *(value.v_pointer) = tmp;
486 }
487 lttv_hooks_add(tmp, hook, hook_data, LTTV_PRIO_DEFAULT);
488}
489
490
491/**
492 * Function to unregister a viewer's hook function which is used to
493 * set/update the filter of the viewer.
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.
497 */
498
499void lttvwindow_unregister_filter_notify(Tab *tab,
500 LttvHook hook,
501 gpointer hook_data)
502{
503 LttvAttributeValue value;
504 LttvHooks * tmp;
505 g_assert(lttv_iattribute_find_by_path(tab->attributes,
506 "hooks/updatefilter", LTTV_POINTER, &value));
507 tmp = (LttvHooks*)*(value.v_pointer);
508 if(tmp == NULL) return;
509 lttv_hooks_remove_data(tmp, hook, hook_data);
510}
511
512/**
513 * Function to register a hook function for a viewer to set/update its
514 * current time.
515 * @param tab viewer's tab
516 * @param hook hook function of the viewer.
517 * @param hook_data hook data associated with the hook function.
518 */
519
520void lttvwindow_register_current_time_notify(Tab *tab,
521 LttvHook hook, gpointer hook_data)
522{
523 LttvAttributeValue value;
524 LttvHooks * tmp;
525 g_assert(lttv_iattribute_find_by_path(tab->attributes,
526 "hooks/updatecurrenttime", LTTV_POINTER, &value));
527 tmp = (LttvHooks*)*(value.v_pointer);
528 if(tmp == NULL){
529 tmp = lttv_hooks_new();
530 *(value.v_pointer) = tmp;
531 }
532 lttv_hooks_add(tmp, hook, hook_data, LTTV_PRIO_DEFAULT);
533}
534
535
536/**
537 * Function to unregister a viewer's hook function which is used to
538 * set/update the current time of the viewer.
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.
542 */
543
544void lttvwindow_unregister_current_time_notify(Tab *tab,
545 LttvHook hook, gpointer hook_data)
546{
547 LttvAttributeValue value;
548 LttvHooks * tmp;
549 g_assert(lttv_iattribute_find_by_path(tab->attributes,
550 "hooks/updatecurrenttime", LTTV_POINTER, &value));
551 tmp = (LttvHooks*)*(value.v_pointer);
552 if(tmp == NULL) return;
553 lttv_hooks_remove_data(tmp, hook, hook_data);
554}
555
556
557/**
558 * Function to register a hook function for a viewer to show
559 * the content of the viewer.
560 * @param tab viewer's tab
561 * @param hook hook function of the viewer.
562 * @param hook_data hook data associated with the hook function.
563 */
564
565void lttvwindow_register_show_notify(Tab *tab,
566 LttvHook hook, gpointer hook_data)
567{
568 LttvAttributeValue value;
569 LttvHooks * tmp;
570 g_assert(lttv_iattribute_find_by_path(tab->attributes,
571 "hooks/showviewer", LTTV_POINTER, &value));
572 tmp = (LttvHooks*)*(value.v_pointer);
573 if(tmp == NULL){
574 tmp = lttv_hooks_new();
575 *(value.v_pointer) = tmp;
576 }
577 lttv_hooks_add(tmp, hook, hook_data, LTTV_PRIO_DEFAULT);
578}
579
580
581/**
582 * Function to unregister a viewer's hook function which is used to
583 * show 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.
587 */
588
589void lttvwindow_unregister_show_notify(Tab *tab,
590 LttvHook hook, gpointer hook_data)
591{
592 LttvAttributeValue value;
593 LttvHooks * tmp;
594 g_assert(lttv_iattribute_find_by_path(tab->attributes,
595 "hooks/showviewer", LTTV_POINTER, &value));
596 tmp = (LttvHooks*)*(value.v_pointer);
597 if(tmp == NULL) return;
598 lttv_hooks_remove_data(tmp, hook, hook_data);
599}
600
601/**
602 * Function to register a hook function for a viewer to set/update the
603 * dividor of the hpane.
604 * @param tab viewer's tab
605 * @param hook hook function of the viewer.
606 * @param hook_data hook data associated with the hook function.
607 */
608
609void lttvwindow_register_dividor(Tab *tab,
610 LttvHook hook, gpointer hook_data)
611{
612 LttvAttributeValue value;
613 LttvHooks * tmp;
614 g_assert(lttv_iattribute_find_by_path(tab->attributes,
615 "hooks/hpanedividor", LTTV_POINTER, &value));
616 tmp = (LttvHooks*)*(value.v_pointer);
617 if(tmp == NULL){
618 tmp = lttv_hooks_new();
619 *(value.v_pointer) = tmp;
620 }
621 lttv_hooks_add(tmp, hook, hook_data, LTTV_PRIO_DEFAULT);
622}
623
624
625/**
626 * Function to unregister a viewer's hook function which is used to
627 * set/update hpane's dividor of the viewer.
628 * It will be called by the destructor of the viewer.
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.
632 */
633
634void lttvwindow_unregister_dividor(Tab *tab,
635 LttvHook hook, gpointer hook_data)
636{
637 LttvAttributeValue value;
638 LttvHooks * tmp;
639 g_assert(lttv_iattribute_find_by_path(tab->attributes,
640 "hooks/hpanedividor", LTTV_POINTER, &value));
641 tmp = (LttvHooks*)*(value.v_pointer);
642 if(tmp == NULL) return;
643 lttv_hooks_remove_data(tmp, hook, hook_data);
644}
645
646
647/**
648 * Update the status bar whenever something changed in the viewer.
649 * @param tab viewer's tab
650 * @param info the message which will be shown in the status bar.
651 */
652
653void lttvwindow_report_status(Tab *tab, const char *info)
654{
655 //FIXME
656 g_warning("update_status not implemented in viewer.c");
657 // Use tab->mw for status
658}
659
660/**
661 * Function to set the time interval of the current tab.
662 * It will be called by a viewer's signal handle associated with
663 * the move_slider signal
664 * @param tab viewer's tab
665 * @param time_interval a pointer where time interval is stored.
666 */
667
668void lttvwindow_report_time_window(Tab *tab,
669 const TimeWindow *time_window)
670{
671 set_time_window(tab, time_window);
672 set_time_window_adjustment(tab, time_window);
673}
674
675
676/**
677 * Function to set the current time/event of the current tab.
678 * It will be called by a viewer's signal handle associated with
679 * the button-release-event signal
680 * @param tab viewer's tab
681 * @param time a pointer where time is stored.
682 */
683
684void lttvwindow_report_current_time(Tab *tab,
685 const LttTime *time)
686{
687 LttvAttributeValue value;
688 LttvHooks * tmp;
689 tab->current_time = *time;
690 g_assert(lttv_iattribute_find_by_path(tab->attributes,
691 "hooks/updatecurrenttime", LTTV_POINTER, &value));
692 tmp = (LttvHooks*)*(value.v_pointer);
693
694 if(tmp == NULL)return;
695 lttv_hooks_call(tmp, &tab->current_time);
696}
697
698/**
699 * Function to set the position of the hpane's dividor (viewer).
700 * It will be called by a viewer's signal handle associated with
701 * the motion_notify_event event/signal
702 * @param tab viewer's tab
703 * @param position position of the hpane's dividor.
704 */
705
706void lttvwindow_report_dividor(Tab *tab, gint position)
707{
708 LttvAttributeValue value;
709 LttvHooks * tmp;
710 g_assert(lttv_iattribute_find_by_path(tab->attributes,
711 "hooks/hpanedividor", LTTV_POINTER, &value));
712 tmp = (LttvHooks*)*(value.v_pointer);
713 if(tmp == NULL) return;
714 lttv_hooks_call(tmp, &position);
715}
716
717/**
718 * Function to set the focused pane (viewer).
719 * It will be called by a viewer's signal handle associated with
720 * the grab_focus signal
721 * @param tab viewer's tab
722 * @param top_widget the top widget containing all the other widgets of the
723 * viewer.
724 */
725
726void lttvwindow_report_focus(Tab *tab, GtkWidget *top_widget)
727{
728 gtk_multi_vpaned_set_focus((GtkWidget*)tab->multi_vpaned,
729 GTK_PANED(gtk_widget_get_parent(top_widget)));
730}
731
732
733/**
734 * Function to request data in a specific time interval to the main window. The
735 * event request servicing is differed until the glib idle functions are
736 * called.
737 *
738 * The viewer has to provide hooks that should be associated with the event
739 * request.
740 *
741 * Either start time or start position must be defined in a EventRequest
742 * structure for it to be valid.
743 *
744 * end_time, end_position and num_events can all be defined. The first one
745 * to occur will be used as end criterion.
746 *
747 * @param tab viewer's tab
748 * @param events_requested the structure of request from.
749 */
750
751void lttvwindow_events_request(Tab *tab,
20fde85f 752 EventsRequest *events_request)
501e4e70 753{
20fde85f 754 tab->events_requests = g_slist_append(tab->events_requests, events_request);
501e4e70 755
756 if(!tab->events_request_pending)
757 {
758 /* Redraw has +20 priority. We want a prio higher than that, so +19 */
759 g_idle_add_full((G_PRIORITY_HIGH_IDLE + 19),
760 (GSourceFunc)execute_events_requests,
761 tab,
762 NULL);
763 tab->events_request_pending = TRUE;
764 }
765}
766
767
768/**
769 * Function to remove data requests related to a viewer.
770 *
771 * The existing requests's viewer gpointer is compared to the pointer
772 * given in argument to establish which data request should be removed.
773 *
774 * @param tab the tab the viewer belongs to.
775 * @param viewer a pointer to the viewer data structure
776 */
777
778gint find_viewer (const EventsRequest *a, gconstpointer b)
779{
2d262115 780 return (a->owner != b);
501e4e70 781}
782
783
784void lttvwindow_events_request_remove_all(Tab *tab,
785 gconstpointer viewer)
786{
787 GSList *element;
788
789 while((element =
790 g_slist_find_custom(tab->events_requests, viewer,
791 (GCompareFunc)find_viewer))
792 != NULL) {
2d262115 793 EventsRequest *events_request = (EventsRequest *)element->data;
501e4e70 794 if(events_request->servicing == TRUE) {
795 lttv_hooks_call(events_request->after_request, NULL);
796 }
797 g_free(events_request);
798 tab->events_requests = g_slist_remove_link(tab->events_requests, element);
799
800 }
801}
802
803
804
805/**
806 * Function to get the current time interval shown on the current tab.
807 * It will be called by a viewer's hook function to update the
808 * shown time interval of the viewer and also be called by the constructor
809 * of the viewer.
810 * @param tab viewer's tab
811 * @param time_interval a pointer where time interval will be stored.
812 */
813
814const TimeWindow *lttvwindow_get_time_window(Tab *tab)
815{
816 return &(tab->time_window);
817
818}
819
820
821/**
822 * Function to get the current time/event of the current tab.
823 * It will be called by a viewer's hook function to update the
824 * current time/event of the viewer.
825 * @param tab viewer's tab
826 * @param time a pointer where time will be stored.
827 */
828
829const LttTime *lttvwindow_get_current_time(Tab *tab)
830{
831 return &(tab->current_time);
832}
833
834
835/**
836 * Function to get the filter of the current tab.
837 * It will be called by the constructor of the viewer and also be
838 * called by a hook funtion of the viewer to update its filter.
839 * @param tab viewer's tab
840 * @param filter, a pointer to a filter.
841 */
842const lttv_filter *lttvwindow_get_filter(Tab *tab)
843{
844 //FIXME
845 g_warning("lttvwindow_get_filter not implemented in viewer.c");
846}
847
848
849/**
850 * Function to get the stats of the traceset
851 * @param tab viewer's tab
852 */
853
854LttvTracesetStats* lttvwindow_get_traceset_stats(Tab *tab)
855{
856 return tab->traceset_info->traceset_context;
857}
858
859
860LttvTracesetContext* lttvwindow_get_traceset_context(Tab *tab)
861{
862 return (LttvTracesetContext*)tab->traceset_info->traceset_context;
863}
This page took 0.054799 seconds and 4 git commands to generate.