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 | |
36b40c74 |
19 | /*! \file lttvviewer.c |
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 | |
13f86ce2 |
31 | #include <lttvwindow/common.h> |
561f5852 |
32 | #include <ltt/ltt.h> |
33 | #include <lttv/lttv.h> |
13f86ce2 |
34 | #include <lttvwindow/mainwindow.h> |
36b40c74 |
35 | #include <lttvwindow/viewer.h> |
d8f124de |
36 | #include <lttv/tracecontext.h> |
13f86ce2 |
37 | #include <lttvwindow/toolbar.h> |
38 | #include <lttvwindow/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. |
224446ce |
51 | * return value : |
52 | * -1 : error |
53 | * 0 : traceset updated |
54 | * 1 : no traceset hooks to update; not an error. |
561f5852 |
55 | */ |
56 | |
224446ce |
57 | int SetTraceset(MainWindow * main_win, gpointer traceset) |
561f5852 |
58 | { |
59 | LttvHooks * tmp; |
60 | LttvAttributeValue value; |
61 | |
224446ce |
62 | if( lttv_iattribute_find_by_path(main_win->attributes, |
63 | "hooks/updatetraceset", LTTV_POINTER, &value) != 0) |
64 | return -1; |
65 | |
561f5852 |
66 | tmp = (LttvHooks*)*(value.v_pointer); |
224446ce |
67 | if(tmp == NULL) return 1; |
68 | |
561f5852 |
69 | lttv_hooks_call(tmp,traceset); |
224446ce |
70 | |
71 | return 0; |
561f5852 |
72 | } |
73 | |
74 | |
75 | /** |
76 | * Function to set/update filter for the viewers |
77 | * @param main_win main window |
78 | * @param filter filter of the main window. |
224446ce |
79 | * return value : |
80 | * -1 : error |
81 | * 0 : filters updated |
82 | * 1 : no filter hooks to update; not an error. |
561f5852 |
83 | */ |
84 | |
224446ce |
85 | int SetFilter(MainWindow * main_win, gpointer filter) |
561f5852 |
86 | { |
87 | LttvHooks * tmp; |
88 | LttvAttributeValue value; |
89 | |
224446ce |
90 | if(lttv_iattribute_find_by_path(main_win->attributes, |
91 | "hooks/updatefilter", LTTV_POINTER, &value) != 0) |
92 | return -1; |
93 | |
561f5852 |
94 | tmp = (LttvHooks*)*(value.v_pointer); |
95 | |
224446ce |
96 | if(tmp == NULL) return 1; |
561f5852 |
97 | lttv_hooks_call(tmp,filter); |
224446ce |
98 | |
99 | return 0; |
100 | } |
101 | |
102 | /** |
103 | * Function to redraw each viewer belonging to the current tab |
104 | * @param main_win the main window the viewer belongs to. |
105 | */ |
106 | |
107 | void update_traceset(MainWindow * main_win) |
108 | { |
109 | LttvAttributeValue value; |
110 | LttvHooks * tmp; |
111 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
112 | "hooks/updatetraceset", LTTV_POINTER, &value)); |
113 | tmp = (LttvHooks*)*(value.v_pointer); |
114 | if(tmp == NULL) return; |
115 | lttv_hooks_call(tmp, NULL); |
116 | } |
117 | |
118 | |
119 | |
120 | /** |
121 | * Function to show each viewer in the current tab. |
122 | * It will be called by main window after it called process_traceset |
123 | * @param main_win the main window the viewer belongs to. |
124 | */ |
125 | |
126 | void show_viewer(MainWindow *main_win) |
127 | { |
128 | LttvAttributeValue value; |
129 | LttvHooks * tmp; |
130 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
131 | "hooks/showviewer", LTTV_POINTER, &value)); |
132 | tmp = (LttvHooks*)*(value.v_pointer); |
133 | if(tmp == NULL) return; |
134 | lttv_hooks_call(tmp, NULL); |
561f5852 |
135 | } |
136 | |
137 | |
138 | |
224446ce |
139 | |
561f5852 |
140 | /** |
141 | * API parts |
142 | */ |
143 | |
144 | /** |
145 | * Function to register a view constructor so that main window can generate |
146 | * a toolbar item for the viewer in order to generate a new instance easily. |
147 | * It will be called by init function of the module. |
148 | * @param ButtonPixmap image shown on the toolbar item. |
149 | * @param tooltip tooltip of the toolbar item. |
150 | * @param view_constructor constructor of the viewer. |
151 | */ |
152 | |
224446ce |
153 | void lttvwindow_register_toolbar(char ** pixmap, char *tooltip, lttvwindow_viewer_constructor view_constructor) |
561f5852 |
154 | { |
155 | LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes()); |
156 | LttvToolbars * toolbar; |
157 | LttvAttributeValue value; |
158 | |
159 | g_assert(lttv_iattribute_find_by_path(attributes_global, |
d2811a98 |
160 | "viewers/toolbar", LTTV_POINTER, &value)); |
561f5852 |
161 | toolbar = (LttvToolbars*)*(value.v_pointer); |
162 | |
224446ce |
163 | if(toolbar == NULL){ |
561f5852 |
164 | toolbar = lttv_toolbars_new(); |
165 | *(value.v_pointer) = toolbar; |
166 | } |
167 | lttv_toolbars_add(toolbar, view_constructor, tooltip, pixmap); |
168 | } |
169 | |
170 | |
171 | /** |
172 | * Function to unregister the viewer's constructor, release the space |
173 | * occupied by pixmap, tooltip and constructor of the viewer. |
174 | * It will be called when a module is unloaded. |
175 | * @param view_constructor constructor of the viewer which is used as |
176 | * a reference to find out where the pixmap and tooltip are. |
177 | */ |
178 | |
224446ce |
179 | void lttvwindow_unregister_toolbar(lttvwindow_viewer_constructor view_constructor) |
561f5852 |
180 | { |
181 | LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes()); |
182 | LttvToolbars * toolbar; |
183 | LttvAttributeValue value; |
184 | |
185 | g_assert(lttv_iattribute_find_by_path(attributes_global, |
d2811a98 |
186 | "viewers/toolbar", LTTV_POINTER, &value)); |
561f5852 |
187 | toolbar = (LttvToolbars*)*(value.v_pointer); |
188 | |
2061e03d |
189 | main_window_remove_toolbar_item(view_constructor); |
190 | |
191 | lttv_toolbars_remove(toolbar, view_constructor); |
561f5852 |
192 | } |
193 | |
194 | |
195 | /** |
196 | * Function to register a view constructor so that main window can generate |
197 | * a menu item for the viewer in order to generate a new instance easily. |
198 | * It will be called by init function of the module. |
199 | * @param menu_path path of the menu item. |
200 | * @param menu_text text of the menu item. |
201 | * @param view_constructor constructor of the viewer. |
202 | */ |
203 | |
224446ce |
204 | void lttvwindow_register_menu(char *menu_path, char *menu_text, lttvwindow_viewer_constructor view_constructor) |
561f5852 |
205 | { |
206 | LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes()); |
207 | LttvMenus * menu; |
208 | LttvAttributeValue value; |
209 | |
210 | g_assert(lttv_iattribute_find_by_path(attributes_global, |
d2811a98 |
211 | "viewers/menu", LTTV_POINTER, &value)); |
561f5852 |
212 | menu = (LttvMenus*)*(value.v_pointer); |
213 | |
214 | if(menu == NULL){ |
215 | menu = lttv_menus_new(); |
216 | *(value.v_pointer) = menu; |
217 | } |
218 | lttv_menus_add(menu, view_constructor, menu_path, menu_text); |
219 | } |
220 | |
221 | /** |
222 | * Function to unregister the viewer's constructor, release the space |
223 | * occupied by menu_path, menu_text and constructor of the viewer. |
224 | * It will be called when a module is unloaded. |
225 | * @param view_constructor constructor of the viewer which is used as |
226 | * a reference to find out where the menu_path and menu_text are. |
227 | */ |
228 | |
224446ce |
229 | void lttvwindow_unregister_menu(lttvwindow_viewer_constructor view_constructor) |
561f5852 |
230 | { |
231 | LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes()); |
232 | LttvMenus * menu; |
233 | LttvAttributeValue value; |
234 | |
235 | g_assert(lttv_iattribute_find_by_path(attributes_global, |
c4c15b5e |
236 | "viewers/menu", LTTV_POINTER, &value)); |
561f5852 |
237 | menu = (LttvMenus*)*(value.v_pointer); |
238 | |
2061e03d |
239 | main_window_remove_menu_item(view_constructor); |
240 | |
241 | lttv_menus_remove(menu, view_constructor); |
561f5852 |
242 | } |
243 | |
561f5852 |
244 | /** |
245 | * Function to register a hook function for a viewer to set/update its |
246 | * time interval. |
561f5852 |
247 | * @param hook hook function of the viewer. |
248 | * @param hook_data hook data associated with the hook function. |
249 | * @param main_win the main window the viewer belongs to. |
250 | */ |
224446ce |
251 | void lttvwindow_register_time_window_notify(MainWindow * main_win, |
252 | LttvHook hook, gpointer hook_data) |
561f5852 |
253 | { |
254 | LttvAttributeValue value; |
255 | LttvHooks * tmp; |
bca3b81f |
256 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
d2811a98 |
257 | "hooks/updatetimewindow", LTTV_POINTER, &value)); |
561f5852 |
258 | tmp = (LttvHooks*)*(value.v_pointer); |
259 | if(tmp == NULL){ |
260 | tmp = lttv_hooks_new(); |
261 | *(value.v_pointer) = tmp; |
262 | } |
263 | lttv_hooks_add(tmp, hook,hook_data); |
264 | } |
265 | |
266 | |
267 | /** |
268 | * Function to unregister a viewer's hook function which is used to |
269 | * set/update the time interval of the viewer. |
561f5852 |
270 | * @param hook hook function of the viewer. |
271 | * @param hook_data hook data associated with the hook function. |
272 | * @param main_win the main window the viewer belongs to. |
273 | */ |
274 | |
224446ce |
275 | void lttvwindow_unregister_time_window_notify(MainWindow * main_win, |
276 | LttvHook hook, gpointer hook_data) |
561f5852 |
277 | { |
278 | LttvAttributeValue value; |
279 | LttvHooks * tmp; |
bca3b81f |
280 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
d2811a98 |
281 | "hooks/updatetimewindow", LTTV_POINTER, &value)); |
561f5852 |
282 | tmp = (LttvHooks*)*(value.v_pointer); |
283 | if(tmp == NULL) return; |
284 | lttv_hooks_remove_data(tmp, hook, hook_data); |
285 | } |
286 | |
561f5852 |
287 | /** |
288 | * Function to register a hook function for a viewer to set/update its |
289 | * traceset. |
561f5852 |
290 | * @param hook hook function of the viewer. |
291 | * @param hook_data hook data associated with the hook function. |
292 | * @param main_win the main window the viewer belongs to. |
293 | */ |
294 | |
224446ce |
295 | void lttvwindow_register_traceset_notify(MainWindow * main_win, |
296 | LttvHook hook, gpointer hook_data) |
561f5852 |
297 | { |
298 | LttvAttributeValue value; |
299 | LttvHooks * tmp; |
a8c0f09d |
300 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
d2811a98 |
301 | "hooks/updatetraceset", LTTV_POINTER, &value)); |
561f5852 |
302 | tmp = (LttvHooks*)*(value.v_pointer); |
303 | if(tmp == NULL){ |
304 | tmp = lttv_hooks_new(); |
305 | *(value.v_pointer) = tmp; |
306 | } |
307 | lttv_hooks_add(tmp, hook, hook_data); |
308 | } |
309 | |
310 | |
311 | /** |
312 | * Function to unregister a viewer's hook function which is used to |
313 | * set/update the traceset of the viewer. |
561f5852 |
314 | * @param hook hook function of the viewer. |
315 | * @param hook_data hook data associated with the hook function. |
316 | * @param main_win the main window the viewer belongs to. |
317 | */ |
318 | |
224446ce |
319 | void lttvwindow_unregister_traceset_notify(MainWindow * main_win, |
320 | LttvHook hook, gpointer hook_data) |
561f5852 |
321 | { |
322 | LttvAttributeValue value; |
323 | LttvHooks * tmp; |
a8c0f09d |
324 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
d2811a98 |
325 | "hooks/updatetraceset", LTTV_POINTER, &value)); |
561f5852 |
326 | tmp = (LttvHooks*)*(value.v_pointer); |
327 | if(tmp == NULL) return; |
328 | lttv_hooks_remove_data(tmp, hook, hook_data); |
329 | } |
330 | |
561f5852 |
331 | /** |
332 | * Function to register a hook function for a viewer to set/update its |
333 | * filter. |
561f5852 |
334 | * @param hook hook function of the viewer. |
335 | * @param hook_data hook data associated with the hook function. |
336 | * @param main_win the main window the viewer belongs to. |
337 | */ |
338 | |
224446ce |
339 | void lttvwindow_register_filter_notify(MainWindow *main_win, |
340 | LttvHook hook, gpointer hook_data) |
561f5852 |
341 | { |
342 | LttvAttributeValue value; |
343 | LttvHooks * tmp; |
bca3b81f |
344 | g_assert(lttv_iattribute_find_by_path(main_win->attributes, |
d2811a98 |
345 | "hooks/updatefilter", LTTV_POINTER, &value)); |
561f5852 |
346 | tmp = (LttvHooks*)*(value.v_pointer); |
347 | if(tmp == NULL){ |
348 | tmp = lttv_hooks_new(); |
349 | *(value.v_pointer) = tmp; |
350 | } |
351 | lttv_hooks_add(tmp, hook, hook_data); |
352 | } |
353 | |
354 | |
355 | /** |
356 | * Function to unregister a viewer's hook function which is used to |
357 | * set/update the filter of the viewer. |
561f5852 |
358 | * @param hook hook function of the viewer. |
359 | * @param hook_data hook data associated with the hook function. |
360 | * @param main_win the main window the viewer belongs to. |
361 | */ |
362 | |
224446ce |
363 | void lttvwindow_unregister_filter_notify(LttvHook hook, gpointer hook_data, |
364 | MainWindow * main_win) |
561f5852 |
365 | { |
366 | LttvAttributeValue value; |
367 | LttvHooks * tmp; |
bca3b81f |
368 | g_assert(lttv_iattribute_find_by_path(main_win->attributes, |
d2811a98 |
369 | "hooks/updatefilter", LTTV_POINTER, &value)); |
561f5852 |
370 | tmp = (LttvHooks*)*(value.v_pointer); |
371 | if(tmp == NULL) return; |
372 | lttv_hooks_remove_data(tmp, hook, hook_data); |
373 | } |
374 | |
375 | |
376 | /** |
377 | * Function to register a hook function for a viewer to set/update its |
378 | * current time. |
561f5852 |
379 | * @param hook hook function of the viewer. |
380 | * @param hook_data hook data associated with the hook function. |
381 | * @param main_win the main window the viewer belongs to. |
382 | */ |
383 | |
224446ce |
384 | void lttvwindow_register_current_time_notify(MainWindow *main_win, |
385 | LttvHook hook, gpointer hook_data) |
561f5852 |
386 | { |
387 | LttvAttributeValue value; |
388 | LttvHooks * tmp; |
bca3b81f |
389 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
d2811a98 |
390 | "hooks/updatecurrenttime", LTTV_POINTER, &value)); |
561f5852 |
391 | tmp = (LttvHooks*)*(value.v_pointer); |
392 | if(tmp == NULL){ |
393 | tmp = lttv_hooks_new(); |
394 | *(value.v_pointer) = tmp; |
395 | } |
396 | lttv_hooks_add(tmp, hook, hook_data); |
397 | } |
398 | |
399 | |
400 | /** |
401 | * Function to unregister a viewer's hook function which is used to |
402 | * set/update the current time of the viewer. |
561f5852 |
403 | * @param hook hook function of the viewer. |
404 | * @param hook_data hook data associated with the hook function. |
405 | * @param main_win the main window the viewer belongs to. |
406 | */ |
407 | |
224446ce |
408 | void lttvwindow_unregister_current_time_notify(MainWindow * main_win, |
409 | LttvHook hook, gpointer hook_data) |
561f5852 |
410 | { |
411 | LttvAttributeValue value; |
412 | LttvHooks * tmp; |
bca3b81f |
413 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
d2811a98 |
414 | "hooks/updatecurrenttime", LTTV_POINTER, &value)); |
561f5852 |
415 | tmp = (LttvHooks*)*(value.v_pointer); |
416 | if(tmp == NULL) return; |
417 | lttv_hooks_remove_data(tmp, hook, hook_data); |
418 | } |
419 | |
420 | |
202f6c8f |
421 | /** |
422 | * Function to register a hook function for a viewer to show |
224446ce |
423 | * the content of the viewer. |
202f6c8f |
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 | |
224446ce |
429 | void lttvwindow_register_show(MainWindow *main_win, |
430 | LttvHook hook, gpointer hook_data) |
202f6c8f |
431 | { |
432 | LttvAttributeValue value; |
433 | LttvHooks * tmp; |
434 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
d2811a98 |
435 | "hooks/showviewer", LTTV_POINTER, &value)); |
202f6c8f |
436 | tmp = (LttvHooks*)*(value.v_pointer); |
437 | if(tmp == NULL){ |
438 | tmp = lttv_hooks_new(); |
439 | *(value.v_pointer) = tmp; |
440 | } |
441 | lttv_hooks_add(tmp, hook, hook_data); |
442 | } |
443 | |
444 | |
445 | /** |
446 | * Function to unregister a viewer's hook function which is used to |
447 | * show the content of the viewer.. |
202f6c8f |
448 | * @param hook hook function of the viewer. |
449 | * @param hook_data hook data associated with the hook function. |
450 | * @param main_win the main window the viewer belongs to. |
451 | */ |
452 | |
224446ce |
453 | void lttvwindow_unregister_show(MainWindow * main_win, |
454 | LttvHook hook, gpointer hook_data) |
202f6c8f |
455 | { |
456 | LttvAttributeValue value; |
457 | LttvHooks * tmp; |
458 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
d2811a98 |
459 | "hooks/showviewer", LTTV_POINTER, &value)); |
202f6c8f |
460 | tmp = (LttvHooks*)*(value.v_pointer); |
461 | if(tmp == NULL) return; |
462 | lttv_hooks_remove_data(tmp, hook, hook_data); |
463 | } |
464 | |
561f5852 |
465 | /** |
466 | * Function to register a hook function for a viewer to set/update the |
467 | * dividor of the hpane. |
561f5852 |
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 | |
224446ce |
473 | void lttvwindow_register_dividor(MainWindow *main_win, |
474 | LttvHook hook, gpointer hook_data) |
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/hpanedividor", 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 hpane's dividor 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 | |
224446ce |
498 | void lttvwindow_unregister_dividor(MainWindow *main_win, |
499 | LttvHook hook, gpointer hook_data) |
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/hpanedividor", 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 | |
224446ce |
511 | /** |
512 | * Update the status bar whenever something changed in the viewer. |
513 | * @param main_win the main window the viewer belongs to. |
514 | * @param info the message which will be shown in the status bar. |
515 | */ |
516 | |
517 | void lttvwindow_report_status(MainWindow *main_win, char *info) |
518 | { |
519 | //FIXME |
520 | g_warning("update_status not implemented in viewer.c"); |
521 | } |
522 | |
523 | /** |
524 | * Function to set the time interval of the current tab. |
525 | * It will be called by a viewer's signal handle associated with |
526 | * the move_slider signal |
527 | * @param main_win the main window the viewer belongs to. |
528 | * @param time_interval a pointer where time interval is stored. |
529 | */ |
530 | |
531 | void lttvwindow_report_time_window(MainWindow *main_win, |
532 | TimeWindow *time_window) |
533 | { |
534 | LttvAttributeValue value; |
535 | LttvHooks * tmp; |
536 | |
537 | TimeWindowNotifyData time_window_notify_data; |
538 | TimeWindow old_time_window = main_win->current_tab->time_window; |
539 | time_window_notify_data.old_time_window = &old_time_window; |
540 | main_win->current_tab->time_window = *time_window; |
541 | time_window_notify_data.new_time_window = |
542 | &(main_win->current_tab->time_window); |
543 | |
544 | gtk_multi_vpaned_set_scroll_value(main_win->current_tab->multi_vpaned, |
545 | ltt_time_to_double(time_window->start_time) |
546 | * NANOSECONDS_PER_SECOND ); |
547 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
548 | "hooks/updatetimewindow", LTTV_POINTER, &value)); |
549 | tmp = (LttvHooks*)*(value.v_pointer); |
550 | if(tmp == NULL) return; |
551 | lttv_hooks_call(tmp, &time_window_notify_data); |
552 | } |
553 | |
554 | /** |
555 | * Function to set the current time/event of the current tab. |
556 | * It will be called by a viewer's signal handle associated with |
557 | * the button-release-event signal |
558 | * @param main_win the main window the viewer belongs to. |
559 | * @param time a pointer where time is stored. |
560 | */ |
561 | |
562 | void lttvwindow_report_current_time(MainWindow *main_win, LttTime *time) |
563 | { |
564 | LttvAttributeValue value; |
565 | LttvHooks * tmp; |
566 | main_win->current_tab->current_time = *time; |
567 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
568 | "hooks/updatecurrenttime", LTTV_POINTER, &value)); |
569 | tmp = (LttvHooks*)*(value.v_pointer); |
570 | |
571 | if(tmp == NULL)return; |
572 | lttv_hooks_call(tmp, time); |
573 | } |
574 | |
561f5852 |
575 | /** |
576 | * Function to set the position of the hpane's dividor (viewer). |
577 | * It will be called by a viewer's signal handle associated with |
578 | * the motion_notify_event event/signal |
579 | * @param main_win the main window the viewer belongs to. |
580 | * @param position position of the hpane's dividor. |
581 | */ |
582 | |
224446ce |
583 | void lttvwindow_report_dividor(MainWindow *main_win, gint position) |
561f5852 |
584 | { |
585 | LttvAttributeValue value; |
586 | LttvHooks * tmp; |
bca3b81f |
587 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
d2811a98 |
588 | "hooks/hpanedividor", LTTV_POINTER, &value)); |
561f5852 |
589 | tmp = (LttvHooks*)*(value.v_pointer); |
590 | if(tmp == NULL) return; |
591 | lttv_hooks_call(tmp, &position); |
592 | } |
593 | |
224446ce |
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 | |
602 | void lttvwindow_report_focus(MainWindow *main_win, gpointer paned) |
603 | { |
604 | gtk_multi_vpaned_set_focus((GtkWidget*)main_win->current_tab->multi_vpaned,paned); |
605 | } |
606 | |
607 | |
608 | |
609 | /** |
610 | * Function to get the current time interval of the current traceset. |
611 | * It will be called by a viewer's hook function to update the |
612 | * time interval of the viewer and also be called by the constructor |
613 | * of the viewer. |
614 | * @param main_win the main window the viewer belongs to. |
615 | * @param time_interval a pointer where time interval will be stored. |
616 | */ |
617 | |
618 | const TimeInterval *lttvwindow_get_time_span(MainWindow *main_win) |
619 | { |
620 | //time_window->start_time = main_win->current_tab->time_window.start_time; |
621 | //time_window->time_width = main_win->current_tab->time_window.time_width; |
622 | return (LTTV_TRACESET_CONTEXT(main_win->current_tab->traceset_info-> |
623 | traceset_context)->Time_Span); |
624 | } |
625 | |
626 | |
627 | |
628 | /** |
629 | * Function to get the current time interval shown on the current tab. |
630 | * It will be called by a viewer's hook function to update the |
631 | * shown time interval of the viewer and also be called by the constructor |
632 | * of the viewer. |
633 | * @param main_win the main window the viewer belongs to. |
634 | * @param time_interval a pointer where time interval will be stored. |
635 | */ |
636 | |
637 | const TimeWindow *lttvwindow_get_time_window(MainWindow *main_win) |
638 | { |
639 | //time_window->start_time = main_win->current_tab->time_window.start_time; |
640 | //time_window->time_width = main_win->current_tab->time_window.time_width; |
641 | return &(main_win->current_tab->time_window); |
642 | |
643 | } |
644 | |
645 | |
646 | /** |
647 | * Function to get the current time/event of the current tab. |
648 | * It will be called by a viewer's hook function to update the |
649 | * current time/event of the viewer. |
650 | * @param main_win the main window the viewer belongs to. |
651 | * @param time a pointer where time will be stored. |
652 | */ |
653 | |
654 | const LttTime *lttvwindow_get_current_time(MainWindow *main_win) |
655 | { |
656 | return &(main_win->current_tab->current_time); |
657 | } |
658 | |
659 | |
660 | /** |
661 | * Function to get the traceset from the current tab. |
662 | * It will be called by the constructor of the viewer and also be |
663 | * called by a hook funtion of the viewer to update its traceset. |
664 | * @param main_win the main window the viewer belongs to. |
665 | * @param traceset a pointer to a traceset. |
666 | */ |
667 | const LttvTraceset *lttvwindow_get_traceset(MainWindow *main_win) |
668 | { |
669 | return main_win->current_tab->traceset_info->traceset; |
670 | } |
671 | |
672 | /** |
673 | * Function to get the filter of the current tab. |
674 | * It will be called by the constructor of the viewer and also be |
675 | * called by a hook funtion of the viewer to update its filter. |
676 | * @param main_win, the main window the viewer belongs to. |
677 | * @param filter, a pointer to a filter. |
678 | */ |
679 | const lttv_filter *lttvwindow_get_filter(MainWindow *main_win) |
680 | { |
681 | //FIXME |
682 | g_warning("lttvwindow_get_filter not implemented in viewer.c"); |
683 | } |
684 | |
685 | |
6b1d3120 |
686 | /** |
687 | * Function to get the stats of the traceset |
688 | * @param main_win the main window the viewer belongs to. |
689 | */ |
690 | |
224446ce |
691 | LttvTracesetStats* lttvwindow_get_traceset_stats(MainWindow *main_win) |
6b1d3120 |
692 | { |
716e4367 |
693 | return main_win->current_tab->traceset_info->traceset_context; |
6b1d3120 |
694 | } |
a8c0f09d |
695 | |
696 | |
224446ce |
697 | LttvTracesetContext* lttvwindow_get_traceset_context(MainWindow *main_win) |
a8c0f09d |
698 | { |
699 | return (LttvTracesetContext*)main_win->current_tab->traceset_info->traceset_context; |
700 | } |