minor add
[lttv.git] / ltt / branches / poly / lttv / modules / gui / lttvwindow / lttvwindow / viewer.h
CommitLineData
c85f674c 1/* This file is part of the Linux Trace Toolkit Graphic User Interface
5a5b35c5 2 * Copyright (C) 2003-2004 Xiangxiu Yang, Mathieu Desnoyers
3bc00fde 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
f95bc830 19/*
911b7a3c 20This file is what every viewer plugin writer should refer to.
21
5a5b35c5 22
23Module Related API
911b7a3c 24
c85f674c 25A viewer plugin is, before anything, a plugin. As a dynamically loadable
26module, it thus has an init and a destroy function called whenever it is
27loaded/initialized and unloaded/destroyed. A graphical module depends on
28lttvwindow for construction of its viewer instances. In order to achieve this,
29it must register its constructor function to the main window along with
30button description or text menu entry description. A module keeps a list of
31every viewer that currently sits in memory so it can destroy them before the
32module gets unloaded/destroyed.
5a5b35c5 33
34
35Viewer Instance Related API
911b7a3c 36
37The lifetime of a viewer is as follows. The viewer constructor function is
38called each time an instance view is created (one subwindow of this viewer
5a5b35c5 39type is created by the user either by clicking on the menu item or the button
40corresponding to the viewer). Thereafter, the viewer gets hooks called for
911b7a3c 41different purposes by the window containing it. These hooks are detailed
5a5b35c5 42below. It also has to deal with GTK Events. Finally, it can be destructed by
43having its top level widget unreferenced by the main window or by any
44GTK Event causing a "destroy-event" signal on the its top widget. Another
45possible way for it do be destroyed is if the module gets unloaded. The module
46unload function will have to emit a "destroy" signal on each top level widget
47of all instances of its viewers.
48
49
c85f674c 50Notices from Main Window
5a5b35c5 51
52time_window : This is the time interval visible on the viewer's tab. Every
53 viewer that cares about being synchronised by respect to the
54 time with other viewers should register to this notification.
55 They should redraw all or part of their display when this occurs.
56
57traceset : This notification is called whenever a trace is added/removed
58 from the traceset. As it affects all the data displayed by the
59 viewer, it sould redraw itself totally.
911b7a3c 60
5a5b35c5 61filter : FIXME : describe..
911b7a3c 62
5a5b35c5 63current_time: Being able to zoom nearer a specific time or highlight a specific
64 time on every viewer in synchronicity implies that the viewer
65 has to shown a visual sign over the drawing or select an event
66 when it receives this notice. It should also inform the main
67 window with the appropriate report API function when a user
68 selects a specific time as being the current time.
69
70dividor : This notice links the positions of the horizontal dividors
71 between the graphic display zone of every viewer and their Y axis,
72 typically showing processes, cpus, ...
73
74
75FIXME : Add background computation explanation here
911b7a3c 76background_init: prepare for background computation (comes after show_end).
77process_trace for background: done in small chunks in gtk_idle, hooks called.
78background_end: remove the hooks and perhaps update the window.
79
5a5b35c5 80
81Reporting Changes to the Main Window
82
83In most cases, the enclosing window knows about updates such as described in the
84Notification section higher. There are a few cases, however, where updates are
85caused by actions known by a view instance. For example, clicking in a view may
86update the current time; all viewers within the same window must be told about
87the new current time to change the currently highlighted time point. A viewer
88reports such events by calling lttvwindow_report_current_time on its lttvwindow.
c85f674c 89The lttvwindow will consequently call current_time_notify for each of its
90contained viewers.
5a5b35c5 91
92
93Available report methods are :
94
95lttvwindow_report_status : reports the text of the status bar.
96lttvwindow_report_time_window : reports the new time window.
97lttvwindow_report_current_time : reports the new current time.
98lttvwindow_report_dividor : reports the new horizontal dividor's position.
99lttvwindow_report_focus : One on the widgets in the viewer has the keyboard's
100 focus from GTK.
101
5a5b35c5 102
c85f674c 103
104Requesting Events to Main Window
105
106Events can be requested by passing a EventsRequest structure to the main window.
107They will be delivered later when the next g_idle functions will be called.
108Event delivery is done by calling the middle hook for this event ID, or the
109main middle hooks.
110
111EventsRequest consists in
112- a start timestamp or position
113- a end timestamp and/or position and/or number of events to read
114- hook lists to call for traceset/trace/tracefile begin and end, and for each
115 event (middle).
116
117The main window will deliver events for every EventRequests it has pending
118through an algorithm that guarantee that all events requested, and only them,
119will be delivered to the viewer between the call of the tracefile_begin hooks
120and the call of the tracefile_end hooks.
121
5a5b35c5 122
123
124
125GTK Events
126
c85f674c 127Events and Signals
128
129GTK is quite different from the other graphical toolkits around there. The main
130difference resides in that there are many X Windows inside one GtkWindow,
131instead of just one. That means that X events are delivered by the glib main
132loop directly to the widget corresponding to the GdkWindow affected by the X
133event.
134
c042ad3b 135Event delivery to a widget emits a signal on that widget. Then, if a handler
136is connected to this widget's signal, it will be executed. There are default
137handlers for signals, connected at class instantiation time. There is also
138the possibility to connect other handlers to these signals, which is what
139should be done in most cases when a viewer needs to interact with X in any
140way.
141
142
143
144Signal emission and propagation is described there :
c85f674c 145
146http://www.gtk.org/tutorial/sec-signalemissionandpropagation.html
147
148For further information on the GTK main loop (now a wrapper over glib main loop)
149see :
150
151http://developer.gnome.org/doc/API/2.0/gtk/gtk-General.html
152http://developer.gnome.org/doc/API/2.0/glib/glib-The-Main-Event-Loop.html
153
154
155For documentation on event handling in GTK/GDK, see :
156
157http://developer.gnome.org/doc/API/2.0/gdk/gdk-Events.html
158http://developer.gnome.org/doc/API/2.0/gdk/gdk-Event-Structures.html
159
160
161Signals can be connected to handlers, emitted, propagated, blocked,
162stopped. See :
163
164http://developer.gnome.org/doc/API/2.0/gobject/gobject-Signals.html
165
166
167
5a5b35c5 168
169The "expose_event"
170
171Provides the exposed region in the GdkEventExpose structure.
172
173There are two ways of dealing with exposures. The first one is to directly draw
174on the screen and the second one is to draw in a pixmap buffer, and then to
175update the screen when necessary.
176
177In the first case, the expose event will be responsible for registering hooks to
178process_traceset and require time intervals to the main window. So, in this
179scenario, if a part of the screen is damaged, the trace has to be read to
180redraw the screen.
181
182In the second case, with a pixmap buffer, the expose handler is only responsible
183of showing the pixmap buffer on the screen. If the pixmap buffer has never
184been filled with a drawing, the expose handler may ask for it to be filled.
185
186It can add dotted lines and such visual effects to enhance the user's
187experience.
188
189
190FIXME : explain other important events
191
f95bc830 192*/
193
194
195
196
36b40c74 197/*! \file viewer.h
3bc00fde 198 * \brief API used by the graphical viewers to interact with their top window.
199 *
5a5b35c5 200 * Main window (lttvwindow module) is the place to contain and display viewers.
201 * Viewers (lttv plugins) interact with main window through this API.
3bc00fde 202 * This header file should be included in each graphic module.
3bc00fde 203 *
204 */
205
206#include <gtk/gtk.h>
207#include <ltt/ltt.h>
208#include <lttv/hook.h>
13f86ce2 209#include <lttvwindow/common.h>
3bc00fde 210#include <lttv/stats.h>
224446ce 211//FIXME (not ready yet) #include <lttv/filter.h>
3bc00fde 212
5a5b35c5 213
214/* Module Related API */
215
216
217/* constructor a the viewer */
218//FIXME explain LttvTracesetSelector and key
219typedef GtkWidget * (*lttvwindow_viewer_constructor)
220 (MainWindow * main_window, LttvTracesetSelector * s, char *key);
221
222
3bc00fde 223/**
224 * Function to register a view constructor so that main window can generate
225 * a toolbar item for the viewer in order to generate a new instance easily.
5a5b35c5 226 *
227 * It should be called by init function of the module.
228 *
229 * @param pixmap Image shown on the toolbar item.
3bc00fde 230 * @param tooltip tooltip of the toolbar item.
231 * @param view_constructor constructor of the viewer.
232 */
233
5a5b35c5 234void lttvwindow_register_toolbar
235 (char ** pixmap,
236 char * tooltip,
237 lttvwindow_viewer_constructor view_constructor);
3bc00fde 238
239
240/**
241 * Function to unregister the viewer's constructor, release the space
242 * occupied by pixmap, tooltip and constructor of the viewer.
5a5b35c5 243 *
3bc00fde 244 * It will be called when a module is unloaded.
5a5b35c5 245 *
246 * @param view_constructor constructor of the viewer.
3bc00fde 247 */
248
5a5b35c5 249void lttvwindow_unregister_toolbar
250 (lttvwindow_viewer_constructor view_constructor);
3bc00fde 251
252
253/**
254 * Function to register a view constructor so that main window can generate
255 * a menu item for the viewer in order to generate a new instance easily.
5a5b35c5 256 *
3bc00fde 257 * It will be called by init function of the module.
5a5b35c5 258 *
3bc00fde 259 * @param menu_path path of the menu item.
260 * @param menu_text text of the menu item.
261 * @param view_constructor constructor of the viewer.
262 */
263
5a5b35c5 264void lttvwindow_register_menu(char *menu_path,
265 char *menu_text,
266 lttvwindow_viewer_constructor view_constructor);
3bc00fde 267
268
269/**
270 * Function to unregister the viewer's constructor, release the space
271 * occupied by menu_path, menu_text and constructor of the viewer.
5a5b35c5 272 *
3bc00fde 273 * It will be called when a module is unloaded.
5a5b35c5 274 *
275 * @param view_constructor constructor of the viewer.
3bc00fde 276 */
277
224446ce 278void lttvwindow_unregister_menu(lttvwindow_viewer_constructor view_constructor);
3bc00fde 279
280
5a5b35c5 281
282/* Viewer Instance Related API */
283
3bc00fde 284/**
5a5b35c5 285 * Structure used as hook_data for the time_window_notify hook.
3bc00fde 286 */
224446ce 287typedef struct _TimeWindowNotifyData {
288 TimeWindow *new_time_window;
289 TimeWindow *old_time_window;
290} TimeWindowNotifyData;
291
5a5b35c5 292
293/**
294 * Function to register a hook function that will be called by the main window
295 * when the time interval needs to be updated.
296 *
297 * This register function is typically called by the constructor of the viewer.
298 *
299 * @param main_win the main window the viewer belongs to.
300 * @param hook hook that sould be called by the main window when the time
301 * interval changes. This hook function takes a
302 * TimeWindowNotifyData* as call_data.
303 * @param hook_data hook data associated with the hook function. It will
304 * be typically a pointer to the viewer's data structure.
305 */
306
307void lttvwindow_register_time_window_notify(MainWindow *main_win,
308 LttvHook hook,
309 gpointer hook_data);
3bc00fde 310
311
312/**
5a5b35c5 313 * Function to unregister the time_window notification hook.
314 *
48f6f981 315 * This unregister function is typically called by the destructor of the viewer.
5a5b35c5 316 *
3bc00fde 317 * @param main_win the main window the viewer belongs to.
5a5b35c5 318 * @param hook hook that sould be called by the main window when the time
319 * interval changes. This hook function takes a
320 * TimeWindowNotifyData* as call_data.
321 * @param hook_data hook data associated with the hook function. It will
322 * be typically a pointer to the viewer's data structure.
3bc00fde 323 */
324
5a5b35c5 325void lttvwindow_unregister_time_window_notify(MainWindow *main_win,
326 LttvHook hook,
327 gpointer hook_data);
3bc00fde 328
329
330/**
5a5b35c5 331 * Function to register a hook function that will be called by the main window
332 * when the traceset is changed. That means that the viewer must redraw
333 * itself completely or check if it's affected by the particular change to the
48f6f981 334 * traceset.
5a5b35c5 335 *
48f6f981 336 * This register function is typically called by the constructor of the viewer.
5a5b35c5 337 *
3bc00fde 338 * @param main_win the main window the viewer belongs to.
5a5b35c5 339 * @param hook hook that should be called whenever a change to the traceset
340 * occurs. The call_data of this hook is a NULL pointer.
341 * @param hook_data hook data associated with the hook function. It will
342 * be typically a pointer to the viewer's data structure.
3bc00fde 343 */
344
5a5b35c5 345void lttvwindow_register_traceset_notify(MainWindow *main_win,
346 LttvHook hook,
347 gpointer hook_data);
3bc00fde 348
349
350/**
5a5b35c5 351 * Function to unregister the traceset_notify hook.
352 *
3bc00fde 353 * @param main_win the main window the viewer belongs to.
5a5b35c5 354 * @param hook hook that should be called whenever a change to the traceset
355 * occurs. The call_data of this hook is a NULL pointer.
356 * @param hook_data hook data associated with the hook function. It will
357 * be typically a pointer to the viewer's data structure.
3bc00fde 358 */
359
5a5b35c5 360void lttvwindow_unregister_traceset_notify(MainWindow *main_win,
361 LttvHook hook,
362 gpointer hook_data);
3bc00fde 363
364
365/**
48f6f981 366 * Function to register a hook function for a viewer to set/update its
5a5b35c5 367 * filter.
368 *
369 * FIXME : Add information about what a filter is as seen from a viewer and how
370 * to use it.
371 *
48f6f981 372 * This register function is typically called by the constructor of the viewer.
5a5b35c5 373 *
3bc00fde 374 * @param main_win the main window the viewer belongs to.
5a5b35c5 375 * @param hook hook function called by the main window when a filter change
376 * occurs.
377 * @param hook_data hook data associated with the hook function. It will
378 * be typically a pointer to the viewer's data structure.
3bc00fde 379 */
380
224446ce 381void lttvwindow_register_filter_notify(MainWindow *main_win,
5a5b35c5 382 LttvHook hook,
383 gpointer hook_data);
3bc00fde 384
385
386/**
48f6f981 387 * Function to unregister a viewer's hook function which is used to
388 * set/update the filter of the viewer.
5a5b35c5 389 *
48f6f981 390 * This unregistration is called by the destructor of the viewer.
5a5b35c5 391 *
48f6f981 392 * @param main_win the main window the viewer belongs to.
5a5b35c5 393 * @param hook hook function called by the main window when a filter change
394 * occurs.
395 * @param hook_data hook data associated with the hook function. It will
396 * be typically a pointer to the viewer's data structure.
3bc00fde 397 */
398
5a5b35c5 399void lttvwindow_unregister_filter_notify(MainWindow * main_win,
400 LttvHook hook,
401 gpointer hook_data);
3bc00fde 402
403
404/**
48f6f981 405 * Function to register a hook function for a viewer to set/update its
406 * current time.
5a5b35c5 407 *
3bc00fde 408 * @param main_win the main window the viewer belongs to.
5a5b35c5 409 * @param hook hook function of the viewer that updates the current time. The
410 * call_data is a LttTime* representing the new current time.
411 * @param hook_data hook data associated with the hook function. It will
412 * be typically a pointer to the viewer's data structure.
3bc00fde 413 */
414
224446ce 415void lttvwindow_register_current_time_notify(MainWindow *main_win,
5a5b35c5 416 LttvHook hook,
417 gpointer hook_data);
3bc00fde 418
419
420/**
421 * Function to unregister a viewer's hook function which is used to
48f6f981 422 * set/update the current time of the viewer.
3bc00fde 423 * @param main_win the main window the viewer belongs to.
5a5b35c5 424 * @param hook hook function of the viewer that updates the current time. The
425 * call_data is a LttTime* representing the new current time.
426 * @param hook_data hook data associated with the hook function. It will
427 * be typically a pointer to the viewer's data structure.
3bc00fde 428 */
429
5a5b35c5 430void lttvwindow_unregister_current_time_notify(MainWindow *main_win,
431 LttvHook hook,
432 gpointer hook_data);
3bc00fde 433
434
224446ce 435/**
436 * Function to register a hook function for a viewer to set/update the
437 * dividor of the hpane. It provides a way to make the horizontal
438 * dividors of all the viewers linked together.
5a5b35c5 439 *
224446ce 440 * @param main_win the main window the viewer belongs to.
5a5b35c5 441 * @param hook hook function of the viewer that will be called whenever a
442 * dividor changes in another viewer. The call_data of this hook
443 * is a gint*. The value of the integer is the new position of the
444 * hpane dividor.
445 * @param hook_data hook data associated with the hook function. It will
446 * be typically a pointer to the viewer's data structure.
224446ce 447 */
3bc00fde 448
224446ce 449void lttvwindow_register_dividor(MainWindow *main_win,
5a5b35c5 450 LttvHook hook,
451 gpointer hook_data);
3bc00fde 452
453
224446ce 454/**
455 * Function to unregister a viewer's hook function which is used to
456 * set/update hpane's dividor of the viewer.
5a5b35c5 457 *
224446ce 458 * @param main_win the main window the viewer belongs to.
5a5b35c5 459 * @param hook hook function of the viewer that will be called whenever a
460 * dividor changes in another viewer. The call_data of this hook
461 * is a gint*. The value of the integer is the new position of the
462 * hpane dividor.
463 * @param hook_data hook data associated with the hook function. It will
464 * be typically a pointer to the viewer's data structure.
224446ce 465 */
466
467void lttvwindow_unregister_dividor(MainWindow *main_win,
5a5b35c5 468 LttvHook hook,
469 gpointer hook_data);
3bc00fde 470
3bc00fde 471
472
473/**
5a5b35c5 474 * This method reports the information to show on the status bar in the
475 * main window.
476 *
3bc00fde 477 * @param main_win the main window the viewer belongs to.
48f6f981 478 * @param info the message which will be shown in the status bar.
3bc00fde 479 */
480
5a5b35c5 481void lttvwindow_report_status(MainWindow *main_win, const char *info);
3bc00fde 482
483
484/**
5a5b35c5 485 * Function to set the time interval of the current tab.a
486 *
3bc00fde 487 * @param main_win the main window the viewer belongs to.
5a5b35c5 488 * @param time_interval pointer to the time interval value.
3bc00fde 489 */
490
5a5b35c5 491void lttvwindow_report_time_window(MainWindow *main_win,
492 const TimeWindow *time_window);
3bc00fde 493
494/**
48f6f981 495 * Function to set the current time/event of the current tab.
496 * It will be called by a viewer's signal handle associated with
497 * the button-release-event signal
3bc00fde 498 * @param main_win the main window the viewer belongs to.
48f6f981 499 * @param time a pointer where time is stored.
3bc00fde 500 */
501
5a5b35c5 502void lttvwindow_report_current_time(MainWindow *main_win,
503 const LttTime *time);
3bc00fde 504
505
506/**
48f6f981 507 * Function to set the position of the hpane's dividor (viewer).
5a5b35c5 508 * It will typically be called by a viewer's signal handle associated
509 * with the motion_notify_event event/signal.
510 *
3bc00fde 511 * @param main_win the main window the viewer belongs to.
48f6f981 512 * @param position position of the hpane's dividor.
3bc00fde 513 */
514
224446ce 515void lttvwindow_report_dividor(MainWindow *main_win, gint position);
3bc00fde 516
517/**
5a5b35c5 518 * Function to set the focused viewer of the tab.
3bc00fde 519 * It will be called by a viewer's signal handle associated with
5a5b35c5 520 * the grab_focus signal of all widgets in the viewer.
521 *
3bc00fde 522 * @param main_win the main window the viewer belongs to.
5a5b35c5 523 * @param top_widget the top widget containing all the other widgets of the
524 * viewer.
3bc00fde 525 */
5a5b35c5 526void lttvwindow_report_focus(MainWindow *main_win,
527 GtkWidget *top_widget);
3bc00fde 528
a43d67ba 529
5a5b35c5 530
531/* Structure sent to the time request hook */
c85f674c 532 /* Value considered as empty */
533typedef struct _EventsRequest {
534 LttTime start_time, /* Unset : { 0, 0 } */
535 LttvTracesetContextPosition start_position, /* Unset : num_traces = 0 */
536 LttTime end_time, /* Unset : { 0, 0 } */
537 guint num_events, /* Unset : G_MAXUINT */
538 LttvTracesetContextPosition end_position, /* Unset : num_traces = 0 */
539 LttvHooksById *before_traceset, /* Unset : NULL */
540 LttvHooksById *before_trace, /* Unset : NULL */
541 LttvHooksById *before_tracefile, /* Unset : NULL */
542 LttvHooksById *middle, /* Unset : NULL */
543 LttvHooksById *after_tracefile, /* Unset : NULL */
544 LttvHooksById *after_trace, /* Unset : NULL */
545 LttvHooksById *after_traceset /* Unset : NULL */
546} EventsRequest;
547
5a5b35c5 548
a43d67ba 549/**
5a5b35c5 550 * Function to request data in a specific time interval to the main window. The
551 * time request servicing is differed until the glib idle functions are
552 * called.
553 *
c85f674c 554 * The viewer has to provide hooks that should be associated with the event
555 * request.
5a5b35c5 556 *
c85f674c 557 * Either start time or start position must be defined in a EventRequest
558 * structure for it to be valid.
559 *
560 * end_time, end_position and num_events can all be defined. The first one
561 * to occur will be used as end criterion.
562 *
a43d67ba 563 * @param main_win the main window the viewer belongs to.
c85f674c 564 * @param events_requested the structure of request from.
a43d67ba 565 */
566
c85f674c 567void lttvwindow_events_request(MainWindow *main_win,
568 EventsRequest events_request);
a43d67ba 569
3bc00fde 570/**
48f6f981 571 * Function to get the life span of the traceset
5a5b35c5 572 *
3bc00fde 573 * @param main_win the main window the viewer belongs to.
5a5b35c5 574 * @return pointer to a time interval : the life span of the traceset.
3bc00fde 575 */
576
224446ce 577const TimeInterval *lttvwindow_get_time_span(MainWindow *main_win);
48f6f981 578
579/**
580 * Function to get the current time window of the current tab.
5a5b35c5 581 *
48f6f981 582 * @param main_win the main window the viewer belongs to.
5a5b35c5 583 * @return a pointer to the current tab's time interval.
48f6f981 584 */
585
224446ce 586const TimeWindow *lttvwindow_get_time_window(MainWindow *main_win);
3bc00fde 587
588
3bc00fde 589/**
5a5b35c5 590 * Function to get the current time of the current tab.
591 *
3bc00fde 592 * @param main_win the main window the viewer belongs to.
5a5b35c5 593 * @return a pointer to the current tab's current time.
48f6f981 594 */
595
224446ce 596const LttTime *lttvwindow_get_current_time(MainWindow *main_win);
48f6f981 597
48f6f981 598
599/**
600 * Function to get the filter of the current tab.
601 * @param main_win, the main window the viewer belongs to.
602 * @param filter, a pointer to a filter.
3bc00fde 603 */
604
224446ce 605//FIXME
606typedef void lttv_filter;
607//FIXME
608const lttv_filter *lttvwindow_get_filter(MainWindow *main_win);
3bc00fde 609
610
3bc00fde 611/**
612 * Function to get the stats of the traceset
5a5b35c5 613 * It must be non const so the viewer can modify it.
614 * FIXME : a set/get pair of functions would be more appropriate here.
224446ce 615 * @param main_win the main window the viewer belongs to.
5a5b35c5 616 * @return A pointer to Traceset statistics.
224446ce 617 */
618
619LttvTracesetStats* lttvwindow_get_traceset_stats(MainWindow *main_win);
620
621/**
622 * Function to get the context of the traceset
623 * It must be non const so the viewer can add and remove hooks from it.
3bc00fde 624 * @param main_win the main window the viewer belongs to.
5a5b35c5 625 * @return Context of the current tab.
3bc00fde 626 */
627
48f6f981 628
224446ce 629LttvTracesetContext* lttvwindow_get_traceset_context(MainWindow *main_win);
48f6f981 630
3bc00fde 631
This page took 0.073659 seconds and 4 git commands to generate.