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 |
20 | This file is what every viewer plugin writer should refer to. |
21 | |
911b7a3c |
22 | - streamline the rest. |
23 | |
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. |
28 | |
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 |
33 | below. |
34 | |
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 |
39 | |
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. |
43 | |
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. |
49 | |
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. |
56 | |
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. |
65 | |
f95bc830 |
66 | |
67 | Things that can happen to a viewer: |
68 | |
69 | update_time_window |
70 | update_current_time |
71 | update_traceset |
72 | update_filter |
73 | show_viewer |
74 | update_dividor |
911b7a3c |
75 | ?? Reshape, damage as gtk methods ?? |
f95bc830 |
76 | |
77 | Things that a viewer can do: |
78 | |
79 | update_status |
224446ce |
80 | lttvwindow_report_time_window |
f95bc830 |
81 | set_current_time |
224446ce |
82 | update_traceset -> not actually |
83 | update_filter -> not actually |
84 | show_viewer -> makes no sense. |
f95bc830 |
85 | set_focused_pane |
86 | set_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 |
120 | void 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 |
131 | void 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 |
143 | void 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 |
154 | void 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 |
166 | typedef struct _TimeWindowNotifyData { |
167 | TimeWindow *new_time_window; |
168 | TimeWindow *old_time_window; |
169 | } TimeWindowNotifyData; |
170 | |
171 | void 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 |
184 | void 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 |
197 | void 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 |
209 | void 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 |
222 | void 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 |
235 | void 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 |
247 | void 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 |
259 | void 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 | |
224446ce |
271 | void lttvwindow_register_show(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 | |
224446ce |
283 | void lttvwindow_unregister_show(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 |
296 | void 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 | |
308 | void 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 |
319 | void 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 |
330 | void 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 |
340 | void 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 |
351 | void 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 |
361 | void lttvwindow_report_focus(MainWindow *main_win, gpointer paned); |
3bc00fde |
362 | |
363 | /** |
48f6f981 |
364 | * Function to get the life span of the traceset |
3bc00fde |
365 | * @param main_win the main window the viewer belongs to. |
48f6f981 |
366 | * @param start start time of the traceset. |
367 | * @param end end time of the traceset. |
3bc00fde |
368 | */ |
369 | |
224446ce |
370 | const TimeInterval *lttvwindow_get_time_span(MainWindow *main_win); |
48f6f981 |
371 | |
372 | /** |
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. |
376 | */ |
377 | |
224446ce |
378 | const TimeWindow *lttvwindow_get_time_window(MainWindow *main_win); |
3bc00fde |
379 | |
380 | |
3bc00fde |
381 | /** |
48f6f981 |
382 | * Function to get the current time/event of the current tab. |
3bc00fde |
383 | * @param main_win the main window the viewer belongs to. |
48f6f981 |
384 | * @param time a pointer where time will be stored. |
385 | */ |
386 | |
224446ce |
387 | const LttTime *lttvwindow_get_current_time(MainWindow *main_win); |
48f6f981 |
388 | |
389 | /** |
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. |
393 | */ |
394 | |
224446ce |
395 | const LttvTraceset *lttvwindow_get_traceset(MainWindow *main_win); |
48f6f981 |
396 | |
397 | |
398 | /** |
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. |
3bc00fde |
402 | */ |
403 | |
224446ce |
404 | //FIXME |
405 | typedef void lttv_filter; |
406 | //FIXME |
407 | const lttv_filter *lttvwindow_get_filter(MainWindow *main_win); |
3bc00fde |
408 | |
409 | |
3bc00fde |
410 | /** |
411 | * Function to get the stats of the traceset |
224446ce |
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. |
414 | */ |
415 | |
416 | LttvTracesetStats* lttvwindow_get_traceset_stats(MainWindow *main_win); |
417 | |
418 | /** |
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. |
3bc00fde |
421 | * @param main_win the main window the viewer belongs to. |
422 | */ |
423 | |
48f6f981 |
424 | |
224446ce |
425 | LttvTracesetContext* lttvwindow_get_traceset_context(MainWindow *main_win); |
48f6f981 |
426 | |
3bc00fde |
427 | |