fix 2.6 dependency
[lttv.git] / ltt / branches / poly / lttv / modules / gui / tracecontrol / tracecontrol.c
index da4df4fb8b1951644f3977a0b78d0ca23b312d62..a44fa27bcd85c2224a04240dd1700f07f4e73294 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
 
@@ -180,7 +181,8 @@ gui_control(Tab *tab)
   pixbuf = gdk_pixbuf_new_from_xpm_data((const char **)TraceControlStart_xpm);
   image = gtk_image_new_from_pixbuf(pixbuf);
   tcd->start_button = gtk_button_new_with_label("start");
-  gtk_button_set_image(GTK_BUTTON(tcd->start_button), image);
+  //2.6 gtk_button_set_image(GTK_BUTTON(tcd->start_button), image);
+  g_object_set(G_OBJECT(tcd->start_button), "image", image, NULL);
   gtk_button_set_alignment(GTK_BUTTON(tcd->start_button), 0.0, 0.0);
   gtk_widget_show (tcd->start_button);
   gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->start_button,6,7,0,1,GTK_FILL,GTK_FILL,2,2);
@@ -188,7 +190,8 @@ gui_control(Tab *tab)
   pixbuf = gdk_pixbuf_new_from_xpm_data((const char **)TraceControlPause_xpm);
   image = gtk_image_new_from_pixbuf(pixbuf);
   tcd->pause_button = gtk_button_new_with_label("pause");
-  gtk_button_set_image(GTK_BUTTON(tcd->pause_button), image);
+  //2.6 gtk_button_set_image(GTK_BUTTON(tcd->pause_button), image);
+  g_object_set(G_OBJECT(tcd->pause_button), "image", image, NULL);
   gtk_button_set_alignment(GTK_BUTTON(tcd->pause_button), 0.0, 0.0);
   gtk_widget_show (tcd->pause_button);
   gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->pause_button,6,7,1,2,GTK_FILL,GTK_FILL,2,2);
@@ -196,7 +199,8 @@ gui_control(Tab *tab)
   pixbuf = gdk_pixbuf_new_from_xpm_data((const char **)TraceControlPause_xpm);
   image = gtk_image_new_from_pixbuf(pixbuf);
   tcd->unpause_button = gtk_button_new_with_label("unpause");
-  gtk_button_set_image(GTK_BUTTON(tcd->unpause_button), image);
+  //2.6 gtk_button_set_image(GTK_BUTTON(tcd->unpause_button), image);
+  g_object_set(G_OBJECT(tcd->unpause_button), "image", image, NULL);
   gtk_button_set_alignment(GTK_BUTTON(tcd->unpause_button), 0.0, 0.0);
   gtk_widget_show (tcd->unpause_button);
   gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->unpause_button,6,7,2,3,GTK_FILL,GTK_FILL,2,2);
@@ -204,7 +208,8 @@ gui_control(Tab *tab)
   pixbuf = gdk_pixbuf_new_from_xpm_data((const char **)TraceControlStop_xpm);
   image = gtk_image_new_from_pixbuf(pixbuf);
   tcd->stop_button = gtk_button_new_with_label("stop");
-  gtk_button_set_image(GTK_BUTTON(tcd->stop_button), image);
+  //2.6 gtk_button_set_image(GTK_BUTTON(tcd->stop_button), image);
+  g_object_set(G_OBJECT(tcd->stop_button), "image", image, NULL);
   gtk_button_set_alignment(GTK_BUTTON(tcd->stop_button), 0.0, 0.0);
   gtk_widget_show (tcd->stop_button);
   gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->stop_button,6,7,3,4,GTK_FILL,GTK_FILL,2,2);
@@ -351,6 +356,8 @@ gui_control(Tab *tab)
 
   gtk_container_set_focus_chain(GTK_CONTAINER(tcd->main_box), focus_chain);
 
+  g_list_free(focus_chain);
+
   g_signal_connect(G_OBJECT(tcd->start_button), "clicked",
       (GCallback)start_clicked, tcd);
   g_signal_connect(G_OBJECT(tcd->pause_button), "clicked", 
@@ -434,9 +441,10 @@ static int execute_command(const gchar *command, const gchar *username,
     /* Read the output from the child terminal before the prompt. If no data in
      * 200 ms, we stop reading to give the password */
     g_info("Reading from child console...");
+    sleep(1); /* make sure the child is ready */
     while(1) {
       pollfd.fd = fdpty;
-      pollfd.events = POLLIN|POLLPRI;
+      pollfd.events = POLLIN|POLLPRI|POLLERR|POLLHUP|POLLNVAL;
 
       num_rdy = poll(&pollfd, 1, 200);
 #if 0
@@ -494,7 +502,7 @@ static int execute_command(const gchar *command, const gchar *username,
     while(1) {
       int num_hup = 0;
       pollfd.fd = fdpty;
-      pollfd.events = POLLIN|POLLPRI;
+      pollfd.events = POLLIN|POLLPRI|POLLERR|POLLHUP|POLLNVAL;
 
       num_rdy = poll(&pollfd, 1, -1);
 #if 0
@@ -536,13 +544,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.");
 
@@ -583,8 +596,15 @@ void start_clicked (GtkButton *button, gpointer user_data)
   const gchar *trace_name =
     gtk_entry_get_text(GTK_ENTRY(tcd->trace_name_entry));
   
-  const gchar *trace_mode_sel =
-    gtk_combo_box_get_active_text(GTK_COMBO_BOX(tcd->trace_mode_combo));
+  const gchar *trace_mode_sel;
+  GtkTreeIter iter;
+  
+  gtk_combo_box_get_active_iter(GTK_COMBO_BOX(tcd->trace_mode_combo), &iter);
+  gtk_tree_model_get(
+      gtk_combo_box_get_model(GTK_COMBO_BOX(tcd->trace_mode_combo)),
+      &iter, 0, &trace_mode_sel, -1);
+  //const gchar *trace_mode_sel =
+    //2.6+ gtk_combo_box_get_active_text(GTK_COMBO_BOX(tcd->trace_mode_combo));
   const gchar *trace_mode;
   if(strcmp(trace_mode_sel, "normal") == 0)
     trace_mode = "normal";
This page took 0.023844 seconds and 4 git commands to generate.