X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttv%2Fmodules%2Fgui%2Flttvwindow%2Flttvwindow%2Fcallbacks.c;h=c101c9c6c792d2624db211943c42fca489ab98c6;hb=c8bba5fa123e79c25c3ed0f6355f511ed84b88b2;hp=e121714437dd6fe936640b8109ea7004103a5bf3;hpb=84ddf5c933843f7b313a6dc4347ea6b5fb834557;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 e1217144..c101c9c6 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c @@ -238,31 +238,38 @@ void insert_viewer(GtkWidget* widget, lttvwindow_viewer_constructor constructor) 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)); - - tmp = (LttvHooks*)*(value.v_pointer); - if(tmp == NULL) retval = 1; - else lttv_hooks_call(tmp,traceset); - - - /* Set scrollbar */ LttvTracesetContext *tsc = LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context); TimeInterval time_span = tsc->time_span; + + /* 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 + || ltt_time_compare( ltt_time_add(tab->time_window.start_time, + tab->time_window.time_width), + time_span.end_time) > 0) { + tab->time_window.start_time = time_span.start_time; + tab->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; + else + tmp_time.tv_sec = time_span.end_time.tv_sec; + tmp_time.tv_nsec = 0; + tab->time_window.time_width = tmp_time ; + } + + /* 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); g_object_set(G_OBJECT(adjustment), "lower", - ltt_time_to_double(time_span.start_time) - * NANOSECONDS_PER_SECOND, /* lower */ + 0.0, /* lower */ "upper", - ltt_time_to_double(time_span.end_time) + ltt_time_to_double(upper) * NANOSECONDS_PER_SECOND, /* upper */ "step_increment", ltt_time_to_double(tab->time_window.time_width) @@ -279,11 +286,26 @@ int SetTraceset(Tab * tab, LttvTraceset *traceset) g_object_set(G_OBJECT(adjustment), "value", - ltt_time_to_double(tab->time_window.start_time) - * NANOSECONDS_PER_SECOND, /* value */ + ltt_time_to_double( + ltt_time_sub(tab->time_window.start_time, time_span.start_time)) + * NANOSECONDS_PER_SECOND, /* value */ NULL); gtk_adjustment_value_changed(adjustment); - + + /* Finally, call the update hooks of the viewers */ + LttvHooks * tmp; + LttvAttributeValue value; + gint retval = 0; + + + g_assert( lttv_iattribute_find_by_path(tab->attributes, + "hooks/updatetraceset", LTTV_POINTER, &value)); + + tmp = (LttvHooks*)*(value.v_pointer); + if(tmp == NULL) retval = 1; + else lttv_hooks_call(tmp,traceset); + + return retval; } @@ -740,10 +762,13 @@ gboolean lttvwindow_process_pending_requests(Tab *tab) /* Events processing algorithm implementation */ + /* Warning : the gtk_events_pending takes a LOT of cpu time. So what we do + * instead is to leave the control to GTK and take it back. + */ /* A. Servicing loop */ - while( (g_slist_length(list_in) != 0 || g_slist_length(list_out) != 0)) { - /* && !gtk_events_pending() ) */ - + //while( (g_slist_length(list_in) != 0 || g_slist_length(list_out) != 0)) { + if((g_slist_length(list_in) != 0 || g_slist_length(list_out) != 0)) { + /* Servicing */ /* 1. If list_in is empty (need a seek) */ if( g_slist_length(list_in) == 0 ) { @@ -1011,7 +1036,7 @@ gboolean lttvwindow_process_pending_requests(Tab *tab) events_request->event, events_request->event_by_id); } - + /* Go to next */ if(remove) { @@ -1113,8 +1138,11 @@ gboolean lttvwindow_process_pending_requests(Tab *tab) count = lttv_process_traceset_middle(tsc, end_time, end_nb_events, end_position); tfc = lttv_traceset_context_get_current_tfc(tsc); - g_debug("Context time after middle : %lu, %lu", tfc->timestamp.tv_sec, + if(tfc != NULL) + g_debug("Context time after middle : %lu, %lu", tfc->timestamp.tv_sec, tfc->timestamp.tv_nsec); + else + g_debug("End of trace reached after middle."); } { @@ -1231,9 +1259,10 @@ gboolean lttvwindow_process_pending_requests(Tab *tab) } } } - - if(gtk_events_pending()) break; } + /* End of removed servicing loop : leave control to GTK instead. */ + // if(gtk_events_pending()) break; + //} /* B. When interrupted between chunks */ @@ -1420,36 +1449,7 @@ static void lttvwindow_add_trace(Tab *tab, LttvTrace *trace_v) traceset_context), traceset); - /* Set the tab's time window and current time if - * out of bounds */ - TimeInterval time_span = - LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context)->time_span; - if(ltt_time_compare(tab->time_window.start_time, time_span.start_time) < 0 - || ltt_time_compare( ltt_time_add(tab->time_window.start_time, - tab->time_window.time_width), - time_span.end_time) > 0) { - tab->time_window.start_time = - LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context)-> - time_span.start_time; - tab->current_time = - LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context)-> - time_span.start_time; - - LttTime tmp_time; - if(DEFAULT_TIME_WIDTH_S < - LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context)-> - time_span.end_time.tv_sec) - tmp_time.tv_sec = DEFAULT_TIME_WIDTH_S; - else - tmp_time.tv_sec = - LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context)-> - time_span.end_time.tv_sec; - tmp_time.tv_nsec = 0; - tab->time_window.time_width = tmp_time ; - - } - //add state update hooks lttv_state_add_event_hooks( (LttvTracesetState*)tab->traceset_info->traceset_context); @@ -1634,17 +1634,18 @@ void remove_trace(GtkWidget *widget, gpointer user_data) trace_v = lttv_traceset_get(traceset, index); - if(lttv_trace_get_ref_number(trace_v) <= 2) { - /* ref 2 : traceset, local */ - lttvwindowtraces_remove_trace(trace_v); - ltt_trace_close(lttv_trace(trace_v)); - } - lttv_traceset_remove(traceset, index); lttv_trace_unref(trace_v); // Remove local reference - if(!lttv_trace_get_ref_number(trace_v)) - lttv_trace_destroy(trace_v); + if(lttv_trace_get_ref_number(trace_v) <= 1) { + /* ref 1 : lttvwindowtraces only*/ + ltt_trace_close(lttv_trace(trace_v)); + /* lttvwindowtraces_remove_trace takes care of destroying + * the traceset linked with the trace_v and also of destroying + * the trace_v at the same time. + */ + lttvwindowtraces_remove_trace(trace_v); + } tab->traceset_info->traceset_context = g_object_new(LTTV_TRACESET_STATS_TYPE, NULL); @@ -1988,15 +1989,15 @@ void zoom(GtkWidget * widget, double size) // // + LttTime rel_time = + ltt_time_sub(new_time_window.start_time, time_span.start_time); if( ltt_time_to_double(new_time_window.time_width) * NANOSECONDS_PER_SECOND / SCROLL_STEP_PER_PAGE/* step increment */ + - ltt_time_to_double(new_time_window.start_time) - * NANOSECONDS_PER_SECOND /* page size */ + ltt_time_to_double(rel_time) * NANOSECONDS_PER_SECOND /* page size */ == - ltt_time_to_double(new_time_window.start_time) - * NANOSECONDS_PER_SECOND /* page size */ + ltt_time_to_double(rel_time) * NANOSECONDS_PER_SECOND /* page size */ ) { g_warning("Can not zoom that far due to scrollbar precision"); } else if( @@ -2016,10 +2017,10 @@ void zoom(GtkWidget * widget, double size) //ltt_time_to_double(new_time_window.start_time) // * NANOSECONDS_PER_SECOND, /* value */ "lower", - ltt_time_to_double(time_span.start_time) - * NANOSECONDS_PER_SECOND, /* lower */ + 0.0, /* lower */ "upper", - ltt_time_to_double(time_span.end_time) + ltt_time_to_double( + ltt_time_sub(time_span.end_time, time_span.start_time)) * NANOSECONDS_PER_SECOND, /* upper */ "step_increment", ltt_time_to_double(new_time_window.time_width) @@ -2037,7 +2038,8 @@ void zoom(GtkWidget * widget, double size) //gtk_adjustment_value_changed(adjustment); g_object_set(G_OBJECT(adjustment), "value", - ltt_time_to_double(new_time_window.start_time) + ltt_time_to_double( + ltt_time_sub(new_time_window.start_time, time_span.start_time)) * NANOSECONDS_PER_SECOND, /* value */ NULL); gtk_adjustment_value_changed(adjustment); @@ -2855,11 +2857,90 @@ on_content_activate (GtkMenuItem *menuitem, } +static void +on_about_close_activate (GtkButton *button, + gpointer user_data) +{ + GtkWidget *about_widget = GTK_WIDGET(user_data); + + gtk_widget_destroy(about_widget); +} + void on_about_activate (GtkMenuItem *menuitem, gpointer user_data) { - g_printf("About...\n"); + MainWindow *main_window = get_window_data_struct(GTK_WIDGET(menuitem)); + GtkWidget *window_widget = main_window->mwindow; + GtkWidget *about_widget = gtk_window_new(GTK_WINDOW_TOPLEVEL); + GtkWindow *about_window = GTK_WINDOW(about_widget); + gint window_width, window_height; + + gtk_window_set_title(about_window, "About Linux Trace Toolkit"); + + gtk_window_set_resizable(about_window, FALSE); + gtk_window_set_transient_for(GTK_WINDOW(window_widget), about_window); + gtk_window_set_destroy_with_parent(about_window, TRUE); + gtk_window_set_modal(about_window, FALSE); + + /* Put the about window at the center of the screen */ + gtk_window_get_size(about_window, &window_width, &window_height); + gtk_window_move (about_window, + (gdk_screen_width() - window_width)/2, + (gdk_screen_height() - window_height)/2); + + GtkWidget *vbox = gtk_vbox_new(FALSE, 1); + + gtk_container_add(GTK_CONTAINER(about_widget), vbox); + + + /* Text to show */ + GtkWidget *label1 = gtk_label_new(""); + gtk_misc_set_padding(GTK_MISC(label1), 10, 20); + gtk_label_set_markup(GTK_LABEL(label1), "\ +Linux Trace Toolkit"); + gtk_label_set_justify(GTK_LABEL(label1), GTK_JUSTIFY_CENTER); + + GtkWidget *label2 = gtk_label_new(""); + gtk_misc_set_padding(GTK_MISC(label2), 10, 20); + gtk_label_set_markup(GTK_LABEL(label2), "\ +Project author: Karim Yaghmour\n\ +\n\ +Contributors :\n\ +\n\ +Michel Dagenais (New trace format, lttv main)\n\ +Mathieu Desnoyers (Directory structure, build with automake/conf,\n\ + lttv gui, control flow view, gui green threads\n\ + with interruptible foreground and background computation,\n\ + detailed event list)\n\ +Benoit Des Ligneris (Cluster adaptation)\n\ +Xang-Xiu Yang (new trace reading library and converter, lttv gui, \n\ + detailed event list and statistics view)\n\ +Tom Zanussi (RelayFS)"); + + GtkWidget *label3 = gtk_label_new(""); + gtk_label_set_markup(GTK_LABEL(label3), "\ +Linux Trace Toolkit, Copyright (C) 2004 Karim Yaghmour\n\ +Linux Trace Toolkit comes with ABSOLUTELY NO WARRANTY.\n\ +This is free software, and you are welcome to redistribute it\n\ +under certain conditions. See COPYING for details."); + gtk_misc_set_padding(GTK_MISC(label3), 10, 20); + + gtk_box_pack_start_defaults(GTK_BOX(vbox), label1); + gtk_box_pack_start_defaults(GTK_BOX(vbox), label2); + gtk_box_pack_start_defaults(GTK_BOX(vbox), label3); + + GtkWidget *hbox = gtk_hbox_new(TRUE, 0); + gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); + GtkWidget *close_button = gtk_button_new_with_mnemonic("_Close"); + gtk_box_pack_end(GTK_BOX(hbox), close_button, FALSE, FALSE, 0); + gtk_container_set_border_width(GTK_CONTAINER(close_button), 20); + + g_signal_connect(G_OBJECT(close_button), "clicked", + G_CALLBACK(on_about_close_activate), + (gpointer)about_widget); + + gtk_widget_show_all(about_widget); } @@ -3082,17 +3163,16 @@ void scroll_value_changed_cb(GtkWidget *scrollbar, { Tab *tab = (Tab *)user_data; TimeWindow time_window; - TimeInterval *time_span; LttTime time; GtkAdjustment *adjust = gtk_range_get_adjustment(GTK_RANGE(scrollbar)); gdouble value = gtk_adjustment_get_value(adjust); gdouble upper, lower, ratio, page_size; LttvTracesetContext * tsc = LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context); + TimeInterval time_span = tsc->time_span; //time_window = tab->time_window; - time_span = &tsc->time_span ; lower = adjust->lower; upper = adjust->upper; ratio = (value - lower) / (upper - lower); @@ -3101,7 +3181,8 @@ void scroll_value_changed_cb(GtkWidget *scrollbar, //time = ltt_time_sub(time_span->end_time, time_span->start_time); //time = ltt_time_mul(time, (float)ratio); //time = ltt_time_add(time_span->start_time, time); - time = ltt_time_from_double(value/NANOSECONDS_PER_SECOND); + time = ltt_time_add(ltt_time_from_double(value/NANOSECONDS_PER_SECOND), + time_span.start_time); time_window.start_time = time; @@ -3109,7 +3190,7 @@ void scroll_value_changed_cb(GtkWidget *scrollbar, time_window.time_width = ltt_time_from_double(page_size/NANOSECONDS_PER_SECOND); - //time = ltt_time_sub(time_span->end_time, time); + //time = ltt_time_sub(time_span.end_time, time); //if(ltt_time_compare(time,time_window.time_width) < 0){ // time_window.time_width = time; //} @@ -3756,8 +3837,8 @@ Tab* create_tab(MainWindow * mw, Tab *copy_tab, tab->attributes = LTTV_IATTRIBUTE(g_object_new(LTTV_ATTRIBUTE_TYPE, NULL)); tab->interrupted_state = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL); - tab->vbox = gtk_vbox_new(FALSE, 0); - tab->viewer_container = gtk_vbox_new(TRUE, 0); + tab->vbox = gtk_vbox_new(FALSE, 2); + tab->viewer_container = gtk_vbox_new(TRUE, 2); tab->scrollbar = gtk_hscrollbar_new(NULL); //tab->multivpaned = gtk_multi_vpaned_new();