authors in about
[lttv.git] / ltt / branches / poly / lttv / modules / gui / lttvwindow / lttvwindow / callbacks.c
index faa2c28b278b6dfd4bf69b517cb83c8256d6e8bf..c101c9c6c792d2624db211943c42fca489ab98c6 100644 (file)
@@ -238,31 +238,38 @@ void insert_viewer(GtkWidget* widget, lttvwindow_viewer_constructor constructor)
 
 int SetTraceset(Tab * tab, LttvTraceset *traceset)
 {
-  LttvHooks * tmp;
-  LttvAttributeValue value;
-  gint retval = 0;
-
-  g_assert( lttv_iattribute_find_by_path(tab->attributes,
-     "hooks/updatetraceset", LTTV_POINTER, &value));
-
-  tmp = (LttvHooks*)*(value.v_pointer);
-  if(tmp == NULL) retval = 1;
-  else lttv_hooks_call(tmp,traceset);
-
-  /* Set scrollbar */
   LttvTracesetContext *tsc =
         LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context);
   TimeInterval time_span = tsc->time_span;
+
+  /* Set the tab's time window and current time if
+   * out of bounds */
+  if(ltt_time_compare(tab->time_window.start_time, time_span.start_time) < 0
+     || ltt_time_compare(  ltt_time_add(tab->time_window.start_time,
+                                        tab->time_window.time_width),
+                           time_span.end_time) > 0) {
+    tab->time_window.start_time = time_span.start_time;
+    tab->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;
+    else
+      tmp_time.tv_sec = time_span.end_time.tv_sec;
+    tmp_time.tv_nsec = 0;
+    tab->time_window.time_width = tmp_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);
       
   g_object_set(G_OBJECT(adjustment),
                "lower",
-               ltt_time_to_double(time_span.start_time) 
-                 * NANOSECONDS_PER_SECOND, /* lower */
+                 0.0, /* lower */
                "upper",
-               ltt_time_to_double(time_span.end_time
+               ltt_time_to_double(upper
                  * NANOSECONDS_PER_SECOND, /* upper */
                "step_increment",
                ltt_time_to_double(tab->time_window.time_width)
@@ -279,11 +286,26 @@ int SetTraceset(Tab * tab, LttvTraceset *traceset)
 
   g_object_set(G_OBJECT(adjustment),
                "value",
-               ltt_time_to_double(tab->time_window.start_time) 
-                 * NANOSECONDS_PER_SECOND, /* value */
+               ltt_time_to_double(
+                ltt_time_sub(tab->time_window.start_time, time_span.start_time))
+                   * NANOSECONDS_PER_SECOND, /* value */
                NULL);
   gtk_adjustment_value_changed(adjustment);
-  
+
+  /* Finally, call the update hooks of the viewers */
+  LttvHooks * tmp;
+  LttvAttributeValue value;
+  gint retval = 0;
+
+  g_assert( lttv_iattribute_find_by_path(tab->attributes,
+     "hooks/updatetraceset", LTTV_POINTER, &value));
+
+  tmp = (LttvHooks*)*(value.v_pointer);
+  if(tmp == NULL) retval = 1;
+  else lttv_hooks_call(tmp,traceset);
+
   return retval;
 }
 
@@ -745,259 +767,190 @@ gboolean lttvwindow_process_pending_requests(Tab *tab)
    */
   /* A. Servicing loop */
   //while( (g_slist_length(list_in) != 0 || g_slist_length(list_out) != 0)) {
+  if((g_slist_length(list_in) != 0 || g_slist_length(list_out) != 0)) {
+    /* Servicing */
+    /* 1. If list_in is empty (need a seek) */
+    if( g_slist_length(list_in) ==  0 ) {
 
-  /* Servicing */
-  /* 1. If list_in is empty (need a seek) */
-  if( g_slist_length(list_in) ==  0 ) {
-
-    /* list in is empty, need a seek */
-    {
-      /* 1.1 Add requests to list_in */
-      GSList *ltime = NULL;
-      GSList *lpos = NULL;
-      GSList *iter = NULL;
-      
-      /* 1.1.1 Find all time requests with the lowest start time in list_out
-       * (ltime)
-       */
-      if(g_slist_length(list_out) > 0)
-        ltime = g_slist_append(ltime, g_slist_nth_data(list_out, 0));
-      for(iter=g_slist_nth(list_out,1);iter!=NULL;iter=g_slist_next(iter)) {
-        /* Find all time requests with the lowest start time in list_out */
-        guint index_ltime = g_array_index(ltime, guint, 0);
-        EventsRequest *event_request_ltime = (EventsRequest*)g_slist_nth_data(ltime, 0);
-        EventsRequest *event_request_list_out = (EventsRequest*)iter->data;
-
-        int comp;
-        comp = ltt_time_compare(event_request_ltime->start_time,
-                                event_request_list_out->start_time);
-        if(comp == 0)
-          ltime = g_slist_append(ltime, event_request_list_out);
-        else if(comp > 0) {
-          /* Remove all elements from ltime, and add current */
-          while(ltime != NULL)
-            ltime = g_slist_delete_link(ltime, g_slist_nth(ltime, 0));
-          ltime = g_slist_append(ltime, event_request_list_out);
-        }
-      }
-      
-      /* 1.1.2 Find all position requests with the lowest position in list_out
-       * (lpos)
-       */
-      if(g_slist_length(list_out) > 0)
-        lpos = g_slist_append(lpos, g_slist_nth_data(list_out, 0));
-      for(iter=g_slist_nth(list_out,1);iter!=NULL;iter=g_slist_next(iter)) {
-        /* Find all position requests with the lowest position in list_out */
-        EventsRequest *event_request_lpos = (EventsRequest*)g_slist_nth_data(lpos, 0);
-        EventsRequest *event_request_list_out = (EventsRequest*)iter->data;
-
-        int comp;
-        if(event_request_lpos->start_position != NULL
-            && event_request_list_out->start_position != NULL)
-        {
-          comp = lttv_traceset_context_pos_pos_compare
-                               (event_request_lpos->start_position,
-                                event_request_list_out->start_position);
-        } else {
-          comp = -1;
-        }
-        if(comp == 0)
-          lpos = g_slist_append(lpos, event_request_list_out);
-        else if(comp > 0) {
-          /* Remove all elements from lpos, and add current */
-          while(lpos != NULL)
-            lpos = g_slist_delete_link(lpos, g_slist_nth(lpos, 0));
-          lpos = g_slist_append(lpos, event_request_list_out);
-        }
-      }
-      
+      /* list in is empty, need a seek */
       {
-        EventsRequest *event_request_lpos = (EventsRequest*)g_slist_nth_data(lpos, 0);
-        EventsRequest *event_request_ltime = (EventsRequest*)g_slist_nth_data(ltime, 0);
-        LttTime lpos_start_time;
+        /* 1.1 Add requests to list_in */
+        GSList *ltime = NULL;
+        GSList *lpos = NULL;
+        GSList *iter = NULL;
         
-        if(event_request_lpos != NULL 
-            && event_request_lpos->start_position != NULL) {
-          lpos_start_time = lttv_traceset_context_position_get_time(
-                                    event_request_lpos->start_position);
+        /* 1.1.1 Find all time requests with the lowest start time in list_out
+         * (ltime)
+         */
+        if(g_slist_length(list_out) > 0)
+          ltime = g_slist_append(ltime, g_slist_nth_data(list_out, 0));
+        for(iter=g_slist_nth(list_out,1);iter!=NULL;iter=g_slist_next(iter)) {
+          /* Find all time requests with the lowest start time in list_out */
+          guint index_ltime = g_array_index(ltime, guint, 0);
+          EventsRequest *event_request_ltime = (EventsRequest*)g_slist_nth_data(ltime, 0);
+          EventsRequest *event_request_list_out = (EventsRequest*)iter->data;
+
+          int comp;
+          comp = ltt_time_compare(event_request_ltime->start_time,
+                                  event_request_list_out->start_time);
+          if(comp == 0)
+            ltime = g_slist_append(ltime, event_request_list_out);
+          else if(comp > 0) {
+            /* Remove all elements from ltime, and add current */
+            while(ltime != NULL)
+              ltime = g_slist_delete_link(ltime, g_slist_nth(ltime, 0));
+            ltime = g_slist_append(ltime, event_request_list_out);
+          }
         }
         
-        /* 1.1.3 If lpos.start time < ltime */
-        if(event_request_lpos != NULL
-            && event_request_lpos->start_position != NULL
-            && ltt_time_compare(lpos_start_time,
-                            event_request_ltime->start_time)<0) {
-          /* Add lpos to list_in, remove them from list_out */
-          for(iter=lpos;iter!=NULL;iter=g_slist_next(iter)) {
-            /* Add to list_in */
-            EventsRequest *event_request_lpos = 
-                                  (EventsRequest*)iter->data;
-
-            list_in = g_slist_append(list_in, event_request_lpos);
-            /* Remove from list_out */
-            list_out = g_slist_remove(list_out, event_request_lpos);
+        /* 1.1.2 Find all position requests with the lowest position in list_out
+         * (lpos)
+         */
+        if(g_slist_length(list_out) > 0)
+          lpos = g_slist_append(lpos, g_slist_nth_data(list_out, 0));
+        for(iter=g_slist_nth(list_out,1);iter!=NULL;iter=g_slist_next(iter)) {
+          /* Find all position requests with the lowest position in list_out */
+          EventsRequest *event_request_lpos = (EventsRequest*)g_slist_nth_data(lpos, 0);
+          EventsRequest *event_request_list_out = (EventsRequest*)iter->data;
+
+          int comp;
+          if(event_request_lpos->start_position != NULL
+              && event_request_list_out->start_position != NULL)
+          {
+            comp = lttv_traceset_context_pos_pos_compare
+                                 (event_request_lpos->start_position,
+                                  event_request_list_out->start_position);
+          } else {
+            comp = -1;
           }
-        } else {
-          /* 1.1.4 (lpos.start time >= ltime) */
-          /* Add ltime to list_in, remove them from list_out */
-
-          for(iter=ltime;iter!=NULL;iter=g_slist_next(iter)) {
-            /* Add to list_in */
-            EventsRequest *event_request_ltime = 
-                                  (EventsRequest*)iter->data;
-
-            list_in = g_slist_append(list_in, event_request_ltime);
-            /* Remove from list_out */
-            list_out = g_slist_remove(list_out, event_request_ltime);
+          if(comp == 0)
+            lpos = g_slist_append(lpos, event_request_list_out);
+          else if(comp > 0) {
+            /* Remove all elements from lpos, and add current */
+            while(lpos != NULL)
+              lpos = g_slist_delete_link(lpos, g_slist_nth(lpos, 0));
+            lpos = g_slist_append(lpos, event_request_list_out);
           }
         }
-      }
-      g_slist_free(lpos);
-      g_slist_free(ltime);
-    }
-
-    /* 1.2 Seek */
-    {
-      tfc = lttv_traceset_context_get_current_tfc(tsc);
-      g_assert(g_slist_length(list_in)>0);
-      EventsRequest *events_request = g_slist_nth_data(list_in, 0);
-      guint seek_count;
-
-      /* 1.2.1 If first request in list_in is a time request */
-      if(events_request->start_position == NULL) {
-        /* - If first req in list_in start time != current time */
-        if(tfc == NULL || ltt_time_compare(events_request->start_time,
-                            tfc->timestamp) != 0)
-          /* - Seek to that time */
-          g_debug("SEEK TIME : %lu, %lu", events_request->start_time.tv_sec,
-            events_request->start_time.tv_nsec);
-          //lttv_process_traceset_seek_time(tsc, events_request->start_time);
-          lttv_state_traceset_seek_time_closest(LTTV_TRACESET_STATE(tsc),
-                                                events_request->start_time);
-
-          /* Process the traceset with only state hooks */
-          seek_count =
-             lttv_process_traceset_middle(tsc,
-                                          events_request->start_time,
-                                          G_MAXUINT, NULL);
-
-
-      } else {
-        LttTime pos_time;
-        /* 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);
-        g_debug("SEEK POS time : %lu, %lu", 
-               lttv_traceset_context_position_get_time(
-                    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);
-        g_assert(events_request->start_position != NULL);
-        if(lttv_traceset_context_ctx_pos_compare(tsc,
-                   events_request->start_position) != 0) {
-          /* 1.2.2.1 Seek to that position */
-          g_debug("SEEK POSITION");
-          //lttv_process_traceset_seek_position(tsc, events_request->start_position);
-          pos_time = lttv_traceset_context_position_get_time(
-                                   events_request->start_position);
+        
+        {
+          EventsRequest *event_request_lpos = (EventsRequest*)g_slist_nth_data(lpos, 0);
+          EventsRequest *event_request_ltime = (EventsRequest*)g_slist_nth_data(ltime, 0);
+          LttTime lpos_start_time;
           
-          lttv_state_traceset_seek_time_closest(LTTV_TRACESET_STATE(tsc),
-                                                pos_time);
-
-          /* Process the traceset with only state hooks */
-          seek_count =
-             lttv_process_traceset_middle(tsc,
-                                          ltt_time_infinite,
-                                          G_MAXUINT,
-                                          events_request->start_position);
-          g_assert(lttv_traceset_context_ctx_pos_compare(tsc,
-                       events_request->start_position) == 0);
-
-
+          if(event_request_lpos != NULL 
+              && event_request_lpos->start_position != NULL) {
+            lpos_start_time = lttv_traceset_context_position_get_time(
+                                      event_request_lpos->start_position);
+          }
+          
+          /* 1.1.3 If lpos.start time < ltime */
+          if(event_request_lpos != NULL
+              && event_request_lpos->start_position != NULL
+              && ltt_time_compare(lpos_start_time,
+                              event_request_ltime->start_time)<0) {
+            /* Add lpos to list_in, remove them from list_out */
+            for(iter=lpos;iter!=NULL;iter=g_slist_next(iter)) {
+              /* Add to list_in */
+              EventsRequest *event_request_lpos = 
+                                    (EventsRequest*)iter->data;
+
+              list_in = g_slist_append(list_in, event_request_lpos);
+              /* Remove from list_out */
+              list_out = g_slist_remove(list_out, event_request_lpos);
+            }
+          } else {
+            /* 1.1.4 (lpos.start time >= ltime) */
+            /* Add ltime to list_in, remove them from list_out */
+
+            for(iter=ltime;iter!=NULL;iter=g_slist_next(iter)) {
+              /* Add to list_in */
+              EventsRequest *event_request_ltime = 
+                                    (EventsRequest*)iter->data;
+
+              list_in = g_slist_append(list_in, event_request_ltime);
+              /* Remove from list_out */
+              list_out = g_slist_remove(list_out, event_request_ltime);
+            }
+          }
         }
+        g_slist_free(lpos);
+        g_slist_free(ltime);
       }
-    }
 
-    /* 1.3 Add hooks and call before request for all list_in members */
-    {
-      GSList *iter = NULL;
+      /* 1.2 Seek */
+      {
+        tfc = lttv_traceset_context_get_current_tfc(tsc);
+        g_assert(g_slist_length(list_in)>0);
+        EventsRequest *events_request = g_slist_nth_data(list_in, 0);
+        guint seek_count;
+
+        /* 1.2.1 If first request in list_in is a time request */
+        if(events_request->start_position == NULL) {
+          /* - If first req in list_in start time != current time */
+          if(tfc == NULL || ltt_time_compare(events_request->start_time,
+                              tfc->timestamp) != 0)
+            /* - Seek to that time */
+            g_debug("SEEK TIME : %lu, %lu", events_request->start_time.tv_sec,
+              events_request->start_time.tv_nsec);
+            //lttv_process_traceset_seek_time(tsc, events_request->start_time);
+            lttv_state_traceset_seek_time_closest(LTTV_TRACESET_STATE(tsc),
+                                                  events_request->start_time);
+
+            /* Process the traceset with only state hooks */
+            seek_count =
+               lttv_process_traceset_middle(tsc,
+                                            events_request->start_time,
+                                            G_MAXUINT, NULL);
 
-      for(iter=list_in;iter!=NULL;iter=g_slist_next(iter)) {
-        EventsRequest *events_request = (EventsRequest*)iter->data;
-        /* 1.3.1 If !servicing */
-        if(events_request->servicing == FALSE) {
-          /* - begin request hooks called
-           * - servicing = TRUE
-           */
-          lttv_hooks_call(events_request->before_request, (gpointer)tsc);
-          events_request->servicing = TRUE;
-        }
-        /* 1.3.2 call before chunk
-         * 1.3.3 events hooks added
-         */
-        lttv_process_traceset_begin(tsc, events_request->before_chunk_traceset,
-                                         events_request->before_chunk_trace,
-                                         events_request->before_chunk_tracefile,
-                                         events_request->event,
-                                         events_request->event_by_id);
-      }
-    }
-  } else {
-    /* 2. Else, list_in is not empty, we continue a read */
-    
-    {
-      /* 2.0 For each req of list_in */
-      GSList *iter = list_in;
-  
-      while(iter != NULL) {
 
-        EventsRequest *events_request = (EventsRequest *)iter->data;
-        
-        /* - Call before chunk
-         * - events hooks added
-         */
-        lttv_process_traceset_begin(tsc, events_request->before_chunk_traceset,
-                                       events_request->before_chunk_trace,
-                                       events_request->before_chunk_tracefile,
-                                       events_request->event,
-                                       events_request->event_by_id);
+        } else {
+          LttTime pos_time;
+          /* 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);
+          g_debug("SEEK POS time : %lu, %lu", 
+                 lttv_traceset_context_position_get_time(
+                      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);
+          g_assert(events_request->start_position != NULL);
+          if(lttv_traceset_context_ctx_pos_compare(tsc,
+                     events_request->start_position) != 0) {
+            /* 1.2.2.1 Seek to that position */
+            g_debug("SEEK POSITION");
+            //lttv_process_traceset_seek_position(tsc, events_request->start_position);
+            pos_time = lttv_traceset_context_position_get_time(
+                                     events_request->start_position);
+            
+            lttv_state_traceset_seek_time_closest(LTTV_TRACESET_STATE(tsc),
+                                                  pos_time);
+
+            /* Process the traceset with only state hooks */
+            seek_count =
+               lttv_process_traceset_middle(tsc,
+                                            ltt_time_infinite,
+                                            G_MAXUINT,
+                                            events_request->start_position);
+            g_assert(lttv_traceset_context_ctx_pos_compare(tsc,
+                         events_request->start_position) == 0);
 
-        iter = g_slist_next(iter);
-      }
-    }
 
-    {
-      tfc = lttv_traceset_context_get_current_tfc(tsc);
-    
-      /* 2.1 For each req of list_out */
-      GSList *iter = list_out;
-  
-      while(iter != NULL) {
+          }
+        }
+      }
 
-        gboolean remove = FALSE;
-        gboolean free_data = FALSE;
-        EventsRequest *events_request = (EventsRequest *)iter->data;
-        
-        /* if req.start time == current context time 
-         * or req.start position == current position*/
-        if(  ltt_time_compare(events_request->start_time,
-                            tfc->timestamp) == 0 
-           ||
-             (events_request->start_position != NULL 
-             &&
-             lttv_traceset_context_ctx_pos_compare(tsc,
-                     events_request->start_position) == 0)
-           ) {
-          /* - Add to list_in, remove from list_out */
-          list_in = g_slist_append(list_in, events_request);
-          remove = TRUE;
-          free_data = FALSE;
+      /* 1.3 Add hooks and call before request for all list_in members */
+      {
+        GSList *iter = NULL;
 
-          /* - If !servicing */
+        for(iter=list_in;iter!=NULL;iter=g_slist_next(iter)) {
+          EventsRequest *events_request = (EventsRequest*)iter->data;
+          /* 1.3.1 If !servicing */
           if(events_request->servicing == FALSE) {
             /* - begin request hooks called
              * - servicing = TRUE
@@ -1005,8 +958,8 @@ gboolean lttvwindow_process_pending_requests(Tab *tab)
             lttv_hooks_call(events_request->before_request, (gpointer)tsc);
             events_request->servicing = TRUE;
           }
-          /* call before chunk
-           * events hooks added
+          /* 1.3.2 call before chunk
+           * 1.3.3 events hooks added
            */
           lttv_process_traceset_begin(tsc, events_request->before_chunk_traceset,
                                            events_request->before_chunk_trace,
@@ -1014,230 +967,299 @@ gboolean lttvwindow_process_pending_requests(Tab *tab)
                                            events_request->event,
                                            events_request->event_by_id);
         }
+      }
+    } else {
+      /* 2. Else, list_in is not empty, we continue a read */
+      
+      {
+        /* 2.0 For each req of list_in */
+        GSList *iter = list_in;
+    
+        while(iter != NULL) {
 
-        /* Go to next */
-        if(remove)
-        {
-          GSList *remove_iter = iter;
+          EventsRequest *events_request = (EventsRequest *)iter->data;
+          
+          /* - Call before chunk
+           * - events hooks added
+           */
+          lttv_process_traceset_begin(tsc, events_request->before_chunk_traceset,
+                                         events_request->before_chunk_trace,
+                                         events_request->before_chunk_tracefile,
+                                         events_request->event,
+                                         events_request->event_by_id);
 
           iter = g_slist_next(iter);
-          if(free_data) events_request_free((EventsRequest*)remove_iter->data);
-          list_out = g_slist_remove_link(list_out, remove_iter);
-        } else { // not remove
-          iter = g_slist_next(iter);
         }
       }
-    }
-  }
 
-  /* 3. Find end criterions */
-  {
-    /* 3.1 End time */
-    GSList *iter;
-    
-    /* 3.1.1 Find lowest end time in list_in */
-    g_assert(g_slist_length(list_in)>0);
-    end_time = ((EventsRequest*)g_slist_nth_data(list_in,0))->end_time;
+      {
+        tfc = lttv_traceset_context_get_current_tfc(tsc);
+      
+        /* 2.1 For each req of list_out */
+        GSList *iter = list_out;
     
-    for(iter=g_slist_nth(list_in,1);iter!=NULL;iter=g_slist_next(iter)) {
-      EventsRequest *events_request = (EventsRequest*)iter->data;
+        while(iter != NULL) {
 
-      if(ltt_time_compare(events_request->end_time,
-                          end_time) < 0)
-        end_time = events_request->end_time;
-    }
-     
-    /* 3.1.2 Find lowest start time in list_out */
-    for(iter=list_out;iter!=NULL;iter=g_slist_next(iter)) {
-      EventsRequest *events_request = (EventsRequest*)iter->data;
-
-      if(ltt_time_compare(events_request->start_time,
-                          end_time) < 0)
-        end_time = events_request->start_time;
-    }
-  }
+          gboolean remove = FALSE;
+          gboolean free_data = FALSE;
+          EventsRequest *events_request = (EventsRequest *)iter->data;
+          
+          /* if req.start time == current context time 
+           * or req.start position == current position*/
+          if(  ltt_time_compare(events_request->start_time,
+                              tfc->timestamp) == 0 
+             ||
+               (events_request->start_position != NULL 
+               &&
+               lttv_traceset_context_ctx_pos_compare(tsc,
+                       events_request->start_position) == 0)
+             ) {
+            /* - Add to list_in, remove from list_out */
+            list_in = g_slist_append(list_in, events_request);
+            remove = TRUE;
+            free_data = FALSE;
+
+            /* - If !servicing */
+            if(events_request->servicing == FALSE) {
+              /* - begin request hooks called
+               * - servicing = TRUE
+               */
+              lttv_hooks_call(events_request->before_request, (gpointer)tsc);
+              events_request->servicing = TRUE;
+            }
+            /* call before chunk
+             * events hooks added
+             */
+            lttv_process_traceset_begin(tsc, events_request->before_chunk_traceset,
+                                             events_request->before_chunk_trace,
+                                             events_request->before_chunk_tracefile,
+                                             events_request->event,
+                                             events_request->event_by_id);
+          }
 
-  {
-    /* 3.2 Number of events */
+          /* Go to next */
+          if(remove)
+          {
+            GSList *remove_iter = iter;
 
-    /* 3.2.1 Find lowest number of events in list_in */
-    GSList *iter;
+            iter = g_slist_next(iter);
+            if(free_data) events_request_free((EventsRequest*)remove_iter->data);
+            list_out = g_slist_remove_link(list_out, remove_iter);
+          } else { // not remove
+            iter = g_slist_next(iter);
+          }
+        }
+      }
+    }
 
-    end_nb_events = ((EventsRequest*)g_slist_nth_data(list_in,0))->num_events;
+    /* 3. Find end criterions */
+    {
+      /* 3.1 End time */
+      GSList *iter;
+      
+      /* 3.1.1 Find lowest end time in list_in */
+      g_assert(g_slist_length(list_in)>0);
+      end_time = ((EventsRequest*)g_slist_nth_data(list_in,0))->end_time;
+      
+      for(iter=g_slist_nth(list_in,1);iter!=NULL;iter=g_slist_next(iter)) {
+        EventsRequest *events_request = (EventsRequest*)iter->data;
 
-    for(iter=g_slist_nth(list_in,1);iter!=NULL;iter=g_slist_next(iter)) {
-      EventsRequest *events_request = (EventsRequest*)iter->data;
+        if(ltt_time_compare(events_request->end_time,
+                            end_time) < 0)
+          end_time = events_request->end_time;
+      }
+       
+      /* 3.1.2 Find lowest start time in list_out */
+      for(iter=list_out;iter!=NULL;iter=g_slist_next(iter)) {
+        EventsRequest *events_request = (EventsRequest*)iter->data;
 
-      if(events_request->num_events < end_nb_events)
-        end_nb_events = events_request->num_events;
+        if(ltt_time_compare(events_request->start_time,
+                            end_time) < 0)
+          end_time = events_request->start_time;
+      }
     }
 
-    /* 3.2.2 Use min(CHUNK_NUM_EVENTS, min num events in list_in) as
-     * num_events */
-    
-    end_nb_events = MIN(CHUNK_NUM_EVENTS, end_nb_events);
-  }
+    {
+      /* 3.2 Number of events */
 
-  {
-    /* 3.3 End position */
+      /* 3.2.1 Find lowest number of events in list_in */
+      GSList *iter;
 
-    /* 3.3.1 Find lowest end position in list_in */
-    GSList *iter;
+      end_nb_events = ((EventsRequest*)g_slist_nth_data(list_in,0))->num_events;
 
-    end_position =((EventsRequest*)g_slist_nth_data(list_in,0))->end_position;
+      for(iter=g_slist_nth(list_in,1);iter!=NULL;iter=g_slist_next(iter)) {
+        EventsRequest *events_request = (EventsRequest*)iter->data;
 
-    for(iter=g_slist_nth(list_in,1);iter!=NULL;iter=g_slist_next(iter)) {
-      EventsRequest *events_request = (EventsRequest*)iter->data;
+        if(events_request->num_events < end_nb_events)
+          end_nb_events = events_request->num_events;
+      }
 
-      if(events_request->end_position != NULL && end_position != NULL &&
-          lttv_traceset_context_pos_pos_compare(events_request->end_position,
-                                               end_position) <0)
-        end_position = events_request->end_position;
+      /* 3.2.2 Use min(CHUNK_NUM_EVENTS, min num events in list_in) as
+       * num_events */
+      
+      end_nb_events = MIN(CHUNK_NUM_EVENTS, end_nb_events);
     }
-  }
-  
-  {  
-    /* 3.3.2 Find lowest start position in list_out */
-    GSList *iter;
 
-    for(iter=list_out;iter!=NULL;iter=g_slist_next(iter)) {
-      EventsRequest *events_request = (EventsRequest*)iter->data;
+    {
+      /* 3.3 End position */
 
-      if(events_request->end_position != NULL && end_position != NULL &&
-          lttv_traceset_context_pos_pos_compare(events_request->end_position,
-                                               end_position) <0)
-        end_position = events_request->end_position;
-    }
-  }
+      /* 3.3.1 Find lowest end position in list_in */
+      GSList *iter;
 
-  {
-    /* 4. Call process traceset middle */
-    g_debug("Calling process traceset middle with %p, %lu sec %lu nsec, %lu nb ev, %p end pos", tsc, end_time.tv_sec, end_time.tv_nsec, end_nb_events, end_position);
-    count = lttv_process_traceset_middle(tsc, end_time, end_nb_events, end_position);
-
-    tfc = lttv_traceset_context_get_current_tfc(tsc);
-    if(tfc != NULL)
-      g_debug("Context time after middle : %lu, %lu", tfc->timestamp.tv_sec,
-                                                      tfc->timestamp.tv_nsec);
-    else
-      g_debug("End of trace reached after middle.");
+      end_position =((EventsRequest*)g_slist_nth_data(list_in,0))->end_position;
 
-  }
-  {
-    /* 5. After process traceset middle */
-    tfc = lttv_traceset_context_get_current_tfc(tsc);
-
-    /* - if current context time > traceset.end time */
-    if(tfc == NULL || ltt_time_compare(tfc->timestamp,
-                                       tsc->time_span.end_time) > 0) {
-      /* - For each req in list_in */
-      GSList *iter = list_in;
-  
-      while(iter != NULL) {
+      for(iter=g_slist_nth(list_in,1);iter!=NULL;iter=g_slist_next(iter)) {
+        EventsRequest *events_request = (EventsRequest*)iter->data;
 
-        gboolean remove = FALSE;
-        gboolean free_data = FALSE;
-        EventsRequest *events_request = (EventsRequest *)iter->data;
-        
-        /* - Remove events hooks for req
-         * - Call end chunk for req
-         */
-        lttv_process_traceset_end(tsc, events_request->after_chunk_traceset,
-                                       events_request->after_chunk_trace,
-                                       events_request->after_chunk_tracefile,
-                                       events_request->event,
-                                       events_request->event_by_id);
-        /* - Call end request for req */
-        lttv_hooks_call(events_request->after_request, (gpointer)tsc);
-        
-        /* - remove req from list_in */
-        /* Destroy the request */
-        remove = TRUE;
-        free_data = TRUE;
+        if(events_request->end_position != NULL && end_position != NULL &&
+            lttv_traceset_context_pos_pos_compare(events_request->end_position,
+                                                 end_position) <0)
+          end_position = events_request->end_position;
+      }
+    }
+    
+    {  
+      /* 3.3.2 Find lowest start position in list_out */
+      GSList *iter;
 
-        /* Go to next */
-        if(remove)
-        {
-          GSList *remove_iter = iter;
+      for(iter=list_out;iter!=NULL;iter=g_slist_next(iter)) {
+        EventsRequest *events_request = (EventsRequest*)iter->data;
 
-          iter = g_slist_next(iter);
-          if(free_data) events_request_free((EventsRequest*)remove_iter->data);
-          list_in = g_slist_remove_link(list_in, remove_iter);
-        } else { // not remove
-          iter = g_slist_next(iter);
-        }
+        if(events_request->end_position != NULL && end_position != NULL &&
+            lttv_traceset_context_pos_pos_compare(events_request->end_position,
+                                                 end_position) <0)
+          end_position = events_request->end_position;
       }
     }
+
     {
-      /* 5.1 For each req in list_in */
-      GSList *iter = list_in;
-  
-      while(iter != NULL) {
+      /* 4. Call process traceset middle */
+      g_debug("Calling process traceset middle with %p, %lu sec %lu nsec, %lu nb ev, %p end pos", tsc, end_time.tv_sec, end_time.tv_nsec, end_nb_events, end_position);
+      count = lttv_process_traceset_middle(tsc, end_time, end_nb_events, end_position);
 
-        gboolean remove = FALSE;
-        gboolean free_data = FALSE;
-        EventsRequest *events_request = (EventsRequest *)iter->data;
-        
-        /* - Remove events hooks for req
-         * - Call end chunk for req
-         */
-        lttv_process_traceset_end(tsc, events_request->after_chunk_traceset,
-                                       events_request->after_chunk_trace,
-                                       events_request->after_chunk_tracefile,
-                                       events_request->event,
-                                       events_request->event_by_id);
-
-        /* - req.num -= count */
-        g_assert(events_request->num_events >= count);
-        events_request->num_events -= count;
-        
-        g_assert(tfc != NULL);
-        /* - if req.num == 0
-         *   or
-         *     current context time >= req.end time
-         *   or
-         *     req.end pos == current pos
-         *   or
-         *     req.stop_flag == TRUE
-         */
-        if(   events_request->num_events == 0
-            ||
-              events_request->stop_flag == TRUE
-            ||
-              ltt_time_compare(tfc->timestamp,
-                                       events_request->end_time) >= 0
-            ||
-                (events_request->end_position != NULL 
-               &&
-                lttv_traceset_context_ctx_pos_compare(tsc,
-                          events_request->end_position) == 0)
+      tfc = lttv_traceset_context_get_current_tfc(tsc);
+      if(tfc != NULL)
+        g_debug("Context time after middle : %lu, %lu", tfc->timestamp.tv_sec,
+                                                        tfc->timestamp.tv_nsec);
+      else
+        g_debug("End of trace reached after middle.");
 
-            ) {
-          g_assert(events_request->servicing == TRUE);
-          /* - Call end request for req
-           * - remove req from list_in */
+    }
+    {
+      /* 5. After process traceset middle */
+      tfc = lttv_traceset_context_get_current_tfc(tsc);
+
+      /* - if current context time > traceset.end time */
+      if(tfc == NULL || ltt_time_compare(tfc->timestamp,
+                                         tsc->time_span.end_time) > 0) {
+        /* - For each req in list_in */
+        GSList *iter = list_in;
+    
+        while(iter != NULL) {
+
+          gboolean remove = FALSE;
+          gboolean free_data = FALSE;
+          EventsRequest *events_request = (EventsRequest *)iter->data;
+          
+          /* - Remove events hooks for req
+           * - Call end chunk for req
+           */
+          lttv_process_traceset_end(tsc, events_request->after_chunk_traceset,
+                                         events_request->after_chunk_trace,
+                                         events_request->after_chunk_tracefile,
+                                         events_request->event,
+                                         events_request->event_by_id);
+          /* - Call end request for req */
           lttv_hooks_call(events_request->after_request, (gpointer)tsc);
+          
           /* - remove req from list_in */
           /* Destroy the request */
           remove = TRUE;
           free_data = TRUE;
+
+          /* Go to next */
+          if(remove)
+          {
+            GSList *remove_iter = iter;
+
+            iter = g_slist_next(iter);
+            if(free_data) events_request_free((EventsRequest*)remove_iter->data);
+            list_in = g_slist_remove_link(list_in, remove_iter);
+          } else { // not remove
+            iter = g_slist_next(iter);
+          }
         }
-        
-        /* Go to next */
-        if(remove)
-        {
-          GSList *remove_iter = iter;
+      }
+      {
+        /* 5.1 For each req in list_in */
+        GSList *iter = list_in;
+    
+        while(iter != NULL) {
 
-          iter = g_slist_next(iter);
-          if(free_data) events_request_free((EventsRequest*)remove_iter->data);
-          list_in = g_slist_remove_link(list_in, remove_iter);
-        } else { // not remove
-          iter = g_slist_next(iter);
+          gboolean remove = FALSE;
+          gboolean free_data = FALSE;
+          EventsRequest *events_request = (EventsRequest *)iter->data;
+          
+          /* - Remove events hooks for req
+           * - Call end chunk for req
+           */
+          lttv_process_traceset_end(tsc, events_request->after_chunk_traceset,
+                                         events_request->after_chunk_trace,
+                                         events_request->after_chunk_tracefile,
+                                         events_request->event,
+                                         events_request->event_by_id);
+
+          /* - req.num -= count */
+          g_assert(events_request->num_events >= count);
+          events_request->num_events -= count;
+          
+          g_assert(tfc != NULL);
+          /* - if req.num == 0
+           *   or
+           *     current context time >= req.end time
+           *   or
+           *     req.end pos == current pos
+           *   or
+           *     req.stop_flag == TRUE
+           */
+          if(   events_request->num_events == 0
+              ||
+                events_request->stop_flag == TRUE
+              ||
+                ltt_time_compare(tfc->timestamp,
+                                         events_request->end_time) >= 0
+              ||
+                  (events_request->end_position != NULL 
+                 &&
+                  lttv_traceset_context_ctx_pos_compare(tsc,
+                            events_request->end_position) == 0)
+
+              ) {
+            g_assert(events_request->servicing == TRUE);
+            /* - Call end request for req
+             * - remove req from list_in */
+            lttv_hooks_call(events_request->after_request, (gpointer)tsc);
+            /* - remove req from list_in */
+            /* Destroy the request */
+            remove = TRUE;
+            free_data = TRUE;
+          }
+          
+          /* Go to next */
+          if(remove)
+          {
+            GSList *remove_iter = iter;
+
+            iter = g_slist_next(iter);
+            if(free_data) events_request_free((EventsRequest*)remove_iter->data);
+            list_in = g_slist_remove_link(list_in, remove_iter);
+          } else { // not remove
+            iter = g_slist_next(iter);
+          }
         }
       }
     }
   }
-
   /* End of removed servicing loop : leave control to GTK instead. */
   //  if(gtk_events_pending()) break;
   //}
@@ -1427,36 +1449,7 @@ static void lttvwindow_add_trace(Tab *tab, LttvTrace *trace_v)
                                       traceset_context),
             traceset); 
 
-  /* Set the tab's time window and current time if
-   * out of bounds */
-  TimeInterval time_span = 
-    LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context)->time_span;
-  if(ltt_time_compare(tab->time_window.start_time, time_span.start_time) < 0
-     || ltt_time_compare(  ltt_time_add(tab->time_window.start_time,
-                                        tab->time_window.time_width),
-                           time_span.end_time) > 0) {
-    tab->time_window.start_time = 
-        LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context)->
-                               time_span.start_time;
-    tab->current_time = 
-       LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context)->
-                             time_span.start_time;
-    
-    LttTime tmp_time;
 
-    if(DEFAULT_TIME_WIDTH_S <
-            LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context)->
-                           time_span.end_time.tv_sec)
-      tmp_time.tv_sec = DEFAULT_TIME_WIDTH_S;
-    else
-      tmp_time.tv_sec =
-              LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context)->
-                           time_span.end_time.tv_sec;
-    tmp_time.tv_nsec = 0;
-    tab->time_window.time_width = tmp_time ;
-    
-  }
   //add state update hooks
   lttv_state_add_event_hooks(
   (LttvTracesetState*)tab->traceset_info->traceset_context);
@@ -1641,17 +1634,18 @@ void remove_trace(GtkWidget *widget, gpointer user_data)
 
     trace_v = lttv_traceset_get(traceset, index);
 
-    if(lttv_trace_get_ref_number(trace_v) <= 2) {
-      /* ref 2 : traceset, local */
-      lttvwindowtraces_remove_trace(trace_v);
-      ltt_trace_close(lttv_trace(trace_v));
-    }
-    
     lttv_traceset_remove(traceset, index);
     lttv_trace_unref(trace_v);  // Remove local reference
 
-    if(!lttv_trace_get_ref_number(trace_v))
-       lttv_trace_destroy(trace_v);
+    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.
+       */
+      lttvwindowtraces_remove_trace(trace_v);
+    }
     
     tab->traceset_info->traceset_context =
       g_object_new(LTTV_TRACESET_STATS_TYPE, NULL);
@@ -1995,15 +1989,15 @@ void zoom(GtkWidget * widget, double size)
   //
   //
 
+ LttTime rel_time =
+       ltt_time_sub(new_time_window.start_time, time_span.start_time); 
  if(   ltt_time_to_double(new_time_window.time_width)
                              * NANOSECONDS_PER_SECOND
                              / SCROLL_STEP_PER_PAGE/* step increment */
        +
-       ltt_time_to_double(new_time_window.start_time)
-                             * NANOSECONDS_PER_SECOND /* page size */
+       ltt_time_to_double(rel_time) * NANOSECONDS_PER_SECOND /* page size */
                     == 
-       ltt_time_to_double(new_time_window.start_time)
-                             * NANOSECONDS_PER_SECOND /* page size */
+       ltt_time_to_double(rel_time) * NANOSECONDS_PER_SECOND /* page size */
        ) {
     g_warning("Can not zoom that far due to scrollbar precision");
  } else if(
@@ -2023,10 +2017,10 @@ void zoom(GtkWidget * widget, double size)
                  //ltt_time_to_double(new_time_window.start_time) 
                  //  * NANOSECONDS_PER_SECOND, /* value */
                  "lower",
-                 ltt_time_to_double(time_span.start_time) 
-                   * NANOSECONDS_PER_SECOND, /* lower */
+                   0.0, /* lower */
                  "upper",
-                 ltt_time_to_double(time_span.end_time) 
+                 ltt_time_to_double(
+                   ltt_time_sub(time_span.end_time, time_span.start_time))
                    * NANOSECONDS_PER_SECOND, /* upper */
                  "step_increment",
                  ltt_time_to_double(new_time_window.time_width)
@@ -2044,7 +2038,8 @@ void zoom(GtkWidget * widget, double size)
     //gtk_adjustment_value_changed(adjustment);
     g_object_set(G_OBJECT(adjustment),
                  "value",
-                 ltt_time_to_double(new_time_window.start_time) 
+                 ltt_time_to_double(
+                   ltt_time_sub(new_time_window.start_time, time_span.start_time))
                    * NANOSECONDS_PER_SECOND, /* value */
                  NULL);
     gtk_adjustment_value_changed(adjustment);
@@ -2862,11 +2857,90 @@ on_content_activate                    (GtkMenuItem     *menuitem,
 }
 
 
+static void 
+on_about_close_activate                (GtkButton       *button,
+                                        gpointer         user_data)
+{
+  GtkWidget *about_widget = GTK_WIDGET(user_data);
+
+  gtk_widget_destroy(about_widget);
+}
+
 void
 on_about_activate                      (GtkMenuItem     *menuitem,
                                         gpointer         user_data)
 {
-  g_printf("About...\n");
+  MainWindow *main_window = get_window_data_struct(GTK_WIDGET(menuitem));
+  GtkWidget *window_widget = main_window->mwindow;
+  GtkWidget *about_widget = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+  GtkWindow *about_window = GTK_WINDOW(about_widget);
+  gint window_width, window_height;
+  
+  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_destroy_with_parent(about_window, TRUE);
+  gtk_window_set_modal(about_window, FALSE);
+
+  /* Put the about window at the center of the screen */
+  gtk_window_get_size(about_window, &window_width, &window_height);
+  gtk_window_move (about_window,
+                   (gdk_screen_width() - window_width)/2,
+                   (gdk_screen_height() - window_height)/2);
+  GtkWidget *vbox = gtk_vbox_new(FALSE, 1);
+
+  gtk_container_add(GTK_CONTAINER(about_widget), vbox);
+
+    
+  /* Text to show */
+  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>");
+  gtk_label_set_justify(GTK_LABEL(label1), GTK_JUSTIFY_CENTER);
+  
+  GtkWidget *label2 = gtk_label_new("");
+  gtk_misc_set_padding(GTK_MISC(label2), 10, 20);
+  gtk_label_set_markup(GTK_LABEL(label2), "\
+Project author: Karim Yaghmour\n\
+\n\
+Contributors :\n\
+\n\
+Michel Dagenais (New trace format, lttv main)\n\
+Mathieu Desnoyers (Directory structure, build with automake/conf,\n\
+                   lttv gui, control flow view, gui green threads\n\
+                   with interruptible foreground and background computation,\n\
+                   detailed event list)\n\
+Benoit Des Ligneris (Cluster adaptation)\n\
+Xang-Xiu Yang (new trace reading library and converter, lttv gui, \n\
+               detailed event list and statistics view)\n\
+Tom Zanussi (RelayFS)");
+
+  GtkWidget *label3 = gtk_label_new("");
+  gtk_label_set_markup(GTK_LABEL(label3), "\
+Linux Trace Toolkit, Copyright (C) 2004  Karim Yaghmour\n\
+Linux Trace Toolkit comes with ABSOLUTELY NO WARRANTY.\n\
+This is free software, and you are welcome to redistribute it\n\
+under certain conditions. See COPYING for details.");
+  gtk_misc_set_padding(GTK_MISC(label3), 10, 20);
+
+  gtk_box_pack_start_defaults(GTK_BOX(vbox), label1);
+  gtk_box_pack_start_defaults(GTK_BOX(vbox), label2);
+  gtk_box_pack_start_defaults(GTK_BOX(vbox), label3);
+
+  GtkWidget *hbox = gtk_hbox_new(TRUE, 0);
+  gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
+  GtkWidget *close_button = gtk_button_new_with_mnemonic("_Close");
+  gtk_box_pack_end(GTK_BOX(hbox), close_button, FALSE, FALSE, 0);
+  gtk_container_set_border_width(GTK_CONTAINER(close_button), 20);
+
+  g_signal_connect(G_OBJECT(close_button), "clicked",
+      G_CALLBACK(on_about_close_activate),
+      (gpointer)about_widget);
+  
+  gtk_widget_show_all(about_widget);
 }
 
 
@@ -3089,17 +3163,16 @@ void scroll_value_changed_cb(GtkWidget *scrollbar,
 {
   Tab *tab = (Tab *)user_data;
   TimeWindow time_window;
-  TimeInterval *time_span;
   LttTime time;
   GtkAdjustment *adjust = gtk_range_get_adjustment(GTK_RANGE(scrollbar));
   gdouble value = gtk_adjustment_get_value(adjust);
   gdouble upper, lower, ratio, page_size;
   LttvTracesetContext * tsc = 
     LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context);
+  TimeInterval time_span = tsc->time_span;
 
   //time_window = tab->time_window;
 
-  time_span = &tsc->time_span ;
   lower = adjust->lower;
   upper = adjust->upper;
   ratio = (value - lower) / (upper - lower);
@@ -3108,7 +3181,8 @@ void scroll_value_changed_cb(GtkWidget *scrollbar,
   //time = ltt_time_sub(time_span->end_time, time_span->start_time);
   //time = ltt_time_mul(time, (float)ratio);
   //time = ltt_time_add(time_span->start_time, time);
-  time = ltt_time_from_double(value/NANOSECONDS_PER_SECOND);
+  time = ltt_time_add(ltt_time_from_double(value/NANOSECONDS_PER_SECOND),
+                      time_span.start_time);
 
   time_window.start_time = time;
   
@@ -3116,7 +3190,7 @@ void scroll_value_changed_cb(GtkWidget *scrollbar,
 
   time_window.time_width = 
     ltt_time_from_double(page_size/NANOSECONDS_PER_SECOND);
-  //time = ltt_time_sub(time_span->end_time, time);
+  //time = ltt_time_sub(time_span.end_time, time);
   //if(ltt_time_compare(time,time_window.time_width) < 0){
   //  time_window.time_width = time;
   //}
This page took 0.035313 seconds and 4 git commands to generate.