fixes to control flow view GC
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 15 Sep 2005 23:20:39 +0000 (23:20 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 15 Sep 2005 23:20:39 +0000 (23:20 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@1202 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/lttv/modules/gui/controlflow/cfv.c
ltt/branches/poly/lttv/modules/gui/controlflow/cfv.h
ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c
ltt/branches/poly/lttv/modules/gui/controlflow/drawing.h
ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c
ltt/branches/poly/lttv/modules/gui/controlflow/processlist.c
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/init_module.c
ltt/branches/poly/lttv/modules/gui/tracecontrol/tracecontrol.c

index a96336ff6a48ac5805bf0c5cb7843e965a5406d3..47ad080bfb46f9cc91ce2ccc92ddaebe3ae9bf3d 100644 (file)
@@ -60,12 +60,14 @@ header_size_allocate(GtkWidget *widget,
  * @return The widget created.
  */
 ControlFlowData *
-guicontrolflow(void)
+guicontrolflow(Tab *tab)
 {
   GtkWidget *process_list_widget, *drawing_widget, *drawing_area;
 
   ControlFlowData* control_flow_data = g_new(ControlFlowData,1) ;
 
+  control_flow_data->tab = tab;
+
   control_flow_data->v_adjust = 
     GTK_ADJUSTMENT(gtk_adjustment_new(  0.0,  /* Value */
               0.0,  /* Lower */
index 3e469bab9514dca82d3eb6980f30426a363341c8..31c42fdf79de148d91428d5a058f252d93af3e08 100644 (file)
@@ -63,7 +63,7 @@ struct _ControlFlowData {
 } ;
 
 /* Control Flow Data constructor */
-ControlFlowData *guicontrolflow(void);
+ControlFlowData *guicontrolflow(Tab *tab);
 void
 guicontrolflow_destructor_full(ControlFlowData *control_flow_data);
 void
index 842313a5d252e0646576b7b0eaa8b90758813b19..94f810899a61c0c34b987b8efa0925df6455f004 100644 (file)
@@ -122,6 +122,7 @@ void drawing_data_request(Drawing_t *drawing,
   if(width < 0) return ;
   if(height < 0) return ;
 
+
   Tab *tab = drawing->control_flow_data->tab;
   TimeWindow time_window =
               lttvwindow_get_time_window(tab);
@@ -627,6 +628,7 @@ configure_event( GtkWidget *widget, GdkEventConfigure *event,
       drawing->alloc_height = drawing->height + EXTRA_ALLOC;
       update_pixmap_size(drawing->control_flow_data->process_list,
                          drawing->alloc_width);
+      update_index_to_pixmap(drawing->control_flow_data->process_list);
     }
     //drawing->height = widget->allocation.height;
 
@@ -693,11 +695,12 @@ expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer user_data )
       (ControlFlowData*)g_object_get_data(
                 G_OBJECT(widget),
                 "control_flow_data");
+#if 0
   if(unlikely(drawing->gc == NULL)) {
     drawing->gc = gdk_gc_new(drawing->drawing_area->window);
     gdk_gc_copy(drawing->gc, drawing->drawing_area->style->black_gc);
   }
-
+#endif //0
   TimeWindow time_window = 
       lttvwindow_get_time_window(control_flow_data->tab);
   LttTime current_time = 
@@ -717,11 +720,18 @@ expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer user_data )
       event->area.width, event->area.height);
 #endif //0
   drawing->height = processlist_get_height(control_flow_data->process_list);
+#if 0
   copy_pixmap_to_screen(control_flow_data->process_list,
                         widget->window,
                         widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
                         event->area.x, event->area.y,
                         event->area.width, event->area.height);
+#endif //0
+  copy_pixmap_to_screen(control_flow_data->process_list,
+                        widget->window,
+                        drawing->gc,
+                        event->area.x, event->area.y,
+                        event->area.width, event->area.height);
                         
   
   /* Erase the dotted lines left.. */
@@ -744,7 +754,7 @@ expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer user_data )
           drawing->width,
           &cursor_x);
 
-
+#if 0
     if(drawing->dotted_gc == NULL) {
 
       drawing->dotted_gc = gdk_gc_new(drawing->drawing_area->window);
@@ -761,6 +771,7 @@ expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer user_data )
                         dash_list,
                         2);
     }
+#endif //0
     gint height_tot = MAX(widget->allocation.height, drawing->height);
     gdk_draw_line(widget->window,
                   drawing->dotted_gc,
@@ -907,8 +918,6 @@ Drawing_t *drawing_construct(ControlFlowData *control_flow_data)
   drawing->pango_layout =
     gtk_widget_create_pango_layout(drawing->drawing_area, NULL);
 
-  drawing->dotted_gc = NULL;
-
   drawing->height = 1;
   drawing->width = 1;
   drawing->depth = 0;
@@ -1011,6 +1020,50 @@ Drawing_t *drawing_construct(ControlFlowData *control_flow_data)
   gdk_colormap_alloc_colors(colormap, drawing_colors, NUM_COLORS, FALSE,
                             TRUE, success);
   
+  drawing->gc =
+    gdk_gc_new(GDK_DRAWABLE(main_window_get_widget(control_flow_data->tab)->window));
+  drawing->dotted_gc =
+    gdk_gc_new(GDK_DRAWABLE(main_window_get_widget(control_flow_data->tab)->window));
+
+  gdk_gc_copy(drawing->gc,
+      main_window_get_widget(control_flow_data->tab)->style->black_gc);
+  gdk_gc_copy(drawing->dotted_gc,
+      main_window_get_widget(control_flow_data->tab)->style->white_gc);
+  
+  gint8 dash_list[] = { 1, 2 };
+  gdk_gc_set_line_attributes(drawing->dotted_gc,
+                             1,
+                             GDK_LINE_ON_OFF_DASH,
+                             GDK_CAP_BUTT,
+                             GDK_JOIN_MITER);
+  gdk_gc_set_dashes(drawing->dotted_gc,
+                    0,
+                    dash_list,
+                    2);
+
+  drawing->ruler_gc_butt = 
+    gdk_gc_new(GDK_DRAWABLE(main_window_get_widget(control_flow_data->tab)->window));
+  gdk_gc_copy(drawing->ruler_gc_butt, 
+      main_window_get_widget(control_flow_data->tab)->style->black_gc);
+  drawing->ruler_gc_round = 
+    gdk_gc_new(GDK_DRAWABLE(main_window_get_widget(control_flow_data->tab)->window));
+  gdk_gc_copy(drawing->ruler_gc_round, 
+      main_window_get_widget(control_flow_data->tab)->style->black_gc);
+
+
+  gdk_gc_set_line_attributes(drawing->ruler_gc_butt,
+                               2,
+                               GDK_LINE_SOLID,
+                               GDK_CAP_BUTT,
+                               GDK_JOIN_MITER);
+
+  gdk_gc_set_line_attributes(drawing->ruler_gc_round,
+                             2,
+                             GDK_LINE_SOLID,
+                             GDK_CAP_ROUND,
+                             GDK_JOIN_ROUND);
+
+  
   return drawing;
 }
 
@@ -1032,6 +1085,9 @@ void drawing_destroy(Drawing_t *drawing)
   
   g_free(drawing->pango_layout);
   if(drawing->dotted_gc != NULL) gdk_gc_unref(drawing->dotted_gc);
+  if(drawing->ruler_gc_butt != NULL) gdk_gc_unref(drawing->ruler_gc_butt);
+  if(drawing->ruler_gc_round != NULL) gdk_gc_unref(drawing->ruler_gc_round);
+
   g_free(drawing);
   g_info("drawing_destroy end");
 }
@@ -1274,15 +1330,8 @@ expose_ruler( GtkWidget *widget, GdkEventExpose *event, gpointer user_data )
           event->area.width,
           event->area.height);
 
-   GdkGC *gc = gdk_gc_new(drawing->ruler->window);
-   gdk_gc_copy(gc, drawing->ruler->style->black_gc);
-   gdk_gc_set_line_attributes(gc,
-                               2,
-                               GDK_LINE_SOLID,
-                               GDK_CAP_BUTT,
-                               GDK_JOIN_MITER);
   gdk_draw_line (drawing->ruler->window,
-                  gc,
+                  drawing->ruler_gc_butt,
                   event->area.x, 1,
                   event->area.x + event->area.width, 1);
 
@@ -1304,19 +1353,13 @@ expose_ruler( GtkWidget *widget, GdkEventExpose *event, gpointer user_data )
   global_width += ink_rect.width;
 
   gdk_draw_layout_with_colors(drawing->ruler->window,
-      gc,
+      drawing->ruler_gc_butt,
       0,
       6,
       layout, &foreground, &background);
 
-  gdk_gc_set_line_attributes(gc,
-                             2,
-                             GDK_LINE_SOLID,
-                             GDK_CAP_ROUND,
-                             GDK_JOIN_ROUND);
-
   gdk_draw_line (drawing->ruler->window,
-                   gc,
+                   drawing->ruler_gc_round,
                    1, 1,
                    1, 7);
 
@@ -1331,19 +1374,13 @@ expose_ruler( GtkWidget *widget, GdkEventExpose *event, gpointer user_data )
   if(global_width <= drawing->ruler->allocation.width)
   {
     gdk_draw_layout_with_colors(drawing->ruler->window,
-      gc,
+      drawing->ruler_gc_butt,
       drawing->ruler->allocation.width - ink_rect.width,
       6,
       layout, &foreground, &background);
 
-    gdk_gc_set_line_attributes(gc,
-                               2,
-                               GDK_LINE_SOLID,
-                               GDK_CAP_ROUND,
-                               GDK_JOIN_ROUND);
-
     gdk_draw_line (drawing->ruler->window,
-                   gc,
+                   drawing->ruler_gc_butt,
                    drawing->ruler->allocation.width-1, 1,
                    drawing->ruler->allocation.width-1, 7);
   }
@@ -1359,19 +1396,13 @@ expose_ruler( GtkWidget *widget, GdkEventExpose *event, gpointer user_data )
   if(global_width <= drawing->ruler->allocation.width)
   {
     gdk_draw_layout_with_colors(drawing->ruler->window,
-      gc,
+      drawing->ruler_gc_butt,
       (drawing->ruler->allocation.width - ink_rect.width)/2,
       6,
       layout, &foreground, &background);
 
-    gdk_gc_set_line_attributes(gc,
-                               2,
-                               GDK_LINE_SOLID,
-                               GDK_CAP_ROUND,
-                               GDK_JOIN_ROUND);
-
     gdk_draw_line (drawing->ruler->window,
-                   gc,
+                   drawing->ruler_gc_butt,
                    drawing->ruler->allocation.width/2, 1,
                    drawing->ruler->allocation.width/2, 7);
 
@@ -1380,7 +1411,6 @@ expose_ruler( GtkWidget *widget, GdkEventExpose *event, gpointer user_data )
 
   }
 
-  gdk_gc_unref(gc);
   g_object_unref(layout);
    
   return FALSE;
index 3cf84ab838ff4e8a92958849a8c3d8d751202fc4..9f2b936003bc5584d1de53073da3934e00849760 100644 (file)
@@ -109,6 +109,8 @@ struct _Drawing_t {
   LttTime   last_start;               
   GdkGC     *dotted_gc;
   GdkGC     *gc;
+  GdkGC     *ruler_gc_butt;
+  GdkGC     *ruler_gc_round;
 
   /* Position of the horizontal selector, -1 for none */
   gint horizontal_sel;
index 72986339f98a96f981eeb0ac2df1eab2af398548..e2a42d4fea5a5fa6c4a718c5b17387f448572d9c 100644 (file)
@@ -182,7 +182,7 @@ GtkWidget *
 h_guicontrolflow(Tab *tab)
 {
   g_info("h_guicontrolflow, %p", tab);
-  ControlFlowData *control_flow_data = guicontrolflow() ;
+  ControlFlowData *control_flow_data = guicontrolflow(tab) ;
   
   control_flow_data->tab = tab;
   
@@ -1926,6 +1926,12 @@ gint traceset_notify(void *hook_data, void *call_data)
   ControlFlowData *control_flow_data = (ControlFlowData*) hook_data;
   Drawing_t *drawing = control_flow_data->drawing;
 
+  if(unlikely(drawing->gc == NULL)) {
+    return FALSE;
+  }
+  if(drawing->dotted_gc == NULL) {
+    return FALSE;
+  }
 
   drawing_clear(control_flow_data->drawing);
   processlist_clear(control_flow_data->process_list);
index 103063ab8fdd00187b18975695d0d869d3edb72c..ce4c0926045103bacdbe842ed13232a731ab5536 100644 (file)
@@ -287,7 +287,8 @@ void copy_pixmap_to_screen(ProcessList *process_list,
     g_assert(i<process_list->index_to_pixmap->len);
     /* Render the pixmap to the screen */
     GdkPixmap *pixmap = 
-      (GdkPixmap*)g_ptr_array_index(process_list->index_to_pixmap, i);
+      //(GdkPixmap*)g_ptr_array_index(process_list->index_to_pixmap, i);
+      GDK_PIXMAP(g_ptr_array_index(process_list->index_to_pixmap, i));
 
     gdk_draw_drawable (dest,
         gc,
index 8571eb25d03076414f69a34b8b380b89d0ab8278..df02b66d072d8cfc2fc3ee629999389b46f28a97 100644 (file)
@@ -4025,57 +4025,48 @@ MainWindow *construct_main_window(MainWindow * parent)
     new_tab = create_tab(new_m_window, parent_tab, notebook, "Traceset");
   } 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);
+  }
 
+  /* 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);
     }
   }
 
index 21a30eedaaa354dbef12304f8772a6255fc39638..1ca5cf04cf154c8500202480f548bba5c6fd0d22 100644 (file)
@@ -82,27 +82,17 @@ LttvHooks
   *main_hooks;
 
 /* Initial trace from command line */
-LttvTrace *g_init_trace = NULL;
+//LttvTrace *g_init_trace = NULL;
 
 static char *a_trace;
+static char g_init_trace[PATH_MAX] = "";
 
 
 void lttv_trace_option(void *hook_data)
 { 
   LttTrace *trace;
-  gchar abs_path[PATH_MAX];
-
-  get_absolute_pathname(a_trace, abs_path);
-  g_init_trace = lttvwindowtraces_get_trace_by_name(abs_path);
-  if(g_init_trace == NULL) {
-    trace = ltt_trace_open(abs_path);
-    if(trace == NULL) {
-      g_warning("cannot open trace %s", abs_path);
-    } else {
-      g_init_trace = lttv_trace_new(trace);
-      lttvwindowtraces_add_trace(g_init_trace);
-    }
-  }
+
+  get_absolute_pathname(a_trace, g_init_trace);
 }
 
 /*****************************************************************************
@@ -130,7 +120,12 @@ static gboolean window_creation_hook(void *hook_data, void *call_data)
   add_pixmap_directory ("pixmaps");
   add_pixmap_directory ("../modules/gui/main/pixmaps");
 
-  construct_main_window(NULL);
+  /* First window, use command line trace */
+  if(strcmp(g_init_trace, "") != 0){
+    create_main_window_with_trace(g_init_trace);
+  } else {
+    construct_main_window(NULL);
+  }
 
   gtk_main ();
 
index da4df4fb8b1951644f3977a0b78d0ca23b312d62..1193046d1feafbb17a58f72b741a0c42d8db3eef 100644 (file)
@@ -45,6 +45,7 @@
 #include <utmp.h>
 #include <sys/wait.h>
 #include <sys/poll.h>
+#include <errno.h>
 
 #define MAX_ARGS_LEN PATH_MAX * 10
 
@@ -536,13 +537,18 @@ wait_child:
     g_info("Waiting for child exit...");
     
     ret = waitpid(pid, &status, 0);
-
-    if(WIFEXITED(status))
-      if(WEXITSTATUS(status) != 0) {
-        retval = WEXITSTATUS(status);
-        g_warning("An error occured in the su command : %s",
-            strerror(retval));
-      }
+    
+    if(ret == -1) {
+      g_warning("An error occured in wait : %s",
+          strerror(errno));
+    } else {
+      if(WIFEXITED(status))
+        if(WEXITSTATUS(status) != 0) {
+          retval = WEXITSTATUS(status);
+          g_warning("An error occured in the su command : %s",
+              strerror(retval));
+        }
+    }
 
     g_info("Child exited.");
 
This page took 0.031476 seconds and 4 git commands to generate.