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:
80 lttvwindow_report_time_window
82 update_traceset -> not actually
83 update_filter -> not actually
84 show_viewer -> makes no sense.
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>
109 //FIXME (not ready yet) #include <lttv/filter.h>
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.
120 void lttvwindow_register_toolbar(char ** pixmap
, char *tooltip
, lttvwindow_viewer_constructor view_constructor
);
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.
131 void lttvwindow_unregister_toolbar(lttvwindow_viewer_constructor view_constructor
);
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.
143 void lttvwindow_register_menu(char *menu_path
, char *menu_text
, lttvwindow_viewer_constructor view_constructor
);
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.
154 void lttvwindow_unregister_menu(lttvwindow_viewer_constructor view_constructor
);
158 * Function to register a hook function for a viewer to update its
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.
163 * @param main_win the main window the viewer belongs to.
166 typedef struct _TimeWindowNotifyData
{
167 TimeWindow
*new_time_window
;
168 TimeWindow
*old_time_window
;
169 } TimeWindowNotifyData
;
171 void lttvwindow_register_time_window_notify(MainWindow
* main_win
,
172 LttvHook hook
, gpointer hook_data
);
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.
181 * @param main_win the main window the viewer belongs to.
184 void lttvwindow_unregister_time_window_notify(MainWindow
* main_win
,
185 LttvHook hook
, gpointer hook_data
);
189 * Function to register a hook function for a viewer to set/update its
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.
194 * @param main_win the main window the viewer belongs to.
197 void lttvwindow_register_traceset_notify(MainWindow
* main_win
,
198 LttvHook hook
, gpointer hook_data
);
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.
206 * @param main_win the main window the viewer belongs to.
209 void lttvwindow_unregister_traceset_notify(MainWindow
* main_win
,
210 LttvHook hook
, gpointer hook_data
);
214 * Function to register a hook function for a viewer to set/update its
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.
219 * @param main_win the main window the viewer belongs to.
222 void lttvwindow_register_filter_notify(MainWindow
*main_win
,
223 LttvHook hook
, gpointer hook_data
);
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.
235 void lttvwindow_unregister_filter_notify(LttvHook hook
, gpointer hook_data
,
236 MainWindow
* main_win
);
240 * Function to register a hook function for a viewer to set/update its
242 * @param hook hook function of the viewer.
243 * @param hook_data hook data associated with the hook function.
244 * @param main_win the main window the viewer belongs to.
247 void lttvwindow_register_current_time_notify(MainWindow
*main_win
,
248 LttvHook hook
, gpointer hook_data
);
252 * Function to unregister a viewer's hook function which is used to
253 * set/update the current time of the viewer.
254 * @param hook hook function of the viewer.
255 * @param hook_data hook data associated with the hook function.
256 * @param main_win the main window the viewer belongs to.
259 void lttvwindow_unregister_current_time_notify(MainWindow
* main_win
,
260 LttvHook hook
, gpointer hook_data
);
264 * Function to register a hook function for a viewer to show
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.
271 void lttvwindow_register_show(MainWindow
*main_win
,
272 LttvHook hook
, gpointer hook_data
);
276 * Function to unregister a viewer's hook function which is used to
277 * show the content of the viewer.
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.
283 void lttvwindow_unregister_show(MainWindow
* main_win
,
284 LttvHook hook
, gpointer hook_data
);
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.
296 void lttvwindow_register_dividor(MainWindow
*main_win
,
297 LttvHook hook
, gpointer hook_data
);
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.
308 void lttvwindow_unregister_dividor(MainWindow
*main_win
,
309 LttvHook hook
, gpointer hook_data
);
314 * Update the status bar whenever something changed in the viewer.
315 * @param main_win the main window the viewer belongs to.
316 * @param info the message which will be shown in the status bar.
319 void lttvwindow_report_status(MainWindow
*main_win
, char *info
);
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
326 * @param main_win the main window the viewer belongs to.
327 * @param time_interval a pointer where time interval is stored.
330 void lttvwindow_report_time_window(MainWindow
*main_win
, TimeWindow
*time_window
);
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
336 * @param main_win the main window the viewer belongs to.
337 * @param time a pointer where time is stored.
340 void lttvwindow_report_current_time(MainWindow
*main_win
, LttTime
*time
);
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
347 * @param main_win the main window the viewer belongs to.
348 * @param position position of the hpane's dividor.
351 void lttvwindow_report_dividor(MainWindow
*main_win
, gint position
);
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.
360 //FIXME : can we do this through normal GTK signals ?
361 void lttvwindow_report_focus(MainWindow
*main_win
, gpointer paned
);
364 * Function to get the life span of the traceset
365 * @param main_win the main window the viewer belongs to.
366 * @param start start time of the traceset.
367 * @param end end time of the traceset.
370 const TimeInterval
*lttvwindow_get_time_span(MainWindow
*main_win
);
373 * Function to get the current time window of the current tab.
374 * @param main_win the main window the viewer belongs to.
375 * @param time_interval a pointer where time interval will be stored.
378 const TimeWindow
*lttvwindow_get_time_window(MainWindow
*main_win
);
382 * Function to get the current time/event of the current tab.
383 * @param main_win the main window the viewer belongs to.
384 * @param time a pointer where time will be stored.
387 const LttTime
*lttvwindow_get_current_time(MainWindow
*main_win
);
390 * Function to get the traceset from the current tab.
391 * @param main_win the main window the viewer belongs to.
392 * @param traceset a pointer to a traceset.
395 const LttvTraceset
*lttvwindow_get_traceset(MainWindow
*main_win
);
399 * Function to get the filter of the current tab.
400 * @param main_win, the main window the viewer belongs to.
401 * @param filter, a pointer to a filter.
405 typedef void lttv_filter
;
407 const lttv_filter
*lttvwindow_get_filter(MainWindow
*main_win
);
411 * Function to get the stats of the traceset
412 * It must be non const so the viewer can modify it. //FIXME really ?
413 * @param main_win the main window the viewer belongs to.
416 LttvTracesetStats
* lttvwindow_get_traceset_stats(MainWindow
*main_win
);
419 * Function to get the context of the traceset
420 * It must be non const so the viewer can add and remove hooks from it.
421 * @param main_win the main window the viewer belongs to.
425 LttvTracesetContext
* lttvwindow_get_traceset_context(MainWindow
*main_win
);