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 | |
6c9d86dd |
147 | void add_toolbar_constructor(MainWindow *mw, LttvToolbarClosure *toolbar_c) |
148 | { |
149 | LttvIAttribute *attributes = LTTV_IATTRIBUTES(mw->attributes); |
150 | LttvAttributeValue value; |
151 | LttvToolbars * instance_toolbar; |
152 | lttvwindow_viewer_constructor constructor; |
153 | GtkWidget * tool_menu_title_menu, *new_widget, *pixmap; |
154 | GdkPixbuf *pixbuf; |
155 | |
156 | g_assert(lttv_iattribute_find_by_path(attributes, |
157 | "viewers/toolbar", LTTV_POINTER, &value)); |
158 | if(*(value.v_pointer) == NULL) |
159 | (LttvToolbars*)*(value.v_pointer) = lttv_toolbars_new(); |
160 | instance_toolbar = (LttvToolbars*)*(value.v_pointer); |
161 | |
162 | constructor = toolbar_c->con; |
163 | tool_menu_title_menu = lookup_widget(mw->mwindow,"MToolbar1"); |
164 | pixbuf = gdk_pixbuf_new_from_xpm_data((const char**)toolbar_c->pixmap); |
165 | pixmap = gtk_image_new_from_pixbuf(pixbuf); |
166 | new_widget = |
167 | gtk_toolbar_append_element (GTK_TOOLBAR (tool_menu_title_menu), |
168 | GTK_TOOLBAR_CHILD_BUTTON, |
169 | NULL, |
170 | "", |
171 | toolbar_item->tooltip, NULL, |
172 | pixmap, NULL, NULL); |
173 | gtk_label_set_use_underline( |
174 | GTK_LABEL (((GtkToolbarChild*) ( |
175 | g_list_last (GTK_TOOLBAR |
176 | (tool_menu_title_menu)->children)->data))->label), |
177 | TRUE); |
178 | gtk_container_set_border_width (GTK_CONTAINER (new_widget), 1); |
179 | g_signal_connect ((gpointer) new_widget, |
180 | "clicked", |
181 | G_CALLBACK (insert_viewer_wrap), |
182 | constructor); |
183 | gtk_widget_show (new_widget); |
184 | |
185 | lttv_toolbars_add(instance_toolbar, toolbar_item_i->con, |
186 | toolbar_item_i->tooltip, |
187 | toolbar_item_i->pixmap, |
188 | new_widget); |
189 | |
190 | } |
191 | |
192 | void add_menu_constructor(MainWindow *mw, LttvMenuClosure *menu_c) |
193 | { |
194 | LttvIAttribute *attributes = LTTV_IATTRIBUTES(mw->attributes); |
195 | LttvAttributeValue value; |
196 | LttvToolbars * instance_menu; |
197 | lttvwindow_viewer_constructor constructor; |
198 | GtkWidget * tool_menu_title_menu, *new_widget; |
199 | |
200 | g_assert(lttv_iattribute_find_by_path(attributes, |
201 | "viewers/menu", LTTV_POINTER, &value)); |
202 | if(*(value.v_pointer) == NULL) |
203 | (LttvMenus*)*(value.v_pointer) = lttv_menus_new(); |
204 | instance_menu = (LttvMenus*)*(value.v_pointer); |
205 | |
206 | |
207 | constructor = menu_item->con; |
208 | tool_menu_title_menu = lookup_widget(mw->mwindow,"ToolMenuTitle_menu"); |
209 | new_widget = |
210 | gtk_menu_item_new_with_mnemonic (menu_c->menuText); |
211 | gtk_container_add (GTK_CONTAINER (tool_menu_title_menu), |
212 | new_widget); |
213 | g_signal_connect ((gpointer) new_widget, "activate", |
214 | G_CALLBACK (insert_viewer_wrap), |
215 | constructor); |
216 | gtk_widget_show (new_widget); |
217 | lttv_menus_add(instance_menu, menu_c->con, |
218 | menu_c->menu_path, |
219 | menu_c->menu_text, |
220 | new_widget); |
221 | } |
222 | |
223 | void remove_toolbar_constructor(MainWindow *mw, lttvwindow_viewer_constructor viewer_constructor) |
224 | { |
225 | LttvIAttribute *attributes = LTTV_IATTRIBUTES(mw->attributes); |
226 | LttvAttributeValue value; |
227 | LttvToolbars * instance_toolbar; |
228 | lttvwindow_viewer_constructor constructor; |
229 | GtkWidget * tool_menu_title_menu, *widget; |
230 | |
231 | g_assert(lttv_iattribute_find_by_path(attributes, |
232 | "viewers/toolbar", LTTV_POINTER, &value)); |
233 | if(*(value.v_pointer) == NULL) |
234 | (LttvToolbars*)*(value.v_pointer) = lttv_toolbars_new(); |
235 | instance_toolbar = (LttvToolbars*)*(value.v_pointer); |
236 | |
237 | tool_menu_title_menu = lookup_widget(mw->mwindow,"MToolbar1"); |
238 | widget = lttv_menus_remove(instance_toolbar, viewer_constructor); |
239 | gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu), |
240 | widget); |
241 | } |
242 | |
243 | |
244 | void remove_menu_constructor(MainWindow *mw, lttvwindow_viewer_constructor viewer_constructor) |
245 | { |
246 | LttvIAttribute *attributes = LTTV_IATTRIBUTES(mw->attributes); |
247 | LttvAttributeValue value; |
248 | LttvMenus * instance_menu; |
249 | lttvwindow_viewer_constructor constructor; |
250 | GtkWidget * tool_menu_title_menu, *widget; |
251 | LttvMenuClosure *menu_item_i; |
252 | |
253 | g_assert(lttv_iattribute_find_by_path(attributes, |
254 | "viewers/menu", LTTV_POINTER, &value)); |
255 | if(*(value.v_pointer) == NULL) |
256 | (LttvMenus*)*(value.v_pointer) = lttv_menus_new(); |
257 | instance_menu = (LttvMenus*)*(value.v_pointer); |
258 | |
259 | widget = lttv_menus_remove(instance_menu, viewer_constructor); |
260 | tool_menu_title_menu = lookup_widget(mw->mwindow,"ToolMenuTitle_menu"); |
261 | gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu), widget); |
262 | } |
263 | |
264 | |
561f5852 |
265 | /** |
266 | * API parts |
267 | */ |
268 | |
001d8606 |
269 | |
561f5852 |
270 | /** |
271 | * Function to register a view constructor so that main window can generate |
001d8606 |
272 | * a menu item and a toolbar item for the viewer in order to generate a new |
273 | * instance easily. A menu entry and toolbar item will be added to each main |
274 | * window. |
275 | * |
276 | * It should be called by init function of the module. |
277 | * |
278 | * @param menu_path path of the menu item. |
279 | * @param menu_text text of the menu item. |
280 | * @param pixmap Image shown on the toolbar item. |
561f5852 |
281 | * @param tooltip tooltip of the toolbar item. |
282 | * @param view_constructor constructor of the viewer. |
283 | */ |
284 | |
001d8606 |
285 | void lttvwindow_register_constructor |
286 | (char * menu_path, |
287 | char * menu_text, |
288 | char ** pixmap, |
289 | char * tooltip, |
290 | lttvwindow_viewer_constructor view_constructor) |
561f5852 |
291 | { |
292 | LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes()); |
293 | LttvToolbars * toolbar; |
001d8606 |
294 | LttvMenus * menu; |
6c9d86dd |
295 | LttvToolbarClosure toolbar_c; |
296 | LttvMenuClosure menu_c; |
561f5852 |
297 | LttvAttributeValue value; |
298 | |
001d8606 |
299 | if(pixmap != NULL) { |
300 | g_assert(lttv_iattribute_find_by_path(attributes_global, |
301 | "viewers/toolbar", LTTV_POINTER, &value)); |
302 | toolbar = (LttvToolbars*)*(value.v_pointer); |
561f5852 |
303 | |
001d8606 |
304 | if(toolbar == NULL) { |
305 | toolbar = lttv_toolbars_new(); |
306 | *(value.v_pointer) = toolbar; |
307 | } |
6c9d86dd |
308 | toolbar_c = lttv_toolbars_add(toolbar, view_constructor, tooltip, pixmap); |
309 | |
310 | g_slist_foreach(g_main_window_list, |
311 | (gpointer)add_toolbar_constructor, |
312 | &toolbar_c); |
001d8606 |
313 | } |
314 | |
315 | if(menu_path != NULL) { |
316 | g_assert(lttv_iattribute_find_by_path(attributes_global, |
317 | "viewers/menu", LTTV_POINTER, &value)); |
318 | menu = (LttvMenus*)*(value.v_pointer); |
319 | |
320 | if(menu == NULL) { |
321 | menu = lttv_menus_new(); |
322 | *(value.v_pointer) = menu; |
323 | } |
6c9d86dd |
324 | menu_c = lttv_menus_add(menu, view_constructor, menu_path, menu_text); |
325 | |
326 | g_slist_foreach(g_main_window_list, |
327 | (gpointer)add_menu_constructor, |
328 | &menu_c); |
561f5852 |
329 | } |
561f5852 |
330 | } |
331 | |
332 | |
333 | /** |
334 | * Function to unregister the viewer's constructor, release the space |
001d8606 |
335 | * occupied by menu_path, menu_text, pixmap, tooltip and constructor of the |
336 | * viewer. |
337 | * |
561f5852 |
338 | * It will be called when a module is unloaded. |
001d8606 |
339 | * |
340 | * @param view_constructor constructor of the viewer. |
561f5852 |
341 | */ |
342 | |
001d8606 |
343 | |
344 | void lttvwindow_unregister_constructor |
345 | (lttvwindow_viewer_constructor view_constructor) |
561f5852 |
346 | { |
347 | LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes()); |
348 | LttvToolbars * toolbar; |
001d8606 |
349 | LttvMenus * menu; |
561f5852 |
350 | LttvAttributeValue value; |
351 | |
352 | g_assert(lttv_iattribute_find_by_path(attributes_global, |
d2811a98 |
353 | "viewers/toolbar", LTTV_POINTER, &value)); |
561f5852 |
354 | toolbar = (LttvToolbars*)*(value.v_pointer); |
355 | |
001d8606 |
356 | if(toolbar != NULL) { |
6c9d86dd |
357 | g_slist_foreach(g_main_window_list, |
358 | (gpointer)remove_toolbar_constructor, |
359 | view_constructor); |
001d8606 |
360 | lttv_toolbars_remove(toolbar, view_constructor); |
361 | } |
561f5852 |
362 | |
363 | g_assert(lttv_iattribute_find_by_path(attributes_global, |
d2811a98 |
364 | "viewers/menu", LTTV_POINTER, &value)); |
561f5852 |
365 | menu = (LttvMenus*)*(value.v_pointer); |
366 | |
001d8606 |
367 | if(menu != NULL) { |
6c9d86dd |
368 | g_slist_foreach(g_main_window_list, |
369 | (gpointer)remove_menu_constructor, |
370 | view_constructor); |
001d8606 |
371 | lttv_menus_remove(menu, view_constructor); |
561f5852 |
372 | } |
561f5852 |
373 | } |
374 | |
001d8606 |
375 | |
561f5852 |
376 | /** |
377 | * Function to register a hook function for a viewer to set/update its |
378 | * time interval. |
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 | */ |
224446ce |
383 | void lttvwindow_register_time_window_notify(MainWindow * main_win, |
384 | LttvHook hook, gpointer hook_data) |
561f5852 |
385 | { |
386 | LttvAttributeValue value; |
387 | LttvHooks * tmp; |
bca3b81f |
388 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
d2811a98 |
389 | "hooks/updatetimewindow", LTTV_POINTER, &value)); |
561f5852 |
390 | tmp = (LttvHooks*)*(value.v_pointer); |
391 | if(tmp == NULL){ |
392 | tmp = lttv_hooks_new(); |
393 | *(value.v_pointer) = tmp; |
394 | } |
395 | lttv_hooks_add(tmp, hook,hook_data); |
396 | } |
397 | |
398 | |
399 | /** |
400 | * Function to unregister a viewer's hook function which is used to |
401 | * set/update the time interval of the viewer. |
561f5852 |
402 | * @param hook hook function of the viewer. |
403 | * @param hook_data hook data associated with the hook function. |
404 | * @param main_win the main window the viewer belongs to. |
405 | */ |
406 | |
224446ce |
407 | void lttvwindow_unregister_time_window_notify(MainWindow * main_win, |
408 | LttvHook hook, gpointer hook_data) |
561f5852 |
409 | { |
410 | LttvAttributeValue value; |
411 | LttvHooks * tmp; |
bca3b81f |
412 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
d2811a98 |
413 | "hooks/updatetimewindow", LTTV_POINTER, &value)); |
561f5852 |
414 | tmp = (LttvHooks*)*(value.v_pointer); |
415 | if(tmp == NULL) return; |
416 | lttv_hooks_remove_data(tmp, hook, hook_data); |
417 | } |
418 | |
561f5852 |
419 | /** |
420 | * Function to register a hook function for a viewer to set/update its |
421 | * traceset. |
561f5852 |
422 | * @param hook hook function of the viewer. |
423 | * @param hook_data hook data associated with the hook function. |
424 | * @param main_win the main window the viewer belongs to. |
425 | */ |
426 | |
224446ce |
427 | void lttvwindow_register_traceset_notify(MainWindow * main_win, |
428 | LttvHook hook, gpointer hook_data) |
561f5852 |
429 | { |
430 | LttvAttributeValue value; |
431 | LttvHooks * tmp; |
a8c0f09d |
432 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
d2811a98 |
433 | "hooks/updatetraceset", LTTV_POINTER, &value)); |
561f5852 |
434 | tmp = (LttvHooks*)*(value.v_pointer); |
435 | if(tmp == NULL){ |
436 | tmp = lttv_hooks_new(); |
437 | *(value.v_pointer) = tmp; |
438 | } |
439 | lttv_hooks_add(tmp, hook, hook_data); |
440 | } |
441 | |
442 | |
443 | /** |
444 | * Function to unregister a viewer's hook function which is used to |
445 | * set/update the traceset of the viewer. |
561f5852 |
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 | |
224446ce |
451 | void lttvwindow_unregister_traceset_notify(MainWindow * main_win, |
452 | LttvHook hook, gpointer hook_data) |
561f5852 |
453 | { |
454 | LttvAttributeValue value; |
455 | LttvHooks * tmp; |
a8c0f09d |
456 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
d2811a98 |
457 | "hooks/updatetraceset", 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 | |
561f5852 |
463 | /** |
464 | * Function to register a hook function for a viewer to set/update its |
465 | * filter. |
561f5852 |
466 | * @param hook hook function of the viewer. |
467 | * @param hook_data hook data associated with the hook function. |
468 | * @param main_win the main window the viewer belongs to. |
469 | */ |
470 | |
224446ce |
471 | void lttvwindow_register_filter_notify(MainWindow *main_win, |
472 | LttvHook hook, gpointer hook_data) |
561f5852 |
473 | { |
474 | LttvAttributeValue value; |
475 | LttvHooks * tmp; |
bca3b81f |
476 | g_assert(lttv_iattribute_find_by_path(main_win->attributes, |
d2811a98 |
477 | "hooks/updatefilter", LTTV_POINTER, &value)); |
561f5852 |
478 | tmp = (LttvHooks*)*(value.v_pointer); |
479 | if(tmp == NULL){ |
480 | tmp = lttv_hooks_new(); |
481 | *(value.v_pointer) = tmp; |
482 | } |
483 | lttv_hooks_add(tmp, hook, hook_data); |
484 | } |
485 | |
486 | |
487 | /** |
488 | * Function to unregister a viewer's hook function which is used to |
489 | * set/update the filter of the viewer. |
561f5852 |
490 | * @param hook hook function of the viewer. |
491 | * @param hook_data hook data associated with the hook function. |
492 | * @param main_win the main window the viewer belongs to. |
493 | */ |
494 | |
5a5b35c5 |
495 | void lttvwindow_unregister_filter_notify(MainWindow * main_win, |
496 | LttvHook hook, |
497 | gpointer hook_data) |
561f5852 |
498 | { |
499 | LttvAttributeValue value; |
500 | LttvHooks * tmp; |
bca3b81f |
501 | g_assert(lttv_iattribute_find_by_path(main_win->attributes, |
d2811a98 |
502 | "hooks/updatefilter", LTTV_POINTER, &value)); |
561f5852 |
503 | tmp = (LttvHooks*)*(value.v_pointer); |
504 | if(tmp == NULL) return; |
505 | lttv_hooks_remove_data(tmp, hook, hook_data); |
506 | } |
507 | |
561f5852 |
508 | /** |
509 | * Function to register a hook function for a viewer to set/update its |
510 | * current time. |
561f5852 |
511 | * @param hook hook function of the viewer. |
512 | * @param hook_data hook data associated with the hook function. |
513 | * @param main_win the main window the viewer belongs to. |
514 | */ |
515 | |
224446ce |
516 | void lttvwindow_register_current_time_notify(MainWindow *main_win, |
517 | LttvHook hook, gpointer hook_data) |
561f5852 |
518 | { |
519 | LttvAttributeValue value; |
520 | LttvHooks * tmp; |
bca3b81f |
521 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
d2811a98 |
522 | "hooks/updatecurrenttime", LTTV_POINTER, &value)); |
561f5852 |
523 | tmp = (LttvHooks*)*(value.v_pointer); |
524 | if(tmp == NULL){ |
525 | tmp = lttv_hooks_new(); |
526 | *(value.v_pointer) = tmp; |
527 | } |
528 | lttv_hooks_add(tmp, hook, hook_data); |
529 | } |
530 | |
531 | |
532 | /** |
533 | * Function to unregister a viewer's hook function which is used to |
534 | * set/update the current time of the viewer. |
561f5852 |
535 | * @param hook hook function of the viewer. |
536 | * @param hook_data hook data associated with the hook function. |
537 | * @param main_win the main window the viewer belongs to. |
538 | */ |
539 | |
224446ce |
540 | void lttvwindow_unregister_current_time_notify(MainWindow * main_win, |
541 | LttvHook hook, gpointer hook_data) |
561f5852 |
542 | { |
543 | LttvAttributeValue value; |
544 | LttvHooks * tmp; |
bca3b81f |
545 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
d2811a98 |
546 | "hooks/updatecurrenttime", LTTV_POINTER, &value)); |
561f5852 |
547 | tmp = (LttvHooks*)*(value.v_pointer); |
548 | if(tmp == NULL) return; |
549 | lttv_hooks_remove_data(tmp, hook, hook_data); |
550 | } |
551 | |
552 | |
202f6c8f |
553 | /** |
554 | * Function to register a hook function for a viewer to show |
224446ce |
555 | * the content of the viewer. |
202f6c8f |
556 | * @param hook hook function of the viewer. |
557 | * @param hook_data hook data associated with the hook function. |
558 | * @param main_win the main window the viewer belongs to. |
559 | */ |
560 | |
a43d67ba |
561 | void lttvwindow_register_show_notify(MainWindow *main_win, |
224446ce |
562 | LttvHook hook, gpointer hook_data) |
202f6c8f |
563 | { |
564 | LttvAttributeValue value; |
565 | LttvHooks * tmp; |
566 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
d2811a98 |
567 | "hooks/showviewer", LTTV_POINTER, &value)); |
202f6c8f |
568 | tmp = (LttvHooks*)*(value.v_pointer); |
569 | if(tmp == NULL){ |
570 | tmp = lttv_hooks_new(); |
571 | *(value.v_pointer) = tmp; |
572 | } |
573 | lttv_hooks_add(tmp, hook, hook_data); |
574 | } |
575 | |
576 | |
577 | /** |
578 | * Function to unregister a viewer's hook function which is used to |
579 | * show the content of the viewer.. |
202f6c8f |
580 | * @param hook hook function of the viewer. |
581 | * @param hook_data hook data associated with the hook function. |
582 | * @param main_win the main window the viewer belongs to. |
583 | */ |
584 | |
a43d67ba |
585 | void lttvwindow_unregister_show_notify(MainWindow * main_win, |
224446ce |
586 | LttvHook hook, gpointer hook_data) |
202f6c8f |
587 | { |
588 | LttvAttributeValue value; |
589 | LttvHooks * tmp; |
590 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
d2811a98 |
591 | "hooks/showviewer", LTTV_POINTER, &value)); |
202f6c8f |
592 | tmp = (LttvHooks*)*(value.v_pointer); |
593 | if(tmp == NULL) return; |
594 | lttv_hooks_remove_data(tmp, hook, hook_data); |
595 | } |
596 | |
561f5852 |
597 | /** |
598 | * Function to register a hook function for a viewer to set/update the |
599 | * dividor of the hpane. |
561f5852 |
600 | * @param hook hook function of the viewer. |
601 | * @param hook_data hook data associated with the hook function. |
602 | * @param main_win the main window the viewer belongs to. |
603 | */ |
604 | |
224446ce |
605 | void lttvwindow_register_dividor(MainWindow *main_win, |
606 | LttvHook hook, gpointer hook_data) |
561f5852 |
607 | { |
608 | LttvAttributeValue value; |
609 | LttvHooks * tmp; |
bca3b81f |
610 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
d2811a98 |
611 | "hooks/hpanedividor", LTTV_POINTER, &value)); |
561f5852 |
612 | tmp = (LttvHooks*)*(value.v_pointer); |
613 | if(tmp == NULL){ |
614 | tmp = lttv_hooks_new(); |
615 | *(value.v_pointer) = tmp; |
616 | } |
617 | lttv_hooks_add(tmp, hook, hook_data); |
618 | } |
619 | |
620 | |
621 | /** |
622 | * Function to unregister a viewer's hook function which is used to |
623 | * set/update hpane's dividor of the viewer. |
624 | * It will be called by the destructor of the viewer. |
625 | * @param hook hook function of the viewer. |
626 | * @param hook_data hook data associated with the hook function. |
627 | * @param main_win the main window the viewer belongs to. |
628 | */ |
629 | |
224446ce |
630 | void lttvwindow_unregister_dividor(MainWindow *main_win, |
631 | LttvHook hook, gpointer hook_data) |
561f5852 |
632 | { |
633 | LttvAttributeValue value; |
634 | LttvHooks * tmp; |
bca3b81f |
635 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
d2811a98 |
636 | "hooks/hpanedividor", LTTV_POINTER, &value)); |
561f5852 |
637 | tmp = (LttvHooks*)*(value.v_pointer); |
638 | if(tmp == NULL) return; |
639 | lttv_hooks_remove_data(tmp, hook, hook_data); |
640 | } |
641 | |
642 | |
224446ce |
643 | /** |
644 | * Update the status bar whenever something changed in the viewer. |
645 | * @param main_win the main window the viewer belongs to. |
646 | * @param info the message which will be shown in the status bar. |
647 | */ |
648 | |
5a5b35c5 |
649 | void lttvwindow_report_status(MainWindow *main_win, const char *info) |
224446ce |
650 | { |
651 | //FIXME |
652 | g_warning("update_status not implemented in viewer.c"); |
653 | } |
654 | |
655 | /** |
656 | * Function to set the time interval of the current tab. |
657 | * It will be called by a viewer's signal handle associated with |
658 | * the move_slider signal |
659 | * @param main_win the main window the viewer belongs to. |
660 | * @param time_interval a pointer where time interval is stored. |
661 | */ |
662 | |
663 | void lttvwindow_report_time_window(MainWindow *main_win, |
5a5b35c5 |
664 | const TimeWindow *time_window) |
224446ce |
665 | { |
a43d67ba |
666 | set_time_window(main_win, time_window); |
667 | set_time_window_adjustment(main_win, time_window); |
224446ce |
668 | } |
669 | |
a43d67ba |
670 | |
224446ce |
671 | /** |
672 | * Function to set the current time/event of the current tab. |
673 | * It will be called by a viewer's signal handle associated with |
674 | * the button-release-event signal |
675 | * @param main_win the main window the viewer belongs to. |
676 | * @param time a pointer where time is stored. |
677 | */ |
678 | |
5a5b35c5 |
679 | void lttvwindow_report_current_time(MainWindow *main_win, |
680 | const LttTime *time) |
224446ce |
681 | { |
682 | LttvAttributeValue value; |
683 | LttvHooks * tmp; |
684 | main_win->current_tab->current_time = *time; |
685 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
686 | "hooks/updatecurrenttime", LTTV_POINTER, &value)); |
687 | tmp = (LttvHooks*)*(value.v_pointer); |
688 | |
689 | if(tmp == NULL)return; |
5a5b35c5 |
690 | lttv_hooks_call(tmp, &main_win->current_tab->current_time); |
224446ce |
691 | } |
692 | |
561f5852 |
693 | /** |
694 | * Function to set the position of the hpane's dividor (viewer). |
695 | * It will be called by a viewer's signal handle associated with |
696 | * the motion_notify_event event/signal |
697 | * @param main_win the main window the viewer belongs to. |
698 | * @param position position of the hpane's dividor. |
699 | */ |
700 | |
224446ce |
701 | void lttvwindow_report_dividor(MainWindow *main_win, gint position) |
561f5852 |
702 | { |
703 | LttvAttributeValue value; |
704 | LttvHooks * tmp; |
bca3b81f |
705 | g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes, |
d2811a98 |
706 | "hooks/hpanedividor", LTTV_POINTER, &value)); |
561f5852 |
707 | tmp = (LttvHooks*)*(value.v_pointer); |
708 | if(tmp == NULL) return; |
709 | lttv_hooks_call(tmp, &position); |
710 | } |
711 | |
224446ce |
712 | /** |
713 | * Function to set the focused pane (viewer). |
714 | * It will be called by a viewer's signal handle associated with |
715 | * the grab_focus signal |
716 | * @param main_win the main window the viewer belongs to. |
5a5b35c5 |
717 | * @param top_widget the top widget containing all the other widgets of the |
718 | * viewer. |
224446ce |
719 | */ |
720 | |
5a5b35c5 |
721 | void lttvwindow_report_focus(MainWindow *main_win, GtkWidget *top_widget) |
224446ce |
722 | { |
5a5b35c5 |
723 | gtk_multi_vpaned_set_focus((GtkWidget*)main_win->current_tab->multi_vpaned, |
724 | gtk_widget_get_parent(top_widget)); |
224446ce |
725 | } |
726 | |
727 | |
a43d67ba |
728 | /** |
729 | * Function to request data in a specific time interval to the main window. |
730 | * The main window will use this time interval and the others present |
731 | * to get the data from the process trace. |
732 | * @param main_win the main window the viewer belongs to. |
733 | * @param paned a pointer to a pane where the viewer is contained. |
734 | */ |
735 | |
736 | void lttvwindow_time_interval_request(MainWindow *main_win, |
737 | TimeWindow time_requested, guint num_events, |
738 | LttvHook after_process_traceset, |
739 | gpointer after_process_traceset_data) |
740 | { |
741 | TimeRequest time_request; |
742 | |
743 | time_request.time_window = time_requested; |
744 | time_request.num_events = num_events; |
745 | time_request.after_hook = after_process_traceset; |
746 | time_request.after_hook_data = after_process_traceset_data; |
747 | |
748 | g_array_append_val(main_win->current_tab->time_requests, time_request); |
749 | |
750 | if(!main_win->current_tab->time_request_pending) |
751 | { |
752 | /* Redraw has +20 priority. We want a prio higher than that, so +19 */ |
753 | g_idle_add_full((G_PRIORITY_HIGH_IDLE + 19), |
754 | (GSourceFunc)execute_time_requests, |
755 | main_win, |
756 | NULL); |
757 | main_win->current_tab->time_request_pending = TRUE; |
758 | } |
759 | } |
760 | |
224446ce |
761 | /** |
762 | * Function to get the current time interval shown on the current tab. |
763 | * It will be called by a viewer's hook function to update the |
764 | * shown time interval of the viewer and also be called by the constructor |
765 | * of the viewer. |
766 | * @param main_win the main window the viewer belongs to. |
767 | * @param time_interval a pointer where time interval will be stored. |
768 | */ |
769 | |
770 | const TimeWindow *lttvwindow_get_time_window(MainWindow *main_win) |
771 | { |
772 | //time_window->start_time = main_win->current_tab->time_window.start_time; |
773 | //time_window->time_width = main_win->current_tab->time_window.time_width; |
774 | return &(main_win->current_tab->time_window); |
775 | |
776 | } |
777 | |
778 | |
779 | /** |
780 | * Function to get the current time/event of the current tab. |
781 | * It will be called by a viewer's hook function to update the |
782 | * current time/event of the viewer. |
783 | * @param main_win the main window the viewer belongs to. |
784 | * @param time a pointer where time will be stored. |
785 | */ |
786 | |
787 | const LttTime *lttvwindow_get_current_time(MainWindow *main_win) |
788 | { |
789 | return &(main_win->current_tab->current_time); |
790 | } |
791 | |
792 | |
224446ce |
793 | /** |
794 | * Function to get the filter of the current tab. |
795 | * It will be called by the constructor of the viewer and also be |
796 | * called by a hook funtion of the viewer to update its filter. |
797 | * @param main_win, the main window the viewer belongs to. |
798 | * @param filter, a pointer to a filter. |
799 | */ |
800 | const lttv_filter *lttvwindow_get_filter(MainWindow *main_win) |
801 | { |
802 | //FIXME |
803 | g_warning("lttvwindow_get_filter not implemented in viewer.c"); |
804 | } |
805 | |
806 | |
6b1d3120 |
807 | /** |
808 | * Function to get the stats of the traceset |
809 | * @param main_win the main window the viewer belongs to. |
810 | */ |
811 | |
224446ce |
812 | LttvTracesetStats* lttvwindow_get_traceset_stats(MainWindow *main_win) |
6b1d3120 |
813 | { |
716e4367 |
814 | return main_win->current_tab->traceset_info->traceset_context; |
6b1d3120 |
815 | } |
a8c0f09d |
816 | |
817 | |
224446ce |
818 | LttvTracesetContext* lttvwindow_get_traceset_context(MainWindow *main_win) |
a8c0f09d |
819 | { |
820 | return (LttvTracesetContext*)main_win->current_tab->traceset_info->traceset_context; |
821 | } |