authors in about
[lttv.git] / ltt / branches / poly / lttv / modules / gui / lttvwindow / lttvwindow / callbacks.c
index 41b0a0fc48b3de5e6b98af9ebfa720d5833d075a..c101c9c6c792d2624db211943c42fca489ab98c6 100644 (file)
@@ -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",
-                 0, /* lower */
+                 0.0, /* lower */
                "upper",
-               ltt_time_to_double(
-                   ltt_time_sub(time_span.end_time, time_span.start_time)) 
+               ltt_time_to_double(upper) 
                  * NANOSECONDS_PER_SECOND, /* upper */
                "step_increment",
                ltt_time_to_double(tab->time_window.time_width)
@@ -284,7 +291,21 @@ int SetTraceset(Tab * tab, LttvTraceset *traceset)
                    * 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;
 }
 
@@ -1428,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);
@@ -1642,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);
@@ -1996,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(
@@ -2024,7 +2017,7 @@ void zoom(GtkWidget * widget, double size)
                  //ltt_time_to_double(new_time_window.start_time) 
                  //  * NANOSECONDS_PER_SECOND, /* value */
                  "lower",
-                   0, /* lower */
+                   0.0, /* lower */
                  "upper",
                  ltt_time_to_double(
                    ltt_time_sub(time_span.end_time, time_span.start_time))
@@ -2864,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), "\
+<big>Linux Trace Toolkit</big>");
+  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);
 }
 
 
This page took 0.024669 seconds and 4 git commands to generate.