merge modifications for multiple viewer read at the same time, better expose handling...
[lttv.git] / ltt / branches / poly / lttv / modules / gui / lttvwindow / lttvwindow / viewer.h
CommitLineData
3bc00fde 1/* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Xiangxiu 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
f95bc830 19/*
911b7a3c 20This file is what every viewer plugin writer should refer to.
21
911b7a3c 22- streamline the rest.
23
24A viewer plugin is, before anything, a plugin. It thus has an init and
25a destroy function called whenever it is loaded/initialized and
26unloaded/destroyed. A viewer depends on lttvwindow and thus uses its init and
27destroy functions to register viewer related hooks defined in this file.
28
29The lifetime of a viewer is as follows. The viewer constructor function is
30called each time an instance view is created (one subwindow of this viewer
31type is created by the user). Thereafter, the viewer gets hooks called for
32different purposes by the window containing it. These hooks are detailed
33below.
34
35show: called initially once the trace, position and time window are known.
36 Do the drawing or register hooks
37process_trace for show: hooks called
38show_end: remove the hooks
39
40background_init: prepare for background computation (comes after show_end).
41process_trace for background: done in small chunks in gtk_idle, hooks called.
42background_end: remove the hooks and perhaps update the window.
43
44update: called when the windows is exposed/resized, the time window is changed,
45 the current time is changed or the traceset is changed (different
46 traceset or traces added/removed. Redraw or register hooks.
47process_trace for update: hooks called
48update_end: remove the hooks.
49
50There may be different versions of update functions for the different cases,
51or the type of update may be described in an argument. The expose method
52normally provides the exposed region. This should be used to register hooks
53to process_traceset but also tell about the time interval for which it is
54required. Then, a expose_end will be required to remove the hooks and finish
55the display as needed.
56
57In most cases, the enclosing window knows about updates such as a new trace
58added to a traceset, time window updates caused by scrolling and even
59expose events. There are a few cases, however, where updates are caused by
60actions known by a view instance. For example, clicking in a view may update
61the current time; all viewers within the same window must be told about the
62new current time to change the currently highlighted time point. A viewer
63reports such events by calling report_update on its lttvwindow. The lttvwindow
64will thereafter call update for each of its contained viewers.
65
f95bc830 66
67Things that can happen to a viewer:
68
69update_time_window
70update_current_time
71update_traceset
72update_filter
73show_viewer
74update_dividor
911b7a3c 75?? Reshape, damage as gtk methods ??
f95bc830 76
77Things that a viewer can do:
78
79update_status
224446ce 80lttvwindow_report_time_window
f95bc830 81set_current_time
224446ce 82update_traceset -> not actually
83update_filter -> not actually
84show_viewer -> makes no sense.
f95bc830 85set_focused_pane
86set_hpane_dividor
87*/
88
89
90
91
36b40c74 92/*! \file viewer.h
3bc00fde 93 * \brief API used by the graphical viewers to interact with their top window.
94 *
95 * Main window (gui module) is the place to contain and display viewers.
96 * Viewers (lttv plugins) interacte with main window through this API and
97 * events sent by gtk.
98 * This header file should be included in each graphic module.
99 * This library is used by graphical modules to interact with the
100 * tracesetWindow.
101 *
102 */
103
104#include <gtk/gtk.h>
105#include <ltt/ltt.h>
106#include <lttv/hook.h>
13f86ce2 107#include <lttvwindow/common.h>
3bc00fde 108#include <lttv/stats.h>
224446ce 109//FIXME (not ready yet) #include <lttv/filter.h>
3bc00fde 110
111/**
112 * Function to register a view constructor so that main window can generate
113 * a toolbar item for the viewer in order to generate a new instance easily.
114 * It will be called by init function of the module.
115 * @param ButtonPixmap image shown on the toolbar item.
116 * @param tooltip tooltip of the toolbar item.
117 * @param view_constructor constructor of the viewer.
118 */
119
224446ce 120void lttvwindow_register_toolbar(char ** pixmap, char *tooltip, lttvwindow_viewer_constructor view_constructor);
3bc00fde 121
122
123/**
124 * Function to unregister the viewer's constructor, release the space
125 * occupied by pixmap, tooltip and constructor of the viewer.
126 * It will be called when a module is unloaded.
127 * @param view_constructor constructor of the viewer which is used as
128 * a reference to find out where the pixmap and tooltip are.
129 */
130
224446ce 131void lttvwindow_unregister_toolbar(lttvwindow_viewer_constructor view_constructor);
3bc00fde 132
133
134/**
135 * Function to register a view constructor so that main window can generate
136 * a menu item for the viewer in order to generate a new instance easily.
137 * It will be called by init function of the module.
138 * @param menu_path path of the menu item.
139 * @param menu_text text of the menu item.
140 * @param view_constructor constructor of the viewer.
141 */
142
224446ce 143void lttvwindow_register_menu(char *menu_path, char *menu_text, lttvwindow_viewer_constructor view_constructor);
3bc00fde 144
145
146/**
147 * Function to unregister the viewer's constructor, release the space
148 * occupied by menu_path, menu_text and constructor of the viewer.
149 * It will be called when a module is unloaded.
150 * @param view_constructor constructor of the viewer which is used as
151 * a reference to find out where the menu_path and menu_text are.
152 */
153
224446ce 154void lttvwindow_unregister_menu(lttvwindow_viewer_constructor view_constructor);
3bc00fde 155
156
157/**
48f6f981 158 * Function to register a hook function for a viewer to update its
159 * time interval.
160 * This register function is typically called by the constructor of the viewer.
161 * @param hook hook function of the viewer. Takes a TimeInterval* as call_data.
162 * @param hook_data hook data associated with the hook function.
3bc00fde 163 * @param main_win the main window the viewer belongs to.
3bc00fde 164 */
165
224446ce 166typedef struct _TimeWindowNotifyData {
167 TimeWindow *new_time_window;
168 TimeWindow *old_time_window;
169} TimeWindowNotifyData;
170
171void lttvwindow_register_time_window_notify(MainWindow * main_win,
48f6f981 172 LttvHook hook, gpointer hook_data);
3bc00fde 173
174
175/**
48f6f981 176 * Function to unregister a viewer's hook function which is used to
177 * set/update the time interval of the viewer.
178 * This unregister function is typically called by the destructor of the viewer.
179 * @param hook hook function of the viewer. Takes a TimeInterval as call_data.
180 * @param hook_data hook data associated with the hook function.
3bc00fde 181 * @param main_win the main window the viewer belongs to.
3bc00fde 182 */
183
224446ce 184void lttvwindow_unregister_time_window_notify(MainWindow * main_win,
48f6f981 185 LttvHook hook, gpointer hook_data);
3bc00fde 186
187
188/**
48f6f981 189 * Function to register a hook function for a viewer to set/update its
190 * traceset.
191 * This register function is typically called by the constructor of the viewer.
192 * @param hook hook function of the viewer.
193 * @param hook_data hook data associated with the hook function.
3bc00fde 194 * @param main_win the main window the viewer belongs to.
3bc00fde 195 */
196
224446ce 197void lttvwindow_register_traceset_notify(MainWindow * main_win,
48f6f981 198 LttvHook hook, gpointer hook_data);
3bc00fde 199
200
201/**
48f6f981 202 * Function to unregister a viewer's hook function which is used to
203 * set/update the traceset of the viewer.
204 * @param hook hook function of the viewer.
205 * @param hook_data hook data associated with the hook function.
3bc00fde 206 * @param main_win the main window the viewer belongs to.
3bc00fde 207 */
208
224446ce 209void lttvwindow_unregister_traceset_notify(MainWindow * main_win,
48f6f981 210 LttvHook hook, gpointer hook_data);
3bc00fde 211
212
213/**
48f6f981 214 * Function to register a hook function for a viewer to set/update its
215 * filter.
216 * This register function is typically called by the constructor of the viewer.
217 * @param hook hook function of the viewer.
218 * @param hook_data hook data associated with the hook function.
3bc00fde 219 * @param main_win the main window the viewer belongs to.
3bc00fde 220 */
221
224446ce 222void lttvwindow_register_filter_notify(MainWindow *main_win,
48f6f981 223 LttvHook hook, gpointer hook_data);
3bc00fde 224
225
226/**
48f6f981 227 * Function to unregister a viewer's hook function which is used to
228 * set/update the filter of the viewer.
229 * This unregistration is called by the destructor of the viewer.
230 * @param hook hook function of the viewer.
231 * @param hook_data hook data associated with the hook function.
232 * @param main_win the main window the viewer belongs to.
3bc00fde 233 */
234
224446ce 235void lttvwindow_unregister_filter_notify(LttvHook hook, gpointer hook_data,
48f6f981 236 MainWindow * main_win);
3bc00fde 237
238
239/**
48f6f981 240 * Function to register a hook function for a viewer to set/update its
241 * current time.
242 * @param hook hook function of the viewer.
3bc00fde 243 * @param hook_data hook data associated with the hook function.
244 * @param main_win the main window the viewer belongs to.
245 */
246
224446ce 247void lttvwindow_register_current_time_notify(MainWindow *main_win,
48f6f981 248 LttvHook hook, gpointer hook_data);
3bc00fde 249
250
251/**
252 * Function to unregister a viewer's hook function which is used to
48f6f981 253 * set/update the current time of the viewer.
254 * @param hook hook function of the viewer.
3bc00fde 255 * @param hook_data hook data associated with the hook function.
256 * @param main_win the main window the viewer belongs to.
257 */
258
224446ce 259void lttvwindow_unregister_current_time_notify(MainWindow * main_win,
48f6f981 260 LttvHook hook, gpointer hook_data);
3bc00fde 261
262
263/**
48f6f981 264 * Function to register a hook function for a viewer to show
265 * its content.
3bc00fde 266 * @param hook hook function of the viewer.
267 * @param hook_data hook data associated with the hook function.
268 * @param main_win the main window the viewer belongs to.
269 */
270
a43d67ba 271void lttvwindow_register_show_notify(MainWindow *main_win,
48f6f981 272 LttvHook hook, gpointer hook_data);
3bc00fde 273
274
275/**
276 * Function to unregister a viewer's hook function which is used to
48f6f981 277 * show the content of the viewer.
3bc00fde 278 * @param hook hook function of the viewer.
279 * @param hook_data hook data associated with the hook function.
280 * @param main_win the main window the viewer belongs to.
281 */
282
a43d67ba 283void lttvwindow_unregister_show_notify(MainWindow * main_win,
48f6f981 284 LttvHook hook, gpointer hook_data);
3bc00fde 285
286
224446ce 287/**
288 * Function to register a hook function for a viewer to set/update the
289 * dividor of the hpane. It provides a way to make the horizontal
290 * dividors of all the viewers linked together.
291 * @param hook hook function of the viewer.
292 * @param hook_data hook data associated with the hook function.
293 * @param main_win the main window the viewer belongs to.
294 */
3bc00fde 295
224446ce 296void lttvwindow_register_dividor(MainWindow *main_win,
297 LttvHook hook, gpointer hook_data);
3bc00fde 298
299
224446ce 300/**
301 * Function to unregister a viewer's hook function which is used to
302 * set/update hpane's dividor of the viewer.
303 * @param hook hook function of the viewer.
304 * @param hook_data hook data associated with the hook function.
305 * @param main_win the main window the viewer belongs to.
306 */
307
308void lttvwindow_unregister_dividor(MainWindow *main_win,
309 LttvHook hook, gpointer hook_data);
3bc00fde 310
3bc00fde 311
312
313/**
48f6f981 314 * Update the status bar whenever something changed in the viewer.
3bc00fde 315 * @param main_win the main window the viewer belongs to.
48f6f981 316 * @param info the message which will be shown in the status bar.
3bc00fde 317 */
318
224446ce 319void lttvwindow_report_status(MainWindow *main_win, char *info);
3bc00fde 320
321
322/**
48f6f981 323 * Function to set the time interval of the current tab.
324 * It will be called by a viewer's signal handle associated with
325 * the move_slider signal
3bc00fde 326 * @param main_win the main window the viewer belongs to.
48f6f981 327 * @param time_interval a pointer where time interval is stored.
3bc00fde 328 */
329
224446ce 330void lttvwindow_report_time_window(MainWindow *main_win, TimeWindow *time_window);
3bc00fde 331
332/**
48f6f981 333 * Function to set the current time/event of the current tab.
334 * It will be called by a viewer's signal handle associated with
335 * the button-release-event signal
3bc00fde 336 * @param main_win the main window the viewer belongs to.
48f6f981 337 * @param time a pointer where time is stored.
3bc00fde 338 */
339
224446ce 340void lttvwindow_report_current_time(MainWindow *main_win, LttTime *time);
3bc00fde 341
342
343/**
48f6f981 344 * Function to set the position of the hpane's dividor (viewer).
345 * It will be called by a viewer's signal handle associated with
346 * the motion_notify_event event/signal
3bc00fde 347 * @param main_win the main window the viewer belongs to.
48f6f981 348 * @param position position of the hpane's dividor.
3bc00fde 349 */
350
224446ce 351void lttvwindow_report_dividor(MainWindow *main_win, gint position);
3bc00fde 352
353/**
354 * Function to set the focused pane (viewer).
355 * It will be called by a viewer's signal handle associated with
356 * the grab_focus signal
357 * @param main_win the main window the viewer belongs to.
358 * @param paned a pointer to a pane where the viewer is contained.
359 */
48f6f981 360//FIXME : can we do this through normal GTK signals ?
224446ce 361void lttvwindow_report_focus(MainWindow *main_win, gpointer paned);
3bc00fde 362
a43d67ba 363
364/**
365 * Function to request data in a specific time interval to the main window.
366 * The main window will use this time interval and the others present
367 * to get the data from the process trace.
368 * @param main_win the main window the viewer belongs to.
369 * @param paned a pointer to a pane where the viewer is contained.
370 */
371
372void lttvwindow_time_interval_request(MainWindow *main_win,
373 TimeWindow time_requested, guint num_events,
374 LttvHook after_process_traceset,
375 gpointer after_process_traceset_data);
376
3bc00fde 377/**
48f6f981 378 * Function to get the life span of the traceset
3bc00fde 379 * @param main_win the main window the viewer belongs to.
48f6f981 380 * @param start start time of the traceset.
381 * @param end end time of the traceset.
3bc00fde 382 */
383
224446ce 384const TimeInterval *lttvwindow_get_time_span(MainWindow *main_win);
48f6f981 385
386/**
387 * Function to get the current time window of the current tab.
388 * @param main_win the main window the viewer belongs to.
389 * @param time_interval a pointer where time interval will be stored.
390 */
391
224446ce 392const TimeWindow *lttvwindow_get_time_window(MainWindow *main_win);
3bc00fde 393
394
3bc00fde 395/**
48f6f981 396 * Function to get the current time/event of the current tab.
3bc00fde 397 * @param main_win the main window the viewer belongs to.
48f6f981 398 * @param time a pointer where time will be stored.
399 */
400
224446ce 401const LttTime *lttvwindow_get_current_time(MainWindow *main_win);
48f6f981 402
403/**
404 * Function to get the traceset from the current tab.
405 * @param main_win the main window the viewer belongs to.
406 * @param traceset a pointer to a traceset.
407 */
408
224446ce 409const LttvTraceset *lttvwindow_get_traceset(MainWindow *main_win);
48f6f981 410
411
412/**
413 * Function to get the filter of the current tab.
414 * @param main_win, the main window the viewer belongs to.
415 * @param filter, a pointer to a filter.
3bc00fde 416 */
417
224446ce 418//FIXME
419typedef void lttv_filter;
420//FIXME
421const lttv_filter *lttvwindow_get_filter(MainWindow *main_win);
3bc00fde 422
423
3bc00fde 424/**
425 * Function to get the stats of the traceset
224446ce 426 * It must be non const so the viewer can modify it. //FIXME really ?
427 * @param main_win the main window the viewer belongs to.
428 */
429
430LttvTracesetStats* lttvwindow_get_traceset_stats(MainWindow *main_win);
431
432/**
433 * Function to get the context of the traceset
434 * It must be non const so the viewer can add and remove hooks from it.
3bc00fde 435 * @param main_win the main window the viewer belongs to.
436 */
437
48f6f981 438
224446ce 439LttvTracesetContext* lttvwindow_get_traceset_context(MainWindow *main_win);
48f6f981 440
3bc00fde 441
This page took 0.043902 seconds and 4 git commands to generate.