X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=lttv%2Fmodules%2Fgui%2Flttvwindow%2Flttvwindow%2Fcallbacks.c;h=ae56ee67354108613cf5b8793c3b61414f48a2c6;hb=9a366873e0ed6ecc7f23e2d3a959ecddd4f2f91d;hp=e00a724458900297258677e309575a8fc8592d0f;hpb=7e18bb764505bff5daee356927dcde1c1a6ac2d4;p=lttv.git diff --git a/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c b/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c index e00a7244..ae56ee67 100644 --- a/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c +++ b/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c @@ -37,9 +37,12 @@ #include #include #include +#include +#ifdef BABEL_CLEANUP #include -#include #include +#endif /* BABEL_CLEANUP */ +#include #include #include #include @@ -49,6 +52,10 @@ #include #include +#include +#include +#include + static LttTime lttvwindow_default_time_width = { 1, 0 }; #define CLIP_BUF 256 // size of clipboard buffer @@ -218,13 +225,12 @@ 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; - LttvTracesetContext *tsc = - LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context); +#ifdef BABEL_CLEANUP // Perform time synchronization on the traces if (syncTraceset(tsc)) { @@ -274,11 +280,15 @@ int SetTraceset(Tab * tab, LttvTraceset *traceset) tsc = LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context); } +#endif /*BABEL_CLEANUP*/ - time_span = tsc->time_span; + time_span = lttv_traceset_get_time_span(traceset); + + tab->traceset_info->traceset = traceset; + new_time_window = tab->time_window; - new_current_time = tab->current_time; - + new_current_time = tab->current_time; + /* Set the tab's time window and current time if * out of bounds */ if(ltt_time_compare(tab->time_window.start_time, time_span.start_time) < 0 @@ -311,6 +321,7 @@ int SetTraceset(Tab * tab, LttvTraceset *traceset) current_time_change_manager(tab, new_current_time); return retval; + } /** @@ -698,6 +709,7 @@ void open_traceset(GtkWidget * widget, gpointer user_data) gboolean lttvwindow_process_pending_requests(Tab *tab) { +#ifdef BABEL_CLEANUP LttvTracesetContext *tsc; LttvTracefileContext *tfc; GSList *list_in = NULL; @@ -974,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); @@ -1476,6 +1489,8 @@ gboolean lttvwindow_process_pending_requests(Tab *tab) NULL); return FALSE; */ + + #endif /* BABEL_CLEANUP */ } #undef list_out @@ -1485,8 +1500,8 @@ gboolean lttvwindow_process_pending_requests(Tab *tab) static gboolean live_trace_update_handler(Tab *tab) { +#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; @@ -1521,10 +1536,12 @@ live_trace_update_handler(Tab *tab) /* Timer will be recalled as long as there is files to update */ return (updated_count > 0); +#endif /* BABEL_CLEANUP */ } static void lttvwindow_add_trace(Tab *tab, LttvTrace *trace_v) { +#ifdef BABEL_CLEANUP LttvTraceset *traceset = tab->traceset_info->traceset; guint i; guint num_traces = lttv_traceset_number(traceset); @@ -1585,7 +1602,7 @@ static void lttvwindow_add_trace(Tab *tab, LttvTrace *trace_v) (GSourceFunc) live_trace_update_handler, tab); } - +#endif /* BABEL_CLEANUP */ } /* add_trace adds a trace into the current traceset. It first displays a @@ -1595,10 +1612,9 @@ static void lttvwindow_add_trace(Tab *tab, LttvTrace *trace_v) void add_trace(GtkWidget * widget, gpointer user_data) { - LttTrace *trace; - LttvTrace * trace_v; + LttvTraceset * traceset; - const char * dir; + const char * path; char abs_path[PATH_MAX]; gint id; MainWindow * mw_data = get_window_data_struct(widget); @@ -1616,7 +1632,8 @@ void add_trace(GtkWidget * widget, gpointer user_data) ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin"); tab = ptab->tab; } - + /* Create a new traceset*/ + traceset = lttv_traceset_new(); /* File open dialog management */ GtkWidget *extra_live_button; GtkFileChooser * file_chooser = @@ -1626,7 +1643,7 @@ 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)); /* Button to indicate the opening of a live trace */ extra_live_button = gtk_check_button_new_with_mnemonic ("Trace is live (currently being writen)"); @@ -1637,67 +1654,59 @@ void add_trace(GtkWidget * widget, gpointer user_data) 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; - } + case GTK_RESPONSE_REJECT: + case GTK_RESPONSE_CANCEL: + default: + closeFileChooserDialog = TRUE; + break; + } + }while(!closeFileChooserDialog); + gtk_widget_destroy((GtkWidget*)file_chooser); } @@ -1716,6 +1725,7 @@ void add_trace(GtkWidget * widget, gpointer user_data) void remove_trace(GtkWidget *widget, gpointer user_data) { +#ifdef BABEL_CLEANUP LttTrace *trace; LttvTrace * trace_v; LttvTraceset * traceset; @@ -1804,6 +1814,7 @@ void remove_trace(GtkWidget *widget, gpointer user_data) SetTraceset(tab, (gpointer)traceset); } g_free(name); +#endif /* BABEL_CLEANUP */ } #if 0 @@ -2056,6 +2067,7 @@ void save_as(GtkWidget * widget, gpointer user_data) void zoom(GtkWidget * widget, double size) { +#ifdef BABEL_CLEANUP TimeInterval time_span; TimeWindow new_time_window; LttTime current_time, time_delta; @@ -2139,6 +2151,8 @@ void zoom(GtkWidget * widget, double size) } else { time_change_manager(tab, new_time_window); } + +#endif /* BABEL_CLEANUP */ } void zoom_in(GtkWidget * widget, gpointer user_data) @@ -3234,14 +3248,19 @@ on_MNotebook_switch_page (GtkNotebook *notebook, void time_change_manager (Tab *tab, TimeWindow new_time_window) -{ +{ + /* Only one source of time change */ if(tab->time_manager_lock == TRUE) return; tab->time_manager_lock = TRUE; + TimeInterval time_span; + + LttvTraceset *ts = tab->traceset_info->traceset; + time_span.start_time =ltt_time_from_uint64( lttv_traceset_get_timestamp_begin(ts)); + time_span.end_time = ltt_time_from_uint64(lttv_traceset_get_timestamp_end(ts)); + - LttvTracesetContext *tsc = LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context); - TimeInterval time_span = tsc->time_span; LttTime start_time = new_time_window.start_time; LttTime end_time = new_time_window.end_time; @@ -3249,7 +3268,8 @@ void time_change_manager (Tab *tab, /* Set scrollbar */ GtkAdjustment *adjustment = gtk_range_get_adjustment(GTK_RANGE(tab->scrollbar)); - LttTime upper = ltt_time_sub(time_span.end_time, time_span.start_time); + LttTime upper = ltt_time_sub(time_span.end_time, time_span.start_time); + #if 0 gtk_range_set_increments(GTK_RANGE(tab->scrollbar), ltt_time_to_double(new_time_window.time_width) @@ -3304,6 +3324,8 @@ void time_change_manager (Tab *tab, set_time_window(tab, &new_time_window); tab->time_manager_lock = FALSE; + + } @@ -3325,19 +3347,15 @@ void current_time_change_manager (Tab *tab, tab->current_time_manager_lock = FALSE; } -void current_position_change_manager(Tab *tab, - LttvTracesetContextPosition *pos) +void current_position_change_manager(Tab *tab, LttvTracesetPosition *pos) { - LttvTracesetContext *tsc = - LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context); - int retval; + lttv_traceset_seek_to_position( pos); - retval= lttv_process_traceset_seek_position(tsc, pos); - g_assert_cmpint(retval, ==, 0); - LttTime new_time = lttv_traceset_context_position_get_time(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); @@ -3347,9 +3365,8 @@ static void on_timebar_starttime_changed(Timebar *timebar, gpointer user_data) { 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); @@ -3384,9 +3401,8 @@ static void on_timebar_endtime_changed(Timebar *timebar, gpointer user_data) { 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; @@ -3413,7 +3429,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); + time_change_manager(tab, new_time_window); } static void on_timebar_currenttime_changed(Timebar *timebar, gpointer user_data) @@ -3435,9 +3451,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); @@ -3457,6 +3473,7 @@ void scroll_value_changed_cb(GtkWidget *scrollbar, time_change_manager(tab, new_time_window); + #if 0 //time_window = tab->time_window; @@ -3485,6 +3502,7 @@ void scroll_value_changed_cb(GtkWidget *scrollbar, /* call viewer hooks for new time window */ set_time_window(tab, &time_window); #endif //0 + } @@ -3855,6 +3873,7 @@ MainWindow *construct_main_window(MainWindow * parent) void tab_destructor(LttvPluginTab * ptab) { +#ifdef BABEL_CLEANUP int i, nb, ref_count; LttvTrace * trace; Tab *tab = ptab->tab; @@ -3893,6 +3912,7 @@ void tab_destructor(LttvPluginTab * ptab) g_free(tab->traceset_info); //g_free(tab); g_object_unref(ptab); +#endif /* BABEL_CLEANUP */ } @@ -3902,6 +3922,7 @@ void tab_destructor(LttvPluginTab * ptab) void init_tab(Tab *tab, MainWindow * mw, Tab *copy_tab, GtkNotebook * notebook, char * label) { + GList * list; //Tab * tab; //LttvFilter *filter = NULL; @@ -3919,9 +3940,13 @@ void init_tab(Tab *tab, MainWindow * mw, Tab *copy_tab, /* Copy the previous tab's filter */ /* We can clone the filter, as we copy the trace set also */ /* The filter must always be in sync with the trace set */ + +#ifdef BABEL_CLEANUP tab->filter = lttv_filter_clone(copy_tab->filter); +#endif /* BABEL_CLEANUP */ } else { tab->traceset_info->traceset = lttv_traceset_new(); + tab->filter = NULL; } #ifdef DEBUG @@ -3931,21 +3956,17 @@ void init_tab(Tab *tab, MainWindow * mw, Tab *copy_tab, 0, 4); fflush(stdout); #endif //DEBUG - +// tab->time_manager_lock = FALSE; tab->current_time_manager_lock = FALSE; - +#ifdef BABEL_CLEANUP //FIXME copy not implemented in lower level tab->traceset_info->traceset_context = g_object_new(LTTV_TRACESET_STATS_TYPE, NULL); - g_assert(tab->traceset_info->traceset_context != NULL); - lttv_context_init( - LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context), - tab->traceset_info->traceset); //add state update hooks lttv_state_add_event_hooks( (LttvTracesetState*)tab->traceset_info->traceset_context); - +#endif //BABEL_CLEANUP //determine the current_time and time_window of the tab #if 0 if(copy_tab != NULL){ @@ -4110,7 +4131,7 @@ void init_tab(Tab *tab, MainWindow * mw, Tab *copy_tab, lttvwindow_report_time_window(tab, time_window); lttvwindow_report_current_time(tab, ltt_time_zero); } - + LttvTraceset *traceset = tab->traceset_info->traceset; SetTraceset(tab, traceset); } @@ -4128,8 +4149,9 @@ gboolean execute_events_requests(Tab *tab) } -__EXPORT void create_main_window_with_trace_list(GSList *traces, gboolean is_live) +__EXPORT void create_main_window_with_trace_list(GSList *traces) { + GSList *iter = NULL; /* Create window */ @@ -4149,24 +4171,19 @@ __EXPORT void create_main_window_with_trace_list(GSList *traces, gboolean is_liv ptab = (LttvPluginTab *)g_object_get_data(G_OBJECT(page), "Tab_Plugin"); tab = ptab->tab; } - + + LttvTraceset * traceset = lttv_traceset_new(); for(iter=traces; iter!=NULL; iter=g_slist_next(iter)) { gchar *path = (gchar*)iter->data; /* 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) { - if(is_live) { - trace = ltt_trace_open_live(abs_path); - } else { - trace = ltt_trace_open(abs_path); - } - if(trace == NULL) { - g_warning("cannot open trace %s", abs_path); + + if(lttv_traceset_add_path(traceset,abs_path) != 0 ){ /*failure*/ + + g_warning("cannot open trace %s", abs_path); GtkWidget *dialogue = gtk_message_dialog_new( @@ -4178,19 +4195,10 @@ __EXPORT void create_main_window_with_trace_list(GSList *traces, gboolean is_liv "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); + else{ + SetTraceset(tab, traceset); + } + } }