+/* 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 <gtk/gtk.h>
-#include <gmodule.h>
#include "callbacks.h"
#include "interface.h"
#include "support.h"
-#include <lttv/mainWindow.h>
+#include <lttv/lttv.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>
static int g_win_count = 0;
+// MD : keep old directory
+static char remember_dir[PATH_LENGTH] = "";
+
+
MainWindow * get_window_data_struct(GtkWidget * widget);
char * get_unload_module(char ** loaded_module_name, int nb_module);
char * get_remove_trace(char ** all_trace_name, int nb_trace);
N_COLUMNS
};
+/* Construct a selector(filter), which will be associated with a viewer,
+ * and provides an interface for user to select interested events and traces
+ */
LttvTracesetSelector * construct_traceset_selector(LttvTraceset * traceset)
{
return s;
}
+
+/* insert_viewer function constructs an instance of a viewer first,
+ * then inserts the widget of the instance into the container of the
+ * main window
+ */
+
void
insert_viewer_wrap(GtkWidget *menuitem, gpointer user_data)
{
}
}
+
+/* get_label function is used to get user input, it displays an input
+ * box, which allows user to input a string
+ */
+
void get_label_string (GtkWidget * text, gchar * label)
{
GtkEntry * entry = (GtkEntry*)text;
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;
}
+
+/* get_window_data_struct function is actually a lookup function,
+ * given a widget which is in the tree of the main window, it will
+ * return the MainWindow data structure associated with main window
+ */
+
MainWindow * get_window_data_struct(GtkWidget * widget)
{
GtkWidget * mw;
return mw_data;
}
+
+/* create_new_window function, just constructs a new main window
+ */
+
void create_new_window(GtkWidget* widget, gpointer user_data, gboolean clone)
{
MainWindow * parent = get_window_data_struct(widget);
if(clone){
g_printf("Clone : use the same traceset\n");
- construct_main_window(parent, NULL);
+ construct_main_window(parent);
}else{
g_printf("Empty : traceset is set to NULL\n");
- construct_main_window(NULL, parent->win_creation_data);
+ construct_main_window(NULL);
}
}
+
+/* move_*_viewer functions move the selected view up/down in
+ * the current tab
+ */
+
void move_up_viewer(GtkWidget * widget, gpointer user_data)
{
MainWindow * mw = get_window_data_struct(widget);
gtk_multi_vpaned_widget_move_down(mw->current_tab->multi_vpaned);
}
+
+/* delete_viewer deletes the selected viewer in the current tab
+ */
+
void delete_viewer(GtkWidget * widget, gpointer user_data)
{
MainWindow * mw = get_window_data_struct(widget);
gtk_multi_vpaned_widget_delete(mw->current_tab->multi_vpaned);
}
+
+/* open_traceset will open a traceset saved in a file
+ * Right now, it is not finished yet, (not working)
+ */
+
void open_traceset(GtkWidget * widget, gpointer user_data)
{
char ** dir;
}
+
+/* get_max_event_number returns the event number limit used by
+ * lttv_process_traceset(LttvTracesetContext, endTime, maxNumEvents)
+ * each viewer can set the limit
+ */
+
unsigned get_max_event_number(MainWindow * mw_data)
{
unsigned nb = 0, *size;
return nb;
}
+
+/* redraw_viewer parses the traceset first by calling
+ * process_traceset_api, then display all viewers of
+ * the current tab
+ */
+
void redraw_viewer(MainWindow * mw_data, TimeWindow * time_window)
{
unsigned max_nb_events;
GdkCursor * new;
GtkWidget* widget;
+ //set the cursor to be X shape, indicating that the computer is busy in doing its job
new = gdk_cursor_new(GDK_X_CURSOR);
- widget = lookup_widget(mw_data->mwindow, "MToolbar2");
+ widget = lookup_widget(mw_data->mwindow, "MToolbar1");
win = gtk_widget_get_parent_window(widget);
gdk_window_set_cursor(win, new);
gdk_cursor_unref(new);
//call hooks to show each viewer and let them remove hooks
show_viewer(mw_data);
+ //set the cursor back to normal
gdk_window_set_cursor(win, NULL);
}
+
+/* add_trace_into_traceset_selector, each instance of a viewer has an associated
+ * selector (filter), when a trace is added into traceset, the selector should
+ * reflect the change. The function is used to update the selector
+ */
+
void add_trace_into_traceset_selector(GtkMultiVPaned * paned, LttTrace * t)
{
int j, k, m, nb_tracefile, nb_control, nb_per_cpu, nb_facility, nb_event;
w = gtk_multi_vpaned_get_first_widget(paned);
while(w){
s = g_object_get_data(G_OBJECT(w), "Traceset_Selector");
-
- trace = lttv_trace_selector_new(t);
- lttv_traceset_selector_trace_add(s, trace);
-
- nb_facility = ltt_trace_facility_number(t);
- for(k=0;k<nb_facility;k++){
- fac = ltt_trace_facility_get(t,k);
- nb_event = (int) ltt_facility_eventtype_number(fac);
- for(m=0;m<nb_event;m++){
- et = ltt_facility_eventtype_get(fac,m);
- eventtype = lttv_eventtype_selector_new(et);
- lttv_trace_selector_eventtype_add(trace, eventtype);
- }
- }
-
- nb_control = ltt_trace_control_tracefile_number(t);
- nb_per_cpu = ltt_trace_per_cpu_tracefile_number(t);
- nb_tracefile = nb_control + nb_per_cpu;
- for(j = 0 ; j < nb_tracefile ; j++) {
- if(j < nb_control)
- tf = ltt_trace_control_tracefile_get(t, j);
- else
- tf = ltt_trace_per_cpu_tracefile_get(t, j - nb_control);
- tracefile = lttv_tracefile_selector_new(tf);
- lttv_trace_selector_tracefile_add(trace, tracefile);
- lttv_eventtype_selector_copy(trace, tracefile);
- }
+ if(s){
+ trace = lttv_trace_selector_new(t);
+ lttv_traceset_selector_trace_add(s, trace);
+
+ nb_facility = ltt_trace_facility_number(t);
+ for(k=0;k<nb_facility;k++){
+ fac = ltt_trace_facility_get(t,k);
+ nb_event = (int) ltt_facility_eventtype_number(fac);
+ for(m=0;m<nb_event;m++){
+ et = ltt_facility_eventtype_get(fac,m);
+ eventtype = lttv_eventtype_selector_new(et);
+ lttv_trace_selector_eventtype_add(trace, eventtype);
+ }
+ }
+
+ nb_control = ltt_trace_control_tracefile_number(t);
+ nb_per_cpu = ltt_trace_per_cpu_tracefile_number(t);
+ nb_tracefile = nb_control + nb_per_cpu;
+
+ for(j = 0 ; j < nb_tracefile ; j++) {
+ if(j < nb_control)
+ tf = ltt_trace_control_tracefile_get(t, j);
+ else
+ tf = ltt_trace_per_cpu_tracefile_get(t, j - nb_control);
+ tracefile = lttv_tracefile_selector_new(tf);
+ lttv_trace_selector_tracefile_add(trace, tracefile);
+ lttv_eventtype_selector_copy(trace, tracefile);
+ }
+ }else g_warning("Module does not support filtering\n");
w = gtk_multi_vpaned_get_next_widget(paned);
}
}
+
+/* add_trace adds a trace into the current traceset. It first displays a
+ * directory selection dialogue to let user choose a trace, then recreates
+ * tracset_context, and redraws all the viewer of the current tab
+ */
+
void add_trace(GtkWidget * widget, gpointer user_data)
{
LttTrace *trace;
LttvTrace * trace_v;
LttvTraceset * traceset;
- char * dir;
+ const char * dir;
gint id;
MainWindow * mw_data = get_window_data_struct(widget);
GtkDirSelection * file_selector = (GtkDirSelection *)gtk_dir_selection_new("Select a trace");
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;
}
}
+
+/* remove_trace_into_traceset_selector, each instance of a viewer has an associated
+ * selector (filter), when a trace is remove from traceset, the selector should
+ * reflect the change. The function is used to update the selector
+ */
+
void remove_trace_from_traceset_selector(GtkMultiVPaned * paned, unsigned i)
{
LttvTracesetSelector * s;
w = gtk_multi_vpaned_get_first_widget(paned);
while(w){
s = g_object_get_data(G_OBJECT(w), "Traceset_Selector");
- t = lttv_traceset_selector_trace_get(s,i);
- lttv_traceset_selector_trace_remove(s, i);
- lttv_trace_selector_destroy(t);
+ if(s){
+ t = lttv_traceset_selector_trace_get(s,i);
+ lttv_traceset_selector_trace_remove(s, i);
+ lttv_trace_selector_destroy(t);
+ }g_warning("Module dose not support filtering\n");
w = gtk_multi_vpaned_get_next_widget(paned);
}
}
+
+/* remove_trace removes a trace from the current traceset if all viewers in
+ * the current tab are not interested in the trace. It first displays a
+ * dialogue, which shows all traces in the current traceset, to let user choose
+ * a trace, then it checks if all viewers unselect the trace, if it is true,
+ * it will remove the trace, recreate the traceset_contex,
+ * and redraws all the viewer of the current tab. If there is on trace in the
+ * current traceset, it will delete all viewers of the current tab
+ */
+
void remove_trace(GtkWidget * widget, gpointer user_data)
{
LttTrace *trace;
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);
- }
+ if(s){
+ 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){
+ s = g_object_get_data(G_OBJECT(w), "Traceset_Selector");
+ if(s){
+ 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;
}
g_free(name);
}
+
+/* save will save the traceset to a file
+ * Not implemented yet
+ */
+
void save(GtkWidget * widget, gpointer user_data)
{
g_printf("Save\n");
g_printf("Save as\n");
}
+
+/* zoom will change the time_window of all the viewers of the
+ * current tab, and redisplay them. The main functionality is to
+ * determine the new time_window of the current tab
+ */
+
void zoom(GtkWidget * widget, double size)
{
TimeInterval *time_span;
}
-void
-on_tab_activate (GtkMenuItem *menuitem,
- gpointer user_data)
-{
+/* create_new_tab calls create_tab to construct a new tab in the main window
+ */
+
+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);
}
}
+/* remove the current tab from the main window if it is not the default tab
+ */
+
void
on_close_tab_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
+ GList * list;
int count = 0;
GtkWidget * notebook;
Tab * tmp;
tmp = mw_data->tab;
while(tmp != mw_data->current_tab){
tmp = tmp->next;
- count++;
+ count++;
}
}
gtk_notebook_remove_page((GtkNotebook*)notebook, count);
+ list = gtk_container_get_children(GTK_CONTAINER(notebook));
+ if(g_list_length(list)==1)
+ gtk_notebook_set_show_tabs((GtkNotebook*)notebook, FALSE);
}
g_printf("Trace facility selector: %s\n");
}
+
+/* Dispaly a file selection dialogue to let user select a module, then call
+ * lttv_module_load(), finally insert tool button and menu entry in the main window
+ * for the loaded module
+ */
+
void
on_load_module_activate (GtkMenuItem *menuitem,
gpointer user_data)
char str[PATH_LENGTH], *str1;
MainWindow * mw_data = get_window_data_struct((GtkWidget*)menuitem);
GtkFileSelection * file_selector = (GtkFileSelection *)gtk_file_selection_new("Select a module");
+ if(remember_dir[0] != '\0')
+ gtk_file_selection_set_filename(file_selector, remember_dir);
gtk_file_selection_hide_fileop_buttons(file_selector);
str[0] = '\0';
case GTK_RESPONSE_ACCEPT:
case GTK_RESPONSE_OK:
dir = gtk_file_selection_get_selections (file_selector);
- sprintf(str,dir[0]);
+ strncpy(str,dir[0],PATH_LENGTH);
+ strncpy(remember_dir,dir[0],PATH_LENGTH);
str1 = strrchr(str,'/');
if(str1)str1++;
else{
str1 = strrchr(str,'\\');
str1++;
}
- if(mw_data->win_creation_data)
- lttv_module_load(str1, mw_data->win_creation_data->argc,mw_data->win_creation_data->argv);
- else
- lttv_module_load(str1, 0,NULL);
+ lttv_module_require(str1, NULL);
g_slist_foreach(g_main_window_list, (gpointer)insert_menu_toolbar_item,
NULL);
g_strfreev(dir);
}
+/* Display all loaded modules, let user to select a module to unload
+ * by calling lttv_module_unload
+ */
+
void
on_unload_module_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
int i;
- char **name, *unload_module_name;
+ GPtrArray *name;
+ char *unload_module_name;
guint nb;
- LttvModule ** modules, *module;
+ LttvLibrary *library;
+ LttvLibraryInfo library_info;
MainWindow * mw_data = get_window_data_struct((GtkWidget*)menuitem);
- modules = lttv_module_list(&nb);
- name = g_new(char*, nb);
+ name = g_ptr_array_new();
+ nb = lttv_library_number();
+
for(i=0;i<nb;i++){
- module = modules[i];
- name[i] = lttv_module_name(module);
+ library = lttv_library_get(i);
+ lttv_library_info(library, &library_info);
+ if(library_info.load_count > 0) g_ptr_array_add(name, library_info.name);
}
- unload_module_name =get_unload_module(name,nb);
+ unload_module_name =get_unload_module((char **)(name->pdata), name->len);
if(unload_module_name){
for(i=0;i<nb;i++){
- if(strcmp(unload_module_name, name[i]) == 0){
- lttv_module_unload(modules[i]);
+ library = lttv_library_get(i);
+ lttv_library_info(library, &library_info);
+ if(strcmp(unload_module_name, library_info.name) == 0){
+ lttv_library_unload(library);
break;
}
}
}
- g_free(name);
+ g_ptr_array_free(name, TRUE);
}
+/* Display a directory dialogue to let user select a path for module searching
+ */
+
void
on_add_module_search_path_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
GtkDirSelection * file_selector = (GtkDirSelection *)gtk_dir_selection_new("Select module path");
- char * dir;
+ const char * dir;
gint id;
MainWindow * mw_data = get_window_data_struct((GtkWidget*)menuitem);
+ if(remember_dir[0] != '\0')
+ gtk_dir_selection_set_filename(file_selector, remember_dir);
id = gtk_dialog_run(GTK_DIALOG(file_selector));
switch(id){
case GTK_RESPONSE_ACCEPT:
case GTK_RESPONSE_OK:
dir = gtk_dir_selection_get_dir (file_selector);
- lttv_module_path_add(dir);
+ strncpy(remember_dir,dir,PATH_LENGTH);
+ strncat(remember_dir,"/",PATH_LENGTH);
+ lttv_library_path_add(dir);
case GTK_RESPONSE_REJECT:
case GTK_RESPONSE_CANCEL:
default:
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));
g_win_count--;
return FALSE;
}
+
+/* Set current tab
+ */
+
void
on_MNotebook_switch_page (GtkNotebook *notebook,
GtkNotebookPage *page,
mw->current_tab = tab;
}
+
+/* callback function to check or uncheck the check box (filter)
+ */
+
void checkbox_changed(GtkTreeView *treeview,
GtkTreePath *arg1,
GtkTreeViewColumn *arg2,
}
+
+/* According to user's selection, update selector(filter)
+ */
+
void update_filter(LttvTracesetSelector *s, GtkTreeStore *store )
{
GtkTreeIter iter, child_iter, child_iter1, child_iter2;
}
}
+
+/* Display a dialogue showing all eventtypes and traces, let user to select the interested
+ * eventtypes, tracefiles and traces (filter)
+ */
+
gboolean get_filter_selection(LttvTracesetSelector *s,char *title, char * column_title)
{
GtkWidget * dialogue;
return FALSE;
}
+
+/* Select a trace which will be removed from traceset
+ */
+
char * get_remove_trace(char ** all_trace_name, int nb_trace)
{
return get_selection(all_trace_name, nb_trace,
"Select a trace", "Trace pathname");
}
+
+
+/* Select a module which will be unloaded
+ */
+
char * get_unload_module(char ** loaded_module_name, int nb_module)
{
return get_selection(loaded_module_name, nb_module,
"Select an unload module", "Module pathname");
}
+
+/* Display a dialogue which shows all selectable items, let user to
+ * select one of them
+ */
+
char * get_selection(char ** loaded_module_name, int nb_module,
char *title, char * column_title)
{
return unload_module_name;
}
+
+/* hash funtions
+ */
+
void main_window_destroy_hash_key(gpointer key)
{
g_free(key);
}
+/* Insert menu entry and tool button into all main windows for modules
+ * It checks whether the menu entry or tool button exists or not,
+ * if they do not exist, then construct the widget and insert them
+ * into all main windows
+ */
+
void insert_menu_toolbar_item(MainWindow * mw, gpointer user_data)
{
int i;
tmp = g_hash_table_lookup(mw->hash_toolbar_item, g_strdup(toolbar_item->tooltip));
if(tmp)continue;
constructor = toolbar_item->con;
- tool_menu_title_menu = lookup_widget(mw->mwindow,"MToolbar2");
+ tool_menu_title_menu = lookup_widget(mw->mwindow,"MToolbar1");
pixbuf = gdk_pixbuf_new_from_xpm_data ((const char**)toolbar_item->pixmap);
pixmap = gtk_image_new_from_pixbuf(pixbuf);
insert_view = gtk_toolbar_append_element (GTK_TOOLBAR (tool_menu_title_menu),
}
}
-void construct_main_window(MainWindow * parent, WindowCreationData * win_creation_data)
+
+/* Create a main window
+ */
+
+void construct_main_window(MainWindow * parent)
{
- g_critical("construct_main_window()");
+ g_debug("construct_main_window()");
GtkWidget * new_window; /* New generated main window */
MainWindow * new_m_window;/* New main window structure */
GtkNotebook * notebook;
new_m_window->tab = NULL;
new_m_window->current_tab = NULL;
new_m_window->attributes = LTTV_IATTRIBUTE(g_object_new(LTTV_ATTRIBUTE_TYPE, NULL));
- if(parent){
- new_m_window->win_creation_data = parent->win_creation_data;
- }else{
- new_m_window->win_creation_data = win_creation_data;
- }
new_m_window->hash_menu_item = g_hash_table_new_full (g_str_hash, g_str_equal,
main_window_destroy_hash_key,
}
//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),
g_win_count++;
}
+
+/* Free the memory occupied by a tab structure
+ * destroy the tab
+ */
+
void tab_destructor(Tab * tab_instance)
{
int i, nb, ref_count;
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);
g_free(tab_instance);
}
+
+/* Create a tab and insert it into the current main window
+ */
+
void * create_tab(MainWindow * parent, MainWindow* current_window,
GtkNotebook * notebook, char * label)
{
MainWindow * mw_data = current_window;
LttTime tmp_time;
+ //create a new tab data structure
tmp_tab = mw_data->tab;
while(tmp_tab && tmp_tab->next) tmp_tab = tmp_tab->next;
if(!tmp_tab){
tmp_tab = tmp_tab->next;
}
+ //construct and initialize the traceset_info
tmp_tab->traceset_info = g_new(TracesetInfo,1);
if(parent){
tmp_tab->traceset_info->traceset =
LTTV_TRACESET_CONTEXT(tmp_tab->traceset_info->traceset_context),
tmp_tab->traceset_info->traceset);
+ //determine the current_time and time_window of the tab
if(mw_data->current_tab){
// Will have to read directly at the main window level, as we want
// to be able to modify a traceset on the fly.
tmp_tab,
(GDestroyNotify)tab_destructor);
+ //add state update hooks
lttv_state_add_event_hooks(
(LttvTracesetState*)tmp_tab->traceset_info->traceset_context);
+ //insert tab into notebook
gtk_notebook_append_page(notebook, (GtkWidget*)tmp_tab->multi_vpaned, tmp_tab->label);
list = gtk_container_get_children(GTK_CONTAINER(notebook));
gtk_notebook_set_current_page(notebook,g_list_length(list)-1);
+ if(g_list_length(list)>1)
+ gtk_notebook_set_show_tabs(notebook, TRUE);
}
+
+/* Remove menu entry and tool button from main window for the
+ * unloaded module
+ */
+
void remove_menu_item(gpointer main_win, gpointer user_data)
{
MainWindow * mw = (MainWindow *) main_win;
GtkWidget * tool_menu_title_menu, *insert_view;
- tool_menu_title_menu = lookup_widget(mw->mwindow,"MToolbar2");
+ tool_menu_title_menu = lookup_widget(mw->mwindow,"MToolbar1");
insert_view = (GtkWidget*)g_hash_table_lookup(mw->hash_toolbar_item,
toolbar_item->tooltip);
if(insert_view){
}
/**
- * Remove menu and toolbar item when a module unloaded
+ * Remove menu and toolbar item when a module unloaded from all
+ * main windows
*/
void main_window_remove_menu_item(lttv_constructor constructor)