+void
+on_button_move_down_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ move_down_viewer((GtkWidget*)button, user_data);
+}
+
+
+void
+on_button_delete_viewer_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ delete_viewer((GtkWidget*)button, user_data);
+}
+
+void
+on_MWindow_destroy (GtkWidget *widget,
+ gpointer user_data)
+{
+ MainWindow *main_window = get_window_data_struct(widget);
+ LttvIAttribute *attributes = main_window->attributes;
+ LttvAttributeValue value;
+
+ //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));
+ lttv_menus_destroy((LttvMenus*)*(value.v_pointer));
+
+ g_assert(lttv_iattribute_find_by_path(attributes,
+ "viewers/toolbar", LTTV_POINTER, &value));
+ lttv_toolbars_destroy((LttvToolbars*)*(value.v_pointer));
+
+ g_object_unref(main_window->attributes);
+ g_main_window_list = g_slist_remove(g_main_window_list, main_window);
+
+ g_info("There are now : %d windows\n",g_slist_length(g_main_window_list));
+ if(g_slist_length(g_main_window_list) == 0)
+ mainwindow_quit();
+}
+
+gboolean
+on_MWindow_configure (GtkWidget *widget,
+ GdkEventConfigure *event,
+ gpointer user_data)
+{
+ MainWindow * mw_data = get_window_data_struct((GtkWidget*)widget);
+
+ // MD : removed time width modification upon resizing of the main window.
+ // The viewers will redraw themselves completely, without time interval
+ // modification.
+/* while(tab){
+ if(mw_data->window_width){
+ time_span = LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context)->Time_Span ;
+ time_win = tab->time_window;
+ ratio = width / mw_data->window_width;
+ tab->time_window.time_width = ltt_time_mul(time_win.time_width,ratio);
+ time = ltt_time_sub(time_span->endTime, time_win.start_time);
+ if(ltt_time_compare(time, tab->time_window.time_width) < 0){
+ tab->time_window.time_width = time;
+ }
+ }
+ tab = tab->next;
+ }
+
+ mw_data->window_width = (int)width;
+ */
+ return FALSE;
+}
+
+/* Set current tab
+ */
+
+void
+on_MNotebook_switch_page (GtkNotebook *notebook,
+ GtkNotebookPage *page,
+ guint page_num,
+ gpointer user_data)
+{
+
+}
+
+
+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;
+
+ 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;
+ LttTime time_width = new_time_window.time_width;
+
+ 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);
+#if 0
+ gtk_range_set_increments(GTK_RANGE(tab->scrollbar),
+ ltt_time_to_double(new_time_window.time_width)
+ / SCROLL_STEP_PER_PAGE
+ * NANOSECONDS_PER_SECOND, /* step increment */
+ ltt_time_to_double(new_time_window.time_width)
+ * NANOSECONDS_PER_SECOND); /* page increment */
+ gtk_range_set_range(GTK_RANGE(tab->scrollbar),
+ 0.0, /* lower */
+ ltt_time_to_double(upper)
+ * NANOSECONDS_PER_SECOND); /* upper */
+#endif //0
+ g_object_set(G_OBJECT(adjustment),
+ "lower",
+ 0.0, /* lower */
+ "upper",
+ ltt_time_to_double(upper), /* upper */
+ "step_increment",
+ new_time_window.time_width_double
+ / SCROLL_STEP_PER_PAGE, /* step increment */
+ "page_increment",
+ new_time_window.time_width_double,
+ /* page increment */
+ "page_size",
+ new_time_window.time_width_double, /* page size */
+ NULL);
+ gtk_adjustment_changed(adjustment);
+
+ // g_object_set(G_OBJECT(adjustment),
+ // "value",
+ // ltt_time_to_double(
+ // ltt_time_sub(start_time, time_span.start_time))
+ // , /* value */
+ // NULL);
+ //gtk_adjustment_value_changed(adjustment);
+ gtk_range_set_value(GTK_RANGE(tab->scrollbar),
+ ltt_time_to_double(
+ ltt_time_sub(start_time, time_span.start_time)) /* value */);
+
+ /* set the time bar. */
+ /* start seconds */
+ gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry1),
+ (double)time_span.start_time.tv_sec,
+ (double)time_span.end_time.tv_sec);
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(tab->MEntry1),
+ (double)start_time.tv_sec);
+
+ /* start nanoseconds */
+ if(start_time.tv_sec == time_span.start_time.tv_sec) {
+ /* can be both beginning and end at the same time. */
+ if(start_time.tv_sec == time_span.end_time.tv_sec) {
+ /* If we are at the end, max nsec to end.. -1 (not zero length) */
+ gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry2),
+ (double)time_span.start_time.tv_nsec,
+ (double)time_span.end_time.tv_nsec-1);
+ } else {
+ gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry2),
+ (double)time_span.start_time.tv_nsec,
+ (double)NANOSECONDS_PER_SECOND-1);
+ }
+ } else if(start_time.tv_sec == time_span.end_time.tv_sec) {
+ /* If we are at the end, max nsec to end.. -1 (not zero length) */
+ gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry2),
+ 0.0,
+ (double)time_span.end_time.tv_nsec-1);
+ } else /* anywhere else */
+ gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry2),
+ 0.0,
+ (double)NANOSECONDS_PER_SECOND-1);
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(tab->MEntry2),
+ (double)start_time.tv_nsec);
+
+ /* end seconds */
+ gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry3),
+ (double)time_span.start_time.tv_sec,
+ (double)time_span.end_time.tv_sec);
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(tab->MEntry3),
+ (double)end_time.tv_sec);
+
+ /* end nanoseconds */
+ if(end_time.tv_sec == time_span.start_time.tv_sec) {
+ /* can be both beginning and end at the same time. */
+ if(end_time.tv_sec == time_span.end_time.tv_sec) {
+ /* If we are at the end, max nsec to end.. */
+ gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry4),
+ (double)time_span.start_time.tv_nsec+1,
+ (double)time_span.end_time.tv_nsec);
+ } else {
+ gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry4),
+ (double)time_span.start_time.tv_nsec+1,
+ (double)NANOSECONDS_PER_SECOND-1);
+ }
+ }
+ else if(end_time.tv_sec == time_span.end_time.tv_sec) {
+ /* If we are at the end, max nsec to end.. */
+ gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry4),
+ 0.0,
+ (double)time_span.end_time.tv_nsec);
+ }
+ else /* anywhere else */
+ gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry4),
+ 0.0,
+ (double)NANOSECONDS_PER_SECOND-1);
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(tab->MEntry4),
+ (double)end_time.tv_nsec);
+
+ /* width seconds */
+ gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry7),
+ (double)0,
+ (double)time_span.time_width.tv_sec);
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(tab->MEntry7),
+ (double)time_width.tv_sec);
+
+ /* width nanoseconds */
+ if(time_width.tv_sec == time_span.time_width.tv_sec) {
+ if(time_width.tv_sec == 0) {
+ gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry8),
+ (double)1,
+ (double)time_span.time_width.tv_nsec);
+ } else {
+ gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry8),
+ (double)0,
+ (double)time_span.time_width.tv_nsec);
+ }
+ }
+ else if(time_width.tv_sec == 0) {
+ gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry8),
+ 1.0,
+ (double)time_span.time_width.tv_nsec);
+ }
+ else /* anywhere else */
+ gtk_spin_button_set_range(GTK_SPIN_BUTTON(tab->MEntry8),
+ 0.0,
+ (double)NANOSECONDS_PER_SECOND-1);
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(tab->MEntry8),
+ (double)time_width.tv_nsec);
+
+ /* call viewer hooks for new time window */
+ set_time_window(tab, &new_time_window);
+
+ tab->time_manager_lock = FALSE;
+}
+
+
+/* value changed for frame start s
+ *
+ * Check time span : if ns is out of range, clip it the nearest good value.
+ */
+void
+on_MEntry1_value_changed (GtkSpinButton *spinbutton,
+ gpointer user_data)
+{
+ Tab *tab =(Tab *)user_data;
+ LttvTracesetContext * tsc =
+ LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context);
+ TimeInterval time_span = tsc->time_span;
+ gint value = gtk_spin_button_get_value_as_int(spinbutton);
+
+ TimeWindow new_time_window = tab->time_window;
+
+ LttTime end_time = new_time_window.end_time;
+
+ new_time_window.start_time.tv_sec = value;
+
+ /* start nanoseconds */
+ if(new_time_window.start_time.tv_sec == time_span.start_time.tv_sec) {
+ if(new_time_window.start_time.tv_sec == time_span.end_time.tv_sec) {
+ if(new_time_window.start_time.tv_nsec > time_span.end_time.tv_nsec)
+ new_time_window.start_time.tv_nsec = time_span.end_time.tv_nsec-1;
+ if(new_time_window.start_time.tv_nsec < time_span.start_time.tv_nsec)
+ new_time_window.start_time.tv_nsec = time_span.start_time.tv_nsec;
+ } else {
+ if(new_time_window.start_time.tv_nsec < time_span.start_time.tv_nsec)
+ new_time_window.start_time.tv_nsec = time_span.start_time.tv_nsec;
+ }
+ }
+ else if(new_time_window.start_time.tv_sec == time_span.end_time.tv_sec) {
+ if(new_time_window.start_time.tv_nsec > time_span.end_time.tv_nsec)
+ new_time_window.start_time.tv_nsec = time_span.end_time.tv_nsec-1;
+ }
+
+ if(ltt_time_compare(new_time_window.start_time, end_time) >= 0) {
+ /* Then, we must push back end time : keep the same time width
+ * if possible, else end traceset time */
+ end_time = LTT_TIME_MIN(ltt_time_add(new_time_window.start_time,
+ new_time_window.time_width),
+ time_span.end_time);
+ }
+
+ /* Fix the time width to fit start time and end time */
+ new_time_window.time_width = ltt_time_sub(end_time,
+ new_time_window.start_time);
+ new_time_window.time_width_double =
+ ltt_time_to_double(new_time_window.time_width);
+
+ new_time_window.end_time = end_time;
+
+ time_change_manager(tab, new_time_window);
+
+}
+
+void
+on_MEntry2_value_changed (GtkSpinButton *spinbutton,
+ gpointer user_data)
+{
+ Tab *tab =(Tab *)user_data;
+ LttvTracesetContext * tsc =
+ LTTV_TRACESET_CONTEXT(tab->traceset_info->traceset_context);
+ TimeInterval time_span = tsc->time_span;
+ gint value = gtk_spin_button_get_value_as_int(spinbutton);
+
+ TimeWindow new_time_window = tab->time_window;
+
+ LttTime end_time = new_time_window.end_time;
+
+ new_time_window.start_time.tv_nsec = value;
+
+ if(ltt_time_compare(new_time_window.start_time, end_time) >= 0) {
+ /* Then, we must push back end time : keep the same time width
+ * if possible, else end traceset time */
+ end_time = LTT_TIME_MIN(ltt_time_add(new_time_window.start_time,
+ new_time_window.time_width),
+ time_span.end_time);
+ }
+
+ /* Fix the time width to fit start time and end time */
+ new_time_window.time_width = ltt_time_sub(end_time,
+ new_time_window.start_time);
+ new_time_window.time_width_double =
+ ltt_time_to_double(new_time_window.time_width);
+
+ new_time_window.end_time = end_time;
+
+ time_change_manager(tab, new_time_window);