X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=lttv%2Fmodules%2Fgui%2Flttvwindow%2Flttvwindow%2Fcallbacks.c;h=122968887e4acd51a328314468085a2d27228f99;hb=ba01343213d0be590b9a567254f0f182304b7bf9;hp=0b5756e9a2d318ba609e9d5f889737deb7eb47e2;hpb=f61f4dca50e13aa52b1ca3941c8f420848f4353f;p=lttv.git diff --git a/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c b/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c index 0b5756e9..12296888 100644 --- a/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c +++ b/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -465,11 +466,66 @@ 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); - TimeInterval time_span = tsc->time_span; - TimeWindow new_time_window = tab->time_window; - LttTime new_current_time = tab->current_time; + LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context); + + // Perform time synchronization on the traces + if (syncTraceset(tsc)) + { + /* There is some time-dependant information that was calculated during + * context initialization. Destroy the old contexts and initialize new + * ones. + * Modified from lttvwindow_add_trace() + */ + // Keep a reference to the traces so they are not freed + for(i = 0; i < lttv_traceset_number(traceset); i++) + { + LttvTrace *trace = lttv_traceset_get(traceset, i); + lttv_trace_ref(trace); + } + + // Remove state update hooks + lttv_state_remove_event_hooks( + (LttvTracesetState*)tab->traceset_info->traceset_context); + + lttv_context_fini(LTTV_TRACESET_CONTEXT( + tab->traceset_info->traceset_context)); + g_object_unref(tab->traceset_info->traceset_context); + + for(i = 0; i < lttv_traceset_number(traceset); i++) + { + LttvTrace *trace = lttv_traceset_get(traceset, i); + lttvwindowtraces_remove_trace(trace); + lttvwindowtraces_add_trace(trace); + } + + // Create new context + tab->traceset_info->traceset_context = + g_object_new(LTTV_TRACESET_STATS_TYPE, NULL); + lttv_context_init(LTTV_TRACESET_CONTEXT(tab->traceset_info-> + traceset_context), traceset); + + // Add state update hooks + lttv_state_add_event_hooks( + (LttvTracesetState*)tab->traceset_info->traceset_context); + + // Remove local reference to the traces + for(i=0; itraceset_info->traceset_context); + } + + time_span = tsc->time_span; + new_time_window = tab->time_window; + new_current_time = tab->current_time; /* Set the tab's time window and current time if * out of bounds */ @@ -551,14 +607,16 @@ int SetTraceset(Tab * tab, LttvTraceset *traceset) LttvHooks * tmp; LttvAttributeValue value; gint retval = 0; - - g_assert( lttv_iattribute_find_by_path(tab->attributes, - "hooks/updatetraceset", LTTV_POINTER, &value)); + retval= lttv_iattribute_find_by_path(tab->attributes, + "hooks/updatetraceset", LTTV_POINTER, &value); + g_assert(retval); tmp = (LttvHooks*)*(value.v_pointer); - if(tmp == NULL) retval = 1; - else lttv_hooks_call(tmp,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); @@ -603,8 +661,11 @@ void update_traceset(Tab *tab) { LttvAttributeValue value; LttvHooks * tmp; - g_assert(lttv_iattribute_find_by_path(tab->attributes, - "hooks/updatetraceset", LTTV_POINTER, &value)); + gboolean retval; + + retval= lttv_iattribute_find_by_path(tab->attributes, + "hooks/updatetraceset", LTTV_POINTER, &value); + g_assert(retval); tmp = (LttvHooks*)*(value.v_pointer); if(tmp == NULL) return; lttv_hooks_call(tmp, NULL); @@ -1784,25 +1845,29 @@ void add_trace(GtkWidget * widget, gpointer user_data) tab = ptab->tab; } - //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)); - + /* File open dialog management */ + GtkFileChooser * file_chooser = + GTK_FILE_CHOOSER( + gtk_file_chooser_dialog_new ("Select a trace", + GTK_WINDOW(mw_data->mwindow), + GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, + NULL)); + + gtk_file_chooser_set_show_hidden (file_chooser, TRUE); if(remember_trace_dir[0] != '\0') - gtk_file_selection_set_filename(file_selector, remember_trace_dir); - - id = gtk_dialog_run(GTK_DIALOG(file_selector)); + gtk_file_chooser_set_filename(file_chooser, remember_trace_dir); + + id = gtk_dialog_run(GTK_DIALOG(file_chooser)); + switch(id){ case GTK_RESPONSE_ACCEPT: case GTK_RESPONSE_OK: - dir = gtk_file_selection_get_filename (file_selector); + dir = 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){ - gtk_widget_destroy((GtkWidget*)file_selector); break; } get_absolute_pathname(dir, abs_path); @@ -1832,7 +1897,6 @@ void add_trace(GtkWidget * widget, gpointer user_data) lttvwindow_add_trace(tab, trace_v); } - gtk_widget_destroy((GtkWidget*)file_selector); //update current tab //update_traceset(mw_data); @@ -1848,9 +1912,10 @@ void add_trace(GtkWidget * widget, gpointer user_data) case GTK_RESPONSE_REJECT: case GTK_RESPONSE_CANCEL: default: - gtk_widget_destroy((GtkWidget*)file_selector); - break; + break; } + gtk_widget_destroy((GtkWidget*)file_chooser); + } /* remove_trace removes a trace from the current traceset if all viewers in @@ -2100,6 +2165,8 @@ void redraw(GtkWidget *widget, gpointer user_data) GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook))); Tab *tab; + gboolean retval; + if(!page) { return; } else { @@ -2111,7 +2178,8 @@ void redraw(GtkWidget *widget, gpointer user_data) LttvHooks * tmp; LttvAttributeValue value; - g_assert(lttv_iattribute_find_by_path(tab->attributes, "hooks/redraw", LTTV_POINTER, &value)); + retval= lttv_iattribute_find_by_path(tab->attributes, "hooks/redraw", LTTV_POINTER, &value); + g_assert(retval); tmp = (LttvHooks*)*(value.v_pointer); if(tmp != NULL) @@ -2125,6 +2193,8 @@ void continue_processing(GtkWidget *widget, gpointer user_data) GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook))); Tab *tab; + gboolean retval; + if(!page) { return; } else { @@ -2136,8 +2206,9 @@ void continue_processing(GtkWidget *widget, gpointer user_data) LttvHooks * tmp; LttvAttributeValue value; - g_assert(lttv_iattribute_find_by_path(tab->attributes, - "hooks/continue", LTTV_POINTER, &value)); + retval= lttv_iattribute_find_by_path(tab->attributes, "hooks/continue", + LTTV_POINTER, &value); + g_assert(retval); tmp = (LttvHooks*)*(value.v_pointer); if(tmp != NULL) @@ -3307,17 +3378,20 @@ on_MWindow_destroy (GtkWidget *widget, MainWindow *main_window = get_window_data_struct(widget); LttvIAttribute *attributes = main_window->attributes; LttvAttributeValue value; + gboolean retval; //This is unnecessary, since widgets will be destroyed //by the main window widget anyway. //remove_all_menu_toolbar_constructors(main_window, NULL); - g_assert(lttv_iattribute_find_by_path(attributes, - "viewers/menu", LTTV_POINTER, &value)); + retval= lttv_iattribute_find_by_path(attributes, "viewers/menu", + LTTV_POINTER, &value); + g_assert(retval); lttv_menus_destroy((LttvMenus*)*(value.v_pointer)); - g_assert(lttv_iattribute_find_by_path(attributes, - "viewers/toolbar", LTTV_POINTER, &value)); + retval= lttv_iattribute_find_by_path(attributes, "viewers/toolbar", + LTTV_POINTER, &value); + g_assert(retval); lttv_toolbars_destroy((LttvToolbars*)*(value.v_pointer)); g_object_unref(main_window->attributes); @@ -3914,8 +3988,10 @@ void current_position_change_manager(Tab *tab, LttvTracesetContext *tsc = LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context); TimeInterval time_span = tsc->time_span; + int retval; - g_assert(lttv_process_traceset_seek_position(tsc, pos) == 0); + retval= lttv_process_traceset_seek_position(tsc, pos); + g_assert_cmpint(retval, ==, 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); @@ -4170,29 +4246,32 @@ void add_all_menu_toolbar_constructors(MainWindow * mw, gpointer user_data) LttvIAttribute *global_attributes = LTTV_IATTRIBUTE(lttv_global_attributes()); LttvIAttribute *attributes = mw->attributes; GtkWidget * tool_menu_title_menu, *new_widget, *pixmap; + gboolean retval; - g_assert(lttv_iattribute_find_by_path(global_attributes, - "viewers/menu", LTTV_POINTER, &value)); + retval= lttv_iattribute_find_by_path(global_attributes, "viewers/menu", + LTTV_POINTER, &value); + g_assert(retval); if(*(value.v_pointer) == NULL) *(value.v_pointer) = lttv_menus_new(); global_menu = (LttvMenus*)*(value.v_pointer); - g_assert(lttv_iattribute_find_by_path(attributes, - "viewers/menu", LTTV_POINTER, &value)); + retval= lttv_iattribute_find_by_path(attributes, "viewers/menu", + LTTV_POINTER, &value); + g_assert(retval); if(*(value.v_pointer) == NULL) *(value.v_pointer) = lttv_menus_new(); instance_menu = (LttvMenus*)*(value.v_pointer); - - - g_assert(lttv_iattribute_find_by_path(global_attributes, - "viewers/toolbar", LTTV_POINTER, &value)); + retval= lttv_iattribute_find_by_path(global_attributes, "viewers/toolbar", + LTTV_POINTER, &value); + g_assert(retval); if(*(value.v_pointer) == NULL) *(value.v_pointer) = lttv_toolbars_new(); global_toolbar = (LttvToolbars*)*(value.v_pointer); - g_assert(lttv_iattribute_find_by_path(attributes, - "viewers/toolbar", LTTV_POINTER, &value)); + retval= lttv_iattribute_find_by_path(attributes, "viewers/toolbar", + LTTV_POINTER, &value); + g_assert(retval); if(*(value.v_pointer) == NULL) *(value.v_pointer) = lttv_toolbars_new(); instance_toolbar = (LttvToolbars*)*(value.v_pointer); @@ -4262,6 +4341,8 @@ void add_all_menu_toolbar_constructors(MainWindow * mw, gpointer user_data) MainWindow *construct_main_window(MainWindow * parent) { + gboolean retval; + g_debug("construct_main_window()"); GtkWidget * new_window; /* New generated main window */ MainWindow * new_m_window;/* New main window structure */ @@ -4282,12 +4363,14 @@ MainWindow *construct_main_window(MainWindow * parent) new_m_window->mwindow = new_window; new_m_window->attributes = attributes; - g_assert(lttv_iattribute_find_by_path(attributes, - "viewers/menu", LTTV_POINTER, &value)); + retval= lttv_iattribute_find_by_path(attributes, "viewers/menu", + LTTV_POINTER, &value); + g_assert(retval); *(value.v_pointer) = lttv_menus_new(); - g_assert(lttv_iattribute_find_by_path(attributes, - "viewers/toolbar", LTTV_POINTER, &value)); + retval= lttv_iattribute_find_by_path(attributes, "viewers/toolbar", + LTTV_POINTER, &value); + g_assert(retval); *(value.v_pointer) = lttv_toolbars_new(); add_all_menu_toolbar_constructors(new_m_window, NULL);