From: compudj Date: Thu, 15 Sep 2005 18:06:47 +0000 (+0000) Subject: open trace automagically upon stop X-Git-Tag: v0.12.20~2291 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=8321ae6a5238e9fda9d9517c9eec8d1a2980dfd2;p=lttv.git open trace automagically upon stop git-svn-id: http://ltt.polymtl.ca/svn@1198 04897980-b3bd-0310-b5e0-8ef037075253 --- diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c index 8bf819e6..8571eb25 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c @@ -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); +} + diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.h b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.h index 348e47ea..e517472a 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.h +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.h @@ -23,10 +23,12 @@ 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); diff --git a/ltt/branches/poly/lttv/modules/gui/tracecontrol/tracecontrol.c b/ltt/branches/poly/lttv/modules/gui/tracecontrol/tracecontrol.c index e852ee71..6e09947a 100644 --- a/ltt/branches/poly/lttv/modules/gui/tracecontrol/tracecontrol.c +++ b/ltt/branches/poly/lttv/modules/gui/tracecontrol/tracecontrol.c @@ -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); + }