1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Xiangxiu Yang
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;
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.
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,
20 This file is what every viewer plugin writer should refer to.
22 - streamline the rest.
24 A viewer plugin is, before anything, a plugin. It thus has an init and
25 a destroy function called whenever it is loaded/initialized and
26 unloaded/destroyed. A viewer depends on lttvwindow and thus uses its init and
27 destroy functions to register viewer related hooks defined in this file.
29 The lifetime of a viewer is as follows. The viewer constructor function is
30 called each time an instance view is created (one subwindow of this viewer
31 type is created by the user). Thereafter, the viewer gets hooks called for
32 different purposes by the window containing it. These hooks are detailed
35 show: called initially once the trace, position and time window are known.
36 Do the drawing or register hooks
37 process_trace for show: hooks called
38 show_end: remove the hooks
40 background_init: prepare for background computation (comes after show_end).
41 process_trace for background: done in small chunks in gtk_idle, hooks called.
42 background_end: remove the hooks and perhaps update the window.
44 update: 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.
47 process_trace for update: hooks called
48 update_end: remove the hooks.
50 There may be different versions of update functions for the different cases,
51 or the type of update may be described in an argument. The expose method
52 normally provides the exposed region. This should be used to register hooks
53 to process_traceset but also tell about the time interval for which it is
54 required. Then, a expose_end will be required to remove the hooks and finish
55 the display as needed.
57 In most cases, the enclosing window knows about updates such as a new trace
58 added to a traceset, time window updates caused by scrolling and even
59 expose events. There are a few cases, however, where updates are caused by
60 actions known by a view instance. For example, clicking in a view may update
61 the current time; all viewers within the same window must be told about the
62 new current time to change the currently highlighted time point. A viewer
63 reports such events by calling report_update on its lttvwindow. The lttvwindow
64 will thereafter call update for each of its contained viewers.
67 Things that can happen to a viewer:
75 ?? Reshape, damage as gtk methods ??
77 Things that a viewer can do:
93 * \brief API used by the graphical viewers to interact with their top window.
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
98 * This header file should be included in each graphic module.
99 * This library is used by graphical modules to interact with the
106 #include <lttv/hook.h>
107 #include <lttvwindow/common.h>
108 #include <lttv/stats.h>
111 * Function to register a view constructor so that main window can generate
112 * a toolbar item for the viewer in order to generate a new instance easily.
113 * It will be called by init function of the module.
114 * @param ButtonPixmap image shown on the toolbar item.
115 * @param tooltip tooltip of the toolbar item.
116 * @param view_constructor constructor of the viewer.
119 void lttvwindow_viewer_register_toolbar_item(char ** pixmap
, char *tooltip
, lttvwindow_viewer_constructor view_constructor
);
123 * Function to unregister the viewer's constructor, release the space
124 * occupied by pixmap, tooltip and constructor of the viewer.
125 * It will be called when a module is unloaded.
126 * @param view_constructor constructor of the viewer which is used as
127 * a reference to find out where the pixmap and tooltip are.
130 void toolbar_item_unreg(lttvwindow_viewer_constructor view_constructor
);
134 * Function to register a view constructor so that main window can generate
135 * a menu item for the viewer in order to generate a new instance easily.
136 * It will be called by init function of the module.
137 * @param menu_path path of the menu item.
138 * @param menu_text text of the menu item.
139 * @param view_constructor constructor of the viewer.
142 void menu_item_reg(char *menu_path
, char *menu_text
, lttvwindow_viewer_constructor view_constructor
);
146 * Function to unregister the viewer's constructor, release the space
147 * occupied by menu_path, menu_text and constructor of the viewer.
148 * It will be called when a module is unloaded.
149 * @param view_constructor constructor of the viewer which is used as
150 * a reference to find out where the menu_path and menu_text are.
153 void menu_item_unreg(lttvwindow_viewer_constructor view_constructor
);
157 * Update the status bar whenever something changed in the viewer.
158 * @param main_win the main window the viewer belongs to.
159 * @param info the message which will be shown in the status bar.
162 void update_status(MainWindow
*main_win
, char *info
);
166 * Function to get the current time window of the current tab.
167 * It will be called by a viewer's hook function to update the
168 * time window of the viewer and also be called by the constructor
170 * @param main_win the main window the viewer belongs to.
171 * @param time_interval a pointer where time interval will be stored.
174 void get_time_window(MainWindow
*main_win
, TimeWindow
*time_window
);
178 * Function to set the time interval of the current tab.
179 * It will be called by a viewer's signal handle associated with
180 * the move_slider signal
181 * @param main_win the main window the viewer belongs to.
182 * @param time_interval a pointer where time interval is stored.
185 void set_time_window(MainWindow
*main_win
, TimeWindow
*time_window
);
188 * Function to get the current time/event of the current tab.
189 * It will be called by a viewer's hook function to update the
190 * current time/event of the viewer.
191 * @param main_win the main window the viewer belongs to.
192 * @param time a pointer where time will be stored.
195 void get_current_time(MainWindow
*main_win
, LttTime
*time
);
199 * Function to set the current time/event of the current tab.
200 * It will be called by a viewer's signal handle associated with
201 * the button-release-event signal
202 * @param main_win the main window the viewer belongs to.
203 * @param time a pointer where time is stored.
206 void set_current_time(MainWindow
*main_win
, LttTime
*time
);
210 * Function to get the traceset from the current tab.
211 * It will be called by the constructor of the viewer and also be
212 * called by a hook funtion of the viewer to update its traceset.
213 * @param main_win the main window the viewer belongs to.
214 * @param traceset a pointer to a traceset.
217 //void get_traceset(MainWindow *main_win, Traceset *traceset);
221 * Function to get the filter of the current tab.
222 * It will be called by the constructor of the viewer and also be
223 * called by a hook funtion of the viewer to update its filter.
224 * @param main_win, the main window the viewer belongs to.
225 * @param filter, a pointer to a filter.
228 //void get_filter(MainWindow *main_win, Filter *filter);
232 * Function to register a hook function for a viewer to set/update its
234 * It will be called by the constructor of the viewer.
235 * @param hook hook function of the viewer. Takes a TimeInterval* as call_data.
236 * @param hook_data hook data associated with the hook function.
237 * @param main_win the main window the viewer belongs to.
240 void reg_update_time_window(LttvHook hook
, gpointer hook_data
,
241 MainWindow
* main_win
);
245 * Function to unregister a viewer's hook function which is used to
246 * set/update the time interval of the viewer.
247 * It will be called by the destructor of the viewer.
248 * @param hook hook function of the viewer. Takes a TimeInterval as call_data.
249 * @param hook_data hook data associated with the hook function.
250 * @param main_win the main window the viewer belongs to.
253 void unreg_update_time_window(LttvHook hook
, gpointer hook_data
,
254 MainWindow
* main_win
);
258 * Function to register a hook function for a viewer to set/update its
260 * It will be called by the constructor of the viewer.
261 * @param hook hook function of the viewer.
262 * @param hook_data hook data associated with the hook function.
263 * @param main_win the main window the viewer belongs to.
266 void reg_update_traceset(LttvHook hook
, gpointer hook_data
,
267 MainWindow
* main_win
);
271 * Function to unregister a viewer's hook function which is used to
272 * set/update the traceset of the viewer.
273 * It will be called by the destructor of the viewer.
274 * @param hook hook function of the viewer.
275 * @param hook_data hook data associated with the hook function.
276 * @param main_win the main window the viewer belongs to.
279 void unreg_update_traceset(LttvHook hook
, gpointer hook_data
,
280 MainWindow
* main_win
);
284 * Function to redraw each viewer belonging to the current tab
285 * @param main_win the main window the viewer belongs to.
288 void update_traceset(MainWindow
* main_win
);
292 * Function to register a hook function for a viewer to set/update its
294 * It will be called by the constructor of the viewer.
295 * @param hook hook function of the viewer.
296 * @param hook_data hook data associated with the hook function.
297 * @param main_win the main window the viewer belongs to.
300 void reg_update_filter(LttvHook hook
, gpointer hook_data
,
301 MainWindow
*main_win
);
305 * Function to unregister a viewer's hook function which is used to
306 * set/update the filter of the viewer.
307 * It will be called by the destructor of the viewer.
308 * @param hook hook function of the viewer.
309 * @param hook_data hook data associated with the hook function.
310 * @param main_win the main window the viewer belongs to.
313 void unreg_update_filter(LttvHook hook
, gpointer hook_data
,
314 MainWindow
* main_win
);
318 * Function to register a hook function for a viewer to set/update its
320 * It will be called by the constructor of the viewer.
321 * @param hook hook function of the viewer.
322 * @param hook_data hook data associated with the hook function.
323 * @param main_win the main window the viewer belongs to.
326 void reg_update_current_time(LttvHook hook
, gpointer hook_data
,
327 MainWindow
*main_win
);
331 * Function to unregister a viewer's hook function which is used to
332 * set/update the current time of the viewer.
333 * It will be called by the destructor of the viewer.
334 * @param hook hook function of the viewer.
335 * @param hook_data hook data associated with the hook function.
336 * @param main_win the main window the viewer belongs to.
339 void unreg_update_current_time(LttvHook hook
, gpointer hook_data
,
340 MainWindow
* main_win
);
344 * Function to register a hook function for a viewer to show
345 *the content of the viewer.
346 * It will be called by the constructor of the viewer.
347 * @param hook hook function of the viewer.
348 * @param hook_data hook data associated with the hook function.
349 * @param main_win the main window the viewer belongs to.
352 void reg_show_viewer(LttvHook hook
, gpointer hook_data
,
353 MainWindow
*main_win
);
357 * Function to unregister a viewer's hook function which is used to
358 * show the content of the viewer..
359 * It will be called by the destructor of the viewer.
360 * @param hook hook function of the viewer.
361 * @param hook_data hook data associated with the hook function.
362 * @param main_win the main window the viewer belongs to.
365 void unreg_show_viewer(LttvHook hook
, gpointer hook_data
,
366 MainWindow
* main_win
);
370 * Function to show each viewer in the current tab.
371 * It will be called by main window after it called process_traceset
372 * @param main_win the main window the viewer belongs to.
375 void show_viewer(MainWindow
*main_win
);
379 * Function to set the focused pane (viewer).
380 * It will be called by a viewer's signal handle associated with
381 * the grab_focus signal
382 * @param main_win the main window the viewer belongs to.
383 * @param paned a pointer to a pane where the viewer is contained.
386 void set_focused_pane(MainWindow
*main_win
, gpointer paned
);
390 * Function to register a hook function for a viewer to set/update the
391 * dividor of the hpane.
392 * It will be called by the constructor of the viewer.
393 * @param hook hook function of the viewer.
394 * @param hook_data hook data associated with the hook function.
395 * @param main_win the main window the viewer belongs to.
398 void reg_update_dividor(LttvHook hook
, gpointer hook_data
,
399 MainWindow
*main_win
);
403 * Function to unregister a viewer's hook function which is used to
404 * set/update hpane's dividor of the viewer.
405 * It will be called by the destructor of the viewer.
406 * @param hook hook function of the viewer.
407 * @param hook_data hook data associated with the hook function.
408 * @param main_win the main window the viewer belongs to.
411 void unreg_update_dividor(LttvHook hook
, gpointer hook_data
,
412 MainWindow
*main_win
);
416 * Function to set the position of the hpane's dividor (viewer).
417 * It will be called by a viewer's signal handle associated with
418 * the motion_notify_event event/signal
419 * @param main_win the main window the viewer belongs to.
420 * @param position position of the hpane's dividor.
423 void set_hpane_dividor(MainWindow
*main_win
, gint position
);
427 * Function to get the life span of the traceset
428 * @param main_win the main window the viewer belongs to.
429 * @param start start time of the traceset.
430 * @param end end time of the traceset.
433 void get_traceset_time_span(MainWindow
*main_win
, TimeInterval
*time_span
);
437 * Function to get the stats of the traceset
438 * @param main_win the main window the viewer belongs to.
441 LttvTracesetStats
* get_traceset_stats(MainWindow
*main_win
);
443 LttvTracesetContext
* get_traceset_context(MainWindow
*main_win
);