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