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 | |
561f5852 |
31 | #include <ltt/ltt.h> |
32 | #include <lttv/lttv.h> |
a43d67ba |
33 | #include <lttv/state.h> |
34 | #include <lttv/stats.h> |
35 | #include <lttv/tracecontext.h> |
36 | #include <lttvwindow/common.h> |
13f86ce2 |
37 | #include <lttvwindow/mainwindow.h> |
36b40c74 |
38 | #include <lttvwindow/viewer.h> |
13f86ce2 |
39 | #include <lttvwindow/toolbar.h> |
40 | #include <lttvwindow/menu.h> |
a43d67ba |
41 | #include <lttvwindow/callbacks.h> // for execute_time_requests |
6b1d3120 |
42 | |
561f5852 |
43 | |
44 | /** |
45 | * Internal function parts |
46 | */ |
47 | |
561f5852 |
48 | /** |
49 | * Function to set/update traceset for the viewers |
50 | * @param main_win main window |
51 | * @param traceset traceset of the main window. |
224446ce |
52 | * return value : |
53 | * -1 : error |
54 | * 0 : traceset updated |
55 | * 1 : no traceset hooks to update; not an error. |
561f5852 |
56 | */ |
57 | |
224446ce |
58 | int SetTraceset(MainWindow * main_win, gpointer traceset) |
561f5852 |
59 | { |
60 | LttvHooks * tmp; |
61 | LttvAttributeValue value; |
62 | |
224446ce |
63 | if( lttv_iattribute_find_by_path(main_win->attributes, |
64 | "hooks/updatetraceset", LTTV_POINTER, &value) != 0) |
65 | return -1; |
66 | |
561f5852 |
67 | tmp = (LttvHooks*)*(value.v_pointer); |
224446ce |
68 | if(tmp == NULL) return 1; |
a43d67ba |
69 | |
224446ce |
70 | |
561f5852 |
71 | lttv_hooks_call(tmp,traceset); |
a43d67ba |
72 | |
224446ce |
73 | return 0; |
561f5852 |
74 | } |
75 | |
76 | |
77 | /** |
78 | * Function to set/update filter for the viewers |
79 | * @param main_win main window |
80 | * @param filter filter of the main window. |
224446ce |
81 | * return value : |
82 | * -1 : error |
83 | * 0 : filters updated |
84 | * 1 : no filter hooks to update; not an error. |
561f5852 |
85 | */ |
86 | |
224446ce |
87 | int SetFilter(MainWindow * main_win, gpointer filter) |
561f5852 |
88 | { |
89 | LttvHooks * tmp; |
90 | LttvAttributeValue value; |
91 | |
224446ce |
92 | if(lttv_iattribute_find_by_path(main_win->attributes, |
93 | "hooks/updatefilter", LTTV_POINTER, &value) != 0) |
94 | return -1; |
95 | |
561f5852 |
96 | tmp = (LttvHooks*)*(value.v_pointer); |
97 | |
224446ce |
98 | if(tmp == NULL) return 1; |
561f5852 |
99 | lttv_hooks_call(tmp,filter); |
224446ce |
100 | |
101 | return 0; |
102 | } |
103 | |
104 | /** |
105 | * Function to redraw each viewer belonging to the current tab |
106 | * @param main_win the main window the viewer belongs to. |
107 | */ |
108 | |
109 | void update_traceset(MainWindow * main_win) |
110 | { |
111 | LttvAttributeValue value; |
112 | LttvHooks * tmp; |
113 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
114 | "hooks/updatetraceset", LTTV_POINTER, &value)); |
115 | tmp = (LttvHooks*)*(value.v_pointer); |
116 | if(tmp == NULL) return; |
117 | lttv_hooks_call(tmp, NULL); |
118 | } |
119 | |
a43d67ba |
120 | void set_time_window_adjustment(MainWindow * main_win, const TimeWindow* new_time_window) |
121 | { |
122 | gtk_multi_vpaned_set_adjust(main_win->current_tab->multi_vpaned, new_time_window, FALSE); |
123 | } |
224446ce |
124 | |
125 | |
a43d67ba |
126 | void set_time_window(MainWindow * main_win, const TimeWindow *time_window) |
224446ce |
127 | { |
128 | LttvAttributeValue value; |
129 | LttvHooks * tmp; |
a43d67ba |
130 | |
131 | TimeWindowNotifyData time_window_notify_data; |
132 | TimeWindow old_time_window = main_win->current_tab->time_window; |
133 | time_window_notify_data.old_time_window = &old_time_window; |
134 | main_win->current_tab->time_window = *time_window; |
135 | time_window_notify_data.new_time_window = |
136 | &(main_win->current_tab->time_window); |
137 | |
224446ce |
138 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
a43d67ba |
139 | "hooks/updatetimewindow", LTTV_POINTER, &value)); |
224446ce |
140 | tmp = (LttvHooks*)*(value.v_pointer); |
141 | if(tmp == NULL) return; |
a43d67ba |
142 | lttv_hooks_call(tmp, &time_window_notify_data); |
561f5852 |
143 | |
144 | |
a43d67ba |
145 | } |
224446ce |
146 | |
84d9b2a1 |
147 | |
148 | /* Remove menu entry and tool button from main window for the |
149 | * unloaded module |
150 | */ |
151 | |
152 | void remove_menu_item(gpointer main_win, gpointer user_data) |
153 | { |
154 | MainWindow * mw = (MainWindow *) main_win; |
155 | lttv_menu_closure *menu_item = (lttv_menu_closure *)user_data; |
156 | GtkWidget * tool_menu_title_menu, *insert_view; |
157 | |
158 | tool_menu_title_menu = lookup_widget(mw->mwindow,"ToolMenuTitle_menu"); |
159 | insert_view = (GtkWidget*)g_hash_table_lookup(mw->hash_menu_item, |
160 | menu_item->menuText); |
161 | if(insert_view){ |
162 | g_hash_table_remove(mw->hash_menu_item, menu_item->menuText); |
163 | gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu), insert_view); |
164 | } |
165 | } |
166 | |
167 | void remove_toolbar_item(gpointer main_win, gpointer user_data) |
168 | { |
169 | MainWindow * mw = (MainWindow *) main_win; |
170 | lttv_toolbar_closure *toolbar_item = (lttv_toolbar_closure *)user_data; |
171 | GtkWidget * tool_menu_title_menu, *insert_view; |
172 | |
173 | |
174 | tool_menu_title_menu = lookup_widget(mw->mwindow,"MToolbar1"); |
175 | insert_view = (GtkWidget*)g_hash_table_lookup(mw->hash_toolbar_item, |
176 | toolbar_item->tooltip); |
177 | if(insert_view){ |
178 | g_hash_table_remove(mw->hash_toolbar_item, toolbar_item->tooltip); |
179 | gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu), insert_view); |
180 | } |
181 | } |
182 | |
183 | /** |
184 | * Remove menu and toolbar item when a module unloaded from all |
185 | * main windows |
186 | */ |
187 | |
188 | void main_window_remove_menu_item(lttvwindow_viewer_constructor constructor) |
189 | { |
190 | int i; |
191 | LttvMenus * menu; |
192 | lttv_menu_closure *menu_item; |
193 | LttvAttributeValue value; |
194 | LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes()); |
195 | |
196 | g_assert(lttv_iattribute_find_by_path(attributes, |
197 | "viewers/menu", LTTV_POINTER, &value)); |
198 | menu = (LttvMenus*)*(value.v_pointer); |
199 | |
200 | if(menu){ |
201 | for(i=0;i<menu->len;i++){ |
202 | menu_item = &g_array_index(menu, lttv_menu_closure, i); |
203 | if(menu_item->con != constructor) continue; |
204 | if(g_main_window_list){ |
205 | g_slist_foreach(g_main_window_list, remove_menu_item, menu_item); |
206 | } |
207 | break; |
208 | } |
209 | } |
210 | |
211 | } |
212 | |
213 | void main_window_remove_toolbar_item(lttvwindow_viewer_constructor constructor) |
214 | { |
215 | int i; |
216 | LttvToolbars * toolbar; |
217 | lttv_toolbar_closure *toolbar_item; |
218 | LttvAttributeValue value; |
219 | LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes()); |
220 | |
221 | g_assert(lttv_iattribute_find_by_path(attributes, |
222 | "viewers/toolbar", LTTV_POINTER, &value)); |
223 | toolbar = (LttvToolbars*)*(value.v_pointer); |
224 | |
225 | if(toolbar){ |
226 | for(i=0;i<toolbar->len;i++){ |
227 | toolbar_item = &g_array_index(toolbar, lttv_toolbar_closure, i); |
228 | if(toolbar_item->con != constructor) continue; |
229 | if(g_main_window_list){ |
230 | g_slist_foreach(g_main_window_list, remove_toolbar_item, toolbar_item); |
231 | } |
232 | break; |
233 | } |
234 | } |
235 | } |
236 | |
237 | |
238 | |
239 | |
561f5852 |
240 | /** |
241 | * API parts |
242 | */ |
243 | |
244 | /** |
245 | * Function to register a view constructor so that main window can generate |
246 | * a toolbar item for the viewer in order to generate a new instance easily. |
247 | * It will be called by init function of the module. |
248 | * @param ButtonPixmap image shown on the toolbar item. |
249 | * @param tooltip tooltip of the toolbar item. |
250 | * @param view_constructor constructor of the viewer. |
251 | */ |
252 | |
224446ce |
253 | void lttvwindow_register_toolbar(char ** pixmap, char *tooltip, lttvwindow_viewer_constructor view_constructor) |
561f5852 |
254 | { |
255 | LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes()); |
256 | LttvToolbars * toolbar; |
257 | LttvAttributeValue value; |
258 | |
259 | g_assert(lttv_iattribute_find_by_path(attributes_global, |
d2811a98 |
260 | "viewers/toolbar", LTTV_POINTER, &value)); |
561f5852 |
261 | toolbar = (LttvToolbars*)*(value.v_pointer); |
262 | |
224446ce |
263 | if(toolbar == NULL){ |
561f5852 |
264 | toolbar = lttv_toolbars_new(); |
265 | *(value.v_pointer) = toolbar; |
266 | } |
267 | lttv_toolbars_add(toolbar, view_constructor, tooltip, pixmap); |
268 | } |
269 | |
270 | |
271 | /** |
272 | * Function to unregister the viewer's constructor, release the space |
273 | * occupied by pixmap, tooltip and constructor of the viewer. |
274 | * It will be called when a module is unloaded. |
275 | * @param view_constructor constructor of the viewer which is used as |
276 | * a reference to find out where the pixmap and tooltip are. |
277 | */ |
278 | |
224446ce |
279 | void lttvwindow_unregister_toolbar(lttvwindow_viewer_constructor view_constructor) |
561f5852 |
280 | { |
281 | LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes()); |
282 | LttvToolbars * toolbar; |
283 | LttvAttributeValue value; |
284 | |
285 | g_assert(lttv_iattribute_find_by_path(attributes_global, |
d2811a98 |
286 | "viewers/toolbar", LTTV_POINTER, &value)); |
561f5852 |
287 | toolbar = (LttvToolbars*)*(value.v_pointer); |
288 | |
2061e03d |
289 | main_window_remove_toolbar_item(view_constructor); |
290 | |
291 | lttv_toolbars_remove(toolbar, view_constructor); |
561f5852 |
292 | } |
293 | |
294 | |
295 | /** |
296 | * Function to register a view constructor so that main window can generate |
297 | * a menu item for the viewer in order to generate a new instance easily. |
298 | * It will be called by init function of the module. |
299 | * @param menu_path path of the menu item. |
300 | * @param menu_text text of the menu item. |
301 | * @param view_constructor constructor of the viewer. |
302 | */ |
303 | |
224446ce |
304 | void lttvwindow_register_menu(char *menu_path, char *menu_text, lttvwindow_viewer_constructor view_constructor) |
561f5852 |
305 | { |
306 | LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes()); |
307 | LttvMenus * menu; |
308 | LttvAttributeValue value; |
309 | |
310 | g_assert(lttv_iattribute_find_by_path(attributes_global, |
d2811a98 |
311 | "viewers/menu", LTTV_POINTER, &value)); |
561f5852 |
312 | menu = (LttvMenus*)*(value.v_pointer); |
313 | |
314 | if(menu == NULL){ |
315 | menu = lttv_menus_new(); |
316 | *(value.v_pointer) = menu; |
317 | } |
318 | lttv_menus_add(menu, view_constructor, menu_path, menu_text); |
319 | } |
320 | |
321 | /** |
322 | * Function to unregister the viewer's constructor, release the space |
323 | * occupied by menu_path, menu_text and constructor of the viewer. |
324 | * It will be called when a module is unloaded. |
325 | * @param view_constructor constructor of the viewer which is used as |
326 | * a reference to find out where the menu_path and menu_text are. |
327 | */ |
328 | |
224446ce |
329 | void lttvwindow_unregister_menu(lttvwindow_viewer_constructor view_constructor) |
561f5852 |
330 | { |
331 | LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes()); |
332 | LttvMenus * menu; |
333 | LttvAttributeValue value; |
334 | |
335 | g_assert(lttv_iattribute_find_by_path(attributes_global, |
c4c15b5e |
336 | "viewers/menu", LTTV_POINTER, &value)); |
561f5852 |
337 | menu = (LttvMenus*)*(value.v_pointer); |
338 | |
2061e03d |
339 | main_window_remove_menu_item(view_constructor); |
340 | |
341 | lttv_menus_remove(menu, view_constructor); |
561f5852 |
342 | } |
343 | |
561f5852 |
344 | /** |
345 | * Function to register a hook function for a viewer to set/update its |
346 | * time interval. |
561f5852 |
347 | * @param hook hook function of the viewer. |
348 | * @param hook_data hook data associated with the hook function. |
349 | * @param main_win the main window the viewer belongs to. |
350 | */ |
224446ce |
351 | void lttvwindow_register_time_window_notify(MainWindow * main_win, |
352 | LttvHook hook, gpointer hook_data) |
561f5852 |
353 | { |
354 | LttvAttributeValue value; |
355 | LttvHooks * tmp; |
bca3b81f |
356 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
d2811a98 |
357 | "hooks/updatetimewindow", LTTV_POINTER, &value)); |
561f5852 |
358 | tmp = (LttvHooks*)*(value.v_pointer); |
359 | if(tmp == NULL){ |
360 | tmp = lttv_hooks_new(); |
361 | *(value.v_pointer) = tmp; |
362 | } |
363 | lttv_hooks_add(tmp, hook,hook_data); |
364 | } |
365 | |
366 | |
367 | /** |
368 | * Function to unregister a viewer's hook function which is used to |
369 | * set/update the time interval of the viewer. |
561f5852 |
370 | * @param hook hook function of the viewer. |
371 | * @param hook_data hook data associated with the hook function. |
372 | * @param main_win the main window the viewer belongs to. |
373 | */ |
374 | |
224446ce |
375 | void lttvwindow_unregister_time_window_notify(MainWindow * main_win, |
376 | LttvHook hook, gpointer hook_data) |
561f5852 |
377 | { |
378 | LttvAttributeValue value; |
379 | LttvHooks * tmp; |
bca3b81f |
380 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
d2811a98 |
381 | "hooks/updatetimewindow", LTTV_POINTER, &value)); |
561f5852 |
382 | tmp = (LttvHooks*)*(value.v_pointer); |
383 | if(tmp == NULL) return; |
384 | lttv_hooks_remove_data(tmp, hook, hook_data); |
385 | } |
386 | |
561f5852 |
387 | /** |
388 | * Function to register a hook function for a viewer to set/update its |
389 | * traceset. |
561f5852 |
390 | * @param hook hook function of the viewer. |
391 | * @param hook_data hook data associated with the hook function. |
392 | * @param main_win the main window the viewer belongs to. |
393 | */ |
394 | |
224446ce |
395 | void lttvwindow_register_traceset_notify(MainWindow * main_win, |
396 | LttvHook hook, gpointer hook_data) |
561f5852 |
397 | { |
398 | LttvAttributeValue value; |
399 | LttvHooks * tmp; |
a8c0f09d |
400 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
d2811a98 |
401 | "hooks/updatetraceset", LTTV_POINTER, &value)); |
561f5852 |
402 | tmp = (LttvHooks*)*(value.v_pointer); |
403 | if(tmp == NULL){ |
404 | tmp = lttv_hooks_new(); |
405 | *(value.v_pointer) = tmp; |
406 | } |
407 | lttv_hooks_add(tmp, hook, hook_data); |
408 | } |
409 | |
410 | |
411 | /** |
412 | * Function to unregister a viewer's hook function which is used to |
413 | * set/update the traceset of the viewer. |
561f5852 |
414 | * @param hook hook function of the viewer. |
415 | * @param hook_data hook data associated with the hook function. |
416 | * @param main_win the main window the viewer belongs to. |
417 | */ |
418 | |
224446ce |
419 | void lttvwindow_unregister_traceset_notify(MainWindow * main_win, |
420 | LttvHook hook, gpointer hook_data) |
561f5852 |
421 | { |
422 | LttvAttributeValue value; |
423 | LttvHooks * tmp; |
a8c0f09d |
424 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
d2811a98 |
425 | "hooks/updatetraceset", LTTV_POINTER, &value)); |
561f5852 |
426 | tmp = (LttvHooks*)*(value.v_pointer); |
427 | if(tmp == NULL) return; |
428 | lttv_hooks_remove_data(tmp, hook, hook_data); |
429 | } |
430 | |
561f5852 |
431 | /** |
432 | * Function to register a hook function for a viewer to set/update its |
433 | * filter. |
561f5852 |
434 | * @param hook hook function of the viewer. |
435 | * @param hook_data hook data associated with the hook function. |
436 | * @param main_win the main window the viewer belongs to. |
437 | */ |
438 | |
224446ce |
439 | void lttvwindow_register_filter_notify(MainWindow *main_win, |
440 | LttvHook hook, gpointer hook_data) |
561f5852 |
441 | { |
442 | LttvAttributeValue value; |
443 | LttvHooks * tmp; |
bca3b81f |
444 | g_assert(lttv_iattribute_find_by_path(main_win->attributes, |
d2811a98 |
445 | "hooks/updatefilter", LTTV_POINTER, &value)); |
561f5852 |
446 | tmp = (LttvHooks*)*(value.v_pointer); |
447 | if(tmp == NULL){ |
448 | tmp = lttv_hooks_new(); |
449 | *(value.v_pointer) = tmp; |
450 | } |
451 | lttv_hooks_add(tmp, hook, hook_data); |
452 | } |
453 | |
454 | |
455 | /** |
456 | * Function to unregister a viewer's hook function which is used to |
457 | * set/update the filter of the viewer. |
561f5852 |
458 | * @param hook hook function of the viewer. |
459 | * @param hook_data hook data associated with the hook function. |
460 | * @param main_win the main window the viewer belongs to. |
461 | */ |
462 | |
5a5b35c5 |
463 | void lttvwindow_unregister_filter_notify(MainWindow * main_win, |
464 | LttvHook hook, |
465 | gpointer hook_data) |
561f5852 |
466 | { |
467 | LttvAttributeValue value; |
468 | LttvHooks * tmp; |
bca3b81f |
469 | g_assert(lttv_iattribute_find_by_path(main_win->attributes, |
d2811a98 |
470 | "hooks/updatefilter", LTTV_POINTER, &value)); |
561f5852 |
471 | tmp = (LttvHooks*)*(value.v_pointer); |
472 | if(tmp == NULL) return; |
473 | lttv_hooks_remove_data(tmp, hook, hook_data); |
474 | } |
475 | |
561f5852 |
476 | /** |
477 | * Function to register a hook function for a viewer to set/update its |
478 | * current time. |
561f5852 |
479 | * @param hook hook function of the viewer. |
480 | * @param hook_data hook data associated with the hook function. |
481 | * @param main_win the main window the viewer belongs to. |
482 | */ |
483 | |
224446ce |
484 | void lttvwindow_register_current_time_notify(MainWindow *main_win, |
485 | LttvHook hook, gpointer hook_data) |
561f5852 |
486 | { |
487 | LttvAttributeValue value; |
488 | LttvHooks * tmp; |
bca3b81f |
489 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
d2811a98 |
490 | "hooks/updatecurrenttime", LTTV_POINTER, &value)); |
561f5852 |
491 | tmp = (LttvHooks*)*(value.v_pointer); |
492 | if(tmp == NULL){ |
493 | tmp = lttv_hooks_new(); |
494 | *(value.v_pointer) = tmp; |
495 | } |
496 | lttv_hooks_add(tmp, hook, hook_data); |
497 | } |
498 | |
499 | |
500 | /** |
501 | * Function to unregister a viewer's hook function which is used to |
502 | * set/update the current time of the viewer. |
561f5852 |
503 | * @param hook hook function of the viewer. |
504 | * @param hook_data hook data associated with the hook function. |
505 | * @param main_win the main window the viewer belongs to. |
506 | */ |
507 | |
224446ce |
508 | void lttvwindow_unregister_current_time_notify(MainWindow * main_win, |
509 | LttvHook hook, gpointer hook_data) |
561f5852 |
510 | { |
511 | LttvAttributeValue value; |
512 | LttvHooks * tmp; |
bca3b81f |
513 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
d2811a98 |
514 | "hooks/updatecurrenttime", LTTV_POINTER, &value)); |
561f5852 |
515 | tmp = (LttvHooks*)*(value.v_pointer); |
516 | if(tmp == NULL) return; |
517 | lttv_hooks_remove_data(tmp, hook, hook_data); |
518 | } |
519 | |
520 | |
202f6c8f |
521 | /** |
522 | * Function to register a hook function for a viewer to show |
224446ce |
523 | * the content of the viewer. |
202f6c8f |
524 | * @param hook hook function of the viewer. |
525 | * @param hook_data hook data associated with the hook function. |
526 | * @param main_win the main window the viewer belongs to. |
527 | */ |
528 | |
a43d67ba |
529 | void lttvwindow_register_show_notify(MainWindow *main_win, |
224446ce |
530 | LttvHook hook, gpointer hook_data) |
202f6c8f |
531 | { |
532 | LttvAttributeValue value; |
533 | LttvHooks * tmp; |
534 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
d2811a98 |
535 | "hooks/showviewer", LTTV_POINTER, &value)); |
202f6c8f |
536 | tmp = (LttvHooks*)*(value.v_pointer); |
537 | if(tmp == NULL){ |
538 | tmp = lttv_hooks_new(); |
539 | *(value.v_pointer) = tmp; |
540 | } |
541 | lttv_hooks_add(tmp, hook, hook_data); |
542 | } |
543 | |
544 | |
545 | /** |
546 | * Function to unregister a viewer's hook function which is used to |
547 | * show the content of the viewer.. |
202f6c8f |
548 | * @param hook hook function of the viewer. |
549 | * @param hook_data hook data associated with the hook function. |
550 | * @param main_win the main window the viewer belongs to. |
551 | */ |
552 | |
a43d67ba |
553 | void lttvwindow_unregister_show_notify(MainWindow * main_win, |
224446ce |
554 | LttvHook hook, gpointer hook_data) |
202f6c8f |
555 | { |
556 | LttvAttributeValue value; |
557 | LttvHooks * tmp; |
558 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
d2811a98 |
559 | "hooks/showviewer", LTTV_POINTER, &value)); |
202f6c8f |
560 | tmp = (LttvHooks*)*(value.v_pointer); |
561 | if(tmp == NULL) return; |
562 | lttv_hooks_remove_data(tmp, hook, hook_data); |
563 | } |
564 | |
561f5852 |
565 | /** |
566 | * Function to register a hook function for a viewer to set/update the |
567 | * dividor of the hpane. |
561f5852 |
568 | * @param hook hook function of the viewer. |
569 | * @param hook_data hook data associated with the hook function. |
570 | * @param main_win the main window the viewer belongs to. |
571 | */ |
572 | |
224446ce |
573 | void lttvwindow_register_dividor(MainWindow *main_win, |
574 | LttvHook hook, gpointer hook_data) |
561f5852 |
575 | { |
576 | LttvAttributeValue value; |
577 | LttvHooks * tmp; |
bca3b81f |
578 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
d2811a98 |
579 | "hooks/hpanedividor", LTTV_POINTER, &value)); |
561f5852 |
580 | tmp = (LttvHooks*)*(value.v_pointer); |
581 | if(tmp == NULL){ |
582 | tmp = lttv_hooks_new(); |
583 | *(value.v_pointer) = tmp; |
584 | } |
585 | lttv_hooks_add(tmp, hook, hook_data); |
586 | } |
587 | |
588 | |
589 | /** |
590 | * Function to unregister a viewer's hook function which is used to |
591 | * set/update hpane's dividor of the viewer. |
592 | * It will be called by the destructor of the viewer. |
593 | * @param hook hook function of the viewer. |
594 | * @param hook_data hook data associated with the hook function. |
595 | * @param main_win the main window the viewer belongs to. |
596 | */ |
597 | |
224446ce |
598 | void lttvwindow_unregister_dividor(MainWindow *main_win, |
599 | LttvHook hook, gpointer hook_data) |
561f5852 |
600 | { |
601 | LttvAttributeValue value; |
602 | LttvHooks * tmp; |
bca3b81f |
603 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
d2811a98 |
604 | "hooks/hpanedividor", LTTV_POINTER, &value)); |
561f5852 |
605 | tmp = (LttvHooks*)*(value.v_pointer); |
606 | if(tmp == NULL) return; |
607 | lttv_hooks_remove_data(tmp, hook, hook_data); |
608 | } |
609 | |
610 | |
224446ce |
611 | /** |
612 | * Update the status bar whenever something changed in the viewer. |
613 | * @param main_win the main window the viewer belongs to. |
614 | * @param info the message which will be shown in the status bar. |
615 | */ |
616 | |
5a5b35c5 |
617 | void lttvwindow_report_status(MainWindow *main_win, const char *info) |
224446ce |
618 | { |
619 | //FIXME |
620 | g_warning("update_status not implemented in viewer.c"); |
621 | } |
622 | |
623 | /** |
624 | * Function to set the time interval of the current tab. |
625 | * It will be called by a viewer's signal handle associated with |
626 | * the move_slider signal |
627 | * @param main_win the main window the viewer belongs to. |
628 | * @param time_interval a pointer where time interval is stored. |
629 | */ |
630 | |
631 | void lttvwindow_report_time_window(MainWindow *main_win, |
5a5b35c5 |
632 | const TimeWindow *time_window) |
224446ce |
633 | { |
a43d67ba |
634 | set_time_window(main_win, time_window); |
635 | set_time_window_adjustment(main_win, time_window); |
224446ce |
636 | } |
637 | |
a43d67ba |
638 | |
224446ce |
639 | /** |
640 | * Function to set the current time/event of the current tab. |
641 | * It will be called by a viewer's signal handle associated with |
642 | * the button-release-event signal |
643 | * @param main_win the main window the viewer belongs to. |
644 | * @param time a pointer where time is stored. |
645 | */ |
646 | |
5a5b35c5 |
647 | void lttvwindow_report_current_time(MainWindow *main_win, |
648 | const LttTime *time) |
224446ce |
649 | { |
650 | LttvAttributeValue value; |
651 | LttvHooks * tmp; |
652 | main_win->current_tab->current_time = *time; |
653 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
654 | "hooks/updatecurrenttime", LTTV_POINTER, &value)); |
655 | tmp = (LttvHooks*)*(value.v_pointer); |
656 | |
657 | if(tmp == NULL)return; |
5a5b35c5 |
658 | lttv_hooks_call(tmp, &main_win->current_tab->current_time); |
224446ce |
659 | } |
660 | |
561f5852 |
661 | /** |
662 | * Function to set the position of the hpane's dividor (viewer). |
663 | * It will be called by a viewer's signal handle associated with |
664 | * the motion_notify_event event/signal |
665 | * @param main_win the main window the viewer belongs to. |
666 | * @param position position of the hpane's dividor. |
667 | */ |
668 | |
224446ce |
669 | void lttvwindow_report_dividor(MainWindow *main_win, gint position) |
561f5852 |
670 | { |
671 | LttvAttributeValue value; |
672 | LttvHooks * tmp; |
bca3b81f |
673 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
d2811a98 |
674 | "hooks/hpanedividor", LTTV_POINTER, &value)); |
561f5852 |
675 | tmp = (LttvHooks*)*(value.v_pointer); |
676 | if(tmp == NULL) return; |
677 | lttv_hooks_call(tmp, &position); |
678 | } |
679 | |
224446ce |
680 | /** |
681 | * Function to set the focused pane (viewer). |
682 | * It will be called by a viewer's signal handle associated with |
683 | * the grab_focus signal |
684 | * @param main_win the main window the viewer belongs to. |
5a5b35c5 |
685 | * @param top_widget the top widget containing all the other widgets of the |
686 | * viewer. |
224446ce |
687 | */ |
688 | |
5a5b35c5 |
689 | void lttvwindow_report_focus(MainWindow *main_win, GtkWidget *top_widget) |
224446ce |
690 | { |
5a5b35c5 |
691 | gtk_multi_vpaned_set_focus((GtkWidget*)main_win->current_tab->multi_vpaned, |
692 | gtk_widget_get_parent(top_widget)); |
224446ce |
693 | } |
694 | |
695 | |
a43d67ba |
696 | /** |
697 | * Function to request data in a specific time interval to the main window. |
698 | * The main window will use this time interval and the others present |
699 | * to get the data from the process trace. |
700 | * @param main_win the main window the viewer belongs to. |
701 | * @param paned a pointer to a pane where the viewer is contained. |
702 | */ |
703 | |
704 | void lttvwindow_time_interval_request(MainWindow *main_win, |
705 | TimeWindow time_requested, guint num_events, |
706 | LttvHook after_process_traceset, |
707 | gpointer after_process_traceset_data) |
708 | { |
709 | TimeRequest time_request; |
710 | |
711 | time_request.time_window = time_requested; |
712 | time_request.num_events = num_events; |
713 | time_request.after_hook = after_process_traceset; |
714 | time_request.after_hook_data = after_process_traceset_data; |
715 | |
716 | g_array_append_val(main_win->current_tab->time_requests, time_request); |
717 | |
718 | if(!main_win->current_tab->time_request_pending) |
719 | { |
720 | /* Redraw has +20 priority. We want a prio higher than that, so +19 */ |
721 | g_idle_add_full((G_PRIORITY_HIGH_IDLE + 19), |
722 | (GSourceFunc)execute_time_requests, |
723 | main_win, |
724 | NULL); |
725 | main_win->current_tab->time_request_pending = TRUE; |
726 | } |
727 | } |
728 | |
224446ce |
729 | /** |
730 | * Function to get the current time interval shown on the current tab. |
731 | * It will be called by a viewer's hook function to update the |
732 | * shown time interval of the viewer and also be called by the constructor |
733 | * of the viewer. |
734 | * @param main_win the main window the viewer belongs to. |
735 | * @param time_interval a pointer where time interval will be stored. |
736 | */ |
737 | |
738 | const TimeWindow *lttvwindow_get_time_window(MainWindow *main_win) |
739 | { |
740 | //time_window->start_time = main_win->current_tab->time_window.start_time; |
741 | //time_window->time_width = main_win->current_tab->time_window.time_width; |
742 | return &(main_win->current_tab->time_window); |
743 | |
744 | } |
745 | |
746 | |
747 | /** |
748 | * Function to get the current time/event of the current tab. |
749 | * It will be called by a viewer's hook function to update the |
750 | * current time/event of the viewer. |
751 | * @param main_win the main window the viewer belongs to. |
752 | * @param time a pointer where time will be stored. |
753 | */ |
754 | |
755 | const LttTime *lttvwindow_get_current_time(MainWindow *main_win) |
756 | { |
757 | return &(main_win->current_tab->current_time); |
758 | } |
759 | |
760 | |
224446ce |
761 | /** |
762 | * Function to get the filter of the current tab. |
763 | * It will be called by the constructor of the viewer and also be |
764 | * called by a hook funtion of the viewer to update its filter. |
765 | * @param main_win, the main window the viewer belongs to. |
766 | * @param filter, a pointer to a filter. |
767 | */ |
768 | const lttv_filter *lttvwindow_get_filter(MainWindow *main_win) |
769 | { |
770 | //FIXME |
771 | g_warning("lttvwindow_get_filter not implemented in viewer.c"); |
772 | } |
773 | |
774 | |
6b1d3120 |
775 | /** |
776 | * Function to get the stats of the traceset |
777 | * @param main_win the main window the viewer belongs to. |
778 | */ |
779 | |
224446ce |
780 | LttvTracesetStats* lttvwindow_get_traceset_stats(MainWindow *main_win) |
6b1d3120 |
781 | { |
716e4367 |
782 | return main_win->current_tab->traceset_info->traceset_context; |
6b1d3120 |
783 | } |
a8c0f09d |
784 | |
785 | |
224446ce |
786 | LttvTracesetContext* lttvwindow_get_traceset_context(MainWindow *main_win) |
a8c0f09d |
787 | { |
788 | return (LttvTracesetContext*)main_win->current_tab->traceset_info->traceset_context; |
789 | } |