X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttv%2Fmodules%2Fgui%2Flttvwindow%2Flttvwindow%2Fcallbacks.c;h=8bf819e631ec9de4e9e1a74137b283d8f175e3fd;hb=45653836d75635b5b841d0d03f1f0789348adc56;hp=a9bdac212f730a5464da842e91fe9f16269daae6;hpb=962e2228963dbdec5d1b92b8c7d85989b941516e;p=lttv.git 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 a9bdac21..8bf819e6 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c @@ -46,10 +46,9 @@ #include #include #include -#include -#define DEFAULT_TIME_WIDTH_S 1 +static LttTime lttvwindow_default_time_width = { 1, 0 }; #define CLIP_BUF 256 // size of clipboard buffer extern LttvTrace *g_init_trace ; @@ -64,21 +63,18 @@ static char remember_trace_dir[PATH_MAX] = ""; MainWindow * get_window_data_struct(GtkWidget * widget); -char * get_load_module(char ** load_module_name, int nb_module); -char * get_unload_module(char ** loaded_module_name, int nb_module); -char * get_remove_trace(char ** all_trace_name, int nb_trace); -char * get_selection(char ** all_name, int nb, char *title, char * column_title); +char * get_load_module(MainWindow *mw, + char ** load_module_name, int nb_module); +char * get_unload_module(MainWindow *mw, + char ** loaded_module_name, int nb_module); +char * get_remove_trace(MainWindow *mw, char ** all_trace_name, int nb_trace); +char * get_selection(MainWindow *mw, + char ** all_name, int nb, char *title, char * column_title); Tab* create_tab(MainWindow * mw, Tab *copy_tab, GtkNotebook * notebook, char * label); static void insert_viewer(GtkWidget* widget, lttvwindow_viewer_constructor constructor); -void checkbox_changed(GtkTreeView *treeview, - GtkTreePath *arg1, - GtkTreeViewColumn *arg2, - gpointer user_data); -void remove_trace_from_traceset_selector(GtkWidget * paned, unsigned i); -void add_trace_into_traceset_selector(GtkWidget * paned, LttTrace * trace); Tab *create_new_tab(GtkWidget* widget, gpointer user_data); static gboolean lttvwindow_process_pending_requests(Tab *tab); @@ -337,6 +333,18 @@ static void connect_focus_recursive(GtkWidget *widget, (gpointer)viewer); } +/* Stop all the processings and call gtk_main_quit() */ +static void mainwindow_quit() +{ + lttvwindowtraces_unregister_requests(g_quark_from_string("stats")); + lttvwindowtraces_unregister_requests(g_quark_from_string("state")); + lttvwindowtraces_unregister_computation_hooks(g_quark_from_string("stats")); + lttvwindowtraces_unregister_computation_hooks(g_quark_from_string("state")); + + gtk_main_quit(); +} + + /* insert_viewer function constructs an instance of a viewer first, * then inserts the widget of the instance into the container of the * main window @@ -402,8 +410,8 @@ int SetTraceset(Tab * tab, LttvTraceset *traceset) LttvTracesetContext *tsc = LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context); TimeInterval time_span = tsc->time_span; - TimeWindow new_time_window; - LttTime new_current_time; + TimeWindow new_time_window = tab->time_window; + LttTime new_current_time = tab->current_time; /* Set the tab's time window and current time if * out of bounds */ @@ -415,20 +423,23 @@ int SetTraceset(Tab * tab, LttvTraceset *traceset) new_current_time = time_span.start_time; LttTime tmp_time; - - if(DEFAULT_TIME_WIDTH_S < time_span.end_time.tv_sec) - tmp_time.tv_sec = DEFAULT_TIME_WIDTH_S; + + if(ltt_time_compare(lttvwindow_default_time_width, + ltt_time_sub(time_span.end_time, time_span.start_time)) < 0 + || + ltt_time_compare(time_span.end_time, time_span.start_time) == 0) + tmp_time = lttvwindow_default_time_width; else - tmp_time.tv_sec = time_span.end_time.tv_sec; - tmp_time.tv_nsec = 0; + tmp_time = time_span.end_time; + new_time_window.time_width = tmp_time ; new_time_window.time_width_double = ltt_time_to_double(tmp_time); new_time_window.end_time = ltt_time_add(new_time_window.start_time, new_time_window.time_width) ; } - time_change_manager(tab, new_time_window); - current_time_change_manager(tab, new_current_time); + + #if 0 /* Set scrollbar */ GtkAdjustment *adjustment = gtk_range_get_adjustment(GTK_RANGE(tab->scrollbar)); @@ -491,7 +502,9 @@ int SetTraceset(Tab * tab, LttvTraceset *traceset) if(tmp == NULL) retval = 1; else lttv_hooks_call(tmp,traceset); - + time_change_manager(tab, new_time_window); + current_time_change_manager(tab, new_current_time); + return retval; } @@ -504,7 +517,7 @@ int SetTraceset(Tab * tab, LttvTraceset *traceset) * 0 : filters updated * 1 : no filter hooks to update; not an error. */ - +#if 0 int SetFilter(Tab * tab, gpointer filter) { LttvHooks * tmp; @@ -520,7 +533,7 @@ int SetFilter(Tab * tab, gpointer filter) return 0; } - +#endif //0 /** @@ -793,6 +806,9 @@ void open_traceset(GtkWidget * widget, gpointer user_data) gtk_file_selection_hide_fileop_buttons(file_selector); + gtk_window_set_transient_for(GTK_WINDOW(file_selector), + GTK_WINDOW(mw_data->mwindow)); + id = gtk_dialog_run(GTK_DIALOG(file_selector)); switch(id){ case GTK_RESPONSE_ACCEPT: @@ -811,42 +827,6 @@ void open_traceset(GtkWidget * widget, gpointer user_data) } -static void events_request_free(EventsRequest *events_request) -{ - if(events_request == NULL) return; - - if(events_request->start_position != NULL) - lttv_traceset_context_position_destroy(events_request->start_position); - if(events_request->end_position != NULL) - lttv_traceset_context_position_destroy(events_request->end_position); - if(events_request->hooks != NULL) - g_array_free(events_request->hooks, TRUE); - if(events_request->before_chunk_traceset != NULL) - lttv_hooks_destroy(events_request->before_chunk_traceset); - if(events_request->before_chunk_trace != NULL) - lttv_hooks_destroy(events_request->before_chunk_trace); - if(events_request->before_chunk_tracefile != NULL) - lttv_hooks_destroy(events_request->before_chunk_tracefile); - if(events_request->event != NULL) - lttv_hooks_destroy(events_request->event); - if(events_request->event_by_id != NULL) - lttv_hooks_by_id_destroy(events_request->event_by_id); - if(events_request->after_chunk_tracefile != NULL) - lttv_hooks_destroy(events_request->after_chunk_tracefile); - if(events_request->after_chunk_trace != NULL) - lttv_hooks_destroy(events_request->after_chunk_trace); - if(events_request->after_chunk_traceset != NULL) - lttv_hooks_destroy(events_request->after_chunk_traceset); - if(events_request->before_request != NULL) - lttv_hooks_destroy(events_request->before_request); - if(events_request->after_request != NULL) - lttv_hooks_destroy(events_request->after_request); - - g_free(events_request); -} - - - /* lttvwindow_process_pending_requests * * This internal function gets called by g_idle, taking care of the pending @@ -959,8 +939,9 @@ gboolean lttvwindow_process_pending_requests(Tab *tab) } /* 0.2 Seek tracefiles positions to context position */ + //g_assert(lttv_process_traceset_seek_position(tsc, sync_position) == 0); lttv_process_traceset_synchronize_tracefiles(tsc); - + /* Events processing algorithm implementation */ /* Warning : the gtk_events_pending takes a LOT of cpu time. So what we do @@ -1102,6 +1083,9 @@ gboolean lttvwindow_process_pending_requests(Tab *tab) lttv_process_traceset_middle(tsc, events_request->start_time, G_MAXUINT, NULL); +#ifdef DEBUG + g_assert(seek_count < LTTV_STATE_SAVE_INTERVAL); +#endif //DEBUG } else { @@ -1566,7 +1550,7 @@ gboolean lttvwindow_process_pending_requests(Tab *tab) /* 1.1. Use current postition as start position */ if(events_request->start_position != NULL) lttv_traceset_context_position_destroy(events_request->start_position); - events_request->start_position = lttv_traceset_context_position_new(); + events_request->start_position = lttv_traceset_context_position_new(tsc); lttv_traceset_context_position_save(tsc, events_request->start_position); /* 1.2. Remove start time */ @@ -1592,10 +1576,10 @@ gboolean lttvwindow_process_pending_requests(Tab *tab) } - /* C Unlock Traces */ { - //lttv_process_traceset_get_sync_data(tsc); + lttv_process_traceset_get_sync_data(tsc); + //lttv_traceset_context_position_save(tsc, sync_position); guint iter_trace; @@ -1607,7 +1591,6 @@ gboolean lttvwindow_process_pending_requests(Tab *tab) lttvwindowtraces_unlock(trace_v); } } - #if 0 //set the cursor back to normal gdk_window_set_cursor(win, NULL); @@ -1720,18 +1703,23 @@ void add_trace(GtkWidget * widget, gpointer user_data) tab = (Tab *)g_object_get_data(G_OBJECT(page), "Tab_Info"); } - GtkDirSelection * file_selector = (GtkDirSelection *)gtk_dir_selection_new("Select a trace"); - gtk_dir_selection_hide_fileop_buttons(file_selector); + //GtkDirSelection * file_selector = (GtkDirSelection *)gtk_dir_selection_new("Select a trace"); + GtkFileSelection * file_selector = (GtkFileSelection *)gtk_file_selection_new("Select a trace"); + gtk_widget_hide( (file_selector)->file_list->parent) ; + gtk_file_selection_hide_fileop_buttons(file_selector); + gtk_window_set_transient_for(GTK_WINDOW(file_selector), + GTK_WINDOW(mw_data->mwindow)); if(remember_trace_dir[0] != '\0') - gtk_dir_selection_set_filename(file_selector, remember_trace_dir); + gtk_file_selection_set_filename(file_selector, remember_trace_dir); id = gtk_dialog_run(GTK_DIALOG(file_selector)); switch(id){ case GTK_RESPONSE_ACCEPT: case GTK_RESPONSE_OK: - dir = gtk_dir_selection_get_dir (file_selector); + dir = gtk_file_selection_get_filename (file_selector); strncpy(remember_trace_dir, dir, PATH_MAX); + strncat(remember_trace_dir, "/", PATH_MAX); if(!dir || strlen(dir) == 0){ gtk_widget_destroy((GtkWidget*)file_selector); break; @@ -1779,9 +1767,11 @@ void add_trace(GtkWidget * widget, gpointer user_data) * it will remove the trace, recreate the traceset_contex, * and redraws all the viewer of the current tab. If there is on trace in the * current traceset, it will delete all viewers of the current tab + * + * It destroys the filter tree. FIXME... we should request for an update + * instead. */ -// MD : no filter version. void remove_trace(GtkWidget *widget, gpointer user_data) { LttTrace *trace; @@ -1807,10 +1797,10 @@ void remove_trace(GtkWidget *widget, gpointer user_data) for(i = 0; i < nb_trace; i++){ trace_v = lttv_traceset_get(tab->traceset_info->traceset, i); trace = lttv_trace(trace_v); - name[i] = ltt_trace_name(trace); + name[i] = g_quark_to_string(ltt_trace_name(trace)); } - remove_trace_name = get_remove_trace(name, nb_trace); + remove_trace_name = get_remove_trace(mw_data, name, nb_trace); if(remove_trace_name){ @@ -2259,6 +2249,8 @@ Tab *create_new_tab(GtkWidget* widget, gpointer user_data){ strcpy(label,"Page"); if(get_label(mw_data, label,"Get the name of the tab","Please input tab's name")) return (create_tab (mw_data, copy_tab, notebook, label)); + else + return NULL; } void @@ -2362,7 +2354,7 @@ void on_quit_activate (GtkMenuItem *menuitem, gpointer user_data) { - gtk_main_quit (); + mainwindow_quit(); } @@ -2495,7 +2487,8 @@ on_load_library_activate (GtkMenuItem *menuitem, g_ptr_array_add(name, path); } - load_module_path = get_selection((char **)(name->pdata), name->len, + load_module_path = get_selection(mw_data, + (char **)(name->pdata), name->len, "Select a library path", "Library paths"); if(load_module_path != NULL) strncpy(load_module_path_alter, load_module_path, PATH_MAX-1); // -1 for / @@ -2528,6 +2521,9 @@ on_load_library_activate (GtkMenuItem *menuitem, gtk_file_selection_set_filename(file_selector, load_module_path_alter); gtk_file_selection_hide_fileop_buttons(file_selector); + gtk_window_set_transient_for(GTK_WINDOW(file_selector), + GTK_WINDOW(mw_data->mwindow)); + str[0] = '\0'; id = gtk_dialog_run(GTK_DIALOG(file_selector)); switch(id){ @@ -2602,7 +2598,7 @@ on_unload_library_activate (GtkMenuItem *menuitem, gchar *path = lib_info[i].name; g_ptr_array_add(name, path); } - lib_name = get_selection((char **)(name->pdata), name->len, + lib_name = get_selection(mw_data, (char **)(name->pdata), name->len, "Select a library", "Libraries"); if(lib_name != NULL) { for(i=0;ipdata), name->len, + lib_name = get_selection(mw_data,(char **)(name->pdata), name->len, "Select a library", "Libraries"); if(lib_name != NULL) { for(i=0;ipdata), name->len, + module_name = get_selection(mw_data, (char **)(name->pdata), name->len, "Select a module", "Modules"); if(module_name != NULL) { for(i=0;ipdata), name->len, + lib_name = get_selection(mw_data, (char **)(name->pdata), name->len, "Select a library", "Libraries"); if(lib_name != NULL) { for(i=0;i 0) g_ptr_array_add(name, path); } - module_name = get_selection((char **)(name->pdata), name->len, + module_name = get_selection(mw_data, (char **)(name->pdata), name->len, "Select a module", "Modules"); if(module_name != NULL) { for(i=0;ifile_list->parent) ; + + gtk_window_set_transient_for(GTK_WINDOW(file_selector), + GTK_WINDOW(mw_data->mwindow)); + const char * dir; gint id; - MainWindow * mw_data = get_window_data_struct((GtkWidget*)menuitem); if(remember_plugins_dir[0] != '\0') - gtk_dir_selection_set_filename(file_selector, remember_plugins_dir); + gtk_file_selection_set_filename(file_selector, remember_plugins_dir); id = gtk_dialog_run(GTK_DIALOG(file_selector)); switch(id){ case GTK_RESPONSE_ACCEPT: case GTK_RESPONSE_OK: - dir = gtk_dir_selection_get_dir (file_selector); + dir = gtk_file_selection_get_filename (file_selector); strncpy(remember_plugins_dir,dir,PATH_MAX); strncat(remember_plugins_dir,"/",PATH_MAX); lttv_library_path_add(dir); @@ -2909,7 +2911,7 @@ on_remove_library_search_path_activate (GtkMenuItem *menuitem, gchar *path = lttv_library_path_get(i); g_ptr_array_add(name, path); } - lib_path = get_selection((char **)(name->pdata), name->len, + lib_path = get_selection(mw_data, (char **)(name->pdata), name->len, "Select a library path", "Library paths"); g_ptr_array_free(name, TRUE); @@ -2994,10 +2996,11 @@ on_about_activate (GtkMenuItem *menuitem, Contributors :\n\ \n\ Michel Dagenais (New trace format, lttv main)\n\ -Mathieu Desnoyers (Directory structure, build with automake/conf,\n\ +Mathieu Desnoyers (Kernel Tracer, Directory structure, build with automake/conf,\n\ lttv gui, control flow view, gui cooperative trace reading\n\ scheduler with interruptible foreground and background\n\ - computation, detailed event list)\n\ + computation, detailed event list (rewrite), trace reading\n\ + library (rewrite))\n\ Benoit Des Ligneris, Eric Clement (Cluster adaptation, work in progress)\n\ Xang-Xiu Yang (new trace reading library and converter, lttv gui, \n\ detailed event list and statistics view)\n\ @@ -3199,7 +3202,7 @@ on_MWindow_destroy (GtkWidget *widget, g_info("There are now : %d windows\n",g_slist_length(g_main_window_list)); if(g_slist_length(g_main_window_list) == 0) - gtk_main_quit (); + mainwindow_quit(); } gboolean @@ -3257,6 +3260,8 @@ void time_change_manager (Tab *tab, LttTime start_time = new_time_window.start_time; LttTime end_time = new_time_window.end_time; + g_assert(ltt_time_compare(start_time, end_time) < 0); + /* 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); @@ -3607,6 +3612,24 @@ void current_time_change_manager (Tab *tab, tab->current_time_manager_lock = FALSE; } +void current_position_change_manager(Tab *tab, + LttvTracesetContextPosition *pos) +{ + LttvTracesetContext *tsc = + LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context); + TimeInterval time_span = tsc->time_span; + + 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); + + set_current_position(tab, pos); +} + + void on_MEntry5_value_changed (GtkSpinButton *spinbutton, gpointer user_data) @@ -3722,9 +3745,10 @@ void scroll_value_changed_cb(GtkWidget *scrollbar, /* Select a trace which will be removed from traceset */ -char * get_remove_trace(char ** all_trace_name, int nb_trace) +char * get_remove_trace(MainWindow *mw_data, + char ** all_trace_name, int nb_trace) { - return get_selection(all_trace_name, nb_trace, + return get_selection(mw_data, all_trace_name, nb_trace, "Select a trace", "Trace pathname"); } @@ -3732,9 +3756,10 @@ char * get_remove_trace(char ** all_trace_name, int nb_trace) /* Select a module which will be loaded */ -char * get_load_module(char ** load_module_name, int nb_module) +char * get_load_module(MainWindow *mw_data, + char ** load_module_name, int nb_module) { - return get_selection(load_module_name, nb_module, + return get_selection(mw_data, load_module_name, nb_module, "Select a module to load", "Module name"); } @@ -3744,9 +3769,10 @@ char * get_load_module(char ** load_module_name, int nb_module) /* Select a module which will be unloaded */ -char * get_unload_module(char ** loaded_module_name, int nb_module) +char * get_unload_module(MainWindow *mw_data, + char ** loaded_module_name, int nb_module) { - return get_selection(loaded_module_name, nb_module, + return get_selection(mw_data, loaded_module_name, nb_module, "Select a module to unload", "Module name"); } @@ -3755,8 +3781,9 @@ char * get_unload_module(char ** loaded_module_name, int nb_module) * select one of them */ -char * get_selection(char ** loaded_module_name, int nb_module, - char *title, char * column_title) +char * get_selection(MainWindow *mw_data, + char ** loaded_module_name, int nb_module, + char *title, char * column_title) { GtkWidget * dialogue; GtkWidget * scroll_win; @@ -3776,6 +3803,8 @@ char * get_selection(char ** loaded_module_name, int nb_module, GTK_STOCK_CANCEL,GTK_RESPONSE_REJECT, NULL); gtk_window_set_default_size((GtkWindow*)dialogue, 500, 200); + gtk_window_set_transient_for(GTK_WINDOW(dialogue), + GTK_WINDOW(mw_data->mwindow)); scroll_win = gtk_scrolled_window_new (NULL, NULL); gtk_widget_show ( scroll_win); @@ -3809,7 +3838,7 @@ char * get_selection(char ** loaded_module_name, int nb_module, } id = gtk_dialog_run(GTK_DIALOG(dialogue)); - GtkTreeModel **store_model = (GtkTreeModel**)&store; /* for strict aliasing */ + GtkTreeModel **store_model = (GtkTreeModel**)&store; switch(id){ case GTK_RESPONSE_ACCEPT: case GTK_RESPONSE_OK: @@ -4123,12 +4152,10 @@ Tab* create_tab(MainWindow * mw, Tab *copy_tab, /* We can clone the filter, as we copy the trace set also */ /* The filter must always be in sync with the trace set */ tab->filter = lttv_filter_clone(copy_tab->filter); - } else { tab->traceset_info->traceset = lttv_traceset_new(); tab->filter = NULL; } - #ifdef DEBUG lttv_attribute_write_xml( lttv_traceset_attribute(tab->traceset_info->traceset), @@ -4185,12 +4212,17 @@ Tab* create_tab(MainWindow * mw, Tab *copy_tab, tab->viewer_container = gtk_vbox_new(TRUE, 2); tab->scrollbar = gtk_hscrollbar_new(NULL); //tab->multivpaned = gtk_multi_vpaned_new(); - + gtk_box_pack_start(GTK_BOX(tab->vbox), tab->viewer_container, TRUE, /* expand */ TRUE, /* Give the extra space to the child */ 0); /* No padding */ + +// if(copy_tab) { +// tab->time_window = copy_tab->time_window; +// tab->current_time = copy_tab->current_time; +// } /* Create the timebar */ { @@ -4434,6 +4466,25 @@ Tab* create_tab(MainWindow * mw, Tab *copy_tab, // always show : not if(g_list_length(list)>1) gtk_notebook_set_show_tabs(notebook, TRUE); + if(copy_tab) { + lttvwindow_report_time_window(tab, copy_tab->time_window); + lttvwindow_report_current_time(tab, copy_tab->current_time); + } else { + TimeWindow time_window; + + time_window.start_time = ltt_time_zero; + time_window.end_time = ltt_time_add(time_window.start_time, + lttvwindow_default_time_width); + time_window.time_width = lttvwindow_default_time_width; + time_window.time_width_double = ltt_time_to_double(time_window.time_width); + + lttvwindow_report_time_window(tab, time_window); + lttvwindow_report_current_time(tab, ltt_time_zero); + } + + LttvTraceset *traceset = tab->traceset_info->traceset; + SetTraceset(tab, traceset); + return tab; }