mega modif by Mathieu Desnoyers. Independant main windows, multiple tracesets, contro...
[lttv.git] / ltt / branches / poly / lttv / modules / gui / mainWin / src / gtkcustom.c
index b0fb2ec3d31983ab26717663e3e04d9ff6101832..491e730c5c781fe9f777ebe5155c031824123b22 100644 (file)
@@ -1,7 +1,8 @@
 #include <gtk/gtk.h>
 
-#include "gtkcustom.h"
+#include <lttv/gtkcustom.h>
 //#include "gtkintl.h"
+#include <lttv/gtkTraceSet.h>
 
 static void gtk_custom_class_init (GtkCustomClass    *klass);
 static void gtk_custom_init       (GtkCustom         *custom);
@@ -12,6 +13,8 @@ static void     gtk_custom_size_request   (GtkWidget      *widget,
 static void     gtk_custom_size_allocate  (GtkWidget      *widget,
                                           GtkAllocation  *allocation);
 
+void gtk_custom_scroll_value_changed (GtkRange *range, gpointer custom);
+
 GType
 gtk_custom_get_type (void)
 {
@@ -102,7 +105,11 @@ void gtk_custom_widget_add(GtkCustom * custom, GtkWidget * widget1)
 {
   GtkPaned * tmpPane; 
   GtkWidget * w;
-
+  TimeWindow Time_Window;
+  LttTime      time;
+  double       tmpValue;
+  TimeInterval *Time_Span;
+  
   g_return_if_fail(GTK_IS_CUSTOM(custom));
   g_object_ref(G_OBJECT(widget1));
  
@@ -113,7 +120,42 @@ void gtk_custom_widget_add(GtkCustom * custom, GtkWidget * widget1)
 
     custom->hScrollbar = gtk_hscrollbar_new (NULL);
     gtk_widget_show(custom->hScrollbar);
-    
+
+    custom->hAdjust = gtk_range_get_adjustment(GTK_RANGE(custom->hScrollbar));
+    GetTimeWindow(custom->mw,&Time_Window);
+    GetCurrentTime(custom->mw,&time);
+    Time_Span = LTTV_TRACESET_CONTEXT(custom->mw->Traceset_Info->TracesetContext)->Time_Span ;
+
+    tmpValue               = Time_Span->startTime.tv_sec;
+    tmpValue              *= NANSECOND_CONST;
+    tmpValue              += Time_Span->startTime.tv_nsec;
+    custom->hAdjust->lower = tmpValue;
+    custom->hAdjust->value = tmpValue;
+    tmpValue               = Time_Span->endTime.tv_sec;
+    tmpValue              *= NANSECOND_CONST;
+    tmpValue              += Time_Span->endTime.tv_nsec;
+    custom->hAdjust->upper = tmpValue;
+    //tmpValue               = time.tv_sec;
+    //tmpValue              *= NANSECOND_CONST;
+    //tmpValue              += time.tv_nsec;
+    //custom->hAdjust->value = tmpValue;
+    /* Step increment to 1/10 of visible area */
+    tmpValue               = Time_Window.Time_Width.tv_sec;
+    tmpValue              *= NANSECOND_CONST;
+    tmpValue              += Time_Window.Time_Width.tv_nsec;
+    custom->hAdjust->step_increment = tmpValue / 10;
+    /* Page increment of whole visible area */
+    custom->hAdjust->page_increment = tmpValue;
+    /* page_size to the whole visible area will take care that the
+     * scroll value + the shown area will never be more than what is
+     * in the trace. */
+    custom->hAdjust->page_size = tmpValue;
+
+    gtk_range_set_update_policy (GTK_RANGE(custom->hScrollbar),
+                                  GTK_UPDATE_DISCONTINUOUS);
+    g_signal_connect(G_OBJECT(custom->hScrollbar), "value-changed",
+                    G_CALLBACK(gtk_custom_scroll_value_changed), custom);
+
     custom->vbox = gtk_vbox_new(FALSE,0);
     gtk_widget_show(custom->vbox);
     
@@ -273,6 +315,17 @@ void gtk_custom_widget_move_down(GtkCustom * custom)
   g_object_unref(G_OBJECT(custom->focusedPane));
 }
 
+void gtk_custom_scroll_value_changed(GtkRange *range, gpointer custom_arg)
+{
+  LttTime time;
+  GtkCustom * custom = (GtkCustom*)custom_arg;
+  gdouble value = gtk_range_get_value(range);
+  time.tv_sec  = value / NANSECOND_CONST;
+  time.tv_nsec = (value / NANSECOND_CONST - time.tv_sec) * NANSECOND_CONST; 
+  SetCurrentTime(custom->mw, &time);
+  g_warning("The current time is second :%d, nanosecond : %d\n", time.tv_sec, time.tv_nsec);
+}
+
 
 static void
 gtk_custom_size_request (GtkWidget      *widget,
This page took 0.02949 seconds and 4 git commands to generate.