1 /*! \file gtkTraceSet.h
2 * \brief API used by the graphical viewers to interact with their top window.
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
7 * This header file should be included in each graphic module.
8 * This library is used by graphical modules to interact with the
15 #include <lttv/lttv.h>
16 #include <lttv/mainWindow.h>
17 #include <lttv/gtkTraceSet.h>
18 #include <lttv/processTrace.h>
23 * Internal function parts
27 * Function to remove toolbar from the GUI
28 * @param view_constructor constructor of the viewer.
31 void RemoveToolbar(void *view_constructor
)
33 g_printf("Toolbar for the viewer will be removed\n");
37 * Function to remove menu entry from the GUI
38 * @param view_constructor constructor of the viewer.
41 void RemoveMenu(void *view_constructor
)
43 g_printf("Menu entry for the viewer will be removed\n");
48 * Function to set/update traceset for the viewers
49 * @param main_win main window
50 * @param traceset traceset of the main window.
53 void SetTraceset(mainWindow
* main_win
, gpointer traceset
)
56 LttvAttributeValue value
;
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
);
67 * Function to set/update filter for the viewers
68 * @param main_win main window
69 * @param filter filter of the main window.
72 void SetFilter(mainWindow
* main_win
, gpointer filter
)
75 LttvAttributeValue value
;
77 g_assert(lttv_iattribute_find_by_path(main_win
->Attributes
,
78 "hooks/updatefilter", LTTV_POINTER
, &value
));
79 tmp
= (LttvHooks
*)*(value
.v_pointer
);
81 if(tmp
== NULL
)return;
82 lttv_hooks_call(tmp
,filter
);
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.
100 void ToolbarItemReg(GdkPixmap
* pixmap
, char *tooltip
, void *view_constructor
)
102 LttvIAttribute
*attributes_global
= LTTV_IATTRIBUTE(lttv_global_attributes());
103 LttvToolbars
* toolbar
;
104 LttvAttributeValue value
;
106 g_assert(lttv_iattribute_find_by_path(attributes_global
,
107 "viewers/toolbar", LTTV_POINTER
, &value
));
108 toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
111 toolbar
= lttv_toolbars_new();
112 *(value
.v_pointer
) = toolbar
;
114 lttv_toolbars_add(toolbar
, view_constructor
, tooltip
, pixmap
);
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.
126 void ToolbarItemUnreg(void *view_constructor
)
128 LttvIAttribute
*attributes_global
= LTTV_IATTRIBUTE(lttv_global_attributes());
129 LttvToolbars
* toolbar
;
130 LttvAttributeValue value
;
132 g_assert(lttv_iattribute_find_by_path(attributes_global
,
133 "viewers/toolbar", LTTV_POINTER
, &value
));
134 toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
136 if(lttv_toolbars_remove(toolbar
, view_constructor
))
137 RemoveToolbar(view_constructor
);
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.
150 void MenuItemReg(char *menu_path
, char *menu_text
, void *view_constructor
)
152 LttvIAttribute
*attributes_global
= LTTV_IATTRIBUTE(lttv_global_attributes());
154 LttvAttributeValue value
;
156 g_assert(lttv_iattribute_find_by_path(attributes_global
,
157 "viewers/menu", LTTV_POINTER
, &value
));
158 menu
= (LttvMenus
*)*(value
.v_pointer
);
161 menu
= lttv_menus_new();
162 *(value
.v_pointer
) = menu
;
164 lttv_menus_add(menu
, view_constructor
, menu_path
, menu_text
);
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.
175 void MenuItemUnreg(void *view_constructor
)
177 LttvIAttribute
*attributes_global
= LTTV_IATTRIBUTE(lttv_global_attributes());
179 LttvAttributeValue value
;
181 g_assert(lttv_iattribute_find_by_path(attributes_global
,
182 "viewers/menu", LTTV_POINTER
, &value
));
183 menu
= (LttvMenus
*)*(value
.v_pointer
);
185 if(lttv_menus_remove(menu
, view_constructor
))
186 RemoveMenu(view_constructor
);
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.
196 void UpdateStatus(mainWindow
*main_win
, char *info
)
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
206 * @param main_win the main window the viewer belongs to.
207 * @param time_interval a pointer where time interval will be stored.
210 void GetTimeInterval(mainWindow
*main_win
, TimeInterval
*time_interval
)
212 time_interval
->startTime
= main_win
->CurrentTab
->startTime
;
213 time_interval
->endTime
= main_win
->CurrentTab
->endTime
;
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.
225 void SetTimeInterval(mainWindow
*main_win
, TimeInterval
*time_interval
)
227 LttvAttributeValue value
;
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
);
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.
247 void GetCurrentTime(mainWindow
*main_win
, LttTime
*time
)
249 time
= &main_win
->CurrentTab
->currentTime
;
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.
261 void SetCurrentTime(mainWindow
*main_win
, LttTime
*time
)
263 LttvAttributeValue value
;
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
);
270 if(tmp
== NULL
)return;
271 lttv_hooks_call(tmp
, time
);
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.
283 void GetTraceset(mainWindow *main_win, Traceset *traceset)
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.
296 void GetFilter(mainWindow *main_win, Filter *filter)
302 * Function to register a hook function for a viewer to set/update its
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.
310 void RegUpdateTimeInterval(LttvHook hook
, gpointer hook_data
,
311 mainWindow
* main_win
)
313 LttvAttributeValue value
;
315 g_assert(lttv_iattribute_find_by_path(main_win
->CurrentTab
->Attributes
,
316 "hooks/updatetimeinterval", LTTV_POINTER
, &value
));
317 tmp
= (LttvHooks
*)*(value
.v_pointer
);
319 tmp
= lttv_hooks_new();
320 *(value
.v_pointer
) = tmp
;
322 lttv_hooks_add(tmp
, hook
,hook_data
);
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.
335 void UnregUpdateTimeInterval(LttvHook hook
, gpointer hook_data
,
336 mainWindow
* main_win
)
338 LttvAttributeValue value
;
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
);
349 * Function to register a hook function for a viewer to set/update its
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.
357 void RegUpdateTraceset(LttvHook hook
, gpointer hook_data
,
358 mainWindow
* main_win
)
360 LttvAttributeValue value
;
362 g_assert(lttv_iattribute_find_by_path(main_win
->Attributes
,
363 "hooks/updatetraceset", LTTV_POINTER
, &value
));
364 tmp
= (LttvHooks
*)*(value
.v_pointer
);
366 tmp
= lttv_hooks_new();
367 *(value
.v_pointer
) = tmp
;
369 lttv_hooks_add(tmp
, hook
, hook_data
);
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.
382 void UnregUpdateTraceset(LttvHook hook
, gpointer hook_data
,
383 mainWindow
* main_win
)
385 LttvAttributeValue value
;
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
);
396 * Function to register a hook function for a viewer to set/update its
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.
404 void RegUpdateFilter(LttvHook hook
, gpointer hook_data
,
405 mainWindow
*main_win
)
407 LttvAttributeValue value
;
409 g_assert(lttv_iattribute_find_by_path(main_win
->Attributes
,
410 "hooks/updatefilter", LTTV_POINTER
, &value
));
411 tmp
= (LttvHooks
*)*(value
.v_pointer
);
413 tmp
= lttv_hooks_new();
414 *(value
.v_pointer
) = tmp
;
416 lttv_hooks_add(tmp
, hook
, hook_data
);
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.
429 void UnregUpdateFilter(LttvHook hook
, gpointer hook_data
,
430 mainWindow
* main_win
)
432 LttvAttributeValue value
;
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
);
443 * Function to register a hook function for a viewer to set/update its
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.
451 void RegUpdateCurrentTime(LttvHook hook
, gpointer hook_data
,
452 mainWindow
*main_win
)
454 LttvAttributeValue value
;
456 g_assert(lttv_iattribute_find_by_path(main_win
->CurrentTab
->Attributes
,
457 "hooks/updatecurrenttime", LTTV_POINTER
, &value
));
458 tmp
= (LttvHooks
*)*(value
.v_pointer
);
460 tmp
= lttv_hooks_new();
461 *(value
.v_pointer
) = tmp
;
463 lttv_hooks_add(tmp
, hook
, hook_data
);
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.
476 void UnregUpdateCurrentTime(LttvHook hook
, gpointer hook_data
,
477 mainWindow
* main_win
)
479 LttvAttributeValue value
;
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
);
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.
497 void SetFocusedPane(mainWindow
*main_win
, gpointer paned
)
499 gtk_custom_set_focus((GtkWidget
*)main_win
->CurrentTab
->custom
,paned
);
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.
512 void RegUpdateDividor(LttvHook hook
, gpointer hook_data
,
513 mainWindow
*main_win
)
515 LttvAttributeValue value
;
517 g_assert(lttv_iattribute_find_by_path(main_win
->CurrentTab
->Attributes
,
518 "hooks/hpanedividor", LTTV_POINTER
, &value
));
519 tmp
= (LttvHooks
*)*(value
.v_pointer
);
521 tmp
= lttv_hooks_new();
522 *(value
.v_pointer
) = tmp
;
524 lttv_hooks_add(tmp
, hook
, hook_data
);
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.
537 void UnregUpdateDividor(LttvHook hook
, gpointer hook_data
,
538 mainWindow
*main_win
)
540 LttvAttributeValue value
;
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
);
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.
558 void SetHPaneDividor(mainWindow
*main_win
, gint position
)
560 LttvAttributeValue value
;
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
);
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.
578 void processTraceset(mainWindow
*main_win
, LttTime start
, LttTime end
)
580 lttv_process_trace(start
, end
, main_win
->traceset
, main_win
->traceset_context
);
584 * Function to add hooks into the context of a traceset,
585 * before reading events from traceset, viewer will call this api to
587 * @param main_win the main window the viewer belongs to.
588 * @param LttvHooks hooks to be registered.
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
)
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
);
613 * Function to remove hooks from the context of a traceset,
614 * before reading events from traceset, viewer will call this api to
616 * @param main_win the main window the viewer belongs to.
617 * @param LttvHooks hooks to be registered.
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
)
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
);
This page took 0.043115 seconds and 4 git commands to generate.