Commit | Line | Data |
---|---|---|
501e4e70 | 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 | ||
19 | /*! \file lttvwindow.c | |
20 | * \brief API used by the graphical viewers to interact with their tab. | |
21 | * | |
22 | * Main window (gui module) is the place to contain and display viewers. | |
23 | * Viewers (lttv plugins) interact with tab and main window through this API | |
24 | * and 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 their tab and | |
27 | * main window. | |
28 | * | |
29 | */ | |
30 | ||
4e4d11b3 | 31 | #ifdef HAVE_CONFIG_H |
32 | #include <config.h> | |
33 | #endif | |
34 | ||
501e4e70 | 35 | #include <ltt/ltt.h> |
36 | #include <lttv/lttv.h> | |
37 | #include <lttv/state.h> | |
451aaf27 | 38 | #ifdef BABEL_CLEANUP |
501e4e70 | 39 | #include <lttv/stats.h> |
451aaf27 | 40 | #endif /* BABEL_CLEANUP */ |
501e4e70 | 41 | #include <lttvwindow/mainwindow.h> |
2d262115 | 42 | #include <lttvwindow/mainwindow-private.h> |
501e4e70 | 43 | #include <lttvwindow/lttvwindow.h> |
44 | #include <lttvwindow/toolbar.h> | |
45 | #include <lttvwindow/menu.h> | |
46 | #include <lttvwindow/callbacks.h> // for execute_events_requests | |
47 | #include <lttvwindow/support.h> | |
48 | ||
501e4e70 | 49 | /** |
50 | * Internal function parts | |
51 | */ | |
52 | ||
53 | extern GSList * g_main_window_list; | |
54 | ||
f9240312 | 55 | __EXPORT gint lttvwindow_preempt_count = 0; |
3c456a8a | 56 | |
b052368a | 57 | /* set_time_window |
58 | * | |
59 | * It updates the time window of the tab, then calls the updatetimewindow | |
60 | * hooks of each viewer. | |
61 | * | |
62 | * This is called whenever the scrollbar value changes. | |
63 | */ | |
501e4e70 | 64 | |
65 | void set_time_window(Tab *tab, const TimeWindow *time_window) | |
66 | { | |
67 | LttvAttributeValue value; | |
68 | LttvHooks * tmp; | |
8f318283 | 69 | gboolean retval; |
501e4e70 | 70 | |
71 | TimeWindowNotifyData time_window_notify_data; | |
72 | TimeWindow old_time_window = tab->time_window; | |
73 | time_window_notify_data.old_time_window = &old_time_window; | |
74 | tab->time_window = *time_window; | |
75 | time_window_notify_data.new_time_window = | |
76 | &(tab->time_window); | |
77 | ||
8f318283 BP |
78 | retval= lttv_iattribute_find_by_path(tab->attributes, |
79 | "hooks/updatetimewindow", LTTV_POINTER, &value); | |
80 | g_assert(retval); | |
501e4e70 | 81 | tmp = (LttvHooks*)*(value.v_pointer); |
b052368a | 82 | if(tmp != NULL) lttv_hooks_call(tmp, &time_window_notify_data); |
501e4e70 | 83 | |
b052368a | 84 | //gtk_multi_vpaned_set_adjust(tab->multi_vpaned, new_time_window, FALSE); |
501e4e70 | 85 | |
86 | } | |
87 | ||
db8bc917 | 88 | /* set_current_time |
89 | * | |
90 | * It updates the current time of the tab, then calls the updatetimewindow | |
91 | * hooks of each viewer. | |
92 | * | |
93 | * This is called whenever the current time value changes. | |
94 | */ | |
95 | ||
96 | void set_current_time(Tab *tab, const LttTime *current_time) | |
97 | { | |
98 | LttvAttributeValue value; | |
99 | LttvHooks * tmp; | |
8f318283 | 100 | gboolean retval; |
db8bc917 | 101 | |
102 | tab->current_time = *current_time; | |
103 | ||
8f318283 BP |
104 | retval= lttv_iattribute_find_by_path(tab->attributes, |
105 | "hooks/updatecurrenttime", LTTV_POINTER, &value); | |
106 | g_assert(retval); | |
db8bc917 | 107 | tmp = (LttvHooks*)*(value.v_pointer); |
108 | if(tmp != NULL) lttv_hooks_call(tmp, &tab->current_time); | |
109 | } | |
110 | ||
5290ec02 | 111 | /* set_current_position |
112 | * | |
113 | * It updates the current time of the tab, then calls the updatetimewindow | |
114 | * hooks of each viewer. | |
115 | * | |
116 | * This is called whenever the current time value changes. | |
117 | */ | |
118 | ||
451aaf27 | 119 | void set_current_position(Tab *tab, const LttvTracesetPosition *pos) |
5290ec02 | 120 | { |
451aaf27 FD |
121 | #ifdef BABEL_CLEANUP |
122 | ||
5290ec02 | 123 | LttvAttributeValue value; |
124 | LttvHooks * tmp; | |
8f318283 | 125 | gboolean retval; |
5290ec02 | 126 | |
127 | tab->current_time = lttv_traceset_context_position_get_time(pos); | |
128 | ||
8f318283 BP |
129 | retval= lttv_iattribute_find_by_path(tab->attributes, |
130 | "hooks/updatecurrentposition", LTTV_POINTER, &value); | |
131 | g_assert(retval); | |
5290ec02 | 132 | tmp = (LttvHooks*)*(value.v_pointer); |
8d8c5ea7 AM |
133 | if (tmp != NULL) { |
134 | lttv_hooks_call(tmp, (void *) pos); | |
135 | } | |
451aaf27 | 136 | #endif /*BABEL_CLEANUP*/ |
5290ec02 | 137 | } |
138 | ||
501e4e70 | 139 | void add_toolbar_constructor(MainWindow *mw, LttvToolbarClosure *toolbar_c) |
140 | { | |
141 | LttvIAttribute *attributes = mw->attributes; | |
142 | LttvAttributeValue value; | |
143 | LttvToolbars * instance_toolbar; | |
144 | lttvwindow_viewer_constructor constructor; | |
145 | GtkWidget * tool_menu_title_menu, *new_widget, *pixmap; | |
146 | GdkPixbuf *pixbuf; | |
8f318283 | 147 | gboolean retval; |
501e4e70 | 148 | |
8f318283 BP |
149 | retval= lttv_iattribute_find_by_path(attributes, "viewers/toolbar", |
150 | LTTV_POINTER, &value); | |
151 | g_assert(retval); | |
501e4e70 | 152 | if(*(value.v_pointer) == NULL) |
153 | *(value.v_pointer) = lttv_toolbars_new(); | |
154 | instance_toolbar = (LttvToolbars*)*(value.v_pointer); | |
155 | ||
156 | constructor = toolbar_c->con; | |
157 | tool_menu_title_menu = lookup_widget(mw->mwindow,"MToolbar1"); | |
158 | pixbuf = gdk_pixbuf_new_from_xpm_data((const char**)toolbar_c->pixmap); | |
159 | pixmap = gtk_image_new_from_pixbuf(pixbuf); | |
160 | new_widget = | |
161 | gtk_toolbar_append_element (GTK_TOOLBAR (tool_menu_title_menu), | |
162 | GTK_TOOLBAR_CHILD_BUTTON, | |
163 | NULL, | |
164 | "", | |
165 | toolbar_c->tooltip, NULL, | |
166 | pixmap, NULL, NULL); | |
167 | gtk_label_set_use_underline( | |
168 | GTK_LABEL (((GtkToolbarChild*) ( | |
169 | g_list_last (GTK_TOOLBAR | |
170 | (tool_menu_title_menu)->children)->data))->label), | |
171 | TRUE); | |
172 | gtk_container_set_border_width (GTK_CONTAINER (new_widget), 1); | |
173 | g_signal_connect ((gpointer) new_widget, | |
174 | "clicked", | |
175 | G_CALLBACK (insert_viewer_wrap), | |
176 | constructor); | |
177 | gtk_widget_show (new_widget); | |
178 | ||
179 | lttv_toolbars_add(instance_toolbar, toolbar_c->con, | |
180 | toolbar_c->tooltip, | |
181 | toolbar_c->pixmap, | |
182 | new_widget); | |
183 | ||
184 | } | |
185 | ||
186 | void add_menu_constructor(MainWindow *mw, LttvMenuClosure *menu_c) | |
187 | { | |
188 | LttvIAttribute *attributes = mw->attributes; | |
189 | LttvAttributeValue value; | |
190 | LttvToolbars * instance_menu; | |
191 | lttvwindow_viewer_constructor constructor; | |
192 | GtkWidget * tool_menu_title_menu, *new_widget; | |
8f318283 | 193 | gboolean retval; |
501e4e70 | 194 | |
8f318283 BP |
195 | retval= lttv_iattribute_find_by_path(attributes, "viewers/menu", |
196 | LTTV_POINTER, &value); | |
197 | g_assert(retval); | |
501e4e70 | 198 | if(*(value.v_pointer) == NULL) |
199 | *(value.v_pointer) = lttv_menus_new(); | |
200 | instance_menu = (LttvMenus*)*(value.v_pointer); | |
201 | ||
202 | ||
203 | constructor = menu_c->con; | |
204 | tool_menu_title_menu = lookup_widget(mw->mwindow,"ToolMenuTitle_menu"); | |
205 | new_widget = | |
206 | gtk_menu_item_new_with_mnemonic (menu_c->menu_text); | |
207 | gtk_container_add (GTK_CONTAINER (tool_menu_title_menu), | |
208 | new_widget); | |
209 | g_signal_connect ((gpointer) new_widget, "activate", | |
210 | G_CALLBACK (insert_viewer_wrap), | |
211 | constructor); | |
212 | gtk_widget_show (new_widget); | |
213 | lttv_menus_add(instance_menu, menu_c->con, | |
214 | menu_c->menu_path, | |
215 | menu_c->menu_text, | |
216 | new_widget); | |
217 | } | |
218 | ||
219 | void remove_toolbar_constructor(MainWindow *mw, lttvwindow_viewer_constructor viewer_constructor) | |
220 | { | |
221 | LttvIAttribute *attributes = mw->attributes; | |
222 | LttvAttributeValue value; | |
223 | LttvToolbars * instance_toolbar; | |
501e4e70 | 224 | GtkWidget * tool_menu_title_menu, *widget; |
8f318283 | 225 | gboolean retval; |
501e4e70 | 226 | |
8f318283 BP |
227 | retval= lttv_iattribute_find_by_path(attributes, "viewers/toolbar", |
228 | LTTV_POINTER, &value); | |
229 | g_assert(retval); | |
501e4e70 | 230 | if(*(value.v_pointer) == NULL) |
231 | *(value.v_pointer) = lttv_toolbars_new(); | |
232 | instance_toolbar = (LttvToolbars*)*(value.v_pointer); | |
233 | ||
234 | tool_menu_title_menu = lookup_widget(mw->mwindow,"MToolbar1"); | |
235 | widget = lttv_menus_remove(instance_toolbar, viewer_constructor); | |
236 | gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu), | |
237 | widget); | |
238 | } | |
239 | ||
240 | ||
241 | void remove_menu_constructor(MainWindow *mw, lttvwindow_viewer_constructor viewer_constructor) | |
242 | { | |
243 | LttvIAttribute *attributes = mw->attributes; | |
244 | LttvAttributeValue value; | |
245 | LttvMenus * instance_menu; | |
501e4e70 | 246 | GtkWidget * tool_menu_title_menu, *widget; |
8f318283 | 247 | gboolean retval; |
501e4e70 | 248 | |
8f318283 BP |
249 | retval= lttv_iattribute_find_by_path(attributes, "viewers/menu", |
250 | LTTV_POINTER, &value); | |
251 | g_assert(retval); | |
501e4e70 | 252 | if(*(value.v_pointer) == NULL) |
253 | *(value.v_pointer) = lttv_menus_new(); | |
254 | instance_menu = (LttvMenus*)*(value.v_pointer); | |
255 | ||
256 | widget = lttv_menus_remove(instance_menu, viewer_constructor); | |
257 | tool_menu_title_menu = lookup_widget(mw->mwindow,"ToolMenuTitle_menu"); | |
258 | gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu), widget); | |
259 | } | |
260 | ||
261 | ||
262 | /** | |
263 | * API parts | |
264 | */ | |
265 | ||
266 | ||
267 | /** | |
268 | * Function to register a view constructor so that main window can generate | |
269 | * a menu item and a toolbar item for the viewer in order to generate a new | |
270 | * instance easily. A menu entry and toolbar item will be added to each main | |
271 | * window. | |
272 | * | |
273 | * It should be called by init function of the module. | |
274 | * | |
e025a729 | 275 | * @param name name of the viewer |
501e4e70 | 276 | * @param menu_path path of the menu item. |
277 | * @param menu_text text of the menu item. | |
278 | * @param pixmap Image shown on the toolbar item. | |
279 | * @param tooltip tooltip of the toolbar item. | |
280 | * @param view_constructor constructor of the viewer. | |
281 | */ | |
282 | ||
f9240312 | 283 | __EXPORT void lttvwindow_register_constructor |
e025a729 | 284 | (char * name, |
285 | char * menu_path, | |
501e4e70 | 286 | char * menu_text, |
287 | char ** pixmap, | |
288 | char * tooltip, | |
289 | lttvwindow_viewer_constructor view_constructor) | |
290 | { | |
291 | LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes()); | |
292 | LttvToolbars * toolbar; | |
293 | LttvMenus * menu; | |
294 | LttvToolbarClosure toolbar_c; | |
295 | LttvMenuClosure menu_c; | |
296 | LttvAttributeValue value; | |
8f318283 | 297 | gboolean retval; |
501e4e70 | 298 | |
e025a729 | 299 | if(view_constructor == NULL) return; |
300 | ||
501e4e70 | 301 | if(pixmap != NULL) { |
8f318283 BP |
302 | retval= lttv_iattribute_find_by_path(attributes_global, "viewers/toolbar", |
303 | LTTV_POINTER, &value); | |
304 | g_assert(retval); | |
501e4e70 | 305 | toolbar = (LttvToolbars*)*(value.v_pointer); |
306 | ||
307 | if(toolbar == NULL) { | |
308 | toolbar = lttv_toolbars_new(); | |
309 | *(value.v_pointer) = toolbar; | |
310 | } | |
311 | toolbar_c = lttv_toolbars_add(toolbar, view_constructor, tooltip, pixmap, | |
312 | NULL); | |
313 | ||
314 | g_slist_foreach(g_main_window_list, | |
315 | (gpointer)add_toolbar_constructor, | |
316 | &toolbar_c); | |
317 | } | |
318 | ||
319 | if(menu_path != NULL) { | |
8f318283 BP |
320 | retval= lttv_iattribute_find_by_path(attributes_global, "viewers/menu", |
321 | LTTV_POINTER, &value); | |
322 | g_assert(retval); | |
501e4e70 | 323 | menu = (LttvMenus*)*(value.v_pointer); |
324 | ||
325 | if(menu == NULL) { | |
326 | menu = lttv_menus_new(); | |
327 | *(value.v_pointer) = menu; | |
328 | } | |
329 | menu_c = lttv_menus_add(menu, view_constructor, menu_path, menu_text,NULL); | |
330 | ||
331 | g_slist_foreach(g_main_window_list, | |
332 | (gpointer)add_menu_constructor, | |
333 | &menu_c); | |
334 | } | |
e025a729 | 335 | { |
336 | LttvAttribute *attribute; | |
96c9eb79 | 337 | gboolean result; |
338 | ||
339 | attribute = LTTV_ATTRIBUTE(lttv_iattribute_find_subdir( | |
340 | LTTV_IATTRIBUTE(attributes_global), | |
341 | LTTV_VIEWER_CONSTRUCTORS)); | |
342 | g_assert(attribute); | |
e025a729 | 343 | |
96c9eb79 | 344 | result = lttv_iattribute_find_by_path(LTTV_IATTRIBUTE(attribute), |
345 | name, LTTV_POINTER, &value); | |
346 | g_assert(result); | |
e025a729 | 347 | |
348 | *(value.v_pointer) = view_constructor; | |
349 | ||
350 | } | |
501e4e70 | 351 | } |
352 | ||
353 | ||
354 | /** | |
355 | * Function to unregister the viewer's constructor, release the space | |
356 | * occupied by menu_path, menu_text, pixmap, tooltip and constructor of the | |
357 | * viewer. | |
358 | * | |
359 | * It will be called when a module is unloaded. | |
360 | * | |
361 | * @param view_constructor constructor of the viewer. | |
362 | */ | |
363 | ||
364 | ||
f9240312 | 365 | __EXPORT void lttvwindow_unregister_constructor |
501e4e70 | 366 | (lttvwindow_viewer_constructor view_constructor) |
367 | { | |
368 | LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes()); | |
369 | LttvToolbars * toolbar; | |
370 | LttvMenus * menu; | |
371 | LttvAttributeValue value; | |
8f318283 BP |
372 | gboolean is_named; |
373 | gboolean retval; | |
501e4e70 | 374 | |
8f318283 BP |
375 | retval= lttv_iattribute_find_by_path(attributes_global, "viewers/toolbar", |
376 | LTTV_POINTER, &value); | |
377 | g_assert(retval); | |
501e4e70 | 378 | toolbar = (LttvToolbars*)*(value.v_pointer); |
379 | ||
380 | if(toolbar != NULL) { | |
381 | g_slist_foreach(g_main_window_list, | |
382 | (gpointer)remove_toolbar_constructor, | |
383 | view_constructor); | |
384 | lttv_toolbars_remove(toolbar, view_constructor); | |
385 | } | |
386 | ||
8f318283 BP |
387 | retval= lttv_iattribute_find_by_path(attributes_global, "viewers/menu", |
388 | LTTV_POINTER, &value); | |
389 | g_assert(retval); | |
501e4e70 | 390 | menu = (LttvMenus*)*(value.v_pointer); |
391 | ||
392 | if(menu != NULL) { | |
393 | g_slist_foreach(g_main_window_list, | |
394 | (gpointer)remove_menu_constructor, | |
395 | view_constructor); | |
396 | lttv_menus_remove(menu, view_constructor); | |
397 | } | |
e025a729 | 398 | |
399 | { | |
400 | LttvAttribute *attribute; | |
96c9eb79 | 401 | attribute = LTTV_ATTRIBUTE(lttv_iattribute_find_subdir( |
402 | LTTV_IATTRIBUTE(attributes_global), | |
403 | LTTV_VIEWER_CONSTRUCTORS)); | |
404 | g_assert(attribute); | |
e025a729 | 405 | |
406 | guint num = lttv_iattribute_get_number(LTTV_IATTRIBUTE(attribute)); | |
407 | guint i; | |
408 | LttvAttributeName name; | |
409 | LttvAttributeValue value; | |
410 | LttvAttributeType type; | |
411 | ||
412 | for(i=0;i<num;i++) { | |
c0cb4d12 | 413 | type = lttv_iattribute_get(LTTV_IATTRIBUTE(attribute), i, &name, &value, |
414 | &is_named); | |
e025a729 | 415 | g_assert(type == LTTV_POINTER); |
416 | if(*(value.v_pointer) == view_constructor) { | |
417 | lttv_iattribute_remove(LTTV_IATTRIBUTE(attribute), i); | |
418 | break; | |
419 | } | |
420 | } | |
421 | } | |
501e4e70 | 422 | } |
423 | ||
424 | ||
425 | /** | |
426 | * Function to register a hook function for a viewer to set/update its | |
427 | * time interval. | |
428 | * @param tab viewer's tab | |
429 | * @param hook hook function of the viewer. | |
430 | * @param hook_data hook data associated with the hook function. | |
431 | */ | |
f9240312 | 432 | __EXPORT void lttvwindow_register_time_window_notify(Tab *tab, |
501e4e70 | 433 | LttvHook hook, gpointer hook_data) |
434 | { | |
435 | LttvAttributeValue value; | |
436 | LttvHooks * tmp; | |
8f318283 BP |
437 | gboolean retval; |
438 | ||
439 | retval= lttv_iattribute_find_by_path(tab->attributes, | |
440 | "hooks/updatetimewindow", LTTV_POINTER, &value); | |
441 | g_assert(retval); | |
501e4e70 | 442 | tmp = (LttvHooks*)*(value.v_pointer); |
443 | if(tmp == NULL){ | |
444 | tmp = lttv_hooks_new(); | |
445 | *(value.v_pointer) = tmp; | |
446 | } | |
447 | lttv_hooks_add(tmp, hook,hook_data, LTTV_PRIO_DEFAULT); | |
448 | } | |
449 | ||
450 | ||
451 | /** | |
452 | * Function to unregister a viewer's hook function which is used to | |
453 | * set/update the time interval of the viewer. | |
454 | * @param tab viewer's tab | |
455 | * @param hook hook function of the viewer. | |
456 | * @param hook_data hook data associated with the hook function. | |
457 | */ | |
458 | ||
f9240312 | 459 | __EXPORT void lttvwindow_unregister_time_window_notify(Tab *tab, |
501e4e70 | 460 | LttvHook hook, gpointer hook_data) |
461 | { | |
462 | LttvAttributeValue value; | |
463 | LttvHooks * tmp; | |
8f318283 BP |
464 | gboolean retval; |
465 | ||
466 | retval= lttv_iattribute_find_by_path(tab->attributes, | |
467 | "hooks/updatetimewindow", LTTV_POINTER, &value); | |
468 | g_assert(retval); | |
1e3594a3 YB |
469 | tmp = (LttvHooks*)*(value.v_pointer); |
470 | if(tmp == NULL) return; | |
471 | lttv_hooks_remove_data(tmp, hook, hook_data); | |
472 | } | |
473 | ||
474 | /** | |
475 | * Function to register a hook function for a viewer to set/update its | |
476 | * allowed time span. | |
477 | * @param tab viewer's tab | |
478 | * @param hook hook function of the viewer. | |
479 | * @param hook_data hook data associated with the hook function. | |
480 | */ | |
68764dff | 481 | __EXPORT void lttvwindow_register_timespan_notify(Tab *tab, |
1e3594a3 YB |
482 | LttvHook hook, gpointer hook_data) |
483 | { | |
484 | LttvAttributeValue value; | |
485 | LttvHooks * tmp; | |
486 | gboolean retval; | |
487 | ||
488 | retval= lttv_iattribute_find_by_path(tab->attributes, | |
489 | "hooks/updatetimespan", LTTV_POINTER, &value); | |
490 | g_assert(retval); | |
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, LTTV_PRIO_DEFAULT); | |
497 | } | |
498 | /** | |
499 | * Function to unregister a viewer's hook function which is used to | |
500 | * set/update the time span allowed for the viewer. | |
501 | * @param tab viewer's tab | |
502 | * @param hook hook function of the viewer. | |
503 | * @param hook_data hook data associated with the hook function. | |
504 | */ | |
505 | ||
68764dff | 506 | __EXPORT void lttvwindow_unregister_timespan_notify(Tab *tab, |
1e3594a3 YB |
507 | LttvHook hook, gpointer hook_data) |
508 | { | |
509 | LttvAttributeValue value; | |
510 | LttvHooks * tmp; | |
511 | gboolean retval; | |
512 | ||
513 | retval= lttv_iattribute_find_by_path(tab->attributes, | |
514 | "hooks/updatetimespan", LTTV_POINTER, &value); | |
515 | g_assert(retval); | |
501e4e70 | 516 | tmp = (LttvHooks*)*(value.v_pointer); |
517 | if(tmp == NULL) return; | |
518 | lttv_hooks_remove_data(tmp, hook, hook_data); | |
519 | } | |
520 | ||
521 | /** | |
522 | * Function to register a hook function for a viewer to set/update its | |
523 | * traceset. | |
524 | * @param tab viewer's tab | |
525 | * @param hook hook function of the viewer. | |
526 | * @param hook_data hook data associated with the hook function. | |
527 | */ | |
528 | ||
f9240312 | 529 | __EXPORT void lttvwindow_register_traceset_notify(Tab *tab, |
501e4e70 | 530 | LttvHook hook, gpointer hook_data) |
531 | { | |
532 | LttvAttributeValue value; | |
533 | LttvHooks * tmp; | |
8f318283 BP |
534 | gboolean retval; |
535 | ||
536 | retval= lttv_iattribute_find_by_path(tab->attributes, | |
537 | "hooks/updatetraceset", LTTV_POINTER, &value); | |
538 | g_assert(retval); | |
501e4e70 | 539 | tmp = (LttvHooks*)*(value.v_pointer); |
540 | if(tmp == NULL){ | |
541 | tmp = lttv_hooks_new(); | |
542 | *(value.v_pointer) = tmp; | |
543 | } | |
544 | lttv_hooks_add(tmp, hook, hook_data, LTTV_PRIO_DEFAULT); | |
545 | } | |
546 | ||
547 | ||
548 | /** | |
549 | * Function to unregister a viewer's hook function which is used to | |
550 | * set/update the traceset of the viewer. | |
551 | * @param tab viewer's tab | |
552 | * @param hook hook function of the viewer. | |
553 | * @param hook_data hook data associated with the hook function. | |
554 | */ | |
555 | ||
f9240312 | 556 | __EXPORT void lttvwindow_unregister_traceset_notify(Tab *tab, |
501e4e70 | 557 | LttvHook hook, gpointer hook_data) |
558 | { | |
559 | LttvAttributeValue value; | |
560 | LttvHooks * tmp; | |
8f318283 BP |
561 | gboolean retval; |
562 | ||
563 | retval= lttv_iattribute_find_by_path(tab->attributes, | |
564 | "hooks/updatetraceset", LTTV_POINTER, &value); | |
565 | g_assert(retval); | |
501e4e70 | 566 | tmp = (LttvHooks*)*(value.v_pointer); |
567 | if(tmp == NULL) return; | |
568 | lttv_hooks_remove_data(tmp, hook, hook_data); | |
569 | } | |
570 | ||
9878c8a4 | 571 | /** |
572 | * Function to register a hook function for a viewer be completely redrawn. | |
573 | * | |
574 | * @param tab viewer's tab | |
575 | * @param hook hook function of the viewer. | |
576 | * @param hook_data hook data associated with the hook function. | |
577 | */ | |
578 | ||
f9240312 | 579 | __EXPORT void lttvwindow_register_redraw_notify(Tab *tab, |
9878c8a4 | 580 | LttvHook hook, gpointer hook_data) |
581 | { | |
582 | LttvAttributeValue value; | |
583 | LttvHooks * tmp; | |
8f318283 BP |
584 | gboolean retval; |
585 | ||
586 | retval= lttv_iattribute_find_by_path(tab->attributes, "hooks/redraw", | |
587 | LTTV_POINTER, &value); | |
588 | g_assert(retval); | |
9878c8a4 | 589 | tmp = (LttvHooks*)*(value.v_pointer); |
590 | if(tmp == NULL){ | |
591 | tmp = lttv_hooks_new(); | |
592 | *(value.v_pointer) = tmp; | |
593 | } | |
594 | lttv_hooks_add(tmp, hook, hook_data, LTTV_PRIO_DEFAULT); | |
595 | } | |
596 | ||
597 | ||
598 | /** | |
599 | * Function to unregister a hook function for a viewer be completely redrawn. | |
600 | * | |
601 | * @param tab viewer's tab | |
602 | * @param hook hook function of the viewer. | |
603 | * @param hook_data hook data associated with the hook function. | |
604 | */ | |
605 | ||
f9240312 | 606 | __EXPORT void lttvwindow_unregister_redraw_notify(Tab *tab, |
9878c8a4 | 607 | LttvHook hook, gpointer hook_data) |
608 | { | |
609 | LttvAttributeValue value; | |
610 | LttvHooks * tmp; | |
8f318283 BP |
611 | gboolean retval; |
612 | ||
613 | retval= lttv_iattribute_find_by_path(tab->attributes, "hooks/redraw", | |
614 | LTTV_POINTER, &value); | |
615 | g_assert(retval); | |
9878c8a4 | 616 | tmp = (LttvHooks*)*(value.v_pointer); |
617 | if(tmp == NULL) return; | |
618 | lttv_hooks_remove_data(tmp, hook, hook_data); | |
619 | } | |
620 | ||
621 | /** | |
622 | * Function to register a hook function for a viewer to re-do the events | |
623 | * requests for the needed interval. | |
624 | * | |
625 | * This action is typically done after a "stop". | |
626 | * | |
627 | * The typical hook will remove all current requests for the viewer | |
628 | * and make requests for missing information. | |
629 | * | |
630 | * @param tab viewer's tab | |
631 | * @param hook hook function of the viewer. | |
632 | * @param hook_data hook data associated with the hook function. | |
633 | */ | |
634 | ||
f9240312 | 635 | __EXPORT void lttvwindow_register_continue_notify(Tab *tab, |
9878c8a4 | 636 | LttvHook hook, gpointer hook_data) |
637 | { | |
638 | LttvAttributeValue value; | |
639 | LttvHooks * tmp; | |
8f318283 BP |
640 | gboolean retval; |
641 | ||
642 | retval= lttv_iattribute_find_by_path(tab->attributes, "hooks/continue", | |
643 | LTTV_POINTER, &value); | |
644 | g_assert(retval); | |
9878c8a4 | 645 | tmp = (LttvHooks*)*(value.v_pointer); |
646 | if(tmp == NULL){ | |
647 | tmp = lttv_hooks_new(); | |
648 | *(value.v_pointer) = tmp; | |
649 | } | |
650 | lttv_hooks_add(tmp, hook, hook_data, LTTV_PRIO_DEFAULT); | |
651 | } | |
652 | ||
653 | ||
654 | /** | |
655 | * Function to unregister a hook function for a viewer to re-do the events | |
656 | * requests for the needed interval. | |
657 | * | |
658 | * @param tab viewer's tab | |
659 | * @param hook hook function of the viewer. | |
660 | * @param hook_data hook data associated with the hook function. | |
661 | */ | |
662 | ||
f9240312 | 663 | __EXPORT void lttvwindow_unregister_continue_notify(Tab *tab, |
9878c8a4 | 664 | LttvHook hook, gpointer hook_data) |
665 | { | |
666 | LttvAttributeValue value; | |
667 | LttvHooks * tmp; | |
8f318283 BP |
668 | gboolean retval; |
669 | ||
670 | retval= lttv_iattribute_find_by_path(tab->attributes, "hooks/continue", | |
671 | LTTV_POINTER, &value); | |
672 | g_assert(retval); | |
9878c8a4 | 673 | tmp = (LttvHooks*)*(value.v_pointer); |
674 | if(tmp == NULL) return; | |
675 | lttv_hooks_remove_data(tmp, hook, hook_data); | |
676 | } | |
677 | ||
678 | ||
501e4e70 | 679 | /** |
680 | * Function to register a hook function for a viewer to set/update its | |
681 | * filter. | |
682 | * @param tab viewer's tab | |
683 | * @param hook hook function of the viewer. | |
684 | * @param hook_data hook data associated with the hook function. | |
685 | */ | |
686 | ||
f9240312 | 687 | __EXPORT void lttvwindow_register_filter_notify(Tab *tab, |
501e4e70 | 688 | LttvHook hook, gpointer hook_data) |
689 | { | |
690 | LttvAttributeValue value; | |
691 | LttvHooks * tmp; | |
8f318283 BP |
692 | gboolean retval; |
693 | ||
694 | retval= lttv_iattribute_find_by_path(tab->attributes, "hooks/updatefilter", | |
695 | LTTV_POINTER, &value); | |
696 | g_assert(retval); | |
501e4e70 | 697 | tmp = (LttvHooks*)*(value.v_pointer); |
698 | if(tmp == NULL){ | |
699 | tmp = lttv_hooks_new(); | |
700 | *(value.v_pointer) = tmp; | |
701 | } | |
702 | lttv_hooks_add(tmp, hook, hook_data, LTTV_PRIO_DEFAULT); | |
703 | } | |
704 | ||
705 | ||
706 | /** | |
707 | * Function to unregister a viewer's hook function which is used to | |
708 | * set/update the filter of the viewer. | |
709 | * @param tab viewer's tab | |
710 | * @param hook hook function of the viewer. | |
711 | * @param hook_data hook data associated with the hook function. | |
712 | */ | |
713 | ||
f9240312 | 714 | __EXPORT void lttvwindow_unregister_filter_notify(Tab *tab, |
501e4e70 | 715 | LttvHook hook, |
716 | gpointer hook_data) | |
717 | { | |
718 | LttvAttributeValue value; | |
719 | LttvHooks * tmp; | |
8f318283 BP |
720 | gboolean retval; |
721 | ||
722 | retval= lttv_iattribute_find_by_path(tab->attributes, "hooks/updatefilter", | |
723 | LTTV_POINTER, &value); | |
724 | g_assert(retval); | |
501e4e70 | 725 | tmp = (LttvHooks*)*(value.v_pointer); |
726 | if(tmp == NULL) return; | |
727 | lttv_hooks_remove_data(tmp, hook, hook_data); | |
728 | } | |
729 | ||
730 | /** | |
5290ec02 | 731 | * function to register a hook function for a viewer to set/update its |
501e4e70 | 732 | * current time. |
733 | * @param tab viewer's tab | |
734 | * @param hook hook function of the viewer. | |
735 | * @param hook_data hook data associated with the hook function. | |
736 | */ | |
737 | ||
f9240312 | 738 | __EXPORT void lttvwindow_register_current_time_notify(Tab *tab, |
501e4e70 | 739 | LttvHook hook, gpointer hook_data) |
740 | { | |
741 | LttvAttributeValue value; | |
742 | LttvHooks * tmp; | |
8f318283 BP |
743 | gboolean retval; |
744 | ||
745 | retval= lttv_iattribute_find_by_path(tab->attributes, | |
746 | "hooks/updatecurrenttime", LTTV_POINTER, &value); | |
747 | g_assert(retval); | |
501e4e70 | 748 | tmp = (LttvHooks*)*(value.v_pointer); |
749 | if(tmp == NULL){ | |
750 | tmp = lttv_hooks_new(); | |
751 | *(value.v_pointer) = tmp; | |
752 | } | |
753 | lttv_hooks_add(tmp, hook, hook_data, LTTV_PRIO_DEFAULT); | |
754 | } | |
755 | ||
756 | ||
757 | /** | |
5290ec02 | 758 | * function to unregister a viewer's hook function which is used to |
501e4e70 | 759 | * set/update the current time of the viewer. |
760 | * @param tab viewer's tab | |
761 | * @param hook hook function of the viewer. | |
762 | * @param hook_data hook data associated with the hook function. | |
763 | */ | |
764 | ||
f9240312 | 765 | __EXPORT void lttvwindow_unregister_current_time_notify(Tab *tab, |
501e4e70 | 766 | LttvHook hook, gpointer hook_data) |
767 | { | |
768 | LttvAttributeValue value; | |
769 | LttvHooks * tmp; | |
8f318283 BP |
770 | gboolean retval; |
771 | ||
772 | retval= lttv_iattribute_find_by_path(tab->attributes, | |
773 | "hooks/updatecurrenttime", LTTV_POINTER, &value); | |
774 | g_assert(retval); | |
501e4e70 | 775 | tmp = (LttvHooks*)*(value.v_pointer); |
776 | if(tmp == NULL) return; | |
777 | lttv_hooks_remove_data(tmp, hook, hook_data); | |
778 | } | |
779 | ||
5290ec02 | 780 | /** |
781 | * function to register a hook function for a viewer to set/update its | |
782 | * current position. | |
783 | * @param tab viewer's tab | |
784 | * @param hook hook function of the viewer. | |
785 | * @param hook_data hook data associated with the hook function. | |
786 | */ | |
787 | ||
f9240312 | 788 | __EXPORT void lttvwindow_register_current_position_notify(Tab *tab, |
5290ec02 | 789 | LttvHook hook, gpointer hook_data) |
790 | { | |
791 | LttvAttributeValue value; | |
792 | LttvHooks * tmp; | |
8f318283 BP |
793 | gboolean retval; |
794 | ||
795 | retval= lttv_iattribute_find_by_path(tab->attributes, | |
796 | "hooks/updatecurrentposition", LTTV_POINTER, &value); | |
797 | g_assert(retval); | |
5290ec02 | 798 | tmp = (LttvHooks*)*(value.v_pointer); |
799 | if(tmp == NULL){ | |
800 | tmp = lttv_hooks_new(); | |
801 | *(value.v_pointer) = tmp; | |
802 | } | |
803 | lttv_hooks_add(tmp, hook, hook_data, LTTV_PRIO_DEFAULT); | |
804 | } | |
805 | ||
806 | ||
807 | /** | |
808 | * function to unregister a viewer's hook function which is used to | |
809 | * set/update the current position of the viewer. | |
810 | * @param tab viewer's tab | |
811 | * @param hook hook function of the viewer. | |
812 | * @param hook_data hook data associated with the hook function. | |
813 | */ | |
814 | ||
f9240312 | 815 | __EXPORT void lttvwindow_unregister_current_position_notify(Tab *tab, |
5290ec02 | 816 | LttvHook hook, gpointer hook_data) |
817 | { | |
818 | LttvAttributeValue value; | |
819 | LttvHooks * tmp; | |
8f318283 BP |
820 | gboolean retval; |
821 | ||
822 | retval= lttv_iattribute_find_by_path(tab->attributes, | |
823 | "hooks/updatecurrentposition", LTTV_POINTER, &value); | |
824 | g_assert(retval); | |
5290ec02 | 825 | tmp = (LttvHooks*)*(value.v_pointer); |
826 | if(tmp == NULL) return; | |
827 | lttv_hooks_remove_data(tmp, hook, hook_data); | |
828 | } | |
829 | ||
501e4e70 | 830 | |
831 | /** | |
832 | * Function to register a hook function for a viewer to show | |
833 | * the content of the viewer. | |
834 | * @param tab viewer's tab | |
835 | * @param hook hook function of the viewer. | |
836 | * @param hook_data hook data associated with the hook function. | |
837 | */ | |
838 | ||
839 | void lttvwindow_register_show_notify(Tab *tab, | |
840 | LttvHook hook, gpointer hook_data) | |
841 | { | |
842 | LttvAttributeValue value; | |
843 | LttvHooks * tmp; | |
8f318283 BP |
844 | gboolean retval; |
845 | ||
846 | retval= lttv_iattribute_find_by_path(tab->attributes, "hooks/showviewer", | |
847 | LTTV_POINTER, &value); | |
848 | g_assert(retval); | |
501e4e70 | 849 | tmp = (LttvHooks*)*(value.v_pointer); |
850 | if(tmp == NULL){ | |
851 | tmp = lttv_hooks_new(); | |
852 | *(value.v_pointer) = tmp; | |
853 | } | |
854 | lttv_hooks_add(tmp, hook, hook_data, LTTV_PRIO_DEFAULT); | |
855 | } | |
856 | ||
857 | ||
858 | /** | |
859 | * Function to unregister a viewer's hook function which is used to | |
860 | * show the content of the viewer.. | |
861 | * @param tab viewer's tab | |
862 | * @param hook hook function of the viewer. | |
863 | * @param hook_data hook data associated with the hook function. | |
864 | */ | |
865 | ||
866 | void lttvwindow_unregister_show_notify(Tab *tab, | |
867 | LttvHook hook, gpointer hook_data) | |
868 | { | |
869 | LttvAttributeValue value; | |
870 | LttvHooks * tmp; | |
8f318283 BP |
871 | gboolean retval; |
872 | ||
873 | retval= lttv_iattribute_find_by_path(tab->attributes, "hooks/showviewer", | |
874 | LTTV_POINTER, &value); | |
875 | g_assert(retval); | |
501e4e70 | 876 | tmp = (LttvHooks*)*(value.v_pointer); |
877 | if(tmp == NULL) return; | |
878 | lttv_hooks_remove_data(tmp, hook, hook_data); | |
879 | } | |
880 | ||
881 | /** | |
882 | * Function to register a hook function for a viewer to set/update the | |
883 | * dividor of the hpane. | |
884 | * @param tab viewer's tab | |
885 | * @param hook hook function of the viewer. | |
886 | * @param hook_data hook data associated with the hook function. | |
887 | */ | |
888 | ||
889 | void lttvwindow_register_dividor(Tab *tab, | |
890 | LttvHook hook, gpointer hook_data) | |
891 | { | |
892 | LttvAttributeValue value; | |
893 | LttvHooks * tmp; | |
8f318283 BP |
894 | gboolean retval; |
895 | ||
896 | retval= lttv_iattribute_find_by_path(tab->attributes, "hooks/hpanedividor", | |
897 | LTTV_POINTER, &value); | |
898 | g_assert(retval); | |
501e4e70 | 899 | tmp = (LttvHooks*)*(value.v_pointer); |
900 | if(tmp == NULL){ | |
901 | tmp = lttv_hooks_new(); | |
902 | *(value.v_pointer) = tmp; | |
903 | } | |
904 | lttv_hooks_add(tmp, hook, hook_data, LTTV_PRIO_DEFAULT); | |
905 | } | |
906 | ||
907 | ||
908 | /** | |
909 | * Function to unregister a viewer's hook function which is used to | |
910 | * set/update hpane's dividor of the viewer. | |
911 | * It will be called by the destructor of the viewer. | |
912 | * @param tab viewer's tab | |
913 | * @param hook hook function of the viewer. | |
914 | * @param hook_data hook data associated with the hook function. | |
915 | */ | |
916 | ||
917 | void lttvwindow_unregister_dividor(Tab *tab, | |
918 | LttvHook hook, gpointer hook_data) | |
919 | { | |
920 | LttvAttributeValue value; | |
921 | LttvHooks * tmp; | |
8f318283 BP |
922 | gboolean retval; |
923 | ||
924 | retval= lttv_iattribute_find_by_path(tab->attributes, "hooks/hpanedividor", | |
925 | LTTV_POINTER, &value); | |
926 | g_assert(retval); | |
501e4e70 | 927 | tmp = (LttvHooks*)*(value.v_pointer); |
928 | if(tmp == NULL) return; | |
929 | lttv_hooks_remove_data(tmp, hook, hook_data); | |
930 | } | |
931 | ||
932 | ||
501e4e70 | 933 | /** |
934 | * Function to set the time interval of the current tab. | |
935 | * It will be called by a viewer's signal handle associated with | |
936 | * the move_slider signal | |
937 | * @param tab viewer's tab | |
938 | * @param time_interval a pointer where time interval is stored. | |
939 | */ | |
940 | ||
f9240312 | 941 | __EXPORT void lttvwindow_report_time_window(Tab *tab, |
942 | TimeWindow time_window) | |
501e4e70 | 943 | { |
b052368a | 944 | //set_time_window(tab, time_window); |
945 | //set_time_window_adjustment(tab, time_window); | |
946 | ||
e800cf84 | 947 | time_change_manager(tab, time_window); |
948 | ||
949 | ||
950 | #if 0 | |
b052368a | 951 | /* Set scrollbar */ |
952 | LttvTracesetContext *tsc = | |
953 | LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context); | |
954 | TimeInterval time_span = tsc->time_span; | |
955 | GtkAdjustment *adjustment = gtk_range_get_adjustment(GTK_RANGE(tab->scrollbar)); | |
b052368a | 956 | g_object_set(G_OBJECT(adjustment), |
957 | "lower", | |
0c5dbe3b | 958 | 0.0, /* lower */ |
b052368a | 959 | "upper", |
b9a010a2 | 960 | ltt_time_to_double( |
961 | ltt_time_sub(time_span.end_time, time_span.start_time)) | |
c74e0cf9 | 962 | , /* upper */ |
b052368a | 963 | "step_increment", |
964 | ltt_time_to_double(time_window->time_width) | |
965 | / SCROLL_STEP_PER_PAGE | |
c74e0cf9 | 966 | , /* step increment */ |
b052368a | 967 | "page_increment", |
968 | ltt_time_to_double(time_window->time_width) | |
c74e0cf9 | 969 | , /* page increment */ |
b052368a | 970 | "page_size", |
971 | ltt_time_to_double(time_window->time_width) | |
c74e0cf9 | 972 | , /* page size */ |
b052368a | 973 | NULL); |
974 | gtk_adjustment_changed(adjustment); | |
975 | ||
976 | //g_object_set(G_OBJECT(adjustment), | |
977 | // "value", | |
978 | // ltt_time_to_double(time_window->start_time) | |
c74e0cf9 | 979 | // , /* value */ |
b052368a | 980 | // NULL); |
981 | /* Note : the set value will call set_time_window if scrollbar value changed | |
982 | */ | |
983 | gtk_adjustment_set_value(adjustment, | |
b9a010a2 | 984 | ltt_time_to_double( |
985 | ltt_time_sub(time_window->start_time, | |
986 | time_span.start_time)) | |
c74e0cf9 | 987 | ); |
e800cf84 | 988 | #endif //0 |
501e4e70 | 989 | } |
990 | ||
991 | ||
992 | /** | |
5290ec02 | 993 | * Function to set the current time of the current tab. |
501e4e70 | 994 | * It will be called by a viewer's signal handle associated with |
995 | * the button-release-event signal | |
996 | * @param tab viewer's tab | |
997 | * @param time a pointer where time is stored. | |
998 | */ | |
999 | ||
f9240312 | 1000 | __EXPORT void lttvwindow_report_current_time(Tab *tab, |
e800cf84 | 1001 | LttTime time) |
501e4e70 | 1002 | { |
e800cf84 | 1003 | current_time_change_manager(tab, time); |
501e4e70 | 1004 | } |
1005 | ||
5290ec02 | 1006 | /** |
1007 | * Function to set the current event of the current tab. | |
1008 | * It will be called by a viewer's signal handle associated with | |
1009 | * the button-release-event signal | |
1010 | * @param tab viewer's tab | |
1011 | * @param time a pointer where time is stored. | |
1012 | */ | |
1013 | ||
f9240312 | 1014 | __EXPORT void lttvwindow_report_current_position(Tab *tab, |
451aaf27 | 1015 | LttvTracesetPosition *pos) |
5290ec02 | 1016 | { |
5290ec02 | 1017 | current_position_change_manager(tab, pos); |
1018 | } | |
1019 | ||
1020 | ||
501e4e70 | 1021 | /** |
1022 | * Function to set the position of the hpane's dividor (viewer). | |
1023 | * It will be called by a viewer's signal handle associated with | |
1024 | * the motion_notify_event event/signal | |
1025 | * @param tab viewer's tab | |
1026 | * @param position position of the hpane's dividor. | |
1027 | */ | |
1028 | ||
1029 | void lttvwindow_report_dividor(Tab *tab, gint position) | |
1030 | { | |
1031 | LttvAttributeValue value; | |
1032 | LttvHooks * tmp; | |
8f318283 BP |
1033 | gboolean retval; |
1034 | ||
1035 | retval= lttv_iattribute_find_by_path(tab->attributes, "hooks/hpanedividor", | |
1036 | LTTV_POINTER, &value); | |
1037 | g_assert(retval); | |
501e4e70 | 1038 | tmp = (LttvHooks*)*(value.v_pointer); |
1039 | if(tmp == NULL) return; | |
1040 | lttv_hooks_call(tmp, &position); | |
1041 | } | |
1042 | ||
501e4e70 | 1043 | /** |
1044 | * Function to request data in a specific time interval to the main window. The | |
1045 | * event request servicing is differed until the glib idle functions are | |
1046 | * called. | |
1047 | * | |
1048 | * The viewer has to provide hooks that should be associated with the event | |
1049 | * request. | |
1050 | * | |
1051 | * Either start time or start position must be defined in a EventRequest | |
1052 | * structure for it to be valid. | |
1053 | * | |
1054 | * end_time, end_position and num_events can all be defined. The first one | |
1055 | * to occur will be used as end criterion. | |
1056 | * | |
1057 | * @param tab viewer's tab | |
1058 | * @param events_requested the structure of request from. | |
1059 | */ | |
1060 | ||
f9240312 | 1061 | __EXPORT void lttvwindow_events_request(Tab *tab, |
1062 | EventsRequest *events_request) | |
501e4e70 | 1063 | { |
20fde85f | 1064 | tab->events_requests = g_slist_append(tab->events_requests, events_request); |
501e4e70 | 1065 | |
1066 | if(!tab->events_request_pending) | |
1067 | { | |
553d1e7b | 1068 | /* Redraw has +20 priority. We want to let the redraw be done while we do |
e140c5b3 | 1069 | * our job. Mathieu : test with high prio higher than events for better |
1070 | * scrolling. */ | |
c55068ce | 1071 | /* Mathieu, 2008 : ok, finally, the control flow view needs the cell updates |
1072 | * to come soon enough so we can have one active cell to get the pixmap | |
1073 | * buffer height from. Therefore, let the gdk events run before the events | |
1074 | * requests. | |
1075 | */ | |
1076 | g_idle_add_full((G_PRIORITY_HIGH_IDLE + 21), | |
1077 | //g_idle_add_full((G_PRIORITY_DEFAULT + 2), | |
501e4e70 | 1078 | (GSourceFunc)execute_events_requests, |
1079 | tab, | |
1080 | NULL); | |
1081 | tab->events_request_pending = TRUE; | |
1082 | } | |
1083 | } | |
1084 | ||
1085 | ||
1086 | /** | |
1087 | * Function to remove data requests related to a viewer. | |
1088 | * | |
1089 | * The existing requests's viewer gpointer is compared to the pointer | |
1090 | * given in argument to establish which data request should be removed. | |
1091 | * | |
1092 | * @param tab the tab the viewer belongs to. | |
1093 | * @param viewer a pointer to the viewer data structure | |
1094 | */ | |
1095 | ||
1096 | gint find_viewer (const EventsRequest *a, gconstpointer b) | |
1097 | { | |
2d262115 | 1098 | return (a->owner != b); |
501e4e70 | 1099 | } |
1100 | ||
1101 | ||
f9240312 | 1102 | __EXPORT void lttvwindow_events_request_remove_all(Tab *tab, |
501e4e70 | 1103 | gconstpointer viewer) |
1104 | { | |
6843100a | 1105 | GSList *element = tab->events_requests; |
501e4e70 | 1106 | |
1107 | while((element = | |
6843100a | 1108 | g_slist_find_custom(element, viewer, |
501e4e70 | 1109 | (GCompareFunc)find_viewer)) |
1110 | != NULL) { | |
2d262115 | 1111 | EventsRequest *events_request = (EventsRequest *)element->data; |
3bafb436 | 1112 | // Modified so a viewer being destroyed won't have its after_request |
1113 | // called. Not so important anyway. Note that a viewer that call this | |
1114 | // remove_all function will not get its after_request called. | |
1115 | //if(events_request->servicing == TRUE) { | |
1116 | // lttv_hooks_call(events_request->after_request, NULL); | |
1117 | //} | |
c5b5eee1 | 1118 | events_request_free(events_request); |
1119 | //g_free(events_request); | |
501e4e70 | 1120 | tab->events_requests = g_slist_remove_link(tab->events_requests, element); |
6843100a | 1121 | element = g_slist_next(element); |
1122 | if(element == NULL) break; /* end of list */ | |
501e4e70 | 1123 | } |
b052368a | 1124 | if(g_slist_length(tab->events_requests) == 0) { |
1125 | tab->events_request_pending = FALSE; | |
1126 | g_idle_remove_by_data(tab); | |
1127 | } | |
1128 | ||
501e4e70 | 1129 | } |
1130 | ||
efcd775d | 1131 | |
1132 | /** | |
1133 | * Function to see if there are events request pending. | |
1134 | * | |
1135 | * It tells if events requests are pending. Useful for checks in some events, | |
1136 | * i.e. detailed event list scrolling. | |
1137 | * | |
1138 | * @param tab the tab the viewer belongs to. | |
1139 | * @param viewer a pointer to the viewer data structure | |
1140 | * @return : TRUE is events requests are pending, else FALSE. | |
1141 | */ | |
1142 | ||
f9240312 | 1143 | __EXPORT gboolean lttvwindow_events_request_pending(Tab *tab) |
efcd775d | 1144 | { |
1145 | GSList *element = tab->events_requests; | |
1146 | ||
1147 | if(element == NULL) return FALSE; | |
1148 | else return TRUE; | |
1149 | } | |
1150 | ||
1151 | ||
50106726 | 1152 | /** |
1153 | * Function to get the current time interval shown on the current tab. | |
1154 | * It will be called by a viewer's hook function to update the | |
1155 | * shown time interval of the viewer and also be called by the constructor | |
1156 | * of the viewer. | |
1157 | * @param tab viewer's tab | |
1158 | * @return time window. | |
1159 | */ | |
1160 | ||
f9240312 | 1161 | __EXPORT TimeWindow lttvwindow_get_time_window(Tab *tab) |
50106726 | 1162 | { |
1163 | return tab->time_window; | |
1164 | } | |
1165 | ||
501e4e70 | 1166 | |
501e4e70 | 1167 | /** |
1168 | * Function to get the current time/event of the current tab. | |
1169 | * It will be called by a viewer's hook function to update the | |
1170 | * current time/event of the viewer. | |
1171 | * @param tab viewer's tab | |
6ea08962 | 1172 | * @return time |
501e4e70 | 1173 | */ |
1174 | ||
f9240312 | 1175 | __EXPORT LttTime lttvwindow_get_current_time(Tab *tab) |
501e4e70 | 1176 | { |
6ea08962 | 1177 | return tab->current_time; |
501e4e70 | 1178 | } |
1179 | ||
1180 | ||
1181 | /** | |
1182 | * Function to get the filter of the current tab. | |
501e4e70 | 1183 | * @param filter, a pointer to a filter. |
c790dfd9 | 1184 | * |
1185 | * returns the current filter | |
501e4e70 | 1186 | */ |
f9240312 | 1187 | __EXPORT LttvFilter *lttvwindow_get_filter(Tab *tab) |
501e4e70 | 1188 | { |
e433e6d6 | 1189 | return g_object_get_data(G_OBJECT(tab->vbox), "filter"); |
501e4e70 | 1190 | } |
1191 | ||
dc5e5266 | 1192 | /** |
1193 | * Function to set the filter of the current tab. | |
1194 | * It should be called by the filter GUI to tell the | |
1195 | * main window to update the filter tab's lttv_filter. | |
1196 | * | |
1197 | * This function does change the current filter, removing the | |
1198 | * old one when necessary, and call the updatefilter hooks | |
1199 | * of the registered viewers. | |
1200 | * | |
1201 | * @param main_win, the main window the viewer belongs to. | |
1202 | * @param filter, a pointer to a filter. | |
1203 | */ | |
dc5e5266 | 1204 | void lttvwindow_report_filter(Tab *tab, LttvFilter *filter) |
1205 | { | |
1206 | LttvAttributeValue value; | |
1207 | LttvHooks * tmp; | |
8f318283 | 1208 | gboolean retval; |
dc5e5266 | 1209 | |
e433e6d6 | 1210 | //lttv_filter_destroy(tab->filter); |
1211 | //tab->filter = filter; | |
dc5e5266 | 1212 | |
8f318283 BP |
1213 | retval= lttv_iattribute_find_by_path(tab->attributes, "hooks/updatefilter", |
1214 | LTTV_POINTER, &value); | |
1215 | g_assert(retval); | |
dc5e5266 | 1216 | tmp = (LttvHooks*)*(value.v_pointer); |
1217 | if(tmp == NULL) return; | |
962e2228 | 1218 | lttv_hooks_call(tmp, filter); |
dc5e5266 | 1219 | } |
1220 | ||
451aaf27 | 1221 | #ifdef BABEL_CLEANUP |
501e4e70 | 1222 | |
1223 | /** | |
1224 | * Function to get the stats of the traceset | |
1225 | * @param tab viewer's tab | |
1226 | */ | |
1227 | ||
f9240312 | 1228 | __EXPORT LttvTracesetStats* lttvwindow_get_traceset_stats(Tab *tab) |
501e4e70 | 1229 | { |
1230 | return tab->traceset_info->traceset_context; | |
1231 | } | |
451aaf27 | 1232 | #endif /*BABEL_CLEANUP*/ |
c5b5eee1 | 1233 | |
1234 | void events_request_free(EventsRequest *events_request) | |
1235 | { | |
451aaf27 | 1236 | #ifdef BABEL_CLEANUP |
c5b5eee1 | 1237 | if(events_request == NULL) return; |
1238 | ||
1239 | if(events_request->start_position != NULL) | |
1240 | lttv_traceset_context_position_destroy(events_request->start_position); | |
1241 | if(events_request->end_position != NULL) | |
1242 | lttv_traceset_context_position_destroy(events_request->end_position); | |
1243 | if(events_request->hooks != NULL) { | |
c5b5eee1 | 1244 | GArray *hooks = events_request->hooks; |
04348950 | 1245 | lttv_trace_hook_remove_all(&hooks); |
c5b5eee1 | 1246 | g_array_free(events_request->hooks, TRUE); |
1247 | } | |
1248 | if(events_request->before_chunk_traceset != NULL) | |
1249 | lttv_hooks_destroy(events_request->before_chunk_traceset); | |
1250 | if(events_request->before_chunk_trace != NULL) | |
1251 | lttv_hooks_destroy(events_request->before_chunk_trace); | |
1252 | if(events_request->before_chunk_tracefile != NULL) | |
1253 | lttv_hooks_destroy(events_request->before_chunk_tracefile); | |
1254 | if(events_request->event != NULL) | |
1255 | lttv_hooks_destroy(events_request->event); | |
750eb11a | 1256 | if(events_request->event_by_id_channel != NULL) |
1257 | lttv_hooks_by_id_channel_destroy(events_request->event_by_id_channel); | |
c5b5eee1 | 1258 | if(events_request->after_chunk_tracefile != NULL) |
1259 | lttv_hooks_destroy(events_request->after_chunk_tracefile); | |
1260 | if(events_request->after_chunk_trace != NULL) | |
1261 | lttv_hooks_destroy(events_request->after_chunk_trace); | |
1262 | if(events_request->after_chunk_traceset != NULL) | |
1263 | lttv_hooks_destroy(events_request->after_chunk_traceset); | |
1264 | if(events_request->before_request != NULL) | |
1265 | lttv_hooks_destroy(events_request->before_request); | |
1266 | if(events_request->after_request != NULL) | |
1267 | lttv_hooks_destroy(events_request->after_request); | |
1268 | ||
1269 | g_free(events_request); | |
451aaf27 | 1270 | #endif /*BABEL_CLEANUP*/ |
c5b5eee1 | 1271 | } |
1272 | ||
1273 | ||
f9240312 | 1274 | __EXPORT GtkWidget *main_window_get_widget(Tab *tab) |
6a4f1205 | 1275 | { |
93ac601b | 1276 | return tab->mw->mwindow; |
6a4f1205 | 1277 | } |
1278 |