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