+/* This file is part of the Linux Trace Toolkit viewer
+ * Copyright (C) 2003-2004 XangXiu Yang
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License Version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ */
+
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "callbacks.h"
#include "interface.h"
#include "support.h"
-#include <lttv/mainWindow.h>
+#include <lttv/mainwindow.h>
#include <lttv/menu.h>
#include <lttv/toolbar.h>
-#include <lttv/gtkTraceSet.h>
+#include <lttv/gtktraceset.h>
#include <lttv/module.h>
#include <lttv/gtkdirsel.h>
#include <lttv/iattribute.h>
strcpy(label,gtk_entry_get_text(entry));
}
-void get_label(MainWindow * mw, gchar * str, gchar* dialogue_title, gchar * label_str)
+gboolean get_label(MainWindow * mw, gchar * str, gchar* dialogue_title, gchar * label_str)
{
GtkWidget * dialogue;
GtkWidget * text;
case GTK_RESPONSE_REJECT:
default:
gtk_widget_destroy(dialogue);
- break;
+ return FALSE;
}
+ return TRUE;
}
MainWindow * get_window_data_struct(GtkWidget * widget)
case GTK_RESPONSE_ACCEPT:
case GTK_RESPONSE_OK:
dir = gtk_dir_selection_get_dir (file_selector);
+ if(!dir || strlen(dir) ==0){
+ gtk_widget_destroy((GtkWidget*)file_selector);
+ break;
+ }
trace = ltt_trace_open(dir);
if(trace == NULL) g_critical("cannot open trace %s", dir);
trace_v = lttv_trace_new(trace);
//update current tab
update_traceset(mw_data);
+
+ get_traceset_time_span(mw_data,LTTV_TRACESET_CONTEXT(mw_data->current_tab->traceset_info->traceset_context)->Time_Span);
+ if(lttv_traceset_number(mw_data->current_tab->traceset_info->traceset) == 1 ||
+ ltt_time_compare(mw_data->current_tab->current_time,
+ LTTV_TRACESET_CONTEXT(mw_data->current_tab->traceset_info->traceset_context)->Time_Span->startTime)<0){
+ mw_data->current_tab->current_time =
+ LTTV_TRACESET_CONTEXT(mw_data->current_tab->traceset_info->traceset_context)->Time_Span->startTime;
+ mw_data->current_tab->time_window.start_time = mw_data->current_tab->current_time;
+ mw_data->current_tab->time_window.time_width.tv_sec = DEFAULT_TIME_WIDTH_S;
+ mw_data->current_tab->time_window.time_width.tv_nsec = 0;
+ }
+
redraw_viewer(mw_data, &(mw_data->current_tab->time_window));
set_current_time(mw_data,&(mw_data->current_tab->current_time));
break;
if(strcmp(remove_trace_name,name[i]) == 0){
//unselect the trace from the current viewer
w = gtk_multi_vpaned_get_widget(mw_data->current_tab->multi_vpaned);
- s = g_object_get_data(G_OBJECT(w), "Traceset_Selector");
- t = lttv_traceset_selector_trace_get(s,i);
- lttv_trace_selector_set_selected(t, FALSE);
-
- //check if other viewers select the trace
- w = gtk_multi_vpaned_get_first_widget(mw_data->current_tab->multi_vpaned);
- while(w){
+ if(w){
s = g_object_get_data(G_OBJECT(w), "Traceset_Selector");
t = lttv_traceset_selector_trace_get(s,i);
- selected = lttv_trace_selector_get_selected(t);
- if(selected)break;
- w = gtk_multi_vpaned_get_next_widget(mw_data->current_tab->multi_vpaned);
- }
+ lttv_trace_selector_set_selected(t, FALSE);
+
+ //check if other viewers select the trace
+ w = gtk_multi_vpaned_get_first_widget(mw_data->current_tab->multi_vpaned);
+ while(w){
+ s = g_object_get_data(G_OBJECT(w), "Traceset_Selector");
+ t = lttv_traceset_selector_trace_get(s,i);
+ selected = lttv_trace_selector_get_selected(t);
+ if(selected)break;
+ w = gtk_multi_vpaned_get_next_widget(mw_data->current_tab->multi_vpaned);
+ }
+ }else selected = FALSE;
//if no viewer selects the trace, remove it
if(!selected){
g_object_unref(mw_data->current_tab->traceset_info->traceset_context);
}
lttv_traceset_remove(traceset, i);
- lttv_trace_destroy(trace_v);
+ if(!lttv_trace_get_ref_number(trace_v))
+ lttv_trace_destroy(trace_v);
mw_data->current_tab->traceset_info->traceset_context =
g_object_new(LTTV_TRACESET_STATS_TYPE, NULL);
lttv_context_init(
traceset_info->traceset_context),traceset);
//update current tab
update_traceset(mw_data);
- redraw_viewer(mw_data, &(mw_data->current_tab->time_window));
- set_current_time(mw_data,&(mw_data->current_tab->current_time));
+ if(nb_trace > 1){
+ redraw_viewer(mw_data, &(mw_data->current_tab->time_window));
+ set_current_time(mw_data,&(mw_data->current_tab->current_time));
+ }else{
+ if(mw_data->current_tab){
+ while(mw_data->current_tab->multi_vpaned->num_children){
+ gtk_multi_vpaned_widget_delete(mw_data->current_tab->multi_vpaned);
+ }
+ }
+ }
}
break;
}
create_new_window((GtkWidget*)menuitem, user_data, TRUE);
}
-
-void
-on_tab_activate (GtkMenuItem *menuitem,
- gpointer user_data)
-{
+void create_new_tab(GtkWidget* widget, gpointer user_data){
gchar label[PATH_LENGTH];
- MainWindow * mw_data = get_window_data_struct((GtkWidget*)menuitem);
- GtkNotebook * notebook = (GtkNotebook *)lookup_widget((GtkWidget*)menuitem, "MNotebook");
+ MainWindow * mw_data = get_window_data_struct(widget);
+ GtkNotebook * notebook = (GtkNotebook *)lookup_widget(widget, "MNotebook");
if(notebook == NULL){
g_printf("Notebook does not exist\n");
return;
}
strcpy(label,"Page");
- get_label(mw_data, label,"Get the name of the tab","Please input tab's name");
+ if(get_label(mw_data, label,"Get the name of the tab","Please input tab's name"))
+ create_tab (mw_data, mw_data, notebook, label);
+}
- create_tab (mw_data, mw_data, notebook, label);
+void
+on_tab_activate (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ create_new_tab((GtkWidget*)menuitem, user_data);
}
on_button_new_clicked (GtkButton *button,
gpointer user_data)
{
- create_new_window((GtkWidget*)button, user_data, FALSE);
+ create_new_window((GtkWidget*)button, user_data, TRUE);
}
+void
+on_button_new_tab_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ create_new_tab((GtkWidget*)button, user_data);
+}
void
on_button_open_clicked (GtkButton *button,
on_MWindow_destroy (GtkObject *object,
gpointer user_data)
{
- MainWindow *Main_Window = (MainWindow*)user_data;
-
+ MainWindow *Main_Window = get_window_data_struct((GtkWidget*)object);
+ GtkWidget *widget;
+ Tab *tab = Main_Window->tab;
+
g_printf("There are : %d windows\n",g_slist_length(g_main_window_list));
+ while(tab){
+ while(tab->multi_vpaned->num_children){
+ gtk_multi_vpaned_widget_delete(tab->multi_vpaned);
+ }
+ tab = tab->next;
+ }
+
g_win_count--;
if(g_win_count == 0)
gtk_main_quit ();
}
//for now there is no name field in LttvTraceset structure
//Use "Traceset" as the label for the default tab
- create_tab(NULL, new_m_window, notebook,"Traceset");
+ create_tab(parent, new_m_window, notebook,"Traceset");
g_object_set_data_full(
G_OBJECT(new_m_window->mwindow),
ref_count = lttv_trace_get_ref_number(trace);
if(ref_count <= 1){
ltt_trace_close(lttv_trace(trace));
+ lttv_trace_destroy(trace);
}
- lttv_trace_destroy(trace);
+ // lttv_trace_destroy(trace);
}
}
lttv_traceset_destroy(tab_instance->traceset_info->traceset);