X-Git-Url: https://git.lttng.org/?p=lttv.git;a=blobdiff_plain;f=lttv%2Fmodules%2Fgui%2Flttvwindow%2Flttvwindow%2Fcallbacks.c;h=7c113118ac79b0bd58d410a0900e5dff97e27b70;hp=832923c9ae9333dedc60ef0bbcb6de9ec13c3fb8;hb=1167062fa9bd8dc2a698106b7d58f63ea6c99a8c;hpb=451aaf275d421d71097d479eb0ae64fe908d8b6f diff --git a/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c b/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c index 832923c9..7c113118 100644 --- a/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c +++ b/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c @@ -226,7 +226,6 @@ void insert_viewer(GtkWidget* widget, lttvwindow_viewer_constructor constructor) int SetTraceset(Tab * tab, LttvTraceset *traceset) { - guint i; TimeInterval time_span; TimeWindow new_time_window; LttTime new_current_time; @@ -283,9 +282,7 @@ int SetTraceset(Tab * tab, LttvTraceset *traceset) } #endif /*BABEL_CLEANUP*/ - - time_span.start_time =ltt_time_from_uint64( lttv_traceset_get_timestamp_begin(traceset)); - time_span.end_time = ltt_time_from_uint64(lttv_traceset_get_timestamp_end(traceset)); + time_span = lttv_traceset_get_time_span(traceset); tab->traceset_info->traceset = traceset; @@ -712,7 +709,7 @@ void open_traceset(GtkWidget * widget, gpointer user_data) gboolean lttvwindow_process_pending_requests(Tab *tab) { - #ifdef BABEL_CLEANUP +#ifdef BABEL_CLEANUP LttvTracesetContext *tsc; LttvTracefileContext *tfc; GSList *list_in = NULL; @@ -989,11 +986,12 @@ gboolean lttvwindow_process_pending_requests(Tab *tab) /* Process the traceset with only state hooks */ #ifdef DEBUG seek_count = -#endif + lttv_process_traceset_middle(tsc, ltt_time_infinite, G_MAXUINT, events_request->start_position); +#endif g_assert(lttv_traceset_context_ctx_pos_compare(tsc, events_request->start_position) == 0); @@ -1502,8 +1500,8 @@ gboolean lttvwindow_process_pending_requests(Tab *tab) static gboolean live_trace_update_handler(Tab *tab) { - unsigned int updated_count; #ifdef BABEL_CLEANUP + unsigned int updated_count; LttvTracesetContext *tsc = LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context); TimeInterval initial_time_span = tsc->time_span; TimeInterval updated_time_span; @@ -1543,7 +1541,7 @@ live_trace_update_handler(Tab *tab) static void lttvwindow_add_trace(Tab *tab, LttvTrace *trace_v) { - #ifdef BABEL_CLEANUP +#ifdef BABEL_CLEANUP LttvTraceset *traceset = tab->traceset_info->traceset; guint i; guint num_traces = lttv_traceset_number(traceset); @@ -1614,11 +1612,9 @@ static void lttvwindow_add_trace(Tab *tab, LttvTrace *trace_v) void add_trace(GtkWidget * widget, gpointer user_data) { -#ifdef BABEL_CLEANUP - LttTrace *trace; - LttvTrace * trace_v; - LttvTraceset * traceset; - const char * dir; + + LttvTraceset * traceset = NULL; + const char * path; char abs_path[PATH_MAX]; gint id; MainWindow * mw_data = get_window_data_struct(widget); @@ -1636,9 +1632,27 @@ void add_trace(GtkWidget * widget, gpointer user_data) ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin"); tab = ptab->tab; } - +//TODO fdeslauriers 2012-07-06: Remove this popup when we support multiple traces + traceset = lttvwindow_get_traceset(tab); + if(traceset != NULL && lttv_traceset_number(traceset) > 0){ + 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, + "Loading multiple traces is not supported at the moment."); + gtk_dialog_run(GTK_DIALOG(dialogue)); + gtk_widget_destroy(dialogue); + return; + } + + /* Create a new traceset*/ + traceset = lttv_traceset_new(); /* File open dialog management */ - GtkWidget *extra_live_button; +#ifdef BABEL_CLEANUP + GtkWidget *extra_live_button; +#endif //babel_cleanup GtkFileChooser * file_chooser = GTK_FILE_CHOOSER( gtk_file_chooser_dialog_new ("Select a trace", @@ -1646,81 +1660,71 @@ void add_trace(GtkWidget * widget, gpointer user_data) GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, - NULL)); - + NULL)); +#ifdef BABEL_CLEANUP /* Button to indicate the opening of a live trace */ extra_live_button = gtk_check_button_new_with_mnemonic ("Trace is live (currently being writen)"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (extra_live_button), FALSE); gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (file_chooser), extra_live_button); - +#endif //babel_cleanup gtk_file_chooser_set_show_hidden (file_chooser, TRUE); if(remember_trace_dir[0] != '\0') gtk_file_chooser_set_filename(file_chooser, remember_trace_dir); - id = gtk_dialog_run(GTK_DIALOG(file_chooser)); + gboolean closeFileChooserDialog = TRUE; - switch(id){ - case GTK_RESPONSE_ACCEPT: - case GTK_RESPONSE_OK: - dir = gtk_file_chooser_get_filename (file_chooser); + do + { + id = gtk_dialog_run(GTK_DIALOG(file_chooser)); + switch(id){ + case GTK_RESPONSE_ACCEPT: + case GTK_RESPONSE_OK: + path = gtk_file_chooser_get_filename (file_chooser); - strncpy(remember_trace_dir, dir, PATH_MAX); - strncat(remember_trace_dir, "/", PATH_MAX); - if(!dir || strlen(dir) == 0){ - break; - } - get_absolute_pathname(dir, abs_path); - trace_v = lttvwindowtraces_get_trace_by_name(abs_path); - if(trace_v == NULL) { - if(gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (extra_live_button))) { - trace = ltt_trace_open_live(abs_path); - } else { - trace = ltt_trace_open(abs_path); + strncpy(remember_trace_dir, path, PATH_MAX); + strncat(remember_trace_dir, "/", PATH_MAX); + if(!path || strlen(path) == 0){ + break; } - - 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); - lttvwindow_add_trace(tab, trace_v); - } - } else { - lttvwindow_add_trace(tab, trace_v); - } - + get_absolute_pathname(path, abs_path); + + if(lttv_traceset_add_path(traceset,abs_path) != 0 ){ /*failure*/ - //update current tab - //update_traceset(mw_data); + g_warning("cannot open trace %s", abs_path); + strncpy(remember_trace_dir, "\0", PATH_MAX); + 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); + closeFileChooserDialog = FALSE; + } + else{ + closeFileChooserDialog = TRUE; + SetTraceset(tab, traceset); + } + break; + //update current tab + //update_traceset(mw_data); - /* Call the updatetraceset hooks */ - - traceset = tab->traceset_info->traceset; - SetTraceset(tab, traceset); - // in expose now call_pending_read_hooks(mw_data); + // in expose now call_pending_read_hooks(mw_data); + + //lttvwindow_report_current_time(mw_data,&(tab->current_time)); - //lttvwindow_report_current_time(mw_data,&(tab->current_time)); - break; - case GTK_RESPONSE_REJECT: - case GTK_RESPONSE_CANCEL: - default: - break; - } - gtk_widget_destroy((GtkWidget*)file_chooser); + case GTK_RESPONSE_REJECT: + case GTK_RESPONSE_CANCEL: + default: + closeFileChooserDialog = TRUE; + break; + } + }while(!closeFileChooserDialog); -#endif /* BABEL_CLEANUP */ + gtk_widget_destroy((GtkWidget*)file_chooser); } @@ -1738,7 +1742,7 @@ void add_trace(GtkWidget * widget, gpointer user_data) void remove_trace(GtkWidget *widget, gpointer user_data) { - #ifdef BABEL_CLEANUP +#ifdef BABEL_CLEANUP LttTrace *trace; LttvTrace * trace_v; LttvTraceset * traceset; @@ -2080,7 +2084,7 @@ void save_as(GtkWidget * widget, gpointer user_data) void zoom(GtkWidget * widget, double size) { - #ifdef BABEL_CLEANUP +#ifdef BABEL_CLEANUP TimeInterval time_span; TimeWindow new_time_window; LttTime current_time, time_delta; @@ -3360,34 +3364,26 @@ void current_time_change_manager (Tab *tab, tab->current_time_manager_lock = FALSE; } -void current_position_change_manager(Tab *tab, - LttvTracesetPosition *pos) +void current_position_change_manager(Tab *tab, LttvTracesetPosition *pos) { - #ifdef BABEL_CLEANUP - LttvTracesetContext *tsc = - LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context); - int retval; - - retval= lttv_process_traceset_seek_position(tsc, pos); - g_assert_cmpint(retval, ==, 0); - LttTime new_time = lttv_traceset_context_position_get_time(pos); + lttv_traceset_seek_to_position( pos); + + LttTime new_time = lttv_traceset_position_get_time(pos); /* Put the context in a state coherent position */ - lttv_state_traceset_seek_time_closest((LttvTracesetState*)tsc, ltt_time_zero); - +#ifdef BABEL_CLEANUP + lttv_state_traceset_seek_time_closest((LttvTracesetState*)tsc, ltt_time_zero); +#endif /* BABEL_CLEANUP */ current_time_change_manager(tab, new_time); set_current_position(tab, pos); - #endif /* BABEL_CLEANUP */ } static void on_timebar_starttime_changed(Timebar *timebar, gpointer user_data) { - #ifdef BABEL_CLEANUP Tab *tab = (Tab *)user_data; - LttvTracesetContext * tsc = - LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context); - TimeInterval time_span = tsc->time_span; + LttvTraceset * ts =tab->traceset_info->traceset; + TimeInterval time_span = lttv_traceset_get_time_span(ts); TimeWindow new_time_window = tab->time_window; new_time_window.start_time = timebar_get_start_time(timebar); @@ -3415,17 +3411,15 @@ static void on_timebar_starttime_changed(Timebar *timebar, /* Notify the time_manager */ time_change_manager(tab, new_time_window); -#endif /* BABEL_CLEANUP */ + } static void on_timebar_endtime_changed(Timebar *timebar, gpointer user_data) { - #ifdef BABEL_CLEANUP Tab *tab = (Tab *)user_data; - LttvTracesetContext * tsc = - LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context); - TimeInterval time_span = tsc->time_span; + LttvTraceset * ts =tab->traceset_info->traceset; + TimeInterval time_span = lttv_traceset_get_time_span(ts); TimeWindow new_time_window = tab->time_window; @@ -3452,8 +3446,7 @@ static void on_timebar_endtime_changed(Timebar *timebar, new_time_window.end_time = end_time; /* Notify the time_manager */ - time_change_manager(tab, new_time_window); - #endif /* BABEL_CLEANUP*/ + time_change_manager(tab, new_time_window); } static void on_timebar_currenttime_changed(Timebar *timebar, gpointer user_data) @@ -3468,7 +3461,6 @@ static void on_timebar_currenttime_changed(Timebar *timebar, void scroll_value_changed_cb(GtkWidget *scrollbar, gpointer user_data) { - #ifdef BABEL_CLEANUP Tab *tab = (Tab *)user_data; TimeWindow new_time_window; LttTime time; @@ -3476,9 +3468,9 @@ void scroll_value_changed_cb(GtkWidget *scrollbar, gdouble value = gtk_adjustment_get_value(adjust); // gdouble upper, lower, ratio, page_size; gdouble page_size; - LttvTracesetContext * tsc = - LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context); - TimeInterval time_span = tsc->time_span; + + LttvTraceset * ts = tab->traceset_info->traceset; + TimeInterval time_span = lttv_traceset_get_time_span(ts); time = ltt_time_add(ltt_time_from_double(value), time_span.start_time); @@ -3498,6 +3490,7 @@ void scroll_value_changed_cb(GtkWidget *scrollbar, time_change_manager(tab, new_time_window); + #if 0 //time_window = tab->time_window; @@ -3526,7 +3519,7 @@ void scroll_value_changed_cb(GtkWidget *scrollbar, /* call viewer hooks for new time window */ set_time_window(tab, &time_window); #endif //0 -#endif /* BABEL_CLEANUP */ + }