update roadmap
[lttv.git] / ltt / branches / poly / lttv / modules / gui / lttvwindow / lttvwindow / callbacks.c
index a19cde58bd9bfdaa3cb3867128ae5879b3f0cbc7..03b8afb5d4df0809e324ab16c35a494f16c40fae 100644 (file)
@@ -1730,6 +1730,18 @@ void add_trace(GtkWidget * widget, gpointer user_data)
         trace = ltt_trace_open(abs_path);
         if(trace == NULL) {
           g_warning("cannot open trace %s", abs_path);
+
+          GtkWidget *dialogue = 
+            gtk_message_dialog_new(
+              GTK_WINDOW(gtk_widget_get_toplevel(widget)),
+              GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
+              GTK_MESSAGE_ERROR,
+              GTK_BUTTONS_OK,
+              "Cannot open trace : maybe you should enter in the trace "
+              "directory to select it ?");
+          gtk_dialog_run(GTK_DIALOG(dialogue));
+          gtk_widget_destroy(dialogue);
+
         } else {
           trace_v = lttv_trace_new(trace);
           lttvwindowtraces_add_trace(trace_v);
@@ -3621,6 +3633,8 @@ void current_position_change_manager(Tab *tab,
 
   g_assert(lttv_process_traceset_seek_position(tsc, pos) == 0);
   LttTime new_time = lttv_traceset_context_position_get_time(pos);
+  /* Put the context in a state coherent position */
+  lttv_state_traceset_seek_time_closest((LttvTracesetState*)tsc, ltt_time_zero);
   
   current_time_change_manager(tab, new_time);
   
@@ -3962,7 +3976,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 */
@@ -4002,7 +4016,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
@@ -4021,61 +4037,54 @@ void 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);
     }
   }
 
   g_info("There are now : %d windows\n",g_slist_length(g_main_window_list));
+
+  return new_m_window;
 }
 
 
@@ -4498,3 +4507,60 @@ 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);
+
+      GtkWidget *dialogue = 
+        gtk_message_dialog_new(
+          GTK_WINDOW(gtk_widget_get_toplevel(widget)),
+          GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
+          GTK_MESSAGE_ERROR,
+          GTK_BUTTONS_OK,
+          "Cannot open trace : maybe you should enter in the directory"
+          "to select it ?");
+      gtk_dialog_run(GTK_DIALOG(dialogue));
+      gtk_widget_destroy(dialogue);
+    } 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);
+}
+
This page took 0.02552 seconds and 4 git commands to generate.