Add Callgrind as an Helper to run lttv
[lttv.git] / lttv / modules / gui / lttvwindow / lttvwindow / callbacks.c
CommitLineData
e076699e 1/* This file is part of the Linux Trace Toolkit viewer
b052368a 2 * Copyright (C) 2003-2004 XangXiu Yang, Mathieu Desnoyers
e076699e 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
561eba2a 19#ifdef HAVE_CONFIG_H
20# include <config.h>
21#endif
22
a1a2b649 23#include <limits.h> // for PATH_MAX
24#include <stdlib.h>
f02b5e22 25#include <ctype.h>
26#include <string.h>
27#include <stdlib.h>
a1a2b649 28
561eba2a 29#include <gtk/gtk.h>
561eba2a 30
31#include "callbacks.h"
32#include "interface.h"
33#include "support.h"
a43d67ba 34#include <ltt/trace.h>
a43d67ba 35#include <ltt/time.h>
36#include <ltt/event.h>
2a2fa4f0 37#include <lttv/lttv.h>
a43d67ba 38#include <lttv/module.h>
39#include <lttv/iattribute.h>
451aaf27
FD
40#include <lttv/traceset.h>
41#ifdef BABEL_CLEANUP
a43d67ba 42#include <lttv/stats.h>
2f076594 43#include <lttv/sync/sync_chain_lttv.h>
451aaf27
FD
44#endif /* BABEL_CLEANUP */
45#include <lttv/filter.h>
13f86ce2 46#include <lttvwindow/mainwindow.h>
2d262115 47#include <lttvwindow/mainwindow-private.h>
13f86ce2 48#include <lttvwindow/menu.h>
4172f013 49#include <lttvwindow/timebar.h>
13f86ce2 50#include <lttvwindow/toolbar.h>
501e4e70 51#include <lttvwindow/lttvwindow.h>
a1a2b649 52#include <lttvwindow/lttvwindowtraces.h>
e433e6d6 53#include <lttvwindow/lttv_plugin_tab.h>
a1a2b649 54
451aaf27
FD
55#include <babeltrace/babeltrace.h>
56#include <babeltrace/ctf/events.h>
57#include <babeltrace/ctf/iterator.h>
58
6c35c853 59static LttTime lttvwindow_default_time_width = { 1, 0 };
f02b5e22 60#define CLIP_BUF 256 // size of clipboard buffer
f7afe191 61
49bf71b5 62extern LttvTrace *g_init_trace ;
561eba2a 63
ec25ff5e 64
65/** Array containing instanced objects. */
68b48a45 66extern GSList * g_main_window_list;
561eba2a 67
a43d67ba 68/** MD : keep old directory. */
a1a2b649 69static char remember_plugins_dir[PATH_MAX] = "";
70static char remember_trace_dir[PATH_MAX] = "";
6fbb1ddf 71
e433e6d6 72void tab_destructor(LttvPluginTab * ptab);
6fbb1ddf 73
bca3b81f 74MainWindow * get_window_data_struct(GtkWidget * widget);
93ac601b 75char * get_load_module(MainWindow *mw,
76 char ** load_module_name, int nb_module);
77char * get_unload_module(MainWindow *mw,
78 char ** loaded_module_name, int nb_module);
79char * get_remove_trace(MainWindow *mw, char ** all_trace_name, int nb_trace);
80char * get_selection(MainWindow *mw,
81 char ** all_name, int nb, char *title, char * column_title);
e433e6d6 82void init_tab(Tab *tab, MainWindow * mw, Tab *copy_tab,
716e4367 83 GtkNotebook * notebook, char * label);
561eba2a 84
68764dff
AM
85int update_traceset(Tab *tab, LttvTraceset *traceset);
86
2d262115 87static void insert_viewer(GtkWidget* widget, lttvwindow_viewer_constructor constructor);
49bf71b5 88
e433e6d6 89LttvPluginTab *create_new_tab(GtkWidget* widget, gpointer user_data);
49bf71b5 90
501e4e70 91static gboolean lttvwindow_process_pending_requests(Tab *tab);
202f6c8f 92
4172f013
YB
93static void on_timebar_starttime_changed(Timebar *timebar,
94 gpointer user_data);
95static void on_timebar_endtime_changed(Timebar *timebar,
96 gpointer user_data);
97static void on_timebar_currenttime_changed(Timebar *timebar,
98 gpointer user_data);
99
49bf71b5 100enum {
101 CHECKBOX_COLUMN,
102 NAME_COLUMN,
103 TOTAL_COLUMNS
104};
561eba2a 105
36b3c068 106enum
107{
108 MODULE_COLUMN,
109 N_COLUMNS
110};
111
f02b5e22 112
e433e6d6 113#if 0
114static void on_top_notify(GObject *gobject,
115 GParamSpec *arg1,
116 gpointer user_data)
117{
118 Tab *tab = (Tab*)user_data;
119 g_message("in on_top_notify.\n");
f02b5e22 120
e433e6d6 121}
122#endif //0
b052368a 123static gboolean viewer_grab_focus(GtkWidget *widget, GdkEventButton *event,
124 gpointer data)
125{
f37a2002 126 GtkWidget *viewer = GTK_WIDGET(data);
127 GtkWidget *viewer_container = gtk_widget_get_parent(viewer);
b052368a 128
129 g_debug("FOCUS GRABBED");
f37a2002 130 g_object_set_data(G_OBJECT(viewer_container), "focused_viewer", viewer);
131 return 0;
b052368a 132}
133
f02b5e22 134
f37a2002 135static void connect_focus_recursive(GtkWidget *widget,
136 GtkWidget *viewer)
137{
138 if(GTK_IS_CONTAINER(widget)) {
139 gtk_container_forall(GTK_CONTAINER(widget),
140 (GtkCallback)connect_focus_recursive,
141 viewer);
1818a315 142
143 }
144 if(GTK_IS_TREE_VIEW(widget)) {
2eef04b5 145 gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(widget), TRUE);
f37a2002 146 }
147 gtk_widget_add_events(widget, GDK_BUTTON_PRESS_MASK);
148 g_signal_connect (G_OBJECT(widget),
149 "button-press-event",
150 G_CALLBACK (viewer_grab_focus),
151 (gpointer)viewer);
152}
b052368a 153
d27948a3 154/* Stop all the processings and call gtk_main_quit() */
155static void mainwindow_quit()
156{
157 lttvwindowtraces_unregister_requests(g_quark_from_string("stats"));
158 lttvwindowtraces_unregister_requests(g_quark_from_string("state"));
159 lttvwindowtraces_unregister_computation_hooks(g_quark_from_string("stats"));
160 lttvwindowtraces_unregister_computation_hooks(g_quark_from_string("state"));
161
162 gtk_main_quit();
163}
164
165
abe346a3 166/* insert_viewer function constructs an instance of a viewer first,
167 * then inserts the widget of the instance into the container of the
168 * main window
169 */
170
561eba2a 171void
606309a4 172insert_viewer_wrap(GtkWidget *menuitem, gpointer user_data)
561eba2a 173{
42fcbb71 174 insert_viewer((GtkWidget*)menuitem, (lttvwindow_viewer_constructor)user_data);
561eba2a 175}
176
561eba2a 177
178/* internal functions */
2d262115 179void insert_viewer(GtkWidget* widget, lttvwindow_viewer_constructor constructor)
561eba2a 180{
b052368a 181 GtkWidget * viewer_container;
6ced96ef 182 GtkWidget * notebook = lookup_widget(widget, "MNotebook");
f9334f6f 183 GtkWidget * viewer;
6ced96ef 184 GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook),
185 gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)));
e433e6d6 186 LttvPluginTab *ptab;
6ced96ef 187 Tab *tab;
188
189 if(!page) {
e433e6d6 190 ptab = create_new_tab(widget, NULL);
6ced96ef 191 } else {
e433e6d6 192 ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin");
47cd8a09 193 }
e433e6d6 194 tab = ptab->tab;
47cd8a09 195
b052368a 196 viewer_container = tab->viewer_container;
561eba2a 197
7d0aa40c 198 viewer = (GtkWidget*)constructor(&ptab->parent);
f9334f6f 199 if(viewer)
f0d936c0 200 {
b052368a 201 //gtk_multivpaned_widget_add(GTK_MULTIVPANED(multivpaned), viewer);
202
203 gtk_box_pack_end(GTK_BOX(viewer_container),
204 viewer,
205 TRUE,
206 TRUE,
207 0);
208
f37a2002 209 /* We want to connect the viewer_grab_focus to EVERY
210 * child of this widget. The little trick is to get each child
211 * of each GTK_CONTAINER, even subchildren.
212 */
0f9d55ef 213 connect_focus_recursive(viewer, viewer);
f0d936c0 214 }
561eba2a 215}
216
313bd6fc 217/**
218 * Function to set/update traceset for the viewers
219 * @param tab viewer's tab
220 * @param traceset traceset of the main window.
221 * return value :
222 * 0 : traceset updated
223 * 1 : no traceset hooks to update; not an error.
224 */
225
226int SetTraceset(Tab * tab, LttvTraceset *traceset)
227{
451aaf27 228
482fe481
BP
229 TimeInterval time_span;
230 TimeWindow new_time_window;
231 LttTime new_current_time;
d26f0474 232
451aaf27 233#ifdef BABEL_CLEANUP
482fe481 234 // Perform time synchronization on the traces
665fdbb7 235 if (syncTraceset(tsc))
482fe481
BP
236 {
237 /* There is some time-dependant information that was calculated during
238 * context initialization. Destroy the old contexts and initialize new
239 * ones.
240 * Modified from lttvwindow_add_trace()
241 */
242 // Keep a reference to the traces so they are not freed
243 for(i = 0; i < lttv_traceset_number(traceset); i++)
244 {
245 LttvTrace *trace = lttv_traceset_get(traceset, i);
246 lttv_trace_ref(trace);
247 }
248
249 // Remove state update hooks
250 lttv_state_remove_event_hooks(
251 (LttvTracesetState*)tab->traceset_info->traceset_context);
252
253 lttv_context_fini(LTTV_TRACESET_CONTEXT(
254 tab->traceset_info->traceset_context));
255 g_object_unref(tab->traceset_info->traceset_context);
256
257 for(i = 0; i < lttv_traceset_number(traceset); i++)
258 {
259 LttvTrace *trace = lttv_traceset_get(traceset, i);
260 lttvwindowtraces_remove_trace(trace);
261 lttvwindowtraces_add_trace(trace);
262 }
263
264 // Create new context
265 tab->traceset_info->traceset_context =
266 g_object_new(LTTV_TRACESET_STATS_TYPE, NULL);
267 lttv_context_init(LTTV_TRACESET_CONTEXT(tab->traceset_info->
268 traceset_context), traceset);
269
270 // Add state update hooks
271 lttv_state_add_event_hooks(
272 (LttvTracesetState*)tab->traceset_info->traceset_context);
273
274 // Remove local reference to the traces
275 for(i=0; i<lttv_traceset_number(traceset); i++)
276 {
277 LttvTrace *trace = lttv_traceset_get(traceset, i);
278 lttv_trace_unref(trace);
279 }
280
281 tsc = LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context);
282 }
451aaf27 283#endif /*BABEL_CLEANUP*/
482fe481 284
9aaa78dc 285 time_span = lttv_traceset_get_time_span(traceset);
451aaf27
FD
286
287 tab->traceset_info->traceset = traceset;
288
289 new_time_window = tab->time_window;
290 new_current_time = tab->current_time;
291
1ba187d3 292 /* Set the tab's time window and current time if
293 * out of bounds */
294 if(ltt_time_compare(tab->time_window.start_time, time_span.start_time) < 0
6f26fc38 295 || ltt_time_compare(tab->time_window.end_time,
1ba187d3 296 time_span.end_time) > 0) {
e800cf84 297 new_time_window.start_time = time_span.start_time;
298
299 new_current_time = time_span.start_time;
1ba187d3 300
301 LttTime tmp_time;
6c35c853 302
303 if(ltt_time_compare(lttvwindow_default_time_width,
4249a3e8 304 ltt_time_sub(time_span.end_time, time_span.start_time)) < 0
305 ||
306 ltt_time_compare(time_span.end_time, time_span.start_time) == 0)
6c35c853 307 tmp_time = lttvwindow_default_time_width;
1ba187d3 308 else
6c35c853 309 tmp_time = time_span.end_time;
310
e800cf84 311 new_time_window.time_width = tmp_time ;
a18124ff 312 new_time_window.time_width_double = ltt_time_to_double(tmp_time);
6f26fc38 313 new_time_window.end_time = ltt_time_add(new_time_window.start_time,
314 new_time_window.time_width) ;
1ba187d3 315 }
e800cf84 316
1ba187d3 317 /* Finally, call the update hooks of the viewers */
68764dff 318 gint retval = update_traceset(tab, traceset);
1ba187d3 319
4249a3e8 320 time_change_manager(tab, new_time_window);
321 current_time_change_manager(tab, new_current_time);
322
b052368a 323 return retval;
451aaf27 324
313bd6fc 325}
326
327/**
328 * Function to set/update filter for the viewers
329 * @param tab viewer's tab
330 * @param filter filter of the main window.
331 * return value :
332 * -1 : error
333 * 0 : filters updated
334 * 1 : no filter hooks to update; not an error.
335 */
a998b781 336#if 0
313bd6fc 337int SetFilter(Tab * tab, gpointer filter)
338{
339 LttvHooks * tmp;
340 LttvAttributeValue value;
341
342 g_assert(lttv_iattribute_find_by_path(tab->attributes,
343 "hooks/updatefilter", LTTV_POINTER, &value));
344
345 tmp = (LttvHooks*)*(value.v_pointer);
346
347 if(tmp == NULL) return 1;
348 lttv_hooks_call(tmp,filter);
349
350 return 0;
351}
a998b781 352#endif //0
313bd6fc 353
354
355/**
356 * Function to redraw each viewer belonging to the current tab
357 * @param tab viewer's tab
358 */
359
1e3594a3 360int update_traceset(Tab *tab, LttvTraceset *traceset)
313bd6fc 361{
362 LttvAttributeValue value;
363 LttvHooks * tmp;
8f318283
BP
364 gboolean retval;
365
366 retval= lttv_iattribute_find_by_path(tab->attributes,
1e3594a3
YB
367 "hooks/updatetraceset",
368 LTTV_POINTER,
369 &value);
8f318283 370 g_assert(retval);
313bd6fc 371 tmp = (LttvHooks*)*(value.v_pointer);
1e3594a3
YB
372 if(tmp == NULL) {
373 retval = 1;
374 } else {
375 lttv_hooks_call(tmp, traceset);
376 }
377 return retval;
313bd6fc 378}
379
1e3594a3
YB
380/**
381 Call hooks register to get update on traceset time span changes
382*/
383int notify_time_span_changed(Tab *tab)
384{
385 LttvAttributeValue value;
386 LttvHooks * tmp;
387 gboolean retval;
388
389 retval= lttv_iattribute_find_by_path(tab->attributes,
390 "hooks/updatetimespan",
391 LTTV_POINTER,
392 &value);
393 g_assert(retval);
394 tmp = (LttvHooks*)*(value.v_pointer);
395 if(tmp == NULL) {
396 retval = 1;
397 } else {
398 lttv_hooks_call(tmp, NULL);
399 }
400 return retval;
401}
abe346a3 402
403/* get_label function is used to get user input, it displays an input
404 * box, which allows user to input a string
405 */
406
561eba2a 407void get_label_string (GtkWidget * text, gchar * label)
408{
409 GtkEntry * entry = (GtkEntry*)text;
410 if(strlen(gtk_entry_get_text(entry))!=0)
411 strcpy(label,gtk_entry_get_text(entry));
412}
413
eb38aea5 414gboolean get_label(MainWindow * mw, gchar * str, gchar* dialogue_title, gchar * label_str)
561eba2a 415{
416 GtkWidget * dialogue;
417 GtkWidget * text;
418 GtkWidget * label;
419 gint id;
420
5723fa24 421 dialogue = gtk_dialog_new_with_buttons(dialogue_title,NULL,
561eba2a 422 GTK_DIALOG_MODAL,
423 GTK_STOCK_OK,GTK_RESPONSE_ACCEPT,
424 GTK_STOCK_CANCEL,GTK_RESPONSE_REJECT,
425 NULL);
426
6b1d3120 427 label = gtk_label_new(label_str);
561eba2a 428 gtk_widget_show(label);
429
430 text = gtk_entry_new();
431 gtk_widget_show(text);
432
433 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialogue)->vbox), label,TRUE, TRUE,0);
434 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialogue)->vbox), text,FALSE, FALSE,0);
435
436 id = gtk_dialog_run(GTK_DIALOG(dialogue));
437 switch(id){
438 case GTK_RESPONSE_ACCEPT:
439 get_label_string(text,str);
440 gtk_widget_destroy(dialogue);
441 break;
442 case GTK_RESPONSE_REJECT:
443 default:
444 gtk_widget_destroy(dialogue);
eb38aea5 445 return FALSE;
561eba2a 446 }
eb38aea5 447 return TRUE;
561eba2a 448}
449
abe346a3 450
451/* get_window_data_struct function is actually a lookup function,
452 * given a widget which is in the tree of the main window, it will
453 * return the MainWindow data structure associated with main window
454 */
455
bca3b81f 456MainWindow * get_window_data_struct(GtkWidget * widget)
561eba2a 457{
458 GtkWidget * mw;
bca3b81f 459 MainWindow * mw_data;
561eba2a 460
461 mw = lookup_widget(widget, "MWindow");
462 if(mw == NULL){
56e5a0f7 463 g_info("Main window does not exist\n");
2d262115 464 return NULL;
561eba2a 465 }
466
2d262115 467 mw_data = (MainWindow *) g_object_get_data(G_OBJECT(mw),"main_window_data");
68b48a45 468 if(mw_data == NULL){
2eef04b5 469 g_warning("Main window data does not exist\n");
2d262115 470 return NULL;
561eba2a 471 }
68b48a45 472 return mw_data;
561eba2a 473}
474
abe346a3 475
476/* create_new_window function, just constructs a new main window
477 */
478
68b48a45 479void create_new_window(GtkWidget* widget, gpointer user_data, gboolean clone)
561eba2a 480{
bca3b81f 481 MainWindow * parent = get_window_data_struct(widget);
561eba2a 482
561eba2a 483 if(clone){
56e5a0f7 484 g_info("Clone : use the same traceset\n");
08b1c66e 485 construct_main_window(parent);
561eba2a 486 }else{
56e5a0f7 487 g_info("Empty : traceset is set to NULL\n");
08b1c66e 488 construct_main_window(NULL);
561eba2a 489 }
490}
491
0f9d55ef 492/* Get the currently focused viewer.
493 * If no viewer is focused, use the first one.
494 *
495 * If no viewer available, return NULL.
496 */
b052368a 497GtkWidget *viewer_container_focus(GtkWidget *container)
498{
499 GtkWidget *widget;
500
501 widget = (GtkWidget*)g_object_get_data(G_OBJECT(container),
bb574a9c 502 "focused_viewer");
b052368a 503
0f9d55ef 504 if(widget == NULL) {
505 g_debug("no widget focused");
506 GList *children = gtk_container_get_children(GTK_CONTAINER(container));
507
508 if(children != NULL)
509 widget = GTK_WIDGET(children->data);
bb574a9c 510 g_object_set_data(G_OBJECT(container),
511 "focused_viewer",
512 widget);
0f9d55ef 513 }
514
b052368a 515 return widget;
516
517
518}
519
520gint viewer_container_position(GtkWidget *container, GtkWidget *child)
521{
522
523 if(child == NULL) return -1;
524
525 gint pos;
2eef04b5 526 GValue value;
527 memset(&value, 0, sizeof(GValue));
b052368a 528 g_value_init(&value, G_TYPE_INT);
529 gtk_container_child_get_property(GTK_CONTAINER(container),
530 child,
531 "position",
532 &value);
533 pos = g_value_get_int(&value);
534
535 return pos;
536}
537
abe346a3 538
539/* move_*_viewer functions move the selected view up/down in
540 * the current tab
541 */
542
b052368a 543void move_down_viewer(GtkWidget * widget, gpointer user_data)
561eba2a 544{
6ced96ef 545 GtkWidget * notebook = lookup_widget(widget, "MNotebook");
546
547 GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook),
548 gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)));
549
550 Tab *tab;
6ced96ef 551 if(!page) {
552 return;
553 } else {
e433e6d6 554 LttvPluginTab *ptab;
43ed82b5 555 ptab = g_object_get_data(G_OBJECT(page), "Tab_Plugin");
e433e6d6 556 tab = ptab->tab;
6ced96ef 557 }
558
b052368a 559 //gtk_multivpaned_widget_move_up(GTK_MULTIVPANED(tab->multivpaned));
560
561 /* change the position in the vbox */
562 GtkWidget *focus_widget;
563 gint position;
564 focus_widget = viewer_container_focus(tab->viewer_container);
565 position = viewer_container_position(tab->viewer_container, focus_widget);
566
567 if(position > 0) {
568 /* can move up one position */
569 gtk_box_reorder_child(GTK_BOX(tab->viewer_container),
570 focus_widget,
571 position-1);
572 }
573
561eba2a 574}
575
b052368a 576void move_up_viewer(GtkWidget * widget, gpointer user_data)
561eba2a 577{
6ced96ef 578 GtkWidget * notebook = lookup_widget(widget, "MNotebook");
579
580 GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook),
581 gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)));
582 Tab *tab;
583
584 if(!page) {
585 return;
586 } else {
e433e6d6 587 LttvPluginTab *ptab;
588 ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin");
589 tab = ptab->tab;
6ced96ef 590 }
591
b052368a 592 //gtk_multivpaned_widget_move_down(GTK_MULTIVPANED(tab->multivpaned));
593 /* change the position in the vbox */
594 GtkWidget *focus_widget;
595 gint position;
596 focus_widget = viewer_container_focus(tab->viewer_container);
597 position = viewer_container_position(tab->viewer_container, focus_widget);
598
599 if(position != -1 &&
600 position <
601 g_list_length(gtk_container_get_children(
602 GTK_CONTAINER(tab->viewer_container)))-1
603 ) {
604 /* can move down one position */
605 gtk_box_reorder_child(GTK_BOX(tab->viewer_container),
606 focus_widget,
607 position+1);
608 }
609
561eba2a 610}
611
abe346a3 612
613/* delete_viewer deletes the selected viewer in the current tab
614 */
615
561eba2a 616void delete_viewer(GtkWidget * widget, gpointer user_data)
617{
6ced96ef 618 GtkWidget * notebook = lookup_widget(widget, "MNotebook");
619
620 GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook),
621 gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)));
622 Tab *tab;
623
624 if(!page) {
625 return;
626 } else {
e433e6d6 627 LttvPluginTab *ptab;
43ed82b5 628 ptab = g_object_get_data(G_OBJECT(page), "Tab_Plugin");
e433e6d6 629 tab = ptab->tab;
6ced96ef 630 }
631
b052368a 632 //gtk_multivpaned_widget_delete(GTK_MULTIVPANED(tab->multivpaned));
633
634 GtkWidget *focus_widget = viewer_container_focus(tab->viewer_container);
635
636 if(focus_widget != NULL)
637 gtk_widget_destroy(focus_widget);
638
639 g_object_set_data(G_OBJECT(tab->viewer_container), "focused_viewer", NULL);
561eba2a 640}
641
e865422c
YB
642#if UNFINISHED_FEATURE
643/* TODO ybrosseau 2012-03-15: Function is half implemented. Should be removed */
abe346a3 644/* open_traceset will open a traceset saved in a file
645 * Right now, it is not finished yet, (not working)
a43d67ba 646 * FIXME
abe346a3 647 */
648
561eba2a 649void open_traceset(GtkWidget * widget, gpointer user_data)
650{
2176f952 651 char ** dir;
652 gint id;
653 LttvTraceset * traceset;
bca3b81f 654 MainWindow * mw_data = get_window_data_struct(widget);
68b48a45 655 GtkFileSelection * file_selector =
2176f952 656 (GtkFileSelection *)gtk_file_selection_new("Select a traceset");
657
68b48a45 658 gtk_file_selection_hide_fileop_buttons(file_selector);
c64c7ea1 659
93ac601b 660 gtk_window_set_transient_for(GTK_WINDOW(file_selector),
661 GTK_WINDOW(mw_data->mwindow));
662
68b48a45 663 id = gtk_dialog_run(GTK_DIALOG(file_selector));
2176f952 664 switch(id){
665 case GTK_RESPONSE_ACCEPT:
666 case GTK_RESPONSE_OK:
68b48a45 667 dir = gtk_file_selection_get_selections (file_selector);
2176f952 668 traceset = lttv_traceset_load(dir[0]);
56e5a0f7 669 g_info("Open a trace set %s\n", dir[0]);
2176f952 670 //Not finished yet
671 g_strfreev(dir);
672 case GTK_RESPONSE_REJECT:
673 case GTK_RESPONSE_CANCEL:
674 default:
68b48a45 675 gtk_widget_destroy((GtkWidget*)file_selector);
2176f952 676 break;
677 }
c64c7ea1 678
561eba2a 679}
e865422c 680#endif
501e4e70 681/* lttvwindow_process_pending_requests
d389bc8d 682 *
683 * Process requests for parts of the trace from viewers.
684 *
685 * These requests are made by lttvwindow_events_request().
501e4e70 686 *
687 * This internal function gets called by g_idle, taking care of the pending
688 * requests. It is responsible for concatenation of time intervals and position
689 * requests. It does it with the following algorithm organizing process traceset
690 * calls. Here is the detailed description of the way it works :
691 *
692 * - Events Requests Servicing Algorithm
693 *
694 * Data structures necessary :
695 *
696 * List of requests added to context : list_in
697 * List of requests not added to context : list_out
698 *
699 * Initial state :
700 *
701 * list_in : empty
702 * list_out : many events requests
703 *
704 * FIXME : insert rest of algorithm here
705 *
abe346a3 706 */
707
6ea08962 708#define list_out tab->events_requests
a43d67ba 709
501e4e70 710gboolean lttvwindow_process_pending_requests(Tab *tab)
a8c0f09d 711{
9a366873 712#ifdef BABEL_CLEANUP
a43d67ba 713 LttvTracesetContext *tsc;
501e4e70 714 LttvTracefileContext *tfc;
501e4e70 715 GSList *list_in = NULL;
716 LttTime end_time;
717 guint end_nb_events;
2d262115 718 guint count;
501e4e70 719 LttvTracesetContextPosition *end_position;
a43d67ba 720
3c456a8a 721 if(lttvwindow_preempt_count > 0) return TRUE;
722
b052368a 723 if(tab == NULL) {
724 g_critical("Foreground processing : tab does not exist. Processing removed.");
501e4e70 725 return FALSE;
b052368a 726 }
a43d67ba 727
501e4e70 728 /* There is no events requests pending : we should never have been called! */
6ea08962 729 g_assert(g_slist_length(list_out) != 0);
a43d67ba 730
501e4e70 731 tsc = LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context);
a8c0f09d 732
abe346a3 733 //set the cursor to be X shape, indicating that the computer is busy in doing its job
a0577796 734#if 0
a8c0f09d 735 new = gdk_cursor_new(GDK_X_CURSOR);
2d262115 736 widget = lookup_widget(tab->mw->mwindow, "MToolbar1");
a8c0f09d 737 win = gtk_widget_get_parent_window(widget);
738 gdk_window_set_cursor(win, new);
739 gdk_cursor_unref(new);
740 gdk_window_stick(win);
741 gdk_window_unstick(win);
a0577796 742#endif //0
a43d67ba 743
6ea08962 744 g_debug("SIZE events req len : %d", g_slist_length(list_out));
745
746 /* Preliminary check for no trace in traceset */
747 /* Unregister the routine if empty, empty list_out too */
748 if(lttv_traceset_number(tsc->ts) == 0) {
749
750 /* - For each req in list_out */
751 GSList *iter = list_out;
752
753 while(iter != NULL) {
754
755 gboolean remove = FALSE;
756 gboolean free_data = FALSE;
757 EventsRequest *events_request = (EventsRequest *)iter->data;
758
759 /* - Call end request for req */
760 if(events_request->servicing == TRUE)
761 lttv_hooks_call(events_request->after_request, (gpointer)tsc);
762
763 /* - remove req from list_out */
764 /* Destroy the request */
765 remove = TRUE;
766 free_data = TRUE;
767
768 /* Go to next */
769 if(remove)
770 {
771 GSList *remove_iter = iter;
772
773 iter = g_slist_next(iter);
b052368a 774 if(free_data) events_request_free((EventsRequest*)remove_iter->data);
6ea08962 775 list_out = g_slist_remove_link(list_out, remove_iter);
776 } else { // not remove
777 iter = g_slist_next(iter);
778 }
779 }
780 }
088f6772 781
b052368a 782 /* 0.1 Lock Traces */
783 {
784 guint iter_trace=0;
785
786 for(iter_trace=0;
787 iter_trace<lttv_traceset_number(tsc->ts);
788 iter_trace++) {
789 LttvTrace *trace_v = lttv_traceset_get(tsc->ts, iter_trace);
790
791 if(lttvwindowtraces_lock(trace_v) != 0) {
792 g_critical("Foreground processing : Unable to get trace lock");
793 return TRUE; /* Cannot get lock, try later */
794 }
795 }
796 }
797
798 /* 0.2 Seek tracefiles positions to context position */
088f6772 799 //g_assert(lttv_process_traceset_seek_position(tsc, sync_position) == 0);
b052368a 800 lttv_process_traceset_synchronize_tracefiles(tsc);
088f6772 801
b052368a 802
501e4e70 803 /* Events processing algorithm implementation */
dd316a11 804 /* Warning : the gtk_events_pending takes a LOT of cpu time. So what we do
805 * instead is to leave the control to GTK and take it back.
806 */
501e4e70 807 /* A. Servicing loop */
dd316a11 808 //while( (g_slist_length(list_in) != 0 || g_slist_length(list_out) != 0)) {
3bafb436 809 if((g_slist_length(list_in) != 0 || g_slist_length(list_out) != 0)) {
810 /* Servicing */
811 /* 1. If list_in is empty (need a seek) */
812 if( g_slist_length(list_in) == 0 ) {
501e4e70 813
3bafb436 814 /* list in is empty, need a seek */
dd316a11 815 {
3bafb436 816 /* 1.1 Add requests to list_in */
817 GSList *ltime = NULL;
818 GSList *lpos = NULL;
819 GSList *iter = NULL;
501e4e70 820
3bafb436 821 /* 1.1.1 Find all time requests with the lowest start time in list_out
822 * (ltime)
823 */
824 if(g_slist_length(list_out) > 0)
825 ltime = g_slist_append(ltime, g_slist_nth_data(list_out, 0));
826 for(iter=g_slist_nth(list_out,1);iter!=NULL;iter=g_slist_next(iter)) {
827 /* Find all time requests with the lowest start time in list_out */
3bafb436 828 EventsRequest *event_request_ltime = (EventsRequest*)g_slist_nth_data(ltime, 0);
829 EventsRequest *event_request_list_out = (EventsRequest*)iter->data;
830
831 int comp;
832 comp = ltt_time_compare(event_request_ltime->start_time,
833 event_request_list_out->start_time);
834 if(comp == 0)
835 ltime = g_slist_append(ltime, event_request_list_out);
836 else if(comp > 0) {
837 /* Remove all elements from ltime, and add current */
838 while(ltime != NULL)
839 ltime = g_slist_delete_link(ltime, g_slist_nth(ltime, 0));
840 ltime = g_slist_append(ltime, event_request_list_out);
841 }
501e4e70 842 }
843
3bafb436 844 /* 1.1.2 Find all position requests with the lowest position in list_out
845 * (lpos)
846 */
847 if(g_slist_length(list_out) > 0)
848 lpos = g_slist_append(lpos, g_slist_nth_data(list_out, 0));
849 for(iter=g_slist_nth(list_out,1);iter!=NULL;iter=g_slist_next(iter)) {
850 /* Find all position requests with the lowest position in list_out */
851 EventsRequest *event_request_lpos = (EventsRequest*)g_slist_nth_data(lpos, 0);
852 EventsRequest *event_request_list_out = (EventsRequest*)iter->data;
853
854 int comp;
855 if(event_request_lpos->start_position != NULL
856 && event_request_list_out->start_position != NULL)
857 {
858 comp = lttv_traceset_context_pos_pos_compare
859 (event_request_lpos->start_position,
860 event_request_list_out->start_position);
861 } else {
862 comp = -1;
553d1e7b 863 }
3bafb436 864 if(comp == 0)
865 lpos = g_slist_append(lpos, event_request_list_out);
866 else if(comp > 0) {
867 /* Remove all elements from lpos, and add current */
868 while(lpos != NULL)
869 lpos = g_slist_delete_link(lpos, g_slist_nth(lpos, 0));
870 lpos = g_slist_append(lpos, event_request_list_out);
501e4e70 871 }
872 }
3bafb436 873
874 {
875 EventsRequest *event_request_lpos = (EventsRequest*)g_slist_nth_data(lpos, 0);
876 EventsRequest *event_request_ltime = (EventsRequest*)g_slist_nth_data(ltime, 0);
877 LttTime lpos_start_time;
dd316a11 878
3bafb436 879 if(event_request_lpos != NULL
880 && event_request_lpos->start_position != NULL) {
881 lpos_start_time = lttv_traceset_context_position_get_time(
882 event_request_lpos->start_position);
883 }
884
885 /* 1.1.3 If lpos.start time < ltime */
886 if(event_request_lpos != NULL
887 && event_request_lpos->start_position != NULL
888 && ltt_time_compare(lpos_start_time,
889 event_request_ltime->start_time)<0) {
890 /* Add lpos to list_in, remove them from list_out */
891 for(iter=lpos;iter!=NULL;iter=g_slist_next(iter)) {
892 /* Add to list_in */
893 EventsRequest *event_request_lpos =
894 (EventsRequest*)iter->data;
895
896 list_in = g_slist_append(list_in, event_request_lpos);
897 /* Remove from list_out */
898 list_out = g_slist_remove(list_out, event_request_lpos);
899 }
900 } else {
901 /* 1.1.4 (lpos.start time >= ltime) */
902 /* Add ltime to list_in, remove them from list_out */
903
904 for(iter=ltime;iter!=NULL;iter=g_slist_next(iter)) {
905 /* Add to list_in */
906 EventsRequest *event_request_ltime =
907 (EventsRequest*)iter->data;
908
909 list_in = g_slist_append(list_in, event_request_ltime);
910 /* Remove from list_out */
911 list_out = g_slist_remove(list_out, event_request_ltime);
912 }
913 }
dd316a11 914 }
3bafb436 915 g_slist_free(lpos);
916 g_slist_free(ltime);
dd316a11 917 }
dd316a11 918
3bafb436 919 /* 1.2 Seek */
920 {
921 tfc = lttv_traceset_context_get_current_tfc(tsc);
922 g_assert(g_slist_length(list_in)>0);
923 EventsRequest *events_request = g_slist_nth_data(list_in, 0);
e865422c 924#ifdef DEBUG
3bafb436 925 guint seek_count;
e865422c 926#endif
3bafb436 927
928 /* 1.2.1 If first request in list_in is a time request */
929 if(events_request->start_position == NULL) {
930 /* - If first req in list_in start time != current time */
931 if(tfc == NULL || ltt_time_compare(events_request->start_time,
932 tfc->timestamp) != 0)
933 /* - Seek to that time */
934 g_debug("SEEK TIME : %lu, %lu", events_request->start_time.tv_sec,
935 events_request->start_time.tv_nsec);
936 //lttv_process_traceset_seek_time(tsc, events_request->start_time);
937 lttv_state_traceset_seek_time_closest(LTTV_TRACESET_STATE(tsc),
938 events_request->start_time);
939
940 /* Process the traceset with only state hooks */
e865422c 941#ifdef DEBUG
3bafb436 942 seek_count =
e865422c 943#endif //DEBUG
3bafb436 944 lttv_process_traceset_middle(tsc,
945 events_request->start_time,
946 G_MAXUINT, NULL);
f4b88a7d 947#ifdef DEBUG
948 g_assert(seek_count < LTTV_STATE_SAVE_INTERVAL);
949#endif //DEBUG
6ea08962 950
a43d67ba 951
3bafb436 952 } else {
953 LttTime pos_time;
2a7a425c 954 LttvTracefileContext *tfc =
955 lttv_traceset_context_get_current_tfc(tsc);
3bafb436 956 /* Else, the first request in list_in is a position request */
957 /* If first req in list_in pos != current pos */
958 g_assert(events_request->start_position != NULL);
959 g_debug("SEEK POS time : %lu, %lu",
960 lttv_traceset_context_position_get_time(
961 events_request->start_position).tv_sec,
962 lttv_traceset_context_position_get_time(
963 events_request->start_position).tv_nsec);
2a7a425c 964
965 if(tfc) {
966 g_debug("SEEK POS context time : %lu, %lu",
967 tfc->timestamp.tv_sec,
968 tfc->timestamp.tv_nsec);
969 } else {
970 g_debug("SEEK POS context time : %lu, %lu",
971 ltt_time_infinite.tv_sec,
972 ltt_time_infinite.tv_nsec);
973 }
3bafb436 974 g_assert(events_request->start_position != NULL);
975 if(lttv_traceset_context_ctx_pos_compare(tsc,
976 events_request->start_position) != 0) {
977 /* 1.2.2.1 Seek to that position */
978 g_debug("SEEK POSITION");
979 //lttv_process_traceset_seek_position(tsc, events_request->start_position);
980 pos_time = lttv_traceset_context_position_get_time(
981 events_request->start_position);
982
983 lttv_state_traceset_seek_time_closest(LTTV_TRACESET_STATE(tsc),
984 pos_time);
985
986 /* Process the traceset with only state hooks */
e865422c 987#ifdef DEBUG
3bafb436 988 seek_count =
9a366873 989
3bafb436 990 lttv_process_traceset_middle(tsc,
991 ltt_time_infinite,
992 G_MAXUINT,
993 events_request->start_position);
9a366873 994#endif
3bafb436 995 g_assert(lttv_traceset_context_ctx_pos_compare(tsc,
996 events_request->start_position) == 0);
dd316a11 997
dd316a11 998
3bafb436 999 }
1000 }
1001 }
2d262115 1002
3bafb436 1003 /* 1.3 Add hooks and call before request for all list_in members */
1004 {
1005 GSList *iter = NULL;
dd316a11 1006
3bafb436 1007 for(iter=list_in;iter!=NULL;iter=g_slist_next(iter)) {
1008 EventsRequest *events_request = (EventsRequest*)iter->data;
1009 /* 1.3.1 If !servicing */
2d262115 1010 if(events_request->servicing == FALSE) {
1011 /* - begin request hooks called
1012 * - servicing = TRUE
1013 */
6ea08962 1014 lttv_hooks_call(events_request->before_request, (gpointer)tsc);
2d262115 1015 events_request->servicing = TRUE;
1016 }
3bafb436 1017 /* 1.3.2 call before chunk
1018 * 1.3.3 events hooks added
2d262115 1019 */
54d8f654 1020 if(events_request->trace == -1)
1021 lttv_process_traceset_begin(tsc,
1022 events_request->before_chunk_traceset,
1023 events_request->before_chunk_trace,
1024 events_request->before_chunk_tracefile,
1025 events_request->event,
750eb11a 1026 events_request->event_by_id_channel);
54d8f654 1027 else {
1028 guint nb_trace = lttv_traceset_number(tsc->ts);
2eef04b5 1029 g_assert((guint)events_request->trace < nb_trace &&
54d8f654 1030 events_request->trace > -1);
1031 LttvTraceContext *tc = tsc->traces[events_request->trace];
1032
1033 lttv_hooks_call(events_request->before_chunk_traceset, tsc);
1034
1035 lttv_trace_context_add_hooks(tc,
1036 events_request->before_chunk_trace,
1037 events_request->before_chunk_tracefile,
1038 events_request->event,
750eb11a 1039 events_request->event_by_id_channel);
54d8f654 1040 }
501e4e70 1041 }
3bafb436 1042 }
1043 } else {
1044 /* 2. Else, list_in is not empty, we continue a read */
1045
1046 {
1047 /* 2.0 For each req of list_in */
1048 GSList *iter = list_in;
1049
1050 while(iter != NULL) {
2d262115 1051
3bafb436 1052 EventsRequest *events_request = (EventsRequest *)iter->data;
1053
1054 /* - Call before chunk
1055 * - events hooks added
1056 */
54d8f654 1057 if(events_request->trace == -1)
1058 lttv_process_traceset_begin(tsc,
1059 events_request->before_chunk_traceset,
1060 events_request->before_chunk_trace,
1061 events_request->before_chunk_tracefile,
1062 events_request->event,
750eb11a 1063 events_request->event_by_id_channel);
54d8f654 1064 else {
1065 guint nb_trace = lttv_traceset_number(tsc->ts);
2eef04b5 1066 g_assert((guint)events_request->trace < nb_trace &&
54d8f654 1067 events_request->trace > -1);
1068 LttvTraceContext *tc = tsc->traces[events_request->trace];
1069
1070 lttv_hooks_call(events_request->before_chunk_traceset, tsc);
1071
1072 lttv_trace_context_add_hooks(tc,
3bafb436 1073 events_request->before_chunk_trace,
1074 events_request->before_chunk_tracefile,
1075 events_request->event,
750eb11a 1076 events_request->event_by_id_channel);
54d8f654 1077 }
6ea08962 1078
1079 iter = g_slist_next(iter);
1080 }
1081 }
1082
3bafb436 1083 {
1084 tfc = lttv_traceset_context_get_current_tfc(tsc);
1085
1086 /* 2.1 For each req of list_out */
1087 GSList *iter = list_out;
553d1e7b 1088
3bafb436 1089 while(iter != NULL) {
6ea08962 1090
3bafb436 1091 gboolean remove = FALSE;
1092 gboolean free_data = FALSE;
1093 EventsRequest *events_request = (EventsRequest *)iter->data;
1094
1095 /* if req.start time == current context time
1096 * or req.start position == current position*/
1097 if( ltt_time_compare(events_request->start_time,
1098 tfc->timestamp) == 0
1099 ||
1100 (events_request->start_position != NULL
1101 &&
1102 lttv_traceset_context_ctx_pos_compare(tsc,
1103 events_request->start_position) == 0)
1104 ) {
1105 /* - Add to list_in, remove from list_out */
1106 list_in = g_slist_append(list_in, events_request);
1107 remove = TRUE;
1108 free_data = FALSE;
1109
1110 /* - If !servicing */
1111 if(events_request->servicing == FALSE) {
1112 /* - begin request hooks called
1113 * - servicing = TRUE
1114 */
1115 lttv_hooks_call(events_request->before_request, (gpointer)tsc);
1116 events_request->servicing = TRUE;
1117 }
1118 /* call before chunk
1119 * events hooks added
1120 */
54d8f654 1121 if(events_request->trace == -1)
1122 lttv_process_traceset_begin(tsc,
1123 events_request->before_chunk_traceset,
1124 events_request->before_chunk_trace,
1125 events_request->before_chunk_tracefile,
1126 events_request->event,
750eb11a 1127 events_request->event_by_id_channel);
54d8f654 1128 else {
1129 guint nb_trace = lttv_traceset_number(tsc->ts);
2eef04b5 1130 g_assert((guint)events_request->trace < nb_trace &&
54d8f654 1131 events_request->trace > -1);
1132 LttvTraceContext *tc = tsc->traces[events_request->trace];
1133
1134 lttv_hooks_call(events_request->before_chunk_traceset, tsc);
1135
1136 lttv_trace_context_add_hooks(tc,
1137 events_request->before_chunk_trace,
1138 events_request->before_chunk_tracefile,
1139 events_request->event,
750eb11a 1140 events_request->event_by_id_channel);
54d8f654 1141 }
1142
1143
3bafb436 1144 }
501e4e70 1145
3bafb436 1146 /* Go to next */
1147 if(remove)
1148 {
1149 GSList *remove_iter = iter;
2d262115 1150
3bafb436 1151 iter = g_slist_next(iter);
1152 if(free_data) events_request_free((EventsRequest*)remove_iter->data);
1153 list_out = g_slist_remove_link(list_out, remove_iter);
1154 } else { // not remove
1155 iter = g_slist_next(iter);
1156 }
1157 }
1158 }
1159 }
8f2872f4 1160
3bafb436 1161 /* 3. Find end criterions */
1162 {
1163 /* 3.1 End time */
1164 GSList *iter;
1165
1166 /* 3.1.1 Find lowest end time in list_in */
1167 g_assert(g_slist_length(list_in)>0);
1168 end_time = ((EventsRequest*)g_slist_nth_data(list_in,0))->end_time;
1169
1170 for(iter=g_slist_nth(list_in,1);iter!=NULL;iter=g_slist_next(iter)) {
1171 EventsRequest *events_request = (EventsRequest*)iter->data;
501e4e70 1172
3bafb436 1173 if(ltt_time_compare(events_request->end_time,
1174 end_time) < 0)
1175 end_time = events_request->end_time;
1176 }
1177
1178 /* 3.1.2 Find lowest start time in list_out */
1179 for(iter=list_out;iter!=NULL;iter=g_slist_next(iter)) {
1180 EventsRequest *events_request = (EventsRequest*)iter->data;
2d262115 1181
3bafb436 1182 if(ltt_time_compare(events_request->start_time,
1183 end_time) < 0)
1184 end_time = events_request->start_time;
1185 }
501e4e70 1186 }
1187
3bafb436 1188 {
1189 /* 3.2 Number of events */
dd316a11 1190
3bafb436 1191 /* 3.2.1 Find lowest number of events in list_in */
1192 GSList *iter;
501e4e70 1193
3bafb436 1194 end_nb_events = ((EventsRequest*)g_slist_nth_data(list_in,0))->num_events;
501e4e70 1195
3bafb436 1196 for(iter=g_slist_nth(list_in,1);iter!=NULL;iter=g_slist_next(iter)) {
1197 EventsRequest *events_request = (EventsRequest*)iter->data;
501e4e70 1198
3bafb436 1199 if(events_request->num_events < end_nb_events)
1200 end_nb_events = events_request->num_events;
1201 }
501e4e70 1202
3bafb436 1203 /* 3.2.2 Use min(CHUNK_NUM_EVENTS, min num events in list_in) as
1204 * num_events */
1205
1206 end_nb_events = MIN(CHUNK_NUM_EVENTS, end_nb_events);
501e4e70 1207 }
501e4e70 1208
3bafb436 1209 {
1210 /* 3.3 End position */
501e4e70 1211
3bafb436 1212 /* 3.3.1 Find lowest end position in list_in */
1213 GSList *iter;
6ea08962 1214
3bafb436 1215 end_position =((EventsRequest*)g_slist_nth_data(list_in,0))->end_position;
6ea08962 1216
3bafb436 1217 for(iter=g_slist_nth(list_in,1);iter!=NULL;iter=g_slist_next(iter)) {
1218 EventsRequest *events_request = (EventsRequest*)iter->data;
dd316a11 1219
3bafb436 1220 if(events_request->end_position != NULL && end_position != NULL &&
1221 lttv_traceset_context_pos_pos_compare(events_request->end_position,
1222 end_position) <0)
1223 end_position = events_request->end_position;
1224 }
1225 }
1226
1227 {
1228 /* 3.3.2 Find lowest start position in list_out */
1229 GSList *iter;
dd316a11 1230
3bafb436 1231 for(iter=list_out;iter!=NULL;iter=g_slist_next(iter)) {
1232 EventsRequest *events_request = (EventsRequest*)iter->data;
dd316a11 1233
3bafb436 1234 if(events_request->end_position != NULL && end_position != NULL &&
1235 lttv_traceset_context_pos_pos_compare(events_request->end_position,
1236 end_position) <0)
1237 end_position = events_request->end_position;
dd316a11 1238 }
2d262115 1239 }
3bafb436 1240
2d262115 1241 {
3bafb436 1242 /* 4. Call process traceset middle */
2eef04b5 1243 g_debug("Calling process traceset middle with %p, %lu sec %lu nsec, %u nb ev, %p end pos", tsc, end_time.tv_sec, end_time.tv_nsec, end_nb_events, end_position);
3bafb436 1244 count = lttv_process_traceset_middle(tsc, end_time, end_nb_events, end_position);
2d262115 1245
3bafb436 1246 tfc = lttv_traceset_context_get_current_tfc(tsc);
1247 if(tfc != NULL)
1248 g_debug("Context time after middle : %lu, %lu", tfc->timestamp.tv_sec,
1249 tfc->timestamp.tv_nsec);
1250 else
1251 g_debug("End of trace reached after middle.");
2d262115 1252
3bafb436 1253 }
1254 {
1255 /* 5. After process traceset middle */
1256 tfc = lttv_traceset_context_get_current_tfc(tsc);
1257
1258 /* - if current context time > traceset.end time */
1259 if(tfc == NULL || ltt_time_compare(tfc->timestamp,
1260 tsc->time_span.end_time) > 0) {
1261 /* - For each req in list_in */
1262 GSList *iter = list_in;
1263
1264 while(iter != NULL) {
1265
1266 gboolean remove = FALSE;
1267 gboolean free_data = FALSE;
1268 EventsRequest *events_request = (EventsRequest *)iter->data;
1269
1270 /* - Remove events hooks for req
1271 * - Call end chunk for req
1272 */
54d8f654 1273
1274 if(events_request->trace == -1)
1275 lttv_process_traceset_end(tsc,
1276 events_request->after_chunk_traceset,
3bafb436 1277 events_request->after_chunk_trace,
1278 events_request->after_chunk_tracefile,
1279 events_request->event,
750eb11a 1280 events_request->event_by_id_channel);
54d8f654 1281
1282 else {
1283 guint nb_trace = lttv_traceset_number(tsc->ts);
1284 g_assert(events_request->trace < nb_trace &&
1285 events_request->trace > -1);
1286 LttvTraceContext *tc = tsc->traces[events_request->trace];
1287
1288 lttv_trace_context_remove_hooks(tc,
1289 events_request->after_chunk_trace,
1290 events_request->after_chunk_tracefile,
1291 events_request->event,
750eb11a 1292 events_request->event_by_id_channel);
54d8f654 1293 lttv_hooks_call(events_request->after_chunk_traceset, tsc);
1294
1295
1296 }
1297
3bafb436 1298 /* - Call end request for req */
6ea08962 1299 lttv_hooks_call(events_request->after_request, (gpointer)tsc);
3bafb436 1300
2d262115 1301 /* - remove req from list_in */
1302 /* Destroy the request */
1303 remove = TRUE;
1304 free_data = TRUE;
3bafb436 1305
1306 /* Go to next */
1307 if(remove)
1308 {
1309 GSList *remove_iter = iter;
1310
1311 iter = g_slist_next(iter);
1312 if(free_data) events_request_free((EventsRequest*)remove_iter->data);
1313 list_in = g_slist_remove_link(list_in, remove_iter);
1314 } else { // not remove
1315 iter = g_slist_next(iter);
1316 }
2d262115 1317 }
3bafb436 1318 }
1319 {
1320 /* 5.1 For each req in list_in */
1321 GSList *iter = list_in;
1322
1323 while(iter != NULL) {
501e4e70 1324
3bafb436 1325 gboolean remove = FALSE;
1326 gboolean free_data = FALSE;
1327 EventsRequest *events_request = (EventsRequest *)iter->data;
1328
1329 /* - Remove events hooks for req
1330 * - Call end chunk for req
1331 */
54d8f654 1332 if(events_request->trace == -1)
1333 lttv_process_traceset_end(tsc,
1334 events_request->after_chunk_traceset,
3bafb436 1335 events_request->after_chunk_trace,
1336 events_request->after_chunk_tracefile,
1337 events_request->event,
750eb11a 1338 events_request->event_by_id_channel);
3bafb436 1339
54d8f654 1340 else {
1341 guint nb_trace = lttv_traceset_number(tsc->ts);
1342 g_assert(events_request->trace < nb_trace &&
1343 events_request->trace > -1);
1344 LttvTraceContext *tc = tsc->traces[events_request->trace];
1345
1346 lttv_trace_context_remove_hooks(tc,
1347 events_request->after_chunk_trace,
1348 events_request->after_chunk_tracefile,
1349 events_request->event,
750eb11a 1350 events_request->event_by_id_channel);
54d8f654 1351
1352 lttv_hooks_call(events_request->after_chunk_traceset, tsc);
1353 }
1354
3bafb436 1355 /* - req.num -= count */
1356 g_assert(events_request->num_events >= count);
1357 events_request->num_events -= count;
1358
1359 g_assert(tfc != NULL);
1360 /* - if req.num == 0
1361 * or
1362 * current context time >= req.end time
1363 * or
1364 * req.end pos == current pos
1365 * or
1366 * req.stop_flag == TRUE
1367 */
1368 if( events_request->num_events == 0
1369 ||
1370 events_request->stop_flag == TRUE
1371 ||
1372 ltt_time_compare(tfc->timestamp,
1373 events_request->end_time) >= 0
1374 ||
1375 (events_request->end_position != NULL
1376 &&
1377 lttv_traceset_context_ctx_pos_compare(tsc,
1378 events_request->end_position) == 0)
1379
1380 ) {
1381 g_assert(events_request->servicing == TRUE);
1382 /* - Call end request for req
1383 * - remove req from list_in */
1384 lttv_hooks_call(events_request->after_request, (gpointer)tsc);
1385 /* - remove req from list_in */
1386 /* Destroy the request */
1387 remove = TRUE;
1388 free_data = TRUE;
1389 }
1390
1391 /* Go to next */
1392 if(remove)
1393 {
1394 GSList *remove_iter = iter;
1395
1396 iter = g_slist_next(iter);
1397 if(free_data) events_request_free((EventsRequest*)remove_iter->data);
1398 list_in = g_slist_remove_link(list_in, remove_iter);
1399 } else { // not remove
1400 iter = g_slist_next(iter);
1401 }
2d262115 1402 }
1403 }
1404 }
501e4e70 1405 }
dd316a11 1406 /* End of removed servicing loop : leave control to GTK instead. */
1407 // if(gtk_events_pending()) break;
1408 //}
1409
2d262115 1410 /* B. When interrupted between chunks */
501e4e70 1411
501e4e70 1412 {
1413 GSList *iter = list_in;
1414
2d262115 1415 /* 1. for each request in list_in */
501e4e70 1416 while(iter != NULL) {
1417
1418 gboolean remove = FALSE;
1419 gboolean free_data = FALSE;
2d262115 1420 EventsRequest *events_request = (EventsRequest *)iter->data;
501e4e70 1421
1422 /* 1.1. Use current postition as start position */
a1a2b649 1423 if(events_request->start_position != NULL)
1424 lttv_traceset_context_position_destroy(events_request->start_position);
8e680509 1425 events_request->start_position = lttv_traceset_context_position_new(tsc);
501e4e70 1426 lttv_traceset_context_position_save(tsc, events_request->start_position);
1427
1428 /* 1.2. Remove start time */
0aa6c3a1 1429 events_request->start_time = ltt_time_infinite;
501e4e70 1430
2d262115 1431 /* 1.3. Move from list_in to list_out */
501e4e70 1432 remove = TRUE;
1433 free_data = FALSE;
1434 list_out = g_slist_append(list_out, events_request);
1435
501e4e70 1436 /* Go to next */
1437 if(remove)
8f2872f4 1438 {
501e4e70 1439 GSList *remove_iter = iter;
1440
1441 iter = g_slist_next(iter);
b052368a 1442 if(free_data) events_request_free((EventsRequest*)remove_iter->data);
501e4e70 1443 list_in = g_slist_remove_link(list_in, remove_iter);
1444 } else { // not remove
1445 iter = g_slist_next(iter);
8f2872f4 1446 }
1447 }
a43d67ba 1448
501e4e70 1449
1450 }
b052368a 1451 /* C Unlock Traces */
1452 {
088f6772 1453 lttv_process_traceset_get_sync_data(tsc);
1454 //lttv_traceset_context_position_save(tsc, sync_position);
b052368a 1455
1456 guint iter_trace;
1457
1458 for(iter_trace=0;
1459 iter_trace<lttv_traceset_number(tsc->ts);
1460 iter_trace++) {
1461 LttvTrace *trace_v = lttv_traceset_get(tsc->ts, iter_trace);
1462
1463 lttvwindowtraces_unlock(trace_v);
1464 }
1465 }
a0577796 1466#if 0
abe346a3 1467 //set the cursor back to normal
a8c0f09d 1468 gdk_window_set_cursor(win, NULL);
a0577796 1469#endif //0
501e4e70 1470
2d262115 1471 g_assert(g_slist_length(list_in) == 0);
6ea08962 1472
2d262115 1473 if( g_slist_length(list_out) == 0 ) {
501e4e70 1474 /* Put tab's request pending flag back to normal */
2d262115 1475 tab->events_request_pending = FALSE;
b052368a 1476 g_debug("remove the idle fct");
501e4e70 1477 return FALSE; /* Remove the idle function */
1478 }
b052368a 1479 g_debug("leave the idle fct");
501e4e70 1480 return TRUE; /* Leave the idle function */
b052368a 1481
1482 /* We do not use simili-round-robin, it may require to read 1 meg buffers
1483 * again and again if many tracesets use the same tracefiles. */
1484 /* Hack for round-robin idle functions */
1485 /* It will put the idle function at the end of the pool */
1486 /*g_idle_add_full((G_PRIORITY_HIGH_IDLE + 21),
1487 (GSourceFunc)execute_events_requests,
1488 tab,
1489 NULL);
1490 return FALSE;
1491 */
451aaf27
FD
1492
1493 #endif /* BABEL_CLEANUP */
202f6c8f 1494}
1495
6ea08962 1496#undef list_out
1e3594a3
YB
1497/**
1498 Manage the periodic update of a live trace
1499*/
1500static gboolean
1501live_trace_update_handler(Tab *tab)
1502{
451aaf27 1503#ifdef BABEL_CLEANUP
9a366873 1504 unsigned int updated_count;
1e3594a3
YB
1505 LttvTracesetContext *tsc = LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context);
1506 TimeInterval initial_time_span = tsc->time_span;
1507 TimeInterval updated_time_span;
1508
1509 updated_count = lttv_process_traceset_update(tsc);
1510
1511 /* TODO ybrosseau 2011-01-12: Add trace resynchronization */
501e4e70 1512
1e3594a3
YB
1513 /* Get the changed period bounds */
1514 updated_time_span = tsc->time_span;
1515
1516 if(ltt_time_compare(updated_time_span.start_time,
1517 initial_time_span.start_time) != 0) {
1518 /* The initial time should not change on a live update */
1519 g_assert(FALSE);
1520 }
1521
1522 /* Notify viewers (only on updates) */
1523 if(ltt_time_compare(updated_time_span.end_time,
1524 initial_time_span.end_time) != 0) {
1525
1526 notify_time_span_changed(tab);
1527 /* TODO ybrosseau 2011-01-12: Change the timebar to register
1528 to the time_span hook */
1529 timebar_set_minmax_time(TIMEBAR(tab->MTimebar),
1530 &updated_time_span.start_time,
1531 &updated_time_span.end_time );
1532
1533 /* To update the min max */
1534 time_change_manager(tab, tab->time_window);
1535 }
1536
1537 /* Timer will be recalled as long as there is files to update */
1538 return (updated_count > 0);
451aaf27 1539#endif /* BABEL_CLEANUP */
1e3594a3 1540}
abe346a3 1541
4266dc7f 1542static void lttvwindow_add_trace(Tab *tab, LttvTrace *trace_v)
1543{
9a366873 1544#ifdef BABEL_CLEANUP
4266dc7f 1545 LttvTraceset *traceset = tab->traceset_info->traceset;
1546 guint i;
91fd6881 1547 guint num_traces = lttv_traceset_number(traceset);
4266dc7f 1548
a1a2b649 1549 //Verify if trace is already present.
91fd6881 1550 for(i=0; i<num_traces; i++)
a1a2b649 1551 {
1552 LttvTrace * trace = lttv_traceset_get(traceset, i);
1553 if(trace == trace_v)
1554 return;
1555 }
1556
4266dc7f 1557 //Keep a reference to the traces so they are not freed.
1558 for(i=0; i<lttv_traceset_number(traceset); i++)
1559 {
1560 LttvTrace * trace = lttv_traceset_get(traceset, i);
1561 lttv_trace_ref(trace);
1562 }
1563
1564 //remove state update hooks
1565 lttv_state_remove_event_hooks(
1566 (LttvTracesetState*)tab->traceset_info->traceset_context);
1567
1568 lttv_context_fini(LTTV_TRACESET_CONTEXT(
1569 tab->traceset_info->traceset_context));
1570 g_object_unref(tab->traceset_info->traceset_context);
1571
1572 lttv_traceset_add(traceset, trace_v);
a1a2b649 1573 lttv_trace_ref(trace_v); /* local ref */
4266dc7f 1574
1575 /* Create new context */
1576 tab->traceset_info->traceset_context =
1577 g_object_new(LTTV_TRACESET_STATS_TYPE, NULL);
1578 lttv_context_init(
1579 LTTV_TRACESET_CONTEXT(tab->traceset_info->
1580 traceset_context),
1581 traceset);
6ea08962 1582
6ea08962 1583
4266dc7f 1584 //add state update hooks
1585 lttv_state_add_event_hooks(
1586 (LttvTracesetState*)tab->traceset_info->traceset_context);
1587 //Remove local reference to the traces.
1588 for(i=0; i<lttv_traceset_number(traceset); i++)
1589 {
1590 LttvTrace * trace = lttv_traceset_get(traceset, i);
1591 lttv_trace_unref(trace);
1592 }
1593
b052368a 1594 //FIXME
1595 //add_trace_into_traceset_selector(GTK_MULTIVPANED(tab->multivpaned), lttv_trace(trace_v));
1e3594a3
YB
1596
1597
1598 if (lttv_trace(trace_v)->is_live) {
1599 /* Add timer for live update */
1600 /* TODO ybrosseau 2011-01-12: Parametrize the hardcoded 1 seconds */
1601 g_timeout_add_seconds (1,
1602 (GSourceFunc) live_trace_update_handler,
1603 tab);
1604 }
451aaf27 1605#endif /* BABEL_CLEANUP */
4266dc7f 1606}
1607
abe346a3 1608/* add_trace adds a trace into the current traceset. It first displays a
1609 * directory selection dialogue to let user choose a trace, then recreates
1610 * tracset_context, and redraws all the viewer of the current tab
1611 */
1612
561eba2a 1613void add_trace(GtkWidget * widget, gpointer user_data)
1614{
861fbe5f 1615
deb3d2f8 1616 LttvTraceset * traceset = NULL;
861fbe5f 1617 const char * path;
a1a2b649 1618 char abs_path[PATH_MAX];
2176f952 1619 gint id;
bca3b81f 1620 MainWindow * mw_data = get_window_data_struct(widget);
6ced96ef 1621 GtkWidget * notebook = lookup_widget(widget, "MNotebook");
1622
1623 GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook),
1624 gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)));
e433e6d6 1625 LttvPluginTab *ptab;
6ced96ef 1626 Tab *tab;
1627
1628 if(!page) {
e433e6d6 1629 ptab = create_new_tab(widget, NULL);
1630 tab = ptab->tab;
6ced96ef 1631 } else {
e433e6d6 1632 ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin");
1633 tab = ptab->tab;
6ced96ef 1634 }
1167062f 1635//TODO fdeslauriers 2012-07-06: Remove this popup when we support multiple traces
deb3d2f8 1636 traceset = lttvwindow_get_traceset(tab);
95544594 1637 if(traceset != NULL && lttv_traceset_number(traceset) > 0){
deb3d2f8
FD
1638 GtkWidget *dialogue =
1639 gtk_message_dialog_new(
1640 GTK_WINDOW(gtk_widget_get_toplevel(widget)),
1641 GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
1642 GTK_MESSAGE_ERROR,
1643 GTK_BUTTONS_OK,
1644 "Loading multiple traces is not supported at the moment.");
1645 gtk_dialog_run(GTK_DIALOG(dialogue));
1646 gtk_widget_destroy(dialogue);
1647 return;
1648 }
1649
861fbe5f
FD
1650 /* Create a new traceset*/
1651 traceset = lttv_traceset_new();
ba013432 1652 /* File open dialog management */
95544594
FD
1653#ifdef BABEL_CLEANUP
1654 GtkWidget *extra_live_button;
1655#endif //babel_cleanup
ba013432
MD
1656 GtkFileChooser * file_chooser =
1657 GTK_FILE_CHOOSER(
1658 gtk_file_chooser_dialog_new ("Select a trace",
1659 GTK_WINDOW(mw_data->mwindow),
1660 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
1661 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
1662 GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
861fbe5f 1663 NULL));
95544594 1664#ifdef BABEL_CLEANUP
1e3594a3
YB
1665 /* Button to indicate the opening of a live trace */
1666 extra_live_button = gtk_check_button_new_with_mnemonic ("Trace is live (currently being writen)");
1667 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (extra_live_button), FALSE);
1668 gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (file_chooser), extra_live_button);
95544594 1669#endif //babel_cleanup
ba013432 1670 gtk_file_chooser_set_show_hidden (file_chooser, TRUE);
3658a338 1671 if(remember_trace_dir[0] != '\0')
ba013432
MD
1672 gtk_file_chooser_set_filename(file_chooser, remember_trace_dir);
1673
861fbe5f 1674 gboolean closeFileChooserDialog = TRUE;
1e3594a3 1675
861fbe5f
FD
1676 do
1677 {
1678 id = gtk_dialog_run(GTK_DIALOG(file_chooser));
1679 switch(id){
1680 case GTK_RESPONSE_ACCEPT:
1681 case GTK_RESPONSE_OK:
1682 path = gtk_file_chooser_get_filename (file_chooser);
1683
1684 strncpy(remember_trace_dir, path, PATH_MAX);
1685 strncat(remember_trace_dir, "/", PATH_MAX);
1686 if(!path || strlen(path) == 0){
1687 break;
1e3594a3 1688 }
861fbe5f
FD
1689 get_absolute_pathname(path, abs_path);
1690
1691 if(lttv_traceset_add_path(traceset,abs_path) != 0 ){ /*failure*/
49bf71b5 1692
861fbe5f
FD
1693 g_warning("cannot open trace %s", abs_path);
1694 strncpy(remember_trace_dir, "\0", PATH_MAX);
1695 GtkWidget *dialogue =
1696 gtk_message_dialog_new(
1697 GTK_WINDOW(gtk_widget_get_toplevel(widget)),
1698 GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
1699 GTK_MESSAGE_ERROR,
1700 GTK_BUTTONS_OK,
1701 "Cannot open trace : maybe you should enter in the directory "
1702 "to select it ?");
1703 gtk_dialog_run(GTK_DIALOG(dialogue));
1704 gtk_widget_destroy(dialogue);
1705 closeFileChooserDialog = FALSE;
1706 }
1707 else{
1708 closeFileChooserDialog = TRUE;
1709 SetTraceset(tab, traceset);
1710 }
1711 break;
1712 //update current tab
1713 //update_traceset(mw_data);
21e8c385 1714
861fbe5f
FD
1715 // in expose now call_pending_read_hooks(mw_data);
1716
1717 //lttvwindow_report_current_time(mw_data,&(tab->current_time));
a43d67ba 1718
861fbe5f
FD
1719 case GTK_RESPONSE_REJECT:
1720 case GTK_RESPONSE_CANCEL:
1721 default:
1722 closeFileChooserDialog = TRUE;
1723 break;
1724 }
1725 }while(!closeFileChooserDialog);
451aaf27 1726
861fbe5f 1727 gtk_widget_destroy((GtkWidget*)file_chooser);
ba013432 1728
49bf71b5 1729}
1730
abe346a3 1731/* remove_trace removes a trace from the current traceset if all viewers in
1732 * the current tab are not interested in the trace. It first displays a
1733 * dialogue, which shows all traces in the current traceset, to let user choose
1734 * a trace, then it checks if all viewers unselect the trace, if it is true,
1735 * it will remove the trace, recreate the traceset_contex,
1736 * and redraws all the viewer of the current tab. If there is on trace in the
1737 * current traceset, it will delete all viewers of the current tab
3a5f75c1 1738 *
1739 * It destroys the filter tree. FIXME... we should request for an update
1740 * instead.
abe346a3 1741 */
1742
b052368a 1743void remove_trace(GtkWidget *widget, gpointer user_data)
1744{
9a366873 1745#ifdef BABEL_CLEANUP
b052368a 1746 LttTrace *trace;
1747 LttvTrace * trace_v;
1748 LttvTraceset * traceset;
1749 gint i, j, nb_trace, index=-1;
1750 char ** name, *remove_trace_name;
1751 MainWindow * mw_data = get_window_data_struct(widget);
1752 GtkWidget * notebook = lookup_widget(widget, "MNotebook");
1753
1754 GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook),
1755 gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)));
1756 Tab *tab;
1757
1758 if(!page) {
1759 return;
1760 } else {
e433e6d6 1761 LttvPluginTab *ptab;
1762 ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin");
1763 tab = ptab->tab;
b052368a 1764 }
1765
1766 nb_trace =lttv_traceset_number(tab->traceset_info->traceset);
1767 name = g_new(char*,nb_trace);
1768 for(i = 0; i < nb_trace; i++){
1769 trace_v = lttv_traceset_get(tab->traceset_info->traceset, i);
1770 trace = lttv_trace(trace_v);
8d8c5ea7 1771 name[i] = (char *) g_quark_to_string(ltt_trace_name(trace));
b052368a 1772 }
1773
93ac601b 1774 remove_trace_name = get_remove_trace(mw_data, name, nb_trace);
b052368a 1775
1776
1777 if(remove_trace_name){
1778
1779 /* yuk, cut n paste from old code.. should be better (MD)*/
1780 for(i = 0; i<nb_trace; i++) {
1781 if(strcmp(remove_trace_name,name[i]) == 0){
1782 index = i;
1783 }
1784 }
1785
1786 traceset = tab->traceset_info->traceset;
1787 //Keep a reference to the traces so they are not freed.
1788 for(j=0; j<lttv_traceset_number(traceset); j++)
1789 {
1790 LttvTrace * trace = lttv_traceset_get(traceset, j);
1791 lttv_trace_ref(trace);
1792 }
1793
1794 //remove state update hooks
1795 lttv_state_remove_event_hooks(
1796 (LttvTracesetState*)tab->traceset_info->traceset_context);
1797 lttv_context_fini(LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context));
1798 g_object_unref(tab->traceset_info->traceset_context);
1799
1800 trace_v = lttv_traceset_get(traceset, index);
1801
b052368a 1802 lttv_traceset_remove(traceset, index);
1803 lttv_trace_unref(trace_v); // Remove local reference
1804
d27948a3 1805 if(lttv_trace_get_ref_number(trace_v) <= 1) {
1ba187d3 1806 /* ref 1 : lttvwindowtraces only*/
1807 ltt_trace_close(lttv_trace(trace_v));
1808 /* lttvwindowtraces_remove_trace takes care of destroying
1809 * the traceset linked with the trace_v and also of destroying
1810 * the trace_v at the same time.
1811 */
d27948a3 1812 lttvwindowtraces_remove_trace(trace_v);
1813 }
b052368a 1814
1815 tab->traceset_info->traceset_context =
1816 g_object_new(LTTV_TRACESET_STATS_TYPE, NULL);
1817 lttv_context_init(
1818 LTTV_TRACESET_CONTEXT(tab->
1819 traceset_info->traceset_context),traceset);
1820 //add state update hooks
1821 lttv_state_add_event_hooks(
1822 (LttvTracesetState*)tab->traceset_info->traceset_context);
1823
1824 //Remove local reference to the traces.
1825 for(j=0; j<lttv_traceset_number(traceset); j++)
1826 {
1827 LttvTrace * trace = lttv_traceset_get(traceset, j);
1828 lttv_trace_unref(trace);
1829 }
1830
1831 SetTraceset(tab, (gpointer)traceset);
1832 }
1833 g_free(name);
451aaf27 1834#endif /* BABEL_CLEANUP */
b052368a 1835}
1836
1837#if 0
561eba2a 1838void remove_trace(GtkWidget * widget, gpointer user_data)
1839{
2176f952 1840 LttTrace *trace;
1841 LttvTrace * trace_v;
1842 LttvTraceset * traceset;
a43d67ba 1843 gint i, j, nb_trace;
2176f952 1844 char ** name, *remove_trace_name;
bca3b81f 1845 MainWindow * mw_data = get_window_data_struct(widget);
49bf71b5 1846 LttvTracesetSelector * s;
1847 LttvTraceSelector * t;
1848 GtkWidget * w;
1849 gboolean selected;
6ced96ef 1850 GtkWidget * notebook = lookup_widget(widget, "MNotebook");
1851
1852 GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook),
1853 gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)));
1854 Tab *tab;
1855
1856 if(!page) {
1857 return;
1858 } else {
1859 tab = (Tab *)g_object_get_data(G_OBJECT(page), "Tab_Info");
1860 }
1861
4266dc7f 1862 nb_trace =lttv_traceset_number(tab->traceset_info->traceset);
2176f952 1863 name = g_new(char*,nb_trace);
1864 for(i = 0; i < nb_trace; i++){
4266dc7f 1865 trace_v = lttv_traceset_get(tab->traceset_info->traceset, i);
2176f952 1866 trace = lttv_trace(trace_v);
a5dcde2f 1867 name[i] = ltt_trace_name(trace);
2176f952 1868 }
1869
1870 remove_trace_name = get_remove_trace(name, nb_trace);
1871
1872 if(remove_trace_name){
1873 for(i=0; i<nb_trace; i++){
1874 if(strcmp(remove_trace_name,name[i]) == 0){
6ced96ef 1875 //unselect the trace from the current viewer
b052368a 1876 //FIXME
1877 w = gtk_multivpaned_get_widget(GTK_MULTIVPANED(tab->multivpaned));
6ced96ef 1878 if(w){
1879 s = g_object_get_data(G_OBJECT(w), "Traceset_Selector");
1880 if(s){
1881 t = lttv_traceset_selector_trace_get(s,i);
1882 lttv_trace_selector_set_selected(t, FALSE);
1883 }
1884
1885 //check if other viewers select the trace
b052368a 1886 w = gtk_multivpaned_get_first_widget(GTK_MULTIVPANED(tab->multivpaned));
6ced96ef 1887 while(w){
1888 s = g_object_get_data(G_OBJECT(w), "Traceset_Selector");
1889 if(s){
1890 t = lttv_traceset_selector_trace_get(s,i);
1891 selected = lttv_trace_selector_get_selected(t);
1892 if(selected)break;
1893 }
b052368a 1894 w = gtk_multivpaned_get_next_widget(GTK_MULTIVPANED(tab->multivpaned));
6ced96ef 1895 }
1896 }else selected = FALSE;
49bf71b5 1897
6ced96ef 1898 //if no viewer selects the trace, remove it
1899 if(!selected){
b052368a 1900 remove_trace_from_traceset_selector(GTK_MULTIVPANED(tab->multivpaned), i);
49bf71b5 1901
6ced96ef 1902 traceset = tab->traceset_info->traceset;
1903 //Keep a reference to the traces so they are not freed.
1904 for(j=0; j<lttv_traceset_number(traceset); j++)
1905 {
1906 LttvTrace * trace = lttv_traceset_get(traceset, j);
1907 lttv_trace_ref(trace);
1908 }
a43d67ba 1909
6ced96ef 1910 //remove state update hooks
1911 lttv_state_remove_event_hooks(
1912 (LttvTracesetState*)tab->traceset_info->traceset_context);
1913 lttv_context_fini(LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context));
1914 g_object_unref(tab->traceset_info->traceset_context);
a43d67ba 1915
a43d67ba 1916
6ced96ef 1917 trace_v = lttv_traceset_get(traceset, i);
a43d67ba 1918
a1a2b649 1919 if(lttv_trace_get_ref_number(trace_v) <= 2) {
1920 /* ref 2 : traceset, local */
1921 lttvwindowtraces_remove_trace(trace_v);
6ced96ef 1922 ltt_trace_close(lttv_trace(trace_v));
a1a2b649 1923 }
6ced96ef 1924
1925 lttv_traceset_remove(traceset, i);
1926 lttv_trace_unref(trace_v); // Remove local reference
c2619a30 1927
6ced96ef 1928 if(!lttv_trace_get_ref_number(trace_v))
1929 lttv_trace_destroy(trace_v);
1930
1931 tab->traceset_info->traceset_context =
1932 g_object_new(LTTV_TRACESET_STATS_TYPE, NULL);
1933 lttv_context_init(
1934 LTTV_TRACESET_CONTEXT(tab->
1935 traceset_info->traceset_context),traceset);
1936 //add state update hooks
1937 lttv_state_add_event_hooks(
1938 (LttvTracesetState*)tab->traceset_info->traceset_context);
1939
1940 //Remove local reference to the traces.
1941 for(j=0; j<lttv_traceset_number(traceset); j++)
1942 {
1943 LttvTrace * trace = lttv_traceset_get(traceset, j);
1944 lttv_trace_unref(trace);
1945 }
a43d67ba 1946
a43d67ba 1947
6ced96ef 1948 //update current tab
1949 //update_traceset(mw_data);
313bd6fc 1950 //if(nb_trace > 1){
6ced96ef 1951
313bd6fc 1952 SetTraceset(tab, (gpointer)traceset);
6ced96ef 1953 // in expose now call_pending_read_hooks(mw_data);
1954
1955 //lttvwindow_report_current_time(mw_data,&(tab->current_time));
313bd6fc 1956 //}else{
1957 // if(tab){
1958 // while(tab->multi_vpaned->num_children){
1959 // gtk_multi_vpaned_widget_delete(tab->multi_vpaned);
1960 // }
1961 // }
1962 //}
6ced96ef 1963 }
1964 break;
2176f952 1965 }
1966 }
1967 }
1968
1969 g_free(name);
561eba2a 1970}
b052368a 1971#endif //0
abe346a3 1972
9878c8a4 1973/* Redraw all the viewers in the current tab */
1974void redraw(GtkWidget *widget, gpointer user_data)
1975{
1976 GtkWidget * notebook = lookup_widget(widget, "MNotebook");
1977 GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook),
1978 gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)));
1979 Tab *tab;
8f318283
BP
1980 gboolean retval;
1981
9878c8a4 1982 if(!page) {
1983 return;
1984 } else {
e433e6d6 1985 LttvPluginTab *ptab;
1986 ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin");
1987 tab = ptab->tab;
9878c8a4 1988 }
1989
1990 LttvHooks * tmp;
1991 LttvAttributeValue value;
1992
8f318283
BP
1993 retval= lttv_iattribute_find_by_path(tab->attributes, "hooks/redraw", LTTV_POINTER, &value);
1994 g_assert(retval);
9878c8a4 1995
1996 tmp = (LttvHooks*)*(value.v_pointer);
c07e9b26 1997 if(tmp != NULL)
1998 lttv_hooks_call(tmp,NULL);
9878c8a4 1999}
2000
2001
2002void continue_processing(GtkWidget *widget, gpointer user_data)
2003{
2004 GtkWidget * notebook = lookup_widget(widget, "MNotebook");
2005 GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook),
2006 gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)));
2007 Tab *tab;
8f318283
BP
2008 gboolean retval;
2009
9878c8a4 2010 if(!page) {
2011 return;
2012 } else {
e433e6d6 2013 LttvPluginTab *ptab;
2014 ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin");
2015 tab = ptab->tab;
9878c8a4 2016 }
2017
2018 LttvHooks * tmp;
2019 LttvAttributeValue value;
2020
8f318283
BP
2021 retval= lttv_iattribute_find_by_path(tab->attributes, "hooks/continue",
2022 LTTV_POINTER, &value);
2023 g_assert(retval);
9878c8a4 2024
2025 tmp = (LttvHooks*)*(value.v_pointer);
c07e9b26 2026 if(tmp != NULL)
2027 lttv_hooks_call(tmp,NULL);
9878c8a4 2028}
2029
2030/* Stop the processing for the calling main window's current tab.
2031 * It removes every processing requests that are in its list. It does not call
2032 * the end request hooks, because the request is not finished.
2033 */
2034
2035void stop_processing(GtkWidget *widget, gpointer user_data)
2036{
2037 GtkWidget * notebook = lookup_widget(widget, "MNotebook");
2038 GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook),
2039 gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)));
2040 Tab *tab;
2041 if(!page) {
2042 return;
2043 } else {
e433e6d6 2044 LttvPluginTab *ptab;
2045 ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin");
2046 tab = ptab->tab;
9878c8a4 2047 }
a0577796 2048 GSList *iter = tab->events_requests;
9878c8a4 2049
2050 while(iter != NULL) {
2051 GSList *remove_iter = iter;
2052 iter = g_slist_next(iter);
2053
2054 g_free(remove_iter->data);
a0577796 2055 tab->events_requests =
2056 g_slist_remove_link(tab->events_requests, remove_iter);
9878c8a4 2057 }
a0577796 2058 tab->events_request_pending = FALSE;
5698740e 2059 tab->stop_foreground = TRUE;
a0577796 2060 g_idle_remove_by_data(tab);
2061 g_assert(g_slist_length(tab->events_requests) == 0);
9878c8a4 2062}
2063
2064
abe346a3 2065/* save will save the traceset to a file
a43d67ba 2066 * Not implemented yet FIXME
abe346a3 2067 */
2068
561eba2a 2069void save(GtkWidget * widget, gpointer user_data)
2070{
56e5a0f7 2071 g_info("Save\n");
561eba2a 2072}
2073
2074void save_as(GtkWidget * widget, gpointer user_data)
2075{
56e5a0f7 2076 g_info("Save as\n");
561eba2a 2077}
2078
abe346a3 2079
2080/* zoom will change the time_window of all the viewers of the
2081 * current tab, and redisplay them. The main functionality is to
2082 * determine the new time_window of the current tab
2083 */
2084
1f1ae829 2085void zoom(GtkWidget * widget, double size)
2086{
9a366873 2087#ifdef BABEL_CLEANUP
b052368a 2088 TimeInterval time_span;
a43d67ba 2089 TimeWindow new_time_window;
2eef04b5 2090 LttTime current_time, time_delta;
4266dc7f 2091 LttvTracesetContext *tsc;
6ced96ef 2092 GtkWidget * notebook = lookup_widget(widget, "MNotebook");
2093
2094 GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook),
2095 gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)));
2096 Tab *tab;
2097
2098 if(!page) {
2099 return;
2100 } else {
e433e6d6 2101 LttvPluginTab *ptab;
2102 ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin");
2103 tab = ptab->tab;
6ced96ef 2104 }
1f1ae829 2105
fda16332 2106 if(size == 1) return;
2107
4266dc7f 2108 tsc = LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context);
b052368a 2109 time_span = tsc->time_span;
501e4e70 2110 new_time_window = tab->time_window;
2111 current_time = tab->current_time;
1f1ae829 2112
b052368a 2113 time_delta = ltt_time_sub(time_span.end_time,time_span.start_time);
1f1ae829 2114 if(size == 0){
b052368a 2115 new_time_window.start_time = time_span.start_time;
a43d67ba 2116 new_time_window.time_width = time_delta;
a18124ff 2117 new_time_window.time_width_double = ltt_time_to_double(time_delta);
6f26fc38 2118 new_time_window.end_time = ltt_time_add(new_time_window.start_time,
2119 new_time_window.time_width) ;
1f1ae829 2120 }else{
a43d67ba 2121 new_time_window.time_width = ltt_time_div(new_time_window.time_width, size);
a18124ff 2122 new_time_window.time_width_double =
2123 ltt_time_to_double(new_time_window.time_width);
a43d67ba 2124 if(ltt_time_compare(new_time_window.time_width,time_delta) > 0)
2125 { /* Case where zoom out is bigger than trace length */
b052368a 2126 new_time_window.start_time = time_span.start_time;
a43d67ba 2127 new_time_window.time_width = time_delta;
a18124ff 2128 new_time_window.time_width_double = ltt_time_to_double(time_delta);
6f26fc38 2129 new_time_window.end_time = ltt_time_add(new_time_window.start_time,
2130 new_time_window.time_width) ;
a8c0f09d 2131 }
a43d67ba 2132 else
2133 {
2134 /* Center the image on the current time */
a43d67ba 2135 new_time_window.start_time =
a18124ff 2136 ltt_time_sub(current_time,
2137 ltt_time_from_double(new_time_window.time_width_double/2.0));
6f26fc38 2138 new_time_window.end_time = ltt_time_add(new_time_window.start_time,
2139 new_time_window.time_width) ;
a43d67ba 2140 /* If on borders, don't fall off */
9e494e53 2141 if(ltt_time_compare(new_time_window.start_time, time_span.start_time) <0
2142 || ltt_time_compare(new_time_window.start_time, time_span.end_time) >0)
a43d67ba 2143 {
b052368a 2144 new_time_window.start_time = time_span.start_time;
6f26fc38 2145 new_time_window.end_time = ltt_time_add(new_time_window.start_time,
2146 new_time_window.time_width) ;
a43d67ba 2147 }
2148 else
2149 {
6f26fc38 2150 if(ltt_time_compare(new_time_window.end_time,
9e494e53 2151 time_span.end_time) > 0
2152 || ltt_time_compare(new_time_window.end_time,
2153 time_span.start_time) < 0)
a43d67ba 2154 {
2155 new_time_window.start_time =
b052368a 2156 ltt_time_sub(time_span.end_time, new_time_window.time_width);
6f26fc38 2157
2158 new_time_window.end_time = ltt_time_add(new_time_window.start_time,
2159 new_time_window.time_width) ;
a43d67ba 2160 }
2161 }
2162
1f1ae829 2163 }
1f1ae829 2164 }
a43d67ba 2165
f02b5e22 2166 if(ltt_time_compare(new_time_window.time_width, ltt_time_zero) == 0) {
2167 g_warning("Zoom more than 1 ns impossible");
b052368a 2168 } else {
e800cf84 2169 time_change_manager(tab, new_time_window);
b052368a 2170 }
451aaf27
FD
2171
2172#endif /* BABEL_CLEANUP */
1f1ae829 2173}
2174
561eba2a 2175void zoom_in(GtkWidget * widget, gpointer user_data)
2176{
1f1ae829 2177 zoom(widget, 2);
561eba2a 2178}
2179
2180void zoom_out(GtkWidget * widget, gpointer user_data)
2181{
1f1ae829 2182 zoom(widget, 0.5);
561eba2a 2183}
2184
2185void zoom_extended(GtkWidget * widget, gpointer user_data)
2186{
1f1ae829 2187 zoom(widget, 0);
561eba2a 2188}
2189
2190void go_to_time(GtkWidget * widget, gpointer user_data)
2191{
56e5a0f7 2192 g_info("Go to time\n");
561eba2a 2193}
2194
2195void show_time_frame(GtkWidget * widget, gpointer user_data)
2196{
56e5a0f7 2197 g_info("Show time frame\n");
561eba2a 2198}
2199
2200
2201/* callback function */
2202
2203void
2204on_empty_traceset_activate (GtkMenuItem *menuitem,
2205 gpointer user_data)
2206{
68b48a45 2207 create_new_window((GtkWidget*)menuitem, user_data, FALSE);
561eba2a 2208}
2209
2210
2211void
2212on_clone_traceset_activate (GtkMenuItem *menuitem,
2213 gpointer user_data)
2214{
68b48a45 2215 create_new_window((GtkWidget*)menuitem, user_data, TRUE);
561eba2a 2216}
2217
abe346a3 2218
2219/* create_new_tab calls create_tab to construct a new tab in the main window
2220 */
2221
e433e6d6 2222LttvPluginTab *create_new_tab(GtkWidget* widget, gpointer user_data)
2223{
a1a2b649 2224 gchar label[PATH_MAX];
2901f314 2225 MainWindow * mw_data = get_window_data_struct(widget);
4266dc7f 2226
2901f314 2227 GtkNotebook * notebook = (GtkNotebook *)lookup_widget(widget, "MNotebook");
561eba2a 2228 if(notebook == NULL){
56e5a0f7 2229 g_info("Notebook does not exist\n");
6ced96ef 2230 return NULL;
2231 }
2232 GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook),
2233 gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)));
2234 Tab *copy_tab;
2235
2236 if(!page) {
2237 copy_tab = NULL;
2238 } else {
e433e6d6 2239 LttvPluginTab *ptab;
2240 ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin");
2241 copy_tab = ptab->tab;
561eba2a 2242 }
4266dc7f 2243
6b1d3120 2244 strcpy(label,"Page");
e433e6d6 2245 if(get_label(mw_data, label,"Get the name of the tab","Please input tab's name")) {
2246 LttvPluginTab *ptab;
2247
2248 ptab = g_object_new(LTTV_TYPE_PLUGIN_TAB, NULL);
2249 init_tab (ptab->tab, mw_data, copy_tab, notebook, label);
2250 ptab->parent.top_widget = ptab->tab->top_widget;
2251 g_object_set_data_full(
2252 G_OBJECT(ptab->tab->vbox),
2253 "Tab_Plugin",
2254 ptab,
2255 (GDestroyNotify)tab_destructor);
2256 return ptab;
2257 }
2258 else return NULL;
561eba2a 2259}
2260
2901f314 2261void
2262on_tab_activate (GtkMenuItem *menuitem,
2263 gpointer user_data)
2264{
2265 create_new_tab((GtkWidget*)menuitem, user_data);
2266}
2267
561eba2a 2268
2269void
2270on_open_activate (GtkMenuItem *menuitem,
2271 gpointer user_data)
2272{
e865422c 2273#ifdef UNFINISHED_FEATURE
561eba2a 2274 open_traceset((GtkWidget*)menuitem, user_data);
e865422c 2275#endif
561eba2a 2276}
2277
2278
2279void
2280on_close_activate (GtkMenuItem *menuitem,
2281 gpointer user_data)
2282{
bca3b81f 2283 MainWindow * mw_data = get_window_data_struct((GtkWidget*)menuitem);
68b48a45 2284 main_window_destructor(mw_data);
561eba2a 2285}
2286
2287
4266dc7f 2288/* remove the current tab from the main window
abe346a3 2289 */
2290
561eba2a 2291void
27a559b9 2292on_close_tab_activate (GtkWidget *widget,
561eba2a 2293 gpointer user_data)
2294{
4266dc7f 2295 gint page_num;
2061e03d 2296 GtkWidget * notebook;
27a559b9 2297 notebook = lookup_widget(widget, "MNotebook");
2061e03d 2298 if(notebook == NULL){
56e5a0f7 2299 g_info("Notebook does not exist\n");
2061e03d 2300 return;
2301 }
4266dc7f 2302
2303 page_num = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook));
2061e03d 2304
4266dc7f 2305 gtk_notebook_remove_page(GTK_NOTEBOOK(notebook), page_num);
2061e03d 2306
561eba2a 2307}
2308
27a559b9 2309void
2310on_close_tab_X_clicked (GtkWidget *widget,
2311 gpointer user_data)
2312{
2313 gint page_num;
2314 GtkWidget *notebook = lookup_widget(widget, "MNotebook");
2315 if(notebook == NULL){
56e5a0f7 2316 g_info("Notebook does not exist\n");
27a559b9 2317 return;
2318 }
2319
2320 if((page_num = gtk_notebook_page_num(GTK_NOTEBOOK(notebook), widget)) != -1)
2321 gtk_notebook_remove_page(GTK_NOTEBOOK(notebook), page_num);
2322
2323}
2324
561eba2a 2325
2326void
2327on_add_trace_activate (GtkMenuItem *menuitem,
2328 gpointer user_data)
2329{
2330 add_trace((GtkWidget*)menuitem, user_data);
2331}
2332
2333
2334void
2335on_remove_trace_activate (GtkMenuItem *menuitem,
2336 gpointer user_data)
2337{
2338 remove_trace((GtkWidget*)menuitem, user_data);
2339}
2340
2341
2342void
2343on_save_activate (GtkMenuItem *menuitem,
2344 gpointer user_data)
2345{
2346 save((GtkWidget*)menuitem, user_data);
2347}
2348
2349
2350void
2351on_save_as_activate (GtkMenuItem *menuitem,
2352 gpointer user_data)
2353{
2354 save_as((GtkWidget*)menuitem, user_data);
2355}
2356
2357
2358void
2359on_quit_activate (GtkMenuItem *menuitem,
2360 gpointer user_data)
2361{
6f9c921e 2362 while (g_slist_length(g_main_window_list) != 0) {
2363 on_MWindow_destroy(((MainWindow *)g_main_window_list->data)->mwindow,
2364 user_data);
2365 }
561eba2a 2366}
2367
2368
2369void
2370on_cut_activate (GtkMenuItem *menuitem,
2371 gpointer user_data)
2372{
56e5a0f7 2373 g_info("Cut\n");
561eba2a 2374}
2375
2376
2377void
2378on_copy_activate (GtkMenuItem *menuitem,
2379 gpointer user_data)
2380{
56e5a0f7 2381 g_info("Copye\n");
561eba2a 2382}
2383
2384
2385void
2386on_paste_activate (GtkMenuItem *menuitem,
2387 gpointer user_data)
2388{
56e5a0f7 2389 g_info("Paste\n");
561eba2a 2390}
2391
2392
2393void
2394on_delete_activate (GtkMenuItem *menuitem,
2395 gpointer user_data)
2396{
56e5a0f7 2397 g_info("Delete\n");
561eba2a 2398}
2399
2400
2401void
2402on_zoom_in_activate (GtkMenuItem *menuitem,
2403 gpointer user_data)
2404{
2405 zoom_in((GtkWidget*)menuitem, user_data);
2406}
2407
2408
2409void
2410on_zoom_out_activate (GtkMenuItem *menuitem,
2411 gpointer user_data)
2412{
2413 zoom_out((GtkWidget*)menuitem, user_data);
2414}
2415
2416
2417void
2418on_zoom_extended_activate (GtkMenuItem *menuitem,
2419 gpointer user_data)
2420{
2421 zoom_extended((GtkWidget*)menuitem, user_data);
2422}
2423
2424
2425void
2426on_go_to_time_activate (GtkMenuItem *menuitem,
2427 gpointer user_data)
2428{
2429 go_to_time((GtkWidget*)menuitem, user_data);
2430}
2431
2432
2433void
2434on_show_time_frame_activate (GtkMenuItem *menuitem,
2435 gpointer user_data)
2436{
2437 show_time_frame((GtkWidget*)menuitem, user_data);
2438}
2439
2440
2441void
2442on_move_viewer_up_activate (GtkMenuItem *menuitem,
2443 gpointer user_data)
2444{
2445 move_up_viewer((GtkWidget*)menuitem, user_data);
2446}
2447
2448
2449void
2450on_move_viewer_down_activate (GtkMenuItem *menuitem,
2451 gpointer user_data)
2452{
2453 move_down_viewer((GtkWidget*)menuitem, user_data);
2454}
2455
2456
2457void
2458on_remove_viewer_activate (GtkMenuItem *menuitem,
2459 gpointer user_data)
2460{
2461 delete_viewer((GtkWidget*)menuitem, user_data);
2462}
2463
49bf71b5 2464void
2465on_trace_facility_activate (GtkMenuItem *menuitem,
2466 gpointer user_data)
2467{
43ed82b5 2468 g_info("Trace facility selector: %s\n", "");
49bf71b5 2469}
561eba2a 2470
abe346a3 2471
b052368a 2472/* Dispaly a file selection dialogue to let user select a library, then call
2473 * lttv_library_load().
2474 */
2475
2476void
2477on_load_library_activate (GtkMenuItem *menuitem,
2478 gpointer user_data)
2479{
2480 GError *error = NULL;
2481 MainWindow * mw_data = get_window_data_struct((GtkWidget*)menuitem);
2482
2483 gchar load_module_path_alter[PATH_MAX];
2484 {
2485 GPtrArray *name;
2486 guint nb,i;
2487 gchar *load_module_path;
2488 name = g_ptr_array_new();
2489 nb = lttv_library_path_number();
2490 /* ask for the library path */
2491
2492 for(i=0;i<nb;i++){
2493 gchar *path;
2494 path = lttv_library_path_get(i);
2495 g_ptr_array_add(name, path);
2496 }
2497
93ac601b 2498 load_module_path = get_selection(mw_data,
2499 (char **)(name->pdata), name->len,
b052368a 2500 "Select a library path", "Library paths");
2501 if(load_module_path != NULL)
2502 strncpy(load_module_path_alter, load_module_path, PATH_MAX-1); // -1 for /
2503
2504 g_ptr_array_free(name, TRUE);
2505
2506 if(load_module_path == NULL) return;
2507 }
2508
2509 {
2510 /* Make sure the module path ends with a / */
2511 gchar *ptr = load_module_path_alter;
2512
2513 ptr = strchr(ptr, '\0');
2514
2515 if(*(ptr-1) != '/') {
2516 *ptr = '/';
2517 *(ptr+1) = '\0';
2518 }
2519 }
2520
2521 {
2522 /* Ask for the library to load : list files in the previously selected
2523 * directory */
2524 gchar str[PATH_MAX];
2525 gchar ** dir;
2526 gint id;
2527 GtkFileSelection * file_selector =
2528 (GtkFileSelection *)gtk_file_selection_new("Select a module");
2529 gtk_file_selection_set_filename(file_selector, load_module_path_alter);
2530 gtk_file_selection_hide_fileop_buttons(file_selector);
2531
93ac601b 2532 gtk_window_set_transient_for(GTK_WINDOW(file_selector),
2533 GTK_WINDOW(mw_data->mwindow));
2534
b052368a 2535 str[0] = '\0';
2536 id = gtk_dialog_run(GTK_DIALOG(file_selector));
2537 switch(id){
2538 case GTK_RESPONSE_ACCEPT:
2539 case GTK_RESPONSE_OK:
2540 dir = gtk_file_selection_get_selections (file_selector);
2541 strncpy(str,dir[0],PATH_MAX);
2542 strncpy(remember_plugins_dir,dir[0],PATH_MAX);
2543 /* only keep file name */
2544 gchar *str1;
2545 str1 = strrchr(str,'/');
2546 if(str1)str1++;
2547 else{
2548 str1 = strrchr(str,'\\');
2549 str1++;
2550 }
2551#if 0
2552 /* remove "lib" */
2553 if(*str1 == 'l' && *(str1+1)== 'i' && *(str1+2)=='b')
2554 str1=str1+3;
2555 remove info after . */
2556 {
2557 gchar *str2 = str1;
2558
2559 str2 = strrchr(str2, '.');
2560 if(str2 != NULL) *str2 = '\0';
2561 }
2562 lttv_module_require(str1, &error);
2563#endif //0
2564 lttv_library_load(str1, &error);
2eef04b5 2565 if(error != NULL) g_warning("%s", error->message);
56e5a0f7 2566 else g_info("Load library: %s\n", str);
b052368a 2567 g_strfreev(dir);
2568 case GTK_RESPONSE_REJECT:
2569 case GTK_RESPONSE_CANCEL:
2570 default:
2571 gtk_widget_destroy((GtkWidget*)file_selector);
2572 break;
2573 }
2574
2575 }
2576
2577
2578
2579}
2580
2581
2582/* Display all loaded modules, let user to select a module to unload
2583 * by calling lttv_module_unload
2584 */
2585
2586void
2587on_unload_library_activate (GtkMenuItem *menuitem,
2588 gpointer user_data)
2589{
2590 MainWindow * mw_data = get_window_data_struct((GtkWidget*)menuitem);
2591
2eef04b5 2592 LttvLibrary *library = NULL;
b052368a 2593
2eef04b5 2594 GPtrArray *name;
2595 guint nb,i;
2596 gchar *lib_name;
2597 name = g_ptr_array_new();
2598 nb = lttv_library_number();
2599 LttvLibraryInfo *lib_info = g_new(LttvLibraryInfo,nb);
2600 /* ask for the library name */
2601
2602 for(i=0;i<nb;i++){
2603 LttvLibrary *iter_lib = lttv_library_get(i);
2604 lttv_library_info(iter_lib, &lib_info[i]);
2605
2606 gchar *path = lib_info[i].name;
2607 g_ptr_array_add(name, path);
2608 }
93ac601b 2609 lib_name = get_selection(mw_data, (char **)(name->pdata), name->len,
2eef04b5 2610 "Select a library", "Libraries");
2611 if(lib_name != NULL) {
b052368a 2612 for(i=0;i<nb;i++){
2eef04b5 2613 if(strcmp(lib_name, lib_info[i].name) == 0) {
2614 library = lttv_library_get(i);
2615 break;
b052368a 2616 }
2617 }
b052368a 2618 }
2eef04b5 2619 g_ptr_array_free(name, TRUE);
2620 g_free(lib_info);
2621
2622 if(lib_name == NULL) return;
2623
2624 if(library != NULL) lttv_library_unload(library);
b052368a 2625}
2626
2627
abe346a3 2628/* Dispaly a file selection dialogue to let user select a module, then call
b052368a 2629 * lttv_module_require().
abe346a3 2630 */
2631
561eba2a 2632void
2633on_load_module_activate (GtkMenuItem *menuitem,
2634 gpointer user_data)
2635{
b052368a 2636 GError *error = NULL;
bca3b81f 2637 MainWindow * mw_data = get_window_data_struct((GtkWidget*)menuitem);
b052368a 2638
2eef04b5 2639 LttvLibrary *library = NULL;
b052368a 2640 {
2641 GPtrArray *name;
2642 guint nb,i;
2643 gchar *lib_name;
2644 name = g_ptr_array_new();
2645 nb = lttv_library_number();
2646 LttvLibraryInfo *lib_info = g_new(LttvLibraryInfo,nb);
2647 /* ask for the library name */
2648
2649 for(i=0;i<nb;i++){
2650 LttvLibrary *iter_lib = lttv_library_get(i);
2651 lttv_library_info(iter_lib, &lib_info[i]);
2652
2653 gchar *path = lib_info[i].name;
2654 g_ptr_array_add(name, path);
2655 }
93ac601b 2656 lib_name = get_selection(mw_data,(char **)(name->pdata), name->len,
b052368a 2657 "Select a library", "Libraries");
2658 if(lib_name != NULL) {
2659 for(i=0;i<nb;i++){
2660 if(strcmp(lib_name, lib_info[i].name) == 0) {
2661 library = lttv_library_get(i);
2662 break;
2663 }
3872a20e 2664 }
b052368a 2665 }
2666 g_ptr_array_free(name, TRUE);
2667 g_free(lib_info);
2668
2669 if(lib_name == NULL) return;
36b3c068 2670 }
b052368a 2671
2672 //LttvModule *module;
2673 gchar module_name_out[PATH_MAX];
2674 {
2675 /* Ask for the module to load : list modules in the selected lib */
2676 GPtrArray *name;
2677 guint nb,i;
2678 gchar *module_name;
bbbd6c25 2679 nb = lttv_library_module_number(library);
b052368a 2680 LttvModuleInfo *module_info = g_new(LttvModuleInfo,nb);
2681 name = g_ptr_array_new();
b052368a 2682 /* ask for the module name */
2683
2684 for(i=0;i<nb;i++){
2685 LttvModule *iter_module = lttv_library_module_get(library, i);
2686 lttv_module_info(iter_module, &module_info[i]);
2687
2688 gchar *path = module_info[i].name;
2689 g_ptr_array_add(name, path);
2690 }
93ac601b 2691 module_name = get_selection(mw_data, (char **)(name->pdata), name->len,
b052368a 2692 "Select a module", "Modules");
2693 if(module_name != NULL) {
2694 for(i=0;i<nb;i++){
2695 if(strcmp(module_name, module_info[i].name) == 0) {
2696 strncpy(module_name_out, module_name, PATH_MAX);
2697 //module = lttv_library_module_get(i);
2698 break;
2699 }
2700 }
2701 }
2702
2703 g_ptr_array_free(name, TRUE);
2704 g_free(module_info);
2705
2706 if(module_name == NULL) return;
2707 }
2708
2709 lttv_module_require(module_name_out, &error);
2eef04b5 2710 if(error != NULL) g_warning("%s", error->message);
56e5a0f7 2711 else g_info("Load module: %s", module_name_out);
b052368a 2712
2713
2714#if 0
2715 {
2716
2717
2718 gchar str[PATH_MAX];
2719 gchar ** dir;
2720 gint id;
2721 GtkFileSelection * file_selector =
2722 (GtkFileSelection *)gtk_file_selection_new("Select a module");
2723 gtk_file_selection_set_filename(file_selector, load_module_path_alter);
2724 gtk_file_selection_hide_fileop_buttons(file_selector);
2725
2726 str[0] = '\0';
2727 id = gtk_dialog_run(GTK_DIALOG(file_selector));
2728 switch(id){
2729 case GTK_RESPONSE_ACCEPT:
2730 case GTK_RESPONSE_OK:
2731 dir = gtk_file_selection_get_selections (file_selector);
2732 strncpy(str,dir[0],PATH_MAX);
2733 strncpy(remember_plugins_dir,dir[0],PATH_MAX);
2734 {
2735 /* only keep file name */
2736 gchar *str1;
2737 str1 = strrchr(str,'/');
2738 if(str1)str1++;
2739 else{
2740 str1 = strrchr(str,'\\');
2741 str1++;
2742 }
2743#if 0
2744 /* remove "lib" */
2745 if(*str1 == 'l' && *(str1+1)== 'i' && *(str1+2)=='b')
2746 str1=str1+3;
2747 remove info after . */
2748 {
2749 gchar *str2 = str1;
2750
2751 str2 = strrchr(str2, '.');
2752 if(str2 != NULL) *str2 = '\0';
2753 }
2754 lttv_module_require(str1, &error);
2755#endif //0
2756 lttv_library_load(str1, &error);
2757 if(error != NULL) g_warning(error->message);
56e5a0f7 2758 else g_info("Load library: %s\n", str);
b052368a 2759 g_strfreev(dir);
2760 case GTK_RESPONSE_REJECT:
2761 case GTK_RESPONSE_CANCEL:
2762 default:
2763 gtk_widget_destroy((GtkWidget*)file_selector);
2764 break;
2765 }
2766
2767 }
2768#endif //0
2769
2770
561eba2a 2771}
2772
2773
b052368a 2774
abe346a3 2775/* Display all loaded modules, let user to select a module to unload
2776 * by calling lttv_module_unload
2777 */
2778
561eba2a 2779void
2780on_unload_module_activate (GtkMenuItem *menuitem,
2781 gpointer user_data)
2782{
bca3b81f 2783 MainWindow * mw_data = get_window_data_struct((GtkWidget*)menuitem);
08b1c66e 2784
43ed82b5 2785 LttvLibrary *library = NULL;
b052368a 2786 {
2787 GPtrArray *name;
2788 guint nb,i;
2789 gchar *lib_name;
2790 name = g_ptr_array_new();
2791 nb = lttv_library_number();
2792 LttvLibraryInfo *lib_info = g_new(LttvLibraryInfo,nb);
2793 /* ask for the library name */
36b3c068 2794
36b3c068 2795 for(i=0;i<nb;i++){
b052368a 2796 LttvLibrary *iter_lib = lttv_library_get(i);
2797 lttv_library_info(iter_lib, &lib_info[i]);
2798
2799 gchar *path = lib_info[i].name;
2800 g_ptr_array_add(name, path);
2801 }
93ac601b 2802 lib_name = get_selection(mw_data, (char **)(name->pdata), name->len,
b052368a 2803 "Select a library", "Libraries");
2804 if(lib_name != NULL) {
2805 for(i=0;i<nb;i++){
2806 if(strcmp(lib_name, lib_info[i].name) == 0) {
2807 library = lttv_library_get(i);
2808 break;
2809 }
36b3c068 2810 }
b052368a 2811 }
2812 g_ptr_array_free(name, TRUE);
2813 g_free(lib_info);
2814
2815 if(lib_name == NULL) return;
36b3c068 2816 }
2817
2eef04b5 2818 LttvModule *module = NULL;
b052368a 2819 {
2820 /* Ask for the module to load : list modules in the selected lib */
2821 GPtrArray *name;
2822 guint nb,i;
2823 gchar *module_name;
6d677a86 2824 nb = lttv_library_module_number(library);
b052368a 2825 LttvModuleInfo *module_info = g_new(LttvModuleInfo,nb);
2826 name = g_ptr_array_new();
b052368a 2827 /* ask for the module name */
2828
2829 for(i=0;i<nb;i++){
2830 LttvModule *iter_module = lttv_library_module_get(library, i);
2831 lttv_module_info(iter_module, &module_info[i]);
2832
2833 gchar *path = module_info[i].name;
2834 if(module_info[i].use_count > 0) g_ptr_array_add(name, path);
2835 }
93ac601b 2836 module_name = get_selection(mw_data, (char **)(name->pdata), name->len,
b052368a 2837 "Select a module", "Modules");
2838 if(module_name != NULL) {
2839 for(i=0;i<nb;i++){
2840 if(strcmp(module_name, module_info[i].name) == 0) {
2841 module = lttv_library_module_get(library, i);
2842 break;
2843 }
2844 }
2845 }
2846
2847 g_ptr_array_free(name, TRUE);
2848 g_free(module_info);
2849
2850 if(module_name == NULL) return;
2851 }
2852
b052368a 2853 LttvModuleInfo module_info;
2854 lttv_module_info(module, &module_info);
56e5a0f7 2855 g_info("Release module: %s\n", module_info.name);
fce9a2fc 2856
2857 lttv_module_release(module);
561eba2a 2858}
2859
2860
b052368a 2861/* Display a directory dialogue to let user select a path for library searching
abe346a3 2862 */
2863
561eba2a 2864void
b052368a 2865on_add_library_search_path_activate (GtkMenuItem *menuitem,
561eba2a 2866 gpointer user_data)
2867{
93ac601b 2868 MainWindow * mw_data = get_window_data_struct((GtkWidget*)menuitem);
0a946563 2869 //GtkDirSelection * file_selector = (GtkDirSelection *)gtk_dir_selection_new("Select library path");
2870 GtkFileSelection * file_selector = (GtkFileSelection *)gtk_file_selection_new("Select a trace");
2871 gtk_widget_hide( (file_selector)->file_list->parent) ;
93ac601b 2872
2873 gtk_window_set_transient_for(GTK_WINDOW(file_selector),
2874 GTK_WINDOW(mw_data->mwindow));
2875
67b98724 2876 const char * dir;
fc188b78 2877 gint id;
2878
3658a338 2879 if(remember_plugins_dir[0] != '\0')
0a946563 2880 gtk_file_selection_set_filename(file_selector, remember_plugins_dir);
fc188b78 2881
68b48a45 2882 id = gtk_dialog_run(GTK_DIALOG(file_selector));
fc188b78 2883 switch(id){
2884 case GTK_RESPONSE_ACCEPT:
2885 case GTK_RESPONSE_OK:
0a946563 2886 dir = gtk_file_selection_get_filename (file_selector);
a1a2b649 2887 strncpy(remember_plugins_dir,dir,PATH_MAX);
2888 strncat(remember_plugins_dir,"/",PATH_MAX);
08b1c66e 2889 lttv_library_path_add(dir);
fc188b78 2890 case GTK_RESPONSE_REJECT:
2891 case GTK_RESPONSE_CANCEL:
2892 default:
68b48a45 2893 gtk_widget_destroy((GtkWidget*)file_selector);
fc188b78 2894 break;
6b1d3120 2895 }
561eba2a 2896}
2897
2898
b052368a 2899/* Display a directory dialogue to let user select a path for library searching
2900 */
2901
2902void
2903on_remove_library_search_path_activate (GtkMenuItem *menuitem,
2904 gpointer user_data)
2905{
2906 MainWindow * mw_data = get_window_data_struct((GtkWidget*)menuitem);
2907
2908 const char *lib_path;
2909 {
2910 GPtrArray *name;
2911 guint nb,i;
b052368a 2912 name = g_ptr_array_new();
2913 nb = lttv_library_path_number();
2914 /* ask for the library name */
2915
2916 for(i=0;i<nb;i++){
2917 gchar *path = lttv_library_path_get(i);
2918 g_ptr_array_add(name, path);
2919 }
93ac601b 2920 lib_path = get_selection(mw_data, (char **)(name->pdata), name->len,
b052368a 2921 "Select a library path", "Library paths");
2922
2923 g_ptr_array_free(name, TRUE);
2924
2925 if(lib_path == NULL) return;
2926 }
2927
2928 lttv_library_path_remove(lib_path);
2929}
2930
561eba2a 2931void
2932on_color_activate (GtkMenuItem *menuitem,
2933 gpointer user_data)
2934{
56e5a0f7 2935 g_info("Color\n");
561eba2a 2936}
2937
2938
561eba2a 2939void
2940on_save_configuration_activate (GtkMenuItem *menuitem,
2941 gpointer user_data)
2942{
56e5a0f7 2943 g_info("Save configuration\n");
561eba2a 2944}
2945
2946
2947void
2948on_content_activate (GtkMenuItem *menuitem,
2949 gpointer user_data)
2950{
7e18bb76
F
2951 char* filename = NULL,
2952 *path;
2953 GdkScreen *screen;
2954 const char* relativePath = "doc/user/user_guide/html/index.html";
2955 filename = g_build_filename (g_get_current_dir(), relativePath, NULL);
2956 path = g_strdup_printf ("ghelp://%s", filename);
2957
2958 screen = gdk_screen_get_default();
2959 gtk_show_uri (screen, path, gtk_get_current_event_time(), NULL);
2960
2961 g_free(filename);
2962 g_free(path);
56e5a0f7 2963 g_info("Content\n");
561eba2a 2964}
2965
2966
51ef553b 2967static void
2968on_about_close_activate (GtkButton *button,
2969 gpointer user_data)
2970{
2971 GtkWidget *about_widget = GTK_WIDGET(user_data);
2972
2973 gtk_widget_destroy(about_widget);
2974}
2975
561eba2a 2976void
2977on_about_activate (GtkMenuItem *menuitem,
2978 gpointer user_data)
2979{
51ef553b 2980 MainWindow *main_window = get_window_data_struct(GTK_WIDGET(menuitem));
2981 GtkWidget *window_widget = main_window->mwindow;
2982 GtkWidget *about_widget = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2983 GtkWindow *about_window = GTK_WINDOW(about_widget);
51ef553b 2984
2985 gtk_window_set_title(about_window, "About Linux Trace Toolkit");
2986
2987 gtk_window_set_resizable(about_window, FALSE);
f5f1a04e 2988 gtk_window_set_transient_for(about_window, GTK_WINDOW(window_widget));
51ef553b 2989 gtk_window_set_destroy_with_parent(about_window, TRUE);
2990 gtk_window_set_modal(about_window, FALSE);
2991
2992 /* Put the about window at the center of the screen */
7e18bb76
F
2993 gtk_window_set_position(about_window, GTK_WIN_POS_CENTER_ALWAYS);
2994
51ef553b 2995 GtkWidget *vbox = gtk_vbox_new(FALSE, 1);
2996
2997 gtk_container_add(GTK_CONTAINER(about_widget), vbox);
2998
51ef553b 2999 /* Text to show */
3000 GtkWidget *label1 = gtk_label_new("");
c8bba5fa 3001 gtk_misc_set_padding(GTK_MISC(label1), 10, 20);
51ef553b 3002 gtk_label_set_markup(GTK_LABEL(label1), "\
f5f1a04e 3003<big>Linux Trace Toolkit " VERSION "</big>");
51ef553b 3004 gtk_label_set_justify(GTK_LABEL(label1), GTK_JUSTIFY_CENTER);
3005
3006 GtkWidget *label2 = gtk_label_new("");
c8bba5fa 3007 gtk_misc_set_padding(GTK_MISC(label2), 10, 20);
51ef553b 3008 gtk_label_set_markup(GTK_LABEL(label2), "\
51ef553b 3009Contributors :\n\
3010\n\
3011Michel Dagenais (New trace format, lttv main)\n\
4b601423 3012Mathieu Desnoyers (Kernel Tracer, Directory structure, build with automake/conf,\n\
ef26c1ea 3013 lttv gui, control flow view, gui cooperative trace reading\n\
4b7bd7e1 3014 scheduler with interruptible foreground and background\n\
57ca4914 3015 computation, detailed event list (rewrite), trace reading\n\
3016 library (rewrite))\n\
7d2855bf 3017Benoit Des Ligneris, Eric Clement (Cluster adaptation, work in progress)\n\
51ef553b 3018Xang-Xiu Yang (new trace reading library and converter, lttv gui, \n\
3019 detailed event list and statistics view)\n\
e8ac6a5e 3020Tom Zanussi (RelayFS)\n\
3021\n\
f5f1a04e 3022Inspired from the original Linux Trace Toolkit Visualizer made by\n\
e8ac6a5e 3023Karim Yaghmour");
c8bba5fa 3024
3025 GtkWidget *label3 = gtk_label_new("");
3026 gtk_label_set_markup(GTK_LABEL(label3), "\
f5f1a04e 3027Linux Trace Toolkit Viewer, Copyright (C) 2004, 2005, 2006\n\
7d2855bf 3028 Michel Dagenais\n\
e8ac6a5e 3029 Mathieu Desnoyers\n\
3030 Xang-Xiu Yang\n\
c8bba5fa 3031Linux Trace Toolkit comes with ABSOLUTELY NO WARRANTY.\n\
3032This is free software, and you are welcome to redistribute it\n\
3033under certain conditions. See COPYING for details.");
3034 gtk_misc_set_padding(GTK_MISC(label3), 10, 20);
3035
51ef553b 3036 gtk_box_pack_start_defaults(GTK_BOX(vbox), label1);
3037 gtk_box_pack_start_defaults(GTK_BOX(vbox), label2);
c8bba5fa 3038 gtk_box_pack_start_defaults(GTK_BOX(vbox), label3);
51ef553b 3039
3040 GtkWidget *hbox = gtk_hbox_new(TRUE, 0);
3041 gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
3042 GtkWidget *close_button = gtk_button_new_with_mnemonic("_Close");
3043 gtk_box_pack_end(GTK_BOX(hbox), close_button, FALSE, FALSE, 0);
3044 gtk_container_set_border_width(GTK_CONTAINER(close_button), 20);
3045
3046 g_signal_connect(G_OBJECT(close_button), "clicked",
3047 G_CALLBACK(on_about_close_activate),
3048 (gpointer)about_widget);
3049
3050 gtk_widget_show_all(about_widget);
561eba2a 3051}
3052
3053
3054void
3055on_button_new_clicked (GtkButton *button,
3056 gpointer user_data)
3057{
6f7ad7ae 3058 create_new_window((GtkWidget*)button, user_data, TRUE);
561eba2a 3059}
3060
2901f314 3061void
3062on_button_new_tab_clicked (GtkButton *button,
3063 gpointer user_data)
3064{
3065 create_new_tab((GtkWidget*)button, user_data);
3066}
561eba2a 3067
3068void
3069on_button_open_clicked (GtkButton *button,
3070 gpointer user_data)
3071{
e865422c 3072#ifdef UNFINISHED_FEATURE
561eba2a 3073 open_traceset((GtkWidget*)button, user_data);
e865422c 3074#endif
561eba2a 3075}
3076
3077
3078void
3079on_button_add_trace_clicked (GtkButton *button,
3080 gpointer user_data)
3081{
3082 add_trace((GtkWidget*)button, user_data);
3083}
3084
3085
3086void
3087on_button_remove_trace_clicked (GtkButton *button,
3088 gpointer user_data)
3089{
3090 remove_trace((GtkWidget*)button, user_data);
3091}
3092
9878c8a4 3093void
3094on_button_redraw_clicked (GtkButton *button,
3095 gpointer user_data)
3096{
3097 redraw((GtkWidget*)button, user_data);
3098}
3099
3100void
3101on_button_continue_processing_clicked (GtkButton *button,
3102 gpointer user_data)
3103{
3104 continue_processing((GtkWidget*)button, user_data);
3105}
3106
3107void
3108on_button_stop_processing_clicked (GtkButton *button,
3109 gpointer user_data)
3110{
3111 stop_processing((GtkWidget*)button, user_data);
3112}
3113
3114
561eba2a 3115
3116void
3117on_button_save_clicked (GtkButton *button,
3118 gpointer user_data)
3119{
3120 save((GtkWidget*)button, user_data);
3121}
3122
3123
3124void
3125on_button_save_as_clicked (GtkButton *button,
3126 gpointer user_data)
3127{
3128 save_as((GtkWidget*)button, user_data);
3129}
3130
3131
3132void
3133on_button_zoom_in_clicked (GtkButton *button,
3134 gpointer user_data)
3135{
3136 zoom_in((GtkWidget*)button, user_data);
3137}
3138
3139
3140void
3141on_button_zoom_out_clicked (GtkButton *button,
3142 gpointer user_data)
3143{
3144 zoom_out((GtkWidget*)button, user_data);
3145}
3146
3147
3148void
3149on_button_zoom_extended_clicked (GtkButton *button,
3150 gpointer user_data)
3151{
3152 zoom_extended((GtkWidget*)button, user_data);
3153}
3154
3155
3156void
3157on_button_go_to_time_clicked (GtkButton *button,
3158 gpointer user_data)
3159{
3160 go_to_time((GtkWidget*)button, user_data);
3161}
3162
3163
3164void
3165on_button_show_time_frame_clicked (GtkButton *button,
3166 gpointer user_data)
3167{
3168 show_time_frame((GtkWidget*)button, user_data);
3169}
3170
3171
3172void
3173on_button_move_up_clicked (GtkButton *button,
3174 gpointer user_data)
3175{
3176 move_up_viewer((GtkWidget*)button, user_data);
3177}
3178
3179
3180void
3181on_button_move_down_clicked (GtkButton *button,
3182 gpointer user_data)
3183{
3184 move_down_viewer((GtkWidget*)button, user_data);
3185}
3186
3187
3188void
3189on_button_delete_viewer_clicked (GtkButton *button,
3190 gpointer user_data)
3191{
3192 delete_viewer((GtkWidget*)button, user_data);
3193}
3194
3195void
2d262115 3196on_MWindow_destroy (GtkWidget *widget,
561eba2a 3197 gpointer user_data)
3198{
2d262115 3199 MainWindow *main_window = get_window_data_struct(widget);
ef68c3ac 3200 LttvIAttribute *attributes = main_window->attributes;
3201 LttvAttributeValue value;
8f318283 3202 gboolean retval;
e4d09234 3203
ef68c3ac 3204 //This is unnecessary, since widgets will be destroyed
3205 //by the main window widget anyway.
3206 //remove_all_menu_toolbar_constructors(main_window, NULL);
3207
8f318283
BP
3208 retval= lttv_iattribute_find_by_path(attributes, "viewers/menu",
3209 LTTV_POINTER, &value);
3210 g_assert(retval);
ef68c3ac 3211 lttv_menus_destroy((LttvMenus*)*(value.v_pointer));
3212
8f318283
BP
3213 retval= lttv_iattribute_find_by_path(attributes, "viewers/toolbar",
3214 LTTV_POINTER, &value);
3215 g_assert(retval);
ef68c3ac 3216 lttv_toolbars_destroy((LttvToolbars*)*(value.v_pointer));
2d262115 3217
ef68c3ac 3218 g_object_unref(main_window->attributes);
3219 g_main_window_list = g_slist_remove(g_main_window_list, main_window);
561eba2a 3220
56e5a0f7 3221 g_info("There are now : %d windows\n",g_slist_length(g_main_window_list));
2d262115 3222 if(g_slist_length(g_main_window_list) == 0)
d27948a3 3223 mainwindow_quit();
561eba2a 3224}
3225
58eecf4a 3226gboolean
3227on_MWindow_configure (GtkWidget *widget,
3228 GdkEventConfigure *event,
3229 gpointer user_data)
3230{
bd24a9af 3231 // MD : removed time width modification upon resizing of the main window.
3232 // The viewers will redraw themselves completely, without time interval
3233 // modification.
3234/* while(tab){
58eecf4a 3235 if(mw_data->window_width){
3236 time_span = LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context)->Time_Span ;
3237 time_win = tab->time_window;
3238 ratio = width / mw_data->window_width;
3239 tab->time_window.time_width = ltt_time_mul(time_win.time_width,ratio);
3240 time = ltt_time_sub(time_span->endTime, time_win.start_time);
3241 if(ltt_time_compare(time, tab->time_window.time_width) < 0){
3242 tab->time_window.time_width = time;
3243 }
3244 }
3245 tab = tab->next;
3246 }
3247
3248 mw_data->window_width = (int)width;
bd24a9af 3249 */
58eecf4a 3250 return FALSE;
3251}
561eba2a 3252
abe346a3 3253/* Set current tab
3254 */
3255
561eba2a 3256void
3257on_MNotebook_switch_page (GtkNotebook *notebook,
3258 GtkNotebookPage *page,
3259 guint page_num,
3260 gpointer user_data)
3261{
47cd8a09 3262
561eba2a 3263}
3264
abe346a3 3265
e800cf84 3266void time_change_manager (Tab *tab,
3267 TimeWindow new_time_window)
451aaf27
FD
3268{
3269
e800cf84 3270 /* Only one source of time change */
3271 if(tab->time_manager_lock == TRUE) return;
3272
3273 tab->time_manager_lock = TRUE;
451aaf27
FD
3274 TimeInterval time_span;
3275
3276 LttvTraceset *ts = tab->traceset_info->traceset;
3277 time_span.start_time =ltt_time_from_uint64( lttv_traceset_get_timestamp_begin(ts));
3278 time_span.end_time = ltt_time_from_uint64(lttv_traceset_get_timestamp_end(ts));
3279
e800cf84 3280
e800cf84 3281 LttTime start_time = new_time_window.start_time;
6f26fc38 3282 LttTime end_time = new_time_window.end_time;
e800cf84 3283
a998b781 3284 g_assert(ltt_time_compare(start_time, end_time) < 0);
3285
e800cf84 3286 /* Set scrollbar */
3287 GtkAdjustment *adjustment = gtk_range_get_adjustment(GTK_RANGE(tab->scrollbar));
451aaf27
FD
3288 LttTime upper = ltt_time_sub(time_span.end_time, time_span.start_time);
3289
e800cf84 3290#if 0
3291 gtk_range_set_increments(GTK_RANGE(tab->scrollbar),
3292 ltt_time_to_double(new_time_window.time_width)
3293 / SCROLL_STEP_PER_PAGE
3294 * NANOSECONDS_PER_SECOND, /* step increment */
3295 ltt_time_to_double(new_time_window.time_width)
3296 * NANOSECONDS_PER_SECOND); /* page increment */
3297 gtk_range_set_range(GTK_RANGE(tab->scrollbar),
3298 0.0, /* lower */
3299 ltt_time_to_double(upper)
3300 * NANOSECONDS_PER_SECOND); /* upper */
3301#endif //0
3302 g_object_set(G_OBJECT(adjustment),
3303 "lower",
3304 0.0, /* lower */
3305 "upper",
c74e0cf9 3306 ltt_time_to_double(upper), /* upper */
e800cf84 3307 "step_increment",
a18124ff 3308 new_time_window.time_width_double
c74e0cf9 3309 / SCROLL_STEP_PER_PAGE, /* step increment */
e800cf84 3310 "page_increment",
a18124ff 3311 new_time_window.time_width_double,
c74e0cf9 3312 /* page increment */
e800cf84 3313 "page_size",
a18124ff 3314 new_time_window.time_width_double, /* page size */
e800cf84 3315 NULL);
3316 gtk_adjustment_changed(adjustment);
3317
3318 // g_object_set(G_OBJECT(adjustment),
3319 // "value",
3320 // ltt_time_to_double(
3321 // ltt_time_sub(start_time, time_span.start_time))
c74e0cf9 3322 // , /* value */
e800cf84 3323 // NULL);
3324 //gtk_adjustment_value_changed(adjustment);
3325 gtk_range_set_value(GTK_RANGE(tab->scrollbar),
3326 ltt_time_to_double(
c74e0cf9 3327 ltt_time_sub(start_time, time_span.start_time)) /* value */);
e800cf84 3328
3329 /* set the time bar. */
e800cf84 3330
6f26fc38 3331
4172f013
YB
3332 timebar_set_minmax_time(TIMEBAR(tab->MTimebar),
3333 &time_span.start_time,
3334 &time_span.end_time );
3335 timebar_set_start_time(TIMEBAR(tab->MTimebar),&start_time);
3336 timebar_set_end_time(TIMEBAR(tab->MTimebar),&end_time);
e800cf84 3337
e800cf84 3338
58de9fc1 3339
4172f013
YB
3340 /* call viewer hooks for new time window */
3341 set_time_window(tab, &new_time_window);
58de9fc1 3342
4172f013 3343 tab->time_manager_lock = FALSE;
451aaf27
FD
3344
3345
58de9fc1 3346}
3347
58de9fc1 3348
58de9fc1 3349
3350
e800cf84 3351
3352void current_time_change_manager (Tab *tab,
3353 LttTime new_current_time)
3354{
3355 /* Only one source of time change */
3356 if(tab->current_time_manager_lock == TRUE) return;
3357
3358 tab->current_time_manager_lock = TRUE;
3359
4172f013 3360 timebar_set_current_time(TIMEBAR(tab->MTimebar), &new_current_time);
e800cf84 3361
db8bc917 3362 set_current_time(tab, &new_current_time);
e800cf84 3363
3364 tab->current_time_manager_lock = FALSE;
3365}
3366
9a366873 3367void current_position_change_manager(Tab *tab, LttvTracesetPosition *pos)
5290ec02 3368{
9a366873 3369 lttv_traceset_seek_to_position( pos);
5290ec02 3370
9a366873 3371 LttTime new_time = lttv_traceset_position_get_time(pos);
16e2bb34 3372 /* Put the context in a state coherent position */
9a366873
FD
3373#ifdef BABEL_CLEANUP
3374 lttv_state_traceset_seek_time_closest((LttvTracesetState*)tsc, ltt_time_zero);
3375#endif /* BABEL_CLEANUP */
5290ec02 3376 current_time_change_manager(tab, new_time);
3377
3378 set_current_position(tab, pos);
3379}
3380
4172f013
YB
3381static void on_timebar_starttime_changed(Timebar *timebar,
3382 gpointer user_data)
e800cf84 3383{
4172f013 3384 Tab *tab = (Tab *)user_data;
9aaa78dc
FD
3385 LttvTraceset * ts =tab->traceset_info->traceset;
3386 TimeInterval time_span = lttv_traceset_get_time_span(ts);
4172f013
YB
3387
3388 TimeWindow new_time_window = tab->time_window;
3389 new_time_window.start_time = timebar_get_start_time(timebar);
3390
3391 LttTime end_time = new_time_window.end_time;
3392
3393 /* TODO ybrosseau 2010-12-02: This if should have been checked
3394 by the timebar already */
3395 if(ltt_time_compare(new_time_window.start_time, end_time) >= 0) {
3396 /* Then, we must push back end time : keep the same time width
3397 * if possible, else end traceset time */
3398 end_time = LTT_TIME_MIN(ltt_time_add(new_time_window.start_time,
3399 new_time_window.time_width),
3400 time_span.end_time);
3401 }
3402
3403 /* Fix the time width to fit start time and end time */
3404 new_time_window.time_width = ltt_time_sub(end_time,
3405 new_time_window.start_time);
3406
3407 new_time_window.time_width_double =
3408 ltt_time_to_double(new_time_window.time_width);
3409
3410 new_time_window.end_time = end_time;
3411
3412 /* Notify the time_manager */
3413 time_change_manager(tab, new_time_window);
9aaa78dc 3414
e800cf84 3415}
3416
4172f013
YB
3417static void on_timebar_endtime_changed(Timebar *timebar,
3418 gpointer user_data)
e800cf84 3419{
4172f013 3420 Tab *tab = (Tab *)user_data;
9aaa78dc
FD
3421 LttvTraceset * ts =tab->traceset_info->traceset;
3422 TimeInterval time_span = lttv_traceset_get_time_span(ts);
e800cf84 3423
4172f013
YB
3424 TimeWindow new_time_window = tab->time_window;
3425
3426 LttTime end_time = timebar_get_end_time(timebar);
3427
3428 /* TODO ybrosseau 2010-12-02: This if should have been
3429 checked by the timebar already */
3430 if(ltt_time_compare(new_time_window.start_time, end_time) >= 0) {
3431 /* Then, we must push front start time : keep the same time
3432 width if possible, else end traceset time */
3433 new_time_window.start_time = LTT_TIME_MAX(
3434 ltt_time_sub(end_time,
3435 new_time_window.time_width),
3436 time_span.start_time);
3437 }
e800cf84 3438
4172f013
YB
3439 /* Fix the time width to fit start time and end time */
3440 new_time_window.time_width = ltt_time_sub(end_time,
3441 new_time_window.start_time);
3442
3443 new_time_window.time_width_double =
3444 ltt_time_to_double(new_time_window.time_width);
3445
3446 new_time_window.end_time = end_time;
3447
3448 /* Notify the time_manager */
9aaa78dc 3449 time_change_manager(tab, new_time_window);
4172f013
YB
3450}
3451static void on_timebar_currenttime_changed(Timebar *timebar,
3452 gpointer user_data)
3453{
3454 Tab *tab = (Tab *)user_data;
3455
3456 LttTime new_current_time = timebar_get_current_time(timebar);
3457
3458 current_time_change_manager(tab, new_current_time);
3459}
e800cf84 3460
b052368a 3461void scroll_value_changed_cb(GtkWidget *scrollbar,
3462 gpointer user_data)
3463{
3464 Tab *tab = (Tab *)user_data;
e800cf84 3465 TimeWindow new_time_window;
b052368a 3466 LttTime time;
3467 GtkAdjustment *adjust = gtk_range_get_adjustment(GTK_RANGE(scrollbar));
3468 gdouble value = gtk_adjustment_get_value(adjust);
e800cf84 3469 // gdouble upper, lower, ratio, page_size;
3470 gdouble page_size;
9aaa78dc
FD
3471
3472 LttvTraceset * ts = tab->traceset_info->traceset;
3473 TimeInterval time_span = lttv_traceset_get_time_span(ts);
b052368a 3474
c74e0cf9 3475 time = ltt_time_add(ltt_time_from_double(value),
e800cf84 3476 time_span.start_time);
3477
3478 new_time_window.start_time = time;
3479
3480 page_size = adjust->page_size;
3481
3482 new_time_window.time_width =
c74e0cf9 3483 ltt_time_from_double(page_size);
e800cf84 3484
a18124ff 3485 new_time_window.time_width_double =
3486 page_size;
3487
6f26fc38 3488 new_time_window.end_time = ltt_time_add(new_time_window.start_time,
3489 new_time_window.time_width);
3490
e800cf84 3491
3492 time_change_manager(tab, new_time_window);
9aaa78dc 3493
e800cf84 3494#if 0
b052368a 3495 //time_window = tab->time_window;
3496
b052368a 3497 lower = adjust->lower;
3498 upper = adjust->upper;
3499 ratio = (value - lower) / (upper - lower);
2b5cc5a5 3500 g_info("lower %lu, upper %lu, value %lu, ratio %lu", lower, upper, value, ratio);
b052368a 3501
3502 //time = ltt_time_sub(time_span->end_time, time_span->start_time);
3503 //time = ltt_time_mul(time, (float)ratio);
3504 //time = ltt_time_add(time_span->start_time, time);
c74e0cf9 3505 time = ltt_time_add(ltt_time_from_double(value),
b9a010a2 3506 time_span.start_time);
b052368a 3507
3508 time_window.start_time = time;
3509
3510 page_size = adjust->page_size;
3511
3512 time_window.time_width =
c74e0cf9 3513 ltt_time_from_double(page_size);
b9a010a2 3514 //time = ltt_time_sub(time_span.end_time, time);
b052368a 3515 //if(ltt_time_compare(time,time_window.time_width) < 0){
3516 // time_window.time_width = time;
3517 //}
3518
3519 /* call viewer hooks for new time window */
3520 set_time_window(tab, &time_window);
e800cf84 3521#endif //0
9aaa78dc 3522
b052368a 3523}
3524
3525
abe346a3 3526/* Display a dialogue showing all eventtypes and traces, let user to select the interested
3527 * eventtypes, tracefiles and traces (filter)
3528 */
3529
abe346a3 3530/* Select a trace which will be removed from traceset
3531 */
3532
93ac601b 3533char * get_remove_trace(MainWindow *mw_data,
3534 char ** all_trace_name, int nb_trace)
2176f952 3535{
93ac601b 3536 return get_selection(mw_data, all_trace_name, nb_trace,
2176f952 3537 "Select a trace", "Trace pathname");
3538}
abe346a3 3539
3540
b052368a 3541/* Select a module which will be loaded
3542 */
3543
93ac601b 3544char * get_load_module(MainWindow *mw_data,
3545 char ** load_module_name, int nb_module)
b052368a 3546{
93ac601b 3547 return get_selection(mw_data, load_module_name, nb_module,
b052368a 3548 "Select a module to load", "Module name");
3549}
3550
3551
3552
3553
abe346a3 3554/* Select a module which will be unloaded
3555 */
3556
93ac601b 3557char * get_unload_module(MainWindow *mw_data,
3558 char ** loaded_module_name, int nb_module)
2176f952 3559{
93ac601b 3560 return get_selection(mw_data, loaded_module_name, nb_module,
b052368a 3561 "Select a module to unload", "Module name");
2176f952 3562}
3563
abe346a3 3564
3565/* Display a dialogue which shows all selectable items, let user to
3566 * select one of them
3567 */
3568
93ac601b 3569char * get_selection(MainWindow *mw_data,
3570 char ** loaded_module_name, int nb_module,
3571 char *title, char * column_title)
36b3c068 3572{
3573 GtkWidget * dialogue;
3574 GtkWidget * scroll_win;
3575 GtkWidget * tree;
3576 GtkListStore * store;
3577 GtkTreeViewColumn * column;
3578 GtkCellRenderer * renderer;
3579 GtkTreeSelection * select;
3580 GtkTreeIter iter;
3581 gint id, i;
3582 char * unload_module_name = NULL;
3583
2176f952 3584 dialogue = gtk_dialog_new_with_buttons(title,
36b3c068 3585 NULL,
3586 GTK_DIALOG_MODAL,
3587 GTK_STOCK_OK,GTK_RESPONSE_ACCEPT,
3588 GTK_STOCK_CANCEL,GTK_RESPONSE_REJECT,
3589 NULL);
3590 gtk_window_set_default_size((GtkWindow*)dialogue, 500, 200);
93ac601b 3591 gtk_window_set_transient_for(GTK_WINDOW(dialogue),
3592 GTK_WINDOW(mw_data->mwindow));
36b3c068 3593
3594 scroll_win = gtk_scrolled_window_new (NULL, NULL);
3595 gtk_widget_show ( scroll_win);
3596 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_win),
3597 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
3598
3599 store = gtk_list_store_new (N_COLUMNS,G_TYPE_STRING);
3600 tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL (store));
3601 gtk_widget_show ( tree);
3602 g_object_unref (G_OBJECT (store));
3603
3604 renderer = gtk_cell_renderer_text_new ();
2176f952 3605 column = gtk_tree_view_column_new_with_attributes (column_title,
36b3c068 3606 renderer,
3607 "text", MODULE_COLUMN,
3608 NULL);
3609 gtk_tree_view_column_set_alignment (column, 0.5);
3610 gtk_tree_view_column_set_fixed_width (column, 150);
3611 gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
3612
3613 select = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree));
3614 gtk_tree_selection_set_mode (select, GTK_SELECTION_SINGLE);
3615
3616 gtk_container_add (GTK_CONTAINER (scroll_win), tree);
3617
3618 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialogue)->vbox), scroll_win,TRUE, TRUE,0);
3619
3620 for(i=0;i<nb_module;i++){
3621 gtk_list_store_append (store, &iter);
3622 gtk_list_store_set (store, &iter, MODULE_COLUMN,loaded_module_name[i],-1);
3623 }
3624
3625 id = gtk_dialog_run(GTK_DIALOG(dialogue));
d27948a3 3626 GtkTreeModel **store_model = (GtkTreeModel**)&store;
36b3c068 3627 switch(id){
3628 case GTK_RESPONSE_ACCEPT:
3629 case GTK_RESPONSE_OK:
2eef04b5 3630 if (gtk_tree_selection_get_selected (select, store_model, &iter)){
36b3c068 3631 gtk_tree_model_get ((GtkTreeModel*)store, &iter, MODULE_COLUMN, &unload_module_name, -1);
3632 }
3633 case GTK_RESPONSE_REJECT:
3634 case GTK_RESPONSE_CANCEL:
3635 default:
3636 gtk_widget_destroy(dialogue);
3637 break;
3638 }
3639
3640 return unload_module_name;
3641}
5723fa24 3642
abe346a3 3643
ef68c3ac 3644/* Insert all menu entry and tool buttons into this main window
001d8606 3645 * for modules.
3646 *
abe346a3 3647 */
3648
6c9d86dd 3649void add_all_menu_toolbar_constructors(MainWindow * mw, gpointer user_data)
5723fa24 3650{
2eef04b5 3651 guint i;
5723fa24 3652 GdkPixbuf *pixbuf;
42fcbb71 3653 lttvwindow_viewer_constructor constructor;
001d8606 3654 LttvMenus * global_menu, * instance_menu;
3655 LttvToolbars * global_toolbar, * instance_toolbar;
6c9d86dd 3656 LttvMenuClosure *menu_item;
3657 LttvToolbarClosure *toolbar_item;
5723fa24 3658 LttvAttributeValue value;
001d8606 3659 LttvIAttribute *global_attributes = LTTV_IATTRIBUTE(lttv_global_attributes());
501e4e70 3660 LttvIAttribute *attributes = mw->attributes;
001d8606 3661 GtkWidget * tool_menu_title_menu, *new_widget, *pixmap;
8f318283 3662 gboolean retval;
001d8606 3663
8f318283
BP
3664 retval= lttv_iattribute_find_by_path(global_attributes, "viewers/menu",
3665 LTTV_POINTER, &value);
3666 g_assert(retval);
001d8606 3667 if(*(value.v_pointer) == NULL)
501e4e70 3668 *(value.v_pointer) = lttv_menus_new();
001d8606 3669 global_menu = (LttvMenus*)*(value.v_pointer);
5723fa24 3670
8f318283
BP
3671 retval= lttv_iattribute_find_by_path(attributes, "viewers/menu",
3672 LTTV_POINTER, &value);
3673 g_assert(retval);
001d8606 3674 if(*(value.v_pointer) == NULL)
501e4e70 3675 *(value.v_pointer) = lttv_menus_new();
001d8606 3676 instance_menu = (LttvMenus*)*(value.v_pointer);
5723fa24 3677
8f318283
BP
3678 retval= lttv_iattribute_find_by_path(global_attributes, "viewers/toolbar",
3679 LTTV_POINTER, &value);
3680 g_assert(retval);
001d8606 3681 if(*(value.v_pointer) == NULL)
501e4e70 3682 *(value.v_pointer) = lttv_toolbars_new();
001d8606 3683 global_toolbar = (LttvToolbars*)*(value.v_pointer);
3684
8f318283
BP
3685 retval= lttv_iattribute_find_by_path(attributes, "viewers/toolbar",
3686 LTTV_POINTER, &value);
3687 g_assert(retval);
001d8606 3688 if(*(value.v_pointer) == NULL)
501e4e70 3689 *(value.v_pointer) = lttv_toolbars_new();
001d8606 3690 instance_toolbar = (LttvToolbars*)*(value.v_pointer);
3691
3692 /* Add missing menu entries to window instance */
3693 for(i=0;i<global_menu->len;i++) {
6c9d86dd 3694 menu_item = &g_array_index(global_menu, LttvMenuClosure, i);
3695
3696 //add menu_item to window instance;
3697 constructor = menu_item->con;
3698 tool_menu_title_menu = lookup_widget(mw->mwindow,"ToolMenuTitle_menu");
3699 new_widget =
501e4e70 3700 gtk_menu_item_new_with_mnemonic (menu_item->menu_text);
6c9d86dd 3701 gtk_container_add (GTK_CONTAINER (tool_menu_title_menu),
3702 new_widget);
3703 g_signal_connect ((gpointer) new_widget, "activate",
3704 G_CALLBACK (insert_viewer_wrap),
3705 constructor);
3706 gtk_widget_show (new_widget);
3707 lttv_menus_add(instance_menu, menu_item->con,
3708 menu_item->menu_path,
3709 menu_item->menu_text,
3710 new_widget);
001d8606 3711
001d8606 3712 }
3713
3714 /* Add missing toolbar entries to window instance */
3715 for(i=0;i<global_toolbar->len;i++) {
6c9d86dd 3716 toolbar_item = &g_array_index(global_toolbar, LttvToolbarClosure, i);
3717
3718 //add toolbar_item to window instance;
3719 constructor = toolbar_item->con;
3720 tool_menu_title_menu = lookup_widget(mw->mwindow,"MToolbar1");
3721 pixbuf = gdk_pixbuf_new_from_xpm_data((const char**)toolbar_item->pixmap);
3722 pixmap = gtk_image_new_from_pixbuf(pixbuf);
3723 new_widget =
3724 gtk_toolbar_append_element (GTK_TOOLBAR (tool_menu_title_menu),
3725 GTK_TOOLBAR_CHILD_BUTTON,
3726 NULL,
3727 "",
3728 toolbar_item->tooltip, NULL,
3729 pixmap, NULL, NULL);
3730 gtk_label_set_use_underline(
3731 GTK_LABEL (((GtkToolbarChild*) (
3732 g_list_last (GTK_TOOLBAR
3733 (tool_menu_title_menu)->children)->data))->label),
3734 TRUE);
3735 gtk_container_set_border_width (GTK_CONTAINER (new_widget), 1);
3736 g_signal_connect ((gpointer) new_widget,
3737 "clicked",
3738 G_CALLBACK (insert_viewer_wrap),
3739 constructor);
3740 gtk_widget_show (new_widget);
001d8606 3741
6c9d86dd 3742 lttv_toolbars_add(instance_toolbar, toolbar_item->con,
3743 toolbar_item->tooltip,
3744 toolbar_item->pixmap,
3745 new_widget);
001d8606 3746
5723fa24 3747 }
6c9d86dd 3748
5723fa24 3749}
3750
abe346a3 3751
3752/* Create a main window
3753 */
3754
8321ae6a 3755MainWindow *construct_main_window(MainWindow * parent)
5723fa24 3756{
8f318283
BP
3757 gboolean retval;
3758
2a2fa4f0 3759 g_debug("construct_main_window()");
68b48a45 3760 GtkWidget * new_window; /* New generated main window */
bca3b81f 3761 MainWindow * new_m_window;/* New main window structure */
5723fa24 3762 GtkNotebook * notebook;
f7afe191 3763 LttvIAttribute *attributes =
3764 LTTV_IATTRIBUTE(g_object_new(LTTV_ATTRIBUTE_TYPE, NULL));
3765 LttvAttributeValue value;
e865422c 3766
bca3b81f 3767 new_m_window = g_new(MainWindow, 1);
5723fa24 3768
3769 // Add the object's information to the module's array
68b48a45 3770 g_main_window_list = g_slist_append(g_main_window_list, new_m_window);
5723fa24 3771
68b48a45 3772 new_window = create_MWindow();
3773 gtk_widget_show (new_window);
5723fa24 3774
bca3b81f 3775 new_m_window->mwindow = new_window;
a43d67ba 3776 new_m_window->attributes = attributes;
5723fa24 3777
8f318283
BP
3778 retval= lttv_iattribute_find_by_path(attributes, "viewers/menu",
3779 LTTV_POINTER, &value);
3780 g_assert(retval);
501e4e70 3781 *(value.v_pointer) = lttv_menus_new();
001d8606 3782
8f318283
BP
3783 retval= lttv_iattribute_find_by_path(attributes, "viewers/toolbar",
3784 LTTV_POINTER, &value);
3785 g_assert(retval);
501e4e70 3786 *(value.v_pointer) = lttv_toolbars_new();
2061e03d 3787
6c9d86dd 3788 add_all_menu_toolbar_constructors(new_m_window, NULL);
5723fa24 3789
2d262115 3790 g_object_set_data_full(G_OBJECT(new_window),
3791 "main_window_data",
3792 (gpointer)new_m_window,
3793 (GDestroyNotify)g_free);
5723fa24 3794 //create a default tab
bca3b81f 3795 notebook = (GtkNotebook *)lookup_widget(new_m_window->mwindow, "MNotebook");
5723fa24 3796 if(notebook == NULL){
56e5a0f7 3797 g_info("Notebook does not exist\n");
8321ae6a 3798 /* FIXME : destroy partially created widgets */
3799 g_free(new_m_window);
3800 return NULL;
5723fa24 3801 }
e800cf84 3802 //gtk_notebook_popup_enable (GTK_NOTEBOOK(notebook));
5723fa24 3803 //for now there is no name field in LttvTraceset structure
3804 //Use "Traceset" as the label for the default tab
6ced96ef 3805 if(parent) {
3806 GtkWidget * parent_notebook = lookup_widget(parent->mwindow, "MNotebook");
3807 GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(parent_notebook),
3808 gtk_notebook_get_current_page(GTK_NOTEBOOK(parent_notebook)));
3809 Tab *parent_tab;
3810
3811 if(!page) {
3812 parent_tab = NULL;
3813 } else {
e433e6d6 3814 LttvPluginTab *ptab;
3815 ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin");
3816 parent_tab = ptab->tab;
6ced96ef 3817 }
e433e6d6 3818 LttvPluginTab *ptab = g_object_new(LTTV_TYPE_PLUGIN_TAB, NULL);
3819 init_tab(ptab->tab,
3820 new_m_window, parent_tab, notebook, "Traceset");
3821 ptab->parent.top_widget = ptab->tab->top_widget;
3822 g_object_set_data_full(
3823 G_OBJECT(ptab->tab->vbox),
3824 "Tab_Plugin",
3825 ptab,
3826 (GDestroyNotify)tab_destructor);
6ced96ef 3827 } else {
e433e6d6 3828 LttvPluginTab *ptab = g_object_new(LTTV_TYPE_PLUGIN_TAB, NULL);
3829 init_tab(ptab->tab, new_m_window, NULL, notebook, "Traceset");
3830 ptab->parent.top_widget = ptab->tab->top_widget;
3831 g_object_set_data_full(
3832 G_OBJECT(ptab->tab->vbox),
3833 "Tab_Plugin",
3834 ptab,
3835 (GDestroyNotify)tab_destructor);
6cec4cd2 3836 }
91fd6881 3837
6cec4cd2 3838 /* Insert default viewers */
3839 {
3840 LttvAttributeType type;
3841 LttvAttributeName name;
3842 LttvAttributeValue value;
3843 LttvAttribute *attribute;
3844
3845 LttvIAttribute *attributes_global =
3846 LTTV_IATTRIBUTE(lttv_global_attributes());
3847
43ed82b5 3848 attribute = LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
3849 LTTV_IATTRIBUTE(attributes_global),
3850 LTTV_VIEWER_CONSTRUCTORS));
3851 g_assert(attribute);
6cec4cd2 3852
3853 name = g_quark_from_string("guievents");
3854 type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute),
3855 name, &value);
3856 if(type == LTTV_POINTER) {
3857 lttvwindow_viewer_constructor viewer_constructor =
3858 (lttvwindow_viewer_constructor)*value.v_pointer;
3859 insert_viewer(new_window, viewer_constructor);
4266dc7f 3860 }
e025a729 3861
6cec4cd2 3862 name = g_quark_from_string("guicontrolflow");
3863 type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute),
3864 name, &value);
3865 if(type == LTTV_POINTER) {
3866 lttvwindow_viewer_constructor viewer_constructor =
3867 (lttvwindow_viewer_constructor)*value.v_pointer;
3868 insert_viewer(new_window, viewer_constructor);
3869 }
e025a729 3870
6cec4cd2 3871 name = g_quark_from_string("guistatistics");
3872 type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute),
3873 name, &value);
3874 if(type == LTTV_POINTER) {
3875 lttvwindow_viewer_constructor viewer_constructor =
3876 (lttvwindow_viewer_constructor)*value.v_pointer;
3877 insert_viewer(new_window, viewer_constructor);
e025a729 3878 }
4266dc7f 3879 }
5723fa24 3880
56e5a0f7 3881 g_info("There are now : %d windows\n",g_slist_length(g_main_window_list));
8321ae6a 3882
3883 return new_m_window;
5723fa24 3884}
3885
abe346a3 3886
3887/* Free the memory occupied by a tab structure
3888 * destroy the tab
3889 */
3890
e433e6d6 3891void tab_destructor(LttvPluginTab * ptab)
f7afe191 3892{
451aaf27 3893#ifdef BABEL_CLEANUP
716e4367 3894 int i, nb, ref_count;
3895 LttvTrace * trace;
e433e6d6 3896 Tab *tab = ptab->tab;
716e4367 3897
3234f094 3898 if(tab->attributes)
3899 g_object_unref(tab->attributes);
501e4e70 3900
3234f094 3901 if(tab->interrupted_state)
3902 g_object_unref(tab->interrupted_state);
501e4e70 3903
2061e03d 3904
3234f094 3905 if(tab->traceset_info->traceset_context != NULL){
784705cc 3906 //remove state update hooks
3907 lttv_state_remove_event_hooks(
3234f094 3908 (LttvTracesetState*)tab->traceset_info->
784705cc 3909 traceset_context);
3234f094 3910 lttv_context_fini(LTTV_TRACESET_CONTEXT(tab->traceset_info->
716e4367 3911 traceset_context));
3234f094 3912 g_object_unref(tab->traceset_info->traceset_context);
716e4367 3913 }
3234f094 3914 if(tab->traceset_info->traceset != NULL) {
3915 nb = lttv_traceset_number(tab->traceset_info->traceset);
716e4367 3916 for(i = 0 ; i < nb ; i++) {
3234f094 3917 trace = lttv_traceset_get(tab->traceset_info->traceset, i);
716e4367 3918 ref_count = lttv_trace_get_ref_number(trace);
49bf71b5 3919 if(ref_count <= 1){
a1a2b649 3920 ltt_trace_close(lttv_trace(trace));
49bf71b5 3921 }
716e4367 3922 }
dc5e5266 3923 }
3234f094 3924 lttv_traceset_destroy(tab->traceset_info->traceset);
501e4e70 3925 /* Remove the idle events requests processing function of the tab */
3234f094 3926 g_idle_remove_by_data(tab);
501e4e70 3927
3234f094 3928 g_slist_free(tab->events_requests);
3929 g_free(tab->traceset_info);
e433e6d6 3930 //g_free(tab);
3931 g_object_unref(ptab);
451aaf27 3932#endif /* BABEL_CLEANUP */
f7afe191 3933}
3934
abe346a3 3935
3936/* Create a tab and insert it into the current main window
3937 */
3938
e433e6d6 3939void init_tab(Tab *tab, MainWindow * mw, Tab *copy_tab,
716e4367 3940 GtkNotebook * notebook, char * label)
5723fa24 3941{
451aaf27 3942
5723fa24 3943 GList * list;
e433e6d6 3944 //Tab * tab;
3945 //LttvFilter *filter = NULL;
a43d67ba 3946
abe346a3 3947 //create a new tab data structure
e433e6d6 3948 //tab = g_new(Tab,1);
716e4367 3949
abe346a3 3950 //construct and initialize the traceset_info
6ced96ef 3951 tab->traceset_info = g_new(TracesetInfo,1);
a43d67ba 3952
4266dc7f 3953 if(copy_tab) {
6ced96ef 3954 tab->traceset_info->traceset =
4266dc7f 3955 lttv_traceset_copy(copy_tab->traceset_info->traceset);
dc5e5266 3956
3957 /* Copy the previous tab's filter */
3958 /* We can clone the filter, as we copy the trace set also */
3959 /* The filter must always be in sync with the trace set */
451aaf27
FD
3960
3961#ifdef BABEL_CLEANUP
ebcead4a 3962 tab->filter = lttv_filter_clone(copy_tab->filter);
451aaf27 3963#endif /* BABEL_CLEANUP */
4266dc7f 3964 } else {
6ced96ef 3965 tab->traceset_info->traceset = lttv_traceset_new();
451aaf27 3966
dc5e5266 3967 tab->filter = NULL;
716e4367 3968 }
84ddf5c9 3969#ifdef DEBUG
20fde85f 3970 lttv_attribute_write_xml(
6ced96ef 3971 lttv_traceset_attribute(tab->traceset_info->traceset),
20fde85f 3972 stdout,
3973 0, 4);
3974 fflush(stdout);
84ddf5c9 3975#endif //DEBUG
451aaf27 3976//
e800cf84 3977 tab->time_manager_lock = FALSE;
3978 tab->current_time_manager_lock = FALSE;
451aaf27 3979#ifdef BABEL_CLEANUP
716e4367 3980 //FIXME copy not implemented in lower level
6ced96ef 3981 tab->traceset_info->traceset_context =
716e4367 3982 g_object_new(LTTV_TRACESET_STATS_TYPE, NULL);
784705cc 3983 //add state update hooks
3984 lttv_state_add_event_hooks(
6ced96ef 3985 (LttvTracesetState*)tab->traceset_info->traceset_context);
451aaf27 3986#endif //BABEL_CLEANUP
abe346a3 3987 //determine the current_time and time_window of the tab
e800cf84 3988#if 0
6ced96ef 3989 if(copy_tab != NULL){
3990 tab->time_window = copy_tab->time_window;
3991 tab->current_time = copy_tab->current_time;
5723fa24 3992 }else{
6ced96ef 3993 tab->time_window.start_time =
3994 LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context)->
3995 time_span.start_time;
f7afe191 3996 if(DEFAULT_TIME_WIDTH_S <
6ced96ef 3997 LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context)->
3998 time_span.end_time.tv_sec)
68b48a45 3999 tmp_time.tv_sec = DEFAULT_TIME_WIDTH_S;
f7afe191 4000 else
68b48a45 4001 tmp_time.tv_sec =
6ced96ef 4002 LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context)->
4003 time_span.end_time.tv_sec;
68b48a45 4004 tmp_time.tv_nsec = 0;
6ced96ef 4005 tab->time_window.time_width = tmp_time ;
4006 tab->current_time.tv_sec =
4007 LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context)->
4008 time_span.start_time.tv_sec;
4009 tab->current_time.tv_nsec =
4010 LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context)->
4011 time_span.start_time.tv_nsec;
5723fa24 4012 }
e800cf84 4013#endif //0
6ced96ef 4014 tab->attributes = LTTV_IATTRIBUTE(g_object_new(LTTV_ATTRIBUTE_TYPE, NULL));
4015 tab->interrupted_state = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL);
b052368a 4016
58f6c2a4 4017 tab->vbox = gtk_vbox_new(FALSE, 2);
e433e6d6 4018 tab->top_widget = tab->vbox;
4019 //g_object_set_data_full(G_OBJECT(tab->top_widget), "filter",
4020// filter, (GDestroyNotify)lttv_filter_destroy);
4021
4022// g_signal_connect (G_OBJECT(tab->top_widget),
4023// "notify",
4024// G_CALLBACK (on_top_notify),
4025// (gpointer)tab);
4026
58f6c2a4 4027 tab->viewer_container = gtk_vbox_new(TRUE, 2);
b052368a 4028 tab->scrollbar = gtk_hscrollbar_new(NULL);
4029 //tab->multivpaned = gtk_multi_vpaned_new();
6c35c853 4030
b052368a 4031 gtk_box_pack_start(GTK_BOX(tab->vbox),
4032 tab->viewer_container,
4033 TRUE, /* expand */
4034 TRUE, /* Give the extra space to the child */
4035 0); /* No padding */
4249a3e8 4036
4037// if(copy_tab) {
4038// tab->time_window = copy_tab->time_window;
4039// tab->current_time = copy_tab->current_time;
4040// }
e800cf84 4041
4042 /* Create the timebar */
4172f013
YB
4043
4044 tab->MTimebar = timebar_new();
e800cf84 4045
b052368a 4046 gtk_box_pack_end(GTK_BOX(tab->vbox),
4047 tab->scrollbar,
4048 FALSE, /* Do not expand */
4049 FALSE, /* Fill has no effect here (expand false) */
4050 0); /* No padding */
e800cf84 4051
4052 gtk_box_pack_end(GTK_BOX(tab->vbox),
4053 tab->MTimebar,
4054 FALSE, /* Do not expand */
4055 FALSE, /* Fill has no effect here (expand false) */
4056 0); /* No padding */
4057
b052368a 4058 g_object_set_data(G_OBJECT(tab->viewer_container), "focused_viewer", NULL);
4059
4060
6ced96ef 4061 tab->mw = mw;
27a559b9 4062
3c031040 4063 /*{
4064 // Display a label with a X
27a559b9 4065 GtkWidget *w_hbox = gtk_hbox_new(FALSE, 4);
4066 GtkWidget *w_label = gtk_label_new (label);
4067 GtkWidget *pixmap = create_pixmap(GTK_WIDGET(notebook), "close.png");
4068 GtkWidget *w_button = gtk_button_new ();
4069 gtk_container_add(GTK_CONTAINER(w_button), pixmap);
4070 //GtkWidget *w_button = gtk_button_new_with_label("x");
4071
4072 gtk_button_set_relief(GTK_BUTTON(w_button), GTK_RELIEF_NONE);
4073
4074 gtk_box_pack_start(GTK_BOX(w_hbox), w_label, TRUE, TRUE, 0);
4075 gtk_box_pack_end(GTK_BOX(w_hbox), w_button, FALSE,
4076 FALSE, 0);
a43d67ba 4077
27a559b9 4078 g_signal_connect_swapped (w_button, "clicked",
4079 G_CALLBACK (on_close_tab_X_clicked),
4080 tab->multi_vpaned);
5723fa24 4081
3c031040 4082 gtk_widget_set_state(w_button, GTK_STATE_ACTIVE);
4083
27a559b9 4084 gtk_widget_show (w_label);
4085 gtk_widget_show (pixmap);
4086 gtk_widget_show (w_button);
4087 gtk_widget_show (w_hbox);
4088
4089 tab->label = w_hbox;
3c031040 4090 }*/
4091
4092
4093 tab->label = gtk_label_new (label);
b052368a 4094
4095 gtk_widget_show(tab->label);
4096 gtk_widget_show(tab->scrollbar);
4172f013 4097 gtk_widget_show(tab->MTimebar);
b052368a 4098 gtk_widget_show(tab->viewer_container);
4099 gtk_widget_show(tab->vbox);
4172f013 4100
b052368a 4101 //gtk_widget_show(tab->multivpaned);
3c031040 4102
4103
501e4e70 4104 /* Start with empty events requests list */
6ced96ef 4105 tab->events_requests = NULL;
4106 tab->events_request_pending = FALSE;
5698740e 4107 tab->stop_foreground = FALSE;
4108
a43d67ba 4109
540edb40 4110
b052368a 4111 g_signal_connect(G_OBJECT(tab->scrollbar), "value-changed",
4112 G_CALLBACK(scroll_value_changed_cb), tab);
e800cf84 4113
4172f013
YB
4114
4115 /* Timebar signal handler */
4116 g_signal_connect(G_OBJECT(tab->MTimebar), "start-time-changed",
4117 G_CALLBACK(on_timebar_starttime_changed), tab);
4118 g_signal_connect(G_OBJECT(tab->MTimebar), "end-time-changed",
4119 G_CALLBACK(on_timebar_endtime_changed), tab);
4120 g_signal_connect(G_OBJECT(tab->MTimebar), "current-time-changed",
4121 G_CALLBACK(on_timebar_currenttime_changed), tab);
e800cf84 4122
b052368a 4123 //g_signal_connect(G_OBJECT(tab->scrollbar), "changed",
4124 // G_CALLBACK(scroll_value_changed_cb), tab);
4125
4126
784705cc 4127 //insert tab into notebook
6ced96ef 4128 gtk_notebook_append_page(notebook,
b052368a 4129 tab->vbox,
4130 tab->label);
5723fa24 4131 list = gtk_container_get_children(GTK_CONTAINER(notebook));
4132 gtk_notebook_set_current_page(notebook,g_list_length(list)-1);
a43d67ba 4133 // always show : not if(g_list_length(list)>1)
4134 gtk_notebook_set_show_tabs(notebook, TRUE);
4135
4249a3e8 4136 if(copy_tab) {
4137 lttvwindow_report_time_window(tab, copy_tab->time_window);
4138 lttvwindow_report_current_time(tab, copy_tab->current_time);
4139 } else {
4140 TimeWindow time_window;
4141
4142 time_window.start_time = ltt_time_zero;
4143 time_window.end_time = ltt_time_add(time_window.start_time,
4144 lttvwindow_default_time_width);
4145 time_window.time_width = lttvwindow_default_time_width;
4146 time_window.time_width_double = ltt_time_to_double(time_window.time_width);
4147
4148 lttvwindow_report_time_window(tab, time_window);
4149 lttvwindow_report_current_time(tab, ltt_time_zero);
4150 }
451aaf27 4151
4249a3e8 4152 LttvTraceset *traceset = tab->traceset_info->traceset;
4153 SetTraceset(tab, traceset);
a43d67ba 4154}
4155
501e4e70 4156/*
4157 * execute_events_requests
4158 *
4159 * Idle function that executes the pending requests for a tab.
4160 *
4161 * @return return value : TRUE : keep the idle function, FALSE : remove it.
4162 */
4163gboolean execute_events_requests(Tab *tab)
a43d67ba 4164{
501e4e70 4165 return ( lttvwindow_process_pending_requests(tab) );
a43d67ba 4166}
4167
8321ae6a 4168
451aaf27 4169__EXPORT void create_main_window_with_trace_list(GSList *traces)
8321ae6a 4170{
451aaf27 4171
8e3a7c75 4172 GSList *iter = NULL;
8321ae6a 4173
4174 /* Create window */
4175 MainWindow *mw = construct_main_window(NULL);
4176 GtkWidget *widget = mw->mwindow;
4177
4178 GtkWidget * notebook = lookup_widget(widget, "MNotebook");
4179 GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook),
4180 gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)));
e433e6d6 4181 LttvPluginTab *ptab;
8321ae6a 4182 Tab *tab;
4183
4184 if(!page) {
e433e6d6 4185 ptab = create_new_tab(widget, NULL);
4186 tab = ptab->tab;
8321ae6a 4187 } else {
e433e6d6 4188 ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin");
4189 tab = ptab->tab;
8321ae6a 4190 }
451aaf27
FD
4191
4192 LttvTraceset * traceset = lttv_traceset_new();
8e3a7c75 4193 for(iter=traces; iter!=NULL; iter=g_slist_next(iter)) {
4194 gchar *path = (gchar*)iter->data;
4195 /* Add trace */
4196 gchar abs_path[PATH_MAX];
8e3a7c75 4197
451aaf27 4198
8e3a7c75 4199 get_absolute_pathname(path, abs_path);
451aaf27
FD
4200
4201 if(lttv_traceset_add_path(traceset,abs_path) != 0 ){ /*failure*/
4202
4203 g_warning("cannot open trace %s", abs_path);
8e3a7c75 4204
4205 GtkWidget *dialogue =
4206 gtk_message_dialog_new(
4207 GTK_WINDOW(gtk_widget_get_toplevel(widget)),
4208 GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
4209 GTK_MESSAGE_ERROR,
4210 GTK_BUTTONS_OK,
0246f776 4211 "Cannot open trace : maybe you should enter in the directory "
8e3a7c75 4212 "to select it ?");
4213 gtk_dialog_run(GTK_DIALOG(dialogue));
4214 gtk_widget_destroy(dialogue);
8321ae6a 4215 }
451aaf27
FD
4216 else{
4217 SetTraceset(tab, traceset);
4218 }
4219 }
8321ae6a 4220}
4221
This page took 0.317994 seconds and 4 git commands to generate.