dcd2cf998460c1cedefbfef453782ba9d3e8b302
[lttv.git] /
1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Mathieu Desnoyers and XangXiu Yang
3 * 2005 Mathieu Desnoyers
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License Version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
17 * MA 02111-1307, USA.
18 */
19
20
21 //*! \defgroup GuiEvents libGuiEvents: The GUI Events display plugin */
22 /*\@{*/
23
24 /*! \file GuiEvents.c
25 * \brief Graphical plugin for showing events.
26 *
27 * This plugin lists all the events contained in the current time interval
28 * in a list.
29 *
30 * This plugin adds a Events Viewer functionnality to Linux TraceToolkit
31 * GUI when this plugin is loaded. The init and destroy functions add the
32 * viewer's insertion menu item and toolbar icon by calling viewer.h's
33 * API functions. Then, when a viewer's object is created, the constructor
34 * creates ans register through API functions what is needed to interact
35 * with the lttvwindow.
36 *
37 * Authors : Mathieu Desnoyers and XangXiu Yang, June to December 2003
38 * Inspired from original LTT, made by Karim Yaghmour
39 *
40 * Mostly rewritten by Mathieu Desnoyers, August 2005.
41 */
42
43 #ifdef HAVE_CONFIG_H
44 #include <config.h>
45 #endif
46
47 #include <math.h>
48
49 #include <glib.h>
50 #include <gtk/gtk.h>
51 #include <gdk/gdk.h>
52 #include <gdk/gdkx.h>
53 #include <string.h>
54
55 #include <ltt/ltt.h>
56 #include <ltt/event.h>
57 #include <ltt/type.h>
58 #include <ltt/trace.h>
59 #include <ltt/facility.h>
60 #include <lttv/module.h>
61 #include <lttv/hook.h>
62 #include <lttv/tracecontext.h>
63 #include <lttv/state.h>
64 #include <lttv/filter.h>
65 #include <lttv/print.h>
66 #include <lttvwindow/lttvwindow.h>
67 #include <lttvwindow/lttvwindowtraces.h>
68 #include <lttvwindow/lttv_plugin_tab.h>
69
70 #include "hGuiEventsInsert.xpm"
71
72 #define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format)
73
74 #ifndef g_debug
75 #define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format)
76 #endif
77
78 #define abs(a) (((a)<0)?(-a):(a))
79 #define max(a,b) ((a)>(b)?(a):(b))
80 #define min(a,b) ((a)<(b)?(a):(b))
81
82 /** Array containing instanced objects. Used when module is unloaded */
83 static GSList *g_event_viewer_data_list = NULL ;
84
85 typedef enum _ScrollDirection{
86 SCROLL_STEP_UP,
87 SCROLL_STEP_DOWN,
88 SCROLL_PAGE_UP,
89 SCROLL_PAGE_DOWN,
90 SCROLL_JUMP,
91 SCROLL_NONE
92 } ScrollDirection;
93
94 typedef struct _EventViewerData {
95
96 Tab * tab;
97 LttvPluginTab *ptab;
98 LttvHooks * event_hooks;
99
100 /* previous value is used to determine if it is a page up/down or
101 * step up/down, in which case we move of a certain amount of events (one or
102 * the number of events shown on the screen) instead of changing begin time.
103 */
104 double previous_value;
105
106 //scroll window containing Tree View
107 GtkWidget * scroll_win;
108
109 /* Model containing list data */
110 GtkListStore *store_m;
111
112 GPtrArray *pos; /* Array of LttvTracesetContextPosition * */
113
114 GtkWidget *top_widget;
115 GtkWidget *hbox_v;
116 /* Widget to display the data in a columned list */
117 GtkWidget *tree_v;
118 GtkAdjustment *vtree_adjust_c ;
119 GtkWidget *button; /* a button of the header, used to get the header_height */
120 gint header_height;
121
122 /* Vertical scrollbar and its adjustment */
123 GtkWidget *vscroll_vc;
124 GtkAdjustment *vadjust_c;
125
126 /* Selection handler */
127 GtkTreeSelection *select_c;
128
129 gint num_visible_events;
130
131 LttvTracesetContextPosition *currently_selected_position;
132 gboolean update_cursor; /* Speed optimisation : do not update cursor when
133 unnecessary */
134 gboolean report_position; /* do not report position when in current_time
135 update */
136
137 LttvTracesetContextPosition *first_event; /* Time of the first event shown */
138 LttvTracesetContextPosition *last_event; /* Time of the first event shown */
139
140 LttvTracesetContextPosition *current_time_get_first;
141
142 LttvFilter *main_win_filter;
143
144 gint background_info_waiting;
145
146 guint32 last_tree_update_time; /* To filter out repeat keys */
147
148 guint num_events; /* Number of events processed */
149
150 } EventViewerData ;
151
152 /** hook functions for update time interval, current time ... */
153 gboolean update_current_time(void * hook_data, void * call_data);
154 gboolean update_current_position(void * hook_data, void * call_data);
155 //gboolean show_event_detail(void * hook_data, void * call_data);
156 gboolean traceset_changed(void * hook_data, void * call_data);
157 gboolean filter_changed(void * hook_data, void * call_data);
158
159 static void request_background_data(EventViewerData *event_viewer_data);
160
161 //! Event Viewer's constructor hook
162 GtkWidget *h_gui_events(LttvPlugin *plugin);
163 //! Event Viewer's constructor
164 EventViewerData *gui_events(LttvPluginTab *ptab);
165 //! Event Viewer's destructor
166 void gui_events_destructor(EventViewerData *event_viewer_data);
167 void gui_events_free(EventViewerData *event_viewer_data);
168
169 static gboolean
170 header_size_allocate(GtkWidget *widget,
171 GtkAllocation *allocation,
172 gpointer user_data);
173
174 void tree_v_set_cursor(EventViewerData *event_viewer_data);
175 void tree_v_get_cursor(EventViewerData *event_viewer_data);
176
177 /* Prototype for selection handler callback */
178 static void tree_selection_changed_cb (GtkTreeSelection *selection,
179 gpointer data);
180 static void v_scroll_cb (GtkAdjustment *adjustment, gpointer data);
181 static void tree_v_size_allocate_cb (GtkWidget *widget, GtkAllocation *alloc,
182 gpointer data);
183 static void tree_v_size_request_cb (GtkWidget *widget,
184 GtkRequisition *requisition, gpointer data);
185 static void tree_v_cursor_changed_cb (GtkWidget *widget, gpointer data);
186 static void tree_v_move_cursor_cb (GtkWidget *widget, GtkMovementStep arg1,
187 gint arg2, gpointer data);
188 static gboolean tree_v_scroll_handler (GtkWidget *widget, GdkEventScroll *event, gpointer data);
189 static gboolean key_handler(GtkWidget *widget, GdkEventKey *event,
190 gpointer user_data);
191
192 static gint redraw_notify(void *hook_data, void *call_data);
193
194 static void get_events(double time, EventViewerData *event_viewer_data);
195
196 int event_hook(void *hook_data, void *call_data);
197
198 /* Enumeration of the columns */
199 enum
200 {
201 TRACE_NAME_COLUMN,
202 TRACEFILE_NAME_COLUMN,
203 CPUID_COLUMN,
204 EVENT_COLUMN,
205 FACILITY_COLUMN,
206 TIME_S_COLUMN,
207 TIME_NS_COLUMN,
208 PID_COLUMN,
209 EVENT_DESCR_COLUMN,
210 POSITION_COLUMN,
211 N_COLUMNS
212 };
213
214 /**
215 * Event Viewer's constructor hook
216 *
217 * This constructor is given as a parameter to the menuitem and toolbar button
218 * registration. It creates the list.
219 * @param parent_window A pointer to the parent window.
220 * @return The widget created.
221 */
222 GtkWidget *
223 h_gui_events(LttvPlugin *plugin)
224 {
225 LttvPluginTab *ptab = LTTV_PLUGIN_TAB(plugin);
226 EventViewerData* event_viewer_data = gui_events(ptab) ;
227 if(event_viewer_data)
228 return event_viewer_data->top_widget;
229 else return NULL;
230
231 }
232
233 /**
234 * Event Viewer's constructor
235 *
236 * This constructor is used to create EventViewerData data structure.
237 * @return The Event viewer data created.
238 */
239 EventViewerData *
240 gui_events(LttvPluginTab *ptab)
241 {
242 LttTime end;
243 GtkTreeViewColumn *column;
244 GtkCellRenderer *renderer;
245 EventViewerData* event_viewer_data = g_new(EventViewerData,1) ;
246 Tab *tab = ptab->tab;
247 event_viewer_data->tab = tab;
248 event_viewer_data->ptab = ptab;
249
250 LttvTracesetContext * tsc =
251 lttvwindow_get_traceset_context(event_viewer_data->tab);
252
253
254 event_viewer_data->event_hooks = lttv_hooks_new();
255 lttv_hooks_add(event_viewer_data->event_hooks,
256 event_hook,
257 event_viewer_data,
258 LTTV_PRIO_DEFAULT);
259
260 lttvwindow_register_current_time_notify(tab,
261 update_current_time,event_viewer_data);
262 lttvwindow_register_current_position_notify(tab,
263 update_current_position,event_viewer_data);
264 lttvwindow_register_traceset_notify(tab,
265 traceset_changed,event_viewer_data);
266 lttvwindow_register_filter_notify(tab,
267 filter_changed, event_viewer_data);
268 lttvwindow_register_redraw_notify(tab,
269 redraw_notify, event_viewer_data);
270
271
272 event_viewer_data->scroll_win = gtk_scrolled_window_new (NULL, NULL);
273 gtk_widget_show (event_viewer_data->scroll_win);
274 gtk_scrolled_window_set_policy(
275 GTK_SCROLLED_WINDOW(event_viewer_data->scroll_win),
276 GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER);
277
278 event_viewer_data->currently_selected_position =
279 lttv_traceset_context_position_new(tsc);
280 event_viewer_data->first_event =
281 lttv_traceset_context_position_new(tsc);
282 event_viewer_data->last_event =
283 lttv_traceset_context_position_new(tsc);
284
285 event_viewer_data->main_win_filter = lttvwindow_get_filter(tab);
286
287 event_viewer_data->update_cursor = TRUE;
288 event_viewer_data->report_position = TRUE;
289
290 event_viewer_data->last_tree_update_time = 0;
291
292 /* Create a model for storing the data list */
293 event_viewer_data->store_m = gtk_list_store_new (
294 N_COLUMNS, /* Total number of columns */
295 G_TYPE_STRING, /* Trace name */
296 G_TYPE_STRING, /* Tracefile name */
297 G_TYPE_UINT, /* CPUID */
298 G_TYPE_STRING, /* Event */
299 G_TYPE_STRING, /* Facility */
300 G_TYPE_UINT, /* Time s */
301 G_TYPE_UINT, /* Time ns */
302 G_TYPE_INT, /* PID */
303 G_TYPE_STRING, /* Event's description */
304 G_TYPE_POINTER);/* Position (not shown) */
305
306 event_viewer_data->pos = g_ptr_array_sized_new(10);
307
308 /* Create the viewer widget for the columned list */
309 event_viewer_data->tree_v =
310 gtk_tree_view_new_with_model (GTK_TREE_MODEL (event_viewer_data->store_m));
311
312 g_signal_connect (G_OBJECT (event_viewer_data->tree_v), "size-allocate",
313 G_CALLBACK (tree_v_size_allocate_cb),
314 event_viewer_data);
315 g_signal_connect (G_OBJECT (event_viewer_data->tree_v), "size-request",
316 G_CALLBACK (tree_v_size_request_cb),
317 event_viewer_data);
318
319 g_signal_connect (G_OBJECT (event_viewer_data->tree_v), "cursor-changed",
320 G_CALLBACK (tree_v_cursor_changed_cb),
321 event_viewer_data);
322
323 g_signal_connect (G_OBJECT (event_viewer_data->tree_v), "move-cursor",
324 G_CALLBACK (tree_v_move_cursor_cb),
325 event_viewer_data);
326
327 g_signal_connect (G_OBJECT(event_viewer_data->tree_v), "key-press-event",
328 G_CALLBACK(key_handler),
329 event_viewer_data);
330
331 g_signal_connect (G_OBJECT(event_viewer_data->tree_v), "scroll-event",
332 G_CALLBACK(tree_v_scroll_handler),
333 event_viewer_data);
334
335 // Use on each column!
336 //gtk_tree_view_column_set_sizing(event_viewer_data->tree_v,
337 //GTK_TREE_VIEW_COLUMN_FIXED);
338
339 /* The view now holds a reference. We can get rid of our own
340 * reference */
341 g_object_unref (G_OBJECT (event_viewer_data->store_m));
342
343
344 /* Create a column, associating the "text" attribute of the
345 * cell_renderer to the first column of the model */
346 /* Columns alignment : 0.0 : Left 0.5 : Center 1.0 : Right */
347 renderer = gtk_cell_renderer_text_new ();
348 column = gtk_tree_view_column_new_with_attributes ("Trace",
349 renderer,
350 "text", TRACE_NAME_COLUMN,
351 NULL);
352 gtk_tree_view_column_set_alignment (column, 0.0);
353 gtk_tree_view_column_set_fixed_width (column, 120);
354 gtk_tree_view_append_column (GTK_TREE_VIEW (event_viewer_data->tree_v),
355 column);
356
357 event_viewer_data->button = column->button;
358
359 g_signal_connect (G_OBJECT(event_viewer_data->button),
360 "size-allocate",
361 G_CALLBACK(header_size_allocate),
362 (gpointer)event_viewer_data);
363
364
365
366 renderer = gtk_cell_renderer_text_new ();
367 column = gtk_tree_view_column_new_with_attributes ("Tracefile",
368 renderer,
369 "text", TRACEFILE_NAME_COLUMN,
370 NULL);
371 gtk_tree_view_column_set_alignment (column, 0.0);
372 gtk_tree_view_column_set_fixed_width (column, 120);
373 gtk_tree_view_append_column (GTK_TREE_VIEW (event_viewer_data->tree_v),
374 column);
375
376
377 renderer = gtk_cell_renderer_text_new ();
378 column = gtk_tree_view_column_new_with_attributes ("CPUID",
379 renderer,
380 "text", CPUID_COLUMN,
381 NULL);
382 gtk_tree_view_column_set_alignment (column, 0.0);
383 gtk_tree_view_column_set_fixed_width (column, 45);
384 gtk_tree_view_append_column (GTK_TREE_VIEW (event_viewer_data->tree_v),
385 column);
386
387 renderer = gtk_cell_renderer_text_new ();
388 column = gtk_tree_view_column_new_with_attributes ("Event",
389 renderer,
390 "text", EVENT_COLUMN,
391 NULL);
392 gtk_tree_view_column_set_alignment (column, 0.0);
393 gtk_tree_view_column_set_fixed_width (column, 120);
394 gtk_tree_view_append_column (GTK_TREE_VIEW (event_viewer_data->tree_v),
395 column);
396
397 renderer = gtk_cell_renderer_text_new ();
398 column = gtk_tree_view_column_new_with_attributes ("Facility",
399 renderer,
400 "text", FACILITY_COLUMN,
401 NULL);
402 gtk_tree_view_column_set_alignment (column, 0.0);
403 gtk_tree_view_column_set_fixed_width (column, 120);
404 gtk_tree_view_append_column (GTK_TREE_VIEW (event_viewer_data->tree_v),
405 column);
406
407 renderer = gtk_cell_renderer_text_new ();
408 column = gtk_tree_view_column_new_with_attributes ("Time (s)",
409 renderer,
410 "text", TIME_S_COLUMN,
411 NULL);
412 gtk_tree_view_column_set_alignment (column, 1.0);
413 gtk_tree_view_column_set_fixed_width (column, 120);
414 gtk_tree_view_append_column (GTK_TREE_VIEW (event_viewer_data->tree_v),
415 column);
416
417 renderer = gtk_cell_renderer_text_new ();
418 column = gtk_tree_view_column_new_with_attributes ("Time (ns)",
419 renderer,
420 "text", TIME_NS_COLUMN,
421 NULL);
422 gtk_tree_view_column_set_alignment (column, 1.0);
423 gtk_tree_view_column_set_fixed_width (column, 120);
424 gtk_tree_view_append_column (GTK_TREE_VIEW (event_viewer_data->tree_v),
425 column);
426
427
428 renderer = gtk_cell_renderer_text_new ();
429 column = gtk_tree_view_column_new_with_attributes ("PID",
430 renderer,
431 "text", PID_COLUMN,
432 NULL);
433 gtk_tree_view_column_set_alignment (column, 1.0);
434 gtk_tree_view_column_set_fixed_width (column, 45);
435 gtk_tree_view_append_column (GTK_TREE_VIEW (event_viewer_data->tree_v),
436 column);
437
438 renderer = gtk_cell_renderer_text_new ();
439 column = gtk_tree_view_column_new_with_attributes ("Event Description",
440 renderer,
441 "text", EVENT_DESCR_COLUMN,
442 NULL);
443 gtk_tree_view_column_set_alignment (column, 0.0);
444 gtk_tree_view_append_column (GTK_TREE_VIEW (event_viewer_data->tree_v),
445 column);
446
447
448 /* Setup the selection handler */
449 event_viewer_data->select_c =
450 gtk_tree_view_get_selection (GTK_TREE_VIEW (event_viewer_data->tree_v));
451 gtk_tree_selection_set_mode (event_viewer_data->select_c,
452 GTK_SELECTION_SINGLE);
453 g_signal_connect (G_OBJECT (event_viewer_data->select_c), "changed",
454 G_CALLBACK (tree_selection_changed_cb),
455 event_viewer_data);
456
457 gtk_container_add (GTK_CONTAINER (event_viewer_data->scroll_win),
458 event_viewer_data->tree_v);
459
460 event_viewer_data->hbox_v = gtk_hbox_new(0, 0);
461 event_viewer_data->top_widget = event_viewer_data->hbox_v;
462 gtk_box_pack_start(GTK_BOX(event_viewer_data->hbox_v),
463 event_viewer_data->scroll_win, TRUE, TRUE, 0);
464
465 gtk_container_set_border_width(GTK_CONTAINER(event_viewer_data->hbox_v), 1);
466
467 /* Create vertical scrollbar and pack it */
468 event_viewer_data->vscroll_vc = gtk_vscrollbar_new(NULL);
469 gtk_range_set_update_policy (GTK_RANGE(event_viewer_data->vscroll_vc),
470 GTK_UPDATE_CONTINUOUS);
471 // Changed by MD : more user friendly :)
472 //GTK_UPDATE_DISCONTINUOUS);
473 gtk_box_pack_start(GTK_BOX(event_viewer_data->hbox_v),
474 event_viewer_data->vscroll_vc, FALSE, TRUE, 0);
475
476 /* Get the vertical scrollbar's adjustment */
477 event_viewer_data->vadjust_c =
478 gtk_range_get_adjustment(GTK_RANGE(event_viewer_data->vscroll_vc));
479 event_viewer_data->vtree_adjust_c = gtk_tree_view_get_vadjustment(
480 GTK_TREE_VIEW (event_viewer_data->tree_v));
481
482 g_signal_connect (G_OBJECT (event_viewer_data->vadjust_c), "value-changed",
483 G_CALLBACK (v_scroll_cb),
484 event_viewer_data);
485 /* Set the upper bound to the last event number */
486 event_viewer_data->previous_value = 0;
487 event_viewer_data->vadjust_c->lower = 0.0;
488 //event_viewer_data->vadjust_c->upper = event_viewer_data->number_of_events;
489 event_viewer_data->vadjust_c->value = 0.0;
490 event_viewer_data->vadjust_c->step_increment = 1.0;
491 event_viewer_data->vadjust_c->page_increment = 2.0;
492 // event_viewer_data->vtree_adjust_c->upper;
493 event_viewer_data->vadjust_c->page_size = 2.0;
494 // event_viewer_data->vtree_adjust_c->upper;
495 /* Raw event trace */
496 gtk_widget_show(event_viewer_data->hbox_v);
497 gtk_widget_show(event_viewer_data->tree_v);
498 gtk_widget_show(event_viewer_data->vscroll_vc);
499
500 /* Add the object's information to the module's array */
501 g_event_viewer_data_list = g_slist_append(g_event_viewer_data_list,
502 event_viewer_data);
503
504 event_viewer_data->num_visible_events = 1;
505
506 //get the life span of the traceset and set the upper of the scroll bar
507
508 TimeInterval time_span = tsc->time_span;
509 end = ltt_time_sub(time_span.end_time, time_span.start_time);
510
511 event_viewer_data->vadjust_c->upper =
512 ltt_time_to_double(end);
513
514 /* Set the Selected Event */
515 // tree_v_set_cursor(event_viewer_data);
516
517 // event_viewer_data->current_time_updated = FALSE;
518 //
519 g_object_set_data_full(
520 G_OBJECT(event_viewer_data->hbox_v),
521 "event_viewer_data",
522 event_viewer_data,
523 (GDestroyNotify)gui_events_free);
524
525 event_viewer_data->background_info_waiting = 0;
526
527 request_background_data(event_viewer_data);
528
529
530 return event_viewer_data;
531 }
532
533
534
535 static gint background_ready(void *hook_data, void *call_data)
536 {
537 EventViewerData *event_viewer_data = (EventViewerData *)hook_data;
538 LttvTrace *trace = (LttvTrace*)call_data;
539
540 event_viewer_data->background_info_waiting--;
541
542 if(event_viewer_data->background_info_waiting == 0) {
543 g_message("event viewer : background computation data ready.");
544
545 redraw_notify(event_viewer_data, NULL);
546 }
547
548 return 0;
549 }
550
551
552 static void request_background_data(EventViewerData *event_viewer_data)
553 {
554 LttvTracesetContext * tsc =
555 lttvwindow_get_traceset_context(event_viewer_data->tab);
556 gint num_traces = lttv_traceset_number(tsc->ts);
557 gint i;
558 LttvTrace *trace;
559 LttvTraceState *tstate;
560
561 LttvHooks *background_ready_hook =
562 lttv_hooks_new();
563 lttv_hooks_add(background_ready_hook, background_ready, event_viewer_data,
564 LTTV_PRIO_DEFAULT);
565 event_viewer_data->background_info_waiting = 0;
566
567 for(i=0;i<num_traces;i++) {
568 trace = lttv_traceset_get(tsc->ts, i);
569 tstate = LTTV_TRACE_STATE(tsc->traces[i]);
570
571 if(lttvwindowtraces_get_ready(g_quark_from_string("state"),trace)==FALSE
572 && !tstate->has_precomputed_states) {
573
574 if(lttvwindowtraces_get_in_progress(g_quark_from_string("state"),
575 trace) == FALSE) {
576 /* We first remove requests that could have been done for the same
577 * information. Happens when two viewers ask for it before servicing
578 * starts.
579 */
580 if(!lttvwindowtraces_background_request_find(trace, "state"))
581 lttvwindowtraces_background_request_queue(
582 main_window_get_widget(event_viewer_data->tab), trace, "state");
583 lttvwindowtraces_background_notify_queue(event_viewer_data,
584 trace,
585 ltt_time_infinite,
586 NULL,
587 background_ready_hook);
588 event_viewer_data->background_info_waiting++;
589 } else { /* in progress */
590
591 lttvwindowtraces_background_notify_current(event_viewer_data,
592 trace,
593 ltt_time_infinite,
594 NULL,
595 background_ready_hook);
596 event_viewer_data->background_info_waiting++;
597 }
598 } else {
599 /* Data ready. By its nature, this viewer doesn't need to have
600 * its data ready hook called htere, because a background
601 * request is always linked with a redraw.
602 */
603 }
604
605 }
606
607 lttv_hooks_destroy(background_ready_hook);
608
609 }
610
611 static gboolean
612 header_size_allocate(GtkWidget *widget,
613 GtkAllocation *allocation,
614 gpointer user_data)
615 {
616 EventViewerData *event_viewer_data = (EventViewerData*)user_data;
617
618 event_viewer_data->header_height = allocation->height;
619
620 return 0;
621 }
622
623
624 void tree_v_set_cursor(EventViewerData *event_viewer_data)
625 {
626 GtkTreePath *path;
627
628 g_debug("set cursor cb");
629
630 #if 0
631 if(event_viewer_data->currently_selected_event != -1)
632 {
633 path = gtk_tree_path_new_from_indices(
634 event_viewer_data->currently_selected_event,
635 -1);
636
637 gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v),
638 path, NULL, FALSE);
639 gtk_tree_path_free(path);
640 }
641 #endif //0
642 }
643
644 void tree_v_get_cursor(EventViewerData *event_viewer_data)
645 {
646 GtkTreePath *path;
647 gint *indices;
648
649 g_debug("get cursor cb");
650
651
652 #if 0
653 gtk_tree_view_get_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v),
654 &path, NULL);
655 indices = gtk_tree_path_get_indices(path);
656
657 if(indices != NULL)
658 event_viewer_data->currently_selected_event = indices[0];
659 else
660 event_viewer_data->currently_selected_event = -1;
661
662 gtk_tree_path_free(path);
663 #endif //0
664 }
665
666 /* Filter out the key repeats that come too fast */
667 static gboolean key_handler(GtkWidget *widget, GdkEventKey *event,
668 gpointer user_data)
669 {
670 EventViewerData *evd = (EventViewerData *)user_data;
671
672 g_debug("event time : %u , last time : %u", event->time,
673 evd->last_tree_update_time);
674
675 if(guint32_before(event->time, evd->last_tree_update_time))
676 return TRUE;
677 else
678 return FALSE;
679 }
680
681 void tree_v_move_cursor_cb (GtkWidget *widget,
682 GtkMovementStep arg1,
683 gint arg2,
684 gpointer data)
685 {
686 GtkTreePath *path; // = gtk_tree_path_new();
687 gint *indices;
688 gdouble value;
689 EventViewerData *event_viewer_data = (EventViewerData*)data;
690
691 g_debug("move cursor cb");
692 //gtk_tree_view_get_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v),
693 // &path, NULL);
694 //if(path == NULL)
695 //{
696 /* No prior cursor, put it at beginning of page
697 * and let the execution do */
698 // path = gtk_tree_path_new_from_indices(0, -1);
699 // gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v),
700 // path, NULL, FALSE);
701 //}
702
703 //indices = gtk_tree_path_get_indices(path);
704
705 //value = gtk_adjustment_get_value(event_viewer_data->vadjust_c);
706
707 /* If events request pending, do nothing*/
708 if(lttvwindow_events_request_pending(event_viewer_data->tab)) return;
709
710 /* If no prior position... */
711 #if 0
712 if(ltt_time_compare(
713 lttv_traceset_context_position_get_time(
714 event_viewer_data->currently_selected_position),
715 ltt_time_infinite) == 0) {
716
717 path = gtk_tree_path_new_from_indices(0, -1);
718 gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v),
719 path, NULL, FALSE);
720
721 gtk_tree_path_free(path);
722 return;
723
724 }
725 #endif //0
726
727 g_debug("tree view move cursor : arg1 is %u and arg2 is %d",
728 (guint)arg1, arg2);
729
730 switch(arg1) {
731 case GTK_MOVEMENT_DISPLAY_LINES:
732 if(arg2 == 1) {
733 /* Move one line down */
734 if(event_viewer_data->pos->len > 0) {
735 LttvTracesetContextPosition *end_pos =
736 (LttvTracesetContextPosition*)g_ptr_array_index(
737 event_viewer_data->pos,
738 event_viewer_data->pos->len-1);
739 if(lttv_traceset_context_pos_pos_compare(end_pos,
740 event_viewer_data->currently_selected_position) == 0) {
741 /* Must get down one event and select the last one */
742 gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(
743 GTK_TREE_VIEW(event_viewer_data->tree_v)));
744 event_viewer_data->update_cursor = FALSE;
745 gtk_adjustment_set_value(event_viewer_data->vadjust_c,
746 gtk_adjustment_get_value(event_viewer_data->vadjust_c) + 1);
747 event_viewer_data->update_cursor = TRUE;
748 if(event_viewer_data->pos->len > 0) {
749 path = gtk_tree_path_new_from_indices(
750 max(0, event_viewer_data->pos->len - 1), -1);
751 if(path) {
752 gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v),
753 path, NULL, FALSE);
754 gtk_tree_path_free(path);
755 }
756 }
757 }
758 } else {
759 /* Must get down one event and select the last one */
760 gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(
761 GTK_TREE_VIEW(event_viewer_data->tree_v)));
762 event_viewer_data->update_cursor = FALSE;
763 gtk_adjustment_set_value(event_viewer_data->vadjust_c,
764 gtk_adjustment_get_value(event_viewer_data->vadjust_c) + 1);
765 event_viewer_data->update_cursor = TRUE;
766 if(event_viewer_data->pos->len > 0) {
767 path = gtk_tree_path_new_from_indices(
768 max(0, event_viewer_data->pos->len - 1), -1);
769 if(path) {
770 gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v),
771 path, NULL, FALSE);
772 gtk_tree_path_free(path);
773 }
774 }
775 }
776
777 } else {
778 if(event_viewer_data->pos->len > 0) {
779 /* Move one line up */
780 LttvTracesetContextPosition *begin_pos =
781 (LttvTracesetContextPosition*)g_ptr_array_index(
782 event_viewer_data->pos,
783 0);
784 if(lttv_traceset_context_pos_pos_compare(begin_pos,
785 event_viewer_data->currently_selected_position) == 0) {
786 /* Must get up one event and select the first one */
787 gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(
788 GTK_TREE_VIEW(event_viewer_data->tree_v)));
789 event_viewer_data->update_cursor = FALSE;
790 gtk_adjustment_set_value(event_viewer_data->vadjust_c,
791 gtk_adjustment_get_value(event_viewer_data->vadjust_c) - 1);
792 event_viewer_data->update_cursor = TRUE;
793 if(event_viewer_data->pos->len > 0) {
794 path = gtk_tree_path_new_from_indices(
795 0, -1);
796 if(path) {
797 gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v),
798 path, NULL, FALSE);
799 gtk_tree_path_free(path);
800 }
801 }
802 }
803 } else {
804 /* Must get up one event and select the first one */
805 gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(
806 GTK_TREE_VIEW(event_viewer_data->tree_v)));
807 event_viewer_data->update_cursor = FALSE;
808 gtk_adjustment_set_value(event_viewer_data->vadjust_c,
809 gtk_adjustment_get_value(event_viewer_data->vadjust_c) - 1);
810 event_viewer_data->update_cursor = TRUE;
811 if(event_viewer_data->pos->len > 0) {
812 path = gtk_tree_path_new_from_indices(
813 0, -1);
814 if(path) {
815 gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v),
816 path, NULL, FALSE);
817 gtk_tree_path_free(path);
818 }
819 }
820 }
821 }
822 break;
823 case GTK_MOVEMENT_PAGES:
824 if(arg2 == 1) {
825 /* Move one page down */
826 if(event_viewer_data->pos->len > 0) {
827 LttvTracesetContextPosition *end_pos =
828 (LttvTracesetContextPosition*)g_ptr_array_index(
829 event_viewer_data->pos,
830 event_viewer_data->pos->len-1);
831 if(lttv_traceset_context_pos_pos_compare(end_pos,
832 event_viewer_data->currently_selected_position) == 0) {
833 /* Must get down one page and select the last one */
834 gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(
835 GTK_TREE_VIEW(event_viewer_data->tree_v)));
836 event_viewer_data->update_cursor = FALSE;
837 gtk_adjustment_set_value(event_viewer_data->vadjust_c,
838 gtk_adjustment_get_value(event_viewer_data->vadjust_c) + 2);
839 event_viewer_data->update_cursor = TRUE;
840 if(event_viewer_data->pos->len > 0) {
841 path = gtk_tree_path_new_from_indices(
842 event_viewer_data->pos->len - 1, -1);
843 if(path) {
844 gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v),
845 path, NULL, FALSE);
846 gtk_tree_path_free(path);
847 }
848 }
849 }
850 } else {
851 /* Must get down one page and select the last one */
852 gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(
853 GTK_TREE_VIEW(event_viewer_data->tree_v)));
854 event_viewer_data->update_cursor = FALSE;
855 gtk_adjustment_set_value(event_viewer_data->vadjust_c,
856 gtk_adjustment_get_value(event_viewer_data->vadjust_c) + 2);
857 event_viewer_data->update_cursor = TRUE;
858 if(event_viewer_data->pos->len > 0) {
859 path = gtk_tree_path_new_from_indices(
860 event_viewer_data->pos->len - 1, -1);
861 if(path) {
862 gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v),
863 path, NULL, FALSE);
864 gtk_tree_path_free(path);
865 }
866 }
867 }
868 } else {
869 /* Move one page up */
870 if(event_viewer_data->pos->len > 0) {
871 LttvTracesetContextPosition *begin_pos =
872 (LttvTracesetContextPosition*)g_ptr_array_index(
873 event_viewer_data->pos,
874 0);
875 if(lttv_traceset_context_pos_pos_compare(begin_pos,
876 event_viewer_data->currently_selected_position) == 0) {
877 /* Must get up one page and select the first one */
878 gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(
879 GTK_TREE_VIEW(event_viewer_data->tree_v)));
880 event_viewer_data->update_cursor = FALSE;
881 gtk_adjustment_set_value(event_viewer_data->vadjust_c,
882 gtk_adjustment_get_value(event_viewer_data->vadjust_c) - 2);
883 event_viewer_data->update_cursor = TRUE;
884 if(event_viewer_data->pos->len > 0) {
885 path = gtk_tree_path_new_from_indices(
886 0, -1);
887 if(path) {
888 gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v),
889 path, NULL, FALSE);
890 gtk_tree_path_free(path);
891 }
892 }
893 }
894 } else {
895 /* Must get up one page and select the first one */
896 gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(
897 GTK_TREE_VIEW(event_viewer_data->tree_v)));
898 event_viewer_data->update_cursor = FALSE;
899 gtk_adjustment_set_value(event_viewer_data->vadjust_c,
900 gtk_adjustment_get_value(event_viewer_data->vadjust_c) - 2);
901 event_viewer_data->update_cursor = TRUE;
902 if(event_viewer_data->pos->len > 0) {
903 path = gtk_tree_path_new_from_indices(
904 0, -1);
905 if(path) {
906 gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v),
907 path, NULL, FALSE);
908 gtk_tree_path_free(path);
909 }
910 }
911 }
912 }
913 break;
914 default:
915 break;
916 }
917
918 //gtk_tree_path_free(path);
919
920 #if 0
921 if(arg1 == GTK_MOVEMENT_DISPLAY_LINES)
922 {
923 /* Move one line */
924 if(arg2 == 1)
925 {
926 /* move one line down */
927 if(indices[0]) // Do we need an empty field here (before first)?
928 {
929 if(value + event_viewer_data->num_visible_events <=
930 event_viewer_data->number_of_events -1)
931 {
932 event_viewer_data->currently_selected_event += 1;
933 // gtk_adjustment_set_value(event_viewer_data->vadjust_c, value+1);
934 //gtk_tree_path_free(path);
935 //path = gtk_tree_path_new_from_indices(event_viewer_data->num_visible_events-1, -1);
936 //gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v), path, NULL, FALSE);
937 g_signal_stop_emission_by_name(G_OBJECT(widget), "move-cursor");
938 }
939 }
940 } else {
941 /* Move one line up */
942 if(indices[0] == 0)
943 {
944 if(value - 1 >= 0 )
945 {
946 event_viewer_data->currently_selected_event -= 1;
947 // gtk_adjustment_set_value(event_viewer_data->vadjust_c, value-1);
948 //gtk_tree_path_free(path);
949 //path = gtk_tree_path_new_from_indices(0, -1);
950 //gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v), path, NULL, FALSE);
951 g_signal_stop_emission_by_name(G_OBJECT(widget), "move-cursor");
952 }
953 }
954 }
955 }
956
957 if(arg1 == GTK_MOVEMENT_PAGES)
958 {
959 /* Move one page */
960 if(arg2 == 1)
961 {
962 if(event_viewer_data->num_visible_events == 1)
963 value += 1 ;
964 /* move one page down */
965 if(value + event_viewer_data->num_visible_events-1 <=
966 event_viewer_data->number_of_events )
967 {
968 event_viewer_data->currently_selected_event +=
969 event_viewer_data->num_visible_events-1;
970 // gtk_adjustment_set_value(event_viewer_data->vadjust_c,
971 // value+(event_viewer_data->num_visible_events-1));
972 //gtk_tree_path_free(path);
973 //path = gtk_tree_path_new_from_indices(0, -1);
974 //gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v), path, NULL, FALSE);
975 g_signal_stop_emission_by_name(G_OBJECT(widget), "move-cursor");
976 }
977 } else {
978 /* Move one page up */
979 if(event_viewer_data->num_visible_events == 1)
980 value -= 1 ;
981
982 if(indices[0] < event_viewer_data->num_visible_events - 2 )
983 {
984 if(value - (event_viewer_data->num_visible_events-1) >= 0)
985 {
986 event_viewer_data->currently_selected_event -=
987 event_viewer_data->num_visible_events-1;
988
989 // gtk_adjustment_set_value(event_viewer_data->vadjust_c,
990 // value-(event_viewer_data->num_visible_events-1));
991 //gtk_tree_path_free(path);
992 //path = gtk_tree_path_new_from_indices(0, -1);
993 //gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v), path, NULL, FALSE);
994 g_signal_stop_emission_by_name(G_OBJECT(widget), "move-cursor");
995
996 } else {
997 /* Go to first Event */
998 event_viewer_data->currently_selected_event == 0 ;
999 // gtk_adjustment_set_value(event_viewer_data->vadjust_c,
1000 // 0);
1001 //gtk_tree_path_free(path);
1002 //path = gtk_tree_path_new_from_indices(0, -1);
1003 //gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v), path, NULL, FALSE);
1004 g_signal_stop_emission_by_name(G_OBJECT(widget), "move-cursor");
1005
1006 }
1007 }
1008 }
1009 }
1010
1011 if(arg1 == GTK_MOVEMENT_BUFFER_ENDS)
1012 {
1013 /* Move to the ends of the buffer */
1014 if(arg2 == 1)
1015 {
1016 /* move end of buffer */
1017 event_viewer_data->currently_selected_event =
1018 event_viewer_data->number_of_events-1 ;
1019 // gtk_adjustment_set_value(event_viewer_data->vadjust_c,
1020 // event_viewer_data->number_of_events -
1021 // event_viewer_data->num_visible_events);
1022 //gtk_tree_path_free(path);
1023 //path = gtk_tree_path_new_from_indices(event_viewer_data->num_visible_events-1, -1);
1024 //gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v), path, NULL, FALSE);
1025 g_signal_stop_emission_by_name(G_OBJECT(widget), "move-cursor");
1026 } else {
1027 /* Move beginning of buffer */
1028 event_viewer_data->currently_selected_event = 0 ;
1029 // gtk_adjustment_set_value(event_viewer_data->vadjust_c, 0);
1030 //gtk_tree_path_free(path);
1031 //path = gtk_tree_path_new_from_indices(0, -1);
1032 //gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v), path, NULL, FALSE);
1033 g_signal_stop_emission_by_name(G_OBJECT(widget), "move-cursor");
1034 }
1035 }
1036 #endif //0
1037 }
1038
1039
1040 gboolean tree_v_scroll_handler (GtkWidget *widget, GdkEventScroll *event, gpointer data)
1041 {
1042 EventViewerData *event_viewer_data = (EventViewerData*) data;
1043 Tab *tab = event_viewer_data->tab;
1044
1045 switch(event->direction) {
1046 case GDK_SCROLL_UP:
1047 gtk_adjustment_set_value(event_viewer_data->vadjust_c,
1048 gtk_adjustment_get_value(event_viewer_data->vadjust_c) - 1);
1049 break;
1050 case GDK_SCROLL_DOWN:
1051 gtk_adjustment_set_value(event_viewer_data->vadjust_c,
1052 gtk_adjustment_get_value(event_viewer_data->vadjust_c) + 1);
1053 break;
1054 default:
1055 g_error("Only scroll up and down expected");
1056 }
1057 return TRUE;
1058 }
1059
1060 void tree_v_cursor_changed_cb (GtkWidget *widget, gpointer data)
1061 {
1062 EventViewerData *event_viewer_data = (EventViewerData*) data;
1063 Tab *tab = event_viewer_data->tab;
1064 GtkTreeIter iter;
1065 GtkTreeModel* model = GTK_TREE_MODEL(event_viewer_data->store_m);
1066 GtkTreePath *path;
1067 LttvTracesetContextPosition *pos;
1068
1069 g_debug("cursor changed cb");
1070
1071 /* On cursor change, modify the currently selected event by calling
1072 * the right API function */
1073 if(event_viewer_data->report_position) {
1074 if(event_viewer_data->pos->len > 0) {
1075 gtk_tree_view_get_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v),
1076 &path, NULL);
1077 if(path) {
1078 if(gtk_tree_model_get_iter(model,&iter,path)){
1079 gtk_tree_model_get(model, &iter, POSITION_COLUMN, &pos, -1);
1080
1081 if(lttv_traceset_context_pos_pos_compare(pos,
1082 event_viewer_data->currently_selected_position) != 0)
1083 lttvwindow_report_current_position(tab, pos);
1084 }else{
1085 g_warning("Can not get iter\n");
1086 }
1087 gtk_tree_path_free(path);
1088 }
1089 }
1090 }
1091 }
1092
1093
1094 static void tree_selection_changed_cb (GtkTreeSelection *selection,
1095 gpointer data)
1096 {
1097 g_debug("tree sel changed cb");
1098 EventViewerData *event_viewer_data = (EventViewerData*) data;
1099 #if 0
1100 /* Set the cursor to currently selected event */
1101 GtkTreeModel* model = GTK_TREE_MODEL(event_viewer_data->store_m);
1102 GtkTreeIter iter;
1103 LttvTracesetContextPosition *pos;
1104 guint i;
1105 GtkTreePath *tree_path;
1106
1107 for(i=0;i<event_viewer_data->num_visible_events;i++) {
1108 tree_path = gtk_tree_path_new_from_indices(
1109 i,
1110 -1);
1111 if(gtk_tree_model_get_iter(model,&iter,tree_path)){
1112 gtk_tree_model_get(model, &iter, POSITION_COLUMN, &pos, -1);
1113
1114 if(lttv_traceset_context_pos_pos_compare(pos,
1115 event_viewer_data->currently_selected_position) == 0) {
1116 /* Match! */
1117 gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v),
1118 tree_path, NULL, FALSE);
1119 break;
1120 }
1121
1122 }else{
1123 g_warning("Can not get iter\n");
1124 }
1125 gtk_tree_path_free(tree_path);
1126 }
1127 #endif //0
1128 }
1129
1130 #if 0
1131 static gint key_snooper(GtkWidget *grab_widget, GdkEventKey *event,
1132 gpointer func_data)
1133 {
1134 return TRUE;
1135 }
1136 #endif //0
1137
1138 /* This callback may be recalled after a step up/down, but we don't want to lose
1139 * the exact position : what we do is that we only set the value if it has
1140 * changed : a step up/down that doesn't change the time value of the first
1141 * event won't trigger a scrollbar change. */
1142
1143 void v_scroll_cb (GtkAdjustment *adjustment, gpointer data)
1144 {
1145 EventViewerData *event_viewer_data = (EventViewerData*)data;
1146 LttvTracesetStats *tss =
1147 lttvwindow_get_traceset_stats(event_viewer_data->tab);
1148 LttvTracesetContext *tsc = (LttvTracesetContext*)tss;
1149 g_debug("SCROLL begin");
1150 g_debug("SCROLL values : %g , %g, %g",
1151 adjustment->value, event_viewer_data->previous_value,
1152 (adjustment->value - event_viewer_data->previous_value));
1153
1154 LttTime new_time_off = ltt_time_from_double(adjustment->value);
1155 LttTime old_time_off = ltt_time_from_double(event_viewer_data->previous_value);
1156 g_debug("SCROLL time values %lu.%lu, %lu.%lu", new_time_off.tv_sec,
1157 new_time_off.tv_nsec, old_time_off.tv_sec, old_time_off.tv_nsec);
1158 /* If same value : nothing to update */
1159 if(ltt_time_compare(new_time_off, old_time_off) == 0)
1160 return;
1161
1162 //LttTime old_time = event_viewer_data->first_event;
1163
1164
1165 //gint snoop = gtk_key_snooper_install(key_snooper, NULL);
1166
1167 get_events(adjustment->value, event_viewer_data);
1168
1169 //gtk_key_snooper_remove(snoop);
1170 #if 0
1171 LttTime time = ltt_time_sub(event_viewer_data->first_event,
1172 tsc->time_span.start_time);
1173 double value = ltt_time_to_double(time);
1174 gtk_adjustment_set_value(event_viewer_data->vadjust_c, value);
1175
1176 if(event_viewer_data->currently_selected_event != -1) {
1177
1178 tree_path = gtk_tree_path_new_from_indices(
1179 event_viewer_data->currently_selected_event,
1180 -1);
1181
1182 // gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v), tree_path,
1183 // NULL, FALSE);
1184 gtk_tree_path_free(tree_path);
1185 }
1186 #endif //0
1187 g_debug("SCROLL end");
1188 }
1189
1190 static __inline gint get_cell_height(GtkTreeView *TreeView)
1191 {
1192 gint height;
1193 GtkTreeViewColumn *column = gtk_tree_view_get_column(TreeView, 0);
1194
1195 gtk_tree_view_column_cell_get_size(column, NULL, NULL, NULL, NULL, &height);
1196
1197 gint vertical_separator;
1198 gtk_widget_style_get (GTK_WIDGET (TreeView),
1199 "vertical-separator", &vertical_separator,
1200 NULL);
1201
1202 height += vertical_separator;
1203
1204 return height;
1205 }
1206
1207 void tree_v_size_allocate_cb (GtkWidget *widget, GtkAllocation *alloc, gpointer data)
1208 {
1209 EventViewerData *event_viewer_data = (EventViewerData*)data;
1210 gint cell_height = get_cell_height(GTK_TREE_VIEW(event_viewer_data->tree_v));
1211 gint last_num_visible_events = event_viewer_data->num_visible_events;
1212 gdouble exact_num_visible;
1213
1214 exact_num_visible = ( alloc->height -
1215 event_viewer_data->header_height )
1216 / (double)cell_height ;
1217
1218 event_viewer_data->num_visible_events = ceil(exact_num_visible) ;
1219
1220 /*
1221 event_viewer_data->vadjust_c->page_increment =
1222 floor(exact_num_visible);
1223 event_viewer_data->vadjust_c->page_size =
1224 floor(exact_num_visible);
1225 */
1226
1227 g_debug("size allocate : last_num_visible_events : %d,\
1228 num_visible_events : %d",
1229 last_num_visible_events,
1230 event_viewer_data->num_visible_events);
1231 if(event_viewer_data->num_visible_events != last_num_visible_events)
1232 {
1233 get_events(event_viewer_data->vadjust_c->value, event_viewer_data);
1234 }
1235
1236
1237 }
1238
1239 void tree_v_size_request_cb (GtkWidget *widget, GtkRequisition *requisition, gpointer data)
1240 {
1241 gint h;
1242 EventViewerData *event_viewer_data = (EventViewerData*)data;
1243 gint cell_height = get_cell_height(GTK_TREE_VIEW(event_viewer_data->tree_v));
1244
1245 h = cell_height + event_viewer_data->header_height;
1246 requisition->height = h;
1247
1248 }
1249
1250 #if 0
1251 gboolean show_event_detail(void * hook_data, void * call_data)
1252 {
1253 EventViewerData *event_viewer_data = (EventViewerData*) hook_data;
1254 LttvTracesetContext * tsc = lttvwindow_get_traceset_context(event_viewer_data->tab);
1255
1256 if(event_viewer_data->event_fields_queue_tmp->length == 0 &&
1257 event_viewer_data->event_fields_queue->length == 0){
1258 event_viewer_data->shown = FALSE;
1259 return FALSE;
1260 }
1261
1262 if(event_viewer_data->shown == FALSE){
1263 event_viewer_data->shown = TRUE;
1264 update_raw_data_array(event_viewer_data,
1265 event_viewer_data->event_fields_queue_tmp->length);
1266
1267 get_data(event_viewer_data->vadjust_c->value,
1268 event_viewer_data->num_visible_events,
1269 event_viewer_data);
1270
1271 remove_context_hooks(event_viewer_data,tsc);
1272 }
1273
1274 return FALSE;
1275 }
1276 #endif //0
1277
1278 static gboolean events_check_handler(guint count, gboolean *stop_flag)
1279 {
1280 if(count % CHECK_GDK_INTERVAL == 0) {
1281 gtk_main_iteration_do(FALSE);
1282 if(*stop_flag)
1283 return TRUE;
1284 else
1285 return FALSE;
1286 } else return FALSE;
1287 }
1288
1289 static void get_events(double new_value, EventViewerData *event_viewer_data)
1290 {
1291 GtkTreePath *tree_path;
1292 LttvTracesetStats *tss =
1293 lttvwindow_get_traceset_stats(event_viewer_data->tab);
1294 LttvTracesetContext *tsc = (LttvTracesetContext*)tss;
1295 guint i;
1296 gboolean seek_by_time;
1297
1298 if(lttvwindow_preempt_count > 0) return;
1299
1300 double value = new_value - event_viewer_data->previous_value;
1301
1302 /* Set stop button status for foreground processing */
1303 event_viewer_data->tab->stop_foreground = FALSE;
1304 lttvwindow_events_request_disable();
1305
1306 /* See where we have to scroll... */
1307 ScrollDirection direction;
1308 gint relative_position;
1309
1310 if(value < -0.8) {
1311 if(value >= -1.0) direction = SCROLL_STEP_UP;
1312 else {
1313 if(value >= -2.0) direction = SCROLL_PAGE_UP;
1314 else direction = SCROLL_JUMP;
1315 }
1316 } else if(value > 0.8) {
1317 if(value <= 1.0) direction = SCROLL_STEP_DOWN;
1318 else {
1319 if(value <= 2.0) direction = SCROLL_PAGE_DOWN;
1320 else direction = SCROLL_JUMP;
1321 }
1322 } else direction = SCROLL_NONE; /* 0.0 */
1323
1324
1325 switch(direction) {
1326 case SCROLL_STEP_UP:
1327 g_debug("get_events : SCROLL_STEP_UP");
1328 relative_position = -1;
1329 seek_by_time = 0;
1330 break;
1331 case SCROLL_STEP_DOWN:
1332 g_debug("get_events : SCROLL_STEP_DOWN");
1333 relative_position = 1;
1334 seek_by_time = 0;
1335 break;
1336 case SCROLL_PAGE_UP:
1337 g_debug("get_events : SCROLL_PAGE_UP");
1338 relative_position = -(event_viewer_data->num_visible_events);
1339 seek_by_time = 0;
1340 break;
1341 case SCROLL_PAGE_DOWN:
1342 g_debug("get_events : SCROLL_PAGE_DOWN");
1343 relative_position = event_viewer_data->num_visible_events;
1344 seek_by_time = 0;
1345 break;
1346 case SCROLL_JUMP:
1347 g_debug("get_events : SCROLL_JUMP");
1348 seek_by_time = 1;
1349 break;
1350 case SCROLL_NONE:
1351 g_debug("get_events : SCROLL_NONE");
1352 relative_position = 0;
1353 seek_by_time = 0;
1354 break;
1355 }
1356
1357 LttTime time = ltt_time_from_double(new_value);
1358 time = ltt_time_add(tsc->time_span.start_time, time);
1359
1360 if(!seek_by_time) {
1361
1362 LttvTracesetContextPosition *pos =
1363 lttv_traceset_context_position_new(tsc);
1364
1365 /* Remember the beginning position */
1366 if(event_viewer_data->pos->len > 0) {
1367 LttvTracesetContextPosition *first_pos =
1368 (LttvTracesetContextPosition*)g_ptr_array_index(
1369 event_viewer_data->pos,
1370 0);
1371 lttv_traceset_context_position_copy(pos, first_pos);
1372
1373 if(relative_position >= 0) {
1374 LttTime first_event_time =
1375 lttv_traceset_context_position_get_time(
1376 pos);
1377 lttv_state_traceset_seek_time_closest((LttvTracesetState*)tsc,
1378 first_event_time);
1379 lttv_process_traceset_middle(tsc, ltt_time_infinite,
1380 G_MAXUINT,
1381 pos);
1382
1383 } else if(relative_position < 0) {
1384 g_assert(lttv_process_traceset_seek_position(tsc, pos) == 0);
1385 }
1386 } else {
1387 /* There is nothing in the list : simply seek to the time value. */
1388 lttv_state_traceset_seek_time_closest((LttvTracesetState*)tsc,
1389 time);
1390 lttv_process_traceset_middle(tsc, time, G_MAXUINT,
1391 NULL);
1392 }
1393
1394 /* Note that, as we mess with the tsc position, this function CANNOT be called
1395 * from a hook inside the lttv_process_traceset_middle. */
1396 /* As the lttvwindow API keeps a sync_position inside the tsc to go back at
1397 * the right spot after being interrupted, it's ok to change the tsc position,
1398 * as long as we do not touch the sync_position. */
1399
1400 /* Get the beginning position of the read (with seek backward or seek forward)
1401 */
1402 if(relative_position > 0) {
1403 guint count;
1404 count += lttv_process_traceset_seek_n_forward(tsc, relative_position,
1405 event_viewer_data->main_win_filter, events_check_handler,
1406 &event_viewer_data->tab->stop_foreground);
1407 } else if(relative_position < 0) {
1408 guint count;
1409
1410 /* Get an idea of currently shown event dispersion */
1411 LttTime first_event_time =
1412 lttv_traceset_context_position_get_time(event_viewer_data->first_event);
1413 LttTime last_event_time =
1414 lttv_traceset_context_position_get_time(event_viewer_data->last_event);
1415 LttTime time_diff = ltt_time_sub(last_event_time, first_event_time);
1416 if(ltt_time_compare(time_diff, ltt_time_zero) == 0)
1417 time_diff = seek_back_default_offset;
1418
1419 count = lttv_process_traceset_seek_n_backward(tsc,
1420 abs(relative_position),
1421 time_diff,
1422 (seek_time_fct)lttv_state_traceset_seek_time_closest,
1423 event_viewer_data->main_win_filter,
1424 events_check_handler,
1425 &event_viewer_data->tab->stop_foreground);
1426 } /* else 0 : do nothing : we are already at the beginning position */
1427
1428 lttv_traceset_context_position_destroy(pos);
1429
1430 /* Save the first event position */
1431 lttv_traceset_context_position_save(tsc, event_viewer_data->first_event);
1432
1433 time = lttv_traceset_context_position_get_time(
1434 event_viewer_data->first_event);
1435 //if(ltt_time_compare(time, tsc->time_span.end_time) > 0)
1436 // time = tsc->time_span.end_time;
1437
1438 LttTime time_val = ltt_time_sub(time,
1439 tsc->time_span.start_time);
1440 event_viewer_data->previous_value = ltt_time_to_double(time_val);
1441
1442 lttv_state_traceset_seek_time_closest((LttvTracesetState*)tsc, time);
1443 lttv_process_traceset_middle(tsc, ltt_time_infinite, G_MAXUINT,
1444 event_viewer_data->first_event);
1445
1446 } else {
1447 /* Seek by time */
1448 lttv_state_traceset_seek_time_closest((LttvTracesetState*)tsc,
1449 time);
1450 lttv_process_traceset_middle(tsc, time, G_MAXUINT,
1451 NULL);
1452 LttTime time_val = ltt_time_sub(time,
1453 tsc->time_span.start_time);
1454 event_viewer_data->previous_value = ltt_time_to_double(time_val);
1455 lttv_traceset_context_position_save(tsc, event_viewer_data->first_event);
1456 }
1457
1458 /* Clear the model (don't forget to free the TCS positions!) */
1459 gtk_list_store_clear(event_viewer_data->store_m);
1460 for(i=0;i<event_viewer_data->pos->len;i++) {
1461 LttvTracesetContextPosition *cur_pos =
1462 (LttvTracesetContextPosition*)g_ptr_array_index(event_viewer_data->pos,
1463 i);
1464 lttv_traceset_context_position_destroy(cur_pos);
1465 }
1466 g_ptr_array_set_size(event_viewer_data->pos, 0);
1467
1468
1469 /* Mathieu :
1470 * I make the choice not to use the mainwindow lttvwindow API here : the idle
1471 * loop might have a too low priority, and we want good update while
1472 * scrolling. However, we call the gdk loop to get events periodically so the
1473 * processing can be stopped.
1474 */
1475
1476 lttv_process_traceset_begin(tsc,
1477 NULL, NULL, NULL, event_viewer_data->event_hooks, NULL);
1478
1479 event_viewer_data->num_events = 0;
1480
1481 lttv_process_traceset_middle(tsc, ltt_time_infinite, G_MAXUINT, NULL);
1482
1483 lttv_process_traceset_end(tsc,
1484 NULL, NULL, NULL, event_viewer_data->event_hooks, NULL);
1485
1486 /* Get the end position */
1487 if(event_viewer_data->pos->len > 0) {
1488 LttvTracesetContextPosition *cur_pos =
1489 (LttvTracesetContextPosition*)g_ptr_array_index(event_viewer_data->pos,
1490 event_viewer_data->pos->len - 1);
1491 lttv_traceset_context_position_copy(event_viewer_data->last_event,
1492 cur_pos);
1493 } else
1494 lttv_traceset_context_position_save(tsc, event_viewer_data->last_event);
1495
1496 gtk_adjustment_set_value(event_viewer_data->vadjust_c,
1497 event_viewer_data->previous_value);
1498
1499 //g_signal_emit_by_name(G_OBJECT (event_viewer_data->select_c),
1500 // "changed");
1501
1502 event_viewer_data->last_tree_update_time =
1503 gdk_x11_get_server_time(
1504 gtk_widget_get_parent_window(event_viewer_data->tree_v));
1505
1506 lttvwindow_events_request_enable();
1507
1508 return;
1509 }
1510
1511
1512
1513 int event_hook(void *hook_data, void *call_data)
1514 {
1515 EventViewerData *event_viewer_data = (EventViewerData*)hook_data;
1516 LttvTracefileContext *tfc = (LttvTracefileContext*)call_data;
1517 LttvTracefileState *tfs = (LttvTracefileState*)call_data;
1518 LttEvent *e = ltt_tracefile_get_event(tfc->tf);
1519
1520 if(event_viewer_data->num_events % CHECK_GDK_INTERVAL == 0) {
1521 gtk_main_iteration_do(FALSE);
1522 if(event_viewer_data->tab->stop_foreground)
1523 return TRUE;
1524 }
1525 event_viewer_data->num_events++;
1526
1527 LttvFilter *filter = event_viewer_data->main_win_filter;
1528 if(filter != NULL && filter->head != NULL)
1529 if(!lttv_filter_tree_parse(filter->head,e,tfc->tf,
1530 tfc->t_context->t,tfc))
1531 return FALSE;
1532
1533 LttFacility *facility = ltt_event_facility(e);
1534 LttEventType *event_type = ltt_event_eventtype(e);
1535 LttTime time = ltt_event_time(e);
1536
1537 guint cpu = tfs->cpu;
1538 LttvTraceState *ts = (LttvTraceState*)tfc->t_context;
1539 LttvProcessState *process = ts->running_process[cpu];
1540
1541 GtkTreeIter iter;
1542
1543 GString *desc = g_string_new("");
1544
1545 LttvTracesetContextPosition *pos =
1546 lttv_traceset_context_position_new(tfc->t_context->ts_context);
1547
1548 lttv_traceset_context_position_save(tfc->t_context->ts_context, pos);
1549
1550 lttv_event_to_string(e, desc, TRUE, TRUE, (LttvTracefileState*)tfc);
1551
1552 g_info("detail : %s", desc->str);
1553
1554 gtk_list_store_append (event_viewer_data->store_m, &iter);
1555 gtk_list_store_set (event_viewer_data->store_m, &iter,
1556 TRACE_NAME_COLUMN, g_quark_to_string(ltt_trace_name(tfc->t_context->t)),
1557 TRACEFILE_NAME_COLUMN, g_quark_to_string(ltt_tracefile_name(tfc->tf)),
1558 CPUID_COLUMN, cpu,
1559 FACILITY_COLUMN, g_quark_to_string(ltt_facility_name(facility)),
1560 EVENT_COLUMN, g_quark_to_string(ltt_eventtype_name(event_type)),
1561 TIME_S_COLUMN, time.tv_sec,
1562 TIME_NS_COLUMN, time.tv_nsec,
1563 PID_COLUMN, process->pid,
1564 EVENT_DESCR_COLUMN, desc->str,
1565 POSITION_COLUMN, pos,
1566 -1);
1567
1568 g_ptr_array_add(event_viewer_data->pos, pos);
1569
1570 g_string_free(desc, TRUE);
1571
1572 if(event_viewer_data->update_cursor) {
1573 if(lttv_traceset_context_pos_pos_compare(pos,
1574 event_viewer_data->currently_selected_position) == 0) {
1575 GtkTreePath *path = gtk_tree_path_new_from_indices(
1576 event_viewer_data->pos->len - 1, -1);
1577 if(path) {
1578 gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v),
1579 path, NULL, FALSE);
1580 gtk_tree_path_free(path);
1581 }
1582 }
1583 }
1584
1585 if(event_viewer_data->pos->len >= event_viewer_data->num_visible_events )
1586 return TRUE;
1587 else
1588 return FALSE;
1589 }
1590
1591
1592
1593 static void event_update_selection(EventViewerData *event_viewer_data)
1594 {
1595 guint i;
1596 GPtrArray *positions = event_viewer_data->pos;
1597 g_info("event_update_selection");
1598
1599 for(i=0;i<positions->len;i++) {
1600 LttvTracesetContextPosition *cur_pos =
1601 (LttvTracesetContextPosition*)g_ptr_array_index(positions, i);
1602 if(lttv_traceset_context_pos_pos_compare(cur_pos,
1603 event_viewer_data->currently_selected_position) == 0) {
1604 GtkTreePath *path = gtk_tree_path_new_from_indices(i, -1);
1605 if(path) {
1606 gtk_tree_view_set_cursor(GTK_TREE_VIEW(event_viewer_data->tree_v),
1607 path, NULL, FALSE);
1608 gtk_tree_path_free(path);
1609 }
1610 }
1611 }
1612 }
1613
1614 static int current_time_get_first_event_hook(void *hook_data, void *call_data)
1615 {
1616 EventViewerData *event_viewer_data = (EventViewerData*)hook_data;
1617 LttvTracefileContext *tfc = (LttvTracefileContext*)call_data;
1618 LttEvent *e = ltt_tracefile_get_event(tfc->tf);
1619
1620 LttvFilter *filter = event_viewer_data->main_win_filter;
1621 if(filter != NULL && filter->head != NULL)
1622 if(!lttv_filter_tree_parse(filter->head,e,tfc->tf,
1623 tfc->t_context->t,tfc))
1624 return FALSE;
1625
1626 lttv_traceset_context_position_save(tfc->t_context->ts_context,
1627 event_viewer_data->current_time_get_first);
1628 return TRUE;
1629 }
1630
1631
1632 gboolean update_current_time(void * hook_data, void * call_data)
1633 {
1634 g_info("update_current_time");
1635 EventViewerData *event_viewer_data = (EventViewerData*) hook_data;
1636 const LttTime * current_time = (LttTime*)call_data;
1637 LttvTracesetContext * tsc =
1638 lttvwindow_get_traceset_context(event_viewer_data->tab);
1639 GtkTreePath *path;
1640
1641 /* If the currently selected event time != current time, set the first event
1642 * with this time as currently selected. */
1643 LttTime pos_time = lttv_traceset_context_position_get_time(
1644 event_viewer_data->currently_selected_position);
1645 if(ltt_time_compare(pos_time, *current_time) != 0) {
1646
1647 lttv_state_traceset_seek_time_closest((LttvTracesetState*)tsc,
1648 *current_time);
1649 lttv_process_traceset_middle(tsc, *current_time, G_MAXUINT,
1650 NULL);
1651
1652 /* Get the first event that passes in the filter */
1653 event_viewer_data->current_time_get_first =
1654 lttv_traceset_context_position_new(tsc);
1655 LttvHooks *hooks = lttv_hooks_new();
1656 lttv_hooks_add(hooks,
1657 current_time_get_first_event_hook,
1658 event_viewer_data,
1659 LTTV_PRIO_DEFAULT);
1660
1661 lttv_process_traceset_begin(tsc,
1662 NULL, NULL, NULL, hooks, NULL);
1663
1664 lttv_process_traceset_middle(tsc, ltt_time_infinite, G_MAXUINT, NULL);
1665
1666 lttv_process_traceset_end(tsc,
1667 NULL, NULL, NULL, hooks, NULL);
1668
1669 lttv_hooks_destroy(hooks);
1670
1671 lttv_traceset_context_position_copy(
1672 event_viewer_data->currently_selected_position,
1673 event_viewer_data->current_time_get_first);
1674 lttv_traceset_context_position_destroy(
1675 event_viewer_data->current_time_get_first);
1676 pos_time = lttv_traceset_context_position_get_time(
1677 event_viewer_data->currently_selected_position);
1678 }
1679
1680 LttTime time = ltt_time_sub(pos_time, tsc->time_span.start_time);
1681 double new_value = ltt_time_to_double(time);
1682
1683 event_viewer_data->report_position = FALSE;
1684 /* Change the viewed area if does not match */
1685 if(lttv_traceset_context_pos_pos_compare(
1686 event_viewer_data->currently_selected_position,
1687 event_viewer_data->first_event) < 0
1688 ||
1689 lttv_traceset_context_pos_pos_compare(
1690 event_viewer_data->currently_selected_position,
1691 event_viewer_data->last_event) > 0) {
1692 gtk_adjustment_set_value(event_viewer_data->vadjust_c, new_value);
1693 } else {
1694 /* Simply update the current time : it is in the list */
1695 event_update_selection(event_viewer_data);
1696 }
1697 event_viewer_data->report_position = TRUE;
1698
1699 return FALSE;
1700 }
1701
1702 gboolean update_current_position(void * hook_data, void * call_data)
1703 {
1704 g_info("update_current_position");
1705 EventViewerData *event_viewer_data = (EventViewerData*) hook_data;
1706 const LttvTracesetContextPosition *current_pos =
1707 (LttvTracesetContextPosition*)call_data;
1708 LttvTracesetContext * tsc =
1709 lttvwindow_get_traceset_context(event_viewer_data->tab);
1710
1711 if(lttv_traceset_context_pos_pos_compare(
1712 event_viewer_data->currently_selected_position, current_pos) != 0) {
1713 lttv_traceset_context_position_copy(
1714 event_viewer_data->currently_selected_position, current_pos);
1715
1716 /* Change the viewed area if does not match */
1717 if(lttv_traceset_context_pos_pos_compare(
1718 event_viewer_data->currently_selected_position,
1719 event_viewer_data->first_event) < 0
1720 ||
1721 lttv_traceset_context_pos_pos_compare(
1722 event_viewer_data->currently_selected_position,
1723 event_viewer_data->last_event) > 0) {
1724 LttTime time = lttv_traceset_context_position_get_time(current_pos);
1725 time = ltt_time_sub(time, tsc->time_span.start_time);
1726 double new_value = ltt_time_to_double(time);
1727 gtk_adjustment_set_value(event_viewer_data->vadjust_c, new_value);
1728 } else {
1729 /* Simply update the current time : it is in the list */
1730 event_update_selection(event_viewer_data);
1731 }
1732
1733 }
1734
1735
1736 return FALSE;
1737 }
1738
1739
1740
1741 gboolean traceset_changed(void * hook_data, void * call_data)
1742 {
1743 EventViewerData *event_viewer_data = (EventViewerData*) hook_data;
1744 LttvTracesetContext * tsc =
1745 lttvwindow_get_traceset_context(event_viewer_data->tab);
1746 TimeInterval time_span = tsc->time_span;
1747
1748 LttTime end;
1749 gtk_list_store_clear(event_viewer_data->store_m);
1750 g_ptr_array_set_size(event_viewer_data->pos, 0);
1751
1752 end = ltt_time_sub(time_span.end_time, time_span.start_time);
1753 event_viewer_data->vadjust_c->upper = ltt_time_to_double(end);
1754
1755 /* Reset the positions */
1756 lttv_traceset_context_position_destroy(
1757 event_viewer_data->currently_selected_position);
1758 lttv_traceset_context_position_destroy(
1759 event_viewer_data->first_event);
1760 lttv_traceset_context_position_destroy(
1761 event_viewer_data->last_event);
1762
1763 event_viewer_data->currently_selected_position =
1764 lttv_traceset_context_position_new(tsc);
1765 event_viewer_data->first_event =
1766 lttv_traceset_context_position_new(tsc);
1767 event_viewer_data->last_event =
1768 lttv_traceset_context_position_new(tsc);
1769
1770 get_events(event_viewer_data->vadjust_c->value, event_viewer_data);
1771 // event_viewer_data->vadjust_c->value = 0;
1772
1773 request_background_data(event_viewer_data);
1774
1775 return FALSE;
1776 }
1777
1778 gboolean filter_changed(void * hook_data, void * call_data)
1779 {
1780 EventViewerData *event_viewer_data = (EventViewerData*) hook_data;
1781 LttvTracesetContext * tsc =
1782 lttvwindow_get_traceset_context(event_viewer_data->tab);
1783
1784 event_viewer_data->main_win_filter =
1785 (LttvFilter*)call_data;
1786 get_events(event_viewer_data->vadjust_c->value, event_viewer_data);
1787
1788 return FALSE;
1789 }
1790
1791
1792 gint redraw_notify(void *hook_data, void *call_data)
1793 {
1794 EventViewerData *event_viewer_data = (EventViewerData*) hook_data;
1795
1796 get_events(event_viewer_data->vadjust_c->value, event_viewer_data);
1797 return 0;
1798 }
1799
1800 void gui_events_free(EventViewerData *event_viewer_data)
1801 {
1802 Tab *tab = event_viewer_data->tab;
1803 guint i;
1804
1805 if(event_viewer_data){
1806 lttv_hooks_remove(event_viewer_data->event_hooks,event_hook);
1807 lttv_hooks_destroy(event_viewer_data->event_hooks);
1808
1809 for(i=0;i<event_viewer_data->pos->len;i++) {
1810 LttvTracesetContextPosition *cur_pos =
1811 (LttvTracesetContextPosition*)g_ptr_array_index(event_viewer_data->pos,
1812 i);
1813 lttv_traceset_context_position_destroy(cur_pos);
1814 }
1815 lttv_traceset_context_position_destroy(
1816 event_viewer_data->currently_selected_position);
1817 lttv_traceset_context_position_destroy(
1818 event_viewer_data->first_event);
1819 lttv_traceset_context_position_destroy(
1820 event_viewer_data->last_event);
1821 g_ptr_array_free(event_viewer_data->pos, TRUE);
1822
1823 lttvwindow_unregister_current_time_notify(tab,
1824 update_current_time, event_viewer_data);
1825 lttvwindow_unregister_current_position_notify(tab,
1826 update_current_position, event_viewer_data);
1827 //lttvwindow_unregister_show_notify(tab,
1828 // show_event_detail, event_viewer_data);
1829 lttvwindow_unregister_traceset_notify(tab,
1830 traceset_changed, event_viewer_data);
1831 lttvwindow_unregister_filter_notify(tab,
1832 filter_changed, event_viewer_data);
1833 lttvwindow_unregister_redraw_notify(tab,
1834 redraw_notify, event_viewer_data);
1835
1836 lttvwindowtraces_background_notify_remove(event_viewer_data);
1837
1838 g_event_viewer_data_list = g_slist_remove(g_event_viewer_data_list,
1839 event_viewer_data);
1840 g_free(event_viewer_data);
1841 }
1842 }
1843
1844
1845
1846 void gui_events_destructor(EventViewerData *event_viewer_data)
1847 {
1848 /* May already been done by GTK window closing */
1849 if(GTK_IS_WIDGET(event_viewer_data->hbox_v)){
1850 gtk_widget_destroy(event_viewer_data->hbox_v);
1851 }
1852 }
1853
1854
1855
1856 /**
1857 * plugin's init function
1858 *
1859 * This function initializes the Event Viewer functionnality through the
1860 * gtkTraceSet API.
1861 */
1862 static void init() {
1863
1864 lttvwindow_register_constructor("guievents",
1865 "/",
1866 "Insert Event Viewer",
1867 hGuiEventsInsert_xpm,
1868 "Insert Event Viewer",
1869 h_gui_events);
1870 }
1871
1872 void event_destroy_walk(gpointer data, gpointer user_data)
1873 {
1874 gui_events_destructor((EventViewerData*)data);
1875 }
1876
1877 /**
1878 * plugin's destroy function
1879 *
1880 * This function releases the memory reserved by the module and unregisters
1881 * everything that has been registered in the gtkTraceSet API.
1882 */
1883 static void destroy() {
1884
1885 g_slist_foreach(g_event_viewer_data_list, event_destroy_walk, NULL );
1886 g_slist_free(g_event_viewer_data_list);
1887
1888 lttvwindow_unregister_constructor(h_gui_events);
1889
1890 }
1891
1892
1893
1894
1895 LTTV_MODULE("guievents", "Detailed events view", \
1896 "Graphical module to display a detailed event list", \
1897 init, destroy, "lttvwindow", "print")
This page took 0.068869 seconds and 3 git commands to generate.