add version to help and about
[lttv.git] / ltt / branches / poly / lttv / modules / gui / lttvwindow / lttvwindow / callbacks.c
index b126b85e62268c996b7f4e19fa9a67d74c58b324..98f58d60a7845ccdb7fb71a52abac55d3f2d7a44 100644 (file)
 #include <lttvwindow/toolbar.h>
 #include <lttvwindow/lttvwindow.h>
 #include <lttvwindow/lttvwindowtraces.h>
 #include <lttvwindow/toolbar.h>
 #include <lttvwindow/lttvwindow.h>
 #include <lttvwindow/lttvwindowtraces.h>
-#include <lttvwindow/gtkdirsel.h>
+#include <lttvwindow/lttv_plugin_tab.h>
 
 
-
-#define DEFAULT_TIME_WIDTH_S   1
+static LttTime lttvwindow_default_time_width = { 1, 0 };
 #define CLIP_BUF 256 // size of clipboard buffer
 
 extern LttvTrace *g_init_trace ;
 #define CLIP_BUF 256 // size of clipboard buffer
 
 extern LttvTrace *g_init_trace ;
@@ -62,18 +61,22 @@ extern GSList * g_main_window_list;
 static char remember_plugins_dir[PATH_MAX] = "";
 static char remember_trace_dir[PATH_MAX] = "";
 
 static char remember_plugins_dir[PATH_MAX] = "";
 static char remember_trace_dir[PATH_MAX] = "";
 
+void tab_destructor(LttvPluginTab * ptab);
 
 MainWindow * get_window_data_struct(GtkWidget * widget);
 
 MainWindow * get_window_data_struct(GtkWidget * widget);
-char * get_load_module(char ** load_module_name, int nb_module);
-char * get_unload_module(char ** loaded_module_name, int nb_module);
-char * get_remove_trace(char ** all_trace_name, int nb_trace);
-char * get_selection(char ** all_name, int nb, char *title, char * column_title);
-Tab* create_tab(MainWindow * mw, Tab *copy_tab,
+char * get_load_module(MainWindow *mw,
+    char ** load_module_name, int nb_module);
+char * get_unload_module(MainWindow *mw,
+    char ** loaded_module_name, int nb_module);
+char * get_remove_trace(MainWindow *mw, char ** all_trace_name, int nb_trace);
+char * get_selection(MainWindow *mw,
+    char ** all_name, int nb, char *title, char * column_title);
+void init_tab(Tab *tab, MainWindow * mw, Tab *copy_tab,
                  GtkNotebook * notebook, char * label);
 
 static void insert_viewer(GtkWidget* widget, lttvwindow_viewer_constructor constructor);
 
                  GtkNotebook * notebook, char * label);
 
 static void insert_viewer(GtkWidget* widget, lttvwindow_viewer_constructor constructor);
 
-Tab *create_new_tab(GtkWidget* widget, gpointer user_data);
+LttvPluginTab *create_new_tab(GtkWidget* widget, gpointer user_data);
 
 static gboolean lttvwindow_process_pending_requests(Tab *tab);
 
 
 static gboolean lttvwindow_process_pending_requests(Tab *tab);
 
@@ -299,7 +302,63 @@ static gboolean on_MEventBox5b_paste(GtkWidget *widget, GdkEventButton *event,
   return 0;
 }
 
   return 0;
 }
 
+/* Interval */
+static void MEventBox8_receive(GtkClipboard *clipboard,
+                          const gchar *text,
+                          gpointer data)
+{
+  if(text == NULL) return;
+  Tab *tab = (Tab *)data;
+  gchar buffer[CLIP_BUF];
+  gchar *ptr = buffer, *ptr_sec, *ptr_nsec;
+
+  strncpy(buffer, text, CLIP_BUF);
+  
+  while(!isdigit(*ptr) && ptr < buffer+CLIP_BUF-1) ptr++;
+                                                       /* remove leading junk */
+  ptr_sec = ptr;
+  while(isdigit(*ptr) && ptr < buffer+CLIP_BUF-1) ptr++;
+                                                 /* read all the first number */
+  *ptr = '\0';
+  ptr++;
+
+  while(!isdigit(*ptr) && ptr < buffer+CLIP_BUF-1) ptr++;
+                                                       /* remove leading junk */
+  ptr_nsec = ptr;
+  while(isdigit(*ptr) && ptr < buffer+CLIP_BUF-1) ptr++;
+                                                 /* read all the first number */
+  *ptr = '\0';
+
+  gtk_spin_button_set_value(GTK_SPIN_BUTTON(tab->MEntry7),
+                            (double)strtoul(ptr_sec, NULL, 10));
+  gtk_spin_button_set_value(GTK_SPIN_BUTTON(tab->MEntry8),
+                            (double)strtoul(ptr_nsec, NULL, 10));
+}
+
+/* Interval */
+static gboolean on_MEventBox8_paste(GtkWidget *widget, GdkEventButton *event,
+                                gpointer data)
+{
+  Tab *tab = (Tab*)data;
+
+  GtkClipboard *clip = gtk_clipboard_get_for_display(gdk_display_get_default(),
+                                                     GDK_SELECTION_PRIMARY);
+  gtk_clipboard_request_text(clip,
+                             (GtkClipboardTextReceivedFunc)MEventBox8_receive,
+                             (gpointer)tab);
+  return 0;
+}
+
+#if 0
+static void on_top_notify(GObject    *gobject,
+               GParamSpec *arg1,
+               gpointer    user_data)
+{
+       Tab *tab = (Tab*)user_data;
+       g_message("in on_top_notify.\n");
 
 
+}
+#endif //0
 static gboolean viewer_grab_focus(GtkWidget *widget, GdkEventButton *event,
                                   gpointer data)
 {
 static gboolean viewer_grab_focus(GtkWidget *widget, GdkEventButton *event,
                                   gpointer data)
 {
@@ -331,6 +390,18 @@ static void connect_focus_recursive(GtkWidget *widget,
                     (gpointer)viewer);
 }
 
                     (gpointer)viewer);
 }
 
+/* Stop all the processings and call gtk_main_quit() */
+static void mainwindow_quit()
+{
+  lttvwindowtraces_unregister_requests(g_quark_from_string("stats"));
+  lttvwindowtraces_unregister_requests(g_quark_from_string("state"));
+  lttvwindowtraces_unregister_computation_hooks(g_quark_from_string("stats"));
+  lttvwindowtraces_unregister_computation_hooks(g_quark_from_string("state"));
+
+  gtk_main_quit();
+}
+
+
 /* insert_viewer function constructs an instance of a viewer first,
  * then inserts the widget of the instance into the container of the
  * main window
 /* insert_viewer function constructs an instance of a viewer first,
  * then inserts the widget of the instance into the container of the
  * main window
@@ -353,17 +424,19 @@ void insert_viewer(GtkWidget* widget, lttvwindow_viewer_constructor constructor)
   TimeInterval * time_interval;
   GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook),
                       gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)));
   TimeInterval * time_interval;
   GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook),
                       gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)));
+  LttvPluginTab *ptab;
   Tab *tab;
   
   if(!page) {
   Tab *tab;
   
   if(!page) {
-    tab = create_new_tab(widget, NULL);
+    ptab = create_new_tab(widget, NULL);
   } else {
   } else {
-    tab = (Tab *)g_object_get_data(G_OBJECT(page), "Tab_Info");
+    ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin");
   }
   }
+  tab = ptab->tab;
 
   viewer_container = tab->viewer_container;
 
 
   viewer_container = tab->viewer_container;
 
-  viewer = (GtkWidget*)constructor(tab);
+  viewer = (GtkWidget*)constructor(ptab);
   if(viewer)
   {
     //gtk_multivpaned_widget_add(GTK_MULTIVPANED(multivpaned), viewer); 
   if(viewer)
   {
     //gtk_multivpaned_widget_add(GTK_MULTIVPANED(multivpaned), viewer); 
@@ -396,8 +469,8 @@ int SetTraceset(Tab * tab, LttvTraceset *traceset)
   LttvTracesetContext *tsc =
         LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context);
   TimeInterval time_span = tsc->time_span;
   LttvTracesetContext *tsc =
         LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context);
   TimeInterval time_span = tsc->time_span;
-  TimeWindow new_time_window;
-  LttTime new_current_time;
+  TimeWindow new_time_window = tab->time_window;
+  LttTime new_current_time = tab->current_time;
 
   /* Set the tab's time window and current time if
    * out of bounds */
 
   /* Set the tab's time window and current time if
    * out of bounds */
@@ -409,24 +482,23 @@ int SetTraceset(Tab * tab, LttvTraceset *traceset)
     new_current_time = time_span.start_time;
     
     LttTime tmp_time;
     new_current_time = time_span.start_time;
     
     LttTime tmp_time;
-
-    if(DEFAULT_TIME_WIDTH_S < time_span.end_time.tv_sec)
-      tmp_time.tv_sec = DEFAULT_TIME_WIDTH_S;
+    
+    if(ltt_time_compare(lttvwindow_default_time_width,
+          ltt_time_sub(time_span.end_time, time_span.start_time)) < 0
+        ||
+       ltt_time_compare(time_span.end_time, time_span.start_time) == 0)
+      tmp_time = lttvwindow_default_time_width;
     else
     else
-      tmp_time.tv_sec = time_span.end_time.tv_sec;
-    tmp_time.tv_nsec = 0;
+      tmp_time = time_span.end_time;
+
     new_time_window.time_width = tmp_time ;
     new_time_window.time_width_double = ltt_time_to_double(tmp_time);
     new_time_window.end_time = ltt_time_add(new_time_window.start_time,
                                             new_time_window.time_width) ;
   }
     new_time_window.time_width = tmp_time ;
     new_time_window.time_width_double = ltt_time_to_double(tmp_time);
     new_time_window.end_time = ltt_time_add(new_time_window.start_time,
                                             new_time_window.time_width) ;
   }
-  time_change_manager(tab, new_time_window);
-  current_time_change_manager(tab, new_current_time);
 
 
-  //FIXME : we delete the filter tree, when it should be updated.
-  lttv_filter_destroy(tab->filter);
-  tab->filter = NULL;
-  
 #if 0
   /* Set scrollbar */
   GtkAdjustment *adjustment = gtk_range_get_adjustment(GTK_RANGE(tab->scrollbar));
 #if 0
   /* Set scrollbar */
   GtkAdjustment *adjustment = gtk_range_get_adjustment(GTK_RANGE(tab->scrollbar));
@@ -489,7 +561,9 @@ int SetTraceset(Tab * tab, LttvTraceset *traceset)
   if(tmp == NULL) retval = 1;
   else lttv_hooks_call(tmp,traceset);
 
   if(tmp == NULL) retval = 1;
   else lttv_hooks_call(tmp,traceset);
 
+  time_change_manager(tab, new_time_window);
+  current_time_change_manager(tab, new_current_time);
+
   return retval;
 }
 
   return retval;
 }
 
@@ -502,7 +576,7 @@ int SetTraceset(Tab * tab, LttvTraceset *traceset)
  *  0 : filters updated
  *  1 : no filter hooks to update; not an error.
  */
  *  0 : filters updated
  *  1 : no filter hooks to update; not an error.
  */
-
+#if 0
 int SetFilter(Tab * tab, gpointer filter)
 {
   LttvHooks * tmp;
 int SetFilter(Tab * tab, gpointer filter)
 {
   LttvHooks * tmp;
@@ -518,7 +592,7 @@ int SetFilter(Tab * tab, gpointer filter)
 
   return 0;
 }
 
   return 0;
 }
-
+#endif //0
 
 
 /**
 
 
 /**
@@ -690,7 +764,9 @@ void move_down_viewer(GtkWidget * widget, gpointer user_data)
   if(!page) {
     return;
   } else {
   if(!page) {
     return;
   } else {
-    tab = (Tab *)g_object_get_data(G_OBJECT(page), "Tab_Info");
+    LttvPluginTab *ptab;
+    ptab = (Tab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin");
+    tab = ptab->tab;
   }
 
   //gtk_multivpaned_widget_move_up(GTK_MULTIVPANED(tab->multivpaned));
   }
 
   //gtk_multivpaned_widget_move_up(GTK_MULTIVPANED(tab->multivpaned));
@@ -722,7 +798,9 @@ void move_up_viewer(GtkWidget * widget, gpointer user_data)
   if(!page) {
     return;
   } else {
   if(!page) {
     return;
   } else {
-    tab = (Tab *)g_object_get_data(G_OBJECT(page), "Tab_Info");
+    LttvPluginTab *ptab;
+    ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin");
+    tab = ptab->tab;
   }
 
   //gtk_multivpaned_widget_move_down(GTK_MULTIVPANED(tab->multivpaned));
   }
 
   //gtk_multivpaned_widget_move_down(GTK_MULTIVPANED(tab->multivpaned));
@@ -761,7 +839,9 @@ void delete_viewer(GtkWidget * widget, gpointer user_data)
   if(!page) {
     return;
   } else {
   if(!page) {
     return;
   } else {
-    tab = (Tab *)g_object_get_data(G_OBJECT(page), "Tab_Info");
+    LttvPluginTab *ptab;
+    ptab = (Tab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin");
+    tab = ptab->tab;
   }
 
   //gtk_multivpaned_widget_delete(GTK_MULTIVPANED(tab->multivpaned));
   }
 
   //gtk_multivpaned_widget_delete(GTK_MULTIVPANED(tab->multivpaned));
@@ -791,6 +871,9 @@ void open_traceset(GtkWidget * widget, gpointer user_data)
 
   gtk_file_selection_hide_fileop_buttons(file_selector);
   
 
   gtk_file_selection_hide_fileop_buttons(file_selector);
   
+  gtk_window_set_transient_for(GTK_WINDOW(file_selector),
+      GTK_WINDOW(mw_data->mwindow));
+
   id = gtk_dialog_run(GTK_DIALOG(file_selector));
   switch(id){
     case GTK_RESPONSE_ACCEPT:
   id = gtk_dialog_run(GTK_DIALOG(file_selector));
   switch(id){
     case GTK_RESPONSE_ACCEPT:
@@ -809,42 +892,6 @@ void open_traceset(GtkWidget * widget, gpointer user_data)
 
 }
 
 
 }
 
-static void events_request_free(EventsRequest *events_request)
-{
-  if(events_request == NULL) return;
-
-  if(events_request->start_position != NULL)
-       lttv_traceset_context_position_destroy(events_request->start_position);
-  if(events_request->end_position != NULL)
-       lttv_traceset_context_position_destroy(events_request->end_position);
-  if(events_request->hooks != NULL)
-    g_array_free(events_request->hooks, TRUE);
-  if(events_request->before_chunk_traceset != NULL)
-       lttv_hooks_destroy(events_request->before_chunk_traceset);
-  if(events_request->before_chunk_trace != NULL)
-       lttv_hooks_destroy(events_request->before_chunk_trace);
-  if(events_request->before_chunk_tracefile != NULL)
-       lttv_hooks_destroy(events_request->before_chunk_tracefile);
-  if(events_request->event != NULL)
-       lttv_hooks_destroy(events_request->event);
-  if(events_request->event_by_id != NULL)
-       lttv_hooks_by_id_destroy(events_request->event_by_id);
-  if(events_request->after_chunk_tracefile != NULL)
-       lttv_hooks_destroy(events_request->after_chunk_tracefile);
-  if(events_request->after_chunk_trace != NULL)
-       lttv_hooks_destroy(events_request->after_chunk_trace);
-  if(events_request->after_chunk_traceset != NULL)
-       lttv_hooks_destroy(events_request->after_chunk_traceset);
-  if(events_request->before_request != NULL)
-       lttv_hooks_destroy(events_request->before_request);
-  if(events_request->after_request != NULL)
-       lttv_hooks_destroy(events_request->after_request);
-
-  g_free(events_request);
-}
-
-
-
 /* lttvwindow_process_pending_requests
  * 
  * This internal function gets called by g_idle, taking care of the pending
 /* lttvwindow_process_pending_requests
  * 
  * This internal function gets called by g_idle, taking care of the pending
@@ -881,6 +928,8 @@ gboolean lttvwindow_process_pending_requests(Tab *tab)
   guint count;
   LttvTracesetContextPosition *end_position;
   
   guint count;
   LttvTracesetContextPosition *end_position;
   
+  if(lttvwindow_preempt_count > 0) return TRUE;
+  
   if(tab == NULL) {
     g_critical("Foreground processing : tab does not exist. Processing removed.");
     return FALSE;
   if(tab == NULL) {
     g_critical("Foreground processing : tab does not exist. Processing removed.");
     return FALSE;
@@ -939,7 +988,7 @@ gboolean lttvwindow_process_pending_requests(Tab *tab)
       }
     }
   }
       }
     }
   }
-#if 0
+  
   /* 0.1 Lock Traces */
   {
     guint iter_trace=0;
   /* 0.1 Lock Traces */
   {
     guint iter_trace=0;
@@ -957,8 +1006,9 @@ gboolean lttvwindow_process_pending_requests(Tab *tab)
   }
 
   /* 0.2 Seek tracefiles positions to context position */
   }
 
   /* 0.2 Seek tracefiles positions to context position */
+  //g_assert(lttv_process_traceset_seek_position(tsc, sync_position) == 0);
   lttv_process_traceset_synchronize_tracefiles(tsc);
   lttv_process_traceset_synchronize_tracefiles(tsc);
-#endif //0
+  
   
   /* Events processing algorithm implementation */
   /* Warning : the gtk_events_pending takes a LOT of cpu time. So what we do
   
   /* Events processing algorithm implementation */
   /* Warning : the gtk_events_pending takes a LOT of cpu time. So what we do
@@ -1100,10 +1150,15 @@ gboolean lttvwindow_process_pending_requests(Tab *tab)
                lttv_process_traceset_middle(tsc,
                                             events_request->start_time,
                                             G_MAXUINT, NULL);
                lttv_process_traceset_middle(tsc,
                                             events_request->start_time,
                                             G_MAXUINT, NULL);
+#ifdef DEBUG
+            g_assert(seek_count < LTTV_STATE_SAVE_INTERVAL);
+#endif //DEBUG
 
 
         } else {
           LttTime pos_time;
 
 
         } else {
           LttTime pos_time;
+                                       LttvTracefileContext *tfc =
+                                               lttv_traceset_context_get_current_tfc(tsc);
           /* Else, the first request in list_in is a position request */
           /* If first req in list_in pos != current pos */
           g_assert(events_request->start_position != NULL);
           /* Else, the first request in list_in is a position request */
           /* If first req in list_in pos != current pos */
           g_assert(events_request->start_position != NULL);
@@ -1112,10 +1167,16 @@ gboolean lttvwindow_process_pending_requests(Tab *tab)
                       events_request->start_position).tv_sec,
                  lttv_traceset_context_position_get_time(
                       events_request->start_position).tv_nsec);
                       events_request->start_position).tv_sec,
                  lttv_traceset_context_position_get_time(
                       events_request->start_position).tv_nsec);
-
-          g_debug("SEEK POS context time : %lu, %lu", 
-               lttv_traceset_context_get_current_tfc(tsc)->timestamp.tv_sec,
-               lttv_traceset_context_get_current_tfc(tsc)->timestamp.tv_nsec);
+                                       
+                                       if(tfc) {
+                                               g_debug("SEEK POS context time : %lu, %lu", 
+                                                        tfc->timestamp.tv_sec,
+                                                        tfc->timestamp.tv_nsec);
+                                       } else {
+                                               g_debug("SEEK POS context time : %lu, %lu", 
+                                                        ltt_time_infinite.tv_sec,
+                                                        ltt_time_infinite.tv_nsec);
+                                       }
           g_assert(events_request->start_position != NULL);
           if(lttv_traceset_context_ctx_pos_compare(tsc,
                      events_request->start_position) != 0) {
           g_assert(events_request->start_position != NULL);
           if(lttv_traceset_context_ctx_pos_compare(tsc,
                      events_request->start_position) != 0) {
@@ -1564,7 +1625,7 @@ gboolean lttvwindow_process_pending_requests(Tab *tab)
       /* 1.1. Use current postition as start position */
       if(events_request->start_position != NULL)
         lttv_traceset_context_position_destroy(events_request->start_position);
       /* 1.1. Use current postition as start position */
       if(events_request->start_position != NULL)
         lttv_traceset_context_position_destroy(events_request->start_position);
-      events_request->start_position = lttv_traceset_context_position_new();
+      events_request->start_position = lttv_traceset_context_position_new(tsc);
       lttv_traceset_context_position_save(tsc, events_request->start_position);
 
       /* 1.2. Remove start time */
       lttv_traceset_context_position_save(tsc, events_request->start_position);
 
       /* 1.2. Remove start time */
@@ -1590,10 +1651,10 @@ gboolean lttvwindow_process_pending_requests(Tab *tab)
 
 
   }
 
 
   }
-#if 0
   /* C Unlock Traces */
   {
   /* C Unlock Traces */
   {
-    //lttv_process_traceset_get_sync_data(tsc);
+    lttv_process_traceset_get_sync_data(tsc);
+    //lttv_traceset_context_position_save(tsc, sync_position);
     
     guint iter_trace;
     
     
     guint iter_trace;
     
@@ -1605,7 +1666,6 @@ gboolean lttvwindow_process_pending_requests(Tab *tab)
       lttvwindowtraces_unlock(trace_v);
     }
   }
       lttvwindowtraces_unlock(trace_v);
     }
   }
-#endif //0
 #if 0
   //set the cursor back to normal
   gdk_window_set_cursor(win, NULL);  
 #if 0
   //set the cursor back to normal
   gdk_window_set_cursor(win, NULL);  
@@ -1710,46 +1770,64 @@ void add_trace(GtkWidget * widget, gpointer user_data)
 
   GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook),
                       gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)));
 
   GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook),
                       gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)));
+  LttvPluginTab *ptab;
   Tab *tab;
 
   if(!page) {
   Tab *tab;
 
   if(!page) {
-    tab = create_new_tab(widget, NULL);
+    ptab = create_new_tab(widget, NULL);
+    tab = ptab->tab;
   } else {
   } else {
-    tab = (Tab *)g_object_get_data(G_OBJECT(page), "Tab_Info");
+    ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin");
+    tab = ptab->tab;
   }
 
   }
 
-  GtkDirSelection * file_selector = (GtkDirSelection *)gtk_dir_selection_new("Select a trace");
-  gtk_dir_selection_hide_fileop_buttons(file_selector);
+  //GtkDirSelection * file_selector = (GtkDirSelection *)gtk_dir_selection_new("Select a trace");
+  GtkFileSelection * file_selector = (GtkFileSelection *)gtk_file_selection_new("Select a trace");
+  gtk_widget_hide( (file_selector)->file_list->parent) ;
+  gtk_file_selection_hide_fileop_buttons(file_selector);
+  gtk_window_set_transient_for(GTK_WINDOW(file_selector),
+      GTK_WINDOW(mw_data->mwindow));
   
   if(remember_trace_dir[0] != '\0')
   
   if(remember_trace_dir[0] != '\0')
-    gtk_dir_selection_set_filename(file_selector, remember_trace_dir);
+    gtk_file_selection_set_filename(file_selector, remember_trace_dir);
   
   id = gtk_dialog_run(GTK_DIALOG(file_selector));
   switch(id){
     case GTK_RESPONSE_ACCEPT:
     case GTK_RESPONSE_OK:
   
   id = gtk_dialog_run(GTK_DIALOG(file_selector));
   switch(id){
     case GTK_RESPONSE_ACCEPT:
     case GTK_RESPONSE_OK:
-      dir = gtk_dir_selection_get_dir (file_selector);
+      dir = gtk_file_selection_get_filename (file_selector);
       strncpy(remember_trace_dir, dir, PATH_MAX);
       strncpy(remember_trace_dir, dir, PATH_MAX);
+      strncat(remember_trace_dir, "/", PATH_MAX);
       if(!dir || strlen(dir) == 0){
        gtk_widget_destroy((GtkWidget*)file_selector);
        break;
       }
       get_absolute_pathname(dir, abs_path);
       if(!dir || strlen(dir) == 0){
        gtk_widget_destroy((GtkWidget*)file_selector);
        break;
       }
       get_absolute_pathname(dir, abs_path);
-      // Mathieu : modify to not share traces anymore : mmap uses so much less
-      // memory than a full buffer read...
-//      trace_v = lttvwindowtraces_get_trace_by_name(abs_path);
-//      if(trace_v == NULL) {
+      trace_v = lttvwindowtraces_get_trace_by_name(abs_path);
+      if(trace_v == NULL) {
         trace = ltt_trace_open(abs_path);
         if(trace == NULL) {
           g_warning("cannot open trace %s", abs_path);
         trace = ltt_trace_open(abs_path);
         if(trace == NULL) {
           g_warning("cannot open trace %s", abs_path);
+
+          GtkWidget *dialogue = 
+            gtk_message_dialog_new(
+              GTK_WINDOW(gtk_widget_get_toplevel(widget)),
+              GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
+              GTK_MESSAGE_ERROR,
+              GTK_BUTTONS_OK,
+              "Cannot open trace : maybe you should enter in the trace "
+              "directory to select it ?");
+          gtk_dialog_run(GTK_DIALOG(dialogue));
+          gtk_widget_destroy(dialogue);
+
         } else {
           trace_v = lttv_trace_new(trace);
         } else {
           trace_v = lttv_trace_new(trace);
-          //lttvwindowtraces_add_trace(trace_v);
+          lttvwindowtraces_add_trace(trace_v);
           lttvwindow_add_trace(tab, trace_v);
         }
           lttvwindow_add_trace(tab, trace_v);
         }
-//      } else {
-//        lttvwindow_add_trace(tab, trace_v);
-//      }
+      } else {
+        lttvwindow_add_trace(tab, trace_v);
+      }
 
       gtk_widget_destroy((GtkWidget*)file_selector);
       
 
       gtk_widget_destroy((GtkWidget*)file_selector);
       
@@ -1801,7 +1879,9 @@ void remove_trace(GtkWidget *widget, gpointer user_data)
   if(!page) {
     return;
   } else {
   if(!page) {
     return;
   } else {
-    tab = (Tab *)g_object_get_data(G_OBJECT(page), "Tab_Info");
+    LttvPluginTab *ptab;
+    ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin");
+    tab = ptab->tab;
   }
 
   nb_trace =lttv_traceset_number(tab->traceset_info->traceset); 
   }
 
   nb_trace =lttv_traceset_number(tab->traceset_info->traceset); 
@@ -1809,10 +1889,10 @@ void remove_trace(GtkWidget *widget, gpointer user_data)
   for(i = 0; i < nb_trace; i++){
     trace_v = lttv_traceset_get(tab->traceset_info->traceset, i);
     trace = lttv_trace(trace_v);
   for(i = 0; i < nb_trace; i++){
     trace_v = lttv_traceset_get(tab->traceset_info->traceset, i);
     trace = lttv_trace(trace_v);
-    name[i] = ltt_trace_name(trace);
+    name[i] = g_quark_to_string(ltt_trace_name(trace));
   }
 
   }
 
-  remove_trace_name = get_remove_trace(name, nb_trace);
+  remove_trace_name = get_remove_trace(mw_data, name, nb_trace);
 
 
   if(remove_trace_name){
 
 
   if(remove_trace_name){
@@ -1843,15 +1923,15 @@ void remove_trace(GtkWidget *widget, gpointer user_data)
     lttv_traceset_remove(traceset, index);
     lttv_trace_unref(trace_v);  // Remove local reference
 
     lttv_traceset_remove(traceset, index);
     lttv_trace_unref(trace_v);  // Remove local reference
 
-//    if(lttv_trace_get_ref_number(trace_v) <= 1) {
+    if(lttv_trace_get_ref_number(trace_v) <= 1) {
       /* ref 1 : lttvwindowtraces only*/
       ltt_trace_close(lttv_trace(trace_v));
       /* lttvwindowtraces_remove_trace takes care of destroying
        * the traceset linked with the trace_v and also of destroying
        * the trace_v at the same time.
        */
       /* ref 1 : lttvwindowtraces only*/
       ltt_trace_close(lttv_trace(trace_v));
       /* lttvwindowtraces_remove_trace takes care of destroying
        * the traceset linked with the trace_v and also of destroying
        * the trace_v at the same time.
        */
-//      lttvwindowtraces_remove_trace(trace_v);
-//    }
+      lttvwindowtraces_remove_trace(trace_v);
+    }
     
     tab->traceset_info->traceset_context =
       g_object_new(LTTV_TRACESET_STATS_TYPE, NULL);
     
     tab->traceset_info->traceset_context =
       g_object_new(LTTV_TRACESET_STATS_TYPE, NULL);
@@ -2020,7 +2100,9 @@ void redraw(GtkWidget *widget, gpointer user_data)
   if(!page) {
     return;
   } else {
   if(!page) {
     return;
   } else {
-    tab = (Tab *)g_object_get_data(G_OBJECT(page), "Tab_Info");
+    LttvPluginTab *ptab;
+    ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin");
+    tab = ptab->tab;
   }
 
   LttvHooks * tmp;
   }
 
   LttvHooks * tmp;
@@ -2043,7 +2125,9 @@ void continue_processing(GtkWidget *widget, gpointer user_data)
   if(!page) {
     return;
   } else {
   if(!page) {
     return;
   } else {
-    tab = (Tab *)g_object_get_data(G_OBJECT(page), "Tab_Info");
+    LttvPluginTab *ptab;
+    ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin");
+    tab = ptab->tab;
   }
 
   LttvHooks * tmp;
   }
 
   LttvHooks * tmp;
@@ -2071,7 +2155,9 @@ void stop_processing(GtkWidget *widget, gpointer user_data)
   if(!page) {
     return;
   } else {
   if(!page) {
     return;
   } else {
-    tab = (Tab *)g_object_get_data(G_OBJECT(page), "Tab_Info");
+    LttvPluginTab *ptab;
+    ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin");
+    tab = ptab->tab;
   }
   GSList *iter = tab->events_requests;
   
   }
   GSList *iter = tab->events_requests;
   
@@ -2084,6 +2170,7 @@ void stop_processing(GtkWidget *widget, gpointer user_data)
                        g_slist_remove_link(tab->events_requests, remove_iter);
   }
   tab->events_request_pending = FALSE;
                        g_slist_remove_link(tab->events_requests, remove_iter);
   }
   tab->events_request_pending = FALSE;
+  tab->stop_foreground = TRUE;
   g_idle_remove_by_data(tab);
   g_assert(g_slist_length(tab->events_requests) == 0);
 }
   g_idle_remove_by_data(tab);
   g_assert(g_slist_length(tab->events_requests) == 0);
 }
@@ -2125,7 +2212,9 @@ void zoom(GtkWidget * widget, double size)
   if(!page) {
     return;
   } else {
   if(!page) {
     return;
   } else {
-    tab = (Tab *)g_object_get_data(G_OBJECT(page), "Tab_Info");
+    LttvPluginTab *ptab;
+    ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin");
+    tab = ptab->tab;
   }
 
   if(size == 1) return;
   }
 
   if(size == 1) return;
@@ -2163,7 +2252,8 @@ void zoom(GtkWidget * widget, double size)
       new_time_window.end_time = ltt_time_add(new_time_window.start_time,
                                             new_time_window.time_width) ;
       /* If on borders, don't fall off */
       new_time_window.end_time = ltt_time_add(new_time_window.start_time,
                                             new_time_window.time_width) ;
       /* If on borders, don't fall off */
-      if(ltt_time_compare(new_time_window.start_time, time_span.start_time) <0)
+      if(ltt_time_compare(new_time_window.start_time, time_span.start_time) <0
+       || ltt_time_compare(new_time_window.start_time, time_span.end_time) >0)
       {
         new_time_window.start_time = time_span.start_time;
         new_time_window.end_time = ltt_time_add(new_time_window.start_time,
       {
         new_time_window.start_time = time_span.start_time;
         new_time_window.end_time = ltt_time_add(new_time_window.start_time,
@@ -2172,7 +2262,9 @@ void zoom(GtkWidget * widget, double size)
       else 
       {
         if(ltt_time_compare(new_time_window.end_time,
       else 
       {
         if(ltt_time_compare(new_time_window.end_time,
-                            time_span.end_time) > 0)
+                            time_span.end_time) > 0
+         || ltt_time_compare(new_time_window.end_time,
+                            time_span.start_time) < 0)
         {
           new_time_window.start_time = 
                   ltt_time_sub(time_span.end_time, new_time_window.time_width);
         {
           new_time_window.start_time = 
                   ltt_time_sub(time_span.end_time, new_time_window.time_width);
@@ -2239,7 +2331,8 @@ on_clone_traceset_activate             (GtkMenuItem     *menuitem,
 /* create_new_tab calls create_tab to construct a new tab in the main window
  */
 
 /* create_new_tab calls create_tab to construct a new tab in the main window
  */
 
-Tab *create_new_tab(GtkWidget* widget, gpointer user_data){
+LttvPluginTab *create_new_tab(GtkWidget* widget, gpointer user_data)
+{
   gchar label[PATH_MAX];
   MainWindow * mw_data = get_window_data_struct(widget);
 
   gchar label[PATH_MAX];
   MainWindow * mw_data = get_window_data_struct(widget);
 
@@ -2255,14 +2348,26 @@ Tab *create_new_tab(GtkWidget* widget, gpointer user_data){
   if(!page) {
     copy_tab = NULL;
   } else {
   if(!page) {
     copy_tab = NULL;
   } else {
-    copy_tab = (Tab *)g_object_get_data(G_OBJECT(page), "Tab_Info");
+    LttvPluginTab *ptab;
+    ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin");
+    copy_tab = ptab->tab;
   }
   
   strcpy(label,"Page");
   }
   
   strcpy(label,"Page");
-  if(get_label(mw_data, label,"Get the name of the tab","Please input tab's name"))    
-    return (create_tab (mw_data, copy_tab, notebook, label));
-  else
-    return NULL;
+  if(get_label(mw_data, label,"Get the name of the tab","Please input tab's name")) {
+    LttvPluginTab *ptab;
+    
+    ptab = g_object_new(LTTV_TYPE_PLUGIN_TAB, NULL);
+    init_tab (ptab->tab, mw_data, copy_tab, notebook, label);
+    ptab->parent.top_widget = ptab->tab->top_widget;
+    g_object_set_data_full(
+           G_OBJECT(ptab->tab->vbox),
+           "Tab_Plugin",
+           ptab,
+          (GDestroyNotify)tab_destructor);
+    return ptab;
+  }
+  else return NULL;
 }
 
 void
 }
 
 void
@@ -2366,7 +2471,7 @@ void
 on_quit_activate                       (GtkMenuItem     *menuitem,
                                         gpointer         user_data)
 {
 on_quit_activate                       (GtkMenuItem     *menuitem,
                                         gpointer         user_data)
 {
-  gtk_main_quit ();
+  mainwindow_quit();
 }
 
 
 }
 
 
@@ -2499,7 +2604,8 @@ on_load_library_activate                (GtkMenuItem     *menuitem,
       g_ptr_array_add(name, path);
     }
 
       g_ptr_array_add(name, path);
     }
 
-    load_module_path = get_selection((char **)(name->pdata), name->len,
+    load_module_path = get_selection(mw_data,
+                             (char **)(name->pdata), name->len,
                              "Select a library path", "Library paths");
     if(load_module_path != NULL)
       strncpy(load_module_path_alter, load_module_path, PATH_MAX-1); // -1 for /
                              "Select a library path", "Library paths");
     if(load_module_path != NULL)
       strncpy(load_module_path_alter, load_module_path, PATH_MAX-1); // -1 for /
@@ -2532,6 +2638,9 @@ on_load_library_activate                (GtkMenuItem     *menuitem,
     gtk_file_selection_set_filename(file_selector, load_module_path_alter);
     gtk_file_selection_hide_fileop_buttons(file_selector);
     
     gtk_file_selection_set_filename(file_selector, load_module_path_alter);
     gtk_file_selection_hide_fileop_buttons(file_selector);
     
+    gtk_window_set_transient_for(GTK_WINDOW(file_selector),
+        GTK_WINDOW(mw_data->mwindow));
+
     str[0] = '\0';
     id = gtk_dialog_run(GTK_DIALOG(file_selector));
     switch(id){
     str[0] = '\0';
     id = gtk_dialog_run(GTK_DIALOG(file_selector));
     switch(id){
@@ -2606,7 +2715,7 @@ on_unload_library_activate              (GtkMenuItem     *menuitem,
     gchar *path = lib_info[i].name;
     g_ptr_array_add(name, path);
   }
     gchar *path = lib_info[i].name;
     g_ptr_array_add(name, path);
   }
-  lib_name = get_selection((char **)(name->pdata), name->len,
+  lib_name = get_selection(mw_data, (char **)(name->pdata), name->len,
                            "Select a library", "Libraries");
   if(lib_name != NULL) {
     for(i=0;i<nb;i++){
                            "Select a library", "Libraries");
   if(lib_name != NULL) {
     for(i=0;i<nb;i++){
@@ -2653,7 +2762,7 @@ on_load_module_activate                (GtkMenuItem     *menuitem,
       gchar *path = lib_info[i].name;
       g_ptr_array_add(name, path);
     }
       gchar *path = lib_info[i].name;
       g_ptr_array_add(name, path);
     }
-    lib_name = get_selection((char **)(name->pdata), name->len,
+    lib_name = get_selection(mw_data,(char **)(name->pdata), name->len,
                              "Select a library", "Libraries");
     if(lib_name != NULL) {
       for(i=0;i<nb;i++){
                              "Select a library", "Libraries");
     if(lib_name != NULL) {
       for(i=0;i<nb;i++){
@@ -2688,7 +2797,7 @@ on_load_module_activate                (GtkMenuItem     *menuitem,
       gchar *path = module_info[i].name;
       g_ptr_array_add(name, path);
     }
       gchar *path = module_info[i].name;
       g_ptr_array_add(name, path);
     }
-    module_name = get_selection((char **)(name->pdata), name->len,
+    module_name = get_selection(mw_data, (char **)(name->pdata), name->len,
                              "Select a module", "Modules");
     if(module_name != NULL) {
       for(i=0;i<nb;i++){
                              "Select a module", "Modules");
     if(module_name != NULL) {
       for(i=0;i<nb;i++){
@@ -2800,7 +2909,7 @@ on_unload_module_activate              (GtkMenuItem     *menuitem,
       gchar *path = lib_info[i].name;
       g_ptr_array_add(name, path);
     }
       gchar *path = lib_info[i].name;
       g_ptr_array_add(name, path);
     }
-    lib_name = get_selection((char **)(name->pdata), name->len,
+    lib_name = get_selection(mw_data, (char **)(name->pdata), name->len,
                              "Select a library", "Libraries");
     if(lib_name != NULL) {
       for(i=0;i<nb;i++){
                              "Select a library", "Libraries");
     if(lib_name != NULL) {
       for(i=0;i<nb;i++){
@@ -2834,7 +2943,7 @@ on_unload_module_activate              (GtkMenuItem     *menuitem,
       gchar *path = module_info[i].name;
       if(module_info[i].use_count > 0) g_ptr_array_add(name, path);
     }
       gchar *path = module_info[i].name;
       if(module_info[i].use_count > 0) g_ptr_array_add(name, path);
     }
-    module_name = get_selection((char **)(name->pdata), name->len,
+    module_name = get_selection(mw_data, (char **)(name->pdata), name->len,
                              "Select a module", "Modules");
     if(module_name != NULL) {
       for(i=0;i<nb;i++){
                              "Select a module", "Modules");
     if(module_name != NULL) {
       for(i=0;i<nb;i++){
@@ -2866,19 +2975,25 @@ void
 on_add_library_search_path_activate     (GtkMenuItem     *menuitem,
                                         gpointer         user_data)
 {
 on_add_library_search_path_activate     (GtkMenuItem     *menuitem,
                                         gpointer         user_data)
 {
-  GtkDirSelection * file_selector = (GtkDirSelection *)gtk_dir_selection_new("Select library path");
+  MainWindow * mw_data = get_window_data_struct((GtkWidget*)menuitem);
+  //GtkDirSelection * file_selector = (GtkDirSelection *)gtk_dir_selection_new("Select library path");
+  GtkFileSelection * file_selector = (GtkFileSelection *)gtk_file_selection_new("Select a trace");
+  gtk_widget_hide( (file_selector)->file_list->parent) ;
+
+  gtk_window_set_transient_for(GTK_WINDOW(file_selector),
+      GTK_WINDOW(mw_data->mwindow));
+
   const char * dir;
   gint id;
 
   const char * dir;
   gint id;
 
-  MainWindow * mw_data = get_window_data_struct((GtkWidget*)menuitem);
   if(remember_plugins_dir[0] != '\0')
   if(remember_plugins_dir[0] != '\0')
-    gtk_dir_selection_set_filename(file_selector, remember_plugins_dir);
+    gtk_file_selection_set_filename(file_selector, remember_plugins_dir);
 
   id = gtk_dialog_run(GTK_DIALOG(file_selector));
   switch(id){
     case GTK_RESPONSE_ACCEPT:
     case GTK_RESPONSE_OK:
 
   id = gtk_dialog_run(GTK_DIALOG(file_selector));
   switch(id){
     case GTK_RESPONSE_ACCEPT:
     case GTK_RESPONSE_OK:
-      dir = gtk_dir_selection_get_dir (file_selector);
+      dir = gtk_file_selection_get_filename (file_selector);
       strncpy(remember_plugins_dir,dir,PATH_MAX);
       strncat(remember_plugins_dir,"/",PATH_MAX);
       lttv_library_path_add(dir);
       strncpy(remember_plugins_dir,dir,PATH_MAX);
       strncat(remember_plugins_dir,"/",PATH_MAX);
       lttv_library_path_add(dir);
@@ -2913,7 +3028,7 @@ on_remove_library_search_path_activate     (GtkMenuItem     *menuitem,
       gchar *path = lttv_library_path_get(i);
       g_ptr_array_add(name, path);
     }
       gchar *path = lttv_library_path_get(i);
       g_ptr_array_add(name, path);
     }
-    lib_path = get_selection((char **)(name->pdata), name->len,
+    lib_path = get_selection(mw_data, (char **)(name->pdata), name->len,
                              "Select a library path", "Library paths");
 
     g_ptr_array_free(name, TRUE);
                              "Select a library path", "Library paths");
 
     g_ptr_array_free(name, TRUE);
@@ -2970,7 +3085,7 @@ on_about_activate                      (GtkMenuItem     *menuitem,
   gtk_window_set_title(about_window, "About Linux Trace Toolkit");
 
   gtk_window_set_resizable(about_window, FALSE);
   gtk_window_set_title(about_window, "About Linux Trace Toolkit");
 
   gtk_window_set_resizable(about_window, FALSE);
-  gtk_window_set_transient_for(GTK_WINDOW(window_widget), about_window);
+  gtk_window_set_transient_for(about_window, GTK_WINDOW(window_widget));
   gtk_window_set_destroy_with_parent(about_window, TRUE);
   gtk_window_set_modal(about_window, FALSE);
 
   gtk_window_set_destroy_with_parent(about_window, TRUE);
   gtk_window_set_modal(about_window, FALSE);
 
@@ -2989,7 +3104,7 @@ on_about_activate                      (GtkMenuItem     *menuitem,
   GtkWidget *label1 = gtk_label_new("");
   gtk_misc_set_padding(GTK_MISC(label1), 10, 20);
   gtk_label_set_markup(GTK_LABEL(label1), "\
   GtkWidget *label1 = gtk_label_new("");
   gtk_misc_set_padding(GTK_MISC(label1), 10, 20);
   gtk_label_set_markup(GTK_LABEL(label1), "\
-<big>Linux Trace Toolkit</big>");
+<big>Linux Trace Toolkit " VERSION "</big>");
   gtk_label_set_justify(GTK_LABEL(label1), GTK_JUSTIFY_CENTER);
   
   GtkWidget *label2 = gtk_label_new("");
   gtk_label_set_justify(GTK_LABEL(label1), GTK_JUSTIFY_CENTER);
   
   GtkWidget *label2 = gtk_label_new("");
@@ -2998,21 +3113,22 @@ on_about_activate                      (GtkMenuItem     *menuitem,
 Contributors :\n\
 \n\
 Michel Dagenais (New trace format, lttv main)\n\
 Contributors :\n\
 \n\
 Michel Dagenais (New trace format, lttv main)\n\
-Mathieu Desnoyers (Directory structure, build with automake/conf,\n\
+Mathieu Desnoyers (Kernel Tracer, Directory structure, build with automake/conf,\n\
                    lttv gui, control flow view, gui cooperative trace reading\n\
                    scheduler with interruptible foreground and background\n\
                    lttv gui, control flow view, gui cooperative trace reading\n\
                    scheduler with interruptible foreground and background\n\
-                   computation, detailed event list)\n\
+                   computation, detailed event list (rewrite), trace reading\n\
+                   library (rewrite))\n\
 Benoit Des Ligneris, Eric Clement (Cluster adaptation, work in progress)\n\
 Xang-Xiu Yang (new trace reading library and converter, lttv gui, \n\
                detailed event list and statistics view)\n\
 Tom Zanussi (RelayFS)\n\
 \n\
 Benoit Des Ligneris, Eric Clement (Cluster adaptation, work in progress)\n\
 Xang-Xiu Yang (new trace reading library and converter, lttv gui, \n\
                detailed event list and statistics view)\n\
 Tom Zanussi (RelayFS)\n\
 \n\
-Strongly inspired from the original Linux Trace Toolkit Visualizer made by\n\
+Inspired from the original Linux Trace Toolkit Visualizer made by\n\
 Karim Yaghmour");
 
   GtkWidget *label3 = gtk_label_new("");
   gtk_label_set_markup(GTK_LABEL(label3), "\
 Karim Yaghmour");
 
   GtkWidget *label3 = gtk_label_new("");
   gtk_label_set_markup(GTK_LABEL(label3), "\
-Linux Trace Toolkit Viewer, Copyright (C) 2004\n\
+Linux Trace Toolkit Viewer, Copyright (C) 2004, 2005, 2006\n\
                                                 Michel Dagenais\n\
                                                 Mathieu Desnoyers\n\
                                                 Xang-Xiu Yang\n\
                                                 Michel Dagenais\n\
                                                 Mathieu Desnoyers\n\
                                                 Xang-Xiu Yang\n\
@@ -3203,7 +3319,7 @@ on_MWindow_destroy                     (GtkWidget       *widget,
 
   g_info("There are now : %d windows\n",g_slist_length(g_main_window_list));
   if(g_slist_length(g_main_window_list) == 0)
 
   g_info("There are now : %d windows\n",g_slist_length(g_main_window_list));
   if(g_slist_length(g_main_window_list) == 0)
-    gtk_main_quit ();
+    mainwindow_quit();
 }
 
 gboolean    
 }
 
 gboolean    
@@ -3260,7 +3376,10 @@ void time_change_manager               (Tab *tab,
   TimeInterval time_span = tsc->time_span;
   LttTime start_time = new_time_window.start_time;
   LttTime end_time = new_time_window.end_time;
   TimeInterval time_span = tsc->time_span;
   LttTime start_time = new_time_window.start_time;
   LttTime end_time = new_time_window.end_time;
+  LttTime time_width = new_time_window.time_width;
 
 
+  g_assert(ltt_time_compare(start_time, end_time) < 0);
+  
   /* Set scrollbar */
   GtkAdjustment *adjustment = gtk_range_get_adjustment(GTK_RANGE(tab->scrollbar));
   LttTime upper = ltt_time_sub(time_span.end_time, time_span.start_time);
   /* Set scrollbar */
   GtkAdjustment *adjustment = gtk_range_get_adjustment(GTK_RANGE(tab->scrollbar));
   LttTime upper = ltt_time_sub(time_span.end_time, time_span.start_time);
@@ -3370,6 +3489,43 @@ void time_change_manager               (Tab *tab,
   gtk_spin_button_set_value(GTK_SPIN_BUTTON(tab->MEntry4),
                             (double)end_time.tv_nsec);
 
   gtk_spin_button_set_value(GTK_SPIN_BUTTON(tab->MEntry4),
                             (double)end_time.tv_nsec);
 
+  /* width seconds */
+  if(time_width.tv_nsec == 0) {
+    gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry7),
+                              (double)1,
+                              (double)upper.tv_sec);
+  } else {
+    gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry7),
+                              (double)0,
+                              (double)upper.tv_sec);
+  }
+  gtk_spin_button_set_value(GTK_SPIN_BUTTON(tab->MEntry7),
+                            (double)time_width.tv_sec);
+
+  /* width nanoseconds */
+  if(time_width.tv_sec == upper.tv_sec) {
+    if(time_width.tv_sec == 0) {
+      gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry8),
+                                (double)1,
+                                (double)upper.tv_nsec);
+    } else {
+      gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry8),
+                                (double)0,
+                                (double)upper.tv_nsec);
+    }
+  }
+  else if(time_width.tv_sec == 0) {
+    gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry8),
+                              1.0,
+                              (double)upper.tv_nsec);
+  }
+  else /* anywhere else */
+    gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry8),
+                              0.0,
+                              (double)NANOSECONDS_PER_SECOND-1);
+  gtk_spin_button_set_value(GTK_SPIN_BUTTON(tab->MEntry8),
+                            (double)time_width.tv_nsec);
+
   /* call viewer hooks for new time window */
   set_time_window(tab, &new_time_window);
 
   /* call viewer hooks for new time window */
   set_time_window(tab, &new_time_window);
 
@@ -3560,6 +3716,141 @@ on_MEntry4_value_changed               (GtkSpinButton *spinbutton,
 
 }
 
 
 }
 
+/* value changed for time frame interval s
+ *
+ * Check time span : if ns is out of range, clip it the nearest good value.
+ */
+void
+on_MEntry7_value_changed               (GtkSpinButton *spinbutton,
+                                        gpointer user_data)
+{
+  Tab *tab =(Tab *)user_data;
+  LttvTracesetContext * tsc = 
+    LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context);
+  TimeInterval time_span = tsc->time_span;
+  gint value = gtk_spin_button_get_value_as_int(spinbutton);
+  LttTime    current_time, time_delta;
+  TimeWindow new_time_window =  tab->time_window;
+  current_time = tab->current_time;
+  
+  time_delta = ltt_time_sub(time_span.end_time,time_span.start_time);
+  new_time_window.time_width.tv_sec = value;
+  new_time_window.time_width_double = 
+                 ltt_time_to_double(new_time_window.time_width);
+  if(ltt_time_compare(new_time_window.time_width,time_delta) > 0)
+  { /* Case where zoom out is bigger than trace length */
+    new_time_window.start_time = time_span.start_time;
+    new_time_window.time_width = time_delta;
+    new_time_window.time_width_double = ltt_time_to_double(time_delta);
+    new_time_window.end_time = ltt_time_add(new_time_window.start_time,
+                                          new_time_window.time_width) ;
+  }
+  else
+  {
+    /* Center the image on the current time */
+    new_time_window.start_time = 
+      ltt_time_sub(current_time,
+          ltt_time_from_double(new_time_window.time_width_double/2.0));
+    new_time_window.end_time = ltt_time_add(new_time_window.start_time,
+                                          new_time_window.time_width) ;
+    /* If on borders, don't fall off */
+    if(ltt_time_compare(new_time_window.start_time, time_span.start_time) <0
+     || ltt_time_compare(new_time_window.start_time, time_span.end_time) >0)
+    {
+      new_time_window.start_time = time_span.start_time;
+      new_time_window.end_time = ltt_time_add(new_time_window.start_time,
+                                          new_time_window.time_width) ;
+    }
+    else 
+    {
+      if(ltt_time_compare(new_time_window.end_time,
+                          time_span.end_time) > 0
+       || ltt_time_compare(new_time_window.end_time,
+                          time_span.start_time) < 0)
+      {
+        new_time_window.start_time = 
+                ltt_time_sub(time_span.end_time, new_time_window.time_width);
+
+        new_time_window.end_time = ltt_time_add(new_time_window.start_time,
+                                                new_time_window.time_width) ;
+      }
+    }
+    
+  }
+
+  if(ltt_time_compare(new_time_window.time_width, ltt_time_zero) == 0) {
+    g_warning("Zoom more than 1 ns impossible");
+  } else {
+   time_change_manager(tab, new_time_window);
+  }
+}
+
+void
+on_MEntry8_value_changed               (GtkSpinButton *spinbutton,
+                                        gpointer user_data)
+{
+  Tab *tab =(Tab *)user_data;
+  LttvTracesetContext * tsc = 
+    LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context);
+  TimeInterval time_span = tsc->time_span;
+  gint value = gtk_spin_button_get_value_as_int(spinbutton);
+  LttTime    current_time, time_delta;
+  TimeWindow new_time_window =  tab->time_window;
+  current_time = tab->current_time;
+  
+  time_delta = ltt_time_sub(time_span.end_time,time_span.start_time);
+  new_time_window.time_width.tv_nsec = value;
+  new_time_window.time_width_double = 
+                 ltt_time_to_double(new_time_window.time_width);
+  if(ltt_time_compare(new_time_window.time_width,time_delta) > 0)
+  { /* Case where zoom out is bigger than trace length */
+    new_time_window.start_time = time_span.start_time;
+    new_time_window.time_width = time_delta;
+    new_time_window.time_width_double = ltt_time_to_double(time_delta);
+    new_time_window.end_time = ltt_time_add(new_time_window.start_time,
+                                          new_time_window.time_width) ;
+  }
+  else
+  {
+    /* Center the image on the current time */
+    new_time_window.start_time = 
+      ltt_time_sub(current_time,
+          ltt_time_from_double(new_time_window.time_width_double/2.0));
+    new_time_window.end_time = ltt_time_add(new_time_window.start_time,
+                                          new_time_window.time_width) ;
+    /* If on borders, don't fall off */
+    if(ltt_time_compare(new_time_window.start_time, time_span.start_time) <0
+     || ltt_time_compare(new_time_window.start_time, time_span.end_time) >0)
+    {
+      new_time_window.start_time = time_span.start_time;
+      new_time_window.end_time = ltt_time_add(new_time_window.start_time,
+                                          new_time_window.time_width) ;
+    }
+    else 
+    {
+      if(ltt_time_compare(new_time_window.end_time,
+                          time_span.end_time) > 0
+       || ltt_time_compare(new_time_window.end_time,
+                          time_span.start_time) < 0)
+      {
+        new_time_window.start_time = 
+                ltt_time_sub(time_span.end_time, new_time_window.time_width);
+
+        new_time_window.end_time = ltt_time_add(new_time_window.start_time,
+                                                new_time_window.time_width) ;
+      }
+    }
+    
+  }
+
+  if(ltt_time_compare(new_time_window.time_width, ltt_time_zero) == 0) {
+    g_warning("Zoom more than 1 ns impossible");
+  } else {
+   time_change_manager(tab, new_time_window);
+  }
+}
+
+
 
 void current_time_change_manager       (Tab *tab,
                                         LttTime new_current_time)
 
 void current_time_change_manager       (Tab *tab,
                                         LttTime new_current_time)
@@ -3611,6 +3902,24 @@ void current_time_change_manager       (Tab *tab,
   tab->current_time_manager_lock = FALSE;
 }
 
   tab->current_time_manager_lock = FALSE;
 }
 
+void current_position_change_manager(Tab *tab,
+                                     LttvTracesetContextPosition *pos)
+{
+  LttvTracesetContext *tsc =
+    LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context);
+  TimeInterval time_span = tsc->time_span;
+
+  g_assert(lttv_process_traceset_seek_position(tsc, pos) == 0);
+  LttTime new_time = lttv_traceset_context_position_get_time(pos);
+  /* Put the context in a state coherent position */
+  lttv_state_traceset_seek_time_closest((LttvTracesetState*)tsc, ltt_time_zero);
+  
+  current_time_change_manager(tab, new_time);
+  
+  set_current_position(tab, pos);
+}
+
+
 void
 on_MEntry5_value_changed               (GtkSpinButton *spinbutton,
                                         gpointer user_data)
 void
 on_MEntry5_value_changed               (GtkSpinButton *spinbutton,
                                         gpointer user_data)
@@ -3726,9 +4035,10 @@ void scroll_value_changed_cb(GtkWidget *scrollbar,
 /* Select a trace which will be removed from traceset
  */
 
 /* Select a trace which will be removed from traceset
  */
 
-char * get_remove_trace(char ** all_trace_name, int nb_trace)
+char * get_remove_trace(MainWindow *mw_data, 
+    char ** all_trace_name, int nb_trace)
 {
 {
-  return get_selection(all_trace_name, nb_trace, 
+  return get_selection(mw_data, all_trace_name, nb_trace, 
                       "Select a trace", "Trace pathname");
 }
 
                       "Select a trace", "Trace pathname");
 }
 
@@ -3736,9 +4046,10 @@ char * get_remove_trace(char ** all_trace_name, int nb_trace)
 /* Select a module which will be loaded
  */
 
 /* Select a module which will be loaded
  */
 
-char * get_load_module(char ** load_module_name, int nb_module)
+char * get_load_module(MainWindow *mw_data, 
+    char ** load_module_name, int nb_module)
 {
 {
-  return get_selection(load_module_name, nb_module, 
+  return get_selection(mw_data, load_module_name, nb_module, 
                       "Select a module to load", "Module name");
 }
 
                       "Select a module to load", "Module name");
 }
 
@@ -3748,9 +4059,10 @@ char * get_load_module(char ** load_module_name, int nb_module)
 /* Select a module which will be unloaded
  */
 
 /* Select a module which will be unloaded
  */
 
-char * get_unload_module(char ** loaded_module_name, int nb_module)
+char * get_unload_module(MainWindow *mw_data,
+    char ** loaded_module_name, int nb_module)
 {
 {
-  return get_selection(loaded_module_name, nb_module, 
+  return get_selection(mw_data, loaded_module_name, nb_module, 
                       "Select a module to unload", "Module name");
 }
 
                       "Select a module to unload", "Module name");
 }
 
@@ -3759,8 +4071,9 @@ char * get_unload_module(char ** loaded_module_name, int nb_module)
  * select one of them
  */
 
  * select one of them
  */
 
-char * get_selection(char ** loaded_module_name, int nb_module,
-                    char *title, char * column_title)
+char * get_selection(MainWindow *mw_data,
+    char ** loaded_module_name, int nb_module,
+         char *title, char * column_title)
 {
   GtkWidget         * dialogue;
   GtkWidget         * scroll_win;
 {
   GtkWidget         * dialogue;
   GtkWidget         * scroll_win;
@@ -3780,6 +4093,8 @@ char * get_selection(char ** loaded_module_name, int nb_module,
                                         GTK_STOCK_CANCEL,GTK_RESPONSE_REJECT,
                                         NULL); 
   gtk_window_set_default_size((GtkWindow*)dialogue, 500, 200);
                                         GTK_STOCK_CANCEL,GTK_RESPONSE_REJECT,
                                         NULL); 
   gtk_window_set_default_size((GtkWindow*)dialogue, 500, 200);
+  gtk_window_set_transient_for(GTK_WINDOW(dialogue), 
+      GTK_WINDOW(mw_data->mwindow));
 
   scroll_win = gtk_scrolled_window_new (NULL, NULL);
   gtk_widget_show ( scroll_win);
 
   scroll_win = gtk_scrolled_window_new (NULL, NULL);
   gtk_widget_show ( scroll_win);
@@ -3813,7 +4128,7 @@ char * get_selection(char ** loaded_module_name, int nb_module,
   }
 
   id = gtk_dialog_run(GTK_DIALOG(dialogue));
   }
 
   id = gtk_dialog_run(GTK_DIALOG(dialogue));
-  GtkTreeModel **store_model = (GtkTreeModel*)store;
+  GtkTreeModel **store_model = (GtkTreeModel**)&store;
   switch(id){
     case GTK_RESPONSE_ACCEPT:
     case GTK_RESPONSE_OK:
   switch(id){
     case GTK_RESPONSE_ACCEPT:
     case GTK_RESPONSE_OK:
@@ -3939,7 +4254,7 @@ void add_all_menu_toolbar_constructors(MainWindow * mw, gpointer user_data)
 /* Create a main window
  */
 
 /* Create a main window
  */
 
-void construct_main_window(MainWindow * parent)
+MainWindow *construct_main_window(MainWindow * parent)
 {
   g_debug("construct_main_window()");
   GtkWidget  * new_window; /* New generated main window */
 {
   g_debug("construct_main_window()");
   GtkWidget  * new_window; /* New generated main window */
@@ -3979,7 +4294,9 @@ void construct_main_window(MainWindow * parent)
   notebook = (GtkNotebook *)lookup_widget(new_m_window->mwindow, "MNotebook");
   if(notebook == NULL){
     g_info("Notebook does not exist\n");
   notebook = (GtkNotebook *)lookup_widget(new_m_window->mwindow, "MNotebook");
   if(notebook == NULL){
     g_info("Notebook does not exist\n");
-    return;
+    /* FIXME : destroy partially created widgets */
+    g_free(new_m_window);
+    return NULL;
   }
   //gtk_notebook_popup_enable (GTK_NOTEBOOK(notebook));
   //for now there is no name field in LttvTraceset structure
   }
   //gtk_notebook_popup_enable (GTK_NOTEBOOK(notebook));
   //for now there is no name field in LttvTraceset structure
@@ -3993,66 +4310,78 @@ void construct_main_window(MainWindow * parent)
     if(!page) {
       parent_tab = NULL;
     } else {
     if(!page) {
       parent_tab = NULL;
     } else {
-      parent_tab = (Tab *)g_object_get_data(G_OBJECT(page), "Tab_Info");
+      LttvPluginTab *ptab;
+      ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin");
+      parent_tab = ptab->tab;
     }
     }
-    new_tab = create_tab(new_m_window, parent_tab, notebook, "Traceset");
+    LttvPluginTab *ptab = g_object_new(LTTV_TYPE_PLUGIN_TAB, NULL);
+    init_tab(ptab->tab,
+                   new_m_window, parent_tab, notebook, "Traceset");
+    ptab->parent.top_widget = ptab->tab->top_widget;
+    g_object_set_data_full(
+           G_OBJECT(ptab->tab->vbox),
+           "Tab_Plugin",
+           ptab,
+          (GDestroyNotify)tab_destructor);
+    new_tab = ptab->tab;
   } else {
   } else {
-    new_tab = create_tab(new_m_window, NULL, notebook, "Traceset");
-    /* First window, use command line trace */
-    if(g_init_trace != NULL){
-      lttvwindow_add_trace(new_tab,
-                           g_init_trace);
+    LttvPluginTab *ptab = g_object_new(LTTV_TYPE_PLUGIN_TAB, NULL);
+    init_tab(ptab->tab, new_m_window, NULL, notebook, "Traceset");
+    ptab->parent.top_widget = ptab->tab->top_widget;
+    g_object_set_data_full(
+           G_OBJECT(ptab->tab->vbox),
+           "Tab_Plugin",
+           ptab,
+          (GDestroyNotify)tab_destructor);
+    new_tab = ptab->tab;
+  }
 
 
+  /* Insert default viewers */
+  {
+    LttvAttributeType type;
+    LttvAttributeName name;
+    LttvAttributeValue value;
+    LttvAttribute *attribute;
+    
+    LttvIAttribute *attributes_global = 
+       LTTV_IATTRIBUTE(lttv_global_attributes());
+
+    g_assert(attribute = 
+      LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
+                                LTTV_IATTRIBUTE(attributes_global),
+                                LTTV_VIEWER_CONSTRUCTORS)));
+
+    name = g_quark_from_string("guievents");
+    type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute),
+                                       name, &value);
+    if(type == LTTV_POINTER) {
+      lttvwindow_viewer_constructor viewer_constructor = 
+                (lttvwindow_viewer_constructor)*value.v_pointer;
+      insert_viewer(new_window, viewer_constructor);
     }
     }
-    LttvTraceset *traceset = new_tab->traceset_info->traceset;
-    SetTraceset(new_tab, traceset);
-
-    /* Insert default viewers */
-    {
-      LttvAttributeType type;
-      LttvAttributeName name;
-      LttvAttributeValue value;
-      LttvAttribute *attribute;
-      
-      LttvIAttribute *attributes_global = 
-         LTTV_IATTRIBUTE(lttv_global_attributes());
-
-      g_assert(attribute = 
-        LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(
-                                  LTTV_IATTRIBUTE(attributes_global),
-                                  LTTV_VIEWER_CONSTRUCTORS)));
-
-      name = g_quark_from_string("guievents");
-      type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute),
-                                         name, &value);
-      if(type == LTTV_POINTER) {
-        lttvwindow_viewer_constructor viewer_constructor = 
-                  (lttvwindow_viewer_constructor)*value.v_pointer;
-        insert_viewer(new_window, viewer_constructor);
-      }
-
-      name = g_quark_from_string("guicontrolflow");
-      type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute),
-                                         name, &value);
-      if(type == LTTV_POINTER) {
-        lttvwindow_viewer_constructor viewer_constructor = 
-                  (lttvwindow_viewer_constructor)*value.v_pointer;
-        insert_viewer(new_window, viewer_constructor);
-      }
 
 
-      name = g_quark_from_string("guistatistics");
-      type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute),
-                                         name, &value);
-      if(type == LTTV_POINTER) {
-        lttvwindow_viewer_constructor viewer_constructor = 
-                  (lttvwindow_viewer_constructor)*value.v_pointer;
-        insert_viewer(new_window, viewer_constructor);
-      }
+    name = g_quark_from_string("guicontrolflow");
+    type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute),
+                                       name, &value);
+    if(type == LTTV_POINTER) {
+      lttvwindow_viewer_constructor viewer_constructor = 
+                (lttvwindow_viewer_constructor)*value.v_pointer;
+      insert_viewer(new_window, viewer_constructor);
+    }
 
 
+    name = g_quark_from_string("guistatistics");
+    type = lttv_iattribute_get_by_name(LTTV_IATTRIBUTE(attribute),
+                                       name, &value);
+    if(type == LTTV_POINTER) {
+      lttvwindow_viewer_constructor viewer_constructor = 
+                (lttvwindow_viewer_constructor)*value.v_pointer;
+      insert_viewer(new_window, viewer_constructor);
     }
   }
 
   g_info("There are now : %d windows\n",g_slist_length(g_main_window_list));
     }
   }
 
   g_info("There are now : %d windows\n",g_slist_length(g_main_window_list));
+
+  return new_m_window;
 }
 
 
 }
 
 
@@ -4060,10 +4389,11 @@ void construct_main_window(MainWindow * parent)
  * destroy the tab
  */
 
  * destroy the tab
  */
 
-void tab_destructor(Tab * tab)
+void tab_destructor(LttvPluginTab * ptab)
 {
   int i, nb, ref_count;
   LttvTrace * trace;
 {
   int i, nb, ref_count;
   LttvTrace * trace;
+  Tab *tab = ptab->tab;
 
   gtk_object_destroy(GTK_OBJECT(tab->tooltips));
   
 
   gtk_object_destroy(GTK_OBJECT(tab->tooltips));
   
@@ -4093,28 +4423,29 @@ void tab_destructor(Tab * tab)
       }
     }
   }
       }
     }
   }
-  lttv_filter_destroy(tab->filter);
   lttv_traceset_destroy(tab->traceset_info->traceset);
   /* Remove the idle events requests processing function of the tab */
   g_idle_remove_by_data(tab);
 
   g_slist_free(tab->events_requests);
   g_free(tab->traceset_info);
   lttv_traceset_destroy(tab->traceset_info->traceset);
   /* Remove the idle events requests processing function of the tab */
   g_idle_remove_by_data(tab);
 
   g_slist_free(tab->events_requests);
   g_free(tab->traceset_info);
-  g_free(tab);
+  //g_free(tab);
+  g_object_unref(ptab);
 }
 
 
 /* Create a tab and insert it into the current main window
  */
 
 }
 
 
 /* Create a tab and insert it into the current main window
  */
 
-Tab* create_tab(MainWindow * mw, Tab *copy_tab, 
+void init_tab(Tab *tab, MainWindow * mw, Tab *copy_tab, 
                  GtkNotebook * notebook, char * label)
 {
   GList * list;
                  GtkNotebook * notebook, char * label)
 {
   GList * list;
-  Tab * tab;
+  //Tab * tab;
+  //LttvFilter *filter = NULL;
   
   //create a new tab data structure
   
   //create a new tab data structure
-  tab = g_new(Tab,1);
+  //tab = g_new(Tab,1);
 
   //construct and initialize the traceset_info
   tab->traceset_info = g_new(TracesetInfo,1);
 
   //construct and initialize the traceset_info
   tab->traceset_info = g_new(TracesetInfo,1);
@@ -4127,12 +4458,10 @@ Tab* create_tab(MainWindow * mw, Tab *copy_tab,
     /* We can clone the filter, as we copy the trace set also */
     /* The filter must always be in sync with the trace set */
     tab->filter = lttv_filter_clone(copy_tab->filter);
     /* We can clone the filter, as we copy the trace set also */
     /* The filter must always be in sync with the trace set */
     tab->filter = lttv_filter_clone(copy_tab->filter);
-
   } else {
     tab->traceset_info->traceset = lttv_traceset_new();
     tab->filter = NULL;
   }
   } else {
     tab->traceset_info->traceset = lttv_traceset_new();
     tab->filter = NULL;
   }
-
 #ifdef DEBUG
   lttv_attribute_write_xml(
       lttv_traceset_attribute(tab->traceset_info->traceset),
 #ifdef DEBUG
   lttv_attribute_write_xml(
       lttv_traceset_attribute(tab->traceset_info->traceset),
@@ -4186,15 +4515,29 @@ Tab* create_tab(MainWindow * mw, Tab *copy_tab,
   tab->interrupted_state = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL);
  
   tab->vbox = gtk_vbox_new(FALSE, 2);
   tab->interrupted_state = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL);
  
   tab->vbox = gtk_vbox_new(FALSE, 2);
+  tab->top_widget = tab->vbox;
+  //g_object_set_data_full(G_OBJECT(tab->top_widget), "filter",
+//               filter, (GDestroyNotify)lttv_filter_destroy);
+
+//  g_signal_connect (G_OBJECT(tab->top_widget),
+//                      "notify",
+//                      G_CALLBACK (on_top_notify),
+//                      (gpointer)tab);
+
   tab->viewer_container = gtk_vbox_new(TRUE, 2);
   tab->scrollbar = gtk_hscrollbar_new(NULL);
   //tab->multivpaned = gtk_multi_vpaned_new();
   tab->viewer_container = gtk_vbox_new(TRUE, 2);
   tab->scrollbar = gtk_hscrollbar_new(NULL);
   //tab->multivpaned = gtk_multi_vpaned_new();
-  
   gtk_box_pack_start(GTK_BOX(tab->vbox),
                      tab->viewer_container,
                      TRUE, /* expand */
                      TRUE, /* Give the extra space to the child */
                      0);    /* No padding */
   gtk_box_pack_start(GTK_BOX(tab->vbox),
                      tab->viewer_container,
                      TRUE, /* expand */
                      TRUE, /* Give the extra space to the child */
                      0);    /* No padding */
+  
+//  if(copy_tab) {
+//    tab->time_window = copy_tab->time_window;
+//    tab->current_time = copy_tab->current_time;
+//  }
 
   /* Create the timebar */
   {
 
   /* Create the timebar */
   {
@@ -4220,6 +4563,7 @@ Tab* create_tab(MainWindow * mw, Tab *copy_tab,
     gtk_widget_show(tab->MText2);
     tab->MText3a = gtk_label_new("ns");
     gtk_widget_show(tab->MText3a);
     gtk_widget_show(tab->MText2);
     tab->MText3a = gtk_label_new("ns");
     gtk_widget_show(tab->MText3a);
+
     tab->MEventBox3b = gtk_event_box_new();
     gtk_widget_show(tab->MEventBox3b);
     gtk_tooltips_set_tip(tab->tooltips, tab->MEventBox3b, 
     tab->MEventBox3b = gtk_event_box_new();
     gtk_widget_show(tab->MEventBox3b);
     gtk_tooltips_set_tip(tab->tooltips, tab->MEventBox3b, 
@@ -4231,6 +4575,19 @@ Tab* create_tab(MainWindow * mw, Tab *copy_tab,
     gtk_widget_show(tab->MText4);
     tab->MText5a = gtk_label_new("ns");
     gtk_widget_show(tab->MText5a);
     gtk_widget_show(tab->MText4);
     tab->MText5a = gtk_label_new("ns");
     gtk_widget_show(tab->MText5a);
+
+    tab->MEventBox8 = gtk_event_box_new();
+    gtk_widget_show(tab->MEventBox8);
+    gtk_tooltips_set_tip(tab->tooltips, tab->MEventBox8, 
+        "Paste Time Interval here", "");
+    tab->MText8 = gtk_label_new("Time Interval:");
+    gtk_widget_show(tab->MText8);
+    gtk_container_add(GTK_CONTAINER(tab->MEventBox8), tab->MText8);
+    tab->MText9 = gtk_label_new("s");
+    gtk_widget_show(tab->MText9);
+    tab->MText10 = gtk_label_new("ns");
+    gtk_widget_show(tab->MText10);
+
     tab->MEventBox5b = gtk_event_box_new();
     gtk_widget_show(tab->MEventBox5b);
     gtk_tooltips_set_tip(tab->tooltips, tab->MEventBox5b, 
     tab->MEventBox5b = gtk_event_box_new();
     gtk_widget_show(tab->MEventBox5b);
     gtk_tooltips_set_tip(tab->tooltips, tab->MEventBox5b, 
@@ -4267,7 +4624,14 @@ Tab* create_tab(MainWindow * mw, Tab *copy_tab,
     gtk_spin_button_set_digits(GTK_SPIN_BUTTON(tab->MEntry6),0);
     gtk_spin_button_set_snap_to_ticks(GTK_SPIN_BUTTON(tab->MEntry6),TRUE);
     gtk_widget_show(tab->MEntry6);
     gtk_spin_button_set_digits(GTK_SPIN_BUTTON(tab->MEntry6),0);
     gtk_spin_button_set_snap_to_ticks(GTK_SPIN_BUTTON(tab->MEntry6),TRUE);
     gtk_widget_show(tab->MEntry6);
-
+    tab->MEntry7 = gtk_spin_button_new_with_range(0.0, 1.0, 1.0);
+    gtk_spin_button_set_digits(GTK_SPIN_BUTTON(tab->MEntry7),0);
+    gtk_spin_button_set_snap_to_ticks(GTK_SPIN_BUTTON(tab->MEntry7),TRUE);
+    gtk_widget_show(tab->MEntry7);
+    tab->MEntry8 = gtk_spin_button_new_with_range(0.0, 1.0, 1.0);
+    gtk_spin_button_set_digits(GTK_SPIN_BUTTON(tab->MEntry8),0);
+    gtk_spin_button_set_snap_to_ticks(GTK_SPIN_BUTTON(tab->MEntry8),TRUE);
+    gtk_widget_show(tab->MEntry8);
     
     GtkWidget *temp_widget;
     
     
     GtkWidget *temp_widget;
     
@@ -4288,6 +4652,16 @@ Tab* create_tab(MainWindow * mw, Tab *copy_tab,
     gtk_box_pack_start (GTK_BOX (tab->MTimebar), tab->MText4, FALSE, FALSE, 0);
     gtk_box_pack_start (GTK_BOX (tab->MTimebar), tab->MEntry4, FALSE, FALSE, 0);
     gtk_box_pack_start (GTK_BOX (tab->MTimebar), tab->MText5a, FALSE, FALSE, 0);
     gtk_box_pack_start (GTK_BOX (tab->MTimebar), tab->MText4, FALSE, FALSE, 0);
     gtk_box_pack_start (GTK_BOX (tab->MTimebar), tab->MEntry4, FALSE, FALSE, 0);
     gtk_box_pack_start (GTK_BOX (tab->MTimebar), tab->MText5a, FALSE, FALSE, 0);
+    temp_widget = gtk_vseparator_new();
+    gtk_widget_show(temp_widget);
+    gtk_box_pack_start (GTK_BOX (tab->MTimebar), temp_widget, FALSE, FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (tab->MTimebar), tab->MEventBox8, FALSE,
+                         FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (tab->MTimebar), tab->MEntry7, FALSE, FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (tab->MTimebar), tab->MText9, FALSE, FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (tab->MTimebar), tab->MEntry8, FALSE, FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (tab->MTimebar), tab->MText10, FALSE, FALSE, 0);
+
     temp_widget = gtk_vseparator_new();
     gtk_widget_show(temp_widget);
     gtk_box_pack_end (GTK_BOX (tab->MTimebar), tab->MText7, FALSE, FALSE, 0);
     temp_widget = gtk_vseparator_new();
     gtk_widget_show(temp_widget);
     gtk_box_pack_end (GTK_BOX (tab->MTimebar), tab->MText7, FALSE, FALSE, 0);
@@ -4335,6 +4709,10 @@ Tab* create_tab(MainWindow * mw, Tab *copy_tab,
                       "button-press-event",
                       G_CALLBACK (on_MEventBox5b_paste),
                       (gpointer)tab);
                       "button-press-event",
                       G_CALLBACK (on_MEventBox5b_paste),
                       (gpointer)tab);
+    g_signal_connect (G_OBJECT(tab->MEventBox8),
+                      "button-press-event",
+                      G_CALLBACK (on_MEventBox8_paste),
+                      (gpointer)tab);
   }
 
   gtk_box_pack_end(GTK_BOX(tab->vbox),
   }
 
   gtk_box_pack_end(GTK_BOX(tab->vbox),
@@ -4396,12 +4774,9 @@ Tab* create_tab(MainWindow * mw, Tab *copy_tab,
   /* Start with empty events requests list */
   tab->events_requests = NULL;
   tab->events_request_pending = FALSE;
   /* Start with empty events requests list */
   tab->events_requests = NULL;
   tab->events_request_pending = FALSE;
+  tab->stop_foreground = FALSE;
+  
 
 
-  g_object_set_data_full(
-           G_OBJECT(tab->vbox),
-           "Tab_Info",
-                tab,
-                (GDestroyNotify)tab_destructor);
 
   g_signal_connect(G_OBJECT(tab->scrollbar), "value-changed",
       G_CALLBACK(scroll_value_changed_cb), tab);
 
   g_signal_connect(G_OBJECT(tab->scrollbar), "value-changed",
       G_CALLBACK(scroll_value_changed_cb), tab);
@@ -4424,6 +4799,12 @@ Tab* create_tab(MainWindow * mw, Tab *copy_tab,
   g_signal_connect ((gpointer) tab->MEntry6, "value-changed",
                     G_CALLBACK (on_MEntry6_value_changed),
                     tab);
   g_signal_connect ((gpointer) tab->MEntry6, "value-changed",
                     G_CALLBACK (on_MEntry6_value_changed),
                     tab);
+  g_signal_connect ((gpointer) tab->MEntry7, "value-changed",
+                    G_CALLBACK (on_MEntry7_value_changed),
+                    tab);
+  g_signal_connect ((gpointer) tab->MEntry8, "value-changed",
+                    G_CALLBACK (on_MEntry8_value_changed),
+                    tab);
 
   //g_signal_connect(G_OBJECT(tab->scrollbar), "changed",
   //    G_CALLBACK(scroll_value_changed_cb), tab);
 
   //g_signal_connect(G_OBJECT(tab->scrollbar), "changed",
   //    G_CALLBACK(scroll_value_changed_cb), tab);
@@ -4438,7 +4819,24 @@ Tab* create_tab(MainWindow * mw, Tab *copy_tab,
   // always show : not if(g_list_length(list)>1)
   gtk_notebook_set_show_tabs(notebook, TRUE);
  
   // always show : not if(g_list_length(list)>1)
   gtk_notebook_set_show_tabs(notebook, TRUE);
  
-  return tab;
+  if(copy_tab) {
+    lttvwindow_report_time_window(tab, copy_tab->time_window);
+    lttvwindow_report_current_time(tab, copy_tab->current_time);
+  } else {
+    TimeWindow time_window;
+
+    time_window.start_time = ltt_time_zero;
+    time_window.end_time = ltt_time_add(time_window.start_time,
+        lttvwindow_default_time_width);
+    time_window.time_width = lttvwindow_default_time_width;
+    time_window.time_width_double = ltt_time_to_double(time_window.time_width);
+
+    lttvwindow_report_time_window(tab, time_window);
+    lttvwindow_report_current_time(tab, ltt_time_zero);
+  }
+  LttvTraceset *traceset = tab->traceset_info->traceset;
+  SetTraceset(tab, traceset);
 }
 
 /*
 }
 
 /*
@@ -4453,3 +4851,66 @@ gboolean execute_events_requests(Tab *tab)
   return ( lttvwindow_process_pending_requests(tab) );
 }
 
   return ( lttvwindow_process_pending_requests(tab) );
 }
 
+
+void create_main_window_with_trace_list(GSList *traces)
+{
+  GSList *iter = NULL;
+
+  /* Create window */
+  MainWindow *mw = construct_main_window(NULL);
+  GtkWidget *widget = mw->mwindow;
+
+  GtkWidget * notebook = lookup_widget(widget, "MNotebook");
+  GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook),
+                      gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)));
+  LttvPluginTab *ptab;
+  Tab *tab;
+  
+  if(!page) {
+    ptab = create_new_tab(widget, NULL);
+    tab = ptab->tab;
+  } else {
+    ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin");
+    tab = ptab->tab;
+  }
+
+  for(iter=traces; iter!=NULL; iter=g_slist_next(iter)) {
+    gchar *path = (gchar*)iter->data;
+    /* Add trace */
+    gchar abs_path[PATH_MAX];
+    LttvTrace *trace_v;
+    LttTrace *trace;
+
+    get_absolute_pathname(path, abs_path);
+    trace_v = lttvwindowtraces_get_trace_by_name(abs_path);
+    if(trace_v == NULL) {
+      trace = ltt_trace_open(abs_path);
+      if(trace == NULL) {
+        g_warning("cannot open trace %s", abs_path);
+
+        GtkWidget *dialogue = 
+          gtk_message_dialog_new(
+            GTK_WINDOW(gtk_widget_get_toplevel(widget)),
+            GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
+            GTK_MESSAGE_ERROR,
+            GTK_BUTTONS_OK,
+            "Cannot open trace : maybe you should enter in the directory "
+            "to select it ?");
+        gtk_dialog_run(GTK_DIALOG(dialogue));
+        gtk_widget_destroy(dialogue);
+      } else {
+        trace_v = lttv_trace_new(trace);
+        lttvwindowtraces_add_trace(trace_v);
+        lttvwindow_add_trace(tab, trace_v);
+      }
+    } else {
+      lttvwindow_add_trace(tab, trace_v);
+    }
+  }
+  
+  LttvTraceset *traceset;
+
+  traceset = tab->traceset_info->traceset;
+  SetTraceset(tab, traceset);
+}
+
This page took 0.041213 seconds and 4 git commands to generate.