/* 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 */
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
}
g_info("There are now : %d windows\n",g_slist_length(g_main_window_list));
+
+ return new_m_window;
}
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);
+}
+
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);
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 */
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);
+
}