Commit | Line | Data |
---|---|---|
501e4e70 | 1 | /* This file is part of the Linux Trace Toolkit Graphic User Interface |
2 | * Copyright (C) 2003-2004 Xiangxiu Yang, Mathieu Desnoyers | |
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 | /* | |
20 | This file is what every viewer plugin writer should refer to. | |
21 | ||
22 | ||
23 | Module Related API | |
24 | ||
2d262115 | 25 | A viewer plugin is, before anything, a plugin. As a dynamically loadable |
501e4e70 | 26 | module, it thus has an init and a destroy function called whenever it is |
27 | loaded/initialized and unloaded/destroyed. A graphical module depends on | |
2d262115 | 28 | lttvwindow for construction of its viewer instances. In order to achieve |
29 | this, it must register its constructor function to the main window along | |
30 | with button description or text menu entry description. A module keeps | |
31 | a list of every viewer that currently sits in memory so it can destroy | |
32 | them before the module gets unloaded/destroyed. | |
501e4e70 | 33 | |
2d262115 | 34 | The contructor registration to the main windows adds button and menu |
35 | entry to each main window, thus allowing instanciation of viewers. | |
501e4e70 | 36 | |
37 | ||
38 | Main Window | |
39 | ||
2d262115 | 40 | The main window is a container that offers menus, buttons and a |
41 | notebook. Some of those menus and buttons are part of the core of the | |
42 | main window, others are dynamically added and removed when modules are | |
43 | loaded/unloaded. | |
501e4e70 | 44 | |
2d262115 | 45 | The notebook contains as much tabs as wanted. Each tab is linked with |
46 | a set of traces (traceset). Each trace contains many tracefiles (one | |
47 | per cpu). A trace corresponds to a kernel being traced. A traceset | |
48 | corresponds to many traces read together. The time span of a traceset | |
49 | goes from the earliest start of all the traces to the latest end of all | |
50 | the traces. | |
501e4e70 | 51 | |
52 | Inside each tab are added the viewers. When they interact with the main | |
53 | window through the lttvwindow API, they affect the other viewers located | |
54 | in the same tab as they are. | |
55 | ||
56 | The insertion of many viewers in a tab permits a quick look at all the | |
2d262115 | 57 | information wanted in a glance. The main window does merge the read |
58 | requests from all the viewers in the same tab in a way that every viewer | |
59 | will get exactly the events it asked for, while the event reading loop | |
60 | and state update are shared. It improves performance of events delivery | |
61 | to the viewers. | |
501e4e70 | 62 | |
63 | ||
64 | ||
65 | Viewer Instance Related API | |
66 | ||
2d262115 | 67 | The lifetime of a viewer is as follows. The viewer constructor function |
68 | is called each time an instance view is created (one subwindow of this | |
69 | viewer type is created by the user either by clicking on the menu item | |
70 | or the button corresponding to the viewer). Thereafter, the viewer gets | |
71 | hooks called for different purposes by the window containing it. These | |
72 | hooks are detailed below. It also has to deal with GTK Events. Finally, | |
73 | it can be destructed by having its top level widget unreferenced by the | |
74 | main window or by any GTK Event causing a "destroy-event" signal on the | |
75 | its top widget. Another possible way for it do be destroyed is if the | |
76 | module gets unloaded. The module unload function will have to emit a | |
77 | "destroy" signal on each top level widget of all instances of its viewers. | |
501e4e70 | 78 | |
79 | ||
80 | Notices from Main Window | |
81 | ||
82 | time_window : This is the time interval visible on the viewer's tab. Every | |
83 | viewer that cares about being synchronised by respect to the | |
84 | time with other viewers should register to this notification. | |
85 | They should redraw all or part of their display when this occurs. | |
86 | ||
87 | traceset : This notification is called whenever a trace is added/removed | |
88 | from the traceset. As it affects all the data displayed by the | |
89 | viewer, it sould redraw itself totally. | |
90 | ||
91 | filter : FIXME : describe.. | |
92 | ||
93 | current_time: Being able to zoom nearer a specific time or highlight a specific | |
94 | time on every viewer in synchronicity implies that the viewer | |
95 | has to shown a visual sign over the drawing or select an event | |
96 | when it receives this notice. It should also inform the main | |
97 | window with the appropriate report API function when a user | |
98 | selects a specific time as being the current time. | |
99 | ||
100 | dividor : This notice links the positions of the horizontal dividors | |
101 | between the graphic display zone of every viewer and their Y axis, | |
102 | typically showing processes, cpus, ... | |
103 | ||
104 | ||
501e4e70 | 105 | Reporting Changes to the Main Window |
106 | ||
2d262115 | 107 | In most cases, the enclosing window knows about updates such as described |
108 | in the Notification section higher. There are a few cases, however, where | |
109 | updates are caused by actions known by a view instance. For example, | |
110 | clicking in a view may update the current time; all viewers within | |
111 | the same window must be told about the new current time to change the | |
112 | currently highlighted time point. A viewer reports such events by calling | |
113 | lttvwindow_report_current_time on its lttvwindow. The lttvwindow will | |
114 | consequently call current_time_notify for each of its contained viewers. | |
501e4e70 | 115 | |
116 | ||
117 | Available report methods are : | |
118 | ||
501e4e70 | 119 | lttvwindow_report_time_window : reports the new time window. |
120 | lttvwindow_report_current_time : reports the new current time. | |
121 | lttvwindow_report_dividor : reports the new horizontal dividor's position. | |
5b962ad0 | 122 | lttvwindow_report_filter : reports the new filter object |
501e4e70 | 123 | |
124 | ||
125 | ||
126 | Requesting Events to Main Window | |
127 | ||
2d262115 | 128 | Events can be requested by passing a EventsRequest structure to the main |
129 | window. They will be delivered later when the next g_idle functions | |
130 | will be called. Event delivery is done by calling the event hook for | |
131 | this event ID, or the main event hooks. A pointer to the EventsRequest | |
132 | structure is passed as hook_data to the event hooks of the viewers. | |
501e4e70 | 133 | |
134 | EventsRequest consists in | |
135 | - a pointer to the viewer specific data structure | |
136 | - a start timestamp or position | |
137 | - a stop_flag, ending the read process when set to TRUE | |
138 | - a end timestamp and/or position and/or number of events to read | |
139 | - hook lists to call for traceset/trace/tracefile begin and end, and for each | |
750eb11a | 140 | event (event hooks and event_by_id_channel hooks). |
501e4e70 | 141 | |
2d262115 | 142 | The main window will deliver events for every EventRequests it has |
143 | pending through an algorithm that guarantee that all events requested, | |
144 | and only them, will be delivered to the viewer between the call of the | |
145 | tracefile_begin hooks and the call of the tracefile_end hooks. | |
501e4e70 | 146 | |
2d262115 | 147 | If a viewer wants to stop the event request at a certain point inside the |
148 | event hooks, it has to set the stop_flag to TRUE and return TRUE from the | |
149 | hook function. Then return value will stop the process traceset. Then, | |
150 | the main window will look for the stop_flag and remove the EventRequests | |
151 | from its lists, calling the process_traceset_end for this request (it | |
152 | removes hooks from the context and calls the after hooks). | |
501e4e70 | 153 | |
9232f6fd | 154 | It no stop_flag is risen, the end timestamp, end position or number |
2d262115 | 155 | of events to read has to be reached to determine the end of the |
156 | request. Otherwise, the end of traceset does determine it. | |
501e4e70 | 157 | |
158 | ||
159 | GTK Events | |
160 | ||
161 | Events and Signals | |
162 | ||
2d262115 | 163 | GTK is quite different from the other graphical toolkits around |
164 | there. The main difference resides in that there are many X Windows | |
165 | inside one GtkWindow, instead of just one. That means that X events are | |
166 | delivered by the glib main loop directly to the widget corresponding to | |
167 | the GdkWindow affected by the X event. | |
501e4e70 | 168 | |
2d262115 | 169 | Event delivery to a widget emits a signal on that widget. Then, if a |
170 | handler is connected to this widget's signal, it will be executed. There | |
171 | are default handlers for signals, connected at class instantiation | |
172 | time. There is also the possibility to connect other handlers to these | |
173 | signals, which is what should be done in most cases when a viewer needs | |
174 | to interact with X in any way. | |
501e4e70 | 175 | |
176 | ||
177 | ||
178 | Signal emission and propagation is described there : | |
179 | ||
180 | http://www.gtk.org/tutorial/sec-signalemissionandpropagation.html | |
181 | ||
182 | For further information on the GTK main loop (now a wrapper over glib main loop) | |
183 | see : | |
184 | ||
185 | http://developer.gnome.org/doc/API/2.0/gtk/gtk-General.html | |
186 | http://developer.gnome.org/doc/API/2.0/glib/glib-The-Main-Event-Loop.html | |
187 | ||
188 | ||
189 | For documentation on event handling in GTK/GDK, see : | |
190 | ||
191 | http://developer.gnome.org/doc/API/2.0/gdk/gdk-Events.html | |
192 | http://developer.gnome.org/doc/API/2.0/gdk/gdk-Event-Structures.html | |
193 | ||
194 | ||
195 | Signals can be connected to handlers, emitted, propagated, blocked, | |
196 | stopped. See : | |
197 | ||
198 | http://developer.gnome.org/doc/API/2.0/gobject/gobject-Signals.html | |
199 | ||
200 | ||
201 | ||
202 | ||
203 | The "expose_event" | |
204 | ||
205 | Provides the exposed region in the GdkEventExpose structure. | |
206 | ||
2d262115 | 207 | There are two ways of dealing with exposures. The first one is to directly |
208 | draw on the screen and the second one is to draw in a pixmap buffer, | |
209 | and then to update the screen when necessary. | |
501e4e70 | 210 | |
2d262115 | 211 | In the first case, the expose event will be responsible for registering |
212 | hooks to process_traceset and require time intervals to the main | |
213 | window. So, in this scenario, if a part of the screen is damaged, the | |
214 | trace has to be read to redraw the screen. | |
501e4e70 | 215 | |
2d262115 | 216 | In the second case, with a pixmap buffer, the expose handler is only |
217 | responsible of showing the pixmap buffer on the screen. If the pixmap | |
218 | buffer has never been filled with a drawing, the expose handler may ask | |
219 | for it to be filled. | |
501e4e70 | 220 | |
2d262115 | 221 | The interest of using events request to the main window instead of reading |
222 | the events directly from the trace comes from the fact that the main | |
223 | window does merge requests from the different viewers in the same tab so | |
224 | that the read loop and the state update is shared. As viewers will, in | |
225 | the common scenario, request the same events, only one pass through the | |
226 | trace that will call the right hooks for the right intervals will be done. | |
501e4e70 | 227 | |
2d262115 | 228 | When the traceset read is over for a events request, the traceset_end |
229 | hook is called. It has the responsibility of finishing the drawing if | |
230 | some parts still need to be drawn and to show it on the screen (if the | |
231 | viewer uses a pixmap buffer). | |
501e4e70 | 232 | |
233 | It can add dotted lines and such visual effects to enhance the user's | |
234 | experience. | |
235 | ||
236 | ||
237 | FIXME : explain other important events | |
238 | ||
239 | */ | |
240 | ||
241 | ||
c5b5eee1 | 242 | #ifndef LTTVWINDOW_H |
243 | #define LTTVWINDOW_H | |
501e4e70 | 244 | |
245 | /*! \file lttvwindow.h | |
246 | * \brief API used by the graphical viewers to interact with their top window. | |
247 | * | |
248 | * Main window (lttvwindow module) is the place to contain and display viewers. | |
249 | * Viewers (lttv plugins) interact with main window through this API. | |
250 | * This header file should be included in each graphic module. | |
251 | * | |
252 | */ | |
253 | ||
254 | #include <gtk/gtk.h> | |
255 | #include <ltt/ltt.h> | |
256 | #include <ltt/time.h> | |
9a366873 | 257 | #include <lttv/traceset.h> |
501e4e70 | 258 | #include <lttv/hook.h> |
451aaf27 | 259 | #ifdef BABEL_CLEANUP |
501e4e70 | 260 | #include <lttv/stats.h> |
5b962ad0 | 261 | #include <lttv/filter.h> |
451aaf27 | 262 | #endif /* BABEL_CLEANUP */ |
2d262115 | 263 | #include <lttvwindow/mainwindow.h> |
e433e6d6 | 264 | #include <lttvwindow/lttv_plugin.h> |
501e4e70 | 265 | |
501e4e70 | 266 | /* Module Related API */ |
267 | ||
e025a729 | 268 | /* GQuark containing constructors of viewers in global attributes */ |
269 | extern GQuark LTTV_VIEWER_CONSTRUCTORS; | |
501e4e70 | 270 | |
271 | /* constructor a the viewer */ | |
e433e6d6 | 272 | typedef GtkWidget* (*lttvwindow_viewer_constructor)(LttvPlugin *plugin); |
501e4e70 | 273 | |
3c456a8a | 274 | extern gint lttvwindow_preempt_count; |
275 | ||
276 | #define CHECK_GDK_INTERVAL 50000 | |
501e4e70 | 277 | |
278 | /** | |
279 | * Function to register a view constructor so that main window can generate | |
280 | * a menu item and a toolbar item for the viewer in order to generate a new | |
281 | * instance easily. A menu entry and toolbar item will be added to each main | |
282 | * window. | |
283 | * | |
284 | * It should be called by init function of the module. | |
e025a729 | 285 | * |
286 | * @param name name of the viewer : mainly used as tag for constructor | |
501e4e70 | 287 | * @param menu_path path of the menu item. NULL : no menu entry. |
288 | * @param menu_text text of the menu item. | |
289 | * @param pixmap Image shown on the toolbar item. NULL : no button. | |
290 | * @param tooltip tooltip of the toolbar item. | |
291 | * @param view_constructor constructor of the viewer. | |
292 | */ | |
293 | ||
294 | void lttvwindow_register_constructor | |
e025a729 | 295 | (char * name, |
296 | char * menu_path, | |
501e4e70 | 297 | char * menu_text, |
298 | char ** pixmap, | |
299 | char * tooltip, | |
300 | lttvwindow_viewer_constructor view_constructor); | |
301 | ||
302 | ||
303 | /** | |
304 | * Function to unregister the viewer's constructor, release the space | |
305 | * occupied by menu_path, menu_text, pixmap, tooltip and constructor of the | |
306 | * viewer. | |
307 | * | |
308 | * It will be called when a module is unloaded. | |
309 | * | |
310 | * @param view_constructor constructor of the viewer. | |
311 | */ | |
312 | ||
313 | void lttvwindow_unregister_constructor | |
314 | (lttvwindow_viewer_constructor view_constructor); | |
315 | ||
316 | ||
317 | ||
318 | ||
319 | /* Viewer Instance Related API */ | |
320 | ||
321 | /** | |
322 | * Structure used as hook_data for the time_window_notify hook. | |
323 | */ | |
324 | typedef struct _TimeWindowNotifyData { | |
325 | TimeWindow *new_time_window; | |
326 | TimeWindow *old_time_window; | |
327 | } TimeWindowNotifyData; | |
328 | ||
329 | ||
330 | /** | |
331 | * Function to register a hook function that will be called by the main window | |
332 | * when the time interval needs to be updated. | |
333 | * | |
334 | * This register function is typically called by the constructor of the viewer. | |
335 | * | |
336 | * @param tab the tab the viewer belongs to. | |
337 | * @param hook hook that sould be called by the main window when the time | |
338 | * interval changes. This hook function takes a | |
339 | * TimeWindowNotifyData* as call_data. | |
340 | * @param hook_data hook data associated with the hook function. It will | |
341 | * be typically a pointer to the viewer's data structure. | |
342 | */ | |
343 | ||
344 | void lttvwindow_register_time_window_notify(Tab *tab, | |
345 | LttvHook hook, | |
346 | gpointer hook_data); | |
347 | ||
348 | ||
349 | /** | |
350 | * Function to unregister the time_window notification hook. | |
351 | * | |
352 | * This unregister function is typically called by the destructor of the viewer. | |
353 | * | |
354 | * @param tab the tab the viewer belongs to. | |
355 | * @param hook hook that sould be called by the main window when the time | |
356 | * interval changes. This hook function takes a | |
357 | * TimeWindowNotifyData* as call_data. | |
358 | * @param hook_data hook data associated with the hook function. It will | |
359 | * be typically a pointer to the viewer's data structure. | |
360 | */ | |
361 | ||
362 | void lttvwindow_unregister_time_window_notify(Tab *tab, | |
363 | LttvHook hook, | |
364 | gpointer hook_data); | |
365 | ||
1e3594a3 YB |
366 | /** |
367 | * Function to register a hook function that will be called by the main window | |
368 | * when the time span of the traceset is updated. | |
369 | * | |
370 | * This register function is typically called by the constructor of the viewer. | |
371 | * | |
372 | * @param tab the tab the viewer belongs to. | |
373 | * @param hook hook that sould be called by the main window when the time | |
374 | * interval changes. | |
375 | * @param hook_data hook data associated with the hook function. It will | |
376 | * be typically a pointer to the viewer's data structure. | |
377 | */ | |
378 | void lttvwindow_register_timespan_notify(Tab *tab, | |
379 | LttvHook hook, | |
380 | gpointer hook_data); | |
381 | ||
382 | /** | |
383 | * Function to unregister the time_span notification hook. | |
384 | * | |
385 | * This unregister function is typically called by the destructor of the viewer. | |
386 | * | |
387 | * @param tab the tab the viewer belongs to. | |
388 | * @param hook hook that sould be called by the main window when the time | |
389 | * interval changes. | |
390 | * @param hook_data hook data associated with the hook function. It will | |
391 | * be typically a pointer to the viewer's data structure. | |
392 | */ | |
393 | void lttvwindow_unregister_timespan_notify(Tab *tab, | |
394 | LttvHook hook, | |
395 | gpointer hook_data); | |
501e4e70 | 396 | |
397 | /** | |
398 | * Function to register a hook function that will be called by the main window | |
399 | * when the traceset is changed. That means that the viewer must redraw | |
400 | * itself completely or check if it's affected by the particular change to the | |
401 | * traceset. | |
402 | * | |
403 | * This register function is typically called by the constructor of the viewer. | |
404 | * | |
405 | * @param tab the tab the viewer belongs to. | |
406 | * @param hook hook that should be called whenever a change to the traceset | |
407 | * occurs. The call_data of this hook is a NULL pointer. | |
408 | * @param hook_data hook data associated with the hook function. It will | |
409 | * be typically a pointer to the viewer's data structure. | |
410 | */ | |
411 | ||
412 | void lttvwindow_register_traceset_notify(Tab *tab, | |
413 | LttvHook hook, | |
414 | gpointer hook_data); | |
415 | ||
416 | ||
417 | /** | |
418 | * Function to unregister the traceset_notify hook. | |
419 | * | |
420 | * @param tab the tab the viewer belongs to. | |
421 | * @param hook hook that should be called whenever a change to the traceset | |
422 | * occurs. The call_data of this hook is a NULL pointer. | |
423 | * @param hook_data hook data associated with the hook function. It will | |
424 | * be typically a pointer to the viewer's data structure. | |
425 | */ | |
426 | ||
427 | void lttvwindow_unregister_traceset_notify(Tab *tab, | |
428 | LttvHook hook, | |
429 | gpointer hook_data); | |
430 | ||
431 | ||
9878c8a4 | 432 | /** |
433 | * Function to register a hook function for a viewer be completely redrawn. | |
434 | * | |
435 | * @param tab viewer's tab | |
436 | * @param hook hook function of the viewer. | |
437 | * @param hook_data hook data associated with the hook function. | |
438 | */ | |
439 | ||
440 | void lttvwindow_register_redraw_notify(Tab *tab, | |
441 | LttvHook hook, gpointer hook_data); | |
442 | ||
443 | /** | |
444 | * Function to unregister a hook function for a viewer be completely redrawn. | |
445 | * | |
446 | * @param tab viewer's tab | |
447 | * @param hook hook function of the viewer. | |
448 | * @param hook_data hook data associated with the hook function. | |
449 | */ | |
450 | ||
451 | void lttvwindow_unregister_redraw_notify(Tab *tab, | |
452 | LttvHook hook, gpointer hook_data); | |
453 | ||
454 | ||
455 | /** | |
456 | * Function to register a hook function for a viewer to re-do the events | |
457 | * requests for the needed interval. | |
458 | * | |
459 | * This action is typically done after a "stop". | |
460 | * | |
461 | * The typical hook will remove all current requests for the viewer | |
462 | * and make requests for missing information. | |
463 | * | |
464 | * @param tab viewer's tab | |
465 | * @param hook hook function of the viewer. | |
466 | * @param hook_data hook data associated with the hook function. | |
467 | */ | |
468 | ||
469 | void lttvwindow_register_continue_notify(Tab *tab, | |
470 | LttvHook hook, gpointer hook_data); | |
471 | ||
472 | ||
473 | /** | |
474 | * Function to unregister a hook function for a viewer to re-do the events | |
475 | * requests for the needed interval. | |
476 | * | |
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 | */ | |
481 | ||
482 | void lttvwindow_unregister_continue_notify(Tab *tab, | |
483 | LttvHook hook, gpointer hook_data); | |
484 | ||
485 | ||
501e4e70 | 486 | /** |
487 | * Function to register a hook function for a viewer to set/update its | |
488 | * filter. | |
489 | * | |
490 | * FIXME : Add information about what a filter is as seen from a viewer and how | |
491 | * to use it. | |
492 | * | |
493 | * This register function is typically called by the constructor of the viewer. | |
494 | * | |
495 | * @param tab the tab the viewer belongs to. | |
496 | * @param hook hook function called by the main window when a filter change | |
497 | * occurs. | |
498 | * @param hook_data hook data associated with the hook function. It will | |
499 | * be typically a pointer to the viewer's data structure. | |
500 | */ | |
501 | ||
502 | void lttvwindow_register_filter_notify(Tab *tab, | |
503 | LttvHook hook, | |
504 | gpointer hook_data); | |
505 | ||
506 | ||
507 | /** | |
508 | * Function to unregister a viewer's hook function which is used to | |
509 | * set/update the filter of the viewer. | |
510 | * | |
511 | * This unregistration is called by the destructor of the viewer. | |
512 | * | |
513 | * @param tab the tab the viewer belongs to. | |
514 | * @param hook hook function called by the main window when a filter change | |
515 | * occurs. | |
516 | * @param hook_data hook data associated with the hook function. It will | |
517 | * be typically a pointer to the viewer's data structure. | |
518 | */ | |
519 | ||
520 | void lttvwindow_unregister_filter_notify(Tab *tab, | |
521 | LttvHook hook, | |
522 | gpointer hook_data); | |
523 | ||
524 | ||
c790dfd9 | 525 | /** |
526 | * Function to get the current filter of the main window : useful at viewer | |
527 | * instanciation. | |
528 | * | |
529 | * @param tab the tab the viewer belongs to. | |
530 | * | |
531 | * returns : the current filter. | |
532 | */ | |
533 | ||
534 | ||
535 | LttvFilter *lttvwindow_get_filter(Tab *tab); | |
536 | ||
501e4e70 | 537 | /** |
538 | * Function to register a hook function for a viewer to set/update its | |
539 | * current time. | |
540 | * | |
541 | * @param tab the tab the viewer belongs to. | |
542 | * @param hook hook function of the viewer that updates the current time. The | |
543 | * call_data is a LttTime* representing the new current time. | |
544 | * @param hook_data hook data associated with the hook function. It will | |
545 | * be typically a pointer to the viewer's data structure. | |
546 | */ | |
547 | ||
548 | void lttvwindow_register_current_time_notify(Tab *tab, | |
549 | LttvHook hook, | |
550 | gpointer hook_data); | |
551 | ||
552 | ||
553 | /** | |
554 | * Function to unregister a viewer's hook function which is used to | |
555 | * set/update the current time of the viewer. | |
556 | * @param tab the tab the viewer belongs to. | |
557 | * @param hook hook function of the viewer that updates the current time. The | |
558 | * call_data is a LttTime* representing the new current time. | |
559 | * @param hook_data hook data associated with the hook function. It will | |
560 | * be typically a pointer to the viewer's data structure. | |
561 | */ | |
562 | ||
563 | void lttvwindow_unregister_current_time_notify(Tab *tab, | |
564 | LttvHook hook, | |
565 | gpointer hook_data); | |
566 | ||
5290ec02 | 567 | /** |
568 | * Function to register a hook function for a viewer to set/update its | |
569 | * current position. | |
570 | * | |
571 | * @param tab the tab the viewer belongs to. | |
572 | * @param hook hook function of the viewer that updates the current time. The | |
573 | * call_data is a LttTime* representing the new current time. | |
574 | * @param hook_data hook data associated with the hook function. It will | |
575 | * be typically a pointer to the viewer's data structure. | |
576 | */ | |
577 | ||
578 | void lttvwindow_register_current_position_notify(Tab *tab, | |
579 | LttvHook hook, | |
580 | gpointer hook_data); | |
581 | ||
582 | ||
583 | /** | |
584 | * Function to unregister a viewer's hook function which is used to | |
585 | * set/update the current position of the viewer. | |
586 | * @param tab the tab the viewer belongs to. | |
587 | * @param hook hook function of the viewer that updates the current time. The | |
588 | * call_data is a LttTime* representing the new current time. | |
589 | * @param hook_data hook data associated with the hook function. It will | |
590 | * be typically a pointer to the viewer's data structure. | |
591 | */ | |
592 | ||
593 | void lttvwindow_unregister_current_position_notify(Tab *tab, | |
594 | LttvHook hook, | |
595 | gpointer hook_data); | |
596 | ||
597 | ||
501e4e70 | 598 | |
599 | /** | |
600 | * Function to register a hook function for a viewer to set/update the | |
601 | * dividor of the hpane. It provides a way to make the horizontal | |
602 | * dividors of all the viewers linked together. | |
603 | * | |
604 | * @param tab the tab the viewer belongs to. | |
605 | * @param hook hook function of the viewer that will be called whenever a | |
606 | * dividor changes in another viewer. The call_data of this hook | |
607 | * is a gint*. The value of the integer is the new position of the | |
608 | * hpane dividor. | |
609 | * @param hook_data hook data associated with the hook function. It will | |
610 | * be typically a pointer to the viewer's data structure. | |
611 | */ | |
612 | ||
613 | void lttvwindow_register_dividor(Tab *tab, | |
614 | LttvHook hook, | |
615 | gpointer hook_data); | |
616 | ||
617 | ||
618 | /** | |
619 | * Function to unregister a viewer's hook function which is used to | |
620 | * set/update hpane's dividor of the viewer. | |
621 | * | |
622 | * @param tab the tab the viewer belongs to. | |
623 | * @param hook hook function of the viewer that will be called whenever a | |
624 | * dividor changes in another viewer. The call_data of this hook | |
625 | * is a gint*. The value of the integer is the new position of the | |
626 | * hpane dividor. | |
627 | * @param hook_data hook data associated with the hook function. It will | |
628 | * be typically a pointer to the viewer's data structure. | |
629 | */ | |
630 | ||
631 | void lttvwindow_unregister_dividor(Tab *tab, | |
632 | LttvHook hook, | |
633 | gpointer hook_data); | |
634 | ||
635 | ||
636 | ||
501e4e70 | 637 | /** |
638 | * Function to set the time interval of the current tab.a | |
639 | * | |
640 | * @param tab the tab the viewer belongs to. | |
e800cf84 | 641 | * @param time_interval new time window. |
501e4e70 | 642 | */ |
643 | ||
644 | void lttvwindow_report_time_window(Tab *tab, | |
e800cf84 | 645 | TimeWindow time_window); |
501e4e70 | 646 | |
647 | /** | |
5290ec02 | 648 | * Function to set the current time of the current tab. |
501e4e70 | 649 | * It will be called by a viewer's signal handle associated with |
650 | * the button-release-event signal | |
651 | * @param tab the tab the viewer belongs to. | |
5290ec02 | 652 | * @param time current time. |
501e4e70 | 653 | */ |
654 | ||
655 | void lttvwindow_report_current_time(Tab *tab, | |
e800cf84 | 656 | LttTime time); |
501e4e70 | 657 | |
658 | ||
5290ec02 | 659 | /** |
660 | * Function to set the current event of the current tab. | |
661 | * It will be called by a viewer's signal handle associated with | |
662 | * the button-release-event signal | |
663 | * @param tab the tab the viewer belongs to. | |
664 | * @param pos the current position. | |
665 | */ | |
666 | ||
667 | void lttvwindow_report_current_position(Tab *tab, | |
451aaf27 | 668 | LttvTracesetPosition *pos); |
5290ec02 | 669 | |
501e4e70 | 670 | /** |
671 | * Function to set the position of the hpane's dividor (viewer). | |
672 | * It will typically be called by a viewer's signal handle associated | |
673 | * with the motion_notify_event event/signal. | |
674 | * | |
675 | * @param tab the tab the viewer belongs to. | |
676 | * @param position position of the hpane's dividor. | |
677 | */ | |
678 | ||
679 | void lttvwindow_report_dividor(Tab *tab, gint position); | |
680 | ||
501e4e70 | 681 | |
682 | /* Structure sent to the events request hook */ | |
0aa6c3a1 | 683 | /* Value considered as empty*/ |
501e4e70 | 684 | typedef struct _EventsRequest { |
2d262115 | 685 | gpointer owner; /* Owner of the request */ |
501e4e70 | 686 | gpointer viewer_data; /* Unset : NULL */ |
0aa6c3a1 | 687 | gboolean servicing; /* service in progress: TRUE*/ |
688 | LttTime start_time; /* Unset : ltt_time_infinite*/ | |
451aaf27 | 689 | LttvTracesetPosition *start_position; /* Unset : NULL */ |
501e4e70 | 690 | gboolean stop_flag; /* Continue:TRUE Stop:FALSE */ |
0aa6c3a1 | 691 | LttTime end_time; /* Unset : ltt_time_infinite*/ |
501e4e70 | 692 | guint num_events; /* Unset : G_MAXUINT */ |
451aaf27 | 693 | LttvTracesetPosition *end_position; /* Unset : NULL */ |
54d8f654 | 694 | gint trace; /* unset : -1 */ |
10a1069a | 695 | GArray *hooks; /* Unset : NULL */ |
501e4e70 | 696 | LttvHooks *before_chunk_traceset; /* Unset : NULL */ |
697 | LttvHooks *before_chunk_trace; /* Unset : NULL */ | |
698 | LttvHooks *before_chunk_tracefile;/* Unset : NULL */ | |
699 | LttvHooks *event; /* Unset : NULL */ | |
501e4e70 | 700 | LttvHooks *after_chunk_tracefile; /* Unset : NULL */ |
701 | LttvHooks *after_chunk_trace; /* Unset : NULL */ | |
702 | LttvHooks *after_chunk_traceset; /* Unset : NULL */ | |
703 | LttvHooks *before_request; /* Unset : NULL */ | |
2d262115 | 704 | LttvHooks *after_request; /* Unset : NULL */ |
501e4e70 | 705 | } EventsRequest; |
706 | ||
2d262115 | 707 | /* Maximum number of events to proceed at once in a chunk */ |
088f6772 | 708 | #define CHUNK_NUM_EVENTS 6000 |
2d262115 | 709 | |
501e4e70 | 710 | |
711 | /** | |
712 | * Function to request data in a specific time interval to the main window. The | |
713 | * event request servicing is differed until the glib idle functions are | |
714 | * called. | |
715 | * | |
716 | * The viewer has to provide hooks that should be associated with the event | |
717 | * request. | |
718 | * | |
719 | * Either start time or start position must be defined in a EventRequest | |
720 | * structure for it to be valid. | |
721 | * | |
722 | * end_time, end_position and num_events can all be defined. The first one | |
723 | * to occur will be used as end criterion. | |
20fde85f | 724 | * |
725 | * The events_request memory will be managed by the main window once its | |
726 | * pointer is passed by this function. | |
501e4e70 | 727 | * |
728 | * @param tab the tab the viewer belongs to. | |
729 | * @param events_requested Details about the event request. | |
730 | */ | |
731 | ||
732 | void lttvwindow_events_request(Tab *tab, | |
20fde85f | 733 | EventsRequest *events_request); |
501e4e70 | 734 | |
735 | /** | |
736 | * Function to remove data requests related to a viewer. | |
737 | * | |
738 | * The existing requests's viewer gpointer is compared to the pointer | |
739 | * given in argument to establish which data request should be removed. | |
740 | * | |
741 | * @param tab the tab the viewer belongs to. | |
742 | * @param viewer a pointer to the viewer data structure | |
743 | */ | |
744 | ||
745 | void lttvwindow_events_request_remove_all(Tab *tab, | |
746 | gconstpointer viewer); | |
747 | ||
748 | ||
efcd775d | 749 | /** |
750 | * Function to see if there are events request pending. | |
751 | * | |
752 | * It tells if events requests are pending. Useful for checks in some events, | |
753 | * i.e. detailed event list scrolling. | |
754 | * | |
755 | * @param tab the tab the viewer belongs to. | |
756 | * @param viewer a pointer to the viewer data structure | |
757 | * @return : TRUE is events requests are pending, else FALSE. | |
758 | */ | |
759 | ||
760 | gboolean lttvwindow_events_request_pending(Tab *tab); | |
761 | ||
762 | ||
763 | ||
764 | ||
501e4e70 | 765 | /** |
6550d711 | 766 | * Function to get the current time interval shown on the current tab. |
767 | * It will be called by a viewer's hook function to update the | |
768 | * shown time interval of the viewer and also be called by the constructor | |
769 | * of the viewer. | |
770 | * @param tab viewer's tab | |
771 | * @return time window. | |
501e4e70 | 772 | */ |
773 | ||
50106726 | 774 | TimeWindow lttvwindow_get_time_window(Tab *tab); |
501e4e70 | 775 | |
776 | ||
777 | /** | |
778 | * Function to get the current time of the current tab. | |
779 | * | |
780 | * @param tab the tab the viewer belongs to. | |
6ea08962 | 781 | * @return the current tab's current time. |
501e4e70 | 782 | */ |
783 | ||
6ea08962 | 784 | LttTime lttvwindow_get_current_time(Tab *tab); |
501e4e70 | 785 | |
786 | ||
787 | /** | |
788 | * Function to get the filter of the current tab. | |
789 | * @param main_win, the main window the viewer belongs to. | |
790 | * @param filter, a pointer to a filter. | |
791 | */ | |
792 | ||
a998b781 | 793 | //LttvFilter *lttvwindow_get_filter(Tab *tab); |
5b962ad0 | 794 | |
795 | /** | |
796 | * Function to set the filter of the current tab. | |
797 | * It should be called by the filter GUI to tell the | |
798 | * main window to update the filter tab's lttv_filter. | |
799 | * | |
800 | * Notice : the lttv_filter object will be owned by the | |
801 | * main window after the return of this function. | |
802 | * Do NOT desallocate it. | |
803 | * | |
804 | * @param main_win, the main window the viewer belongs to. | |
805 | * @param filter, a pointer to a filter. | |
806 | */ | |
807 | ||
2ea36caf | 808 | void lttvwindow_report_filter(Tab *tab, LttvFilter *filter); |
5b962ad0 | 809 | |
451aaf27 | 810 | #ifdef BABEL_CLEANUP |
501e4e70 | 811 | |
812 | /** | |
813 | * Function to get the stats of the traceset | |
814 | * It must be non const so the viewer can modify it. | |
815 | * FIXME : a set/get pair of functions would be more appropriate here. | |
816 | * @param tab the tab the viewer belongs to. | |
817 | * @return A pointer to Traceset statistics. | |
818 | */ | |
819 | ||
820 | LttvTracesetStats* lttvwindow_get_traceset_stats(Tab *tab); | |
451aaf27 | 821 | #endif /*BABEL_CLEANUP*/ |
501e4e70 | 822 | |
9a366873 | 823 | LttvTraceset* lttvwindow_get_traceset(Tab *tab); |
501e4e70 | 824 | |
2eef04b5 | 825 | /* set_time_window |
826 | * | |
827 | * It updates the time window of the tab, then calls the updatetimewindow | |
828 | * hooks of each viewer. | |
829 | * | |
830 | * This is called whenever the scrollbar value changes. | |
831 | * | |
832 | * This is mostly an internal function. | |
833 | */ | |
834 | ||
835 | void set_time_window(Tab *tab, const TimeWindow *time_window); | |
836 | ||
837 | ||
838 | /* set_current_time | |
839 | * | |
840 | * It updates the current time of the tab, then calls the updatetimewindow | |
841 | * hooks of each viewer. | |
842 | * | |
843 | * This is called whenever the current time value changes. | |
844 | * | |
845 | * This is mostly an internal function. | |
846 | */ | |
847 | ||
848 | void set_current_time(Tab *tab, const LttTime *current_time); | |
849 | ||
c5b5eee1 | 850 | void events_request_free(EventsRequest *events_request); |
851 | ||
93ac601b | 852 | GtkWidget *main_window_get_widget(Tab *tab); |
6a4f1205 | 853 | |
451aaf27 | 854 | void set_current_position(Tab *tab, const LttvTracesetPosition *pos); |
5e96e7e3 | 855 | |
3c456a8a | 856 | |
857 | /** | |
858 | * Function to disable the EventsRequests scheduler, nestable. | |
859 | * | |
860 | */ | |
861 | static inline void lttvwindow_events_request_disable(void) | |
862 | { | |
863 | lttvwindow_preempt_count++; | |
864 | } | |
865 | ||
866 | /** | |
867 | * Function to restore the EventsRequests scheduler, nestable. | |
868 | * | |
869 | */ | |
870 | static inline void lttvwindow_events_request_enable(void) | |
871 | { | |
872 | lttvwindow_preempt_count--; | |
873 | } | |
874 | ||
875 | ||
43ed82b5 | 876 | void current_position_change_manager(Tab *tab, |
451aaf27 | 877 | LttvTracesetPosition *pos); |
3c456a8a | 878 | |
c5b5eee1 | 879 | #endif //LTTVWINDOW_H |