open trace automagically upon stop
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 15 Sep 2005 18:06:47 +0000 (18:06 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 15 Sep 2005 18:06:47 +0000 (18:06 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@1198 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.h
ltt/branches/poly/lttv/modules/gui/tracecontrol/tracecontrol.c

index 8bf819e631ec9de4e9e1a74137b283d8f175e3fd..8571eb25d03076414f69a34b8b380b89d0ab8278 100644 (file)
@@ -3964,7 +3964,7 @@ void add_all_menu_toolbar_constructors(MainWindow * mw, gpointer user_data)
 /* Create a main window
  */
 
-void construct_main_window(MainWindow * parent)
+MainWindow *construct_main_window(MainWindow * parent)
 {
   g_debug("construct_main_window()");
   GtkWidget  * new_window; /* New generated main window */
@@ -4004,7 +4004,9 @@ void construct_main_window(MainWindow * parent)
   notebook = (GtkNotebook *)lookup_widget(new_m_window->mwindow, "MNotebook");
   if(notebook == NULL){
     g_info("Notebook does not exist\n");
-    return;
+    /* FIXME : destroy partially created widgets */
+    g_free(new_m_window);
+    return NULL;
   }
   //gtk_notebook_popup_enable (GTK_NOTEBOOK(notebook));
   //for now there is no name field in LttvTraceset structure
@@ -4078,6 +4080,8 @@ void construct_main_window(MainWindow * parent)
   }
 
   g_info("There are now : %d windows\n",g_slist_length(g_main_window_list));
+
+  return new_m_window;
 }
 
 
@@ -4500,3 +4504,49 @@ gboolean execute_events_requests(Tab *tab)
   return ( lttvwindow_process_pending_requests(tab) );
 }
 
+
+void create_main_window_with_trace(gchar *path)
+{
+  if(path == NULL) return;
+
+  /* Create window */
+  MainWindow *mw = construct_main_window(NULL);
+  GtkWidget *widget = mw->mwindow;
+
+  GtkWidget * notebook = lookup_widget(widget, "MNotebook");
+  GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook),
+                      gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)));
+  Tab *tab;
+  
+  if(!page) {
+    tab = create_new_tab(widget, NULL);
+  } else {
+    tab = (Tab *)g_object_get_data(G_OBJECT(page), "Tab_Info");
+  }
+
+  /* Add trace */
+  gchar abs_path[PATH_MAX];
+  LttvTrace *trace_v;
+  LttTrace *trace;
+
+  get_absolute_pathname(path, abs_path);
+  trace_v = lttvwindowtraces_get_trace_by_name(abs_path);
+  if(trace_v == NULL) {
+    trace = ltt_trace_open(abs_path);
+    if(trace == NULL) {
+      g_warning("cannot open trace %s", abs_path);
+    } else {
+      trace_v = lttv_trace_new(trace);
+      lttvwindowtraces_add_trace(trace_v);
+      lttvwindow_add_trace(tab, trace_v);
+    }
+  } else {
+    lttvwindow_add_trace(tab, trace_v);
+  }
+
+  LttvTraceset *traceset;
+
+  traceset = tab->traceset_info->traceset;
+  SetTraceset(tab, traceset);
+}
+
index 348e47eae5210592902cecd34478b6120d8f1e9b..e517472a6e0c60d424f3840b8da5ebcc4682a1ab 100644 (file)
 
 void create_new_window(GtkWidget* widget, gpointer user_data, gboolean clone);
 void insert_menu_toolbar_item(MainWindow * mw, gpointer user_data);
-void construct_main_window(MainWindow * parent);
+MainWindow *construct_main_window(MainWindow * parent);
 void main_window_free(MainWindow * mw);
 void main_window_destructor(MainWindow * mw);
 
+void create_main_window_with_trace(gchar *path);
+
 void insert_viewer_wrap(GtkWidget *menuitem, gpointer user_data);
 gboolean execute_events_requests(Tab *tab);
 
index e852ee711a0690d15a1af2a9e22df045c50c1e56..6e09947ab3c7df5f13201f6f2e4ffa8a79f596cb 100644 (file)
@@ -846,6 +846,7 @@ void stop_clicked (GtkButton *button, gpointer user_data)
   
   const gchar *lttctl_path =
     gtk_entry_get_text(GTK_ENTRY(tcd->lttctl_path_entry));
+  const gchar *trace_dir = gtk_entry_get_text(GTK_ENTRY(tcd->trace_dir_entry));
 
   /* Setup arguments to su */
   /* child */
@@ -889,6 +890,37 @@ void stop_clicked (GtkButton *button, gpointer user_data)
   execute_command(args, username, password, lttd_path, fac_path);
 
 
+  /* Ask to the user if he wants to open the trace in a new window */
+  GtkWidget *dialogue;
+  GtkWidget *label;
+  gint id;
+  
+  dialogue = gtk_dialog_new_with_buttons("Open trace ?",
+      GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(button))),
+      GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+      GTK_STOCK_YES,GTK_RESPONSE_ACCEPT,
+      GTK_STOCK_NO,GTK_RESPONSE_REJECT,
+      NULL);
+  label = gtk_label_new("Do you want to open the trace in LTTV ?");
+  gtk_widget_show(label);
+
+  gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialogue)->vbox),
+      label);
+
+  id = gtk_dialog_run(GTK_DIALOG(dialogue));
+
+  switch(id){
+    case GTK_RESPONSE_ACCEPT:
+      {
+        create_main_window_with_trace(trace_dir);
+      }
+      break;
+    case GTK_RESPONSE_REJECT:
+    default:
+      break;
+  }
+  gtk_widget_destroy(dialogue);
+
 }
 
 
This page took 0.027751 seconds and 4 git commands to generate.