Moving files around to get rid of the shared include tree. Some other
[lttv.git] / ltt / branches / poly / lttv / modules / gui / mainlib / gtktraceset.c
CommitLineData
cef97e7c 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 gtktraceset.h
561f5852 20 * \brief API used by the graphical viewers to interact with their top window.
21 *
22 * Main window (gui module) is the place to contain and display viewers.
23 * Viewers (lttv plugins) interacte with main window through this API and
24 * 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 the
27 * tracesetWindow.
28 *
29 */
30
d0cf1bcd 31#include <lttv/common.h>
561f5852 32#include <ltt/ltt.h>
33#include <lttv/lttv.h>
637bd544 34#include <lttv/mainwindow.h>
cef97e7c 35#include <lttv/gtktraceset.h>
d8f124de 36#include <lttv/tracecontext.h>
c4c15b5e 37#include <lttv/toolbar.h>
38#include <lttv/menu.h>
6b1d3120 39#include <lttv/state.h>
40#include <lttv/stats.h>
41
561f5852 42
43/**
44 * Internal function parts
45 */
46
561f5852 47/**
48 * Function to set/update traceset for the viewers
49 * @param main_win main window
50 * @param traceset traceset of the main window.
51 */
52
bca3b81f 53void SetTraceset(MainWindow * main_win, gpointer traceset)
561f5852 54{
55 LttvHooks * tmp;
56 LttvAttributeValue value;
57
bca3b81f 58 g_assert(lttv_iattribute_find_by_path(main_win->attributes,
d2811a98 59 "hooks/updatetraceset", LTTV_POINTER, &value));
561f5852 60 tmp = (LttvHooks*)*(value.v_pointer);
61 if(tmp == NULL)return;
62 lttv_hooks_call(tmp,traceset);
63}
64
65
66/**
67 * Function to set/update filter for the viewers
68 * @param main_win main window
69 * @param filter filter of the main window.
70 */
71
bca3b81f 72void SetFilter(MainWindow * main_win, gpointer filter)
561f5852 73{
74 LttvHooks * tmp;
75 LttvAttributeValue value;
76
bca3b81f 77 g_assert(lttv_iattribute_find_by_path(main_win->attributes,
d2811a98 78 "hooks/updatefilter", LTTV_POINTER, &value));
561f5852 79 tmp = (LttvHooks*)*(value.v_pointer);
80
81 if(tmp == NULL)return;
82 lttv_hooks_call(tmp,filter);
83}
84
85
86
87/**
88 * API parts
89 */
90
91/**
92 * Function to register a view constructor so that main window can generate
93 * a toolbar item for the viewer in order to generate a new instance easily.
94 * It will be called by init function of the module.
95 * @param ButtonPixmap image shown on the toolbar item.
96 * @param tooltip tooltip of the toolbar item.
97 * @param view_constructor constructor of the viewer.
98 */
99
41a76985 100void toolbar_item_reg(char ** pixmap, char *tooltip, lttv_constructor view_constructor)
561f5852 101{
102 LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes());
103 LttvToolbars * toolbar;
104 LttvAttributeValue value;
105
106 g_assert(lttv_iattribute_find_by_path(attributes_global,
d2811a98 107 "viewers/toolbar", LTTV_POINTER, &value));
561f5852 108 toolbar = (LttvToolbars*)*(value.v_pointer);
109
110 if(toolbar == NULL){
111 toolbar = lttv_toolbars_new();
112 *(value.v_pointer) = toolbar;
113 }
114 lttv_toolbars_add(toolbar, view_constructor, tooltip, pixmap);
115}
116
117
118/**
119 * Function to unregister the viewer's constructor, release the space
120 * occupied by pixmap, tooltip and constructor of the viewer.
121 * It will be called when a module is unloaded.
122 * @param view_constructor constructor of the viewer which is used as
123 * a reference to find out where the pixmap and tooltip are.
124 */
125
41a76985 126void toolbar_item_unreg(lttv_constructor view_constructor)
561f5852 127{
128 LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes());
129 LttvToolbars * toolbar;
130 LttvAttributeValue value;
131
132 g_assert(lttv_iattribute_find_by_path(attributes_global,
d2811a98 133 "viewers/toolbar", LTTV_POINTER, &value));
561f5852 134 toolbar = (LttvToolbars*)*(value.v_pointer);
135
2061e03d 136 main_window_remove_toolbar_item(view_constructor);
137
138 lttv_toolbars_remove(toolbar, view_constructor);
561f5852 139}
140
141
142/**
143 * Function to register a view constructor so that main window can generate
144 * a menu item for the viewer in order to generate a new instance easily.
145 * It will be called by init function of the module.
146 * @param menu_path path of the menu item.
147 * @param menu_text text of the menu item.
148 * @param view_constructor constructor of the viewer.
149 */
150
41a76985 151void menu_item_reg(char *menu_path, char *menu_text, lttv_constructor view_constructor)
561f5852 152{
153 LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes());
154 LttvMenus * menu;
155 LttvAttributeValue value;
156
157 g_assert(lttv_iattribute_find_by_path(attributes_global,
d2811a98 158 "viewers/menu", LTTV_POINTER, &value));
561f5852 159 menu = (LttvMenus*)*(value.v_pointer);
160
161 if(menu == NULL){
162 menu = lttv_menus_new();
163 *(value.v_pointer) = menu;
164 }
165 lttv_menus_add(menu, view_constructor, menu_path, menu_text);
166}
167
168/**
169 * Function to unregister the viewer's constructor, release the space
170 * occupied by menu_path, menu_text and constructor of the viewer.
171 * It will be called when a module is unloaded.
172 * @param view_constructor constructor of the viewer which is used as
173 * a reference to find out where the menu_path and menu_text are.
174 */
175
41a76985 176void menu_item_unreg(lttv_constructor view_constructor)
561f5852 177{
178 LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes());
179 LttvMenus * menu;
180 LttvAttributeValue value;
181
182 g_assert(lttv_iattribute_find_by_path(attributes_global,
c4c15b5e 183 "viewers/menu", LTTV_POINTER, &value));
561f5852 184 menu = (LttvMenus*)*(value.v_pointer);
185
2061e03d 186 main_window_remove_menu_item(view_constructor);
187
188 lttv_menus_remove(menu, view_constructor);
561f5852 189}
190
191
192/**
193 * Update the status bar whenever something changed in the viewer.
194 * @param main_win the main window the viewer belongs to.
195 * @param info the message which will be shown in the status bar.
196 */
197
41a76985 198void update_status(MainWindow *main_win, char *info)
561f5852 199{
200}
201
202
203/**
f7afe191 204 * Function to get the current time interval shown on the current tab.
205 * It will be called by a viewer's hook function to update the
206 * shown time interval of the viewer and also be called by the constructor
207 * of the viewer.
208 * @param main_win the main window the viewer belongs to.
209 * @param time_interval a pointer where time interval will be stored.
210 */
211
41a76985 212void get_time_window(MainWindow *main_win, TimeWindow *time_window)
f7afe191 213{
bca3b81f 214 //time_window->start_time = main_win->current_tab->time_window.start_time;
215 //time_window->time_width = main_win->current_tab->time_window.time_width;
216 *time_window = main_win->current_tab->time_window;
f7afe191 217}
218
219/**
220 * Function to get the current time interval of the current traceset.
561f5852 221 * It will be called by a viewer's hook function to update the
222 * time interval of the viewer and also be called by the constructor
223 * of the viewer.
224 * @param main_win the main window the viewer belongs to.
225 * @param time_interval a pointer where time interval will be stored.
226 */
227
41a76985 228void get_traceset_time_span(MainWindow *main_win, TimeInterval *time_interval)
561f5852 229{
bca3b81f 230 //time_window->start_time = main_win->current_tab->time_window.start_time;
231 //time_window->time_width = main_win->current_tab->time_window.time_width;
716e4367 232 *time_interval = *(LTTV_TRACESET_CONTEXT(main_win->current_tab->traceset_info->
d2811a98 233 traceset_context)->Time_Span);
561f5852 234}
235
236
f7afe191 237
561f5852 238/**
239 * Function to set the time interval of the current tab.
240 * It will be called by a viewer's signal handle associated with
241 * the move_slider signal
242 * @param main_win the main window the viewer belongs to.
243 * @param time_interval a pointer where time interval is stored.
244 */
245
41a76985 246void set_time_window(MainWindow *main_win, TimeWindow *time_window)
561f5852 247{
248 LttvAttributeValue value;
249 LttvHooks * tmp;
bca3b81f 250 main_win->current_tab->time_window = *time_window;
bca085a1 251 gtk_multi_vpaned_set_scroll_value(main_win->current_tab->multi_vpaned,
d2811a98 252 ltt_time_to_double(time_window->start_time)
253 * NANOSECONDS_PER_SECOND );
bca3b81f 254 g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
d2811a98 255 "hooks/updatetimewindow", LTTV_POINTER, &value));
561f5852 256 tmp = (LttvHooks*)*(value.v_pointer);
f7afe191 257 if(tmp == NULL) return;
a2eab0c9 258 lttv_hooks_call(tmp, time_window);
561f5852 259}
260
261
262/**
263 * Function to get the current time/event of the current tab.
264 * It will be called by a viewer's hook function to update the
265 * current time/event of the viewer.
266 * @param main_win the main window the viewer belongs to.
267 * @param time a pointer where time will be stored.
268 */
269
41a76985 270void get_current_time(MainWindow *main_win, LttTime *time)
561f5852 271{
bca3b81f 272 time = &main_win->current_tab->current_time;
561f5852 273}
274
275
276/**
277 * Function to set the current time/event of the current tab.
278 * It will be called by a viewer's signal handle associated with
279 * the button-release-event signal
280 * @param main_win the main window the viewer belongs to.
281 * @param time a pointer where time is stored.
282 */
283
41a76985 284void set_current_time(MainWindow *main_win, LttTime *time)
561f5852 285{
286 LttvAttributeValue value;
287 LttvHooks * tmp;
bca3b81f 288 main_win->current_tab->current_time = *time;
289 g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
d2811a98 290 "hooks/updatecurrenttime", LTTV_POINTER, &value));
561f5852 291 tmp = (LttvHooks*)*(value.v_pointer);
292
293 if(tmp == NULL)return;
294 lttv_hooks_call(tmp, time);
295}
296
297
298/**
299 * Function to get the traceset from the current tab.
300 * It will be called by the constructor of the viewer and also be
301 * called by a hook funtion of the viewer to update its traceset.
302 * @param main_win the main window the viewer belongs to.
303 * @param traceset a pointer to a traceset.
304 */
305/*
41a76985 306void get_traceset(MainWindow *main_win, Traceset *traceset)
561f5852 307{
308}
309*/
310
311/**
312 * Function to get the filter of the current tab.
313 * It will be called by the constructor of the viewer and also be
314 * called by a hook funtion of the viewer to update its filter.
315 * @param main_win, the main window the viewer belongs to.
316 * @param filter, a pointer to a filter.
317 */
318/*
41a76985 319void get_filter(MainWindow *main_win, Filter *filter)
561f5852 320{
321}
322*/
323
324/**
325 * Function to register a hook function for a viewer to set/update its
326 * time interval.
327 * It will be called by the constructor of the viewer.
328 * @param hook hook function of the viewer.
329 * @param hook_data hook data associated with the hook function.
330 * @param main_win the main window the viewer belongs to.
331 */
332
41a76985 333void reg_update_time_window(LttvHook hook, gpointer hook_data,
d2811a98 334 MainWindow * main_win)
561f5852 335{
336 LttvAttributeValue value;
337 LttvHooks * tmp;
bca3b81f 338 g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
d2811a98 339 "hooks/updatetimewindow", LTTV_POINTER, &value));
561f5852 340 tmp = (LttvHooks*)*(value.v_pointer);
341 if(tmp == NULL){
342 tmp = lttv_hooks_new();
343 *(value.v_pointer) = tmp;
344 }
345 lttv_hooks_add(tmp, hook,hook_data);
346}
347
348
349/**
350 * Function to unregister a viewer's hook function which is used to
351 * set/update the time interval of the viewer.
352 * It will be called by the destructor of the viewer.
353 * @param hook hook function of the viewer.
354 * @param hook_data hook data associated with the hook function.
355 * @param main_win the main window the viewer belongs to.
356 */
357
41a76985 358void unreg_update_time_window(LttvHook hook, gpointer hook_data,
d2811a98 359 MainWindow * main_win)
561f5852 360{
361 LttvAttributeValue value;
362 LttvHooks * tmp;
bca3b81f 363 g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
d2811a98 364 "hooks/updatetimewindow", LTTV_POINTER, &value));
561f5852 365 tmp = (LttvHooks*)*(value.v_pointer);
366 if(tmp == NULL) return;
367 lttv_hooks_remove_data(tmp, hook, hook_data);
368}
369
370
371/**
372 * Function to register a hook function for a viewer to set/update its
373 * traceset.
374 * It will be called by the constructor of the viewer.
375 * @param hook hook function of the viewer.
376 * @param hook_data hook data associated with the hook function.
377 * @param main_win the main window the viewer belongs to.
378 */
379
41a76985 380void reg_update_traceset(LttvHook hook, gpointer hook_data,
d2811a98 381 MainWindow * main_win)
561f5852 382{
383 LttvAttributeValue value;
384 LttvHooks * tmp;
a8c0f09d 385 g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
d2811a98 386 "hooks/updatetraceset", LTTV_POINTER, &value));
561f5852 387 tmp = (LttvHooks*)*(value.v_pointer);
388 if(tmp == NULL){
389 tmp = lttv_hooks_new();
390 *(value.v_pointer) = tmp;
391 }
392 lttv_hooks_add(tmp, hook, hook_data);
393}
394
395
396/**
397 * Function to unregister a viewer's hook function which is used to
398 * set/update the traceset of the viewer.
399 * It will be called by the destructor of the viewer.
400 * @param hook hook function of the viewer.
401 * @param hook_data hook data associated with the hook function.
402 * @param main_win the main window the viewer belongs to.
403 */
404
41a76985 405void unreg_update_traceset(LttvHook hook, gpointer hook_data,
d2811a98 406 MainWindow * main_win)
561f5852 407{
408 LttvAttributeValue value;
409 LttvHooks * tmp;
a8c0f09d 410 g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
d2811a98 411 "hooks/updatetraceset", LTTV_POINTER, &value));
561f5852 412 tmp = (LttvHooks*)*(value.v_pointer);
413 if(tmp == NULL) return;
414 lttv_hooks_remove_data(tmp, hook, hook_data);
415}
416
417
a8c0f09d 418/**
419 * Function to redraw each viewer belonging to the current tab
420 * @param main_win the main window the viewer belongs to.
421 */
422
423void update_traceset(MainWindow * main_win)
424{
425 LttvAttributeValue value;
426 LttvHooks * tmp;
427 g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
d2811a98 428 "hooks/updatetraceset", LTTV_POINTER, &value));
a8c0f09d 429 tmp = (LttvHooks*)*(value.v_pointer);
430 if(tmp == NULL) return;
431 lttv_hooks_call(tmp, NULL);
432}
433
434
561f5852 435/**
436 * Function to register a hook function for a viewer to set/update its
437 * filter.
438 * It will be called by the constructor of the viewer.
439 * @param hook hook function of the viewer.
440 * @param hook_data hook data associated with the hook function.
441 * @param main_win the main window the viewer belongs to.
442 */
443
41a76985 444void reg_update_filter(LttvHook hook, gpointer hook_data,
d2811a98 445 MainWindow *main_win)
561f5852 446{
447 LttvAttributeValue value;
448 LttvHooks * tmp;
bca3b81f 449 g_assert(lttv_iattribute_find_by_path(main_win->attributes,
d2811a98 450 "hooks/updatefilter", LTTV_POINTER, &value));
561f5852 451 tmp = (LttvHooks*)*(value.v_pointer);
452 if(tmp == NULL){
453 tmp = lttv_hooks_new();
454 *(value.v_pointer) = tmp;
455 }
456 lttv_hooks_add(tmp, hook, hook_data);
457}
458
459
460/**
461 * Function to unregister a viewer's hook function which is used to
462 * set/update the filter of the viewer.
463 * It will be called by the destructor of the viewer.
464 * @param hook hook function of the viewer.
465 * @param hook_data hook data associated with the hook function.
466 * @param main_win the main window the viewer belongs to.
467 */
468
41a76985 469void unreg_update_filter(LttvHook hook, gpointer hook_data,
d2811a98 470 MainWindow * main_win)
561f5852 471{
472 LttvAttributeValue value;
473 LttvHooks * tmp;
bca3b81f 474 g_assert(lttv_iattribute_find_by_path(main_win->attributes,
d2811a98 475 "hooks/updatefilter", LTTV_POINTER, &value));
561f5852 476 tmp = (LttvHooks*)*(value.v_pointer);
477 if(tmp == NULL) return;
478 lttv_hooks_remove_data(tmp, hook, hook_data);
479}
480
481
482/**
483 * Function to register a hook function for a viewer to set/update its
484 * current time.
485 * It will be called by the constructor of the viewer.
486 * @param hook hook function of the viewer.
487 * @param hook_data hook data associated with the hook function.
488 * @param main_win the main window the viewer belongs to.
489 */
490
41a76985 491void reg_update_current_time(LttvHook hook, gpointer hook_data,
d2811a98 492 MainWindow *main_win)
561f5852 493{
494 LttvAttributeValue value;
495 LttvHooks * tmp;
bca3b81f 496 g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
d2811a98 497 "hooks/updatecurrenttime", LTTV_POINTER, &value));
561f5852 498 tmp = (LttvHooks*)*(value.v_pointer);
499 if(tmp == NULL){
500 tmp = lttv_hooks_new();
501 *(value.v_pointer) = tmp;
502 }
503 lttv_hooks_add(tmp, hook, hook_data);
504}
505
506
507/**
508 * Function to unregister a viewer's hook function which is used to
509 * set/update the current time of the viewer.
510 * It will be called by the destructor of the viewer.
511 * @param hook hook function of the viewer.
512 * @param hook_data hook data associated with the hook function.
513 * @param main_win the main window the viewer belongs to.
514 */
515
41a76985 516void unreg_update_current_time(LttvHook hook, gpointer hook_data,
d2811a98 517 MainWindow * main_win)
561f5852 518{
519 LttvAttributeValue value;
520 LttvHooks * tmp;
bca3b81f 521 g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
d2811a98 522 "hooks/updatecurrenttime", LTTV_POINTER, &value));
561f5852 523 tmp = (LttvHooks*)*(value.v_pointer);
524 if(tmp == NULL) return;
525 lttv_hooks_remove_data(tmp, hook, hook_data);
526}
527
528
202f6c8f 529/**
530 * Function to register a hook function for a viewer to show
531 *the content of the viewer.
532 * It will be called by the constructor of the viewer.
533 * @param hook hook function of the viewer.
534 * @param hook_data hook data associated with the hook function.
535 * @param main_win the main window the viewer belongs to.
536 */
537
538void reg_show_viewer(LttvHook hook, gpointer hook_data,
d2811a98 539 MainWindow *main_win)
202f6c8f 540{
541 LttvAttributeValue value;
542 LttvHooks * tmp;
543 g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
d2811a98 544 "hooks/showviewer", LTTV_POINTER, &value));
202f6c8f 545 tmp = (LttvHooks*)*(value.v_pointer);
546 if(tmp == NULL){
547 tmp = lttv_hooks_new();
548 *(value.v_pointer) = tmp;
549 }
550 lttv_hooks_add(tmp, hook, hook_data);
551}
552
553
554/**
555 * Function to unregister a viewer's hook function which is used to
556 * show the content of the viewer..
557 * It will be called by the destructor of the viewer.
558 * @param hook hook function of the viewer.
559 * @param hook_data hook data associated with the hook function.
560 * @param main_win the main window the viewer belongs to.
561 */
562
563void unreg_show_viewer(LttvHook hook, gpointer hook_data,
d2811a98 564 MainWindow * main_win)
202f6c8f 565{
566 LttvAttributeValue value;
567 LttvHooks * tmp;
568 g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
d2811a98 569 "hooks/showviewer", LTTV_POINTER, &value));
202f6c8f 570 tmp = (LttvHooks*)*(value.v_pointer);
571 if(tmp == NULL) return;
572 lttv_hooks_remove_data(tmp, hook, hook_data);
573}
574
575
576/**
577 * Function to show each viewer in the current tab.
578 * It will be called by main window after it called process_traceset
579 * @param main_win the main window the viewer belongs to.
580 */
581
582void show_viewer(MainWindow *main_win)
583{
584 LttvAttributeValue value;
585 LttvHooks * tmp;
586 g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
d2811a98 587 "hooks/showviewer", LTTV_POINTER, &value));
202f6c8f 588 tmp = (LttvHooks*)*(value.v_pointer);
589 if(tmp == NULL) return;
590 lttv_hooks_call(tmp, NULL);
591}
592
593
561f5852 594/**
595 * Function to set the focused pane (viewer).
596 * It will be called by a viewer's signal handle associated with
597 * the grab_focus signal
598 * @param main_win the main window the viewer belongs to.
599 * @param paned a pointer to a pane where the viewer is contained.
600 */
601
41a76985 602void set_focused_pane(MainWindow *main_win, gpointer paned)
561f5852 603{
daecc161 604 gtk_multi_vpaned_set_focus((GtkWidget*)main_win->current_tab->multi_vpaned,paned);
561f5852 605}
606
607
608/**
609 * Function to register a hook function for a viewer to set/update the
610 * dividor of the hpane.
611 * It will be called by the constructor of the viewer.
612 * @param hook hook function of the viewer.
613 * @param hook_data hook data associated with the hook function.
614 * @param main_win the main window the viewer belongs to.
615 */
616
41a76985 617void reg_update_dividor(LttvHook hook, gpointer hook_data,
d2811a98 618 MainWindow *main_win)
561f5852 619{
620 LttvAttributeValue value;
621 LttvHooks * tmp;
bca3b81f 622 g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
d2811a98 623 "hooks/hpanedividor", LTTV_POINTER, &value));
561f5852 624 tmp = (LttvHooks*)*(value.v_pointer);
625 if(tmp == NULL){
626 tmp = lttv_hooks_new();
627 *(value.v_pointer) = tmp;
628 }
629 lttv_hooks_add(tmp, hook, hook_data);
630}
631
632
633/**
634 * Function to unregister a viewer's hook function which is used to
635 * set/update hpane's dividor of the viewer.
636 * It will be called by the destructor of the viewer.
637 * @param hook hook function of the viewer.
638 * @param hook_data hook data associated with the hook function.
639 * @param main_win the main window the viewer belongs to.
640 */
641
41a76985 642void unreg_update_dividor(LttvHook hook, gpointer hook_data,
d2811a98 643 MainWindow *main_win)
561f5852 644{
645 LttvAttributeValue value;
646 LttvHooks * tmp;
bca3b81f 647 g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
d2811a98 648 "hooks/hpanedividor", LTTV_POINTER, &value));
561f5852 649 tmp = (LttvHooks*)*(value.v_pointer);
650 if(tmp == NULL) return;
651 lttv_hooks_remove_data(tmp, hook, hook_data);
652}
653
654
655/**
656 * Function to set the position of the hpane's dividor (viewer).
657 * It will be called by a viewer's signal handle associated with
658 * the motion_notify_event event/signal
659 * @param main_win the main window the viewer belongs to.
660 * @param position position of the hpane's dividor.
661 */
662
41a76985 663void set_hpane_dividor(MainWindow *main_win, gint position)
561f5852 664{
665 LttvAttributeValue value;
666 LttvHooks * tmp;
bca3b81f 667 g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
d2811a98 668 "hooks/hpanedividor", LTTV_POINTER, &value));
561f5852 669 tmp = (LttvHooks*)*(value.v_pointer);
670 if(tmp == NULL) return;
671 lttv_hooks_call(tmp, &position);
672}
673
674
675/**
676 * Function to process traceset. It will call lttv_process_trace,
677 * each view will call this api to get events.
678 * @param main_win the main window the viewer belongs to.
679 * @param start the start time of the first event to be processed.
680 * @param end the end time of the last event to be processed.
681 */
682
41a76985 683void process_traceset_api(MainWindow *main_win, LttTime start,
d2811a98 684 LttTime end, unsigned maxNumEvents)
561f5852 685{
162ed572 686 lttv_process_traceset_seek_time(
687 LTTV_TRACESET_CONTEXT(main_win->current_tab->traceset_info->
688 traceset_context),
689 start);
690 lttv_process_traceset(
691 LTTV_TRACESET_CONTEXT(main_win->current_tab->traceset_info->
692 traceset_context),
693 end,
694 maxNumEvents);
561f5852 695}
696
697/**
698 * Function to add hooks into the context of a traceset,
699 * before reading events from traceset, viewer will call this api to
700 * register hooks
701 * @param main_win the main window the viewer belongs to.
702 * @param LttvHooks hooks to be registered.
703 */
704
41a76985 705void context_add_hooks_api(MainWindow *main_win ,
d2811a98 706 LttvHooks *before_traceset,
707 LttvHooks *after_traceset,
708 LttvHooks *check_trace,
709 LttvHooks *before_trace,
710 LttvHooks *after_trace,
711 LttvHooks *check_tracefile,
712 LttvHooks *before_tracefile,
713 LttvHooks *after_tracefile,
714 LttvHooks *check_event,
715 LttvHooks *before_event,
716 LttvHooks *after_event)
561f5852 717{
f7afe191 718 LttvTracesetContext * tsc =
d2811a98 719 LTTV_TRACESET_CONTEXT(main_win->current_tab->traceset_info->
720 traceset_context);
561f5852 721 lttv_traceset_context_add_hooks(tsc,before_traceset,after_traceset,
d2811a98 722 check_trace,before_trace,after_trace,
723 check_tracefile,before_tracefile,after_tracefile,
724 check_event,before_event, after_event);
561f5852 725}
726
727
728/**
729 * Function to remove hooks from the context of a traceset,
730 * before reading events from traceset, viewer will call this api to
731 * unregister hooks
732 * @param main_win the main window the viewer belongs to.
733 * @param LttvHooks hooks to be registered.
734 */
735
41a76985 736void context_remove_hooks_api(MainWindow *main_win ,
d2811a98 737 LttvHooks *before_traceset,
738 LttvHooks *after_traceset,
739 LttvHooks *check_trace,
740 LttvHooks *before_trace,
741 LttvHooks *after_trace,
742 LttvHooks *check_tracefile,
743 LttvHooks *before_tracefile,
744 LttvHooks *after_tracefile,
745 LttvHooks *check_event,
746 LttvHooks *before_event,
747 LttvHooks *after_event)
561f5852 748{
f7afe191 749 LttvTracesetContext * tsc =
716e4367 750 LTTV_TRACESET_CONTEXT(main_win->current_tab->traceset_info->traceset_context);
561f5852 751 lttv_traceset_context_remove_hooks(tsc,before_traceset,after_traceset,
d2811a98 752 check_trace,before_trace,after_trace,
753 check_tracefile,before_tracefile,after_tracefile,
754 check_event,before_event, after_event);
561f5852 755}
f735c59a 756
757
6b1d3120 758/**
759 * Function to add/remove event hooks for state
760 * @param main_win the main window the viewer belongs to.
761 */
762
41a76985 763void state_add_event_hooks_api(MainWindow *main_win )
6b1d3120 764{
f7afe191 765 lttv_state_add_event_hooks(
716e4367 766 (LttvTracesetState*)main_win->current_tab->traceset_info->traceset_context);
6b1d3120 767}
768
41a76985 769void state_remove_event_hooks_api(MainWindow *main_win )
6b1d3120 770{
f7afe191 771 lttv_state_remove_event_hooks(
716e4367 772 (LttvTracesetState*)main_win->current_tab->traceset_info->traceset_context);
6b1d3120 773}
774
775
776/**
777 * Function to add/remove event hooks for stats
778 * @param main_win the main window the viewer belongs to.
779 */
780
41a76985 781void stats_add_event_hooks_api(MainWindow *main_win )
6b1d3120 782{
f7afe191 783 lttv_stats_add_event_hooks(
716e4367 784 (LttvTracesetStats*)main_win->current_tab->traceset_info->traceset_context);
6b1d3120 785}
786
41a76985 787void stats_remove_event_hooks_api(MainWindow *main_win )
6b1d3120 788{
f7afe191 789 lttv_stats_remove_event_hooks(
716e4367 790 (LttvTracesetStats*)main_win->current_tab->traceset_info->traceset_context);
6b1d3120 791}
792
793/**
794 * Function to get the stats of the traceset
795 * @param main_win the main window the viewer belongs to.
796 */
797
41a76985 798LttvTracesetStats* get_traceset_stats_api(MainWindow *main_win)
6b1d3120 799{
716e4367 800 return main_win->current_tab->traceset_info->traceset_context;
6b1d3120 801}
a8c0f09d 802
803
804LttvTracesetContext* get_traceset_context(MainWindow *main_win)
805{
806 return (LttvTracesetContext*)main_win->current_tab->traceset_info->traceset_context;
807}
This page took 0.061381 seconds and 4 git commands to generate.