enhancements and bugfixes
[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
501e4e70 51void set_time_window_adjustment(Tab *tab, const TimeWindow* new_time_window)
52{
53 gtk_multi_vpaned_set_adjust(tab->multi_vpaned, new_time_window, FALSE);
54}
55
56
57void set_time_window(Tab *tab, const TimeWindow *time_window)
58{
59 LttvAttributeValue value;
60 LttvHooks * tmp;
61
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 =
67 &(tab->time_window);
68
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);
74
75
76}
77
78void add_toolbar_constructor(MainWindow *mw, LttvToolbarClosure *toolbar_c)
79{
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;
85 GdkPixbuf *pixbuf;
86
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);
92
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);
97 new_widget =
98 gtk_toolbar_append_element (GTK_TOOLBAR (tool_menu_title_menu),
99 GTK_TOOLBAR_CHILD_BUTTON,
100 NULL,
101 "",
102 toolbar_c->tooltip, NULL,
103 pixmap, NULL, 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),
108 TRUE);
109 gtk_container_set_border_width (GTK_CONTAINER (new_widget), 1);
110 g_signal_connect ((gpointer) new_widget,
111 "clicked",
112 G_CALLBACK (insert_viewer_wrap),
113 constructor);
114 gtk_widget_show (new_widget);
115
116 lttv_toolbars_add(instance_toolbar, toolbar_c->con,
117 toolbar_c->tooltip,
118 toolbar_c->pixmap,
119 new_widget);
120
121}
122
123void add_menu_constructor(MainWindow *mw, LttvMenuClosure *menu_c)
124{
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;
130
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);
136
137
138 constructor = menu_c->con;
139 tool_menu_title_menu = lookup_widget(mw->mwindow,"ToolMenuTitle_menu");
140 new_widget =
141 gtk_menu_item_new_with_mnemonic (menu_c->menu_text);
142 gtk_container_add (GTK_CONTAINER (tool_menu_title_menu),
143 new_widget);
144 g_signal_connect ((gpointer) new_widget, "activate",
145 G_CALLBACK (insert_viewer_wrap),
146 constructor);
147 gtk_widget_show (new_widget);
148 lttv_menus_add(instance_menu, menu_c->con,
149 menu_c->menu_path,
150 menu_c->menu_text,
151 new_widget);
152}
153
154void remove_toolbar_constructor(MainWindow *mw, lttvwindow_viewer_constructor viewer_constructor)
155{
156 LttvIAttribute *attributes = mw->attributes;
157 LttvAttributeValue value;
158 LttvToolbars * instance_toolbar;
159 lttvwindow_viewer_constructor constructor;
160 GtkWidget * tool_menu_title_menu, *widget;
161
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);
167
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),
171 widget);
172}
173
174
175void remove_menu_constructor(MainWindow *mw, lttvwindow_viewer_constructor viewer_constructor)
176{
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;
183
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);
189
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);
193}
194
195
196/**
197 * API parts
198 */
199
200
201/**
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
205 * window.
206 *
207 * It should be called by init function of the module.
208 *
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.
214 */
215
216void lttvwindow_register_constructor
217 (char * menu_path,
218 char * menu_text,
219 char ** pixmap,
220 char * tooltip,
221 lttvwindow_viewer_constructor view_constructor)
222{
223 LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes());
224 LttvToolbars * toolbar;
225 LttvMenus * menu;
226 LttvToolbarClosure toolbar_c;
227 LttvMenuClosure menu_c;
228 LttvAttributeValue value;
229
230 if(pixmap != NULL) {
231 g_assert(lttv_iattribute_find_by_path(attributes_global,
232 "viewers/toolbar", LTTV_POINTER, &value));
233 toolbar = (LttvToolbars*)*(value.v_pointer);
234
235 if(toolbar == NULL) {
236 toolbar = lttv_toolbars_new();
237 *(value.v_pointer) = toolbar;
238 }
239 toolbar_c = lttv_toolbars_add(toolbar, view_constructor, tooltip, pixmap,
240 NULL);
241
242 g_slist_foreach(g_main_window_list,
243 (gpointer)add_toolbar_constructor,
244 &toolbar_c);
245 }
246
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);
251
252 if(menu == NULL) {
253 menu = lttv_menus_new();
254 *(value.v_pointer) = menu;
255 }
256 menu_c = lttv_menus_add(menu, view_constructor, menu_path, menu_text,NULL);
257
258 g_slist_foreach(g_main_window_list,
259 (gpointer)add_menu_constructor,
260 &menu_c);
261 }
262}
263
264
265/**
266 * Function to unregister the viewer's constructor, release the space
267 * occupied by menu_path, menu_text, pixmap, tooltip and constructor of the
268 * viewer.
269 *
270 * It will be called when a module is unloaded.
271 *
272 * @param view_constructor constructor of the viewer.
273 */
274
275
276void lttvwindow_unregister_constructor
277 (lttvwindow_viewer_constructor view_constructor)
278{
279 LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes());
280 LttvToolbars * toolbar;
281 LttvMenus * menu;
282 LttvAttributeValue value;
283
284 g_assert(lttv_iattribute_find_by_path(attributes_global,
285 "viewers/toolbar", LTTV_POINTER, &value));
286 toolbar = (LttvToolbars*)*(value.v_pointer);
287
288 if(toolbar != NULL) {
289 g_slist_foreach(g_main_window_list,
290 (gpointer)remove_toolbar_constructor,
291 view_constructor);
292 lttv_toolbars_remove(toolbar, view_constructor);
293 }
294
295 g_assert(lttv_iattribute_find_by_path(attributes_global,
296 "viewers/menu", LTTV_POINTER, &value));
297 menu = (LttvMenus*)*(value.v_pointer);
298
299 if(menu != NULL) {
300 g_slist_foreach(g_main_window_list,
301 (gpointer)remove_menu_constructor,
302 view_constructor);
303 lttv_menus_remove(menu, view_constructor);
304 }
305}
306
307
308/**
309 * Function to register a hook function for a viewer to set/update its
310 * time interval.
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.
314 */
315void lttvwindow_register_time_window_notify(Tab *tab,
316 LttvHook hook, gpointer hook_data)
317{
318 LttvAttributeValue value;
319 LttvHooks * tmp;
320 g_assert(lttv_iattribute_find_by_path(tab->attributes,
321 "hooks/updatetimewindow", LTTV_POINTER, &value));
322 tmp = (LttvHooks*)*(value.v_pointer);
323 if(tmp == NULL){
324 tmp = lttv_hooks_new();
325 *(value.v_pointer) = tmp;
326 }
327 lttv_hooks_add(tmp, hook,hook_data, LTTV_PRIO_DEFAULT);
328}
329
330
331/**
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.
337 */
338
339void lttvwindow_unregister_time_window_notify(Tab *tab,
340 LttvHook hook, gpointer hook_data)
341{
342 LttvAttributeValue value;
343 LttvHooks * tmp;
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);
349}
350
351/**
352 * Function to register a hook function for a viewer to set/update its
353 * traceset.
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.
357 */
358
359void lttvwindow_register_traceset_notify(Tab *tab,
360 LttvHook hook, gpointer hook_data)
361{
362 LttvAttributeValue value;
363 LttvHooks * tmp;
364 g_assert(lttv_iattribute_find_by_path(tab->attributes,
365 "hooks/updatetraceset", LTTV_POINTER, &value));
366 tmp = (LttvHooks*)*(value.v_pointer);
367 if(tmp == NULL){
368 tmp = lttv_hooks_new();
369 *(value.v_pointer) = tmp;
370 }
371 lttv_hooks_add(tmp, hook, hook_data, LTTV_PRIO_DEFAULT);
372}
373
374
375/**
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.
381 */
382
383void lttvwindow_unregister_traceset_notify(Tab *tab,
384 LttvHook hook, gpointer hook_data)
385{
386 LttvAttributeValue value;
387 LttvHooks * tmp;
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);
393}
394
9878c8a4 395/**
396 * Function to register a hook function for a viewer be completely redrawn.
397 *
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.
401 */
402
403void lttvwindow_register_redraw_notify(Tab *tab,
404 LttvHook hook, gpointer hook_data)
405{
406 LttvAttributeValue value;
407 LttvHooks * tmp;
408 g_assert(lttv_iattribute_find_by_path(tab->attributes,
409 "hooks/redraw", LTTV_POINTER, &value));
410 tmp = (LttvHooks*)*(value.v_pointer);
411 if(tmp == NULL){
412 tmp = lttv_hooks_new();
413 *(value.v_pointer) = tmp;
414 }
415 lttv_hooks_add(tmp, hook, hook_data, LTTV_PRIO_DEFAULT);
416}
417
418
419/**
420 * Function to unregister a hook function for a viewer be completely redrawn.
421 *
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.
425 */
426
427void lttvwindow_unregister_redraw_notify(Tab *tab,
428 LttvHook hook, gpointer hook_data)
429{
430 LttvAttributeValue value;
431 LttvHooks * tmp;
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);
437}
438
439/**
440 * Function to register a hook function for a viewer to re-do the events
441 * requests for the needed interval.
442 *
443 * This action is typically done after a "stop".
444 *
445 * The typical hook will remove all current requests for the viewer
446 * and make requests for missing information.
447 *
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.
451 */
452
453void lttvwindow_register_continue_notify(Tab *tab,
454 LttvHook hook, gpointer hook_data)
455{
456 LttvAttributeValue value;
457 LttvHooks * tmp;
458 g_assert(lttv_iattribute_find_by_path(tab->attributes,
459 "hooks/continue", LTTV_POINTER, &value));
460 tmp = (LttvHooks*)*(value.v_pointer);
461 if(tmp == NULL){
462 tmp = lttv_hooks_new();
463 *(value.v_pointer) = tmp;
464 }
465 lttv_hooks_add(tmp, hook, hook_data, LTTV_PRIO_DEFAULT);
466}
467
468
469/**
470 * Function to unregister a hook function for a viewer to re-do the events
471 * requests for the needed interval.
472 *
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.
476 */
477
478void lttvwindow_unregister_continue_notify(Tab *tab,
479 LttvHook hook, gpointer hook_data)
480{
481 LttvAttributeValue value;
482 LttvHooks * tmp;
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);
488}
489
490
501e4e70 491/**
492 * Function to register a hook function for a viewer to set/update its
493 * filter.
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_register_filter_notify(Tab *tab,
500 LttvHook hook, gpointer hook_data)
501{
502 LttvAttributeValue value;
503 LttvHooks * tmp;
504 g_assert(lttv_iattribute_find_by_path(tab->attributes,
505 "hooks/updatefilter", LTTV_POINTER, &value));
506 tmp = (LttvHooks*)*(value.v_pointer);
507 if(tmp == NULL){
508 tmp = lttv_hooks_new();
509 *(value.v_pointer) = tmp;
510 }
511 lttv_hooks_add(tmp, hook, hook_data, LTTV_PRIO_DEFAULT);
512}
513
514
515/**
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.
521 */
522
523void lttvwindow_unregister_filter_notify(Tab *tab,
524 LttvHook hook,
525 gpointer hook_data)
526{
527 LttvAttributeValue value;
528 LttvHooks * tmp;
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);
534}
535
536/**
537 * Function to register a hook function for a viewer to set/update its
538 * current time.
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_register_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){
553 tmp = lttv_hooks_new();
554 *(value.v_pointer) = tmp;
555 }
556 lttv_hooks_add(tmp, hook, hook_data, LTTV_PRIO_DEFAULT);
557}
558
559
560/**
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.
566 */
567
568void lttvwindow_unregister_current_time_notify(Tab *tab,
569 LttvHook hook, gpointer hook_data)
570{
571 LttvAttributeValue value;
572 LttvHooks * tmp;
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);
578}
579
580
581/**
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.
587 */
588
589void lttvwindow_register_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){
598 tmp = lttv_hooks_new();
599 *(value.v_pointer) = tmp;
600 }
601 lttv_hooks_add(tmp, hook, hook_data, LTTV_PRIO_DEFAULT);
602}
603
604
605/**
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.
611 */
612
613void lttvwindow_unregister_show_notify(Tab *tab,
614 LttvHook hook, gpointer hook_data)
615{
616 LttvAttributeValue value;
617 LttvHooks * tmp;
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);
623}
624
625/**
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.
631 */
632
633void lttvwindow_register_dividor(Tab *tab,
634 LttvHook hook, gpointer hook_data)
635{
636 LttvAttributeValue value;
637 LttvHooks * tmp;
638 g_assert(lttv_iattribute_find_by_path(tab->attributes,
639 "hooks/hpanedividor", LTTV_POINTER, &value));
640 tmp = (LttvHooks*)*(value.v_pointer);
641 if(tmp == NULL){
642 tmp = lttv_hooks_new();
643 *(value.v_pointer) = tmp;
644 }
645 lttv_hooks_add(tmp, hook, hook_data, LTTV_PRIO_DEFAULT);
646}
647
648
649/**
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.
656 */
657
658void lttvwindow_unregister_dividor(Tab *tab,
659 LttvHook hook, gpointer hook_data)
660{
661 LttvAttributeValue value;
662 LttvHooks * tmp;
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);
668}
669
670
671/**
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.
675 */
676
677void lttvwindow_report_status(Tab *tab, const char *info)
678{
679 //FIXME
680 g_warning("update_status not implemented in viewer.c");
681 // Use tab->mw for status
682}
683
684/**
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.
690 */
691
692void lttvwindow_report_time_window(Tab *tab,
693 const TimeWindow *time_window)
694{
695 set_time_window(tab, time_window);
696 set_time_window_adjustment(tab, time_window);
697}
698
699
700/**
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.
706 */
707
708void lttvwindow_report_current_time(Tab *tab,
709 const LttTime *time)
710{
711 LttvAttributeValue value;
712 LttvHooks * tmp;
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);
717
718 if(tmp == NULL)return;
719 lttv_hooks_call(tmp, &tab->current_time);
720}
721
722/**
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.
728 */
729
730void lttvwindow_report_dividor(Tab *tab, gint position)
731{
732 LttvAttributeValue value;
733 LttvHooks * tmp;
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);
739}
740
741/**
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
747 * viewer.
748 */
749
750void lttvwindow_report_focus(Tab *tab, GtkWidget *top_widget)
751{
752 gtk_multi_vpaned_set_focus((GtkWidget*)tab->multi_vpaned,
753 GTK_PANED(gtk_widget_get_parent(top_widget)));
754}
755
756
757/**
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
760 * called.
761 *
762 * The viewer has to provide hooks that should be associated with the event
763 * request.
764 *
765 * Either start time or start position must be defined in a EventRequest
766 * structure for it to be valid.
767 *
768 * end_time, end_position and num_events can all be defined. The first one
769 * to occur will be used as end criterion.
770 *
771 * @param tab viewer's tab
772 * @param events_requested the structure of request from.
773 */
774
775void lttvwindow_events_request(Tab *tab,
20fde85f 776 EventsRequest *events_request)
501e4e70 777{
20fde85f 778 tab->events_requests = g_slist_append(tab->events_requests, events_request);
501e4e70 779
780 if(!tab->events_request_pending)
781 {
553d1e7b 782 /* Redraw has +20 priority. We want to let the redraw be done while we do
783 * our job. */
784 g_idle_add_full((G_PRIORITY_HIGH_IDLE + 21),
501e4e70 785 (GSourceFunc)execute_events_requests,
786 tab,
787 NULL);
788 tab->events_request_pending = TRUE;
789 }
790}
791
792
793/**
794 * Function to remove data requests related to a viewer.
795 *
796 * The existing requests's viewer gpointer is compared to the pointer
797 * given in argument to establish which data request should be removed.
798 *
799 * @param tab the tab the viewer belongs to.
800 * @param viewer a pointer to the viewer data structure
801 */
802
803gint find_viewer (const EventsRequest *a, gconstpointer b)
804{
2d262115 805 return (a->owner != b);
501e4e70 806}
807
808
809void lttvwindow_events_request_remove_all(Tab *tab,
810 gconstpointer viewer)
811{
812 GSList *element;
813
814 while((element =
815 g_slist_find_custom(tab->events_requests, viewer,
816 (GCompareFunc)find_viewer))
817 != NULL) {
2d262115 818 EventsRequest *events_request = (EventsRequest *)element->data;
501e4e70 819 if(events_request->servicing == TRUE) {
820 lttv_hooks_call(events_request->after_request, NULL);
821 }
822 g_free(events_request);
823 tab->events_requests = g_slist_remove_link(tab->events_requests, element);
824
825 }
826}
827
828
829
830/**
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
834 * of the viewer.
835 * @param tab viewer's tab
6ea08962 836 * @return time window.
501e4e70 837 */
838
6ea08962 839TimeWindow lttvwindow_get_time_window(Tab *tab)
501e4e70 840{
6ea08962 841 return tab->time_window;
501e4e70 842
843}
844
845
846/**
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
6ea08962 851 * @return time
501e4e70 852 */
853
6ea08962 854LttTime lttvwindow_get_current_time(Tab *tab)
501e4e70 855{
6ea08962 856 return tab->current_time;
501e4e70 857}
858
859
860/**
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.
866 */
867const lttv_filter *lttvwindow_get_filter(Tab *tab)
868{
869 //FIXME
870 g_warning("lttvwindow_get_filter not implemented in viewer.c");
871}
872
873
874/**
875 * Function to get the stats of the traceset
876 * @param tab viewer's tab
877 */
878
879LttvTracesetStats* lttvwindow_get_traceset_stats(Tab *tab)
880{
881 return tab->traceset_info->traceset_context;
882}
883
884
885LttvTracesetContext* lttvwindow_get_traceset_context(Tab *tab)
886{
887 return (LttvTracesetContext*)tab->traceset_info->traceset_context;
888}
This page took 0.05429 seconds and 4 git commands to generate.