specific popt link
[lttv.git] / ltt / branches / poly / lttv / modules / gui / lttvwindow / lttvwindow / callbacks.c
index 8a228fbab8b9b465d9fc5c69c3c3897031f87f24..c4568cf49498bc3af206c4b6afc7a702fa35b883 100644 (file)
@@ -61,7 +61,7 @@ gboolean get_filter_selection(LttvTracesetSelector *s, char *title, char * colum
 void * create_tab(MainWindow * parent, MainWindow * current_window,
                  GtkNotebook * notebook, char * label);
 
-void insert_viewer(GtkWidget* widget, view_constructor constructor);
+void insert_viewer(GtkWidget* widget, lttvwindow_viewer_constructor constructor);
 void update_filter(LttvTracesetSelector *s,  GtkTreeStore *store );
 
 void checkbox_changed(GtkTreeView *treeview,
@@ -153,13 +153,13 @@ insert_viewer_wrap(GtkWidget *menuitem, gpointer user_data)
 {
   guint val = 20;
 
-  insert_viewer((GtkWidget*)menuitem, (view_constructor)user_data);
+  insert_viewer((GtkWidget*)menuitem, (lttvwindow_viewer_constructor)user_data);
   //  selected_hook(&val);
 }
 
 
 /* internal functions */
-void insert_viewer(GtkWidget* widget, view_constructor constructor)
+void insert_viewer(GtkWidget* widget, lttvwindow_viewer_constructor constructor)
 {
   GtkMultiVPaned * multi_vpaned;
   MainWindow * mw_data;  
@@ -189,9 +189,9 @@ void insert_viewer(GtkWidget* widget, view_constructor constructor)
     }
 
     redraw_viewer(mw_data,&time_window);
-    set_current_time(mw_data,&(mw_data->current_tab->current_time));
+    lttvwindow_report_current_time(mw_data,&(mw_data->current_tab->current_time));
     if(time_interval){
-      set_time_window(mw_data,&t);
+      lttvwindow_report_time_window(mw_data,&t);
     }
   }
 }
@@ -389,7 +389,7 @@ void redraw_viewer(MainWindow * mw_data, TimeWindow * time_window)
   GdkCursor * new;
   GtkWidget* widget;
   LttvTracesetContext *tsc = 
-   LTTV_TRACESET_CONTEXT(main_win->current_tab->traceset_info->
+   LTTV_TRACESET_CONTEXT(mw_data->current_tab->traceset_info->
                             traceset_context);
 
   //set the cursor to be X shape, indicating that the computer is busy in doing its job
@@ -402,7 +402,7 @@ void redraw_viewer(MainWindow * mw_data, TimeWindow * time_window)
   gdk_window_unstick(win);
  
   //update time window of each viewer, let viewer insert hooks needed by process_traceset
-  set_time_window(mw_data, time_window);
+  lttvwindow_report_time_window(mw_data, time_window);
   
   max_nb_events = get_max_event_number(mw_data);
 
@@ -485,6 +485,7 @@ void add_trace(GtkWidget * widget, gpointer user_data)
   LttTrace *trace;
   LttvTrace * trace_v;
   LttvTraceset * traceset;
+  LttvTracesetStats* tmp_context;
   const char * dir;
   gint id;
   MainWindow * mw_data = get_window_data_struct(widget);
@@ -507,25 +508,31 @@ void add_trace(GtkWidget * widget, gpointer user_data)
       if(trace == NULL) g_critical("cannot open trace %s", dir);
       trace_v = lttv_trace_new(trace);
       traceset = mw_data->current_tab->traceset_info->traceset;
-      if(mw_data->current_tab->traceset_info->traceset_context != NULL){
-      //remove state update hooks
-      lttv_state_remove_event_hooks(
-           (LttvTracesetState*)mw_data->current_tab->traceset_info->
-                                traceset_context);
-       lttv_context_fini(LTTV_TRACESET_CONTEXT(mw_data->current_tab->
-                                               traceset_info->traceset_context));
-       g_object_unref(mw_data->current_tab->traceset_info->traceset_context);
-      }
+
+      // Keep the context until the new one is created.
+      tmp_context = mw_data->current_tab->traceset_info->traceset_context;
+      mw_data->current_tab->traceset_info->traceset_context = NULL;
+
       lttv_traceset_add(traceset, trace_v);
       mw_data->current_tab->traceset_info->traceset_context =
-       g_object_new(LTTV_TRACESET_STATS_TYPE, NULL);
+                               g_object_new(LTTV_TRACESET_STATS_TYPE, NULL);
       lttv_context_init(
-       LTTV_TRACESET_CONTEXT(mw_data->current_tab->traceset_info->
-                             traceset_context),traceset); 
+               LTTV_TRACESET_CONTEXT(mw_data->current_tab->traceset_info->
+                                                           traceset_context),
+                traceset); 
       //add state update hooks
       lttv_state_add_event_hooks(
       (LttvTracesetState*)mw_data->current_tab->traceset_info->traceset_context);
-  
+      if(tmp_context != NULL)
+      {
+        //remove state update hooks
+        lttv_state_remove_event_hooks(
+           (LttvTracesetState*)tmp_context);
+       lttv_context_fini(LTTV_TRACESET_CONTEXT(tmp_context));
+       g_object_unref(tmp_context);
+      }
+
+
  
       add_trace_into_traceset_selector(mw_data->current_tab->multi_vpaned, trace);
 
@@ -534,7 +541,7 @@ void add_trace(GtkWidget * widget, gpointer user_data)
       //update current tab
       update_traceset(mw_data);
 
-      get_traceset_time_span(mw_data,LTTV_TRACESET_CONTEXT(mw_data->current_tab->traceset_info->traceset_context)->Time_Span);
+      //get_traceset_time_span(mw_data,LTTV_TRACESET_CONTEXT(mw_data->current_tab->traceset_info->traceset_context)->Time_Span);
       if(lttv_traceset_number(mw_data->current_tab->traceset_info->traceset) == 1 ||
         ltt_time_compare(mw_data->current_tab->current_time,
              LTTV_TRACESET_CONTEXT(mw_data->current_tab->traceset_info->traceset_context)->Time_Span->startTime)<0){
@@ -546,7 +553,7 @@ void add_trace(GtkWidget * widget, gpointer user_data)
       } 
 
       redraw_viewer(mw_data, &(mw_data->current_tab->time_window));
-      set_current_time(mw_data,&(mw_data->current_tab->current_time));
+      lttvwindow_report_current_time(mw_data,&(mw_data->current_tab->current_time));
       break;
     case GTK_RESPONSE_REJECT:
     case GTK_RESPONSE_CANCEL:
@@ -595,6 +602,7 @@ void remove_trace(GtkWidget * widget, gpointer user_data)
   LttTrace *trace;
   LttvTrace * trace_v;
   LttvTraceset * traceset;
+  LttvTracesetStats* tmp_context;
   gint i, nb_trace;
   char ** name, *remove_trace_name;
   MainWindow * mw_data = get_window_data_struct(widget);
@@ -647,16 +655,11 @@ void remove_trace(GtkWidget * widget, gpointer user_data)
          trace_v = lttv_traceset_get(traceset, i);
          if(lttv_trace_get_ref_number(trace_v) <= 1)
            ltt_trace_close(lttv_trace(trace_v));
-
-         if(mw_data->current_tab->traceset_info->traceset_context != NULL){
-      //remove state update hooks
-      lttv_state_remove_event_hooks(
-           (LttvTracesetState*)mw_data->current_tab->traceset_info->
-                                traceset_context);
-           lttv_context_fini(LTTV_TRACESET_CONTEXT(mw_data->current_tab->
-                                                   traceset_info->traceset_context));
-           g_object_unref(mw_data->current_tab->traceset_info->traceset_context);
-         }
+    
+    // Keep the context until the new one is created.
+    tmp_context = mw_data->current_tab->traceset_info->traceset_context;
+    mw_data->current_tab->traceset_info->traceset_context = NULL;
+    
          lttv_traceset_remove(traceset, i);
          if(!lttv_trace_get_ref_number(trace_v))
             lttv_trace_destroy(trace_v);
@@ -668,11 +671,21 @@ void remove_trace(GtkWidget * widget, gpointer user_data)
       //add state update hooks
       lttv_state_add_event_hooks(
       (LttvTracesetState*)mw_data->current_tab->traceset_info->traceset_context);
+
+         if(tmp_context != NULL){
+      //remove state update hooks
+      lttv_state_remove_event_hooks(
+           (LttvTracesetState*)tmp_context);
+           lttv_context_fini(LTTV_TRACESET_CONTEXT(tmp_context));
+           g_object_unref(tmp_context);
+         }
+
+      
          //update current tab
          update_traceset(mw_data);
          if(nb_trace > 1){
            redraw_viewer(mw_data, &(mw_data->current_tab->time_window));
-           set_current_time(mw_data,&(mw_data->current_tab->current_time));
+           lttvwindow_report_current_time(mw_data,&(mw_data->current_tab->current_time));
          }else{
            if(mw_data->current_tab){
              while(mw_data->current_tab->multi_vpaned->num_children){
@@ -749,7 +762,7 @@ void zoom(GtkWidget * widget, double size)
     time_window.start_time = time_s;    
   }
   redraw_viewer(mw_data, &time_window);
-  set_current_time(mw_data,&(mw_data->current_tab->current_time));
+  lttvwindow_report_current_time(mw_data,&(mw_data->current_tab->current_time));
   gtk_multi_vpaned_set_adjust(mw_data->current_tab->multi_vpaned, FALSE);
 }
 
@@ -1028,7 +1041,7 @@ on_trace_filter_activate              (GtkMenuItem     *menuitem,
   if(get_filter_selection(s, "Configure trace and tracefile filter", "Select traces and tracefiles")){
     update_traceset(mw_data);
     redraw_viewer(mw_data, &(mw_data->current_tab->time_window));
-    set_current_time(mw_data,&(mw_data->current_tab->current_time));
+    lttvwindow_report_current_time(mw_data,&(mw_data->current_tab->current_time));
   }
 }
 
@@ -1737,7 +1750,7 @@ void insert_menu_toolbar_item(MainWindow * mw, gpointer user_data)
 {
   int i;
   GdkPixbuf *pixbuf;
-  view_constructor constructor;
+  lttvwindow_viewer_constructor constructor;
   LttvMenus * menu;
   LttvToolbars * toolbar;
   lttv_menu_closure *menu_item;
@@ -2049,7 +2062,7 @@ void remove_toolbar_item(gpointer main_win, gpointer user_data)
  * main windows
  */
 
-void main_window_remove_menu_item(lttv_constructor constructor)
+void main_window_remove_menu_item(lttvwindow_viewer_constructor constructor)
 {
   int i;
   LttvMenus * menu;
@@ -2074,7 +2087,7 @@ void main_window_remove_menu_item(lttv_constructor constructor)
   
 }
 
-void main_window_remove_toolbar_item(lttv_constructor constructor)
+void main_window_remove_toolbar_item(lttvwindow_viewer_constructor constructor)
 {
   int i;
   LttvToolbars * toolbar;
This page took 0.025952 seconds and 4 git commands to generate.