main window api files
[lttv.git] / ltt / branches / poly / lttv / modules / gui / API / gtkTraceSet.c
1 /*! \file gtkTraceSet.h
2 * \brief API used by the graphical viewers to interact with their top window.
3 *
4 * Main window (gui module) is the place to contain and display viewers.
5 * Viewers (lttv plugins) interacte with main window through this API and
6 * events sent by gtk.
7 * This header file should be included in each graphic module.
8 * This library is used by graphical modules to interact with the
9 * tracesetWindow.
10 *
11 */
12
13 #include "common.h"
14 #include <ltt/ltt.h>
15 #include <lttv/lttv.h>
16 #include <lttv/mainWindow.h>
17 #include <lttv/gtkTraceSet.h>
18 #include <lttv/processTrace.h>
19 #include "toolbar.h"
20 #include "menu.h"
21
22 /**
23 * Internal function parts
24 */
25
26 /**
27 * Function to remove toolbar from the GUI
28 * @param view_constructor constructor of the viewer.
29 */
30
31 void RemoveToolbar(void *view_constructor)
32 {
33 g_printf("Toolbar for the viewer will be removed\n");
34 }
35
36 /**
37 * Function to remove menu entry from the GUI
38 * @param view_constructor constructor of the viewer.
39 */
40
41 void RemoveMenu(void *view_constructor)
42 {
43 g_printf("Menu entry for the viewer will be removed\n");
44 }
45
46
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
53 void SetTraceset(mainWindow * main_win, gpointer traceset)
54 {
55 LttvHooks * tmp;
56 LttvAttributeValue value;
57
58 g_assert(lttv_iattribute_find_by_path(main_win->Attributes,
59 "hooks/updatetraceset", LTTV_POINTER, &value));
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
72 void SetFilter(mainWindow * main_win, gpointer filter)
73 {
74 LttvHooks * tmp;
75 LttvAttributeValue value;
76
77 g_assert(lttv_iattribute_find_by_path(main_win->Attributes,
78 "hooks/updatefilter", LTTV_POINTER, &value));
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
100 void ToolbarItemReg(GdkPixmap * pixmap, char *tooltip, void *view_constructor)
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,
107 "viewers/toolbar", LTTV_POINTER, &value));
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
126 void ToolbarItemUnreg(void *view_constructor)
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,
133 "viewers/toolbar", LTTV_POINTER, &value));
134 toolbar = (LttvToolbars*)*(value.v_pointer);
135
136 if(lttv_toolbars_remove(toolbar, view_constructor))
137 RemoveToolbar(view_constructor);
138 }
139
140
141 /**
142 * Function to register a view constructor so that main window can generate
143 * a menu item for the viewer in order to generate a new instance easily.
144 * It will be called by init function of the module.
145 * @param menu_path path of the menu item.
146 * @param menu_text text of the menu item.
147 * @param view_constructor constructor of the viewer.
148 */
149
150 void MenuItemReg(char *menu_path, char *menu_text, void *view_constructor)
151 {
152 LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes());
153 LttvMenus * menu;
154 LttvAttributeValue value;
155
156 g_assert(lttv_iattribute_find_by_path(attributes_global,
157 "viewers/menu", LTTV_POINTER, &value));
158 menu = (LttvMenus*)*(value.v_pointer);
159
160 if(menu == NULL){
161 menu = lttv_menus_new();
162 *(value.v_pointer) = menu;
163 }
164 lttv_menus_add(menu, view_constructor, menu_path, menu_text);
165 }
166
167 /**
168 * Function to unregister the viewer's constructor, release the space
169 * occupied by menu_path, menu_text and constructor of the viewer.
170 * It will be called when a module is unloaded.
171 * @param view_constructor constructor of the viewer which is used as
172 * a reference to find out where the menu_path and menu_text are.
173 */
174
175 void MenuItemUnreg(void *view_constructor)
176 {
177 LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes());
178 LttvMenus * menu;
179 LttvAttributeValue value;
180
181 g_assert(lttv_iattribute_find_by_path(attributes_global,
182 "viewers/menu", LTTV_POINTER, &value));
183 menu = (LttvMenus*)*(value.v_pointer);
184
185 if(lttv_menus_remove(menu, view_constructor))
186 RemoveMenu(view_constructor);
187 }
188
189
190 /**
191 * Update the status bar whenever something changed in the viewer.
192 * @param main_win the main window the viewer belongs to.
193 * @param info the message which will be shown in the status bar.
194 */
195
196 void UpdateStatus(mainWindow *main_win, char *info)
197 {
198 }
199
200
201 /**
202 * Function to get the current time interval of the current tab.
203 * It will be called by a viewer's hook function to update the
204 * time interval of the viewer and also be called by the constructor
205 * of the viewer.
206 * @param main_win the main window the viewer belongs to.
207 * @param time_interval a pointer where time interval will be stored.
208 */
209
210 void GetTimeInterval(mainWindow *main_win, TimeInterval *time_interval)
211 {
212 time_interval->startTime = main_win->CurrentTab->startTime;
213 time_interval->endTime = main_win->CurrentTab->endTime;
214 }
215
216
217 /**
218 * Function to set the time interval of the current tab.
219 * It will be called by a viewer's signal handle associated with
220 * the move_slider signal
221 * @param main_win the main window the viewer belongs to.
222 * @param time_interval a pointer where time interval is stored.
223 */
224
225 void SetTimeInterval(mainWindow *main_win, TimeInterval *time_interval)
226 {
227 LttvAttributeValue value;
228 LttvHooks * tmp;
229 main_win->CurrentTab->startTime = time_interval->startTime;
230 main_win->CurrentTab->endTime = time_interval->endTime;
231 g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes,
232 "hooks/updatetimeinterval", LTTV_POINTER, &value));
233 tmp = (LttvHooks*)*(value.v_pointer);
234 if(tmp == NULL)return;
235 lttv_hooks_call(tmp, time_interval);
236 }
237
238
239 /**
240 * Function to get the current time/event of the current tab.
241 * It will be called by a viewer's hook function to update the
242 * current time/event of the viewer.
243 * @param main_win the main window the viewer belongs to.
244 * @param time a pointer where time will be stored.
245 */
246
247 void GetCurrentTime(mainWindow *main_win, LttTime *time)
248 {
249 time = &main_win->CurrentTab->currentTime;
250 }
251
252
253 /**
254 * Function to set the current time/event of the current tab.
255 * It will be called by a viewer's signal handle associated with
256 * the button-release-event signal
257 * @param main_win the main window the viewer belongs to.
258 * @param time a pointer where time is stored.
259 */
260
261 void SetCurrentTime(mainWindow *main_win, LttTime *time)
262 {
263 LttvAttributeValue value;
264 LttvHooks * tmp;
265 main_win->CurrentTab->currentTime = *time;
266 g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes,
267 "hooks/updatecurrenttime", LTTV_POINTER, &value));
268 tmp = (LttvHooks*)*(value.v_pointer);
269
270 if(tmp == NULL)return;
271 lttv_hooks_call(tmp, time);
272 }
273
274
275 /**
276 * Function to get the traceset from the current tab.
277 * It will be called by the constructor of the viewer and also be
278 * called by a hook funtion of the viewer to update its traceset.
279 * @param main_win the main window the viewer belongs to.
280 * @param traceset a pointer to a traceset.
281 */
282 /*
283 void GetTraceset(mainWindow *main_win, Traceset *traceset)
284 {
285 }
286 */
287
288 /**
289 * Function to get the filter of the current tab.
290 * It will be called by the constructor of the viewer and also be
291 * called by a hook funtion of the viewer to update its filter.
292 * @param main_win, the main window the viewer belongs to.
293 * @param filter, a pointer to a filter.
294 */
295 /*
296 void GetFilter(mainWindow *main_win, Filter *filter)
297 {
298 }
299 */
300
301 /**
302 * Function to register a hook function for a viewer to set/update its
303 * time interval.
304 * It will be called by the constructor of the viewer.
305 * @param hook hook function of the viewer.
306 * @param hook_data hook data associated with the hook function.
307 * @param main_win the main window the viewer belongs to.
308 */
309
310 void RegUpdateTimeInterval(LttvHook hook, gpointer hook_data,
311 mainWindow * main_win)
312 {
313 LttvAttributeValue value;
314 LttvHooks * tmp;
315 g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes,
316 "hooks/updatetimeinterval", LTTV_POINTER, &value));
317 tmp = (LttvHooks*)*(value.v_pointer);
318 if(tmp == NULL){
319 tmp = lttv_hooks_new();
320 *(value.v_pointer) = tmp;
321 }
322 lttv_hooks_add(tmp, hook,hook_data);
323 }
324
325
326 /**
327 * Function to unregister a viewer's hook function which is used to
328 * set/update the time interval of the viewer.
329 * It will be called by the destructor of the viewer.
330 * @param hook hook function of the viewer.
331 * @param hook_data hook data associated with the hook function.
332 * @param main_win the main window the viewer belongs to.
333 */
334
335 void UnregUpdateTimeInterval(LttvHook hook, gpointer hook_data,
336 mainWindow * main_win)
337 {
338 LttvAttributeValue value;
339 LttvHooks * tmp;
340 g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes,
341 "hooks/updatetimeinterval", LTTV_POINTER, &value));
342 tmp = (LttvHooks*)*(value.v_pointer);
343 if(tmp == NULL) return;
344 lttv_hooks_remove_data(tmp, hook, hook_data);
345 }
346
347
348 /**
349 * Function to register a hook function for a viewer to set/update its
350 * traceset.
351 * It will be called by the constructor of the viewer.
352 * @param hook hook function of the viewer.
353 * @param hook_data hook data associated with the hook function.
354 * @param main_win the main window the viewer belongs to.
355 */
356
357 void RegUpdateTraceset(LttvHook hook, gpointer hook_data,
358 mainWindow * main_win)
359 {
360 LttvAttributeValue value;
361 LttvHooks * tmp;
362 g_assert(lttv_iattribute_find_by_path(main_win->Attributes,
363 "hooks/updatetraceset", LTTV_POINTER, &value));
364 tmp = (LttvHooks*)*(value.v_pointer);
365 if(tmp == NULL){
366 tmp = lttv_hooks_new();
367 *(value.v_pointer) = tmp;
368 }
369 lttv_hooks_add(tmp, hook, hook_data);
370 }
371
372
373 /**
374 * Function to unregister a viewer's hook function which is used to
375 * set/update the traceset of the viewer.
376 * It will be called by the destructor of the viewer.
377 * @param hook hook function of the viewer.
378 * @param hook_data hook data associated with the hook function.
379 * @param main_win the main window the viewer belongs to.
380 */
381
382 void UnregUpdateTraceset(LttvHook hook, gpointer hook_data,
383 mainWindow * main_win)
384 {
385 LttvAttributeValue value;
386 LttvHooks * tmp;
387 g_assert(lttv_iattribute_find_by_path(main_win->Attributes,
388 "hooks/updatetraceset", LTTV_POINTER, &value));
389 tmp = (LttvHooks*)*(value.v_pointer);
390 if(tmp == NULL) return;
391 lttv_hooks_remove_data(tmp, hook, hook_data);
392 }
393
394
395 /**
396 * Function to register a hook function for a viewer to set/update its
397 * filter.
398 * It will be called by the constructor of the viewer.
399 * @param hook hook function of the viewer.
400 * @param hook_data hook data associated with the hook function.
401 * @param main_win the main window the viewer belongs to.
402 */
403
404 void RegUpdateFilter(LttvHook hook, gpointer hook_data,
405 mainWindow *main_win)
406 {
407 LttvAttributeValue value;
408 LttvHooks * tmp;
409 g_assert(lttv_iattribute_find_by_path(main_win->Attributes,
410 "hooks/updatefilter", LTTV_POINTER, &value));
411 tmp = (LttvHooks*)*(value.v_pointer);
412 if(tmp == NULL){
413 tmp = lttv_hooks_new();
414 *(value.v_pointer) = tmp;
415 }
416 lttv_hooks_add(tmp, hook, hook_data);
417 }
418
419
420 /**
421 * Function to unregister a viewer's hook function which is used to
422 * set/update the filter of the viewer.
423 * It will be called by the destructor of the viewer.
424 * @param hook hook function of the viewer.
425 * @param hook_data hook data associated with the hook function.
426 * @param main_win the main window the viewer belongs to.
427 */
428
429 void UnregUpdateFilter(LttvHook hook, gpointer hook_data,
430 mainWindow * main_win)
431 {
432 LttvAttributeValue value;
433 LttvHooks * tmp;
434 g_assert(lttv_iattribute_find_by_path(main_win->Attributes,
435 "hooks/updatefilter", LTTV_POINTER, &value));
436 tmp = (LttvHooks*)*(value.v_pointer);
437 if(tmp == NULL) return;
438 lttv_hooks_remove_data(tmp, hook, hook_data);
439 }
440
441
442 /**
443 * Function to register a hook function for a viewer to set/update its
444 * current time.
445 * It will be called by the constructor of the viewer.
446 * @param hook hook function of the viewer.
447 * @param hook_data hook data associated with the hook function.
448 * @param main_win the main window the viewer belongs to.
449 */
450
451 void RegUpdateCurrentTime(LttvHook hook, gpointer hook_data,
452 mainWindow *main_win)
453 {
454 LttvAttributeValue value;
455 LttvHooks * tmp;
456 g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes,
457 "hooks/updatecurrenttime", LTTV_POINTER, &value));
458 tmp = (LttvHooks*)*(value.v_pointer);
459 if(tmp == NULL){
460 tmp = lttv_hooks_new();
461 *(value.v_pointer) = tmp;
462 }
463 lttv_hooks_add(tmp, hook, hook_data);
464 }
465
466
467 /**
468 * Function to unregister a viewer's hook function which is used to
469 * set/update the current time of the viewer.
470 * It will be called by the destructor of the viewer.
471 * @param hook hook function of the viewer.
472 * @param hook_data hook data associated with the hook function.
473 * @param main_win the main window the viewer belongs to.
474 */
475
476 void UnregUpdateCurrentTime(LttvHook hook, gpointer hook_data,
477 mainWindow * main_win)
478 {
479 LttvAttributeValue value;
480 LttvHooks * tmp;
481 g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes,
482 "hooks/updatecurrenttime", LTTV_POINTER, &value));
483 tmp = (LttvHooks*)*(value.v_pointer);
484 if(tmp == NULL) return;
485 lttv_hooks_remove_data(tmp, hook, hook_data);
486 }
487
488
489 /**
490 * Function to set the focused pane (viewer).
491 * It will be called by a viewer's signal handle associated with
492 * the grab_focus signal
493 * @param main_win the main window the viewer belongs to.
494 * @param paned a pointer to a pane where the viewer is contained.
495 */
496
497 void SetFocusedPane(mainWindow *main_win, gpointer paned)
498 {
499 gtk_custom_set_focus((GtkWidget*)main_win->CurrentTab->custom,paned);
500 }
501
502
503 /**
504 * Function to register a hook function for a viewer to set/update the
505 * dividor of the hpane.
506 * It will be called by the constructor of the viewer.
507 * @param hook hook function of the viewer.
508 * @param hook_data hook data associated with the hook function.
509 * @param main_win the main window the viewer belongs to.
510 */
511
512 void RegUpdateDividor(LttvHook hook, gpointer hook_data,
513 mainWindow *main_win)
514 {
515 LttvAttributeValue value;
516 LttvHooks * tmp;
517 g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes,
518 "hooks/hpanedividor", LTTV_POINTER, &value));
519 tmp = (LttvHooks*)*(value.v_pointer);
520 if(tmp == NULL){
521 tmp = lttv_hooks_new();
522 *(value.v_pointer) = tmp;
523 }
524 lttv_hooks_add(tmp, hook, hook_data);
525 }
526
527
528 /**
529 * Function to unregister a viewer's hook function which is used to
530 * set/update hpane's dividor of the viewer.
531 * It will be called by the destructor of the viewer.
532 * @param hook hook function of the viewer.
533 * @param hook_data hook data associated with the hook function.
534 * @param main_win the main window the viewer belongs to.
535 */
536
537 void UnregUpdateDividor(LttvHook hook, gpointer hook_data,
538 mainWindow *main_win)
539 {
540 LttvAttributeValue value;
541 LttvHooks * tmp;
542 g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes,
543 "hooks/hpanedividor", LTTV_POINTER, &value));
544 tmp = (LttvHooks*)*(value.v_pointer);
545 if(tmp == NULL) return;
546 lttv_hooks_remove_data(tmp, hook, hook_data);
547 }
548
549
550 /**
551 * Function to set the position of the hpane's dividor (viewer).
552 * It will be called by a viewer's signal handle associated with
553 * the motion_notify_event event/signal
554 * @param main_win the main window the viewer belongs to.
555 * @param position position of the hpane's dividor.
556 */
557
558 void SetHPaneDividor(mainWindow *main_win, gint position)
559 {
560 LttvAttributeValue value;
561 LttvHooks * tmp;
562 g_assert(lttv_iattribute_find_by_path(main_win->CurrentTab->Attributes,
563 "hooks/hpanedividor", LTTV_POINTER, &value));
564 tmp = (LttvHooks*)*(value.v_pointer);
565 if(tmp == NULL) return;
566 lttv_hooks_call(tmp, &position);
567 }
568
569
570 /**
571 * Function to process traceset. It will call lttv_process_trace,
572 * each view will call this api to get events.
573 * @param main_win the main window the viewer belongs to.
574 * @param start the start time of the first event to be processed.
575 * @param end the end time of the last event to be processed.
576 */
577
578 void processTraceset(mainWindow *main_win, LttTime start, LttTime end)
579 {
580 lttv_process_trace(start, end, main_win->traceset, main_win->traceset_context);
581 }
582
583 /**
584 * Function to add hooks into the context of a traceset,
585 * before reading events from traceset, viewer will call this api to
586 * register hooks
587 * @param main_win the main window the viewer belongs to.
588 * @param LttvHooks hooks to be registered.
589 */
590
591 void contextAddHooks(mainWindow *main_win ,
592 LttvHooks *before_traceset,
593 LttvHooks *after_traceset,
594 LttvHooks *check_trace,
595 LttvHooks *before_trace,
596 LttvHooks *after_trace,
597 LttvHooks *check_tracefile,
598 LttvHooks *before_tracefile,
599 LttvHooks *after_tracefile,
600 LttvHooks *check_event,
601 LttvHooks *before_event,
602 LttvHooks *after_event)
603 {
604 LttvTracesetContext * tsc = main_win->traceset_context;
605 lttv_traceset_context_add_hooks(tsc,before_traceset,after_traceset,
606 check_trace,before_trace,after_trace,
607 check_tracefile,before_tracefile,after_tracefile,
608 check_event,before_event, after_event);
609 }
610
611
612 /**
613 * Function to remove hooks from the context of a traceset,
614 * before reading events from traceset, viewer will call this api to
615 * unregister hooks
616 * @param main_win the main window the viewer belongs to.
617 * @param LttvHooks hooks to be registered.
618 */
619
620 void contextRemoveHooks(mainWindow *main_win ,
621 LttvHooks *before_traceset,
622 LttvHooks *after_traceset,
623 LttvHooks *check_trace,
624 LttvHooks *before_trace,
625 LttvHooks *after_trace,
626 LttvHooks *check_tracefile,
627 LttvHooks *before_tracefile,
628 LttvHooks *after_tracefile,
629 LttvHooks *check_event,
630 LttvHooks *before_event,
631 LttvHooks *after_event)
632 {
633 LttvTracesetContext * tsc = main_win->traceset_context;
634 lttv_traceset_context_remove_hooks(tsc,before_traceset,after_traceset,
635 check_trace,before_trace,after_trace,
636 check_tracefile,before_tracefile,after_tracefile,
637 check_event,before_event, after_event);
638 }
This page took 0.04167 seconds and 4 git commands to generate.