Back into a compile/executable state. Now .h files are bundled with their
authordagenais <dagenais@04897980-b3bd-0310-b5e0-8ef037075253>
Tue, 20 Apr 2004 19:46:36 +0000 (19:46 +0000)
committerdagenais <dagenais@04897980-b3bd-0310-b5e0-8ef037075253>
Tue, 20 Apr 2004 19:46:36 +0000 (19:46 +0000)
package and the directory structure has been slightly simplified and
some names changed (mainwin for lttvwindow).

git-svn-id: http://ltt.polymtl.ca/svn@506 04897980-b3bd-0310-b5e0-8ef037075253

46 files changed:
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/Makefile.am [new file with mode: 0644]
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c [new file with mode: 0644]
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.h [new file with mode: 0644]
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/common.h [new file with mode: 0644]
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/gtkdirsel.c [new file with mode: 0644]
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/gtkdirsel.h [new file with mode: 0644]
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/gtkmultivpaned.c [new file with mode: 0644]
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/gtkmultivpaned.h [new file with mode: 0644]
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/gtktraceset.c [new file with mode: 0644]
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/gtktraceset.h [new file with mode: 0644]
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/init_module.c [new file with mode: 0644]
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/interface.c [new file with mode: 0644]
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/interface.h [new file with mode: 0644]
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvfilter.c [new file with mode: 0644]
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvfilter.h [new file with mode: 0644]
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/main.c [new file with mode: 0644]
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/mainwindow.h [new file with mode: 0644]
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/menu.c [new file with mode: 0644]
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/menu.h [new file with mode: 0644]
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/support.c [new file with mode: 0644]
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/support.h [new file with mode: 0644]
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/toolbar.c [new file with mode: 0644]
ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/toolbar.h [new file with mode: 0644]
ltt/branches/poly/lttv/modules/gui/lttvwindow/src/Makefile.am [deleted file]
ltt/branches/poly/lttv/modules/gui/lttvwindow/src/callbacks.c [deleted file]
ltt/branches/poly/lttv/modules/gui/lttvwindow/src/callbacks.h [deleted file]
ltt/branches/poly/lttv/modules/gui/lttvwindow/src/common.h [deleted file]
ltt/branches/poly/lttv/modules/gui/lttvwindow/src/gtkdirsel.c [deleted file]
ltt/branches/poly/lttv/modules/gui/lttvwindow/src/gtkdirsel.h [deleted file]
ltt/branches/poly/lttv/modules/gui/lttvwindow/src/gtkmultivpaned.c [deleted file]
ltt/branches/poly/lttv/modules/gui/lttvwindow/src/gtkmultivpaned.h [deleted file]
ltt/branches/poly/lttv/modules/gui/lttvwindow/src/gtktraceset.c [deleted file]
ltt/branches/poly/lttv/modules/gui/lttvwindow/src/gtktraceset.h [deleted file]
ltt/branches/poly/lttv/modules/gui/lttvwindow/src/init_module.c [deleted file]
ltt/branches/poly/lttv/modules/gui/lttvwindow/src/interface.c [deleted file]
ltt/branches/poly/lttv/modules/gui/lttvwindow/src/interface.h [deleted file]
ltt/branches/poly/lttv/modules/gui/lttvwindow/src/lttvfilter.c [deleted file]
ltt/branches/poly/lttv/modules/gui/lttvwindow/src/lttvfilter.h [deleted file]
ltt/branches/poly/lttv/modules/gui/lttvwindow/src/main.c [deleted file]
ltt/branches/poly/lttv/modules/gui/lttvwindow/src/mainwindow.h [deleted file]
ltt/branches/poly/lttv/modules/gui/lttvwindow/src/menu.c [deleted file]
ltt/branches/poly/lttv/modules/gui/lttvwindow/src/menu.h [deleted file]
ltt/branches/poly/lttv/modules/gui/lttvwindow/src/support.c [deleted file]
ltt/branches/poly/lttv/modules/gui/lttvwindow/src/support.h [deleted file]
ltt/branches/poly/lttv/modules/gui/lttvwindow/src/toolbar.c [deleted file]
ltt/branches/poly/lttv/modules/gui/lttvwindow/src/toolbar.h [deleted file]

diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/Makefile.am b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/Makefile.am
new file mode 100644 (file)
index 0000000..574a345
--- /dev/null
@@ -0,0 +1,49 @@
+## Process this file with automake to produce Makefile.in
+
+AM_CFLAGS = $(GLIB_CFLAGS) 
+AM_CFLAGS += $(GTK_CFLAGS)
+LIBS += $(GLIB_LIBS)
+LIBS += $(GTK_LIBS)
+
+INCLUDES = \
+       -DPACKAGE_DATA_DIR=\""$(datadir)"\" \
+       -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
+       @PACKAGE_CFLAGS@ \
+       $(DEFAULT_INCLUDES)
+
+libdir = ${lttvplugindir}
+
+#bin_PROGRAMS = lttvwindow
+lib_LTLIBRARIES = liblttvwindow.la
+
+
+#liblttvwindow_la_LDFLAGS = -module
+liblttvwindow_la_SOURCES = \
+       toolbar.c\
+       menu.c\
+       gtkdirsel.c\
+       gtkmultivpaned.c\
+       gtktraceset.c \
+       init_module.c \
+       support.c \
+       interface.c \
+       callbacks.c \
+       lttvfilter.c
+
+noinst_HEADERS = \
+       support.h \
+       interface.h \
+       callbacks.h
+
+lttvwindowinclude_HEADERS = \
+       common.h\
+       gtkdirsel.h\
+       gtkmultivpaned.h\
+       gtktraceset.h\
+       lttvfilter.h\
+       mainwindow.h\
+       menu.h\
+       toolbar.h
+
+liblttvwindow_la_LIBADD = @PACKAGE_LIBS@ $(INTLLIBS)
+
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c
new file mode 100644 (file)
index 0000000..3dfaad1
--- /dev/null
@@ -0,0 +1,2075 @@
+/* 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 "callbacks.h"
+#include "interface.h"
+#include "support.h"
+#include <lttv/lttv.h>
+#include <lttvwindow/mainwindow.h>
+#include <lttvwindow/menu.h>
+#include <lttvwindow/toolbar.h>
+#include <lttvwindow/gtktraceset.h>
+#include <lttv/module.h>
+#include <lttvwindow/gtkdirsel.h>
+#include <lttv/iattribute.h>
+#include <lttvwindow/lttvfilter.h>
+#include <ltt/trace.h>
+#include <ltt/facility.h>
+
+#define PATH_LENGTH          256
+#define DEFAULT_TIME_WIDTH_S   1
+
+extern LttvTrace *g_init_trace ;
+
+
+/** Array containing instanced objects. */
+extern GSList * g_main_window_list;
+
+static int g_win_count = 0;
+
+// MD : keep old directory
+static char remember_plugins_dir[PATH_LENGTH] = "";
+static char remember_trace_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);
+char * get_selection(char ** all_name, int nb, char *title, char * column_title);
+gboolean get_filter_selection(LttvTracesetSelector *s, char *title, char * column_title);
+void * create_tab(MainWindow * parent, MainWindow * current_window,
+                 GtkNotebook * notebook, char * label);
+
+void insert_viewer(GtkWidget* widget, view_constructor constructor);
+void update_filter(LttvTracesetSelector *s,  GtkTreeStore *store );
+
+void checkbox_changed(GtkTreeView *treeview,
+                     GtkTreePath *arg1,
+                     GtkTreeViewColumn *arg2,
+                     gpointer user_data);
+void remove_trace_from_traceset_selector(GtkMultiVPaned * paned, unsigned i);
+void add_trace_into_traceset_selector(GtkMultiVPaned * paned, LttTrace * trace);
+
+LttvTracesetSelector * construct_traceset_selector(LttvTraceset * traceset);
+
+void redraw_viewer(MainWindow * mw_data, TimeWindow * time_window);
+unsigned get_max_event_number(MainWindow * mw_data);
+
+enum {
+  CHECKBOX_COLUMN,
+  NAME_COLUMN,
+  TOTAL_COLUMNS
+};
+
+enum
+{
+  MODULE_COLUMN,
+  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)
+{
+  LttvTracesetSelector  * s;
+  LttvTraceSelector     * trace;
+  LttvTracefileSelector * tracefile;
+  LttvEventtypeSelector * eventtype;
+  int i, j, k, m;
+  int nb_trace, nb_tracefile, nb_control, nb_per_cpu, nb_facility, nb_event;
+  LttvTrace * trace_v;
+  LttTrace  * t;
+  LttTracefile *tf;
+  LttFacility * fac;
+  LttEventType * et;
+
+  s = lttv_traceset_selector_new(lttv_traceset_name(traceset));
+  nb_trace = lttv_traceset_number(traceset);
+  for(i=0;i<nb_trace;i++){
+    trace_v = lttv_traceset_get(traceset, i);
+    t       = lttv_trace(trace_v);
+    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);
+    }
+  } 
+  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)
+{
+  guint val = 20;
+
+  insert_viewer((GtkWidget*)menuitem, (view_constructor)user_data);
+  //  selected_hook(&val);
+}
+
+
+/* internal functions */
+void insert_viewer(GtkWidget* widget, view_constructor constructor)
+{
+  GtkMultiVPaned * multi_vpaned;
+  MainWindow * mw_data;  
+  GtkWidget * viewer;
+  LttvTracesetSelector  * s;
+  TimeInterval * time_interval;
+  TimeWindow  time_window, t;
+
+  mw_data = get_window_data_struct(widget);
+  if(!mw_data->current_tab) return;
+  multi_vpaned = mw_data->current_tab->multi_vpaned;
+
+  s = construct_traceset_selector(mw_data->current_tab->traceset_info->traceset);
+  viewer = (GtkWidget*)constructor(mw_data, s, "Traceset_Selector");
+  if(viewer)
+  {
+    gtk_multi_vpaned_widget_add(multi_vpaned, viewer); 
+    // Added by MD
+    //    g_object_unref(G_OBJECT(viewer));
+
+    time_window = mw_data->current_tab->time_window;
+    time_interval = (TimeInterval*)g_object_get_data(G_OBJECT(viewer), TRACESET_TIME_SPAN);
+    if(time_interval){
+      t = time_window;
+      time_window.start_time = time_interval->startTime;
+      time_window.time_width = ltt_time_sub(time_interval->endTime,time_interval->startTime);
+    }
+
+    redraw_viewer(mw_data,&time_window);
+    set_current_time(mw_data,&(mw_data->current_tab->current_time));
+    if(time_interval){
+      set_time_window(mw_data,&t);
+    }
+  }
+}
+
+
+/* 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;
+  if(strlen(gtk_entry_get_text(entry))!=0)
+    strcpy(label,gtk_entry_get_text(entry)); 
+}
+
+gboolean get_label(MainWindow * mw, gchar * str, gchar* dialogue_title, gchar * label_str)
+{
+  GtkWidget * dialogue;
+  GtkWidget * text;
+  GtkWidget * label;
+  gint id;
+
+  dialogue = gtk_dialog_new_with_buttons(dialogue_title,NULL,
+                                        GTK_DIALOG_MODAL,
+                                        GTK_STOCK_OK,GTK_RESPONSE_ACCEPT,
+                                        GTK_STOCK_CANCEL,GTK_RESPONSE_REJECT,
+                                        NULL); 
+
+  label = gtk_label_new(label_str);
+  gtk_widget_show(label);
+
+  text = gtk_entry_new();
+  gtk_widget_show(text);
+
+  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialogue)->vbox), label,TRUE, TRUE,0);
+  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialogue)->vbox), text,FALSE, FALSE,0);
+
+  id = gtk_dialog_run(GTK_DIALOG(dialogue));
+  switch(id){
+    case GTK_RESPONSE_ACCEPT:
+      get_label_string(text,str);
+      gtk_widget_destroy(dialogue);
+      break;
+    case GTK_RESPONSE_REJECT:
+    default:
+      gtk_widget_destroy(dialogue);
+      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;
+  MainWindow * mw_data;
+
+  mw = lookup_widget(widget, "MWindow");
+  if(mw == NULL){
+    g_printf("Main window does not exist\n");
+    return;
+  }
+  
+  mw_data = (MainWindow *) g_object_get_data(G_OBJECT(mw),"mainWindow");
+  if(mw_data == NULL){
+    g_printf("Main window data does not exist\n");
+    return;
+  }
+  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);
+  }else{
+    g_printf("Empty : traceset is set to NULL\n");
+    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);
+  if(!mw->current_tab) return;
+  gtk_multi_vpaned_widget_move_up(mw->current_tab->multi_vpaned);
+}
+
+void move_down_viewer(GtkWidget * widget, gpointer user_data)
+{
+  MainWindow * mw = get_window_data_struct(widget);
+  if(!mw->current_tab) return;
+  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);
+  if(!mw->current_tab) return;
+  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;
+  gint id;
+  LttvTraceset * traceset;
+  MainWindow * mw_data = get_window_data_struct(widget);
+  GtkFileSelection * file_selector = 
+    (GtkFileSelection *)gtk_file_selection_new("Select a traceset");
+
+  gtk_file_selection_hide_fileop_buttons(file_selector);
+  
+  id = gtk_dialog_run(GTK_DIALOG(file_selector));
+  switch(id){
+    case GTK_RESPONSE_ACCEPT:
+    case GTK_RESPONSE_OK:
+      dir = gtk_file_selection_get_selections (file_selector);
+      traceset = lttv_traceset_load(dir[0]);
+      g_printf("Open a trace set %s\n", dir[0]); 
+      //Not finished yet
+      g_strfreev(dir);
+    case GTK_RESPONSE_REJECT:
+    case GTK_RESPONSE_CANCEL:
+    default:
+      gtk_widget_destroy((GtkWidget*)file_selector);
+      break;
+  }
+
+}
+
+
+/* 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;
+  GtkWidget * w;
+
+  w = gtk_multi_vpaned_get_first_widget(mw_data->current_tab->multi_vpaned);  
+  while(w){
+    size = (unsigned*)g_object_get_data(G_OBJECT(w), MAX_NUMBER_EVENT);
+    if(size == NULL){
+      nb = G_MAXULONG;
+      break;
+    }else{
+      if(nb < *size)
+       nb = *size;
+    }
+    w = gtk_multi_vpaned_get_next_widget(mw_data->current_tab->multi_vpaned);  
+  }  
+  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;
+  GdkWindow * win;
+  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, "MToolbar1");
+  win = gtk_widget_get_parent_window(widget);  
+  gdk_window_set_cursor(win, new);
+  gdk_cursor_unref(new);  
+  gdk_window_stick(win);
+  gdk_window_unstick(win);
+  //update time window of each viewer, let viewer insert hooks needed by process_traceset
+  set_time_window(mw_data, time_window);
+  
+  max_nb_events = get_max_event_number(mw_data);
+
+  process_traceset_api(mw_data, time_window->start_time, 
+                      ltt_time_add(time_window->start_time,time_window->time_width),
+                      max_nb_events);
+
+  //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;
+  LttvTracesetSelector  * s;
+  LttvTraceSelector     * trace;
+  LttvTracefileSelector * tracefile;
+  LttvEventtypeSelector * eventtype;
+  LttTracefile          * tf;
+  GtkWidget             * w;
+  LttFacility           * fac;
+  LttEventType          * et;
+
+  w = gtk_multi_vpaned_get_first_widget(paned);  
+  while(w){
+    s = g_object_get_data(G_OBJECT(w), "Traceset_Selector");
+    
+    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;
+  const char * dir;
+  gint id;
+  MainWindow * mw_data = get_window_data_struct(widget);
+  GtkDirSelection * file_selector = (GtkDirSelection *)gtk_dir_selection_new("Select a trace");
+  gtk_dir_selection_hide_fileop_buttons(file_selector);
+  if(remember_trace_dir[0] != '\0')
+    gtk_dir_selection_set_filename(file_selector, remember_trace_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);
+      strncpy(remember_trace_dir, dir, PATH_LENGTH);
+      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);
+      traceset = mw_data->current_tab->traceset_info->traceset;
+      if(mw_data->current_tab->traceset_info->traceset_context != NULL){
+       lttv_context_fini(LTTV_TRACESET_CONTEXT(mw_data->current_tab->
+                                               traceset_info->traceset_context));
+       g_object_unref(mw_data->current_tab->traceset_info->traceset_context);
+      }
+      lttv_traceset_add(traceset, trace_v);
+      mw_data->current_tab->traceset_info->traceset_context =
+       g_object_new(LTTV_TRACESET_STATS_TYPE, NULL);
+      lttv_context_init(
+       LTTV_TRACESET_CONTEXT(mw_data->current_tab->traceset_info->
+                             traceset_context),traceset); 
+      add_trace_into_traceset_selector(mw_data->current_tab->multi_vpaned, trace);
+
+      gtk_widget_destroy((GtkWidget*)file_selector);
+      
+      //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;
+    case GTK_RESPONSE_REJECT:
+    case GTK_RESPONSE_CANCEL:
+    default:
+      gtk_widget_destroy((GtkWidget*)file_selector);
+      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;
+  LttvTraceSelector * t;
+  GtkWidget * w; 
+  
+  w = gtk_multi_vpaned_get_first_widget(paned);  
+  while(w){
+    s = g_object_get_data(G_OBJECT(w), "Traceset_Selector");
+    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;
+  LttvTrace * trace_v;
+  LttvTraceset * traceset;
+  gint i, nb_trace;
+  char ** name, *remove_trace_name;
+  MainWindow * mw_data = get_window_data_struct(widget);
+  LttvTracesetSelector * s;
+  LttvTraceSelector * t;
+  GtkWidget * w; 
+  gboolean selected;
+  
+  nb_trace =lttv_traceset_number(mw_data->current_tab->traceset_info->traceset); 
+  name = g_new(char*,nb_trace);
+  for(i = 0; i < nb_trace; i++){
+    trace_v = lttv_traceset_get(mw_data->current_tab->
+                               traceset_info->traceset, i);
+    trace = lttv_trace(trace_v);
+    name[i] = ltt_trace_name(trace);
+  }
+
+  remove_trace_name = get_remove_trace(name, nb_trace);
+
+  if(remove_trace_name){
+    for(i=0; i<nb_trace; i++){
+      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);  
+       if(w){
+         s = g_object_get_data(G_OBJECT(w), "Traceset_Selector");
+         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){
+         remove_trace_from_traceset_selector(mw_data->current_tab->multi_vpaned, i);
+
+         traceset = mw_data->current_tab->traceset_info->traceset;
+         trace_v = lttv_traceset_get(traceset, i);
+         if(lttv_trace_get_ref_number(trace_v) <= 1)
+           ltt_trace_close(lttv_trace(trace_v));
+
+         if(mw_data->current_tab->traceset_info->traceset_context != NULL){
+           lttv_context_fini(LTTV_TRACESET_CONTEXT(mw_data->current_tab->
+                                                   traceset_info->traceset_context));
+           g_object_unref(mw_data->current_tab->traceset_info->traceset_context);
+         }
+         lttv_traceset_remove(traceset, i);
+         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(
+                           LTTV_TRACESET_CONTEXT(mw_data->current_tab->
+                                     traceset_info->traceset_context),traceset);      
+         //update current tab
+         update_traceset(mw_data);
+         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");
+}
+
+void save_as(GtkWidget * widget, gpointer user_data)
+{
+  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;
+  TimeWindow time_window;
+  LttTime    current_time, time_delta, time_s, time_e, time_t;
+  MainWindow * mw_data = get_window_data_struct(widget);
+
+  if(size == 1) return;
+
+  time_span = LTTV_TRACESET_CONTEXT(mw_data->current_tab->
+                                   traceset_info->traceset_context)->Time_Span;
+  time_window =  mw_data->current_tab->time_window;
+  current_time = mw_data->current_tab->current_time;
+  
+  time_delta = ltt_time_sub(time_span->endTime,time_span->startTime);
+  if(size == 0){
+    time_window.start_time = time_span->startTime;
+    time_window.time_width = time_delta;
+  }else{
+    time_window.time_width = ltt_time_div(time_window.time_width, size);
+    if(ltt_time_compare(time_window.time_width,time_delta) > 0)
+      time_window.time_width = time_delta;
+
+    time_t = ltt_time_div(time_window.time_width, 2);
+    if(ltt_time_compare(current_time, time_t) < 0){
+      time_s = time_span->startTime;
+    } else {
+      time_s = ltt_time_sub(current_time,time_t);
+    }
+    time_e = ltt_time_add(current_time,time_t);
+    if(ltt_time_compare(time_span->startTime, time_s) > 0){
+      time_s = time_span->startTime;
+    }else if(ltt_time_compare(time_span->endTime, time_e) < 0){
+      time_e = time_span->endTime;
+      time_s = ltt_time_sub(time_e,time_window.time_width);
+    }
+    time_window.start_time = time_s;    
+  }
+  redraw_viewer(mw_data, &time_window);
+  set_current_time(mw_data,&(mw_data->current_tab->current_time));
+  gtk_multi_vpaned_set_adjust(mw_data->current_tab->multi_vpaned, FALSE);
+}
+
+void zoom_in(GtkWidget * widget, gpointer user_data)
+{
+  zoom(widget, 2);
+}
+
+void zoom_out(GtkWidget * widget, gpointer user_data)
+{
+  zoom(widget, 0.5);
+}
+
+void zoom_extended(GtkWidget * widget, gpointer user_data)
+{
+  zoom(widget, 0);
+}
+
+void go_to_time(GtkWidget * widget, gpointer user_data)
+{
+  g_printf("Go to time\n");
+}
+
+void show_time_frame(GtkWidget * widget, gpointer user_data)
+{
+  g_printf("Show time frame\n");  
+}
+
+
+/* callback function */
+
+void
+on_empty_traceset_activate             (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+  create_new_window((GtkWidget*)menuitem, user_data, FALSE);
+}
+
+
+void
+on_clone_traceset_activate             (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+  create_new_window((GtkWidget*)menuitem, user_data, TRUE);
+}
+
+
+/* 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(widget);
+  GtkNotebook * notebook = (GtkNotebook *)lookup_widget(widget, "MNotebook");
+  if(notebook == NULL){
+    g_printf("Notebook does not exist\n");
+    return;
+  }
+
+  strcpy(label,"Page");
+  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);
+}
+
+void
+on_tab_activate                        (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+  create_new_tab((GtkWidget*)menuitem, user_data);
+}
+
+
+void
+on_open_activate                       (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+  open_traceset((GtkWidget*)menuitem, user_data);
+}
+
+
+void
+on_close_activate                      (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+  MainWindow * mw_data = get_window_data_struct((GtkWidget*)menuitem);
+  main_window_destructor(mw_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;
+  MainWindow * mw_data = get_window_data_struct((GtkWidget*)menuitem);
+  notebook = lookup_widget((GtkWidget*)menuitem, "MNotebook");
+  if(notebook == NULL){
+    g_printf("Notebook does not exist\n");
+    return;
+  }
+  
+  if(mw_data->tab == mw_data->current_tab){
+    //    tmp = mw_data->current_tb;
+    //    mw_data->tab = mw_data->current_tab->next;
+    g_printf("The default TAB can not be deleted\n");
+    return;
+  }else{
+    tmp = mw_data->tab;
+    while(tmp != mw_data->current_tab){
+      tmp = tmp->next;
+      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);
+}
+
+
+void
+on_add_trace_activate                  (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+  add_trace((GtkWidget*)menuitem, user_data);
+}
+
+
+void
+on_remove_trace_activate               (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+  remove_trace((GtkWidget*)menuitem, user_data);
+}
+
+
+void
+on_save_activate                       (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+  save((GtkWidget*)menuitem, user_data);
+}
+
+
+void
+on_save_as_activate                    (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+  save_as((GtkWidget*)menuitem, user_data);
+}
+
+
+void
+on_quit_activate                       (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+  gtk_main_quit ();
+}
+
+
+void
+on_cut_activate                        (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+  g_printf("Cut\n");
+}
+
+
+void
+on_copy_activate                       (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+  g_printf("Copye\n");
+}
+
+
+void
+on_paste_activate                      (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+  g_printf("Paste\n");
+}
+
+
+void
+on_delete_activate                     (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+  g_printf("Delete\n");
+}
+
+
+void
+on_zoom_in_activate                    (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+   zoom_in((GtkWidget*)menuitem, user_data); 
+}
+
+
+void
+on_zoom_out_activate                   (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+   zoom_out((GtkWidget*)menuitem, user_data); 
+}
+
+
+void
+on_zoom_extended_activate              (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+   zoom_extended((GtkWidget*)menuitem, user_data); 
+}
+
+
+void
+on_go_to_time_activate                 (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+   go_to_time((GtkWidget*)menuitem, user_data); 
+}
+
+
+void
+on_show_time_frame_activate            (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+   show_time_frame((GtkWidget*)menuitem, user_data); 
+}
+
+
+void
+on_move_viewer_up_activate             (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+  move_up_viewer((GtkWidget*)menuitem, user_data);
+}
+
+
+void
+on_move_viewer_down_activate           (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+  move_down_viewer((GtkWidget*)menuitem, user_data);
+}
+
+
+void
+on_remove_viewer_activate              (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+  delete_viewer((GtkWidget*)menuitem, user_data);
+}
+
+void
+on_trace_filter_activate              (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+  MainWindow * mw_data = get_window_data_struct((GtkWidget*)menuitem);
+  LttvTracesetSelector * s;
+  GtkWidget * w = gtk_multi_vpaned_get_widget(mw_data->current_tab->multi_vpaned);
+  
+  s = g_object_get_data(G_OBJECT(w), "Traceset_Selector");
+  if(!s){
+    g_printf("There is no viewer yet\n");      
+    return;
+  }
+  if(get_filter_selection(s, "Configure trace and tracefile filter", "Select traces and tracefiles")){
+    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));
+  }
+}
+
+void
+on_trace_facility_activate              (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+  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 ** dir;
+  gint id;
+  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_plugins_dir[0] != '\0')
+    gtk_file_selection_set_filename(file_selector, remember_plugins_dir);
+  gtk_file_selection_hide_fileop_buttons(file_selector);
+  
+  str[0] = '\0';
+  id = gtk_dialog_run(GTK_DIALOG(file_selector));
+  switch(id){
+    case GTK_RESPONSE_ACCEPT:
+    case GTK_RESPONSE_OK:
+      dir = gtk_file_selection_get_selections (file_selector);
+      strncpy(str,dir[0],PATH_LENGTH);
+      strncpy(remember_plugins_dir,dir[0],PATH_LENGTH);
+      str1 = strrchr(str,'/');
+      if(str1)str1++;
+      else{
+       str1 = strrchr(str,'\\');
+       str1++;
+      }
+      lttv_module_require(str1, NULL);
+      g_slist_foreach(g_main_window_list, (gpointer)insert_menu_toolbar_item,
+          NULL);
+      g_strfreev(dir);
+    case GTK_RESPONSE_REJECT:
+    case GTK_RESPONSE_CANCEL:
+    default:
+      gtk_widget_destroy((GtkWidget*)file_selector);
+      break;
+  }
+  g_printf("Load module: %s\n", str);
+}
+
+
+/* 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;
+  GPtrArray *name;
+  char *unload_module_name;
+  guint nb;
+  LttvLibrary *library;
+  LttvLibraryInfo library_info;
+  MainWindow * mw_data = get_window_data_struct((GtkWidget*)menuitem);
+  
+  name  = g_ptr_array_new();
+  nb = lttv_library_number();
+
+  for(i=0;i<nb;i++){
+    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((char **)(name->pdata), name->len);
+  
+  if(unload_module_name){
+    for(i=0;i<nb;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_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");
+  const char * dir;
+  gint id;
+
+  MainWindow * mw_data = get_window_data_struct((GtkWidget*)menuitem);
+  if(remember_plugins_dir[0] != '\0')
+    gtk_dir_selection_set_filename(file_selector, remember_plugins_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);
+      strncpy(remember_plugins_dir,dir,PATH_LENGTH);
+      strncat(remember_plugins_dir,"/",PATH_LENGTH);
+      lttv_library_path_add(dir);
+    case GTK_RESPONSE_REJECT:
+    case GTK_RESPONSE_CANCEL:
+    default:
+      gtk_widget_destroy((GtkWidget*)file_selector);
+      break;
+  }
+}
+
+
+void
+on_color_activate                      (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+  g_printf("Color\n");
+}
+
+
+void
+on_filter_activate                     (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+  g_printf("Filter\n");
+}
+
+
+void
+on_save_configuration_activate         (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+  g_printf("Save configuration\n");
+}
+
+
+void
+on_content_activate                    (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+  g_printf("Content\n");
+}
+
+
+void
+on_about_activate                      (GtkMenuItem     *menuitem,
+                                        gpointer         user_data)
+{
+  g_printf("About...\n");
+}
+
+
+void
+on_button_new_clicked                  (GtkButton       *button,
+                                        gpointer         user_data)
+{
+  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,
+                                        gpointer         user_data)
+{
+  open_traceset((GtkWidget*)button, user_data);
+}
+
+
+void
+on_button_add_trace_clicked            (GtkButton       *button,
+                                        gpointer         user_data)
+{
+  add_trace((GtkWidget*)button, user_data);
+}
+
+
+void
+on_button_remove_trace_clicked         (GtkButton       *button,
+                                        gpointer         user_data)
+{
+  remove_trace((GtkWidget*)button, user_data);
+}
+
+
+void
+on_button_save_clicked                 (GtkButton       *button,
+                                        gpointer         user_data)
+{
+  save((GtkWidget*)button, user_data);
+}
+
+
+void
+on_button_save_as_clicked              (GtkButton       *button,
+                                        gpointer         user_data)
+{
+  save_as((GtkWidget*)button, user_data);
+}
+
+
+void
+on_button_zoom_in_clicked              (GtkButton       *button,
+                                        gpointer         user_data)
+{
+   zoom_in((GtkWidget*)button, user_data); 
+}
+
+
+void
+on_button_zoom_out_clicked             (GtkButton       *button,
+                                        gpointer         user_data)
+{
+   zoom_out((GtkWidget*)button, user_data); 
+}
+
+
+void
+on_button_zoom_extended_clicked        (GtkButton       *button,
+                                        gpointer         user_data)
+{
+   zoom_extended((GtkWidget*)button, user_data); 
+}
+
+
+void
+on_button_go_to_time_clicked           (GtkButton       *button,
+                                        gpointer         user_data)
+{
+   go_to_time((GtkWidget*)button, user_data); 
+}
+
+
+void
+on_button_show_time_frame_clicked      (GtkButton       *button,
+                                        gpointer         user_data)
+{
+   show_time_frame((GtkWidget*)button, user_data); 
+}
+
+
+void
+on_button_move_up_clicked              (GtkButton       *button,
+                                        gpointer         user_data)
+{
+  move_up_viewer((GtkWidget*)button, user_data);
+}
+
+
+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                     (GtkObject       *object,
+                                        gpointer         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--;
+  if(g_win_count == 0)
+    gtk_main_quit ();
+}
+
+gboolean    
+on_MWindow_configure                   (GtkWidget         *widget,
+                                        GdkEventConfigure *event,
+                                        gpointer           user_data)
+{
+  MainWindow * mw_data = get_window_data_struct((GtkWidget*)widget);
+  float width = event->width;
+  Tab * tab = mw_data->tab;
+  TimeWindow time_win;
+  double ratio;
+  TimeInterval *time_span;
+  LttTime time;
+       
+       // 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)
+{
+  MainWindow * mw = get_window_data_struct((GtkWidget*)notebook);
+  Tab * tab = mw->tab;
+  while(page_num){
+    tab = tab->next;
+    page_num--;
+  }
+  mw->current_tab = tab;
+}
+
+
+/* callback function to check or uncheck the check box (filter)
+ */
+
+void checkbox_changed(GtkTreeView *treeview,
+                     GtkTreePath *arg1,
+                     GtkTreeViewColumn *arg2,
+                     gpointer user_data)
+{
+  GtkTreeStore * store = (GtkTreeStore *)gtk_tree_view_get_model (treeview);
+  GtkTreeIter iter;
+  gboolean value;
+
+  if (gtk_tree_model_get_iter ((GtkTreeModel *)store, &iter, arg1)){
+    gtk_tree_model_get ((GtkTreeModel *)store, &iter, CHECKBOX_COLUMN, &value, -1);
+    value = value? FALSE : TRUE;
+    gtk_tree_store_set (GTK_TREE_STORE (store), &iter, CHECKBOX_COLUMN, value, -1);    
+  }  
+  
+}
+
+
+/* According to user's selection, update selector(filter)
+ */
+
+void update_filter(LttvTracesetSelector *s,  GtkTreeStore *store )
+{
+  GtkTreeIter iter, child_iter, child_iter1, child_iter2;
+  int i, j, k, nb_eventtype;
+  LttvTraceSelector     * trace;
+  LttvTracefileSelector * tracefile;
+  LttvEventtypeSelector * eventtype;
+  gboolean value, value1, value2;
+
+  if(gtk_tree_model_get_iter_first((GtkTreeModel*)store, &iter)){
+    i = 0;
+    do{
+      trace = lttv_traceset_selector_trace_get(s, i);
+      nb_eventtype = lttv_trace_selector_eventtype_number(trace);
+      gtk_tree_model_get ((GtkTreeModel*)store, &iter, CHECKBOX_COLUMN, &value,-1);
+      if(value){
+       j = 0;
+       if(gtk_tree_model_iter_children ((GtkTreeModel*)store, &child_iter, &iter)){
+         do{
+           if(j<1){//eventtype selector for trace
+             gtk_tree_model_get ((GtkTreeModel*)store, &child_iter, CHECKBOX_COLUMN, &value2,-1);
+             if(value2){
+               k=0;
+               if(gtk_tree_model_iter_children ((GtkTreeModel*)store, &child_iter1, &child_iter)){
+                 do{
+                   eventtype = lttv_trace_selector_eventtype_get(trace,k);
+                   gtk_tree_model_get ((GtkTreeModel*)store, &child_iter1, CHECKBOX_COLUMN, &value2,-1);
+                   lttv_eventtype_selector_set_selected(eventtype,value2);
+                   k++;
+                 }while(gtk_tree_model_iter_next((GtkTreeModel*)store, &child_iter1));
+               }
+             }
+           }else{ //tracefile selector
+             tracefile = lttv_trace_selector_tracefile_get(trace, j - 1);
+             gtk_tree_model_get ((GtkTreeModel*)store, &child_iter, CHECKBOX_COLUMN, &value1,-1);
+             lttv_tracefile_selector_set_selected(tracefile,value1);
+             if(value1){
+               gtk_tree_model_iter_children((GtkTreeModel*)store, &child_iter1, &child_iter); //eventtype selector
+               gtk_tree_model_get ((GtkTreeModel*)store, &child_iter1, CHECKBOX_COLUMN, &value2,-1);
+               if(value2){
+                 k = 0;
+                 if(gtk_tree_model_iter_children ((GtkTreeModel*)store, &child_iter2, &child_iter1)){
+                   do{//eventtype selector for tracefile
+                     eventtype = lttv_tracefile_selector_eventtype_get(tracefile,k);
+                     gtk_tree_model_get ((GtkTreeModel*)store, &child_iter2, CHECKBOX_COLUMN, &value2,-1);
+                     lttv_eventtype_selector_set_selected(eventtype,value2);
+                     k++;
+                   }while(gtk_tree_model_iter_next((GtkTreeModel*)store, &child_iter2));
+                 }
+               }
+             }
+           }
+           j++;
+         }while(gtk_tree_model_iter_next((GtkTreeModel*)store, &child_iter));
+       }
+      }
+      lttv_trace_selector_set_selected(trace,value);
+      i++;
+    }while(gtk_tree_model_iter_next((GtkTreeModel*)store, &iter));
+  }
+}
+
+
+/* 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;
+  GtkTreeStore      * store;
+  GtkWidget         * tree;
+  GtkWidget         * scroll_win;
+  GtkCellRenderer   * renderer;
+  GtkTreeViewColumn * column;
+  GtkTreeIter         iter, child_iter, child_iter1, child_iter2;
+  int i, j, k, id, nb_trace, nb_tracefile, nb_eventtype;
+  LttvTraceSelector     * trace;
+  LttvTracefileSelector * tracefile;
+  LttvEventtypeSelector * eventtype;
+  char * name;
+  gboolean checked;
+
+  dialogue = gtk_dialog_new_with_buttons(title,
+                                        NULL,
+                                        GTK_DIALOG_MODAL,
+                                        GTK_STOCK_OK,GTK_RESPONSE_ACCEPT,
+                                        GTK_STOCK_CANCEL,GTK_RESPONSE_REJECT,
+                                        NULL); 
+  gtk_window_set_default_size((GtkWindow*)dialogue, 300, 500);
+
+  store = gtk_tree_store_new (TOTAL_COLUMNS, G_TYPE_BOOLEAN, G_TYPE_STRING);
+  tree  = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
+  g_object_unref (G_OBJECT (store));
+  g_signal_connect (G_OBJECT (tree), "row-activated",
+                   G_CALLBACK (checkbox_changed),
+                   NULL);  
+
+
+  renderer = gtk_cell_renderer_toggle_new ();
+  gtk_cell_renderer_toggle_set_radio((GtkCellRendererToggle *)renderer, FALSE);
+
+  g_object_set (G_OBJECT (renderer),"activatable", TRUE, NULL);
+
+  column   = gtk_tree_view_column_new_with_attributes ("Checkbox",
+                                                      renderer,
+                                                      "active", CHECKBOX_COLUMN,
+                                                      NULL);
+  gtk_tree_view_column_set_alignment (column, 0.5);
+  gtk_tree_view_column_set_fixed_width (column, 20);
+  gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
+
+  renderer = gtk_cell_renderer_text_new ();
+  column   = gtk_tree_view_column_new_with_attributes (column_title,
+                                                      renderer,
+                                                      "text", NAME_COLUMN,
+                                                      NULL);
+  gtk_tree_view_column_set_alignment (column, 0.0);
+  gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
+  gtk_tree_view_set_headers_visible(GTK_TREE_VIEW (tree), FALSE);
+
+  scroll_win = gtk_scrolled_window_new (NULL, NULL);
+  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_win), 
+                                GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
+  gtk_container_add (GTK_CONTAINER (scroll_win), tree);
+
+  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialogue)->vbox), scroll_win,TRUE, TRUE,0);
+
+  gtk_widget_show(scroll_win);
+  gtk_widget_show(tree);
+  
+  nb_trace = lttv_traceset_selector_trace_number(s);
+  for(i=0;i<nb_trace;i++){
+    trace = lttv_traceset_selector_trace_get(s, i);
+    name  = lttv_trace_selector_get_name(trace);    
+    gtk_tree_store_append (store, &iter, NULL);
+    checked = lttv_trace_selector_get_selected(trace);
+    gtk_tree_store_set (store, &iter, 
+                       CHECKBOX_COLUMN,checked,
+                       NAME_COLUMN,name,
+                       -1);
+
+    gtk_tree_store_append (store, &child_iter, &iter);      
+    gtk_tree_store_set (store, &child_iter, 
+                       CHECKBOX_COLUMN, checked,
+                       NAME_COLUMN,"eventtype",
+                       -1);
+    
+    nb_eventtype = lttv_trace_selector_eventtype_number(trace);
+    for(j=0;j<nb_eventtype;j++){
+      eventtype = lttv_trace_selector_eventtype_get(trace,j);
+      name      = lttv_eventtype_selector_get_name(eventtype);    
+      checked   = lttv_eventtype_selector_get_selected(eventtype);
+      gtk_tree_store_append (store, &child_iter1, &child_iter);      
+      gtk_tree_store_set (store, &child_iter1, 
+                         CHECKBOX_COLUMN, checked,
+                         NAME_COLUMN,name,
+                         -1);
+    }
+
+    nb_tracefile = lttv_trace_selector_tracefile_number(trace);
+    for(j=0;j<nb_tracefile;j++){
+      tracefile = lttv_trace_selector_tracefile_get(trace, j);
+      name      = lttv_tracefile_selector_get_name(tracefile);    
+      gtk_tree_store_append (store, &child_iter, &iter);
+      checked = lttv_tracefile_selector_get_selected(tracefile);
+      gtk_tree_store_set (store, &child_iter, 
+                         CHECKBOX_COLUMN, checked,
+                         NAME_COLUMN,name,
+                         -1);
+
+      gtk_tree_store_append (store, &child_iter1, &child_iter);      
+      gtk_tree_store_set (store, &child_iter1, 
+                         CHECKBOX_COLUMN, checked,
+                         NAME_COLUMN,"eventtype",
+                         -1);
+    
+      for(k=0;k<nb_eventtype;k++){
+       eventtype = lttv_tracefile_selector_eventtype_get(tracefile,k);
+       name      = lttv_eventtype_selector_get_name(eventtype);    
+       checked   = lttv_eventtype_selector_get_selected(eventtype);
+       gtk_tree_store_append (store, &child_iter2, &child_iter1);      
+       gtk_tree_store_set (store, &child_iter2, 
+                           CHECKBOX_COLUMN, checked,
+                           NAME_COLUMN,name,
+                           -1);
+      }
+    }
+  }
+
+  id = gtk_dialog_run(GTK_DIALOG(dialogue));
+  switch(id){
+    case GTK_RESPONSE_ACCEPT:
+    case GTK_RESPONSE_OK:
+      update_filter(s, store);
+      gtk_widget_destroy(dialogue);
+      return TRUE;
+    case GTK_RESPONSE_REJECT:
+    case GTK_RESPONSE_CANCEL:
+    default:
+      gtk_widget_destroy(dialogue);
+      break;
+  }
+  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)
+{
+  GtkWidget         * dialogue;
+  GtkWidget         * scroll_win;
+  GtkWidget         * tree;
+  GtkListStore      * store;
+  GtkTreeViewColumn * column;
+  GtkCellRenderer   * renderer;
+  GtkTreeSelection  * select;
+  GtkTreeIter         iter;
+  gint                id, i;
+  char              * unload_module_name = NULL;
+
+  dialogue = gtk_dialog_new_with_buttons(title,
+                                        NULL,
+                                        GTK_DIALOG_MODAL,
+                                        GTK_STOCK_OK,GTK_RESPONSE_ACCEPT,
+                                        GTK_STOCK_CANCEL,GTK_RESPONSE_REJECT,
+                                        NULL); 
+  gtk_window_set_default_size((GtkWindow*)dialogue, 500, 200);
+
+  scroll_win = gtk_scrolled_window_new (NULL, NULL);
+  gtk_widget_show ( scroll_win);
+  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_win), 
+                                GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+  store = gtk_list_store_new (N_COLUMNS,G_TYPE_STRING);
+  tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL (store));
+  gtk_widget_show ( tree);
+  g_object_unref (G_OBJECT (store));
+               
+  renderer = gtk_cell_renderer_text_new ();
+  column   = gtk_tree_view_column_new_with_attributes (column_title,
+                                                    renderer,
+                                                    "text", MODULE_COLUMN,
+                                                    NULL);
+  gtk_tree_view_column_set_alignment (column, 0.5);
+  gtk_tree_view_column_set_fixed_width (column, 150);
+  gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
+
+  select = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree));
+  gtk_tree_selection_set_mode (select, GTK_SELECTION_SINGLE);
+
+  gtk_container_add (GTK_CONTAINER (scroll_win), tree);  
+
+  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialogue)->vbox), scroll_win,TRUE, TRUE,0);
+
+  for(i=0;i<nb_module;i++){
+    gtk_list_store_append (store, &iter);
+    gtk_list_store_set (store, &iter, MODULE_COLUMN,loaded_module_name[i],-1);
+  }
+
+  id = gtk_dialog_run(GTK_DIALOG(dialogue));
+  switch(id){
+    case GTK_RESPONSE_ACCEPT:
+    case GTK_RESPONSE_OK:
+      if (gtk_tree_selection_get_selected (select, (GtkTreeModel**)&store, &iter)){
+         gtk_tree_model_get ((GtkTreeModel*)store, &iter, MODULE_COLUMN, &unload_module_name, -1);
+      }
+    case GTK_RESPONSE_REJECT:
+    case GTK_RESPONSE_CANCEL:
+    default:
+      gtk_widget_destroy(dialogue);
+      break;
+  }
+
+  return unload_module_name;
+}
+
+
+/* hash funtions 
+ */
+
+void main_window_destroy_hash_key(gpointer key)
+{
+  g_free(key);
+}
+
+void main_window_destroy_hash_data(gpointer data)
+{
+}
+
+
+/* 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;
+  GdkPixbuf *pixbuf;
+  view_constructor constructor;
+  LttvMenus * menu;
+  LttvToolbars * toolbar;
+  lttv_menu_closure *menu_item;
+  lttv_toolbar_closure *toolbar_item;
+  LttvAttributeValue value;
+  LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes());
+  GtkWidget * tool_menu_title_menu, *insert_view, *pixmap, *tmp;
+
+  g_assert(lttv_iattribute_find_by_path(attributes,
+          "viewers/menu", LTTV_POINTER, &value));
+  menu = (LttvMenus*)*(value.v_pointer);
+
+  if(menu){
+    for(i=0;i<menu->len;i++){
+      menu_item = &g_array_index(menu, lttv_menu_closure, i);
+      tmp = g_hash_table_lookup(mw->hash_menu_item, g_strdup(menu_item->menuText));
+      if(tmp)continue;
+      constructor = menu_item->con;
+      tool_menu_title_menu = lookup_widget(mw->mwindow,"ToolMenuTitle_menu");
+      insert_view = gtk_menu_item_new_with_mnemonic (menu_item->menuText);
+      gtk_widget_show (insert_view);
+      gtk_container_add (GTK_CONTAINER (tool_menu_title_menu), insert_view);
+      g_signal_connect ((gpointer) insert_view, "activate",
+                       G_CALLBACK (insert_viewer_wrap),
+                       constructor);  
+      g_hash_table_insert(mw->hash_menu_item, g_strdup(menu_item->menuText),
+                         insert_view);
+    }
+  }
+
+  g_assert(lttv_iattribute_find_by_path(attributes,
+          "viewers/toolbar", LTTV_POINTER, &value));
+  toolbar = (LttvToolbars*)*(value.v_pointer);
+
+  if(toolbar){
+    for(i=0;i<toolbar->len;i++){
+      toolbar_item = &g_array_index(toolbar, lttv_toolbar_closure, 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,"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),
+                                               GTK_TOOLBAR_CHILD_BUTTON,
+                                               NULL,
+                                               "",
+                                               toolbar_item->tooltip, NULL,
+                                               pixmap, NULL, NULL);
+      gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (tool_menu_title_menu)->children)->data))->label), TRUE);
+      gtk_widget_show (insert_view);
+      gtk_container_set_border_width (GTK_CONTAINER (insert_view), 1);
+      g_signal_connect ((gpointer) insert_view, "clicked",G_CALLBACK (insert_viewer_wrap),constructor);       
+      g_hash_table_insert(mw->hash_toolbar_item, g_strdup(toolbar_item->tooltip),
+                         insert_view);
+    }
+  }
+}
+
+
+/* Create a main window
+ */
+
+void construct_main_window(MainWindow * parent)
+{
+  g_debug("construct_main_window()");
+  GtkWidget  * new_window; /* New generated main window */
+  MainWindow * new_m_window;/* New main window structure */
+  GtkNotebook * notebook;
+  LttvIAttribute *attributes =
+         LTTV_IATTRIBUTE(g_object_new(LTTV_ATTRIBUTE_TYPE, NULL));
+  LttvAttributeValue value;
+         
+  new_m_window = g_new(MainWindow, 1);
+
+  // Add the object's information to the module's array 
+  g_main_window_list = g_slist_append(g_main_window_list, new_m_window);
+
+
+  new_window  = create_MWindow();
+  gtk_widget_show (new_window);
+    
+  new_m_window->attributes = attributes;
+  
+  new_m_window->mwindow = new_window;
+  new_m_window->tab = NULL;
+  new_m_window->current_tab = NULL;
+  new_m_window->attributes = LTTV_IATTRIBUTE(g_object_new(LTTV_ATTRIBUTE_TYPE, NULL));
+
+  new_m_window->hash_menu_item = g_hash_table_new_full (g_str_hash, g_str_equal,
+                                             main_window_destroy_hash_key, 
+                                             main_window_destroy_hash_data);
+  new_m_window->hash_toolbar_item = g_hash_table_new_full (g_str_hash, g_str_equal,
+                                             main_window_destroy_hash_key, 
+                                             main_window_destroy_hash_data);
+
+  insert_menu_toolbar_item(new_m_window, NULL);
+  
+  g_object_set_data(G_OBJECT(new_window), "mainWindow", (gpointer)new_m_window);    
+
+  //create a default tab
+  notebook = (GtkNotebook *)lookup_widget(new_m_window->mwindow, "MNotebook");
+  if(notebook == NULL){
+    g_printf("Notebook does not exist\n");
+    return;
+  }
+  //for now there is no name field in LttvTraceset structure
+  //Use "Traceset" as the label for the default tab
+  create_tab(parent, new_m_window, notebook,"Traceset");
+
+  g_object_set_data_full(
+                       G_OBJECT(new_m_window->mwindow),
+                       "Main_Window_Data",
+                       new_m_window,
+                       (GDestroyNotify)main_window_free);
+
+  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;
+  LttvTrace * trace;
+
+  if(tab_instance->attributes)
+    g_object_unref(tab_instance->attributes);  
+
+  if(tab_instance->mw->tab == tab_instance){
+    tab_instance->mw->tab = tab_instance->next;
+  }else{
+    Tab * tmp1, *tmp = tab_instance->mw->tab;
+    while(tmp != tab_instance){
+      tmp1 = tmp;
+      tmp = tmp->next;
+    }
+    tmp1->next = tab_instance->next;
+  }
+
+  if(tab_instance->traceset_info->traceset_context != NULL){
+    lttv_context_fini(LTTV_TRACESET_CONTEXT(tab_instance->traceset_info->
+                                           traceset_context));
+    g_object_unref(tab_instance->traceset_info->traceset_context);
+  }
+  if(tab_instance->traceset_info->traceset != NULL) {
+    nb = lttv_traceset_number(tab_instance->traceset_info->traceset);
+    for(i = 0 ; i < nb ; i++) {
+      trace = lttv_traceset_get(tab_instance->traceset_info->traceset, i);
+      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_traceset_destroy(tab_instance->traceset_info->traceset); 
+  g_free(tab_instance->traceset_info);
+  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)
+{
+  GList * list;
+  Tab * tmp_tab;
+  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){
+    mw_data->current_tab = NULL;
+    tmp_tab = g_new(Tab,1);
+    mw_data->tab = tmp_tab;    
+  }else{
+    tmp_tab->next = g_new(Tab,1);
+    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_copy(parent->current_tab->traceset_info->traceset);
+  }else{
+    if(mw_data->current_tab){
+      tmp_tab->traceset_info->traceset = 
+        lttv_traceset_copy(mw_data->current_tab->traceset_info->traceset);
+    }else{
+      tmp_tab->traceset_info->traceset = lttv_traceset_new();    
+      /* Add the command line trace */
+      if(g_init_trace != NULL)
+       lttv_traceset_add(tmp_tab->traceset_info->traceset, g_init_trace);
+    }
+  }
+  //FIXME copy not implemented in lower level
+  tmp_tab->traceset_info->traceset_context =
+    g_object_new(LTTV_TRACESET_STATS_TYPE, NULL);
+  lttv_context_init(
+           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->time_window      = mw_data->current_tab->time_window;
+    tmp_tab->current_time     = mw_data->current_tab->current_time;
+  }else{
+    // Will have to read directly at the main window level, as we want
+    // to be able to modify a traceset on the fly.
+    // get_traceset_time_span(mw_data,&tmp_tab->traceStartTime, &tmp_tab->traceEndTime);
+    tmp_tab->time_window.start_time   = 
+           LTTV_TRACESET_CONTEXT(tmp_tab->traceset_info->traceset_context)->Time_Span->startTime;
+    if(DEFAULT_TIME_WIDTH_S <
+              LTTV_TRACESET_CONTEXT(tmp_tab->traceset_info->traceset_context)->Time_Span->endTime.tv_sec)
+      tmp_time.tv_sec = DEFAULT_TIME_WIDTH_S;
+    else
+      tmp_time.tv_sec =
+              LTTV_TRACESET_CONTEXT(tmp_tab->traceset_info->traceset_context)->Time_Span->endTime.tv_sec;
+    tmp_time.tv_nsec = 0;
+    tmp_tab->time_window.time_width = tmp_time ;
+    tmp_tab->current_time.tv_sec = 
+       LTTV_TRACESET_CONTEXT(tmp_tab->traceset_info->traceset_context)->Time_Span->startTime.tv_sec;
+    tmp_tab->current_time.tv_nsec = 
+       LTTV_TRACESET_CONTEXT(tmp_tab->traceset_info->traceset_context)->Time_Span->startTime.tv_nsec;
+  }
+  tmp_tab->attributes = LTTV_IATTRIBUTE(g_object_new(LTTV_ATTRIBUTE_TYPE, NULL));
+  //  mw_data->current_tab = tmp_tab;
+  tmp_tab->multi_vpaned = (GtkMultiVPaned*)gtk_multi_vpaned_new();
+  tmp_tab->multi_vpaned->mw = mw_data;
+  gtk_widget_show((GtkWidget*)tmp_tab->multi_vpaned);
+  tmp_tab->next = NULL;    
+  tmp_tab->mw   = mw_data;
+
+  tmp_tab->label = gtk_label_new (label);
+  gtk_widget_show (tmp_tab->label);
+
+  g_object_set_data_full(
+           G_OBJECT(tmp_tab->multi_vpaned),
+           "Tab_Info",
+          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;
+  lttv_menu_closure *menu_item = (lttv_menu_closure *)user_data;
+  GtkWidget * tool_menu_title_menu, *insert_view;
+
+  tool_menu_title_menu = lookup_widget(mw->mwindow,"ToolMenuTitle_menu");
+  insert_view = (GtkWidget*)g_hash_table_lookup(mw->hash_menu_item,
+                                               menu_item->menuText);
+  if(insert_view){
+    g_hash_table_remove(mw->hash_menu_item, menu_item->menuText);
+    gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu), insert_view);
+  }
+}
+
+void remove_toolbar_item(gpointer main_win, gpointer user_data)
+{
+  MainWindow * mw = (MainWindow *) main_win;
+  lttv_toolbar_closure *toolbar_item = (lttv_toolbar_closure *)user_data;
+  GtkWidget * tool_menu_title_menu, *insert_view;
+
+
+  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){
+    g_hash_table_remove(mw->hash_toolbar_item, toolbar_item->tooltip);
+    gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu), insert_view);
+  }
+}
+
+/**
+ * Remove menu and toolbar item when a module unloaded from all 
+ * main windows
+ */
+
+void main_window_remove_menu_item(lttv_constructor constructor)
+{
+  int i;
+  LttvMenus * menu;
+  lttv_menu_closure *menu_item;
+  LttvAttributeValue value;
+  LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes());
+
+  g_assert(lttv_iattribute_find_by_path(attributes,
+          "viewers/menu", LTTV_POINTER, &value));
+  menu = (LttvMenus*)*(value.v_pointer);
+
+  if(menu){
+    for(i=0;i<menu->len;i++){
+      menu_item = &g_array_index(menu, lttv_menu_closure, i);
+      if(menu_item->con != constructor) continue;
+      if(g_main_window_list){
+       g_slist_foreach(g_main_window_list, remove_menu_item, menu_item);
+      }
+      break;
+    }
+  }
+  
+}
+
+void main_window_remove_toolbar_item(lttv_constructor constructor)
+{
+  int i;
+  LttvToolbars * toolbar;
+  lttv_toolbar_closure *toolbar_item;
+  LttvAttributeValue value;
+  LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes());
+
+  g_assert(lttv_iattribute_find_by_path(attributes,
+          "viewers/toolbar", LTTV_POINTER, &value));
+  toolbar = (LttvToolbars*)*(value.v_pointer);
+
+  if(toolbar){
+    for(i=0;i<toolbar->len;i++){
+      toolbar_item = &g_array_index(toolbar, lttv_toolbar_closure, i);
+      if(toolbar_item->con != constructor) continue;
+      if(g_main_window_list){
+       g_slist_foreach(g_main_window_list, remove_toolbar_item, toolbar_item);
+      }
+      break;
+    }
+  }
+}
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.h b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.h
new file mode 100644 (file)
index 0000000..96cc541
--- /dev/null
@@ -0,0 +1,243 @@
+/* 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.
+ */
+
+#include <gtk/gtk.h>
+#include <lttvwindow/common.h>
+#include <lttvwindow/mainwindow.h>
+
+/* internal functions */
+
+void create_new_window(GtkWidget* widget, gpointer user_data, gboolean clone);
+void insert_menu_toolbar_item(MainWindow * mw, gpointer user_data);
+void construct_main_window(MainWindow * parent);
+void main_window_free(MainWindow * mw);
+void main_window_destructor(MainWindow * mw);
+
+/* callback functions*/
+
+void
+on_empty_traceset_activate             (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_clone_traceset_activate             (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_tab_activate                        (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_open_activate                       (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_close_activate                      (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_close_tab_activate                  (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_add_trace_activate                  (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_remove_trace_activate               (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_save_activate                       (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_save_as_activate                    (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_quit_activate                       (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_cut_activate                        (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_copy_activate                       (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_paste_activate                      (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_delete_activate                     (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_zoom_in_activate                    (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_zoom_out_activate                   (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_zoom_extended_activate              (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_go_to_time_activate                 (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_show_time_frame_activate            (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_move_viewer_up_activate             (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_move_viewer_down_activate           (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_remove_viewer_activate              (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_trace_filter_activate              (GtkMenuItem     *menuitem,
+                                      gpointer         user_data);
+
+void
+on_trace_facility_activate              (GtkMenuItem     *menuitem,
+                                      gpointer         user_data);
+
+void
+on_load_module_activate                (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_unload_module_activate              (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_add_module_search_path_activate     (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_color_activate                      (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_filter_activate                     (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_save_configuration_activate         (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_content_activate                    (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_about_activate                      (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+on_button_new_clicked                  (GtkButton       *button,
+                                        gpointer         user_data);
+void
+on_button_new_tab_clicked              (GtkButton       *button,
+                                        gpointer         user_data);
+void
+on_button_open_clicked                 (GtkButton       *button,
+                                        gpointer         user_data);
+
+void
+on_button_add_trace_clicked            (GtkButton       *button,
+                                        gpointer         user_data);
+
+void
+on_button_remove_trace_clicked         (GtkButton       *button,
+                                        gpointer         user_data);
+
+void
+on_button_save_clicked                 (GtkButton       *button,
+                                        gpointer         user_data);
+
+void
+on_button_save_as_clicked              (GtkButton       *button,
+                                        gpointer         user_data);
+
+void
+on_button_zoom_in_clicked              (GtkButton       *button,
+                                        gpointer         user_data);
+
+void
+on_button_zoom_out_clicked             (GtkButton       *button,
+                                        gpointer         user_data);
+
+void
+on_button_zoom_extended_clicked        (GtkButton       *button,
+                                        gpointer         user_data);
+
+void
+on_button_go_to_time_clicked           (GtkButton       *button,
+                                        gpointer         user_data);
+
+void
+on_button_show_time_frame_clicked      (GtkButton       *button,
+                                        gpointer         user_data);
+
+void
+on_button_move_up_clicked              (GtkButton       *button,
+                                        gpointer         user_data);
+
+void
+on_button_move_down_clicked            (GtkButton       *button,
+                                        gpointer         user_data);
+
+void
+on_button_delete_viewer_clicked        (GtkButton       *button,
+                                        gpointer         user_data);
+
+void
+on_MWindow_destroy                     (GtkObject       *object,
+                                        gpointer         user_data);
+
+gboolean    
+on_MWindow_configure                   (GtkWidget         *widget,
+                                        GdkEventConfigure *event,
+                                        gpointer           user_data);
+
+void
+on_insert_viewer_test_activate         (GtkMenuItem     *menuitem,
+                                        gpointer         user_data);
+
+void
+insertViewTest(GtkMenuItem *menuitem, gpointer user_data);
+
+void
+on_MNotebook_switch_page               (GtkNotebook     *notebook,
+                                        GtkNotebookPage *page,
+                                        guint            page_num,
+                                        gpointer         user_data);
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/common.h b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/common.h
new file mode 100644 (file)
index 0000000..e41a735
--- /dev/null
@@ -0,0 +1,43 @@
+/* This file is part of the Linux Trace Toolkit viewer
+ * Copyright (C) 2003-2004 Xiangxiu 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.
+ */
+
+#ifndef COMMON_H
+#define COMMON_H
+
+#include <stdio.h>
+#include <ltt/ltt.h>
+#include <gtk/gtk.h>
+#include <lttvwindow/lttvfilter.h>
+
+#define MAX_NUMBER_EVENT     "MAX_NUMBER_EVENT"
+#define TRACESET_TIME_SPAN   "TRACESET_TIME_SPAN"
+
+typedef struct _MainWindow MainWindow;
+typedef struct _Tab Tab;
+
+/* constructor of the viewer */
+typedef GtkWidget * (*lttv_constructor)(MainWindow * main_window, 
+                           LttvTracesetSelector * s, char *key);
+typedef lttv_constructor view_constructor;
+
+typedef struct _TimeWindow {
+       LttTime start_time;
+       LttTime time_width;
+} TimeWindow;
+
+#endif // COMMON_H
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/gtkdirsel.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/gtkdirsel.c
new file mode 100644 (file)
index 0000000..a52e877
--- /dev/null
@@ -0,0 +1,4064 @@
+/* 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.
+ */
+
+#include "config.h"
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
+#include <stdlib.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <string.h>
+#include <errno.h>
+#ifdef HAVE_PWD_H
+#include <pwd.h>
+#endif
+
+#include <glib.h>              /* Include early to get G_OS_WIN32 and
+                                * G_WITH_CYGWIN */
+
+#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
+#include <ctype.h>
+#define STRICT
+#include <windows.h>
+#undef STRICT
+#endif /* G_OS_WIN32 || G_WITH_CYGWIN */
+#ifdef G_OS_WIN32
+#include <winsock.h>           /* For gethostname */
+#endif
+
+#include "gdk/gdkkeysyms.h"
+#include <gtk/gtk.h>
+#include <lttvwindow/gtkdirsel.h>
+
+#define _(A) A
+#define WANT_HPANED 1
+
+#ifdef G_OS_WIN32
+#include <direct.h>
+#include <io.h>
+#define mkdir(p,m) _mkdir(p)
+#ifndef S_ISDIR
+#define S_ISDIR(mode) ((mode)&_S_IFDIR)
+#endif
+#endif /* G_OS_WIN32 */
+
+#ifdef G_WITH_CYGWIN
+#include <sys/cygwin.h>                /* For cygwin_conv_to_posix_path */
+#endif
+
+#define DIR_LIST_WIDTH   180
+#define DIR_LIST_HEIGHT  180
+#define FILE_LIST_WIDTH  180
+#define FILE_LIST_HEIGHT 180
+
+/* The Hurd doesn't define either PATH_MAX or MAXPATHLEN, so we put this
+ * in here, since the rest of the code in the file does require some
+ * fixed maximum.
+ */
+#ifndef MAXPATHLEN
+#  ifdef PATH_MAX
+#    define MAXPATHLEN PATH_MAX
+#  else
+#    define MAXPATHLEN 2048
+#  endif
+#endif
+
+/* I've put this here so it doesn't get confused with the 
+ * file completion interface */
+typedef struct _HistoryCallbackArg HistoryCallbackArg;
+
+struct _HistoryCallbackArg
+{
+  gchar *directory;
+  GtkWidget *menu_item;
+};
+
+
+typedef struct _CompletionState    CompletionState;
+typedef struct _CompletionDir      CompletionDir;
+typedef struct _CompletionDirSent  CompletionDirSent;
+typedef struct _CompletionDirEntry CompletionDirEntry;
+typedef struct _CompletionUserDir  CompletionUserDir;
+typedef struct _PossibleCompletion PossibleCompletion;
+
+/* Non-external file completion decls and structures */
+
+/* A contant telling PRCS how many directories to cache.  Its actually
+ * kept in a list, so the geometry isn't important. */
+#define CMPL_DIRECTORY_CACHE_SIZE 10
+
+/* A constant used to determine whether a substring was an exact
+ * match by first_diff_index()
+ */
+#define PATTERN_MATCH -1
+#define CMPL_ERRNO_TOO_LONG ((1<<16)-1)
+#define CMPL_ERRNO_DID_NOT_CONVERT ((1<<16)-2)
+
+/* This structure contains all the useful information about a directory
+ * for the purposes of filename completion.  These structures are cached
+ * in the CompletionState struct.  CompletionDir's are reference counted.
+ */
+struct _CompletionDirSent
+{
+  ino_t inode;
+  time_t mtime;
+  dev_t device;
+
+  gint entry_count;
+  struct _CompletionDirEntry *entries;
+};
+
+struct _CompletionDir
+{
+  CompletionDirSent *sent;
+
+  gchar *fullname;
+  gint fullname_len;
+
+  struct _CompletionDir *cmpl_parent;
+  gint cmpl_index;
+  gchar *cmpl_text;
+};
+
+/* This structure contains pairs of directory entry names with a flag saying
+ * whether or not they are a valid directory.  NOTE: This information is used
+ * to provide the caller with information about whether to update its completions
+ * or try to open a file.  Since directories are cached by the directory mtime,
+ * a symlink which points to an invalid file (which will not be a directory),
+ * will not be reevaluated if that file is created, unless the containing
+ * directory is touched.  I consider this case to be worth ignoring (josh).
+ */
+struct _CompletionDirEntry
+{
+  gboolean is_dir;
+  gchar *entry_name;
+  gchar *sort_key;
+};
+
+struct _CompletionUserDir
+{
+  gchar *login;
+  gchar *homedir;
+};
+
+struct _PossibleCompletion
+{
+  /* accessible fields, all are accessed externally by functions
+   * declared above
+   */
+  gchar *text;
+  gint is_a_completion;
+  gboolean is_directory;
+
+  /* Private fields
+   */
+  gint text_alloc;
+};
+
+struct _CompletionState
+{
+  gint last_valid_char;
+  gchar *updated_text;
+  gint updated_text_len;
+  gint updated_text_alloc;
+  gboolean re_complete;
+
+  gchar *user_dir_name_buffer;
+  gint user_directories_len;
+
+  gchar *last_completion_text;
+
+  gint user_completion_index; /* if >= 0, currently completing ~user */
+
+  struct _CompletionDir *completion_dir; /* directory completing from */
+  struct _CompletionDir *active_completion_dir;
+
+  struct _PossibleCompletion the_completion;
+
+  struct _CompletionDir *reference_dir; /* initial directory */
+
+  GList* directory_storage;
+  GList* directory_sent_storage;
+
+  struct _CompletionUserDir *user_directories;
+};
+
+enum {
+  PROP_0,
+  PROP_SHOW_FILEOPS,
+  PROP_FILENAME,
+  PROP_SELECT_MULTIPLE
+};
+
+enum {
+  DIR_COLUMN
+};
+
+enum {
+  FILE_COLUMN
+};
+
+/* File completion functions which would be external, were they used
+ * outside of this file.
+ */
+
+static CompletionState*    cmpl_init_state        (void);
+static void                cmpl_free_state        (CompletionState *cmpl_state);
+static gint                cmpl_state_okay        (CompletionState* cmpl_state);
+static const gchar*        cmpl_strerror          (gint);
+
+static PossibleCompletion* cmpl_completion_matches(gchar           *text_to_complete,
+                                                  gchar          **remaining_text,
+                                                  CompletionState *cmpl_state);
+
+/* Returns a name for consideration, possibly a completion, this name
+ * will be invalid after the next call to cmpl_next_completion.
+ */
+static char*               cmpl_this_completion   (PossibleCompletion*);
+
+/* True if this completion matches the given text.  Otherwise, this
+ * output can be used to have a list of non-completions.
+ */
+static gint                cmpl_is_a_completion   (PossibleCompletion*);
+
+/* True if the completion is a directory
+ */
+static gboolean            cmpl_is_directory      (PossibleCompletion*);
+
+/* Obtains the next completion, or NULL
+ */
+static PossibleCompletion* cmpl_next_completion   (CompletionState*);
+
+/* Updating completions: the return value of cmpl_updated_text() will
+ * be text_to_complete completed as much as possible after the most
+ * recent call to cmpl_completion_matches.  For the present
+ * application, this is the suggested replacement for the user's input
+ * string.  You must CALL THIS AFTER ALL cmpl_text_completions have
+ * been received.
+ */
+static gchar*              cmpl_updated_text       (CompletionState* cmpl_state);
+
+/* After updating, to see if the completion was a directory, call
+ * this.  If it was, you should consider re-calling completion_matches.
+ */
+static gboolean            cmpl_updated_dir        (CompletionState* cmpl_state);
+
+/* Current location: if using file completion, return the current
+ * directory, from which file completion begins.  More specifically,
+ * the cwd concatenated with all exact completions up to the last
+ * directory delimiter('/').
+ */
+static gchar*              cmpl_reference_position (CompletionState* cmpl_state);
+
+/* backing up: if cmpl_completion_matches returns NULL, you may query
+ * the index of the last completable character into cmpl_updated_text.
+ */
+static gint                cmpl_last_valid_char    (CompletionState* cmpl_state);
+
+/* When the user selects a non-directory, call cmpl_completion_fullname
+ * to get the full name of the selected file.
+ */
+static const gchar*        cmpl_completion_fullname (const gchar*, CompletionState* cmpl_state);
+
+
+/* Directory operations. */
+static CompletionDir* open_ref_dir         (gchar* text_to_complete,
+                                           gchar** remaining_text,
+                                           CompletionState* cmpl_state);
+#if !defined(G_OS_WIN32) && !defined(G_WITH_CYGWIN)
+static gboolean       check_dir            (gchar *dir_name, 
+                                           struct stat *result, 
+                                           gboolean *stat_subdirs);
+#endif
+static CompletionDir* open_dir             (gchar* dir_name,
+                                           CompletionState* cmpl_state);
+#ifdef HAVE_PWD_H
+static CompletionDir* open_user_dir        (const gchar* text_to_complete,
+                                           CompletionState *cmpl_state);
+#endif
+static CompletionDir* open_relative_dir    (gchar* dir_name, CompletionDir* dir,
+                                           CompletionState *cmpl_state);
+static CompletionDirSent* open_new_dir     (gchar* dir_name, 
+                                           struct stat* sbuf,
+                                           gboolean stat_subdirs);
+static gint           correct_dir_fullname (CompletionDir* cmpl_dir);
+static gint           correct_parent       (CompletionDir* cmpl_dir,
+                                           struct stat *sbuf);
+#ifndef G_OS_WIN32
+static gchar*         find_parent_dir_fullname    (gchar* dirname);
+#endif
+static CompletionDir* attach_dir           (CompletionDirSent* sent,
+                                           gchar* dir_name,
+                                           CompletionState *cmpl_state);
+static void           free_dir_sent (CompletionDirSent* sent);
+static void           free_dir      (CompletionDir  *dir);
+static void           prune_memory_usage(CompletionState *cmpl_state);
+
+/* Completion operations */
+#ifdef HAVE_PWD_H
+static PossibleCompletion* attempt_homedir_completion(gchar* text_to_complete,
+                                                     CompletionState *cmpl_state);
+#endif
+static PossibleCompletion* attempt_dir_completion(CompletionState *cmpl_state);
+static CompletionDir* find_completion_dir(gchar* text_to_complete,
+                                         gchar** remaining_text,
+                                         CompletionState* cmpl_state);
+static PossibleCompletion* append_completion_text(gchar* text,
+                                                 CompletionState* cmpl_state);
+#ifdef HAVE_PWD_H
+static gint get_pwdb(CompletionState* cmpl_state);
+static gint compare_user_dir(const void* a, const void* b);
+#endif
+static gint first_diff_index(gchar* pat, gchar* text);
+static gint compare_cmpl_dir(const void* a, const void* b);
+static void update_cmpl(PossibleCompletion* poss,
+                       CompletionState* cmpl_state);
+
+static void gtk_dir_selection_class_init    (GtkDirSelectionClass *klass);
+static void gtk_dir_selection_set_property  (GObject         *object,
+                                             guint            prop_id,
+                                             const GValue    *value,
+                                             GParamSpec      *pspec);
+static void gtk_dir_selection_get_property  (GObject         *object,
+                                             guint            prop_id,
+                                             GValue          *value,
+                                             GParamSpec      *pspec);
+static void gtk_dir_selection_init          (GtkDirSelection      *filesel);
+static void gtk_dir_selection_finalize      (GObject               *object);
+static void gtk_dir_selection_destroy       (GtkObject             *object);
+static void gtk_dir_selection_map           (GtkWidget             *widget);
+static gint gtk_dir_selection_key_press     (GtkWidget             *widget,
+                                             GdkEventKey           *event,
+                                             gpointer               user_data);
+static gint gtk_dir_selection_insert_text   (GtkWidget             *widget,
+                                             const gchar           *new_text,
+                                             gint                   new_text_length,
+                                             gint                  *position,
+                                             gpointer               user_data);
+static void gtk_dir_selection_update_fileops (GtkDirSelection     *filesel);
+
+static void gtk_dir_selection_file_activate (GtkTreeView       *tree_view,
+                                             GtkTreePath       *path,
+                                             GtkTreeViewColumn *column,
+                                             gpointer           user_data);
+static void gtk_dir_selection_file_changed  (GtkTreeSelection  *selection,
+                                             gpointer           user_data);
+static void gtk_dir_selection_dir_activate  (GtkTreeView       *tree_view,
+                                             GtkTreePath       *path,
+                                             GtkTreeViewColumn *column,
+                                             gpointer           user_data);
+static void gtk_dir_selection_dir_changed  (GtkTreeSelection  *selection,
+                                             gpointer           user_data);
+static void gtk_dir_selection_populate      (GtkDirSelection      *fs,
+                                             gchar                 *rel_path,
+                                             gboolean               try_complete,
+                                             gboolean               reset_entry);
+static void gtk_dir_selection_abort         (GtkDirSelection      *fs);
+
+static void gtk_dir_selection_update_history_menu (GtkDirSelection       *fs,
+                                                   gchar                  *current_dir);
+
+static void gtk_dir_selection_create_dir  (GtkWidget *widget, gpointer data);
+static void gtk_dir_selection_delete_file (GtkWidget *widget, gpointer data);
+static void gtk_dir_selection_rename_file (GtkWidget *widget, gpointer data);
+
+static void free_selected_names (GPtrArray *names);
+
+#if !defined(G_OS_WIN32) && !defined(G_WITH_CYGWIN)
+#define compare_filenames(a, b) strcmp(a, b)
+#else
+#define compare_filenames(a, b) g_ascii_strcasecmp(a, b)
+#endif
+
+
+static GtkWindowClass *parent_class = NULL;
+
+/* Saves errno when something cmpl does fails. */
+static gint cmpl_errno;
+
+#ifdef G_WITH_CYGWIN
+/*
+ * Take the path currently in the file selection
+ * entry field and translate as necessary from
+ * a WIN32 style to CYGWIN32 style path.  For
+ * instance translate:
+ * x:\somepath\file.jpg
+ * to:
+ * /cygdrive/x/somepath/file.jpg
+ *
+ * Replace the path in the selection text field.
+ * Return a boolean value concerning whether a
+ * translation had to be made.
+ */
+static int
+translate_win32_path (GtkDirSelection *filesel)
+{
+  int updated = 0;
+  const gchar *path;
+  gchar newPath[MAX_PATH];
+
+  /*
+   * Retrieve the current path
+   */
+  path = gtk_entry_get_text (GTK_ENTRY (filesel->selection_entry));
+
+  cygwin_conv_to_posix_path (path, newPath);
+  updated = (strcmp (path, newPath) != 0);
+
+  if (updated)
+    gtk_entry_set_text (GTK_ENTRY (filesel->selection_entry), newPath);
+    
+  return updated;
+}
+#endif
+
+GType
+gtk_dir_selection_get_type (void)
+{
+  static GType file_selection_type = 0;
+
+  if (!file_selection_type)
+    {
+      static const GTypeInfo filesel_info =
+      {
+       sizeof (GtkDirSelectionClass),
+       NULL,           /* base_init */
+       NULL,           /* base_finalize */
+       (GClassInitFunc) gtk_dir_selection_class_init,
+       NULL,           /* class_finalize */
+       NULL,           /* class_data */
+       sizeof (GtkDirSelection),
+       0,              /* n_preallocs */
+       (GInstanceInitFunc) gtk_dir_selection_init,
+      };
+
+      file_selection_type =
+       g_type_register_static (GTK_TYPE_DIALOG, "GtkDirSelection",
+                               &filesel_info, 0);
+    }
+
+  return file_selection_type;
+}
+
+static void
+gtk_dir_selection_class_init (GtkDirSelectionClass *class)
+{
+  GObjectClass *gobject_class;
+  GtkObjectClass *object_class;
+  GtkWidgetClass *widget_class;
+
+  gobject_class = (GObjectClass*) class;
+  object_class = (GtkObjectClass*) class;
+  widget_class = (GtkWidgetClass*) class;
+
+  parent_class = g_type_class_peek_parent (class);
+
+  gobject_class->finalize = gtk_dir_selection_finalize;
+  gobject_class->set_property = gtk_dir_selection_set_property;
+  gobject_class->get_property = gtk_dir_selection_get_property;
+   
+  g_object_class_install_property (gobject_class,
+                                   PROP_FILENAME,
+                                   g_param_spec_string ("filename",
+                                                        _("Filename"),
+                                                        _("The currently selected filename"),
+                                                        NULL,
+                                                        G_PARAM_READABLE | G_PARAM_WRITABLE));
+  g_object_class_install_property (gobject_class,
+                                  PROP_SHOW_FILEOPS,
+                                  g_param_spec_boolean ("show_fileops",
+                                                        _("Show file operations"),
+                                                        _("Whether buttons for creating/manipulating files should be displayed"),
+                                                        FALSE,
+                                                        G_PARAM_READABLE |
+                                                        G_PARAM_WRITABLE));
+  g_object_class_install_property (gobject_class,
+                                  PROP_SELECT_MULTIPLE,
+                                  g_param_spec_boolean ("select_multiple",
+                                                        _("Select multiple"),
+                                                        _("Whether to allow multiple files to be selected"),
+                                                        FALSE,
+                                                        G_PARAM_READABLE |
+                                                        G_PARAM_WRITABLE));
+  object_class->destroy = gtk_dir_selection_destroy;
+  widget_class->map = gtk_dir_selection_map;
+}
+
+static void gtk_dir_selection_set_property (GObject         *object,
+                                            guint            prop_id,
+                                            const GValue    *value,
+                                            GParamSpec      *pspec)
+{
+  GtkDirSelection *filesel;
+
+  filesel = GTK_DIR_SELECTION (object);
+
+  switch (prop_id)
+    {
+    case PROP_FILENAME:
+      gtk_dir_selection_set_filename (filesel,
+                                       g_value_get_string (value));
+      break;
+    case PROP_SHOW_FILEOPS:
+      if (g_value_get_boolean (value))
+        gtk_dir_selection_show_fileop_buttons (filesel);
+      else
+        gtk_dir_selection_hide_fileop_buttons (filesel);
+      break;
+    case PROP_SELECT_MULTIPLE:
+      gtk_dir_selection_set_select_multiple (filesel, g_value_get_boolean (value));
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static void gtk_dir_selection_get_property (GObject         *object,
+                                            guint            prop_id,
+                                            GValue          *value,
+                                            GParamSpec      *pspec)
+{
+  GtkDirSelection *filesel;
+
+  filesel = GTK_DIR_SELECTION (object);
+
+  switch (prop_id)
+    {
+    case PROP_FILENAME:
+      g_value_set_string (value,
+                          gtk_dir_selection_get_filename(filesel));
+      break;
+
+    case PROP_SHOW_FILEOPS:
+      /* This is a little bit hacky, but doing otherwise would require
+       * adding a field to the object.
+       */
+      g_value_set_boolean (value, (filesel->fileop_c_dir && 
+                                  filesel->fileop_del_file &&
+                                  filesel->fileop_ren_file));
+      break;
+    case PROP_SELECT_MULTIPLE:
+      g_value_set_boolean (value, gtk_dir_selection_get_select_multiple (filesel));
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static gboolean
+grab_default (GtkWidget *widget)
+{
+  gtk_widget_grab_default (widget);
+  return FALSE;
+}
+     
+static void
+gtk_dir_selection_init (GtkDirSelection *filesel)
+{
+  GtkWidget *entry_vbox;
+  GtkWidget *label;
+  GtkWidget *list_hbox, *list_container;
+  GtkWidget *confirm_area;
+  GtkWidget *pulldown_hbox;
+  GtkWidget *scrolled_win;
+  GtkWidget *eventbox;
+  GtkWidget *spacer;
+  GtkDialog *dialog;
+
+  GtkListStore *model;
+  GtkTreeViewColumn *column;
+  
+  gtk_widget_push_composite_child ();
+
+  dialog = GTK_DIALOG (filesel);
+
+  filesel->cmpl_state = cmpl_init_state ();
+
+  /* The dialog-sized vertical box  */
+  filesel->main_vbox = dialog->vbox;
+  gtk_container_set_border_width (GTK_CONTAINER (filesel), 10);
+
+  /* The horizontal box containing create, rename etc. buttons */
+  filesel->button_area = gtk_hbutton_box_new ();
+  gtk_button_box_set_layout (GTK_BUTTON_BOX (filesel->button_area), GTK_BUTTONBOX_START);
+  gtk_box_set_spacing (GTK_BOX (filesel->button_area), 0);
+  gtk_box_pack_start (GTK_BOX (filesel->main_vbox), filesel->button_area, 
+                     FALSE, FALSE, 0);
+  gtk_widget_show (filesel->button_area);
+  
+  gtk_dir_selection_show_fileop_buttons (filesel);
+
+  /* hbox for pulldown menu */
+  pulldown_hbox = gtk_hbox_new (TRUE, 5);
+  gtk_box_pack_start (GTK_BOX (filesel->main_vbox), pulldown_hbox, FALSE, FALSE, 0);
+  gtk_widget_show (pulldown_hbox);
+  
+  /* Pulldown menu */
+  filesel->history_pulldown = gtk_option_menu_new ();
+  //  gtk_widget_show (filesel->history_pulldown);
+  //  gtk_box_pack_start (GTK_BOX (pulldown_hbox), filesel->history_pulldown, 
+  //                 FALSE, FALSE, 0);
+    
+  /*  The horizontal box containing the directory and file listboxes  */
+
+  spacer = gtk_hbox_new (FALSE, 0);
+  gtk_widget_set_size_request (spacer, -1, 5);
+  gtk_box_pack_start (GTK_BOX (filesel->main_vbox), spacer, FALSE, FALSE, 0);
+  gtk_widget_show (spacer);
+  
+  list_hbox = gtk_hbox_new (FALSE, 5);
+  gtk_box_pack_start (GTK_BOX (filesel->main_vbox), list_hbox, TRUE, TRUE, 0);
+  gtk_widget_show (list_hbox);
+  if (WANT_HPANED)
+    list_container = g_object_new (GTK_TYPE_HPANED,
+                                  "visible", TRUE,
+                                  "parent", list_hbox,
+                                  "border_width", 0,
+                                  NULL);
+  else
+    list_container = list_hbox;
+
+  spacer = gtk_hbox_new (FALSE, 0);
+  gtk_widget_set_size_request (spacer, -1, 5);
+  gtk_box_pack_start (GTK_BOX (filesel->main_vbox), spacer, FALSE, FALSE, 0);  
+  gtk_widget_show (spacer);
+  
+  /* The directories list */
+
+  model = gtk_list_store_new (1, G_TYPE_STRING);
+  filesel->dir_list = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+  g_object_unref (model);
+
+  column = gtk_tree_view_column_new_with_attributes (_("Folders"),
+                                                    gtk_cell_renderer_text_new (),
+                                                    "text", DIR_COLUMN,
+                                                    NULL);
+  label = gtk_label_new_with_mnemonic (_("Fol_ders"));
+  gtk_label_set_mnemonic_widget (GTK_LABEL (label), filesel->dir_list);
+  gtk_widget_show (label);
+  gtk_tree_view_column_set_widget (column, label);
+  gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
+  gtk_tree_view_append_column (GTK_TREE_VIEW (filesel->dir_list), column);
+
+  gtk_widget_set_size_request (filesel->dir_list,
+                              DIR_LIST_WIDTH, DIR_LIST_HEIGHT);
+  g_signal_connect (filesel->dir_list, "row_activated",
+                   G_CALLBACK (gtk_dir_selection_dir_activate), filesel);
+  g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (filesel->dir_list)), "changed",
+                   G_CALLBACK (gtk_dir_selection_dir_changed), filesel);
+
+  /*  gtk_clist_column_titles_passive (GTK_CLIST (filesel->dir_list)); */
+
+  scrolled_win = gtk_scrolled_window_new (NULL, NULL);
+  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win), GTK_SHADOW_IN);  
+  gtk_container_add (GTK_CONTAINER (scrolled_win), filesel->dir_list);
+  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
+                                 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
+  gtk_container_set_border_width (GTK_CONTAINER (scrolled_win), 0);
+  if (GTK_IS_PANED (list_container))
+    gtk_paned_pack1 (GTK_PANED (list_container), scrolled_win, TRUE, TRUE);
+  else
+    gtk_container_add (GTK_CONTAINER (list_container), scrolled_win);
+  gtk_widget_show (filesel->dir_list);
+  gtk_widget_show (scrolled_win);
+
+  /* The files list */
+  model = gtk_list_store_new (1, G_TYPE_STRING);
+  filesel->file_list = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+  g_object_unref (model);
+
+  column = gtk_tree_view_column_new_with_attributes (_("Files"),
+                                                    gtk_cell_renderer_text_new (),
+                                                    "text", FILE_COLUMN,
+                                                    NULL);
+  label = gtk_label_new_with_mnemonic (_("_Files"));
+  gtk_label_set_mnemonic_widget (GTK_LABEL (label), filesel->file_list);
+  gtk_widget_show (label);
+  gtk_tree_view_column_set_widget (column, label);
+  gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
+  gtk_tree_view_append_column (GTK_TREE_VIEW (filesel->file_list), column);
+
+  gtk_widget_set_size_request (filesel->file_list,
+                              FILE_LIST_WIDTH, FILE_LIST_HEIGHT);
+  g_signal_connect (filesel->file_list, "row_activated",
+                   G_CALLBACK (gtk_dir_selection_file_activate), filesel);
+  g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (filesel->file_list)), "changed",
+                   G_CALLBACK (gtk_dir_selection_file_changed), filesel);
+
+  /* gtk_clist_column_titles_passive (GTK_CLIST (filesel->file_list)); */
+
+  scrolled_win = gtk_scrolled_window_new (NULL, NULL);
+  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win), GTK_SHADOW_IN);
+  gtk_container_add (GTK_CONTAINER (scrolled_win), filesel->file_list);
+  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
+                                 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
+  gtk_container_set_border_width (GTK_CONTAINER (scrolled_win), 0);
+  //  gtk_container_add (GTK_CONTAINER (list_container), scrolled_win);
+  //  gtk_widget_show (filesel->file_list);
+  //  gtk_widget_show (scrolled_win);
+
+  /* action area for packing buttons into. */
+  filesel->action_area = gtk_hbox_new (TRUE, 0);
+  gtk_box_pack_start (GTK_BOX (filesel->main_vbox), filesel->action_area, 
+                     FALSE, FALSE, 0);
+  gtk_widget_show (filesel->action_area);
+  
+  /*  The OK/Cancel button area */
+  confirm_area = dialog->action_area;
+
+  /*  The Cancel button  */
+  filesel->cancel_button = gtk_dialog_add_button (dialog,
+                                                  GTK_STOCK_CANCEL,
+                                                  GTK_RESPONSE_CANCEL);
+  /*  The OK button  */
+  filesel->ok_button = gtk_dialog_add_button (dialog,
+                                              GTK_STOCK_OK,
+                                              GTK_RESPONSE_OK);
+  
+  gtk_widget_grab_default (filesel->ok_button);
+
+  /*  The selection entry widget  */
+  entry_vbox = gtk_vbox_new (FALSE, 2);
+  gtk_box_pack_end (GTK_BOX (filesel->main_vbox), entry_vbox, FALSE, FALSE, 2);
+  gtk_widget_show (entry_vbox);
+  
+  eventbox = gtk_event_box_new ();
+  filesel->selection_text = label = gtk_label_new ("");
+  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+  gtk_container_add (GTK_CONTAINER (eventbox), label);
+  gtk_box_pack_start (GTK_BOX (entry_vbox), eventbox, FALSE, FALSE, 0);
+  gtk_widget_show (label);
+  gtk_widget_show (eventbox);
+
+  filesel->selection_entry = gtk_entry_new ();
+  g_signal_connect (filesel->selection_entry, "key_press_event",
+                   G_CALLBACK (gtk_dir_selection_key_press), filesel);
+  g_signal_connect (filesel->selection_entry, "insert_text",
+                   G_CALLBACK (gtk_dir_selection_insert_text), NULL);
+  g_signal_connect_swapped (filesel->selection_entry, "changed",
+                           G_CALLBACK (gtk_dir_selection_update_fileops), filesel);
+  g_signal_connect_swapped (filesel->selection_entry, "focus_in_event",
+                           G_CALLBACK (grab_default),
+                           filesel->ok_button);
+  g_signal_connect_swapped (filesel->selection_entry, "activate",
+                           G_CALLBACK (gtk_button_clicked),
+                           filesel->ok_button);
+  
+  gtk_box_pack_start (GTK_BOX (entry_vbox), filesel->selection_entry, TRUE, TRUE, 0);
+  gtk_widget_show (filesel->selection_entry);
+
+  gtk_label_set_mnemonic_widget (GTK_LABEL (filesel->selection_text),
+                                filesel->selection_entry);
+
+  if (!cmpl_state_okay (filesel->cmpl_state))
+    {
+      gchar err_buf[256];
+
+      g_snprintf (err_buf, sizeof (err_buf), _("Folder unreadable: %s"), cmpl_strerror (cmpl_errno));
+
+      gtk_label_set_text (GTK_LABEL (filesel->selection_text), err_buf);
+    }
+  else
+    {
+      gtk_dir_selection_populate (filesel, "", FALSE, TRUE);
+    }
+
+  gtk_widget_grab_focus (filesel->selection_entry);
+
+  gtk_widget_pop_composite_child ();
+}
+
+static gchar *
+uri_list_extract_first_uri (const gchar* uri_list)
+{
+  const gchar *p, *q;
+  
+  g_return_val_if_fail (uri_list != NULL, NULL);
+  
+  p = uri_list;
+  /* We don't actually try to validate the URI according to RFC
+   * 2396, or even check for allowed characters - we just ignore
+   * comments and trim whitespace off the ends.  We also
+   * allow LF delimination as well as the specified CRLF.
+   *
+   * We do allow comments like specified in RFC 2483.
+   */
+  while (p)
+    {
+      if (*p != '#')
+       {
+         while (g_ascii_isspace(*p))
+           p++;
+         
+         q = p;
+         while (*q && (*q != '\n') && (*q != '\r'))
+           q++;
+         
+         if (q > p)
+           {
+             q--;
+             while (q > p && g_ascii_isspace (*q))
+               q--;
+
+             if (q > p)
+               return g_strndup (p, q - p + 1);
+           }
+       }
+      p = strchr (p, '\n');
+      if (p)
+       p++;
+    }
+  return NULL;
+}
+
+static void
+dnd_really_drop  (GtkWidget *dialog, gint response_id, GtkDirSelection *fs)
+{
+  gchar *filename;
+  
+  if (response_id == GTK_RESPONSE_YES)
+    {
+      filename = g_object_get_data (G_OBJECT (dialog), "gtk-fs-dnd-filename");
+
+      gtk_dir_selection_set_filename (fs, filename);
+    }
+  
+  gtk_widget_destroy (dialog);
+}
+
+
+static void
+filenames_dropped (GtkWidget        *widget,
+                  GdkDragContext   *context,
+                  gint              x,
+                  gint              y,
+                  GtkSelectionData *selection_data,
+                  guint             info,
+                  guint             time)
+{
+  char *uri = NULL;
+  char *filename = NULL;
+  char *hostname;
+  char this_hostname[257];
+  int res;
+  GError *error = NULL;
+       
+  if (!selection_data->data)
+    return;
+
+  uri = uri_list_extract_first_uri ((char *)selection_data->data);
+  
+  if (!uri)
+    return;
+
+  filename = g_filename_from_uri (uri, &hostname, &error);
+  g_free (uri);
+  
+  if (!filename)
+    {
+      g_warning ("Error getting dropped filename: %s\n",
+                error->message);
+      g_error_free (error);
+      return;
+    }
+
+  res = gethostname (this_hostname, 256);
+  this_hostname[256] = 0;
+  
+  if ((hostname == NULL) ||
+      (res == 0 && strcmp (hostname, this_hostname) == 0) ||
+      (strcmp (hostname, "localhost") == 0))
+    gtk_dir_selection_set_filename (GTK_DIR_SELECTION (widget),
+                                    filename);
+  else
+    {
+      GtkWidget *dialog;
+      gchar *filename_utf8;
+
+      /* Conversion back to UTF-8 should always succeed for the result
+       * of g_filename_from_uri()
+       */
+      filename_utf8 = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL);
+      g_assert (filename_utf8);
+      
+      dialog = gtk_message_dialog_new (GTK_WINDOW (widget),
+                                      GTK_DIALOG_DESTROY_WITH_PARENT,
+                                      GTK_MESSAGE_QUESTION,
+                                      GTK_BUTTONS_YES_NO,
+                                      _("The file \"%s\" resides on another machine (called %s) and may not be available to this program.\n"
+                                        "Are you sure that you want to select it?"), filename_utf8, hostname);
+      g_free (filename_utf8);
+
+      g_object_set_data_full (G_OBJECT (dialog), "gtk-fs-dnd-filename", g_strdup (filename), g_free);
+      
+      g_signal_connect_data (dialog, "response",
+                            (GCallback) dnd_really_drop, 
+                            widget, NULL, 0);
+      
+      gtk_widget_show (dialog);
+    }
+
+  g_free (hostname);
+  g_free (filename);
+}
+
+enum
+{
+  TARGET_URILIST,
+  TARGET_UTF8_STRING,
+  TARGET_STRING,
+  TARGET_TEXT,
+  TARGET_COMPOUND_TEXT
+};
+
+
+static void
+filenames_drag_get (GtkWidget        *widget,
+                   GdkDragContext   *context,
+                   GtkSelectionData *selection_data,
+                   guint             info,
+                   guint             time,
+                   GtkDirSelection *filesel)
+{
+  const gchar *file;
+  gchar *uri_list;
+  char hostname[256];
+  int res;
+  GError *error;
+
+  file = gtk_dir_selection_get_filename (filesel);
+
+  if (file)
+    {
+      if (info == TARGET_URILIST)
+       {
+         res = gethostname (hostname, 256);
+         
+         error = NULL;
+         uri_list = g_filename_to_uri (file, (!res)?hostname:NULL, &error);
+         if (!uri_list)
+           {
+             g_warning ("Error getting filename: %s\n",
+                        error->message);
+             g_error_free (error);
+             return;
+           }
+         
+         gtk_selection_data_set (selection_data,
+                                 selection_data->target, 8,
+                                 (void *)uri_list, strlen((char *)uri_list));
+         g_free (uri_list);
+       }
+      else
+       {
+         gchar *filename_utf8 = g_filename_to_utf8 (file, -1, NULL, NULL, NULL);
+         g_assert (filename_utf8);
+         gtk_selection_data_set_text (selection_data, filename_utf8, -1);
+         g_free (filename_utf8);
+       }
+    }
+}
+
+static void
+file_selection_setup_dnd (GtkDirSelection *filesel)
+{
+  GtkWidget *eventbox;
+  static const GtkTargetEntry drop_types[] = {
+    { "text/uri-list", 0, TARGET_URILIST}
+  };
+  static gint n_drop_types = sizeof(drop_types)/sizeof(drop_types[0]);
+  static const GtkTargetEntry drag_types[] = {
+    { "text/uri-list", 0, TARGET_URILIST},
+    { "UTF8_STRING", 0, TARGET_UTF8_STRING },
+    { "STRING", 0, 0 },
+    { "TEXT",   0, 0 }, 
+    { "COMPOUND_TEXT", 0, 0 }
+  };
+  static gint n_drag_types = sizeof(drag_types)/sizeof(drag_types[0]);
+
+  gtk_drag_dest_set (GTK_WIDGET (filesel),
+                    GTK_DEST_DEFAULT_ALL,
+                    drop_types, n_drop_types,
+                    GDK_ACTION_COPY);
+
+  g_signal_connect (filesel, "drag_data_received",
+                   G_CALLBACK (filenames_dropped), NULL);
+
+  eventbox = gtk_widget_get_parent (filesel->selection_text);
+  gtk_drag_source_set (eventbox,
+                      GDK_BUTTON1_MASK,
+                      drag_types, n_drag_types,
+                      GDK_ACTION_COPY);
+
+  g_signal_connect (eventbox, "drag_data_get",
+                   G_CALLBACK (filenames_drag_get), filesel);
+}
+
+GtkWidget*
+gtk_dir_selection_new (const gchar *title)
+{
+  GtkDirSelection *filesel;
+
+  filesel = g_object_new (GTK_TYPE_DIR_SELECTION, NULL);
+  gtk_window_set_title (GTK_WINDOW (filesel), title);
+  gtk_dialog_set_has_separator (GTK_DIALOG (filesel), FALSE);
+
+  file_selection_setup_dnd (filesel);
+  
+  return GTK_WIDGET (filesel);
+}
+
+void
+gtk_dir_selection_show_fileop_buttons (GtkDirSelection *filesel)
+{
+  g_return_if_fail (GTK_IS_DIR_SELECTION (filesel));
+    
+  /* delete, create directory, and rename */
+  if (!filesel->fileop_c_dir) 
+    {
+      filesel->fileop_c_dir = gtk_button_new_with_mnemonic (_("_New Folder"));
+      g_signal_connect (filesel->fileop_c_dir, "clicked",
+                       G_CALLBACK (gtk_dir_selection_create_dir),
+                       filesel);
+      //      gtk_box_pack_start (GTK_BOX (filesel->button_area), 
+      //                         filesel->fileop_c_dir, TRUE, TRUE, 0);
+      //      gtk_widget_show (filesel->fileop_c_dir);
+    }
+       
+  if (!filesel->fileop_del_file) 
+    {
+      filesel->fileop_del_file = gtk_button_new_with_mnemonic (_("De_lete File"));
+      g_signal_connect (filesel->fileop_del_file, "clicked",
+                       G_CALLBACK (gtk_dir_selection_delete_file),
+                       filesel);
+      //      gtk_box_pack_start (GTK_BOX (filesel->button_area), 
+      //                         filesel->fileop_del_file, TRUE, TRUE, 0);
+      //      gtk_widget_show (filesel->fileop_del_file);
+    }
+
+  if (!filesel->fileop_ren_file)
+    {
+      filesel->fileop_ren_file = gtk_button_new_with_mnemonic (_("_Rename File"));
+      g_signal_connect (filesel->fileop_ren_file, "clicked",
+                       G_CALLBACK (gtk_dir_selection_rename_file),
+                       filesel);
+      //      gtk_box_pack_start (GTK_BOX (filesel->button_area), 
+      //                         filesel->fileop_ren_file, TRUE, TRUE, 0);
+      //      gtk_widget_show (filesel->fileop_ren_file);
+    }
+  
+  gtk_dir_selection_update_fileops (filesel);
+  
+  g_object_notify (G_OBJECT (filesel), "show_fileops");
+}
+
+void       
+gtk_dir_selection_hide_fileop_buttons (GtkDirSelection *filesel)
+{
+  g_return_if_fail (GTK_IS_DIR_SELECTION (filesel));
+    
+  if (filesel->fileop_ren_file)
+    {
+      gtk_widget_destroy (filesel->fileop_ren_file);
+      filesel->fileop_ren_file = NULL;
+    }
+
+  if (filesel->fileop_del_file)
+    {
+      gtk_widget_destroy (filesel->fileop_del_file);
+      filesel->fileop_del_file = NULL;
+    }
+
+  if (filesel->fileop_c_dir)
+    {
+      gtk_widget_destroy (filesel->fileop_c_dir);
+      filesel->fileop_c_dir = NULL;
+    }
+  g_object_notify (G_OBJECT (filesel), "show_fileops");
+}
+
+
+
+/**
+ * gtk_dir_selection_set_filename:
+ * @filesel: a #GtkDirSelection.
+ * @filename:  a string to set as the default file name.
+ * 
+ * Sets a default path for the file requestor. If @filename includes a
+ * directory path, then the requestor will open with that path as its
+ * current working directory.
+ *
+ * The encoding of @filename is the on-disk encoding, which
+ * may not be UTF-8. See g_filename_from_utf8().
+ **/
+void
+gtk_dir_selection_set_filename (GtkDirSelection *filesel,
+                                const gchar      *filename)
+{
+  gchar *buf;
+  const char *name, *last_slash;
+  char *filename_utf8;
+
+  g_return_if_fail (GTK_IS_DIR_SELECTION (filesel));
+  g_return_if_fail (filename != NULL);
+
+  filename_utf8 = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL);
+  g_return_if_fail (filename_utf8 != NULL);
+
+  last_slash = strrchr (filename_utf8, G_DIR_SEPARATOR);
+
+  if (!last_slash)
+    {
+      buf = g_strdup ("");
+      name = filename_utf8;
+    }
+  else
+    {
+      buf = g_strdup (filename_utf8);
+      buf[last_slash - filename_utf8 + 1] = 0;
+      name = last_slash + 1;
+    }
+
+  gtk_dir_selection_populate (filesel, buf, FALSE, TRUE);
+
+  if (filesel->selection_entry)
+    gtk_entry_set_text (GTK_ENTRY (filesel->selection_entry), name);
+  g_free (buf);
+  g_object_notify (G_OBJECT (filesel), "filename");
+
+  g_free (filename_utf8);
+}
+
+/**
+ * gtk_dir_selection_get_filename:
+ * @filesel: a #GtkDirSelection
+ * 
+ * This function returns the selected filename in the on-disk encoding
+ * (see g_filename_from_utf8()), which may or may not be the same as that
+ * used by GTK+ (UTF-8). To convert to UTF-8, call g_filename_to_utf8().
+ * The returned string points to a statically allocated buffer and
+ * should be copied if you plan to keep it around.
+ *
+ * If no file is selected then the selected directory path is returned.
+ * 
+ * Return value: currently-selected filename in the on-disk encoding.
+ **/
+G_CONST_RETURN gchar*
+gtk_dir_selection_get_filename (GtkDirSelection *filesel)
+{
+  static const gchar nothing[2] = "";
+  static gchar something[MAXPATHLEN*2];
+  char *sys_filename;
+  const char *text;
+
+  g_return_val_if_fail (GTK_IS_DIR_SELECTION (filesel), nothing);
+
+#ifdef G_WITH_CYGWIN
+  translate_win32_path (filesel);
+#endif
+  text = gtk_entry_get_text (GTK_ENTRY (filesel->selection_entry));
+  if (text)
+    {
+      sys_filename = g_filename_from_utf8 (cmpl_completion_fullname (text, filesel->cmpl_state), -1, NULL, NULL, NULL);
+      if (!sys_filename)
+       return nothing;
+      strncpy (something, sys_filename, sizeof (something));
+      g_free (sys_filename);
+      return something;
+    }
+
+  return nothing;
+}
+
+void
+gtk_dir_selection_complete (GtkDirSelection *filesel,
+                            const gchar      *pattern)
+{
+  g_return_if_fail (GTK_IS_DIR_SELECTION (filesel));
+  g_return_if_fail (pattern != NULL);
+
+  if (filesel->selection_entry)
+    gtk_entry_set_text (GTK_ENTRY (filesel->selection_entry), pattern);
+  gtk_dir_selection_populate (filesel, (gchar*) pattern, TRUE, TRUE);
+}
+
+static void
+gtk_dir_selection_destroy (GtkObject *object)
+{
+  GtkDirSelection *filesel;
+  GList *list;
+  HistoryCallbackArg *callback_arg;
+  
+  g_return_if_fail (GTK_IS_DIR_SELECTION (object));
+  
+  filesel = GTK_DIR_SELECTION (object);
+  
+  if (filesel->fileop_dialog)
+    {
+      gtk_widget_destroy (filesel->fileop_dialog);
+      filesel->fileop_dialog = NULL;
+    }
+  
+  if (filesel->history_list)
+    {
+      list = filesel->history_list;
+      while (list)
+       {
+         callback_arg = list->data;
+         g_free (callback_arg->directory);
+         g_free (callback_arg);
+         list = list->next;
+       }
+      g_list_free (filesel->history_list);
+      filesel->history_list = NULL;
+    }
+
+  if (filesel->cmpl_state)
+    {
+      cmpl_free_state (filesel->cmpl_state);
+      filesel->cmpl_state = NULL;
+    }
+  if (filesel->selected_names)
+    {
+      free_selected_names (filesel->selected_names);
+      filesel->selected_names = NULL;
+    } 
+
+  if (filesel->last_selected)
+    {
+      g_free (filesel->last_selected);
+      filesel->last_selected = NULL;
+    }
+
+  GTK_OBJECT_CLASS (parent_class)->destroy (object);
+}
+
+static void
+gtk_dir_selection_map (GtkWidget *widget)
+{
+  GtkDirSelection *filesel = GTK_DIR_SELECTION (widget);
+
+  /* Refresh the contents */
+  gtk_dir_selection_populate (filesel, "", FALSE, FALSE);
+  
+  GTK_WIDGET_CLASS (parent_class)->map (widget);
+}
+
+static void
+gtk_dir_selection_finalize (GObject *object)
+{
+  GtkDirSelection *filesel = GTK_DIR_SELECTION (object);
+
+  g_free (filesel->fileop_file);
+
+  G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+/* Begin file operations callbacks */
+
+static void
+gtk_dir_selection_fileop_error (GtkDirSelection *fs,
+                                gchar            *error_message)
+{
+  GtkWidget *dialog;
+    
+  g_return_if_fail (error_message != NULL);
+
+  /* main dialog */
+  dialog = gtk_message_dialog_new (GTK_WINDOW (fs),
+                                  GTK_DIALOG_DESTROY_WITH_PARENT,
+                                  GTK_MESSAGE_ERROR,
+                                  GTK_BUTTONS_CLOSE,
+                                  "%s", error_message);
+
+  /* yes, we free it */
+  g_free (error_message);
+
+  gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
+  g_signal_connect_swapped (dialog, "response",
+                           G_CALLBACK (gtk_widget_destroy),
+                           dialog);
+
+  gtk_widget_show (dialog);
+}
+
+static void
+gtk_dir_selection_fileop_destroy (GtkWidget *widget,
+                                  gpointer   data)
+{
+  GtkDirSelection *fs = data;
+
+  g_return_if_fail (GTK_IS_DIR_SELECTION (fs));
+  
+  fs->fileop_dialog = NULL;
+}
+
+static gboolean
+entry_is_empty (GtkEntry *entry)
+{
+  const gchar *text = gtk_entry_get_text (entry);
+  
+  return *text == '\0';
+}
+
+static void
+gtk_dir_selection_fileop_entry_changed (GtkEntry   *entry,
+                                        GtkWidget  *button)
+{
+  gtk_widget_set_sensitive (button, !entry_is_empty (entry));
+}
+
+static void
+gtk_dir_selection_create_dir_confirmed (GtkWidget *widget,
+                                        gpointer   data)
+{
+  GtkDirSelection *fs = data;
+  const gchar *dirname;
+  gchar *path;
+  gchar *full_path;
+  gchar *sys_full_path;
+  gchar *buf;
+  GError *error = NULL;
+  CompletionState *cmpl_state;
+  
+  g_return_if_fail (GTK_IS_DIR_SELECTION (fs));
+
+  dirname = gtk_entry_get_text (GTK_ENTRY (fs->fileop_entry));
+  cmpl_state = (CompletionState*) fs->cmpl_state;
+  path = cmpl_reference_position (cmpl_state);
+  
+  full_path = g_strconcat (path, G_DIR_SEPARATOR_S, dirname, NULL);
+  sys_full_path = g_filename_from_utf8 (full_path, -1, NULL, NULL, &error);
+  if (error)
+    {
+      if (g_error_matches (error, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE))
+       buf = g_strdup_printf (_("The folder name \"%s\" contains symbols that are not allowed in filenames"), dirname);
+      else
+       buf = g_strdup_printf (_("Error creating folder \"%s\": %s\n%s"), dirname, error->message,
+                              _("You probably used symbols not allowed in filenames."));
+      gtk_dir_selection_fileop_error (fs, buf);
+      g_error_free (error);
+      goto out;
+    }
+
+  if (mkdir (sys_full_path, 0755) < 0) 
+    {
+      buf = g_strdup_printf (_("Error creating folder \"%s\": %s\n"), dirname,
+                            g_strerror (errno));
+      gtk_dir_selection_fileop_error (fs, buf);
+    }
+
+ out:
+  g_free (full_path);
+  g_free (sys_full_path);
+  
+  gtk_widget_destroy (fs->fileop_dialog);
+  gtk_dir_selection_populate (fs, "", FALSE, FALSE);
+}
+  
+static void
+gtk_dir_selection_create_dir (GtkWidget *widget,
+                              gpointer   data)
+{
+  GtkDirSelection *fs = data;
+  GtkWidget *label;
+  GtkWidget *dialog;
+  GtkWidget *vbox;
+  GtkWidget *button;
+
+  g_return_if_fail (GTK_IS_DIR_SELECTION (fs));
+
+  if (fs->fileop_dialog)
+    return;
+  
+  /* main dialog */
+  dialog = gtk_dialog_new ();
+  fs->fileop_dialog = dialog;
+  g_signal_connect (dialog, "destroy",
+                   G_CALLBACK (gtk_dir_selection_fileop_destroy),
+                   fs);
+  gtk_window_set_title (GTK_WINDOW (dialog), _("New Folder"));
+  gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
+  gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (fs));
+
+  /* If file dialog is grabbed, grab option dialog */
+  /* When option dialog is closed, file dialog will be grabbed again */
+  if (GTK_WINDOW (fs)->modal)
+      gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
+
+  vbox = gtk_vbox_new (FALSE, 0);
+  gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
+  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), vbox,
+                    FALSE, FALSE, 0);
+  gtk_widget_show( vbox);
+  
+  label = gtk_label_new_with_mnemonic (_("_Folder name:"));
+  gtk_misc_set_alignment(GTK_MISC (label), 0.0, 0.0);
+  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 5);
+  gtk_widget_show (label);
+
+  /*  The directory entry widget  */
+  fs->fileop_entry = gtk_entry_new ();
+  gtk_label_set_mnemonic_widget (GTK_LABEL (label), fs->fileop_entry);
+  gtk_box_pack_start (GTK_BOX (vbox), fs->fileop_entry, 
+                     TRUE, TRUE, 5);
+  GTK_WIDGET_SET_FLAGS (fs->fileop_entry, GTK_CAN_DEFAULT);
+  gtk_widget_show (fs->fileop_entry);
+  
+  /* buttons */
+  button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
+  g_signal_connect_swapped (button, "clicked",
+                           G_CALLBACK (gtk_widget_destroy),
+                           dialog);
+  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area),
+                    button, TRUE, TRUE, 0);
+  GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+  gtk_widget_grab_default (button);
+  gtk_widget_show (button);
+
+  gtk_widget_grab_focus (fs->fileop_entry);
+
+  button = gtk_button_new_with_mnemonic (_("C_reate"));
+  gtk_widget_set_sensitive (button, FALSE);
+  g_signal_connect (button, "clicked",
+                   G_CALLBACK (gtk_dir_selection_create_dir_confirmed),
+                   fs);
+  g_signal_connect (fs->fileop_entry, "changed",
+                    G_CALLBACK (gtk_dir_selection_fileop_entry_changed),
+                   button);
+
+  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area),
+                    button, TRUE, TRUE, 0);
+  GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+  gtk_widget_show (button);
+  
+  gtk_widget_show (dialog);
+}
+
+static void
+gtk_dir_selection_delete_dir_response (GtkDialog *dialog, 
+                                         gint       response_id,
+                                         gpointer   data)
+{
+  GtkDirSelection *fs = data;
+  CompletionState *cmpl_state;
+  gchar *path;
+  gchar *full_path;
+  gchar *sys_full_path;
+  GError *error = NULL;
+  gchar *buf;
+  
+  g_return_if_fail (GTK_IS_DIR_SELECTION (fs));
+
+  if (response_id != GTK_RESPONSE_OK)
+    {
+      gtk_widget_destroy (GTK_WIDGET (dialog));
+      return;
+    }
+
+  cmpl_state = (CompletionState*) fs->cmpl_state;
+  path = cmpl_reference_position (cmpl_state);
+  
+  full_path = g_strconcat (path, G_DIR_SEPARATOR_S, fs->fileop_file, NULL);
+  sys_full_path = g_filename_from_utf8 (full_path, -1, NULL, NULL, &error);
+  if (error)
+    {
+      if (g_error_matches (error, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE))
+       buf = g_strdup_printf (_("The filename \"%s\" contains symbols that are not allowed in filenames"),
+                              fs->fileop_file);
+      else
+       buf = g_strdup_printf (_("Error deleting file \"%s\": %s\n%s"),
+                              fs->fileop_file, error->message,
+                              _("It probably contains symbols not allowed in filenames."));
+      
+      gtk_dir_selection_fileop_error (fs, buf);
+      g_error_free (error);
+      goto out;
+    }
+
+  if (unlink (sys_full_path) < 0) 
+    {
+      buf = g_strdup_printf (_("Error deleting file \"%s\": %s"),
+                            fs->fileop_file, g_strerror (errno));
+      gtk_dir_selection_fileop_error (fs, buf);
+    }
+  
+ out:
+  g_free (full_path);
+  g_free (sys_full_path);
+  
+  gtk_widget_destroy (fs->fileop_dialog);
+  gtk_dir_selection_populate (fs, "", FALSE, TRUE);
+}
+
+static void
+gtk_dir_selection_delete_file (GtkWidget *widget,
+                               gpointer   data)
+{
+  GtkDirSelection *fs = data;
+  GtkWidget *dialog;
+  const gchar *filename;
+  
+  g_return_if_fail (GTK_IS_DIR_SELECTION (fs));
+
+  if (fs->fileop_dialog)
+    return;
+
+#ifdef G_WITH_CYGWIN
+  translate_win32_path (fs);
+#endif
+
+  filename = gtk_entry_get_text (GTK_ENTRY (fs->selection_entry));
+  if (strlen (filename) < 1)
+    return;
+
+  g_free (fs->fileop_file);
+  fs->fileop_file = g_strdup (filename);
+  
+  /* main dialog */
+  fs->fileop_dialog = dialog = 
+    gtk_message_dialog_new (GTK_WINDOW (fs),
+                            GTK_WINDOW (fs)->modal ? GTK_DIALOG_MODAL : 0,
+                            GTK_MESSAGE_QUESTION,
+                            GTK_BUTTONS_NONE,
+                            _("Really delete file \"%s\" ?"), filename);
+
+  g_signal_connect (dialog, "destroy",
+                   G_CALLBACK (gtk_dir_selection_fileop_destroy),
+                   fs);
+  gtk_window_set_title (GTK_WINDOW (dialog), _("Delete File"));
+  gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
+  
+  /* buttons */
+  gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+                          GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+                          GTK_STOCK_DELETE, GTK_RESPONSE_OK,
+                          NULL);
+
+  gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
+
+  g_signal_connect (dialog, "response",
+                    G_CALLBACK (gtk_dir_selection_delete_dir_response),
+                    fs);
+  
+  gtk_widget_show (dialog);
+}
+
+static void
+gtk_dir_selection_rename_dir_confirmed (GtkWidget *widget,
+                                         gpointer   data)
+{
+  GtkDirSelection *fs = data;
+  gchar *buf;
+  const gchar *file;
+  gchar *path;
+  gchar *new_filename;
+  gchar *old_filename;
+  gchar *sys_new_filename;
+  gchar *sys_old_filename;
+  CompletionState *cmpl_state;
+  GError *error = NULL;
+  
+  g_return_if_fail (GTK_IS_DIR_SELECTION (fs));
+
+  file = gtk_entry_get_text (GTK_ENTRY (fs->fileop_entry));
+  cmpl_state = (CompletionState*) fs->cmpl_state;
+  path = cmpl_reference_position (cmpl_state);
+  
+  new_filename = g_strconcat (path, G_DIR_SEPARATOR_S, file, NULL);
+  old_filename = g_strconcat (path, G_DIR_SEPARATOR_S, fs->fileop_file, NULL);
+
+  sys_new_filename = g_filename_from_utf8 (new_filename, -1, NULL, NULL, &error);
+  if (error)
+    {
+      if (g_error_matches (error, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE))
+       buf = g_strdup_printf (_("The file name \"%s\" contains symbols that are not allowed in filenames"), new_filename);
+      else
+       buf = g_strdup_printf (_("Error renaming file to \"%s\": %s\n%s"),
+                              new_filename, error->message,
+                              _("You probably used symbols not allowed in filenames."));
+      gtk_dir_selection_fileop_error (fs, buf);
+      g_error_free (error);
+      goto out1;
+    }
+
+  sys_old_filename = g_filename_from_utf8 (old_filename, -1, NULL, NULL, &error);
+  if (error)
+    {
+      if (g_error_matches (error, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE))
+       buf = g_strdup_printf (_("The file name \"%s\" contains symbols that are not allowed in filenames"), old_filename);
+      else
+       buf = g_strdup_printf (_("Error renaming file \"%s\": %s\n%s"),
+                              old_filename, error->message,
+                              _("It probably contains symbols not allowed in filenames."));
+      gtk_dir_selection_fileop_error (fs, buf);
+      g_error_free (error);
+      goto out2;
+    }
+  
+  if (rename (sys_old_filename, sys_new_filename) < 0) 
+    {
+      buf = g_strdup_printf (_("Error renaming file \"%s\" to \"%s\": %s"),
+                            sys_old_filename, sys_new_filename,
+                            g_strerror (errno));
+      gtk_dir_selection_fileop_error (fs, buf);
+      goto out2;
+    }
+  
+  gtk_dir_selection_populate (fs, "", FALSE, FALSE);
+  gtk_entry_set_text (GTK_ENTRY (fs->selection_entry), file);
+  
+ out2:
+  g_free (sys_old_filename);
+
+ out1:
+  g_free (new_filename);
+  g_free (old_filename);
+  g_free (sys_new_filename);
+  
+  gtk_widget_destroy (fs->fileop_dialog);
+}
+  
+static void
+gtk_dir_selection_rename_file (GtkWidget *widget,
+                               gpointer   data)
+{
+  GtkDirSelection *fs = data;
+  GtkWidget *label;
+  GtkWidget *dialog;
+  GtkWidget *vbox;
+  GtkWidget *button;
+  gchar *buf;
+  
+  g_return_if_fail (GTK_IS_DIR_SELECTION (fs));
+
+  if (fs->fileop_dialog)
+         return;
+
+  g_free (fs->fileop_file);
+  fs->fileop_file = g_strdup (gtk_entry_get_text (GTK_ENTRY (fs->selection_entry)));
+  if (strlen (fs->fileop_file) < 1)
+    return;
+  
+  /* main dialog */
+  fs->fileop_dialog = dialog = gtk_dialog_new ();
+  g_signal_connect (dialog, "destroy",
+                   G_CALLBACK (gtk_dir_selection_fileop_destroy),
+                   fs);
+  gtk_window_set_title (GTK_WINDOW (dialog), _("Rename File"));
+  gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
+  gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (fs));
+
+  /* If file dialog is grabbed, grab option dialog */
+  /* When option dialog  closed, file dialog will be grabbed again */
+  if (GTK_WINDOW (fs)->modal)
+    gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
+  
+  vbox = gtk_vbox_new (FALSE, 0);
+  gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
+  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), vbox,
+                     FALSE, FALSE, 0);
+  gtk_widget_show(vbox);
+  
+  buf = g_strdup_printf (_("Rename file \"%s\" to:"), fs->fileop_file);
+  label = gtk_label_new (buf);
+  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
+  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 5);
+  gtk_widget_show (label);
+  g_free (buf);
+
+  /* New filename entry */
+  fs->fileop_entry = gtk_entry_new ();
+  gtk_box_pack_start (GTK_BOX (vbox), fs->fileop_entry, 
+                     TRUE, TRUE, 5);
+  GTK_WIDGET_SET_FLAGS (fs->fileop_entry, GTK_CAN_DEFAULT);
+  gtk_widget_show (fs->fileop_entry);
+  
+  gtk_entry_set_text (GTK_ENTRY (fs->fileop_entry), fs->fileop_file);
+  gtk_editable_select_region (GTK_EDITABLE (fs->fileop_entry),
+                             0, strlen (fs->fileop_file));
+
+  /* buttons */
+  button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
+  g_signal_connect_swapped (button, "clicked",
+                           G_CALLBACK (gtk_widget_destroy),
+                           dialog);
+  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area),
+                     button, TRUE, TRUE, 0);
+  GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+  gtk_widget_grab_default (button);
+  gtk_widget_show (button);
+
+  gtk_widget_grab_focus (fs->fileop_entry);
+
+  button = gtk_button_new_with_mnemonic (_("_Rename"));
+  g_signal_connect (button, "clicked",
+                   G_CALLBACK (gtk_dir_selection_rename_dir_confirmed),
+                   fs);
+  g_signal_connect (fs->fileop_entry, "changed",
+                   G_CALLBACK (gtk_dir_selection_fileop_entry_changed),
+                   button);
+
+  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area),
+                     button, TRUE, TRUE, 0);
+  GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+  gtk_widget_show (button);
+  
+  gtk_widget_show (dialog);
+}
+
+static gint
+gtk_dir_selection_insert_text (GtkWidget   *widget,
+                               const gchar *new_text,
+                               gint         new_text_length,
+                               gint        *position,
+                               gpointer     user_data)
+{
+  gchar *filename;
+
+  filename = g_filename_from_utf8 (new_text, new_text_length, NULL, NULL, NULL);
+
+  if (!filename)
+    {
+      gdk_display_beep (gtk_widget_get_display (widget));
+      g_signal_stop_emission_by_name (widget, "insert_text");
+      return FALSE;
+    }
+  
+  g_free (filename);
+  
+  return TRUE;
+}
+
+static void
+gtk_dir_selection_update_fileops (GtkDirSelection *fs)
+{
+  gboolean sensitive;
+
+  if (!fs->selection_entry)
+    return;
+
+  sensitive = !entry_is_empty (GTK_ENTRY (fs->selection_entry));
+
+  if (fs->fileop_del_file)
+    gtk_widget_set_sensitive (fs->fileop_del_file, sensitive);
+  
+  if (fs->fileop_ren_file)
+    gtk_widget_set_sensitive (fs->fileop_ren_file, sensitive);
+}
+
+static gint
+gtk_dir_selection_key_press (GtkWidget   *widget,
+                             GdkEventKey *event,
+                             gpointer     user_data)
+{
+  GtkDirSelection *fs;
+  char *text;
+
+  g_return_val_if_fail (widget != NULL, FALSE);
+  g_return_val_if_fail (event != NULL, FALSE);
+
+  if ((event->keyval == GDK_Tab || event->keyval == GDK_KP_Tab) &&
+      (event->state & gtk_accelerator_get_default_mod_mask ()) == 0)
+    {
+      fs = GTK_DIR_SELECTION (user_data);
+#ifdef G_WITH_CYGWIN
+      translate_win32_path (fs);
+#endif
+      text = g_strdup (gtk_entry_get_text (GTK_ENTRY (fs->selection_entry)));
+
+      gtk_dir_selection_populate (fs, text, TRUE, TRUE);
+
+      g_free (text);
+
+      return TRUE;
+    }
+
+  return FALSE;
+}
+
+static void
+gtk_dir_selection_history_callback (GtkWidget *widget,
+                                    gpointer   data)
+{
+  GtkDirSelection *fs = data;
+  HistoryCallbackArg *callback_arg;
+  GList *list;
+
+  g_return_if_fail (GTK_IS_DIR_SELECTION (fs));
+
+  list = fs->history_list;
+  
+  while (list) {
+    callback_arg = list->data;
+    
+    if (callback_arg->menu_item == widget)
+      {
+       gtk_dir_selection_populate (fs, callback_arg->directory, FALSE, FALSE);
+       break;
+      }
+    
+    list = list->next;
+  }
+}
+
+static void 
+gtk_dir_selection_update_history_menu (GtkDirSelection *fs,
+                                       gchar            *current_directory)
+{
+  HistoryCallbackArg *callback_arg;
+  GtkWidget *menu_item;
+  GList *list;
+  gchar *current_dir;
+  gint dir_len;
+  gint i;
+  
+  g_return_if_fail (GTK_IS_DIR_SELECTION (fs));
+  g_return_if_fail (current_directory != NULL);
+  
+  list = fs->history_list;
+
+  if (fs->history_menu) 
+    {
+      while (list) {
+       callback_arg = list->data;
+       g_free (callback_arg->directory);
+       g_free (callback_arg);
+       list = list->next;
+      }
+      g_list_free (fs->history_list);
+      fs->history_list = NULL;
+      
+      gtk_widget_destroy (fs->history_menu);
+    }
+  
+  fs->history_menu = gtk_menu_new ();
+
+  current_dir = g_strdup (current_directory);
+
+  dir_len = strlen (current_dir);
+
+  for (i = dir_len; i >= 0; i--)
+    {
+      /* the i == dir_len is to catch the full path for the first 
+       * entry. */
+      if ( (current_dir[i] == G_DIR_SEPARATOR) || (i == dir_len))
+       {
+         /* another small hack to catch the full path */
+         if (i != dir_len) 
+                 current_dir[i + 1] = '\0';
+#ifdef G_WITH_CYGWIN
+         if (!strcmp (current_dir, "//"))
+           continue;
+#endif
+         menu_item = gtk_menu_item_new_with_label (current_dir);
+         
+         callback_arg = g_new (HistoryCallbackArg, 1);
+         callback_arg->menu_item = menu_item;
+         
+         /* since the autocompletion gets confused if you don't 
+          * supply a trailing '/' on a dir entry, set the full
+          * (current) path to "" which just refreshes the filesel */
+         if (dir_len == i)
+           {
+             callback_arg->directory = g_strdup ("");
+           }
+         else
+           {
+             callback_arg->directory = g_strdup (current_dir);
+           }
+         
+         fs->history_list = g_list_append (fs->history_list, callback_arg);
+         
+         g_signal_connect (menu_item, "activate",
+                           G_CALLBACK (gtk_dir_selection_history_callback),
+                           fs);
+         gtk_menu_shell_append (GTK_MENU_SHELL (fs->history_menu), menu_item);
+         gtk_widget_show (menu_item);
+       }
+    }
+
+  gtk_option_menu_set_menu (GTK_OPTION_MENU (fs->history_pulldown), 
+                           fs->history_menu);
+  g_free (current_dir);
+}
+
+static gchar *
+get_real_filename (gchar    *filename,
+                   gboolean  free_old)
+{
+#ifdef G_WITH_CYGWIN
+  /* Check to see if the selection was a drive selector */
+  if (isalpha (filename[0]) && (filename[1] == ':'))
+    {
+      gchar temp_filename[MAX_PATH];
+      int len;
+
+      cygwin_conv_to_posix_path (filename, temp_filename);
+
+      /* we need trailing '/'. */
+      len = strlen (temp_filename);
+      if (len > 0 && temp_filename[len-1] != '/')
+        {
+          temp_filename[len]   = '/';
+          temp_filename[len+1] = '\0';
+        }
+      
+      if (free_old)
+       g_free (filename);
+
+      return g_strdup (temp_filename);
+    }
+#endif /* G_WITH_CYGWIN */
+  return filename;
+}
+
+static void
+gtk_dir_selection_file_activate (GtkTreeView       *tree_view,
+                                 GtkTreePath       *path,
+                                 GtkTreeViewColumn *column,
+                                 gpointer           user_data)
+{
+  GtkDirSelection *fs = GTK_DIR_SELECTION (user_data);
+  GtkTreeModel *model = gtk_tree_view_get_model (tree_view);
+  GtkTreeIter iter;  
+  gchar *filename;
+  
+  gtk_tree_model_get_iter (model, &iter, path);
+  gtk_tree_model_get (model, &iter, FILE_COLUMN, &filename, -1);
+  filename = get_real_filename (filename, TRUE);
+  gtk_entry_set_text (GTK_ENTRY (fs->selection_entry), filename);
+  gtk_button_clicked (GTK_BUTTON (fs->ok_button));
+
+  g_free (filename);
+}
+
+static void
+gtk_dir_selection_dir_activate (GtkTreeView       *tree_view,
+                                GtkTreePath       *path,
+                                GtkTreeViewColumn *column,
+                                gpointer           user_data)
+{
+  GtkDirSelection *fs = GTK_DIR_SELECTION (user_data);
+  GtkTreeModel *model = gtk_tree_view_get_model (tree_view);
+  GtkTreeIter iter;
+  gchar *filename;
+
+  gtk_tree_model_get_iter (model, &iter, path);
+  gtk_tree_model_get (model, &iter, DIR_COLUMN, &filename, -1);
+  filename = get_real_filename (filename, TRUE);
+  gtk_dir_selection_populate (fs, filename, FALSE, FALSE);
+  g_free (filename);
+}
+
+#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
+
+static void
+win32_gtk_add_drives_to_dir_list (GtkListStore *model)
+{
+  gchar *textPtr;
+  gchar buffer[128];
+  char formatBuffer[128];
+  GtkTreeIter iter;
+
+  /* Get the drives string */
+  GetLogicalDriveStrings (sizeof (buffer), buffer);
+
+  /* Add the drives as necessary */
+  textPtr = buffer;
+  while (*textPtr != '\0')
+    {
+      /* Ignore floppies (?) */
+      if ((tolower (textPtr[0]) != 'a') && (tolower (textPtr[0]) != 'b'))
+       {
+         /* Build the actual displayable string */
+         g_snprintf (formatBuffer, sizeof (formatBuffer), "%c:\\", toupper (textPtr[0]));
+
+         /* Add to the list */
+         gtk_list_store_append (model, &iter);
+         gtk_list_store_set (model, &iter, DIR_COLUMN, formatBuffer, -1);
+       }
+      textPtr += (strlen (textPtr) + 1);
+    }
+}
+#endif
+
+static gchar *
+escape_underscores (const gchar *str)
+{
+  GString *result = g_string_new (NULL);
+  while (*str)
+    {
+      if (*str == '_')
+       g_string_append_c (result, '_');
+
+      g_string_append_c (result, *str);
+      str++;
+    }
+
+  return g_string_free (result, FALSE);
+}
+
+static void
+gtk_dir_selection_populate (GtkDirSelection *fs,
+                            gchar            *rel_path,
+                            gboolean          try_complete,
+                            gboolean          reset_entry)
+{
+  CompletionState *cmpl_state;
+  PossibleCompletion* poss;
+  GtkTreeIter iter;
+  GtkListStore *dir_model;
+  GtkListStore *file_model;
+  gchar* filename;
+  gchar* rem_path = rel_path;
+  gchar* sel_text;
+  gint did_recurse = FALSE;
+  gint possible_count = 0;
+  gint selection_index = -1;
+  
+  g_return_if_fail (GTK_IS_DIR_SELECTION (fs));
+
+  cmpl_state = (CompletionState*) fs->cmpl_state;
+  poss = cmpl_completion_matches (rel_path, &rem_path, cmpl_state);
+
+  if (!cmpl_state_okay (cmpl_state))
+    {
+      /* Something went wrong. */
+      gtk_dir_selection_abort (fs);
+      return;
+    }
+
+  g_assert (cmpl_state->reference_dir);
+
+  dir_model = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (fs->dir_list)));
+  file_model = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (fs->file_list)));
+
+  gtk_list_store_clear (dir_model);
+  gtk_list_store_clear (file_model);
+
+  /* Set the dir list to include ./ and ../ */
+  gtk_list_store_append (dir_model, &iter);
+  gtk_list_store_set (dir_model, &iter, DIR_COLUMN, "." G_DIR_SEPARATOR_S, -1);
+  gtk_list_store_append (dir_model, &iter);
+  gtk_list_store_set (dir_model, &iter, DIR_COLUMN, ".." G_DIR_SEPARATOR_S, -1);
+
+  while (poss)
+    {
+      if (cmpl_is_a_completion (poss))
+        {
+          possible_count += 1;
+
+          filename = cmpl_this_completion (poss);
+
+          if (cmpl_is_directory (poss))
+            {
+              if (strcmp (filename, "." G_DIR_SEPARATOR_S) != 0 &&
+                  strcmp (filename, ".." G_DIR_SEPARATOR_S) != 0)
+               {
+                 gtk_list_store_append (dir_model, &iter);
+                 gtk_list_store_set (dir_model, &iter, DIR_COLUMN, filename, -1);
+               }
+           }
+          else
+           {
+             gtk_list_store_append (file_model, &iter);
+             gtk_list_store_set (file_model, &iter, DIR_COLUMN, filename, -1);
+            }
+       }
+
+      poss = cmpl_next_completion (cmpl_state);
+    }
+
+#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
+  /* For Windows, add drives as potential selections */
+  win32_gtk_add_drives_to_dir_list (dir_model);
+#endif
+
+  /* File lists are set. */
+
+  g_assert (cmpl_state->reference_dir);
+
+  if (try_complete)
+    {
+
+      /* User is trying to complete filenames, so advance the user's input
+       * string to the updated_text, which is the common leading substring
+       * of all possible completions, and if its a directory attempt
+       * attempt completions in it. */
+
+      if (cmpl_updated_text (cmpl_state)[0])
+        {
+
+          if (cmpl_updated_dir (cmpl_state))
+            {
+             gchar* dir_name = g_strdup (cmpl_updated_text (cmpl_state));
+
+              did_recurse = TRUE;
+
+              gtk_dir_selection_populate (fs, dir_name, TRUE, TRUE);
+
+              g_free (dir_name);
+            }
+          else
+            {
+             if (fs->selection_entry)
+                     gtk_entry_set_text (GTK_ENTRY (fs->selection_entry),
+                                         cmpl_updated_text (cmpl_state));
+            }
+        }
+      else
+        {
+          selection_index = cmpl_last_valid_char (cmpl_state) -
+                            (strlen (rel_path) - strlen (rem_path));
+         if (fs->selection_entry)
+           gtk_entry_set_text (GTK_ENTRY (fs->selection_entry), rem_path);
+        }
+    }
+  else if (reset_entry)
+    {
+      if (fs->selection_entry)
+       gtk_entry_set_text (GTK_ENTRY (fs->selection_entry), "");
+    }
+
+  if (!did_recurse)
+    {
+      if (fs->selection_entry)
+       gtk_editable_set_position (GTK_EDITABLE (fs->selection_entry),
+                                  selection_index);
+
+      if (fs->selection_entry)
+       {
+         char *escaped = escape_underscores (cmpl_reference_position (cmpl_state));
+         sel_text = g_strconcat (_("_Selection: "), escaped, NULL);
+         g_free (escaped);
+
+         gtk_label_set_text_with_mnemonic (GTK_LABEL (fs->selection_text), sel_text);
+         gtk_entry_set_text (GTK_ENTRY (fs->selection_entry), cmpl_reference_position (cmpl_state));
+         g_free (sel_text);
+       }
+
+      if (fs->history_pulldown) 
+       {
+         gtk_dir_selection_update_history_menu (fs, cmpl_reference_position (cmpl_state));
+       }
+      
+    }
+}
+
+static void
+gtk_dir_selection_abort (GtkDirSelection *fs)
+{
+  gchar err_buf[256];
+
+  g_snprintf (err_buf, sizeof (err_buf), _("Folder unreadable: %s"), cmpl_strerror (cmpl_errno));
+
+  /*  BEEP gdk_beep();  */
+
+  if (fs->selection_entry)
+    gtk_label_set_text (GTK_LABEL (fs->selection_text), err_buf);
+}
+
+/**
+ * gtk_dir_selection_set_select_multiple:
+ * @filesel: a #GtkDirSelection
+ * @select_multiple: whether or not the user is allowed to select multiple
+ * files in the file list.
+ *
+ * Sets whether the user is allowed to select multiple files in the file list.
+ * Use gtk_dir_selection_get_selections () to get the list of selected files.
+ **/
+void
+gtk_dir_selection_set_select_multiple (GtkDirSelection *filesel,
+                                       gboolean          select_multiple)
+{
+  GtkTreeSelection *sel;
+  GtkSelectionMode mode;
+
+  g_return_if_fail (GTK_IS_DIR_SELECTION (filesel));
+
+  sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (filesel->file_list));
+
+  mode = select_multiple ? GTK_SELECTION_MULTIPLE : GTK_SELECTION_SINGLE;
+
+  if (mode != gtk_tree_selection_get_mode (sel))
+    {
+      gtk_tree_selection_set_mode (sel, mode);
+
+      g_object_notify (G_OBJECT (filesel), "select-multiple");
+    }
+}
+
+/**
+ * gtk_dir_selection_get_select_multiple:
+ * @filesel: a #GtkDirSelection
+ *
+ * Determines whether or not the user is allowed to select multiple files in
+ * the file list. See gtk_dir_selection_set_select_multiple().
+ *
+ * Return value: %TRUE if the user is allowed to select multiple files in the
+ * file list
+ **/
+gboolean
+gtk_dir_selection_get_select_multiple (GtkDirSelection *filesel)
+{
+  GtkTreeSelection *sel;
+
+  g_return_val_if_fail (GTK_IS_DIR_SELECTION (filesel), FALSE);
+
+  sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (filesel->file_list));
+  return (gtk_tree_selection_get_mode (sel) == GTK_SELECTION_MULTIPLE);
+}
+
+static void
+multiple_changed_foreach (GtkTreeModel *model,
+                         GtkTreePath  *path,
+                         GtkTreeIter  *iter,
+                         gpointer      data)
+{
+  GPtrArray *names = data;
+  gchar *filename;
+
+  gtk_tree_model_get (model, iter, FILE_COLUMN, &filename, -1);
+
+  g_ptr_array_add (names, filename);
+}
+
+static void
+free_selected_names (GPtrArray *names)
+{
+  gint i;
+
+  for (i = 0; i < names->len; i++)
+    g_free (g_ptr_array_index (names, i));
+
+  g_ptr_array_free (names, TRUE);
+}
+
+static void
+gtk_dir_selection_file_changed (GtkTreeSelection *selection,
+                                gpointer          user_data)
+{
+  GtkDirSelection *fs = GTK_DIR_SELECTION (user_data);
+  GPtrArray *new_names;
+  gchar *filename;
+  const gchar *entry;
+  gint index = -1;
+
+  new_names = g_ptr_array_sized_new (8);
+
+  gtk_tree_selection_selected_foreach (selection,
+                                      multiple_changed_foreach,
+                                      new_names);
+
+  /* nothing selected */
+  if (new_names->len == 0)
+    {
+      g_ptr_array_free (new_names, TRUE);
+
+      if (fs->selected_names != NULL)
+       {
+         free_selected_names (fs->selected_names);
+         fs->selected_names = NULL;
+       }
+
+      goto maybe_clear_entry;
+    }
+
+  if (new_names->len != 1)
+    {
+      GPtrArray *old_names = fs->selected_names;
+
+      if (old_names != NULL)
+       {
+         /* A common case is selecting a range of files from top to bottom,
+          * so quickly check for that to avoid looping over the entire list
+          */
+         if (compare_filenames (g_ptr_array_index (old_names, old_names->len - 1),
+                                g_ptr_array_index (new_names, new_names->len - 1)) != 0)
+           index = new_names->len - 1;
+         else
+           {
+             gint i = 0, j = 0, cmp;
+
+             /* do a quick diff, stopping at the first file not in the
+              * old list
+              */
+             while (i < old_names->len && j < new_names->len)
+               {
+                 cmp = compare_filenames (g_ptr_array_index (old_names, i),
+                                          g_ptr_array_index (new_names, j));
+                 if (cmp < 0)
+                   {
+                     i++;
+                   }
+                 else if (cmp == 0)
+                   {
+                     i++;
+                     j++;
+                   }
+                 else if (cmp > 0)
+                   {
+                     index = j;
+                     break;
+                   }
+               }
+
+             /* we ran off the end of the old list */
+             if (index == -1 && i < new_names->len)
+               index = j;
+           }
+       }
+      else
+       {
+         /* A phantom anchor still exists at the point where the last item
+          * was selected, which is used for subsequent range selections.
+          * So search up from there.
+          */
+         if (fs->last_selected &&
+             compare_filenames (fs->last_selected,
+                                g_ptr_array_index (new_names, 0)) == 0)
+           index = new_names->len - 1;
+         else
+           index = 0;
+       }
+    }
+  else
+    index = 0;
+
+  if (fs->selected_names != NULL)
+    free_selected_names (fs->selected_names);
+
+  fs->selected_names = new_names;
+
+  if (index != -1)
+    {
+      if (fs->last_selected != NULL)
+       g_free (fs->last_selected);
+
+      fs->last_selected = g_strdup (g_ptr_array_index (new_names, index));
+      filename = get_real_filename (fs->last_selected, FALSE);
+
+      gtk_entry_set_text (GTK_ENTRY (fs->selection_entry), filename);
+
+      if (filename != fs->last_selected)
+       g_free (filename);
+      
+      return;
+    }
+  
+maybe_clear_entry:
+
+  entry = gtk_entry_get_text (GTK_ENTRY (fs->selection_entry));
+  if ((entry != NULL) && (fs->last_selected != NULL) &&
+      (compare_filenames (entry, fs->last_selected) == 0))
+    gtk_entry_set_text (GTK_ENTRY (fs->selection_entry), "");
+}
+
+static void
+gtk_dir_selection_dir_changed (GtkTreeSelection *selection,
+                                gpointer          user_data)
+{
+  GtkDirSelection *fs = GTK_DIR_SELECTION (user_data);
+  GPtrArray *new_names;
+  gchar *filename;
+  const gchar *entry;
+  gint index = -1;
+
+  new_names = g_ptr_array_sized_new (8);
+
+  gtk_tree_selection_selected_foreach (selection,
+                                      multiple_changed_foreach,
+                                      new_names);
+
+  /* nothing selected */
+  if (new_names->len == 0)
+    {
+      g_ptr_array_free (new_names, TRUE);
+
+      if (fs->selected_names != NULL)
+       {
+         free_selected_names (fs->selected_names);
+         fs->selected_names = NULL;
+       }
+
+      goto maybe_clear_entry;
+    }
+
+  if (new_names->len != 1)
+    {
+      GPtrArray *old_names = fs->selected_names;
+
+      if (old_names != NULL)
+       {
+         /* A common case is selecting a range of files from top to bottom,
+          * so quickly check for that to avoid looping over the entire list
+          */
+         if (compare_filenames (g_ptr_array_index (old_names, old_names->len - 1),
+                                g_ptr_array_index (new_names, new_names->len - 1)) != 0)
+           index = new_names->len - 1;
+         else
+           {
+             gint i = 0, j = 0, cmp;
+
+             /* do a quick diff, stopping at the first file not in the
+              * old list
+              */
+             while (i < old_names->len && j < new_names->len)
+               {
+                 cmp = compare_filenames (g_ptr_array_index (old_names, i),
+                                          g_ptr_array_index (new_names, j));
+                 if (cmp < 0)
+                   {
+                     i++;
+                   }
+                 else if (cmp == 0)
+                   {
+                     i++;
+                     j++;
+                   }
+                 else if (cmp > 0)
+                   {
+                     index = j;
+                     break;
+                   }
+               }
+
+             /* we ran off the end of the old list */
+             if (index == -1 && i < new_names->len)
+               index = j;
+           }
+       }
+      else
+       {
+         /* A phantom anchor still exists at the point where the last item
+          * was selected, which is used for subsequent range selections.
+          * So search up from there.
+          */
+         if (fs->last_selected &&
+             compare_filenames (fs->last_selected,
+                                g_ptr_array_index (new_names, 0)) == 0)
+           index = new_names->len - 1;
+         else
+           index = 0;
+       }
+    }
+  else
+    index = 0;
+
+  if (fs->selected_names != NULL)
+    free_selected_names (fs->selected_names);
+
+  fs->selected_names = new_names;
+
+  if (index != -1)
+    {
+      const gchar * err;
+      gchar str[256];
+      err = gtk_label_get_text (GTK_LABEL (fs->selection_text));
+      err += 11;  //pass over "Selection: "
+      sprintf(str,"%s\0",err);
+      
+      
+      if (fs->last_selected != NULL)
+       g_free (fs->last_selected);
+
+      fs->last_selected = g_strdup (g_ptr_array_index (new_names, index));
+      filename = get_real_filename (fs->last_selected, FALSE);
+      
+      strcat(str,"/");
+      strcat(str,filename);
+      str[strlen(str)-1] = '\0';
+
+      gtk_entry_set_text (GTK_ENTRY (fs->selection_entry), str);
+
+      if (filename != fs->last_selected)
+       g_free (filename);
+      
+      return;
+    }
+  
+maybe_clear_entry:
+
+  entry = gtk_entry_get_text (GTK_ENTRY (fs->selection_entry));
+  if ((entry != NULL) && (fs->last_selected != NULL) &&
+      (compare_filenames (entry, fs->last_selected) == 0))
+    gtk_entry_set_text (GTK_ENTRY (fs->selection_entry), "");
+}
+
+/**
+ * gtk_dir_selection_get_selections:
+ * @filesel: a #GtkDirSelection
+ *
+ * Retrieves the list of file selections the user has made in the dialog box.
+ * This function is intended for use when the user can select multiple files
+ * in the file list. The first file in the list is equivalent to what
+ * gtk_dir_selection_get_filename() would return.
+ *
+ * The filenames are in the encoding of g_filename_from_utf8(), which may or 
+ * may not be the same as that used by GTK+ (UTF-8). To convert to UTF-8, call
+ * g_filename_to_utf8() on each string.
+ *
+ * Return value: a newly-allocated %NULL-terminated array of strings. Use
+ * g_strfreev() to free it.
+ **/
+gchar **
+gtk_dir_selection_get_selections (GtkDirSelection *filesel)
+{
+  GPtrArray *names;
+  gchar **selections;
+  gchar *filename, *dirname;
+  gchar *current, *buf;
+  gint i, count;
+  gboolean unselected_entry;
+
+  g_return_val_if_fail (GTK_IS_DIR_SELECTION (filesel), NULL);
+
+  filename = g_strdup (gtk_dir_selection_get_filename (filesel));
+
+  if (strlen (filename) == 0)
+    {
+      g_free (filename);
+      return NULL;
+    }
+
+  names = filesel->selected_names;
+
+  if (names != NULL)
+    selections = g_new (gchar *, names->len + 2);
+  else
+    selections = g_new (gchar *, 2);
+
+  count = 0;
+  unselected_entry = TRUE;
+
+  if (names != NULL)
+    {
+      dirname = g_path_get_dirname (filename);
+
+      for (i = 0; i < names->len; i++)
+       {
+         buf = g_filename_from_utf8 (g_ptr_array_index (names, i), -1,
+                                     NULL, NULL, NULL);
+         current = g_build_filename (dirname, buf, NULL);
+         g_free (buf);
+
+         selections[count++] = current;
+
+         if (unselected_entry && compare_filenames (current, filename) == 0)
+           unselected_entry = FALSE;
+       }
+
+      g_free (dirname);
+    }
+
+  if (unselected_entry)
+    selections[count++] = filename;
+  else
+    g_free (filename);
+
+  selections[count] = NULL;
+
+  return selections;
+}
+
+/**********************************************************************/
+/*                       External Interface                          */
+/**********************************************************************/
+
+/* The four completion state selectors
+ */
+static gchar*
+cmpl_updated_text (CompletionState *cmpl_state)
+{
+  return cmpl_state->updated_text;
+}
+
+static gboolean
+cmpl_updated_dir (CompletionState *cmpl_state)
+{
+  return cmpl_state->re_complete;
+}
+
+static gchar*
+cmpl_reference_position (CompletionState *cmpl_state)
+{
+  return cmpl_state->reference_dir->fullname;
+}
+
+static gint
+cmpl_last_valid_char (CompletionState *cmpl_state)
+{
+  return cmpl_state->last_valid_char;
+}
+
+static const gchar*
+cmpl_completion_fullname (const gchar     *text,
+                         CompletionState *cmpl_state)
+{
+  static const char nothing[2] = "";
+
+  if (!cmpl_state_okay (cmpl_state))
+    {
+      return nothing;
+    }
+  else if (g_path_is_absolute (text))
+    {
+      strcpy (cmpl_state->updated_text, text);
+    }
+#ifdef HAVE_PWD_H
+  else if (text[0] == '~')
+    {
+      CompletionDir* dir;
+      char* slash;
+
+      dir = open_user_dir (text, cmpl_state);
+
+      if (!dir)
+       {
+         /* spencer says just return ~something, so
+          * for now just do it. */
+         strcpy (cmpl_state->updated_text, text);
+       }
+      else
+       {
+
+         strcpy (cmpl_state->updated_text, dir->fullname);
+
+         slash = strchr (text, G_DIR_SEPARATOR);
+
+         if (slash)
+           strcat (cmpl_state->updated_text, slash);
+       }
+    }
+#endif
+  else
+    {
+      strcpy (cmpl_state->updated_text, cmpl_state->reference_dir->fullname);
+      if (cmpl_state->updated_text[strlen (cmpl_state->updated_text) - 1] != G_DIR_SEPARATOR)
+       strcat (cmpl_state->updated_text, G_DIR_SEPARATOR_S);
+      strcat (cmpl_state->updated_text, text);
+    }
+
+  return cmpl_state->updated_text;
+}
+
+/* The three completion selectors
+ */
+static gchar*
+cmpl_this_completion (PossibleCompletion* pc)
+{
+  return pc->text;
+}
+
+static gboolean
+cmpl_is_directory (PossibleCompletion* pc)
+{
+  return pc->is_directory;
+}
+
+static gint
+cmpl_is_a_completion (PossibleCompletion* pc)
+{
+  return pc->is_a_completion;
+}
+
+/**********************************************************************/
+/*                      Construction, deletion                       */
+/**********************************************************************/
+
+static CompletionState*
+cmpl_init_state (void)
+{
+  gchar *sys_getcwd_buf;
+  gchar *utf8_cwd;
+  CompletionState *new_state;
+
+  new_state = g_new (CompletionState, 1);
+
+  /* g_get_current_dir() returns a string in the "system" charset */
+  sys_getcwd_buf = g_get_current_dir ();
+  utf8_cwd = g_filename_to_utf8 (sys_getcwd_buf, -1, NULL, NULL, NULL);
+  g_free (sys_getcwd_buf);
+
+tryagain:
+
+  new_state->reference_dir = NULL;
+  new_state->completion_dir = NULL;
+  new_state->active_completion_dir = NULL;
+  new_state->directory_storage = NULL;
+  new_state->directory_sent_storage = NULL;
+  new_state->last_valid_char = 0;
+  new_state->updated_text = g_new (gchar, MAXPATHLEN);
+  new_state->updated_text_alloc = MAXPATHLEN;
+  new_state->the_completion.text = g_new (gchar, MAXPATHLEN);
+  new_state->the_completion.text_alloc = MAXPATHLEN;
+  new_state->user_dir_name_buffer = NULL;
+  new_state->user_directories = NULL;
+
+  new_state->reference_dir = open_dir (utf8_cwd, new_state);
+
+  if (!new_state->reference_dir)
+    {
+      /* Directories changing from underneath us, grumble */
+      strcpy (utf8_cwd, G_DIR_SEPARATOR_S);
+      goto tryagain;
+    }
+
+  g_free (utf8_cwd);
+  return new_state;
+}
+
+static void
+cmpl_free_dir_list (GList* dp0)
+{
+  GList *dp = dp0;
+
+  while (dp)
+    {
+      free_dir (dp->data);
+      dp = dp->next;
+    }
+
+  g_list_free (dp0);
+}
+
+static void
+cmpl_free_dir_sent_list (GList* dp0)
+{
+  GList *dp = dp0;
+
+  while (dp)
+    {
+      free_dir_sent (dp->data);
+      dp = dp->next;
+    }
+
+  g_list_free (dp0);
+}
+
+static void
+cmpl_free_state (CompletionState* cmpl_state)
+{
+  g_return_if_fail (cmpl_state != NULL);
+
+  cmpl_free_dir_list (cmpl_state->directory_storage);
+  cmpl_free_dir_sent_list (cmpl_state->directory_sent_storage);
+
+  if (cmpl_state->user_dir_name_buffer)
+    g_free (cmpl_state->user_dir_name_buffer);
+  if (cmpl_state->user_directories)
+    g_free (cmpl_state->user_directories);
+  if (cmpl_state->the_completion.text)
+    g_free (cmpl_state->the_completion.text);
+  if (cmpl_state->updated_text)
+    g_free (cmpl_state->updated_text);
+
+  g_free (cmpl_state);
+}
+
+static void
+free_dir (CompletionDir* dir)
+{
+  g_free (dir->cmpl_text);
+  g_free (dir->fullname);
+  g_free (dir);
+}
+
+static void
+free_dir_sent (CompletionDirSent* sent)
+{
+  gint i;
+  for (i = 0; i < sent->entry_count; i++)
+    {
+      g_free (sent->entries[i].entry_name);
+      g_free (sent->entries[i].sort_key);
+    }
+  g_free (sent->entries);
+  g_free (sent);
+}
+
+static void
+prune_memory_usage (CompletionState *cmpl_state)
+{
+  GList* cdsl = cmpl_state->directory_sent_storage;
+  GList* cdl = cmpl_state->directory_storage;
+  GList* cdl0 = cdl;
+  gint len = 0;
+
+  for (; cdsl && len < CMPL_DIRECTORY_CACHE_SIZE; len += 1)
+    cdsl = cdsl->next;
+
+  if (cdsl)
+    {
+      cmpl_free_dir_sent_list (cdsl->next);
+      cdsl->next = NULL;
+    }
+
+  cmpl_state->directory_storage = NULL;
+  while (cdl)
+    {
+      if (cdl->data == cmpl_state->reference_dir)
+       cmpl_state->directory_storage = g_list_prepend (NULL, cdl->data);
+      else
+       free_dir (cdl->data);
+      cdl = cdl->next;
+    }
+
+  g_list_free (cdl0);
+}
+
+/**********************************************************************/
+/*                        The main entrances.                         */
+/**********************************************************************/
+
+static PossibleCompletion*
+cmpl_completion_matches (gchar           *text_to_complete,
+                        gchar          **remaining_text,
+                        CompletionState *cmpl_state)
+{
+  gchar* first_slash;
+  PossibleCompletion *poss;
+
+  prune_memory_usage (cmpl_state);
+
+  g_assert (text_to_complete != NULL);
+
+  cmpl_state->user_completion_index = -1;
+  cmpl_state->last_completion_text = text_to_complete;
+  cmpl_state->the_completion.text[0] = 0;
+  cmpl_state->last_valid_char = 0;
+  cmpl_state->updated_text_len = -1;
+  cmpl_state->updated_text[0] = 0;
+  cmpl_state->re_complete = FALSE;
+
+#ifdef HAVE_PWD_H
+  first_slash = strchr (text_to_complete, G_DIR_SEPARATOR);
+
+  if (text_to_complete[0] == '~' && !first_slash)
+    {
+      /* Text starts with ~ and there is no slash, show all the
+       * home directory completions.
+       */
+      poss = attempt_homedir_completion (text_to_complete, cmpl_state);
+
+      update_cmpl (poss, cmpl_state);
+
+      return poss;
+    }
+#endif
+  cmpl_state->reference_dir =
+    open_ref_dir (text_to_complete, remaining_text, cmpl_state);
+
+  if (!cmpl_state->reference_dir)
+    return NULL;
+
+  cmpl_state->completion_dir =
+    find_completion_dir (*remaining_text, remaining_text, cmpl_state);
+
+  cmpl_state->last_valid_char = *remaining_text - text_to_complete;
+
+  if (!cmpl_state->completion_dir)
+    return NULL;
+
+  cmpl_state->completion_dir->cmpl_index = -1;
+  cmpl_state->completion_dir->cmpl_parent = NULL;
+  cmpl_state->completion_dir->cmpl_text = g_strdup (*remaining_text);
+
+  cmpl_state->active_completion_dir = cmpl_state->completion_dir;
+
+  cmpl_state->reference_dir = cmpl_state->completion_dir;
+
+  poss = attempt_dir_completion (cmpl_state);
+
+  update_cmpl (poss, cmpl_state);
+
+  return poss;
+}
+
+static PossibleCompletion*
+cmpl_next_completion (CompletionState* cmpl_state)
+{
+  PossibleCompletion* poss = NULL;
+
+  cmpl_state->the_completion.text[0] = 0;
+
+#ifdef HAVE_PWD_H
+  if (cmpl_state->user_completion_index >= 0)
+    poss = attempt_homedir_completion (cmpl_state->last_completion_text, cmpl_state);
+  else
+    poss = attempt_dir_completion (cmpl_state);
+#else
+  poss = attempt_dir_completion (cmpl_state);
+#endif
+
+  update_cmpl (poss, cmpl_state);
+
+  return poss;
+}
+
+/**********************************************************************/
+/*                      Directory Operations                         */
+/**********************************************************************/
+
+/* Open the directory where completion will begin from, if possible. */
+static CompletionDir*
+open_ref_dir (gchar           *text_to_complete,
+             gchar          **remaining_text,
+             CompletionState *cmpl_state)
+{
+  gchar* first_slash;
+  CompletionDir *new_dir;
+
+  first_slash = strchr (text_to_complete, G_DIR_SEPARATOR);
+
+#ifdef G_WITH_CYGWIN
+  if (text_to_complete[0] == '/' && text_to_complete[1] == '/')
+    {
+      char root_dir[5];
+      g_snprintf (root_dir, sizeof (root_dir), "//%c", text_to_complete[2]);
+
+      new_dir = open_dir (root_dir, cmpl_state);
+
+      if (new_dir) {
+       *remaining_text = text_to_complete + 4;
+      }
+    }
+#else
+  if (FALSE)
+    ;
+#endif
+#ifdef HAVE_PWD_H
+  else if (text_to_complete[0] == '~')
+    {
+      new_dir = open_user_dir (text_to_complete, cmpl_state);
+
+      if (new_dir)
+       {
+         if (first_slash)
+           *remaining_text = first_slash + 1;
+         else
+           *remaining_text = text_to_complete + strlen (text_to_complete);
+       }
+      else
+       {
+         return NULL;
+       }
+    }
+#endif
+  else if (g_path_is_absolute (text_to_complete) || !cmpl_state->reference_dir)
+    {
+      gchar *tmp = g_strdup (text_to_complete);
+      gchar *p;
+
+      p = tmp;
+      while (*p && *p != '*' && *p != '?')
+       p++;
+
+      *p = '\0';
+      p = strrchr (tmp, G_DIR_SEPARATOR);
+      if (p)
+       {
+         if (p == tmp)
+           p++;
+      
+         *p = '\0';
+
+         new_dir = open_dir (tmp, cmpl_state);
+
+         if (new_dir)
+           *remaining_text = text_to_complete + 
+             ((p == tmp + 1) ? (p - tmp) : (p + 1 - tmp));
+       }
+      else
+       {
+         /* If no possible candidates, use the cwd */
+         gchar *sys_curdir = g_get_current_dir ();
+         gchar *utf8_curdir = g_filename_to_utf8 (sys_curdir, -1, NULL, NULL, NULL);
+
+         g_free (sys_curdir);
+
+         new_dir = open_dir (utf8_curdir, cmpl_state);
+
+         if (new_dir)
+           *remaining_text = text_to_complete;
+
+         g_free (utf8_curdir);
+       }
+
+      g_free (tmp);
+    }
+  else
+    {
+      *remaining_text = text_to_complete;
+
+      new_dir = open_dir (cmpl_state->reference_dir->fullname, cmpl_state);
+    }
+
+  if (new_dir)
+    {
+      new_dir->cmpl_index = -1;
+      new_dir->cmpl_parent = NULL;
+    }
+
+  return new_dir;
+}
+
+#ifdef HAVE_PWD_H
+
+/* open a directory by user name */
+static CompletionDir*
+open_user_dir (const gchar     *text_to_complete,
+              CompletionState *cmpl_state)
+{
+  CompletionDir *result;
+  gchar *first_slash;
+  gint cmp_len;
+
+  g_assert (text_to_complete && text_to_complete[0] == '~');
+
+  first_slash = strchr (text_to_complete, G_DIR_SEPARATOR);
+
+  if (first_slash)
+    cmp_len = first_slash - text_to_complete - 1;
+  else
+    cmp_len = strlen (text_to_complete + 1);
+
+  if (!cmp_len)
+    {
+      /* ~/ */
+      const gchar *homedir = g_get_home_dir ();
+      gchar *utf8_homedir = g_filename_to_utf8 (homedir, -1, NULL, NULL, NULL);
+
+      if (utf8_homedir)
+       result = open_dir (utf8_homedir, cmpl_state);
+      else
+       result = NULL;
+      
+      g_free (utf8_homedir);
+    }
+  else
+    {
+      /* ~user/ */
+      gchar* copy = g_new (char, cmp_len + 1);
+      gchar *utf8_dir;
+      struct passwd *pwd;
+
+      strncpy (copy, text_to_complete + 1, cmp_len);
+      copy[cmp_len] = 0;
+      pwd = getpwnam (copy);
+      g_free (copy);
+      if (!pwd)
+       {
+         cmpl_errno = errno;
+         return NULL;
+       }
+      utf8_dir = g_filename_to_utf8 (pwd->pw_dir, -1, NULL, NULL, NULL);
+      result = open_dir (utf8_dir, cmpl_state);
+      g_free (utf8_dir);
+    }
+  return result;
+}
+
+#endif
+
+/* open a directory relative the the current relative directory */
+static CompletionDir*
+open_relative_dir (gchar           *dir_name,
+                  CompletionDir   *dir,
+                  CompletionState *cmpl_state)
+{
+  CompletionDir *result;
+  GString *path;
+
+  path = g_string_sized_new (dir->fullname_len + strlen (dir_name) + 10);
+  g_string_assign (path, dir->fullname);
+
+  if (dir->fullname_len > 1
+      && path->str[dir->fullname_len - 1] != G_DIR_SEPARATOR)
+    g_string_append_c (path, G_DIR_SEPARATOR);
+  g_string_append (path, dir_name);
+
+  result = open_dir (path->str, cmpl_state);
+
+  g_string_free (path, TRUE);
+
+  return result;
+}
+
+/* after the cache lookup fails, really open a new directory */
+static CompletionDirSent*
+open_new_dir (gchar       *dir_name,
+             struct stat *sbuf,
+             gboolean     stat_subdirs)
+{
+  CompletionDirSent *sent;
+  GDir *directory;
+  const char *dirent;
+  GError *error = NULL;
+  gint entry_count = 0;
+  gint n_entries = 0;
+  gint i;
+  struct stat ent_sbuf;
+  GString *path;
+  gchar *sys_dir_name;
+
+  sent = g_new (CompletionDirSent, 1);
+  sent->mtime = sbuf->st_mtime;
+  sent->inode = sbuf->st_ino;
+  sent->device = sbuf->st_dev;
+
+  path = g_string_sized_new (2*MAXPATHLEN + 10);
+
+  sys_dir_name = g_filename_from_utf8 (dir_name, -1, NULL, NULL, NULL);
+  if (!sys_dir_name)
+    {
+      cmpl_errno = CMPL_ERRNO_DID_NOT_CONVERT;
+      return NULL;
+    }
+  
+  directory = g_dir_open (sys_dir_name, 0, &error);
+  if (!directory)
+    {
+      cmpl_errno = error->code; /* ??? */
+      g_free (sys_dir_name);
+      return NULL;
+    }
+
+  while ((dirent = g_dir_read_name (directory)) != NULL)
+    entry_count++;
+
+  entry_count += 2;            /* For ".",".." */
+
+  sent->entries = g_new (CompletionDirEntry, entry_count);
+  sent->entry_count = entry_count;
+
+  g_dir_rewind (directory);
+
+  for (i = 0; i < entry_count; i += 1)
+    {
+      GError *error = NULL;
+
+      if (i == 0)
+       dirent = ".";
+      else if (i == 1)
+       dirent = "..";
+      else
+       {
+         dirent = g_dir_read_name (directory);
+         if (!dirent)          /* Directory changed */
+           break;
+       }
+
+      sent->entries[n_entries].entry_name = g_filename_to_utf8 (dirent, -1, NULL, NULL, &error);
+      if (sent->entries[n_entries].entry_name == NULL
+         || !g_utf8_validate (sent->entries[n_entries].entry_name, -1, NULL))
+       {
+         gchar *escaped_str = g_strescape (dirent, NULL);
+         g_message (_("The filename \"%s\" couldn't be converted to UTF-8 "
+                      "(try setting the environment variable G_BROKEN_FILENAMES): %s"),
+                    escaped_str,
+                    error->message ? error->message : _("Invalid Utf-8"));
+         g_free (escaped_str);
+         g_clear_error (&error);
+         continue;
+       }
+      g_clear_error (&error);
+      
+      sent->entries[n_entries].sort_key = g_utf8_collate_key (sent->entries[n_entries].entry_name, -1);
+      
+      g_string_assign (path, sys_dir_name);
+      if (path->str[path->len-1] != G_DIR_SEPARATOR)
+       {
+         g_string_append_c (path, G_DIR_SEPARATOR);
+       }
+      g_string_append (path, dirent);
+
+      if (stat_subdirs)
+       {
+         /* Here we know path->str is a "system charset" string */
+         if (stat (path->str, &ent_sbuf) >= 0 && S_ISDIR (ent_sbuf.st_mode))
+           sent->entries[n_entries].is_dir = TRUE;
+         else
+           /* stat may fail, and we don't mind, since it could be a
+            * dangling symlink. */
+           sent->entries[n_entries].is_dir = FALSE;
+       }
+      else
+       sent->entries[n_entries].is_dir = 1;
+
+      n_entries++;
+    }
+  sent->entry_count = n_entries;
+  
+  g_free (sys_dir_name);
+  g_string_free (path, TRUE);
+  qsort (sent->entries, sent->entry_count, sizeof (CompletionDirEntry), compare_cmpl_dir);
+
+  g_dir_close (directory);
+
+  return sent;
+}
+
+#if !defined(G_OS_WIN32) && !defined(G_WITH_CYGWIN)
+
+static gboolean
+check_dir (gchar       *dir_name,
+          struct stat *result,
+          gboolean    *stat_subdirs)
+{
+  /* A list of directories that we know only contain other directories.
+   * Trying to stat every file in these directories would be very
+   * expensive.
+   */
+
+  static struct {
+    gchar *name;
+    gboolean present;
+    struct stat statbuf;
+  } no_stat_dirs[] = {
+    { "/afs", FALSE, { 0 } },
+    { "/net", FALSE, { 0 } }
+  };
+
+  static const gint n_no_stat_dirs = G_N_ELEMENTS (no_stat_dirs);
+  static gboolean initialized = FALSE;
+  gchar *sys_dir_name;
+  gint i;
+
+  if (!initialized)
+    {
+      initialized = TRUE;
+      for (i = 0; i < n_no_stat_dirs; i++)
+       {
+         if (stat (no_stat_dirs[i].name, &no_stat_dirs[i].statbuf) == 0)
+           no_stat_dirs[i].present = TRUE;
+       }
+    }
+
+  sys_dir_name = g_filename_from_utf8 (dir_name, -1, NULL, NULL, NULL);
+  if (!sys_dir_name)
+    {
+      cmpl_errno = CMPL_ERRNO_DID_NOT_CONVERT;
+      return FALSE;
+    }
+  
+  if (stat (sys_dir_name, result) < 0)
+    {
+      g_free (sys_dir_name);
+      cmpl_errno = errno;
+      return FALSE;
+    }
+  g_free (sys_dir_name);
+
+  *stat_subdirs = TRUE;
+  for (i = 0; i < n_no_stat_dirs; i++)
+    {
+      if (no_stat_dirs[i].present &&
+         (no_stat_dirs[i].statbuf.st_dev == result->st_dev) &&
+         (no_stat_dirs[i].statbuf.st_ino == result->st_ino))
+       {
+         *stat_subdirs = FALSE;
+         break;
+       }
+    }
+
+  return TRUE;
+}
+
+#endif
+
+/* open a directory by absolute pathname */
+static CompletionDir*
+open_dir (gchar           *dir_name,
+         CompletionState *cmpl_state)
+{
+  struct stat sbuf;
+  gboolean stat_subdirs;
+  CompletionDirSent *sent;
+  GList* cdsl;
+
+#if !defined(G_OS_WIN32) && !defined(G_WITH_CYGWIN)
+  if (!check_dir (dir_name, &sbuf, &stat_subdirs))
+    return NULL;
+
+  cdsl = cmpl_state->directory_sent_storage;
+
+  while (cdsl)
+    {
+      sent = cdsl->data;
+
+      if (sent->inode == sbuf.st_ino &&
+         sent->mtime == sbuf.st_mtime &&
+         sent->device == sbuf.st_dev)
+       return attach_dir (sent, dir_name, cmpl_state);
+
+      cdsl = cdsl->next;
+    }
+#else
+  stat_subdirs = TRUE;
+#endif
+
+  sent = open_new_dir (dir_name, &sbuf, stat_subdirs);
+
+  if (sent)
+    {
+      cmpl_state->directory_sent_storage =
+       g_list_prepend (cmpl_state->directory_sent_storage, sent);
+
+      return attach_dir (sent, dir_name, cmpl_state);
+    }
+
+  return NULL;
+}
+
+static CompletionDir*
+attach_dir (CompletionDirSent *sent,
+           gchar             *dir_name,
+           CompletionState   *cmpl_state)
+{
+  CompletionDir* new_dir;
+
+  new_dir = g_new (CompletionDir, 1);
+
+  cmpl_state->directory_storage =
+    g_list_prepend (cmpl_state->directory_storage, new_dir);
+
+  new_dir->sent = sent;
+  new_dir->fullname = g_strdup (dir_name);
+  new_dir->fullname_len = strlen (dir_name);
+  new_dir->cmpl_text = NULL;
+
+  return new_dir;
+}
+
+static gint
+correct_dir_fullname (CompletionDir* cmpl_dir)
+{
+  gint length = strlen (cmpl_dir->fullname);
+  gchar *first_slash = strchr (cmpl_dir->fullname, G_DIR_SEPARATOR);
+  gchar *sys_filename;
+  struct stat sbuf;
+
+  /* Does it end with /. (\.) ? */
+  if (length >= 2 &&
+      strcmp (cmpl_dir->fullname + length - 2, G_DIR_SEPARATOR_S ".") == 0)
+    {
+      /* Is it just the root directory (on a drive) ? */
+      if (cmpl_dir->fullname + length - 2 == first_slash)
+       {
+         cmpl_dir->fullname[length - 1] = 0;
+         cmpl_dir->fullname_len = length - 1;
+         return TRUE;
+       }
+      else
+       {
+         cmpl_dir->fullname[length - 2] = 0;
+       }
+    }
+
+  /* Ends with /./ (\.\)? */
+  else if (length >= 3 &&
+          strcmp (cmpl_dir->fullname + length - 3,
+                  G_DIR_SEPARATOR_S "." G_DIR_SEPARATOR_S) == 0)
+    cmpl_dir->fullname[length - 2] = 0;
+
+  /* Ends with /.. (\..) ? */
+  else if (length >= 3 &&
+          strcmp (cmpl_dir->fullname + length - 3,
+                  G_DIR_SEPARATOR_S "..") == 0)
+    {
+      /* Is it just /.. (X:\..)? */
+      if (cmpl_dir->fullname + length - 3 == first_slash)
+       {
+         cmpl_dir->fullname[length - 2] = 0;
+         cmpl_dir->fullname_len = length - 2;
+         return TRUE;
+       }
+
+      sys_filename = g_filename_from_utf8 (cmpl_dir->fullname, -1, NULL, NULL, NULL);
+      if (!sys_filename)
+       {
+         cmpl_errno = CMPL_ERRNO_DID_NOT_CONVERT;
+         return FALSE;
+       }
+      
+      if (stat (sys_filename, &sbuf) < 0)
+       {
+         g_free (sys_filename);
+         cmpl_errno = errno;
+         return FALSE;
+       }
+      g_free (sys_filename);
+
+      cmpl_dir->fullname[length - 3] = 0;
+
+      if (!correct_parent (cmpl_dir, &sbuf))
+       return FALSE;
+    }
+
+  /* Ends with /../ (\..\)? */
+  else if (length >= 4 &&
+          strcmp (cmpl_dir->fullname + length - 4,
+                  G_DIR_SEPARATOR_S ".." G_DIR_SEPARATOR_S) == 0)
+    {
+      /* Is it just /../ (X:\..\)? */
+      if (cmpl_dir->fullname + length - 4 == first_slash)
+       {
+         cmpl_dir->fullname[length - 3] = 0;
+         cmpl_dir->fullname_len = length - 3;
+         return TRUE;
+       }
+
+      sys_filename = g_filename_from_utf8 (cmpl_dir->fullname, -1, NULL, NULL, NULL);
+      if (!sys_filename)
+       {
+         cmpl_errno = CMPL_ERRNO_DID_NOT_CONVERT;
+         return FALSE;
+       }
+      
+      if (stat (sys_filename, &sbuf) < 0)
+       {
+         g_free (sys_filename);
+         cmpl_errno = errno;
+         return FALSE;
+       }
+      g_free (sys_filename);
+
+      cmpl_dir->fullname[length - 4] = 0;
+
+      if (!correct_parent (cmpl_dir, &sbuf))
+       return FALSE;
+    }
+
+  cmpl_dir->fullname_len = strlen (cmpl_dir->fullname);
+
+  return TRUE;
+}
+
+static gint
+correct_parent (CompletionDir *cmpl_dir,
+               struct stat   *sbuf)
+{
+  struct stat parbuf;
+  gchar *last_slash;
+  gchar *first_slash;
+  gchar *new_name;
+  gchar *sys_filename;
+  gchar c = 0;
+
+  last_slash = strrchr (cmpl_dir->fullname, G_DIR_SEPARATOR);
+  g_assert (last_slash);
+  first_slash = strchr (cmpl_dir->fullname, G_DIR_SEPARATOR);
+
+  /* Clever (?) way to check for top-level directory that works also on
+   * Win32, where there is a drive letter and colon prefixed...
+   */
+  if (last_slash != first_slash)
+    {
+      last_slash[0] = 0;
+    }
+  else
+    {
+      c = last_slash[1];
+      last_slash[1] = 0;
+    }
+
+  sys_filename = g_filename_from_utf8 (cmpl_dir->fullname, -1, NULL, NULL, NULL);
+  if (!sys_filename)
+    {
+      cmpl_errno = CMPL_ERRNO_DID_NOT_CONVERT;
+      if (!c)
+       last_slash[0] = G_DIR_SEPARATOR;
+      return FALSE;
+    }
+  
+  if (stat (sys_filename, &parbuf) < 0)
+    {
+      g_free (sys_filename);
+      cmpl_errno = errno;
+      if (!c)
+       last_slash[0] = G_DIR_SEPARATOR;
+      return FALSE;
+    }
+  g_free (sys_filename);
+
+#ifndef G_OS_WIN32             /* No inode numbers on Win32 */
+  if (parbuf.st_ino == sbuf->st_ino && parbuf.st_dev == sbuf->st_dev)
+    /* it wasn't a link */
+    return TRUE;
+
+  if (c)
+    last_slash[1] = c;
+  else
+    last_slash[0] = G_DIR_SEPARATOR;
+
+  /* it was a link, have to figure it out the hard way */
+
+  new_name = find_parent_dir_fullname (cmpl_dir->fullname);
+
+  if (!new_name)
+    return FALSE;
+
+  g_free (cmpl_dir->fullname);
+
+  cmpl_dir->fullname = new_name;
+#endif
+
+  return TRUE;
+}
+
+#ifndef G_OS_WIN32
+
+static gchar*
+find_parent_dir_fullname (gchar* dirname)
+{
+  gchar *sys_orig_dir;
+  gchar *result;
+  gchar *sys_cwd;
+  gchar *sys_dirname;
+
+  sys_orig_dir = g_get_current_dir ();
+  sys_dirname = g_filename_from_utf8 (dirname, -1, NULL, NULL, NULL);
+  if (!sys_dirname)
+    {
+      g_free (sys_orig_dir);
+      cmpl_errno = CMPL_ERRNO_DID_NOT_CONVERT;
+      return NULL;
+    }
+  
+  if (chdir (sys_dirname) != 0 || chdir ("..") != 0)
+    {
+      cmpl_errno = errno;
+      chdir (sys_orig_dir);
+      g_free (sys_dirname);
+      g_free (sys_orig_dir);
+      return NULL;
+    }
+  g_free (sys_dirname);
+
+  sys_cwd = g_get_current_dir ();
+  result = g_filename_to_utf8 (sys_cwd, -1, NULL, NULL, NULL);
+  g_free (sys_cwd);
+
+  if (chdir (sys_orig_dir) != 0)
+    {
+      cmpl_errno = errno;
+      g_free (sys_orig_dir);
+      return NULL;
+    }
+
+  g_free (sys_orig_dir);
+  return result;
+}
+
+#endif
+
+/**********************************************************************/
+/*                        Completion Operations                       */
+/**********************************************************************/
+
+#ifdef HAVE_PWD_H
+
+static PossibleCompletion*
+attempt_homedir_completion (gchar           *text_to_complete,
+                           CompletionState *cmpl_state)
+{
+  gint index, length;
+
+  if (!cmpl_state->user_dir_name_buffer &&
+      !get_pwdb (cmpl_state))
+    return NULL;
+  length = strlen (text_to_complete) - 1;
+
+  cmpl_state->user_completion_index += 1;
+
+  while (cmpl_state->user_completion_index < cmpl_state->user_directories_len)
+    {
+      index = first_diff_index (text_to_complete + 1,
+                               cmpl_state->user_directories
+                               [cmpl_state->user_completion_index].login);
+
+      switch (index)
+       {
+       case PATTERN_MATCH:
+         break;
+       default:
+         if (cmpl_state->last_valid_char < (index + 1))
+           cmpl_state->last_valid_char = index + 1;
+         cmpl_state->user_completion_index += 1;
+         continue;
+       }
+
+      cmpl_state->the_completion.is_a_completion = 1;
+      cmpl_state->the_completion.is_directory = TRUE;
+
+      append_completion_text ("~", cmpl_state);
+
+      append_completion_text (cmpl_state->
+                             user_directories[cmpl_state->user_completion_index].login,
+                             cmpl_state);
+
+      return append_completion_text (G_DIR_SEPARATOR_S, cmpl_state);
+    }
+
+  if (text_to_complete[1]
+      || cmpl_state->user_completion_index > cmpl_state->user_directories_len)
+    {
+      cmpl_state->user_completion_index = -1;
+      return NULL;
+    }
+  else
+    {
+      cmpl_state->user_completion_index += 1;
+      cmpl_state->the_completion.is_a_completion = 1;
+      cmpl_state->the_completion.is_directory = TRUE;
+
+      return append_completion_text ("~" G_DIR_SEPARATOR_S, cmpl_state);
+    }
+}
+
+#endif
+
+#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
+#define FOLD(c) (tolower(c))
+#else
+#define FOLD(c) (c)
+#endif
+
+/* returns the index (>= 0) of the first differing character,
+ * PATTERN_MATCH if the completion matches */
+static gint
+first_diff_index (gchar *pat,
+                 gchar *text)
+{
+  gint diff = 0;
+
+  while (*pat && *text && FOLD (*text) == FOLD (*pat))
+    {
+      pat += 1;
+      text += 1;
+      diff += 1;
+    }
+
+  if (*pat)
+    return diff;
+
+  return PATTERN_MATCH;
+}
+
+static PossibleCompletion*
+append_completion_text (gchar           *text,
+                       CompletionState *cmpl_state)
+{
+  gint len, i = 1;
+
+  if (!cmpl_state->the_completion.text)
+    return NULL;
+
+  len = strlen (text) + strlen (cmpl_state->the_completion.text) + 1;
+
+  if (cmpl_state->the_completion.text_alloc > len)
+    {
+      strcat (cmpl_state->the_completion.text, text);
+      return &cmpl_state->the_completion;
+    }
+
+  while (i < len)
+    i <<= 1;
+
+  cmpl_state->the_completion.text_alloc = i;
+
+  cmpl_state->the_completion.text = (gchar*) g_realloc (cmpl_state->the_completion.text, i);
+
+  if (!cmpl_state->the_completion.text)
+    return NULL;
+  else
+    {
+      strcat (cmpl_state->the_completion.text, text);
+      return &cmpl_state->the_completion;
+    }
+}
+
+static CompletionDir*
+find_completion_dir (gchar          *text_to_complete,
+                   gchar          **remaining_text,
+                   CompletionState *cmpl_state)
+{
+  gchar* first_slash = strchr (text_to_complete, G_DIR_SEPARATOR);
+  CompletionDir* dir = cmpl_state->reference_dir;
+  CompletionDir* next;
+  *remaining_text = text_to_complete;
+
+  while (first_slash)
+    {
+      gint len = first_slash - *remaining_text;
+      gint found = 0;
+      gchar *found_name = NULL;         /* Quiet gcc */
+      gint i;
+      gchar* pat_buf = g_new (gchar, len + 1);
+
+      strncpy (pat_buf, *remaining_text, len);
+      pat_buf[len] = 0;
+
+      for (i = 0; i < dir->sent->entry_count; i += 1)
+       {
+         if (dir->sent->entries[i].is_dir &&
+             _gtk_fnmatch (pat_buf, dir->sent->entries[i].entry_name))
+           {
+             if (found)
+               {
+                 g_free (pat_buf);
+                 return dir;
+               }
+             else
+               {
+                 found = 1;
+                 found_name = dir->sent->entries[i].entry_name;
+               }
+           }
+       }
+
+      if (!found)
+       {
+         /* Perhaps we are trying to open an automount directory */
+         found_name = pat_buf;
+       }
+
+      next = open_relative_dir (found_name, dir, cmpl_state);
+      
+      if (!next)
+       {
+         g_free (pat_buf);
+         return NULL;
+}
+      
+      next->cmpl_parent = dir;
+      
+      dir = next;
+      
+      if (!correct_dir_fullname (dir))
+       {
+         g_free (pat_buf);
+         return NULL;
+       }
+      
+      *remaining_text = first_slash + 1;
+      first_slash = strchr (*remaining_text, G_DIR_SEPARATOR);
+
+      g_free (pat_buf);
+    }
+
+  return dir;
+}
+
+static void
+update_cmpl (PossibleCompletion *poss,
+            CompletionState    *cmpl_state)
+{
+  gint cmpl_len;
+
+  if (!poss || !cmpl_is_a_completion (poss))
+    return;
+
+  cmpl_len = strlen (cmpl_this_completion (poss));
+
+  if (cmpl_state->updated_text_alloc < cmpl_len + 1)
+    {
+      cmpl_state->updated_text =
+       (gchar*)g_realloc (cmpl_state->updated_text,
+                          cmpl_state->updated_text_alloc);
+      cmpl_state->updated_text_alloc = 2*cmpl_len;
+    }
+
+  if (cmpl_state->updated_text_len < 0)
+    {
+      strcpy (cmpl_state->updated_text, cmpl_this_completion (poss));
+      cmpl_state->updated_text_len = cmpl_len;
+      cmpl_state->re_complete = cmpl_is_directory (poss);
+    }
+  else if (cmpl_state->updated_text_len == 0)
+    {
+      cmpl_state->re_complete = FALSE;
+    }
+  else
+    {
+      gint first_diff =
+       first_diff_index (cmpl_state->updated_text,
+                         cmpl_this_completion (poss));
+
+      cmpl_state->re_complete = FALSE;
+
+      if (first_diff == PATTERN_MATCH)
+       return;
+
+      if (first_diff > cmpl_state->updated_text_len)
+       strcpy (cmpl_state->updated_text, cmpl_this_completion (poss));
+
+      cmpl_state->updated_text_len = first_diff;
+      cmpl_state->updated_text[first_diff] = 0;
+    }
+}
+
+static PossibleCompletion*
+attempt_dir_completion (CompletionState *cmpl_state)
+{
+  gchar *pat_buf, *first_slash;
+  CompletionDir *dir = cmpl_state->active_completion_dir;
+
+  dir->cmpl_index += 1;
+
+  if (dir->cmpl_index == dir->sent->entry_count)
+    {
+      if (dir->cmpl_parent == NULL)
+       {
+         cmpl_state->active_completion_dir = NULL;
+
+         return NULL;
+       }
+      else
+       {
+         cmpl_state->active_completion_dir = dir->cmpl_parent;
+
+         return attempt_dir_completion (cmpl_state);
+       }
+    }
+
+  g_assert (dir->cmpl_text);
+
+  first_slash = strchr (dir->cmpl_text, G_DIR_SEPARATOR);
+
+  if (first_slash)
+    {
+      gint len = first_slash - dir->cmpl_text;
+
+      pat_buf = g_new (gchar, len + 1);
+      strncpy (pat_buf, dir->cmpl_text, len);
+      pat_buf[len] = 0;
+    }
+  else
+    {
+      gint len = strlen (dir->cmpl_text);
+
+      pat_buf = g_new (gchar, len + 2);
+      strcpy (pat_buf, dir->cmpl_text);
+      /* Don't append a * if the user entered one herself.
+       * This way one can complete *.h and don't get matches
+       * on any .help files, for instance.
+       */
+      if (strchr (pat_buf, '*') == NULL)
+       strcpy (pat_buf + len, "*");
+    }
+
+  if (first_slash)
+    {
+      if (dir->sent->entries[dir->cmpl_index].is_dir)
+       {
+         if (_gtk_fnmatch (pat_buf, dir->sent->entries[dir->cmpl_index].entry_name))
+           {
+             CompletionDir* new_dir;
+
+             new_dir = open_relative_dir (dir->sent->entries[dir->cmpl_index].entry_name,
+                                          dir, cmpl_state);
+
+             if (!new_dir)
+               {
+                 g_free (pat_buf);
+                 return NULL;
+               }
+
+             new_dir->cmpl_parent = dir;
+
+             new_dir->cmpl_index = -1;
+             new_dir->cmpl_text = g_strdup (first_slash + 1);
+
+             cmpl_state->active_completion_dir = new_dir;
+
+             g_free (pat_buf);
+             return attempt_dir_completion (cmpl_state);
+           }
+         else
+           {
+             g_free (pat_buf);
+             return attempt_dir_completion (cmpl_state);
+           }
+       }
+      else
+       {
+         g_free (pat_buf);
+         return attempt_dir_completion (cmpl_state);
+       }
+    }
+  else
+    {
+      if (dir->cmpl_parent != NULL)
+       {
+         append_completion_text (dir->fullname +
+                                 strlen (cmpl_state->completion_dir->fullname) + 1,
+                                 cmpl_state);
+         append_completion_text (G_DIR_SEPARATOR_S, cmpl_state);
+       }
+
+      append_completion_text (dir->sent->entries[dir->cmpl_index].entry_name, cmpl_state);
+
+      cmpl_state->the_completion.is_a_completion =
+       _gtk_fnmatch (pat_buf, dir->sent->entries[dir->cmpl_index].entry_name);
+
+      cmpl_state->the_completion.is_directory = dir->sent->entries[dir->cmpl_index].is_dir;
+      if (dir->sent->entries[dir->cmpl_index].is_dir)
+       append_completion_text (G_DIR_SEPARATOR_S, cmpl_state);
+
+      g_free (pat_buf);
+      return &cmpl_state->the_completion;
+    }
+}
+
+#ifdef HAVE_PWD_H
+
+static gint
+get_pwdb (CompletionState* cmpl_state)
+{
+  struct passwd *pwd_ptr;
+  gchar* buf_ptr;
+  gchar *utf8;
+  gint len = 0, i, count = 0;
+
+  if (cmpl_state->user_dir_name_buffer)
+    return TRUE;
+  setpwent ();
+
+  while ((pwd_ptr = getpwent ()) != NULL)
+    {
+      utf8 = g_filename_to_utf8 (pwd_ptr->pw_name, -1, NULL, NULL, NULL);
+      len += strlen (utf8);
+      g_free (utf8);
+      utf8 = g_filename_to_utf8 (pwd_ptr->pw_dir, -1, NULL, NULL, NULL);
+      len += strlen (utf8);
+      g_free (utf8);
+      len += 2;
+      count += 1;
+    }
+
+  setpwent ();
+
+  cmpl_state->user_dir_name_buffer = g_new (gchar, len);
+  cmpl_state->user_directories = g_new (CompletionUserDir, count);
+  cmpl_state->user_directories_len = count;
+
+  buf_ptr = cmpl_state->user_dir_name_buffer;
+
+  for (i = 0; i < count; i += 1)
+    {
+      pwd_ptr = getpwent ();
+      if (!pwd_ptr)
+       {
+         cmpl_errno = errno;
+         goto error;
+       }
+
+      utf8 = g_filename_to_utf8 (pwd_ptr->pw_name, -1, NULL, NULL, NULL);
+      strcpy (buf_ptr, utf8);
+      g_free (utf8);
+
+      cmpl_state->user_directories[i].login = buf_ptr;
+
+      buf_ptr += strlen (buf_ptr);
+      buf_ptr += 1;
+
+      utf8 = g_filename_to_utf8 (pwd_ptr->pw_dir, -1, NULL, NULL, NULL);
+      strcpy (buf_ptr, utf8);
+      g_free (utf8);
+
+      cmpl_state->user_directories[i].homedir = buf_ptr;
+
+      buf_ptr += strlen (buf_ptr);
+      buf_ptr += 1;
+    }
+
+  qsort (cmpl_state->user_directories,
+        cmpl_state->user_directories_len,
+        sizeof (CompletionUserDir),
+        compare_user_dir);
+
+  endpwent ();
+
+  return TRUE;
+
+error:
+
+  if (cmpl_state->user_dir_name_buffer)
+    g_free (cmpl_state->user_dir_name_buffer);
+  if (cmpl_state->user_directories)
+    g_free (cmpl_state->user_directories);
+
+  cmpl_state->user_dir_name_buffer = NULL;
+  cmpl_state->user_directories = NULL;
+
+  return FALSE;
+}
+
+static gint
+compare_user_dir (const void *a,
+                 const void *b)
+{
+  return strcmp ((((CompletionUserDir*)a))->login,
+                (((CompletionUserDir*)b))->login);
+}
+
+#endif
+
+static gint
+compare_cmpl_dir (const void *a,
+                 const void *b)
+{
+  
+  return strcmp (((CompletionDirEntry*)a)->sort_key,
+                (((CompletionDirEntry*)b))->sort_key);
+}
+
+static gint
+cmpl_state_okay (CompletionState* cmpl_state)
+{
+  return  cmpl_state && cmpl_state->reference_dir;
+}
+
+static const gchar*
+cmpl_strerror (gint err)
+{
+  if (err == CMPL_ERRNO_TOO_LONG)
+    return _("Name too long");
+  else if (err == CMPL_ERRNO_DID_NOT_CONVERT)
+    return _("Couldn't convert filename");
+  else
+    return g_strerror (err);
+}
+
+const gchar *    gtk_dir_selection_get_dir (GtkDirSelection *filesel)
+{
+  return     gtk_entry_get_text (GTK_ENTRY (filesel->selection_entry));
+}
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/gtkdirsel.h b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/gtkdirsel.h
new file mode 100644 (file)
index 0000000..103ced2
--- /dev/null
@@ -0,0 +1,115 @@
+/* This file is part of the Linux Trace Toolkit viewer
+ * Copyright (C) 2003-2004 Xiangxiu 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.
+ */
+
+
+#ifndef __GTK_DIR_SEL_H__
+#define __GTK_DIR_SEL_H__
+
+
+#include <gdk/gdk.h>
+#include <gtk/gtkdialog.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+#define GTK_TYPE_DIR_SELECTION            (gtk_dir_selection_get_type ())
+#define GTK_DIR_SELECTION(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_DIR_SELECTION, GtkDirSelection))
+#define GTK_DIR_SELECTION_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_DIR_SELECTION, GtkDirSelectionClass))
+#define GTK_IS_DIR_SELECTION(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_DIR_SELECTION))
+#define GTK_IS_DIR_SELECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_DIR_SELECTION))
+#define GTK_DIR_SELECTION_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_DIR_SELECTION, GtkDirSelectionClass))
+
+
+typedef struct _GtkDirSelection       GtkDirSelection;
+typedef struct _GtkDirSelectionClass  GtkDirSelectionClass;
+
+struct _GtkDirSelection
+{
+  GtkDialog parent_instance;
+
+  GtkWidget *dir_list;
+  GtkWidget *file_list;
+  GtkWidget *selection_entry;
+  GtkWidget *selection_text;
+  GtkWidget *main_vbox;
+  GtkWidget *ok_button;
+  GtkWidget *cancel_button;
+  GtkWidget *help_button;
+  GtkWidget *history_pulldown;
+  GtkWidget *history_menu;
+  GList     *history_list;
+  GtkWidget *fileop_dialog;
+  GtkWidget *fileop_entry;
+  gchar     *fileop_file;
+  gpointer   cmpl_state;
+  
+  GtkWidget *fileop_c_dir;
+  GtkWidget *fileop_del_file;
+  GtkWidget *fileop_ren_file;
+  
+  GtkWidget *button_area;
+  GtkWidget *action_area;
+
+  GPtrArray *selected_names;
+  gchar     *last_selected;
+};
+
+struct _GtkDirSelectionClass
+{
+  GtkDialogClass parent_class;
+
+  /* Padding for future expansion */
+  void (*_gtk_reserved1) (void);
+  void (*_gtk_reserved2) (void);
+  void (*_gtk_reserved3) (void);
+  void (*_gtk_reserved4) (void);
+};
+
+
+GType      gtk_dir_selection_get_type            (void) G_GNUC_CONST;
+GtkWidget* gtk_dir_selection_new                 (const gchar      *title);
+void       gtk_dir_selection_set_filename        (GtkDirSelection *filesel,
+                                                  const gchar      *filename);
+/* This function returns the selected filename in the C runtime's
+ * multibyte string encoding, which may or may not be the same as that
+ * used by GDK (UTF-8). To convert to UTF-8, call g_filename_to_utf8().
+ * The returned string points to a statically allocated buffer and
+ * should be copied away.
+ */
+G_CONST_RETURN gchar* gtk_dir_selection_get_filename        (GtkDirSelection *filesel);
+
+void      gtk_dir_selection_complete             (GtkDirSelection *filesel,
+                                                  const gchar      *pattern);
+void       gtk_dir_selection_show_fileop_buttons (GtkDirSelection *filesel);
+void       gtk_dir_selection_hide_fileop_buttons (GtkDirSelection *filesel);
+
+gchar**    gtk_dir_selection_get_selections      (GtkDirSelection *filesel);
+const gchar *    gtk_dir_selection_get_dir (GtkDirSelection *filesel);
+void       gtk_dir_selection_set_select_multiple (GtkDirSelection *filesel,
+                                                  gboolean          select_multiple);
+gboolean   gtk_dir_selection_get_select_multiple (GtkDirSelection *filesel);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __GTK_DIR_SEL_H__ */
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/gtkmultivpaned.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/gtkmultivpaned.c
new file mode 100644 (file)
index 0000000..93d87c5
--- /dev/null
@@ -0,0 +1,567 @@
+/* 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.
+ */
+
+#include <gtk/gtk.h>
+
+#include <lttvwindow/gtkmultivpaned.h>
+//#include "gtkintl.h"
+#include <lttvwindow/mainwindow.h>
+#include <lttvwindow/gtktraceset.h>
+
+static void gtk_multi_vpaned_class_init (GtkMultiVPanedClass    *klass);
+static void gtk_multi_vpaned_init       (GtkMultiVPaned         *multi_vpaned);
+
+
+static void     gtk_multi_vpaned_size_request   (GtkWidget      *widget,
+                                          GtkRequisition *requisition);
+static void     gtk_multi_vpaned_size_allocate  (GtkWidget      *widget,
+                                          GtkAllocation  *allocation);
+
+void gtk_multi_vpaned_scroll_value_changed (GtkRange *range, gpointer multi_vpaned);
+
+gboolean gtk_multi_vpaned_destroy(GtkObject       *object,
+                                  gpointer           user_data)
+{
+  GtkMultiVPaned * multi_vpaned = (GtkMultiVPaned * )object;
+  while(multi_vpaned->num_children){
+    gtk_multi_vpaned_widget_delete(multi_vpaned);
+  }    
+  return FALSE;
+}
+
+GType
+gtk_multi_vpaned_get_type (void)
+{
+  static GType multi_vpaned_type = 0;
+
+  if (!multi_vpaned_type)
+    {
+      static const GTypeInfo multi_vpaned_info =
+      {
+       sizeof (GtkMultiVPanedClass),
+       NULL,           /* base_init */
+       NULL,           /* base_finalize */
+       (GClassInitFunc) gtk_multi_vpaned_class_init,
+       NULL,           /* class_finalize */
+       NULL,           /* class_data */
+       sizeof (GtkMultiVPaned),
+       0,              /* n_preallocs */
+       (GInstanceInitFunc) gtk_multi_vpaned_init,
+       NULL,           /* value_table */
+      };
+
+      multi_vpaned_type = g_type_register_static (GTK_TYPE_PANED, "GtkMultiVPaned", 
+                                        &multi_vpaned_info, 0);
+    }
+
+  return multi_vpaned_type;
+}
+
+static void
+gtk_multi_vpaned_class_init (GtkMultiVPanedClass *class)
+{
+  GtkWidgetClass *widget_class;
+  
+  widget_class = (GtkWidgetClass *) class;
+
+  widget_class->size_request = gtk_multi_vpaned_size_request;
+  widget_class->size_allocate = gtk_multi_vpaned_size_allocate;
+}
+
+static void
+gtk_multi_vpaned_init (GtkMultiVPaned * multi_vpaned)
+{
+  GtkWidget * button;
+
+  GTK_WIDGET_SET_FLAGS (multi_vpaned, GTK_NO_WINDOW);
+  gtk_widget_set_redraw_on_allocate (GTK_WIDGET (multi_vpaned), FALSE);
+  
+  multi_vpaned->first_pane    = NULL;
+  multi_vpaned->last_pane     = NULL;
+  multi_vpaned->focused_pane  = NULL;
+  multi_vpaned->iter          = NULL;
+  multi_vpaned->num_children  = 0;
+
+  multi_vpaned->vbox         = NULL;
+  //  multi_vpaned->scrollWindow = NULL;
+  //  multi_vpaned->viewport     = NULL;
+  multi_vpaned->hscrollbar   = NULL;
+}
+
+
+GtkWidget* gtk_multi_vpaned_new ()
+{
+  GtkWidget * widget = GTK_WIDGET (g_object_new (gtk_multi_vpaned_get_type (), NULL));
+  g_signal_connect(G_OBJECT(widget), "destroy",
+                  G_CALLBACK(gtk_multi_vpaned_destroy),NULL);
+  
+  return widget;
+}
+
+GtkWidget * gtk_multi_vpaned_get_widget(GtkMultiVPaned * multi_vpaned)
+{
+  if(multi_vpaned->focused_pane == NULL)return NULL;
+  return (GtkWidget*)multi_vpaned->focused_pane->child2;
+}
+
+GtkWidget * gtk_multi_vpaned_get_first_widget(GtkMultiVPaned * multi_vpaned)
+{
+  if(multi_vpaned->first_pane == NULL)return NULL;
+  multi_vpaned->iter = multi_vpaned->first_pane;
+  return multi_vpaned->first_pane->child2;
+}
+
+GtkWidget * gtk_multi_vpaned_get_next_widget(GtkMultiVPaned * multi_vpaned)
+{
+  if(multi_vpaned->iter != multi_vpaned->last_pane){
+    multi_vpaned->iter = (GtkPaned *)multi_vpaned->iter->child1;
+    return multi_vpaned->iter->child2;
+  }else {
+    return NULL;
+  }
+}
+
+void gtk_multi_vpaned_set_data(GtkMultiVPaned * multi_vpaned,char * key, gpointer value)
+{
+  g_object_set_data(G_OBJECT(multi_vpaned->focused_pane), key, value);    
+}
+
+gpointer gtk_multi_vpaned_get_data(GtkMultiVPaned * multi_vpaned,char * key)
+{
+  if(multi_vpaned->focused_pane == NULL)return NULL;
+  return g_object_get_data(G_OBJECT(multi_vpaned->focused_pane), key);
+}
+
+void gtk_multi_vpaned_set_focus (GtkWidget * widget, gpointer user_data)
+{
+  GtkMultiVPaned * multi_vpaned = (GtkMultiVPaned*) widget;
+  GtkPaned * pane;
+  if(!multi_vpaned->first_pane) return;
+  
+
+  pane = multi_vpaned->first_pane;
+  while(1){
+    if((GtkWidget*)pane == (GtkWidget*)user_data){
+      multi_vpaned->focused_pane = pane;
+      break;
+    }
+    if(pane == multi_vpaned->last_pane){
+      multi_vpaned->focused_pane = NULL;
+      break;
+    }
+    pane = (GtkPaned*)pane->child1;
+  }
+}
+
+void gtk_multi_vpaned_set_adjust(GtkMultiVPaned * multi_vpaned, gboolean first_time)
+{
+  TimeWindow time_window;
+  TimeInterval *time_span;
+  double tmp, start;
+  double range = 0;
+
+  get_time_window(multi_vpaned->mw,&time_window);
+  if(first_time){
+    time_span = LTTV_TRACESET_CONTEXT(multi_vpaned->mw->current_tab->traceset_info->
+                                     traceset_context)->Time_Span ;
+  
+    multi_vpaned->hadjust->lower = ltt_time_to_double(time_span->startTime) * 
+                             NANOSECONDS_PER_SECOND;
+    multi_vpaned->hadjust->value = multi_vpaned->hadjust->lower;
+    multi_vpaned->hadjust->upper = ltt_time_to_double(time_span->endTime) *
+                             NANOSECONDS_PER_SECOND;
+  }
+
+  /* Page increment of whole visible area */
+  if(multi_vpaned->hadjust == NULL){
+    g_warning("Insert a viewer first");
+    return;
+  }
+
+  start = ltt_time_to_double(time_window.start_time) * NANOSECONDS_PER_SECOND;
+  tmp = multi_vpaned->hadjust->upper - multi_vpaned->hadjust->lower;
+
+  multi_vpaned->hadjust->page_increment = ltt_time_to_double(
+                       time_window.time_width) * NANOSECONDS_PER_SECOND;
+
+  if(multi_vpaned->hadjust->page_increment >= tmp - range)
+    multi_vpaned->hadjust->value = multi_vpaned->hadjust->lower;
+  if(start + multi_vpaned->hadjust->page_increment >= multi_vpaned->hadjust->upper - range)
+    multi_vpaned->hadjust->value = start;
+
+  /* page_size to the whole visible area will take care that the
+     * scroll value + the shown area will never be more than what is
+     * in the trace. */
+  multi_vpaned->hadjust->page_size = multi_vpaned->hadjust->page_increment;
+  multi_vpaned->hadjust->step_increment = multi_vpaned->hadjust->page_increment / 10;
+
+  gtk_adjustment_changed (multi_vpaned->hadjust);
+}
+
+void gtk_multi_vpaned_widget_add(GtkMultiVPaned * multi_vpaned, GtkWidget * widget1)
+{
+  GtkPaned * tmpPane; 
+  GtkWidget * w;
+  
+  g_return_if_fail(GTK_IS_MULTI_VPANED(multi_vpaned));
+  g_object_ref(G_OBJECT(widget1));
+
+  if(!multi_vpaned->first_pane){
+    multi_vpaned->first_pane = (GtkPaned *)gtk_vpaned_new();
+    multi_vpaned->last_pane = multi_vpaned->first_pane;
+
+    multi_vpaned->hscrollbar = gtk_hscrollbar_new (NULL);
+    gtk_widget_show(multi_vpaned->hscrollbar);
+
+    multi_vpaned->hadjust = gtk_range_get_adjustment(GTK_RANGE(multi_vpaned->hscrollbar));
+    gtk_multi_vpaned_set_adjust(multi_vpaned, TRUE);
+
+    gtk_range_set_update_policy (GTK_RANGE(multi_vpaned->hscrollbar),
+                                                                                                                                GTK_UPDATE_CONTINUOUS);
+                                                                                                                                //changed by Mathieu Desnoyers, was :
+                                 // GTK_UPDATE_DISCONTINUOUS);
+    g_signal_connect(G_OBJECT(multi_vpaned->hscrollbar), "value-changed",
+                    G_CALLBACK(gtk_multi_vpaned_scroll_value_changed), multi_vpaned);
+
+    multi_vpaned->vbox = gtk_vbox_new(FALSE,0);
+    gtk_widget_show(multi_vpaned->vbox);
+    
+    //    multi_vpaned->viewport = gtk_viewport_new (NULL,NULL);
+    //    gtk_widget_show(multi_vpaned->viewport);
+    
+    //    gtk_container_add(GTK_CONTAINER(multi_vpaned->viewport), (GtkWidget*)multi_vpaned->vbox);
+    gtk_box_pack_end(GTK_BOX(multi_vpaned->vbox),(GtkWidget*)multi_vpaned->hscrollbar,FALSE,FALSE,0);
+    gtk_box_pack_end(GTK_BOX(multi_vpaned->vbox),(GtkWidget*)multi_vpaned->first_pane,TRUE,TRUE,0);
+    
+    //    multi_vpaned->scrollWindow = gtk_scrolled_window_new (NULL, NULL);
+    //    gtk_widget_show(multi_vpaned->scrollWindow);
+    //    gtk_container_add (GTK_CONTAINER (multi_vpaned->scrollWindow), (GtkWidget*)multi_vpaned->viewport);    
+    //    gtk_paned_pack1(GTK_PANED(multi_vpaned), (GtkWidget*)multi_vpaned->scrollWindow,FALSE, TRUE);
+
+    gtk_paned_pack1(GTK_PANED(multi_vpaned), (GtkWidget*)multi_vpaned->vbox,FALSE, TRUE);
+  }else{
+    tmpPane = multi_vpaned->last_pane;
+    multi_vpaned->last_pane = (GtkPaned *)gtk_vpaned_new();
+    gtk_paned_pack1 (tmpPane,(GtkWidget*)multi_vpaned->last_pane, FALSE,TRUE);
+  }
+  gtk_widget_show((GtkWidget *)multi_vpaned->last_pane);  
+
+  gtk_paned_pack2 (multi_vpaned->last_pane,widget1, TRUE, TRUE);      
+  multi_vpaned->focused_pane = multi_vpaned->last_pane;
+  multi_vpaned->num_children++;
+  
+}
+
+void gtk_multi_vpaned_widget_delete(GtkMultiVPaned * multi_vpaned)
+{
+  GtkPaned * tmp, *prev, *next;
+
+  if(!multi_vpaned->focused_pane) return;
+  tmp = (GtkPaned*)multi_vpaned->focused_pane->child2; //widget in vpaned
+  g_object_unref(G_OBJECT(tmp));
+
+  if(multi_vpaned->focused_pane == multi_vpaned->first_pane &&
+     multi_vpaned->focused_pane == multi_vpaned->last_pane){
+    //    gtk_container_remove(GTK_CONTAINER(multi_vpaned),(GtkWidget*)multi_vpaned->scrollWindow);
+    gtk_container_remove(GTK_CONTAINER(multi_vpaned),(GtkWidget*)multi_vpaned->vbox);
+    multi_vpaned->first_pane = NULL;
+    multi_vpaned->last_pane = NULL;
+    multi_vpaned->focused_pane = NULL;
+  }else if(multi_vpaned->focused_pane == multi_vpaned->first_pane &&
+          multi_vpaned->focused_pane != multi_vpaned->last_pane){
+    next = (GtkPaned*)multi_vpaned->first_pane->child1;
+    g_object_ref(G_OBJECT(next));
+    gtk_container_remove(GTK_CONTAINER(multi_vpaned->first_pane),(GtkWidget*)next);
+    gtk_container_remove(GTK_CONTAINER(multi_vpaned->vbox),(GtkWidget*)multi_vpaned->first_pane);
+    multi_vpaned->first_pane = next;
+    gtk_box_pack_end(GTK_BOX(multi_vpaned->vbox),(GtkWidget*)multi_vpaned->first_pane,TRUE,TRUE,0);
+    multi_vpaned->focused_pane = multi_vpaned->first_pane;
+    g_object_unref(G_OBJECT(next));
+  }else if(multi_vpaned->focused_pane != multi_vpaned->first_pane &&
+          multi_vpaned->focused_pane == multi_vpaned->last_pane){
+    tmp = multi_vpaned->last_pane;
+    multi_vpaned->last_pane = (GtkPaned*)gtk_widget_get_parent((GtkWidget*)multi_vpaned->last_pane);
+    multi_vpaned->focused_pane = multi_vpaned->last_pane;
+    gtk_container_remove(GTK_CONTAINER(multi_vpaned->last_pane),(GtkWidget*)tmp);
+  }else{
+    tmp = multi_vpaned->focused_pane;
+    prev = (GtkPaned*)gtk_widget_get_parent((GtkWidget*)tmp);
+    next = (GtkPaned*)tmp->child1;
+    g_object_ref(G_OBJECT(next));
+    gtk_container_remove(GTK_CONTAINER(multi_vpaned->focused_pane),(GtkWidget*)next);
+    gtk_container_remove(GTK_CONTAINER(prev),(GtkWidget*)multi_vpaned->focused_pane);
+    gtk_paned_pack1(prev, (GtkWidget*)next, FALSE, TRUE);
+    multi_vpaned->focused_pane = next;
+    g_object_unref(G_OBJECT(next));
+  }
+
+  multi_vpaned->num_children--;
+}
+
+
+void gtk_multi_vpaned_widget_move_up(GtkMultiVPaned * multi_vpaned)
+{
+  GtkWidget* upWidget, *downWidget;
+  GtkPaned * prev,*next, *prevPrev;
+
+  if(multi_vpaned->last_pane == multi_vpaned->focused_pane) return;
+
+  // move VPane
+  prev = (GtkPaned*)multi_vpaned->focused_pane->child1;
+  g_object_ref(G_OBJECT(prev));
+  gtk_container_remove(GTK_CONTAINER(multi_vpaned->focused_pane),(GtkWidget*)prev);
+
+  if(prev == multi_vpaned->last_pane){
+    prevPrev = NULL;
+    multi_vpaned->last_pane = multi_vpaned->focused_pane;
+  }else{    
+    prevPrev = (GtkPaned*)prev->child1;
+    g_object_ref(G_OBJECT(prevPrev));
+    gtk_container_remove(GTK_CONTAINER(prev),(GtkWidget*)prevPrev);   
+  }
+
+  g_object_ref(G_OBJECT(multi_vpaned->focused_pane));
+  if(multi_vpaned->first_pane == multi_vpaned->focused_pane){
+    gtk_container_remove(GTK_CONTAINER(multi_vpaned->vbox),(GtkWidget*)multi_vpaned->focused_pane);
+    gtk_box_pack_end(GTK_BOX(multi_vpaned->vbox),(GtkWidget*)prev,TRUE,TRUE,0);
+    multi_vpaned->first_pane = prev;
+  }else{
+    next = (GtkPaned*)gtk_widget_get_parent((GtkWidget*)multi_vpaned->focused_pane);
+    gtk_container_remove(GTK_CONTAINER(next),(GtkWidget*)multi_vpaned->focused_pane);
+    gtk_paned_pack1(GTK_PANED(next), (GtkWidget*)prev, FALSE,TRUE);
+  }
+  gtk_paned_pack1(GTK_PANED(prev),(GtkWidget*)multi_vpaned->focused_pane, FALSE,TRUE);
+  if(prevPrev)
+    gtk_paned_pack1(GTK_PANED(multi_vpaned->focused_pane),(GtkWidget*)prevPrev, FALSE,TRUE);
+
+  g_object_unref(G_OBJECT(prev));
+  if(prevPrev) g_object_unref(G_OBJECT(prevPrev));
+  g_object_unref(G_OBJECT(multi_vpaned->focused_pane));
+}
+
+
+void gtk_multi_vpaned_widget_move_down(GtkMultiVPaned * multi_vpaned)
+{
+  GtkWidget* upWidget, *downWidget;
+  GtkPaned * prev,*next, *nextNext;
+
+  if(multi_vpaned->first_pane == multi_vpaned->focused_pane) return;
+
+  //move VPane
+  next = (GtkPaned*)gtk_widget_get_parent((GtkWidget*)multi_vpaned->focused_pane);
+  g_object_ref(G_OBJECT(next));
+
+  if(multi_vpaned->last_pane == multi_vpaned->focused_pane){
+    prev = NULL;
+    multi_vpaned->last_pane = next;
+  }else{
+    prev = (GtkPaned*)multi_vpaned->focused_pane->child1;
+    g_object_ref(G_OBJECT(prev));
+    gtk_container_remove(GTK_CONTAINER(multi_vpaned->focused_pane),(GtkWidget*)prev);    
+  }
+
+  g_object_ref(G_OBJECT(multi_vpaned->focused_pane));
+  gtk_container_remove(GTK_CONTAINER(next),(GtkWidget*)multi_vpaned->focused_pane);
+  
+  if(next == multi_vpaned->first_pane){
+    multi_vpaned->first_pane = multi_vpaned->focused_pane;
+    gtk_container_remove(GTK_CONTAINER(multi_vpaned->vbox),(GtkWidget*)next);       
+    gtk_box_pack_end(GTK_BOX(multi_vpaned->vbox),(GtkWidget*)multi_vpaned->focused_pane,TRUE,TRUE,0);
+  }else{    
+    nextNext = (GtkPaned*)gtk_widget_get_parent((GtkWidget*)next);
+    gtk_container_remove(GTK_CONTAINER(nextNext),(GtkWidget*)next);       
+    gtk_paned_pack1(nextNext, (GtkWidget*)multi_vpaned->focused_pane, FALSE, TRUE);
+  }
+  gtk_paned_pack1(multi_vpaned->focused_pane,(GtkWidget*)next, FALSE,TRUE);
+  if(prev)
+    gtk_paned_pack1(next,(GtkWidget*)prev, FALSE,TRUE);
+
+  if(prev)g_object_unref(G_OBJECT(prev));
+  g_object_unref(G_OBJECT(next));
+  g_object_unref(G_OBJECT(multi_vpaned->focused_pane));
+}
+
+void gtk_multi_vpaned_set_scroll_value(GtkMultiVPaned * multi_vpaned, double value)
+{
+  gtk_adjustment_set_value(multi_vpaned->hadjust, value);
+  g_signal_stop_emission_by_name(G_OBJECT(multi_vpaned->hscrollbar), "value-changed");  
+}
+
+void gtk_multi_vpaned_scroll_value_changed(GtkRange *range, gpointer multi_vpaned_arg)
+{
+  TimeWindow time_window;
+  TimeInterval *time_span;
+  LttTime time;
+  GtkMultiVPaned * multi_vpaned = (GtkMultiVPaned*)multi_vpaned_arg;
+  gdouble value = gtk_range_get_value(range);
+  gdouble upper, lower, ratio;
+
+  time_window = multi_vpaned->mw->current_tab->time_window;
+
+  time_span = LTTV_TRACESET_CONTEXT(multi_vpaned->mw->current_tab->traceset_info->
+                                   traceset_context)->Time_Span ;
+  lower = multi_vpaned->hadjust->lower;
+  upper = multi_vpaned->hadjust->upper;
+  ratio = (value - lower) / (upper - lower);
+  
+  time = ltt_time_sub(time_span->endTime, time_span->startTime);
+  time = ltt_time_mul(time, (float)ratio);
+  time = ltt_time_add(time_span->startTime, time);
+
+  time_window.start_time = time;
+
+  time = ltt_time_sub(time_span->endTime, time);
+  if(ltt_time_compare(time,time_window.time_width) < 0){
+    time_window.time_width = time;
+  }
+  set_time_window(multi_vpaned->mw, &time_window); 
+}
+
+
+static void
+gtk_multi_vpaned_size_request (GtkWidget      *widget,
+                        GtkRequisition *requisition)
+{
+  GtkPaned *paned = GTK_PANED (widget);
+  GtkRequisition child_requisition;
+
+  requisition->width = 0;
+  requisition->height = 0;
+
+  if (paned->child1 && GTK_WIDGET_VISIBLE (paned->child1))
+    {
+      gtk_widget_size_request (paned->child1, &child_requisition);
+
+      requisition->height = child_requisition.height;
+      requisition->width = child_requisition.width;
+    }
+
+  if (paned->child2 && GTK_WIDGET_VISIBLE (paned->child2))
+    {
+      gtk_widget_size_request (paned->child2, &child_requisition);
+
+      requisition->width = MAX (requisition->width, child_requisition.width);
+      requisition->height += child_requisition.height;
+    }
+
+  requisition->height += GTK_CONTAINER (paned)->border_width * 2;
+  requisition->width += GTK_CONTAINER (paned)->border_width * 2;
+  
+  if (paned->child1 && GTK_WIDGET_VISIBLE (paned->child1) &&
+      paned->child2 && GTK_WIDGET_VISIBLE (paned->child2))
+    {
+      gint handle_size;
+
+      gtk_widget_style_get (widget, "handle_size", &handle_size, NULL);
+      requisition->height += handle_size;
+    }
+
+}
+
+static void
+gtk_multi_vpaned_size_allocate (GtkWidget     *widget,
+                         GtkAllocation *allocation)
+{
+  GtkPaned *paned = GTK_PANED (widget);
+  gint border_width = GTK_CONTAINER (paned)->border_width;
+
+  widget->allocation = *allocation;
+
+  if (paned->child1 && GTK_WIDGET_VISIBLE (paned->child1) &&
+      paned->child2 && GTK_WIDGET_VISIBLE (paned->child2))
+    {
+      GtkRequisition child1_requisition;
+      GtkRequisition child2_requisition;
+      GtkAllocation child1_allocation;
+      GtkAllocation child2_allocation;
+      gint handle_size;
+      
+      gtk_widget_style_get (widget, "handle_size", &handle_size, NULL);
+
+      gtk_widget_get_child_requisition (paned->child1, &child1_requisition);
+      gtk_widget_get_child_requisition (paned->child2, &child2_requisition);
+    
+      gtk_paned_compute_position (paned,
+                                 MAX (1, widget->allocation.height
+                                      - handle_size
+                                      - 2 * border_width),
+                                 child1_requisition.height,
+                                 child2_requisition.height);
+
+      paned->handle_pos.x = widget->allocation.x + border_width;
+      paned->handle_pos.y = widget->allocation.y + paned->child1_size + border_width;
+      paned->handle_pos.width = MAX (1, (gint) widget->allocation.width - 2 * border_width);
+      paned->handle_pos.height = handle_size;
+      
+      if (GTK_WIDGET_REALIZED (widget))
+       {
+         if (GTK_WIDGET_MAPPED (widget))
+           gdk_window_show (paned->handle);
+         gdk_window_move_resize (paned->handle,
+                                 paned->handle_pos.x,
+                                 paned->handle_pos.y,
+                                 paned->handle_pos.width,
+                                 handle_size);
+       }
+
+      child1_allocation.width = child2_allocation.width = MAX (1, (gint) allocation->width - border_width * 2);
+      child1_allocation.height = MAX (1, paned->child1_size);
+      child1_allocation.x = child2_allocation.x = widget->allocation.x + border_width;
+      child1_allocation.y = widget->allocation.y + border_width;
+      
+      child2_allocation.y = child1_allocation.y + paned->child1_size + paned->handle_pos.height;
+      child2_allocation.height = MAX (1, widget->allocation.y + widget->allocation.height - child2_allocation.y - border_width);
+      
+      if (GTK_WIDGET_MAPPED (widget) &&
+         paned->child1->allocation.height < child1_allocation.height)
+       {
+         gtk_widget_size_allocate (paned->child2, &child2_allocation);
+         gtk_widget_size_allocate (paned->child1, &child1_allocation);
+       }
+      else
+       {
+         gtk_widget_size_allocate (paned->child1, &child1_allocation);
+         gtk_widget_size_allocate (paned->child2, &child2_allocation);
+       }
+    }
+  else
+    {
+      GtkAllocation child_allocation;
+
+      if (GTK_WIDGET_REALIZED (widget))      
+       gdk_window_hide (paned->handle);
+
+      if (paned->child1)
+       gtk_widget_set_child_visible (paned->child1, TRUE);
+      if (paned->child2)
+       gtk_widget_set_child_visible (paned->child2, TRUE);
+
+      child_allocation.x = widget->allocation.x + border_width;
+      child_allocation.y = widget->allocation.y + border_width;
+      child_allocation.width = MAX (1, allocation->width - 2 * border_width);
+      child_allocation.height = MAX (1, allocation->height - 2 * border_width);
+      
+      if (paned->child1 && GTK_WIDGET_VISIBLE (paned->child1))
+       gtk_widget_size_allocate (paned->child1, &child_allocation);
+      else if (paned->child2 && GTK_WIDGET_VISIBLE (paned->child2))
+       gtk_widget_size_allocate (paned->child2, &child_allocation);
+    }
+}
+
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/gtkmultivpaned.h b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/gtkmultivpaned.h
new file mode 100644 (file)
index 0000000..316ec4d
--- /dev/null
@@ -0,0 +1,92 @@
+
+/* This file is part of the Linux Trace Toolkit viewer
+ * Copyright (C) 2003-2004 Xiangxiu 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.
+ */
+
+#ifndef __GTK_MULTI_VPANED_H__
+#define __GTK_MULTI_VPANED_H__
+
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gdk/gdk.h>
+#include <gtk/gtkcontainer.h>
+#include <lttvwindow/common.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+#define GTK_TYPE_MULTI_VPANED            (gtk_multi_vpaned_get_type ())
+#define GTK_MULTI_VPANED(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_MULTI_VPANED, GtkMultiVPaned))
+#define GTK_MULTI_VPANED_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_MULTI_VPANED, GtkMultiVPanedClass))
+#define GTK_IS_MULTI_VPANED(obj   )      (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_MULTI_VPANED))
+#define GTK_IS_MULTI_VPANED_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_MULTI_VPANED))
+#define GTK_MULTI_VPANED_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_MULTI_VPANED, GtkMultiVPanedClass))
+
+
+typedef struct _GtkMultiVPaned  GtkMultiVPaned;
+typedef struct _GtkMultiVPanedClass   GtkMultiVPanedClass;
+
+struct _GtkMultiVPaned
+{
+  GtkPaned container;
+
+  /*< public >*/
+  GtkPaned * first_pane;
+  GtkPaned * last_pane;
+  GtkPaned * focused_pane;
+  GtkPaned * iter;
+  guint num_children;
+
+  GtkWidget * vbox;
+  //  GtkWidget * scrollWindow;
+  //  GtkWidget * viewport;
+  GtkWidget * hscrollbar;  
+  GtkAdjustment *hadjust;
+  MainWindow * mw;
+};
+
+struct _GtkMultiVPanedClass
+{
+  GtkPanedClass parent_class;
+};
+
+
+GType     gtk_multi_vpaned_get_type (void) G_GNUC_CONST;
+GtkWidget* gtk_multi_vpaned_new (void);
+
+void gtk_multi_vpaned_set_focus (GtkWidget * widget, gpointer user_data);     
+void gtk_multi_vpaned_widget_add(GtkMultiVPaned * multi_vpaned, GtkWidget * widget1);
+void gtk_multi_vpaned_widget_delete(GtkMultiVPaned * multi_vpaned);
+void gtk_multi_vpaned_widget_move_up(GtkMultiVPaned * multi_vpaned);
+void gtk_multi_vpaned_widget_move_down(GtkMultiVPaned * multi_vpaned);
+void gtk_multi_vpaned_set_adjust(GtkMultiVPaned * multi_vpaned, gboolean first_time);
+void gtk_multi_vpaned_set_data(GtkMultiVPaned * multi_vpaned, char * key, gpointer value);
+gpointer gtk_multi_vpaned_get_data(GtkMultiVPaned * multi_vpaned, char * key);
+GtkWidget * gtk_multi_vpaned_get_widget(GtkMultiVPaned * multi_vpaned);
+GtkWidget * gtk_multi_vpaned_get_first_widget(GtkMultiVPaned * multi_vpaned);
+GtkWidget * gtk_multi_vpaned_get_next_widget(GtkMultiVPaned * multi_vpaned);
+void gtk_multi_vpaned_set_scroll_value(GtkMultiVPaned * multi_vpaned, double value);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __GTK_MULTI_VPANED_H__ */
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/gtktraceset.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/gtktraceset.c
new file mode 100644 (file)
index 0000000..9d0fc7f
--- /dev/null
@@ -0,0 +1,807 @@
+/* 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.
+ */
+
+/*! \file gtktraceset.h
+ * \brief API used by the graphical viewers to interact with their top window.
+ * 
+ * Main window (gui module) is the place to contain and display viewers. 
+ * Viewers (lttv plugins) interacte with main window through this API and
+ * events sent by gtk.
+ * This header file should be included in each graphic module.
+ * This library is used by graphical modules to interact with the
+ * tracesetWindow.
+ * 
+ */
+
+#include <lttvwindow/common.h>
+#include <ltt/ltt.h>
+#include <lttv/lttv.h>
+#include <lttvwindow/mainwindow.h>   
+#include <lttvwindow/gtktraceset.h>
+#include <lttv/tracecontext.h>
+#include <lttvwindow/toolbar.h>
+#include <lttvwindow/menu.h>
+#include <lttv/state.h>
+#include <lttv/stats.h>
+
+
+/**
+ * Internal function parts
+ */
+
+/**
+ * Function to set/update traceset for the viewers
+ * @param main_win main window 
+ * @param traceset traceset of the main window.
+ */
+
+void SetTraceset(MainWindow * main_win, gpointer traceset)
+{
+  LttvHooks * tmp;
+  LttvAttributeValue value;
+
+  g_assert(lttv_iattribute_find_by_path(main_win->attributes,
+     "hooks/updatetraceset", LTTV_POINTER, &value));
+  tmp = (LttvHooks*)*(value.v_pointer);
+  if(tmp == NULL)return;
+  lttv_hooks_call(tmp,traceset);
+}
+
+
+/**
+ * Function to set/update filter for the viewers
+ * @param main_win main window 
+ * @param filter filter of the main window.
+ */
+
+void SetFilter(MainWindow * main_win, gpointer filter)
+{
+  LttvHooks * tmp;
+  LttvAttributeValue value;
+
+  g_assert(lttv_iattribute_find_by_path(main_win->attributes,
+     "hooks/updatefilter", LTTV_POINTER, &value));
+  tmp = (LttvHooks*)*(value.v_pointer);
+
+  if(tmp == NULL)return;
+  lttv_hooks_call(tmp,filter);
+}
+
+
+
+/**
+ * API parts
+ */
+
+/**
+ * Function to register a view constructor so that main window can generate
+ * a toolbar item for the viewer in order to generate a new instance easily. 
+ * It will be called by init function of the module.
+ * @param ButtonPixmap image shown on the toolbar item.
+ * @param tooltip tooltip of the toolbar item.
+ * @param view_constructor constructor of the viewer. 
+ */
+
+void toolbar_item_reg(char ** pixmap, char *tooltip, lttv_constructor view_constructor)
+{
+  LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes());
+  LttvToolbars * toolbar;
+  LttvAttributeValue value;
+
+  g_assert(lttv_iattribute_find_by_path(attributes_global,
+     "viewers/toolbar", LTTV_POINTER, &value));
+  toolbar = (LttvToolbars*)*(value.v_pointer);
+
+  if(toolbar == NULL){    
+    toolbar = lttv_toolbars_new();
+    *(value.v_pointer) = toolbar;
+  }
+  lttv_toolbars_add(toolbar, view_constructor, tooltip, pixmap);
+}
+
+
+/**
+ * Function to unregister the viewer's constructor, release the space 
+ * occupied by pixmap, tooltip and constructor of the viewer.
+ * It will be called when a module is unloaded.
+ * @param view_constructor constructor of the viewer which is used as 
+ * a reference to find out where the pixmap and tooltip are.
+ */
+
+void toolbar_item_unreg(lttv_constructor view_constructor)
+{
+  LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes());
+  LttvToolbars * toolbar;
+  LttvAttributeValue value;
+
+  g_assert(lttv_iattribute_find_by_path(attributes_global,
+     "viewers/toolbar", LTTV_POINTER, &value));
+  toolbar = (LttvToolbars*)*(value.v_pointer);
+  
+  main_window_remove_toolbar_item(view_constructor);
+
+  lttv_toolbars_remove(toolbar, view_constructor);
+}
+
+
+/**
+ * Function to register a view constructor so that main window can generate
+ * a menu item for the viewer in order to generate a new instance easily.
+ * It will be called by init function of the module.
+ * @param menu_path path of the menu item.
+ * @param menu_text text of the menu item.
+ * @param view_constructor constructor of the viewer. 
+ */
+
+void menu_item_reg(char *menu_path, char *menu_text, lttv_constructor view_constructor)
+{
+  LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes());
+  LttvMenus * menu;
+  LttvAttributeValue value;
+
+  g_assert(lttv_iattribute_find_by_path(attributes_global,
+     "viewers/menu", LTTV_POINTER, &value));
+  menu = (LttvMenus*)*(value.v_pointer);
+  
+  if(menu == NULL){    
+    menu = lttv_menus_new();
+    *(value.v_pointer) = menu;
+  }
+  lttv_menus_add(menu, view_constructor, menu_path, menu_text);
+}
+
+/**
+ * Function to unregister the viewer's constructor, release the space 
+ * occupied by menu_path, menu_text and constructor of the viewer.
+ * It will be called when a module is unloaded.
+ * @param view_constructor constructor of the viewer which is used as 
+ * a reference to find out where the menu_path and menu_text are.
+ */
+
+void menu_item_unreg(lttv_constructor view_constructor)
+{
+  LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes());
+  LttvMenus * menu;
+  LttvAttributeValue value;
+
+  g_assert(lttv_iattribute_find_by_path(attributes_global,
+                              "viewers/menu", LTTV_POINTER, &value));
+  menu = (LttvMenus*)*(value.v_pointer);
+
+  main_window_remove_menu_item(view_constructor);
+
+  lttv_menus_remove(menu, view_constructor);
+}
+
+
+/**
+ * Update the status bar whenever something changed in the viewer.
+ * @param main_win the main window the viewer belongs to.
+ * @param info the message which will be shown in the status bar.
+ */
+
+void update_status(MainWindow *main_win, char *info)
+{
+}
+
+
+/**
+ * Function to get the current time interval shown on the current tab.
+ * It will be called by a viewer's hook function to update the 
+ * shown time interval of the viewer and also be called by the constructor
+ * of the viewer.
+ * @param main_win the main window the viewer belongs to.
+ * @param time_interval a pointer where time interval will be stored.
+ */
+
+void get_time_window(MainWindow *main_win, TimeWindow *time_window)
+{
+  //time_window->start_time = main_win->current_tab->time_window.start_time;
+  //time_window->time_width = main_win->current_tab->time_window.time_width;
+  *time_window = main_win->current_tab->time_window;
+}
+
+/**
+ * Function to get the current time interval of the current traceset.
+ * It will be called by a viewer's hook function to update the 
+ * time interval of the viewer and also be called by the constructor
+ * of the viewer.
+ * @param main_win the main window the viewer belongs to.
+ * @param time_interval a pointer where time interval will be stored.
+ */
+
+void get_traceset_time_span(MainWindow *main_win, TimeInterval *time_interval)
+{
+  //time_window->start_time = main_win->current_tab->time_window.start_time;
+  //time_window->time_width = main_win->current_tab->time_window.time_width;
+  *time_interval = *(LTTV_TRACESET_CONTEXT(main_win->current_tab->traceset_info->
+             traceset_context)->Time_Span);
+}
+
+
+
+/**
+ * Function to set the time interval of the current tab.
+ * It will be called by a viewer's signal handle associated with 
+ * the move_slider signal
+ * @param main_win the main window the viewer belongs to.
+ * @param time_interval a pointer where time interval is stored.
+ */
+
+void set_time_window(MainWindow *main_win, TimeWindow *time_window)
+{
+  LttvAttributeValue value;
+  LttvHooks * tmp;
+  main_win->current_tab->time_window = *time_window;
+  gtk_multi_vpaned_set_scroll_value(main_win->current_tab->multi_vpaned,
+            ltt_time_to_double(time_window->start_time)
+            * NANOSECONDS_PER_SECOND );
+  g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
+           "hooks/updatetimewindow", LTTV_POINTER, &value));
+  tmp = (LttvHooks*)*(value.v_pointer);
+  if(tmp == NULL) return;
+  lttv_hooks_call(tmp, time_window);
+}
+
+
+/**
+ * Function to get the current time/event of the current tab.
+ * It will be called by a viewer's hook function to update the 
+ * current time/event of the viewer.
+ * @param main_win the main window the viewer belongs to.
+ * @param time a pointer where time will be stored.
+ */
+
+void get_current_time(MainWindow *main_win, LttTime *time)
+{
+  time = &main_win->current_tab->current_time;
+}
+
+
+/**
+ * Function to set the current time/event of the current tab.
+ * It will be called by a viewer's signal handle associated with 
+ * the button-release-event signal
+ * @param main_win the main window the viewer belongs to.
+ * @param time a pointer where time is stored.
+ */
+
+void set_current_time(MainWindow *main_win, LttTime *time)
+{
+  LttvAttributeValue value;
+  LttvHooks * tmp;
+  main_win->current_tab->current_time = *time;
+  g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
+           "hooks/updatecurrenttime", LTTV_POINTER, &value));
+  tmp = (LttvHooks*)*(value.v_pointer);
+
+  if(tmp == NULL)return;
+  lttv_hooks_call(tmp, time);
+}
+
+
+/**
+ * Function to get the traceset from the current tab.
+ * It will be called by the constructor of the viewer and also be
+ * called by a hook funtion of the viewer to update its traceset.
+ * @param main_win the main window the viewer belongs to.
+ * @param traceset a pointer to a traceset.
+ */
+/*
+void get_traceset(MainWindow *main_win, Traceset *traceset)
+{
+}
+*/
+
+/**
+ * Function to get the filter of the current tab.
+ * It will be called by the constructor of the viewer and also be
+ * called by a hook funtion of the viewer to update its filter.
+ * @param main_win, the main window the viewer belongs to.
+ * @param filter, a pointer to a filter.
+ */
+/*
+void get_filter(MainWindow *main_win, Filter *filter)
+{
+}
+*/
+
+/**
+ * Function to register a hook function for a viewer to set/update its
+ * time interval.
+ * It will be called by the constructor of the viewer.
+ * @param hook hook function of the viewer.
+ * @param hook_data hook data associated with the hook function.
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void reg_update_time_window(LttvHook hook, gpointer hook_data,
+         MainWindow * main_win)
+{
+  LttvAttributeValue value;
+  LttvHooks * tmp;
+  g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
+           "hooks/updatetimewindow", LTTV_POINTER, &value));
+  tmp = (LttvHooks*)*(value.v_pointer);
+  if(tmp == NULL){    
+    tmp = lttv_hooks_new();
+    *(value.v_pointer) = tmp;
+  }
+  lttv_hooks_add(tmp, hook,hook_data);
+}
+
+
+/**
+ * Function to unregister a viewer's hook function which is used to 
+ * set/update the time interval of the viewer.
+ * It will be called by the destructor of the viewer.
+ * @param hook hook function of the viewer.
+ * @param hook_data hook data associated with the hook function.
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void unreg_update_time_window(LttvHook hook, gpointer hook_data,
+           MainWindow * main_win)
+{
+  LttvAttributeValue value;
+  LttvHooks * tmp;
+  g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
+           "hooks/updatetimewindow", LTTV_POINTER, &value));
+  tmp = (LttvHooks*)*(value.v_pointer);
+  if(tmp == NULL) return;
+  lttv_hooks_remove_data(tmp, hook, hook_data);
+}
+
+
+/**
+ * Function to register a hook function for a viewer to set/update its 
+ * traceset.
+ * It will be called by the constructor of the viewer.
+ * @param hook hook function of the viewer.
+ * @param hook_data hook data associated with the hook function.
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void reg_update_traceset(LttvHook hook, gpointer hook_data,
+           MainWindow * main_win)
+{
+  LttvAttributeValue value;
+  LttvHooks * tmp;
+  g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
+           "hooks/updatetraceset", LTTV_POINTER, &value));
+  tmp = (LttvHooks*)*(value.v_pointer);
+  if(tmp == NULL){    
+    tmp = lttv_hooks_new();
+    *(value.v_pointer) = tmp;
+  }
+  lttv_hooks_add(tmp, hook, hook_data);
+}
+
+
+/**
+ * Function to unregister a viewer's hook function which is used to 
+ * set/update the traceset of the viewer.
+ * It will be called by the destructor of the viewer.
+ * @param hook hook function of the viewer.
+ * @param hook_data hook data associated with the hook function.
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void unreg_update_traceset(LttvHook hook, gpointer hook_data,
+       MainWindow * main_win)
+{
+  LttvAttributeValue value;
+  LttvHooks * tmp;
+  g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
+           "hooks/updatetraceset", LTTV_POINTER, &value));
+  tmp = (LttvHooks*)*(value.v_pointer);
+  if(tmp == NULL) return;
+  lttv_hooks_remove_data(tmp, hook, hook_data);
+}
+
+
+/**
+ * Function to redraw each viewer belonging to the current tab 
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void update_traceset(MainWindow * main_win)
+{
+  LttvAttributeValue value;
+  LttvHooks * tmp;
+  g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
+           "hooks/updatetraceset", LTTV_POINTER, &value));
+  tmp = (LttvHooks*)*(value.v_pointer);
+  if(tmp == NULL) return;
+  lttv_hooks_call(tmp, NULL);
+}
+
+
+/**
+ * Function to register a hook function for a viewer to set/update its 
+ * filter.
+ * It will be called by the constructor of the viewer.
+ * @param hook hook function of the viewer.
+ * @param hook_data hook data associated with the hook function.
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void reg_update_filter(LttvHook hook, gpointer hook_data,
+         MainWindow *main_win)
+{
+  LttvAttributeValue value;
+  LttvHooks * tmp;
+  g_assert(lttv_iattribute_find_by_path(main_win->attributes,
+           "hooks/updatefilter", LTTV_POINTER, &value));
+  tmp = (LttvHooks*)*(value.v_pointer);
+  if(tmp == NULL){    
+    tmp = lttv_hooks_new();
+    *(value.v_pointer) = tmp;
+  }
+  lttv_hooks_add(tmp, hook, hook_data);
+}
+
+
+/**
+ * Function to unregister a viewer's hook function which is used to 
+ * set/update the filter of the viewer.
+ * It will be called by the destructor of the viewer.
+ * @param hook hook function of the viewer.
+ * @param hook_data hook data associated with the hook function.
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void unreg_update_filter(LttvHook hook, gpointer hook_data,
+           MainWindow * main_win)
+{
+  LttvAttributeValue value;
+  LttvHooks * tmp;
+  g_assert(lttv_iattribute_find_by_path(main_win->attributes,
+           "hooks/updatefilter", LTTV_POINTER, &value));
+  tmp = (LttvHooks*)*(value.v_pointer);
+  if(tmp == NULL) return;
+  lttv_hooks_remove_data(tmp, hook, hook_data);
+}
+
+
+/**
+ * Function to register a hook function for a viewer to set/update its 
+ * current time.
+ * It will be called by the constructor of the viewer.
+ * @param hook hook function of the viewer.
+ * @param hook_data hook data associated with the hook function.
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void reg_update_current_time(LttvHook hook, gpointer hook_data, 
+        MainWindow *main_win)
+{
+  LttvAttributeValue value;
+  LttvHooks * tmp;
+  g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
+           "hooks/updatecurrenttime", LTTV_POINTER, &value));
+  tmp = (LttvHooks*)*(value.v_pointer);
+  if(tmp == NULL){    
+    tmp = lttv_hooks_new();
+    *(value.v_pointer) = tmp;
+  }
+  lttv_hooks_add(tmp, hook, hook_data);
+}
+
+
+/**
+ * Function to unregister a viewer's hook function which is used to 
+ * set/update the current time of the viewer.
+ * It will be called by the destructor of the viewer.
+ * @param hook hook function of the viewer.
+ * @param hook_data hook data associated with the hook function.
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void unreg_update_current_time(LttvHook hook, gpointer hook_data,
+          MainWindow * main_win)
+{
+  LttvAttributeValue value;
+  LttvHooks * tmp;
+  g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
+           "hooks/updatecurrenttime", LTTV_POINTER, &value));
+  tmp = (LttvHooks*)*(value.v_pointer);
+  if(tmp == NULL) return;
+  lttv_hooks_remove_data(tmp, hook, hook_data);
+}
+
+
+/**
+ * Function to register a hook function for a viewer to show 
+ *the content of the viewer.
+ * It will be called by the constructor of the viewer.
+ * @param hook hook function of the viewer.
+ * @param hook_data hook data associated with the hook function.
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void reg_show_viewer(LttvHook hook, gpointer hook_data, 
+         MainWindow *main_win)
+{
+  LttvAttributeValue value;
+  LttvHooks * tmp;
+  g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
+           "hooks/showviewer", LTTV_POINTER, &value));
+  tmp = (LttvHooks*)*(value.v_pointer);
+  if(tmp == NULL){    
+    tmp = lttv_hooks_new();
+    *(value.v_pointer) = tmp;
+  }
+  lttv_hooks_add(tmp, hook, hook_data);
+}
+
+
+/**
+ * Function to unregister a viewer's hook function which is used to 
+ * show the content of the viewer..
+ * It will be called by the destructor of the viewer.
+ * @param hook hook function of the viewer.
+ * @param hook_data hook data associated with the hook function.
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void unreg_show_viewer(LttvHook hook, gpointer hook_data,
+           MainWindow * main_win)
+{
+  LttvAttributeValue value;
+  LttvHooks * tmp;
+  g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
+           "hooks/showviewer", LTTV_POINTER, &value));
+  tmp = (LttvHooks*)*(value.v_pointer);
+  if(tmp == NULL) return;
+  lttv_hooks_remove_data(tmp, hook, hook_data);
+}
+
+
+/**
+ * Function to show each viewer in the current tab.
+ * It will be called by main window after it called process_traceset 
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void show_viewer(MainWindow *main_win)
+{
+  LttvAttributeValue value;
+  LttvHooks * tmp;
+  g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
+           "hooks/showviewer", LTTV_POINTER, &value));
+  tmp = (LttvHooks*)*(value.v_pointer);
+  if(tmp == NULL) return;
+  lttv_hooks_call(tmp, NULL);
+}
+
+
+/**
+ * Function to set the focused pane (viewer).
+ * It will be called by a viewer's signal handle associated with 
+ * the grab_focus signal
+ * @param main_win the main window the viewer belongs to.
+ * @param paned a pointer to a pane where the viewer is contained.
+ */
+
+void set_focused_pane(MainWindow *main_win, gpointer paned)
+{
+  gtk_multi_vpaned_set_focus((GtkWidget*)main_win->current_tab->multi_vpaned,paned);  
+}
+
+
+/**
+ * Function to register a hook function for a viewer to set/update the 
+ * dividor of the hpane.
+ * It will be called by the constructor of the viewer.
+ * @param hook hook function of the viewer.
+ * @param hook_data hook data associated with the hook function.
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void reg_update_dividor(LttvHook hook, gpointer hook_data, 
+          MainWindow *main_win)
+{
+  LttvAttributeValue value;
+  LttvHooks * tmp;
+  g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
+           "hooks/hpanedividor", LTTV_POINTER, &value));
+  tmp = (LttvHooks*)*(value.v_pointer);
+  if(tmp == NULL){    
+    tmp = lttv_hooks_new();
+    *(value.v_pointer) = tmp;
+  }
+  lttv_hooks_add(tmp, hook, hook_data);
+}
+
+
+/**
+ * Function to unregister a viewer's hook function which is used to 
+ * set/update hpane's dividor of the viewer.
+ * It will be called by the destructor of the viewer.
+ * @param hook hook function of the viewer.
+ * @param hook_data hook data associated with the hook function.
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void unreg_update_dividor(LttvHook hook, gpointer hook_data, 
+      MainWindow *main_win)
+{
+  LttvAttributeValue value;
+  LttvHooks * tmp;
+  g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
+           "hooks/hpanedividor", LTTV_POINTER, &value));
+  tmp = (LttvHooks*)*(value.v_pointer);
+  if(tmp == NULL) return;
+  lttv_hooks_remove_data(tmp, hook, hook_data);
+}
+
+
+/**
+ * Function to set the position of the hpane's dividor (viewer).
+ * It will be called by a viewer's signal handle associated with 
+ * the motion_notify_event event/signal
+ * @param main_win the main window the viewer belongs to.
+ * @param position position of the hpane's dividor.
+ */
+
+void set_hpane_dividor(MainWindow *main_win, gint position)
+{
+  LttvAttributeValue value;
+  LttvHooks * tmp;
+  g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
+           "hooks/hpanedividor", LTTV_POINTER, &value));
+  tmp = (LttvHooks*)*(value.v_pointer);
+  if(tmp == NULL) return;
+  lttv_hooks_call(tmp, &position);
+}
+
+
+/**
+ * Function to process traceset. It will call lttv_process_trace, 
+ * each view will call this api to get events.
+ * @param main_win the main window the viewer belongs to.
+ * @param start the start time of the first event to be processed.
+ * @param end the end time of the last event to be processed.
+ */
+
+void process_traceset_api(MainWindow *main_win, LttTime start, 
+        LttTime end, unsigned maxNumEvents)
+{
+  lttv_process_traceset_seek_time(
+     LTTV_TRACESET_CONTEXT(main_win->current_tab->traceset_info->
+           traceset_context),
+      start);
+  lttv_process_traceset(
+     LTTV_TRACESET_CONTEXT(main_win->current_tab->traceset_info->
+           traceset_context),
+      end,
+      maxNumEvents);
+}
+
+/**
+ * Function to add hooks into the context of a traceset,
+ * before reading events from traceset, viewer will call this api to
+ * register hooks
+ * @param main_win the main window the viewer belongs to.
+ * @param LttvHooks hooks to be registered.
+ */
+
+void context_add_hooks_api(MainWindow *main_win ,
+         LttvHooks *before_traceset, 
+         LttvHooks *after_traceset,
+         LttvHooks *check_trace, 
+         LttvHooks *before_trace, 
+         LttvHooks *after_trace, 
+         LttvHooks *check_tracefile,
+         LttvHooks *before_tracefile,
+         LttvHooks *after_tracefile,
+         LttvHooks *check_event, 
+         LttvHooks *before_event, 
+         LttvHooks *after_event)
+{
+  LttvTracesetContext * tsc = 
+    LTTV_TRACESET_CONTEXT(main_win->current_tab->traceset_info->
+        traceset_context);
+  lttv_traceset_context_add_hooks(tsc,before_traceset,after_traceset,
+          check_trace,before_trace,after_trace,
+          check_tracefile,before_tracefile,after_tracefile,
+          check_event,before_event, after_event);
+}
+
+
+/**
+ * Function to remove hooks from the context of a traceset,
+ * before reading events from traceset, viewer will call this api to
+ * unregister hooks
+ * @param main_win the main window the viewer belongs to.
+ * @param LttvHooks hooks to be registered.
+ */
+
+void context_remove_hooks_api(MainWindow *main_win ,
+            LttvHooks *before_traceset, 
+            LttvHooks *after_traceset,
+            LttvHooks *check_trace, 
+            LttvHooks *before_trace, 
+            LttvHooks *after_trace, 
+            LttvHooks *check_tracefile,
+            LttvHooks *before_tracefile,
+            LttvHooks *after_tracefile,
+            LttvHooks *check_event, 
+            LttvHooks *before_event, 
+            LttvHooks *after_event)
+{
+  LttvTracesetContext * tsc =
+        LTTV_TRACESET_CONTEXT(main_win->current_tab->traceset_info->traceset_context);
+  lttv_traceset_context_remove_hooks(tsc,before_traceset,after_traceset,
+             check_trace,before_trace,after_trace,
+             check_tracefile,before_tracefile,after_tracefile,
+             check_event,before_event, after_event);
+}
+
+
+/**
+ * Function to add/remove event hooks for state 
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void state_add_event_hooks_api(MainWindow *main_win )
+{
+  lttv_state_add_event_hooks(
+       (LttvTracesetState*)main_win->current_tab->traceset_info->traceset_context);
+}
+
+void state_remove_event_hooks_api(MainWindow *main_win )
+{
+  lttv_state_remove_event_hooks(
+       (LttvTracesetState*)main_win->current_tab->traceset_info->traceset_context);
+}
+
+
+/**
+ * Function to add/remove event hooks for stats 
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void stats_add_event_hooks_api(MainWindow *main_win )
+{
+  lttv_stats_add_event_hooks(
+        (LttvTracesetStats*)main_win->current_tab->traceset_info->traceset_context);
+}
+
+void stats_remove_event_hooks_api(MainWindow *main_win )
+{
+  lttv_stats_remove_event_hooks(
+        (LttvTracesetStats*)main_win->current_tab->traceset_info->traceset_context);
+}
+
+/**
+ * Function to get the stats of the traceset 
+ * @param main_win the main window the viewer belongs to.
+ */
+
+LttvTracesetStats* get_traceset_stats_api(MainWindow *main_win)
+{
+  return main_win->current_tab->traceset_info->traceset_context;
+}
+
+
+LttvTracesetContext* get_traceset_context(MainWindow *main_win)
+{
+  return (LttvTracesetContext*)main_win->current_tab->traceset_info->traceset_context;
+}
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/gtktraceset.h b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/gtktraceset.h
new file mode 100644 (file)
index 0000000..e26e718
--- /dev/null
@@ -0,0 +1,476 @@
+/* This file is part of the Linux Trace Toolkit viewer
+ * Copyright (C) 2003-2004 Xiangxiu 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.
+ */
+
+/*
+CHECK Rename to viewer.h
+
+Things that can happen to a viewer:
+
+update_time_window
+update_current_time
+update_traceset
+update_filter
+show_viewer
+update_dividor
+?? Reshape, damage ??
+
+Things that a viewer can do:
+
+update_status
+set_time_window
+set_current_time
+update_traceset?
+update_filter?
+show_viewer?
+set_focused_pane
+set_hpane_dividor
+*/
+
+
+
+
+/*! \file gtktraceset.h
+ * \brief API used by the graphical viewers to interact with their top window.
+ * 
+ * Main window (gui module) is the place to contain and display viewers. 
+ * Viewers (lttv plugins) interacte with main window through this API and
+ * events sent by gtk.
+ * This header file should be included in each graphic module.
+ * This library is used by graphical modules to interact with the
+ * tracesetWindow.
+ * 
+ */
+
+#include <gtk/gtk.h>
+#include <ltt/ltt.h>
+#include <lttv/hook.h>
+#include <lttvwindow/common.h>
+#include <lttv/stats.h>
+
+/**
+ * Function to register a view constructor so that main window can generate
+ * a toolbar item for the viewer in order to generate a new instance easily. 
+ * It will be called by init function of the module.
+ * @param ButtonPixmap image shown on the toolbar item.
+ * @param tooltip tooltip of the toolbar item.
+ * @param view_constructor constructor of the viewer. 
+ */
+
+void toolbar_item_reg(char ** pixmap, char *tooltip, lttv_constructor view_constructor);
+
+
+/**
+ * Function to unregister the viewer's constructor, release the space 
+ * occupied by pixmap, tooltip and constructor of the viewer.
+ * It will be called when a module is unloaded.
+ * @param view_constructor constructor of the viewer which is used as 
+ * a reference to find out where the pixmap and tooltip are.
+ */
+
+void toolbar_item_unreg(lttv_constructor view_constructor);
+
+
+/**
+ * Function to register a view constructor so that main window can generate
+ * a menu item for the viewer in order to generate a new instance easily.
+ * It will be called by init function of the module.
+ * @param menu_path path of the menu item.
+ * @param menu_text text of the menu item.
+ * @param view_constructor constructor of the viewer. 
+ */
+
+void menu_item_reg(char *menu_path, char *menu_text, lttv_constructor view_constructor);
+
+
+/**
+ * Function to unregister the viewer's constructor, release the space 
+ * occupied by menu_path, menu_text and constructor of the viewer.
+ * It will be called when a module is unloaded.
+ * @param view_constructor constructor of the viewer which is used as 
+ * a reference to find out where the menu_path and menu_text are.
+ */
+
+void menu_item_unreg(lttv_constructor view_constructor);
+
+
+/**
+ * Update the status bar whenever something changed in the viewer.
+ * @param main_win the main window the viewer belongs to.
+ * @param info the message which will be shown in the status bar.
+ */
+
+void update_status(MainWindow *main_win, char *info);
+
+
+/**
+ * Function to get the current time window of the current tab.
+ * It will be called by a viewer's hook function to update the 
+ * time window of the viewer and also be called by the constructor
+ * of the viewer.
+ * @param main_win the main window the viewer belongs to.
+ * @param time_interval a pointer where time interval will be stored.
+ */
+
+void get_time_window(MainWindow *main_win, TimeWindow *time_window);
+
+
+/**
+ * Function to set the time interval of the current tab.
+ * It will be called by a viewer's signal handle associated with 
+ * the move_slider signal
+ * @param main_win the main window the viewer belongs to.
+ * @param time_interval a pointer where time interval is stored.
+ */
+
+void set_time_window(MainWindow *main_win, TimeWindow *time_window);
+
+/**
+ * Function to get the current time/event of the current tab.
+ * It will be called by a viewer's hook function to update the 
+ * current time/event of the viewer.
+ * @param main_win the main window the viewer belongs to.
+ * @param time a pointer where time will be stored.
+ */
+
+void get_current_time(MainWindow *main_win, LttTime *time);
+
+
+/**
+ * Function to set the current time/event of the current tab.
+ * It will be called by a viewer's signal handle associated with 
+ * the button-release-event signal
+ * @param main_win the main window the viewer belongs to.
+ * @param time a pointer where time is stored.
+ */
+
+void set_current_time(MainWindow *main_win, LttTime *time);
+
+
+/**
+ * Function to get the traceset from the current tab.
+ * It will be called by the constructor of the viewer and also be
+ * called by a hook funtion of the viewer to update its traceset.
+ * @param main_win the main window the viewer belongs to.
+ * @param traceset a pointer to a traceset.
+ */
+
+//void get_traceset(MainWindow *main_win, Traceset *traceset);
+
+
+/**
+ * Function to get the filter of the current tab.
+ * It will be called by the constructor of the viewer and also be
+ * called by a hook funtion of the viewer to update its filter.
+ * @param main_win, the main window the viewer belongs to.
+ * @param filter, a pointer to a filter.
+ */
+
+//void get_filter(MainWindow *main_win, Filter *filter);
+
+
+/**
+ * Function to register a hook function for a viewer to set/update its
+ * time interval.
+ * It will be called by the constructor of the viewer.
+ * @param hook hook function of the viewer. Takes a TimeInterval* as call_data.
+ * @param hook_data hook data associated with the hook function.
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void reg_update_time_window(LttvHook hook, gpointer hook_data,
+                           MainWindow * main_win);
+
+
+/**
+ * Function to unregister a viewer's hook function which is used to 
+ * set/update the time interval of the viewer.
+ * It will be called by the destructor of the viewer.
+ * @param hook hook function of the viewer. Takes a TimeInterval as call_data.
+ * @param hook_data hook data associated with the hook function.
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void unreg_update_time_window(LttvHook hook, gpointer hook_data,
+                             MainWindow * main_win);
+
+
+/**
+ * Function to register a hook function for a viewer to set/update its 
+ * traceset.
+ * It will be called by the constructor of the viewer.
+ * @param hook hook function of the viewer.
+ * @param hook_data hook data associated with the hook function.
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void reg_update_traceset(LttvHook hook, gpointer hook_data,
+                      MainWindow * main_win);
+
+
+/**
+ * Function to unregister a viewer's hook function which is used to 
+ * set/update the traceset of the viewer.
+ * It will be called by the destructor of the viewer.
+ * @param hook hook function of the viewer.
+ * @param hook_data hook data associated with the hook function.
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void unreg_update_traceset(LttvHook hook, gpointer hook_data,
+                        MainWindow * main_win);
+
+
+/**
+ * Function to redraw each viewer belonging to the current tab 
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void update_traceset(MainWindow * main_win);
+
+
+/**
+ * Function to register a hook function for a viewer to set/update its 
+ * filter.
+ * It will be called by the constructor of the viewer.
+ * @param hook hook function of the viewer.
+ * @param hook_data hook data associated with the hook function.
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void reg_update_filter(LttvHook hook, gpointer hook_data, 
+                    MainWindow *main_win);
+
+
+/**
+ * Function to unregister a viewer's hook function which is used to 
+ * set/update the filter of the viewer.
+ * It will be called by the destructor of the viewer.
+ * @param hook hook function of the viewer.
+ * @param hook_data hook data associated with the hook function.
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void unreg_update_filter(LttvHook hook,  gpointer hook_data,
+                      MainWindow * main_win);
+
+
+/**
+ * Function to register a hook function for a viewer to set/update its 
+ * current time.
+ * It will be called by the constructor of the viewer.
+ * @param hook hook function of the viewer.
+ * @param hook_data hook data associated with the hook function.
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void reg_update_current_time(LttvHook hook, gpointer hook_data, 
+                         MainWindow *main_win);
+
+
+/**
+ * Function to unregister a viewer's hook function which is used to 
+ * set/update the current time of the viewer.
+ * It will be called by the destructor of the viewer.
+ * @param hook hook function of the viewer.
+ * @param hook_data hook data associated with the hook function.
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void unreg_update_current_time(LttvHook hook, gpointer hook_data,
+                           MainWindow * main_win);
+
+
+/**
+ * Function to register a hook function for a viewer to show 
+ *the content of the viewer.
+ * It will be called by the constructor of the viewer.
+ * @param hook hook function of the viewer.
+ * @param hook_data hook data associated with the hook function.
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void reg_show_viewer(LttvHook hook, gpointer hook_data, 
+                    MainWindow *main_win);
+
+
+/**
+ * Function to unregister a viewer's hook function which is used to 
+ * show the content of the viewer..
+ * It will be called by the destructor of the viewer.
+ * @param hook hook function of the viewer.
+ * @param hook_data hook data associated with the hook function.
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void unreg_show_viewer(LttvHook hook, gpointer hook_data,
+                      MainWindow * main_win);
+
+
+/**
+ * Function to show each viewer in the current tab.
+ * It will be called by main window after it called process_traceset 
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void show_viewer(MainWindow *main_win);
+
+
+/**
+ * Function to set the focused pane (viewer).
+ * It will be called by a viewer's signal handle associated with 
+ * the grab_focus signal
+ * @param main_win the main window the viewer belongs to.
+ * @param paned a pointer to a pane where the viewer is contained.
+ */
+
+void set_focused_pane(MainWindow *main_win, gpointer paned);
+
+
+/**
+ * Function to register a hook function for a viewer to set/update the 
+ * dividor of the hpane.
+ * It will be called by the constructor of the viewer.
+ * @param hook hook function of the viewer.
+ * @param hook_data hook data associated with the hook function.
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void reg_update_dividor(LttvHook hook, gpointer hook_data, 
+                     MainWindow *main_win);
+
+
+/**
+ * Function to unregister a viewer's hook function which is used to 
+ * set/update hpane's dividor of the viewer.
+ * It will be called by the destructor of the viewer.
+ * @param hook hook function of the viewer.
+ * @param hook_data hook data associated with the hook function.
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void unreg_update_dividor(LttvHook hook, gpointer hook_data, 
+                       MainWindow *main_win);
+
+
+/**
+ * Function to set the position of the hpane's dividor (viewer).
+ * It will be called by a viewer's signal handle associated with 
+ * the motion_notify_event event/signal
+ * @param main_win the main window the viewer belongs to.
+ * @param position position of the hpane's dividor.
+ */
+
+void set_hpane_dividor(MainWindow *main_win, gint position);
+
+
+/*
+CHECK These functions really should not appear here. Directr calls would
+be OK unless there is a linker problem.
+*/
+/**
+ * Function to process traceset. It will call lttv_process_trace, 
+ * each view will call this api to get events.
+ * @param main_win the main window the viewer belongs to.
+ * @param start the start time of the first event to be processed.
+ * @param end the end time of the last event to be processed.
+ */
+
+void process_traceset_api(MainWindow *main_win, LttTime start, 
+                         LttTime end, unsigned maxNumEvents);
+
+
+/**
+ * Function to add hooks into the context of a traceset,
+ * before reading events from traceset, viewer will call this api to
+ * register hooks
+ * @param main_win the main window the viewer belongs to.
+ * @param LttvHooks hooks to be registered.
+ */
+
+void context_add_hooks_api(MainWindow *main_win ,
+                          LttvHooks *before_traceset, 
+                          LttvHooks *after_traceset,
+                          LttvHooks *check_trace, 
+                          LttvHooks *before_trace, 
+                          LttvHooks *after_trace, 
+                          LttvHooks *check_tracefile,
+                          LttvHooks *before_tracefile,
+                          LttvHooks *after_tracefile,
+                          LttvHooks *check_event, 
+                          LttvHooks *before_event, 
+                          LttvHooks *after_event);
+
+
+/**
+ * Function to remove hooks from the context of a traceset,
+ * before reading events from traceset, viewer will call this api to
+ * unregister hooks
+ * @param main_win the main window the viewer belongs to.
+ * @param LttvHooks hooks to be registered.
+ */
+
+void context_remove_hooks_api(MainWindow *main_win ,
+                             LttvHooks *before_traceset, 
+                             LttvHooks *after_traceset,
+                             LttvHooks *check_trace, 
+                             LttvHooks *before_trace, 
+                             LttvHooks *after_trace, 
+                             LttvHooks *check_tracefile,
+                             LttvHooks *before_tracefile,
+                             LttvHooks *after_tracefile,
+                             LttvHooks *check_event, 
+                             LttvHooks *before_event, 
+                             LttvHooks *after_event);
+
+
+/**
+ * Function to get the life span of the traceset
+ * @param main_win the main window the viewer belongs to.
+ * @param start start time of the traceset.
+ * @param end end time of the traceset.
+ */
+
+void get_traceset_time_span(MainWindow *main_win, TimeInterval *time_span);
+
+
+/**
+ * Function to add/remove event hooks for state 
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void state_add_event_hooks_api(MainWindow *main_win );
+void state_remove_event_hooks_api(MainWindow *main_win );
+
+
+/**
+ * Function to add/remove event hooks for stats 
+ * @param main_win the main window the viewer belongs to.
+ */
+
+void stats_add_event_hooks_api(MainWindow *main_win );
+void stats_remove_event_hooks_api(MainWindow *main_win );
+
+
+/**
+ * Function to get the stats of the traceset 
+ * @param main_win the main window the viewer belongs to.
+ */
+
+LttvTracesetStats* get_traceset_stats_api(MainWindow *main_win);
+
+LttvTracesetContext* get_traceset_context(MainWindow *main_win);
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/init_module.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/init_module.c
new file mode 100644 (file)
index 0000000..a6d63cb
--- /dev/null
@@ -0,0 +1,190 @@
+/* This file is part of the Linux Trace Toolkit viewer
+ * Copyright (C) 2003-2004 Mathieu Desnoyers and 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.
+ */
+
+/*
+ * Initial main.c file generated by Glade. Edit as required.
+ * Glade will not overwrite this file.
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include <gtk/gtk.h>
+
+#include <lttv/lttv.h>
+#include <lttv/attribute.h>
+#include <lttv/hook.h>
+#include <lttv/option.h>
+#include <lttv/module.h>
+#include <lttv/tracecontext.h>
+#include <lttv/state.h>
+#include <lttv/stats.h>
+#include <lttvwindow/menu.h>
+#include <lttvwindow/toolbar.h>
+
+#include "interface.h"
+#include "support.h"
+#include <lttvwindow/mainwindow.h>
+#include "callbacks.h"
+#include <ltt/trace.h>
+
+
+/** Array containing instanced objects. */
+GSList * g_main_window_list = NULL ;
+
+LttvHooks
+  *main_hooks;
+
+/* Initial trace from command line */
+LttvTrace *g_init_trace = NULL;
+
+static char *a_trace;
+
+void lttv_trace_option(void *hook_data)
+{ 
+  LttTrace *trace;
+
+  trace = ltt_trace_open(a_trace);
+  if(trace == NULL) g_critical("cannot open trace %s", a_trace);
+  g_init_trace = lttv_trace_new(trace);
+}
+
+/*****************************************************************************
+ *                 Functions for module loading/unloading                    *
+ *****************************************************************************/
+/**
+ * plugin's init function
+ *
+ * This function initializes the GUI.
+ */
+
+static gboolean window_creation_hook(void *hook_data, void *call_data)
+{
+  g_debug("GUI window_creation_hook()");
+#ifdef ENABLE_NLS
+  bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+  textdomain (GETTEXT_PACKAGE);
+#endif
+
+  gtk_set_locale ();
+  gtk_init (&lttv_argc, &lttv_argv);
+
+  add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps");
+  add_pixmap_directory ("pixmaps");
+  add_pixmap_directory ("../modules/gui/main/pixmaps");
+
+  construct_main_window(NULL);
+
+  gtk_main ();
+
+  return FALSE;
+}
+
+static void init() {
+
+  LttvAttributeValue value;
+  // Global attributes only used for interaction with main() here.
+  LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes());
+  
+  g_debug("GUI init()");
+  
+  lttv_option_add("trace", 't', 
+      "add a trace to the trace set to analyse", 
+      "pathname of the directory containing the trace", 
+      LTTV_OPT_STRING, &a_trace, lttv_trace_option, NULL);
+
+  g_assert(lttv_iattribute_find_by_path(attributes, "hooks/main/before",
+      LTTV_POINTER, &value));
+  g_assert((main_hooks = *(value.v_pointer)) != NULL);
+
+  lttv_hooks_add(main_hooks, window_creation_hook, NULL);
+
+}
+
+void
+main_window_free(MainWindow * mw)
+{ 
+  if(mw){
+    while(mw->tab){
+      lttv_state_remove_event_hooks(
+           (LttvTracesetState*)mw->tab->traceset_info->traceset_context);
+      mw->tab = mw->tab->next;
+    }
+    g_object_unref(mw->attributes);
+    g_main_window_list = g_slist_remove(g_main_window_list, mw);
+
+    g_hash_table_destroy(mw->hash_menu_item);
+    g_hash_table_destroy(mw->hash_toolbar_item);
+    
+    g_free(mw);
+    mw = NULL;
+  }
+}
+
+void
+main_window_destructor(MainWindow * mw)
+{
+  if(GTK_IS_WIDGET(mw->mwindow)){
+    gtk_widget_destroy(mw->mwindow);
+    //    gtk_widget_destroy(mw->HelpContents);
+    //    gtk_widget_destroy(mw->AboutBox);    
+    mw = NULL;
+  }
+  //main_window_free called when the object mw in the widget is unref.
+  //main_window_free(mw);
+}
+
+
+void main_window_destroy_walk(gpointer data, gpointer user_data)
+{
+  main_window_destructor((MainWindow*)data);
+}
+
+
+
+/**
+ * plugin's destroy function
+ *
+ * This function releases the memory reserved by the module and unregisters
+ * everything that has been registered in the gtkTraceSet API.
+ */
+static void destroy() {
+
+  LttvAttributeValue value;  
+  LttvTrace *trace;
+
+  lttv_option_remove("trace");
+
+  lttv_hooks_remove_data(main_hooks, window_creation_hook, NULL);
+
+  g_debug("GUI destroy()");
+
+  if(g_main_window_list){
+    g_slist_foreach(g_main_window_list, main_window_destroy_walk, NULL );
+    g_slist_free(g_main_window_list);
+  }
+  
+}
+
+
+LTTV_MODULE("lttvwindow", "Viewer main window", \
+    "Viewer with multiple windows, tabs and panes for graphical modules", \
+           init, destroy, "stats")
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/interface.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/interface.c
new file mode 100644 (file)
index 0000000..ee08b8e
--- /dev/null
@@ -0,0 +1,856 @@
+/* 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.
+ */
+
+/*
+ * DO NOT EDIT THIS FILE - it is generated by Glade.
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <gdk/gdkkeysyms.h>
+#include <gtk/gtk.h>
+
+#include "callbacks.h"
+#include "interface.h"
+#include "support.h"
+
+#define GLADE_HOOKUP_OBJECT(component,widget,name) \
+  g_object_set_data_full (G_OBJECT (component), name, \
+    gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref)
+
+#define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \
+  g_object_set_data (G_OBJECT (component), name, widget)
+
+GtkWidget*
+create_MWindow (void)
+{
+  GtkWidget *MWindow;
+  GtkWidget *MVbox;
+  GtkWidget *MMenuBox;
+  GtkWidget *MenuMain;
+  GtkWidget *FileMenuTitle;
+  GtkWidget *FileMenuTitle_menu;
+  GtkWidget *FileMenuNewTitle;
+  GtkWidget *FileMenuNewTitle_menu;
+  //  GtkWidget *EmptyTraceset;
+  GtkWidget *CloneTraceset;
+  GtkWidget *FileMenuNewSep;
+  GtkWidget *Tab;
+  //  GtkWidget *OpenTraceset;
+  GtkWidget *Close;
+  GtkWidget *CloseTab;
+  GtkWidget *FileMenuSeparator1;
+  GtkWidget *AddTrace;
+  GtkWidget *RemoveTrace;
+  //  GtkWidget *Save;
+  //  GtkWidget *SaveAs;
+  GtkWidget *FileMenuSeparator2;
+  GtkWidget *Quit;
+  //  GtkWidget *EditMenuTitle;
+  //  GtkWidget *EditMenuTitle_menu;
+  //  GtkWidget *Cut;
+  //  GtkWidget *Copy;
+  //  GtkWidget *Paste;
+  //  GtkWidget *Delete;
+  GtkWidget *ViewMenuTitle;
+  GtkWidget *ViewMenuTitle_menu;
+  GtkWidget *ZoomIn;
+  GtkWidget *ZoomOut;
+  GtkWidget *ZoomExtended;
+  GtkWidget *ViewMenuSeparator;
+  //  GtkWidget *GoToTime;
+  //  GtkWidget *ShowTimeFrame;
+  GtkWidget *ToolMenuTitle;
+  GtkWidget *ToolMenuTitle_menu;
+  GtkWidget *MoveViewerUp;
+  GtkWidget *MoveViewerDown;
+  GtkWidget *RemoveViewer;
+  GtkWidget *ToolMenuSeparator;
+  GtkWidget *Filter;
+  //  GtkWidget *Facility;
+  GtkWidget *ToolMenuSeparator1;
+  //  GtkWidget *insert_viewer_test;
+  GtkWidget *PluginMenuTitle;
+  GtkWidget *PluginMenuTitle_menu;
+  GtkWidget *LoadModule;
+  GtkWidget *UnloadModule;
+  GtkWidget *AddModuleSearchPath;
+  //  GtkWidget *OptionMenuTitle;
+  //  GtkWidget *OptionMenuTitle_menu;
+  //  GtkWidget *Color;
+  //  GtkWidget *OptMenuSeparator;
+  //  GtkWidget *OpenFilter;
+  //  GtkWidget *SaveConfiguration;
+  GtkWidget *MenuHelp;
+  GtkWidget *HelpMenuTitle;
+  GtkWidget *HelpMenu;
+  GtkWidget *Content;
+  GtkWidget *HelpmenuSeparator;
+  GtkWidget *About;
+  GtkWidget *MToolbar1;
+  GtkWidget *tmp_toolbar_icon;
+  GtkWidget *tlbEmptyTraceset;
+  GtkWidget *tlbTab;
+  //  GtkWidget *tlbOpenTraceset;
+  GtkWidget *tlbAddTrace;
+  GtkWidget *tlbRemoveTrace;
+  //  GtkWidget *tlbSave;
+  //  GtkWidget *tlbSaveAs;
+  GtkWidget *tlbZoomIn;
+  GtkWidget *tlbZoomOut;
+  GtkWidget *tlbZoomExtended;
+  //  GtkWidget *tlbGoToTime;
+  //  GtkWidget *tlbShowTimeFrame;
+  GtkWidget *tlbMoveViewerUp;
+  GtkWidget *tlbMoveViewerDown;
+  GtkWidget *tlbRemoveViewer;
+  GtkWidget *MToolbar2;
+  GtkWidget *MNotebook;
+  //  GtkWidget *empty_notebook_page;
+  //  GtkWidget *label1;
+  GtkWidget *MStatusbar;
+  GtkAccelGroup *accel_group;
+
+  accel_group = gtk_accel_group_new ();
+
+  MWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+  gtk_widget_set_size_request (MWindow, 100, 50);
+  gtk_window_set_title (GTK_WINDOW (MWindow), "LTT");
+  gtk_window_set_default_size (GTK_WINDOW (MWindow), 600, 400);
+
+  MVbox = gtk_vbox_new (FALSE, 0);
+  gtk_widget_show (MVbox);
+  gtk_container_add (GTK_CONTAINER (MWindow), MVbox);
+
+  MMenuBox = gtk_hbox_new (FALSE, 0);
+  gtk_widget_show (MMenuBox);
+  gtk_box_pack_start (GTK_BOX (MVbox), MMenuBox, FALSE, FALSE, 0);
+
+  MenuMain = gtk_menu_bar_new ();
+  gtk_widget_show (MenuMain);
+  gtk_box_pack_start (GTK_BOX (MMenuBox), MenuMain, FALSE, FALSE, 0);
+
+  FileMenuTitle = gtk_menu_item_new_with_mnemonic ("_File");
+  gtk_widget_show (FileMenuTitle);
+  gtk_container_add (GTK_CONTAINER (MenuMain), FileMenuTitle);
+
+  FileMenuTitle_menu = gtk_menu_new ();
+  gtk_menu_item_set_submenu (GTK_MENU_ITEM (FileMenuTitle), FileMenuTitle_menu);
+
+  FileMenuNewTitle = gtk_menu_item_new_with_mnemonic ("New");
+  gtk_widget_show (FileMenuNewTitle);
+  gtk_container_add (GTK_CONTAINER (FileMenuTitle_menu), FileMenuNewTitle);
+
+  FileMenuNewTitle_menu = gtk_menu_new ();
+  gtk_menu_item_set_submenu (GTK_MENU_ITEM (FileMenuNewTitle), FileMenuNewTitle_menu);
+
+  //  EmptyTraceset = gtk_menu_item_new_with_mnemonic ("Empty trace set");
+  //  gtk_widget_show (EmptyTraceset);
+  //  gtk_container_add (GTK_CONTAINER (FileMenuNewTitle_menu), EmptyTraceset);
+
+  //  CloneTraceset = gtk_menu_item_new_with_mnemonic ("Clone trace set");
+  CloneTraceset = gtk_menu_item_new_with_mnemonic ("New window");
+  gtk_widget_show (CloneTraceset);
+  gtk_container_add (GTK_CONTAINER (FileMenuNewTitle_menu), CloneTraceset);
+
+  FileMenuNewSep = gtk_menu_item_new ();
+  gtk_widget_show (FileMenuNewSep);
+  gtk_container_add (GTK_CONTAINER (FileMenuNewTitle_menu), FileMenuNewSep);
+  gtk_widget_set_sensitive (FileMenuNewSep, FALSE);
+
+  Tab = gtk_menu_item_new_with_mnemonic ("Tab");
+  gtk_widget_show (Tab);
+  gtk_container_add (GTK_CONTAINER (FileMenuNewTitle_menu), Tab);
+/*
+  OpenTraceset = gtk_menu_item_new_with_mnemonic ("Open");
+  gtk_widget_show (OpenTraceset);
+  gtk_container_add (GTK_CONTAINER (FileMenuTitle_menu), OpenTraceset);
+*/
+  Close = gtk_menu_item_new_with_mnemonic ("Close");
+  gtk_widget_show (Close);
+  gtk_container_add (GTK_CONTAINER (FileMenuTitle_menu), Close);
+
+  CloseTab = gtk_menu_item_new_with_mnemonic ("Close Tab");
+  gtk_widget_show (CloseTab);
+  gtk_container_add (GTK_CONTAINER (FileMenuTitle_menu), CloseTab);
+
+  FileMenuSeparator1 = gtk_menu_item_new ();
+  gtk_widget_show (FileMenuSeparator1);
+  gtk_container_add (GTK_CONTAINER (FileMenuTitle_menu), FileMenuSeparator1);
+  gtk_widget_set_sensitive (FileMenuSeparator1, FALSE);
+
+  AddTrace = gtk_menu_item_new_with_mnemonic ("Add Trace");
+  gtk_widget_show (AddTrace);
+  gtk_container_add (GTK_CONTAINER (FileMenuTitle_menu), AddTrace);
+
+  RemoveTrace = gtk_menu_item_new_with_mnemonic ("Remove Trace");
+  gtk_widget_show (RemoveTrace);
+  gtk_container_add (GTK_CONTAINER (FileMenuTitle_menu), RemoveTrace);
+/*
+  Save = gtk_menu_item_new_with_mnemonic ("Save");
+  gtk_widget_show (Save);
+  gtk_container_add (GTK_CONTAINER (FileMenuTitle_menu), Save);
+
+  SaveAs = gtk_menu_item_new_with_mnemonic ("Save As");
+  gtk_widget_show (SaveAs);
+  gtk_container_add (GTK_CONTAINER (FileMenuTitle_menu), SaveAs);
+*/
+  FileMenuSeparator2 = gtk_menu_item_new ();
+  gtk_widget_show (FileMenuSeparator2);
+  gtk_container_add (GTK_CONTAINER (FileMenuTitle_menu), FileMenuSeparator2);
+  gtk_widget_set_sensitive (FileMenuSeparator2, FALSE);
+
+  Quit = gtk_menu_item_new_with_mnemonic ("Quit");
+  gtk_widget_show (Quit);
+  gtk_container_add (GTK_CONTAINER (FileMenuTitle_menu), Quit);
+/*
+  EditMenuTitle = gtk_menu_item_new_with_mnemonic ("_Edit");
+  gtk_widget_show (EditMenuTitle);
+  gtk_container_add (GTK_CONTAINER (MenuMain), EditMenuTitle);
+
+  EditMenuTitle_menu = gtk_menu_new ();
+  gtk_menu_item_set_submenu (GTK_MENU_ITEM (EditMenuTitle), EditMenuTitle_menu);
+
+  Cut = gtk_image_menu_item_new_from_stock ("gtk-cut", accel_group);
+  gtk_widget_show (Cut);
+  gtk_container_add (GTK_CONTAINER (EditMenuTitle_menu), Cut);
+
+  Copy = gtk_image_menu_item_new_from_stock ("gtk-copy", accel_group);
+  gtk_widget_show (Copy);
+  gtk_container_add (GTK_CONTAINER (EditMenuTitle_menu), Copy);
+
+  Paste = gtk_image_menu_item_new_from_stock ("gtk-paste", accel_group);
+  gtk_widget_show (Paste);
+  gtk_container_add (GTK_CONTAINER (EditMenuTitle_menu), Paste);
+
+  Delete = gtk_image_menu_item_new_from_stock ("gtk-delete", accel_group);
+  gtk_widget_show (Delete);
+  gtk_container_add (GTK_CONTAINER (EditMenuTitle_menu), Delete);
+*/
+  ViewMenuTitle = gtk_menu_item_new_with_mnemonic ("_View");
+  gtk_widget_show (ViewMenuTitle);
+  gtk_container_add (GTK_CONTAINER (MenuMain), ViewMenuTitle);
+
+  ViewMenuTitle_menu = gtk_menu_new ();
+  gtk_menu_item_set_submenu (GTK_MENU_ITEM (ViewMenuTitle), ViewMenuTitle_menu);
+
+  ZoomIn = gtk_menu_item_new_with_mnemonic ("Zoom in");
+  gtk_widget_show (ZoomIn);
+  gtk_container_add (GTK_CONTAINER (ViewMenuTitle_menu), ZoomIn);
+
+  ZoomOut = gtk_menu_item_new_with_mnemonic ("Zoom out");
+  gtk_widget_show (ZoomOut);
+  gtk_container_add (GTK_CONTAINER (ViewMenuTitle_menu), ZoomOut);
+
+  ZoomExtended = gtk_menu_item_new_with_mnemonic ("Zoom extended");
+  gtk_widget_show (ZoomExtended);
+  gtk_container_add (GTK_CONTAINER (ViewMenuTitle_menu), ZoomExtended);
+
+  ViewMenuSeparator = gtk_menu_item_new ();
+  gtk_widget_show (ViewMenuSeparator);
+  gtk_container_add (GTK_CONTAINER (ViewMenuTitle_menu), ViewMenuSeparator);
+  gtk_widget_set_sensitive (ViewMenuSeparator, FALSE);
+/*
+  GoToTime = gtk_menu_item_new_with_mnemonic ("Go to time");
+  gtk_widget_show (GoToTime);
+  gtk_container_add (GTK_CONTAINER (ViewMenuTitle_menu), GoToTime);
+
+  ShowTimeFrame = gtk_menu_item_new_with_mnemonic ("Show time frame");
+  gtk_widget_show (ShowTimeFrame);
+  gtk_container_add (GTK_CONTAINER (ViewMenuTitle_menu), ShowTimeFrame);
+*/
+  ToolMenuTitle = gtk_menu_item_new_with_mnemonic ("Tools");
+  gtk_widget_show (ToolMenuTitle);
+  gtk_container_add (GTK_CONTAINER (MenuMain), ToolMenuTitle);
+
+  ToolMenuTitle_menu = gtk_menu_new ();
+  gtk_menu_item_set_submenu (GTK_MENU_ITEM (ToolMenuTitle), ToolMenuTitle_menu);
+
+  MoveViewerUp = gtk_menu_item_new_with_mnemonic ("Move viewer up");
+  gtk_widget_show (MoveViewerUp);
+  gtk_container_add (GTK_CONTAINER (ToolMenuTitle_menu), MoveViewerUp);
+
+  MoveViewerDown = gtk_menu_item_new_with_mnemonic ("Move viewer down");
+  gtk_widget_show (MoveViewerDown);
+  gtk_container_add (GTK_CONTAINER (ToolMenuTitle_menu), MoveViewerDown);
+
+  RemoveViewer = gtk_menu_item_new_with_mnemonic ("Remove viewer");
+  gtk_widget_show (RemoveViewer);
+  gtk_container_add (GTK_CONTAINER (ToolMenuTitle_menu), RemoveViewer);
+
+  ToolMenuSeparator = gtk_menu_item_new ();
+  gtk_widget_show (ToolMenuSeparator);
+  gtk_container_add (GTK_CONTAINER (ToolMenuTitle_menu), ToolMenuSeparator);
+  gtk_widget_set_sensitive (ToolMenuSeparator, FALSE);
+
+  Filter = gtk_menu_item_new_with_mnemonic ("Trace Filter Selector");
+  gtk_widget_show (Filter);
+  gtk_container_add (GTK_CONTAINER (ToolMenuTitle_menu), Filter);
+
+  //  Facility = gtk_menu_item_new_with_mnemonic ("Facility Selector");
+  //  gtk_widget_show (Facility);
+  //  gtk_container_add (GTK_CONTAINER (ToolMenuTitle_menu), Facility);
+
+  ToolMenuSeparator1 = gtk_menu_item_new ();
+  gtk_widget_show (ToolMenuSeparator1);
+  gtk_container_add (GTK_CONTAINER (ToolMenuTitle_menu), ToolMenuSeparator1);
+  gtk_widget_set_sensitive (ToolMenuSeparator1, FALSE);
+
+  //  insert_viewer_test = gtk_menu_item_new_with_mnemonic ("Insert viewer test");
+  //  gtk_widget_show (insert_viewer_test);
+  //  gtk_container_add (GTK_CONTAINER (ToolMenuTitle_menu), insert_viewer_test);
+
+  PluginMenuTitle = gtk_menu_item_new_with_mnemonic ("Plugins");
+  gtk_widget_show (PluginMenuTitle);
+  gtk_container_add (GTK_CONTAINER (MenuMain), PluginMenuTitle);
+
+  PluginMenuTitle_menu = gtk_menu_new ();
+  gtk_menu_item_set_submenu (GTK_MENU_ITEM (PluginMenuTitle), PluginMenuTitle_menu);
+
+  LoadModule = gtk_menu_item_new_with_mnemonic ("Load module");
+  gtk_widget_show (LoadModule);
+  gtk_container_add (GTK_CONTAINER (PluginMenuTitle_menu), LoadModule);
+
+  UnloadModule = gtk_menu_item_new_with_mnemonic ("Unload module");
+  gtk_widget_show (UnloadModule);
+  gtk_container_add (GTK_CONTAINER (PluginMenuTitle_menu), UnloadModule);
+
+  AddModuleSearchPath = gtk_menu_item_new_with_mnemonic ("Add module search path");
+  gtk_widget_show (AddModuleSearchPath);
+  gtk_container_add (GTK_CONTAINER (PluginMenuTitle_menu), AddModuleSearchPath);
+/*
+  OptionMenuTitle = gtk_menu_item_new_with_mnemonic ("Options");
+  gtk_widget_show (OptionMenuTitle);
+  gtk_container_add (GTK_CONTAINER (MenuMain), OptionMenuTitle);
+
+  OptionMenuTitle_menu = gtk_menu_new ();
+  gtk_menu_item_set_submenu (GTK_MENU_ITEM (OptionMenuTitle), OptionMenuTitle_menu);
+
+  Color = gtk_menu_item_new_with_mnemonic ("Color");
+  gtk_widget_show (Color);
+  gtk_container_add (GTK_CONTAINER (OptionMenuTitle_menu), Color);
+
+  OptMenuSeparator = gtk_menu_item_new ();
+  gtk_widget_show (OptMenuSeparator);
+  gtk_container_add (GTK_CONTAINER (OptionMenuTitle_menu), OptMenuSeparator);
+  gtk_widget_set_sensitive (OptMenuSeparator, FALSE);
+
+  OpenFilter = gtk_menu_item_new_with_mnemonic ("Filter");
+  gtk_widget_show (OpenFilter);
+  gtk_container_add (GTK_CONTAINER (OptionMenuTitle_menu), OpenFilter);
+
+  SaveConfiguration = gtk_menu_item_new_with_mnemonic ("Save configuration");
+  gtk_widget_show (SaveConfiguration);
+  gtk_container_add (GTK_CONTAINER (OptionMenuTitle_menu), SaveConfiguration);
+*/
+  MenuHelp = gtk_menu_bar_new ();
+  gtk_widget_show (MenuHelp);
+  gtk_box_pack_end (GTK_BOX (MMenuBox), MenuHelp, FALSE, FALSE, 0);
+
+  HelpMenuTitle = gtk_menu_item_new_with_mnemonic ("_Help");
+  gtk_widget_show (HelpMenuTitle);
+  gtk_container_add (GTK_CONTAINER (MenuHelp), HelpMenuTitle);
+
+  HelpMenu = gtk_menu_new ();
+  gtk_menu_item_set_submenu (GTK_MENU_ITEM (HelpMenuTitle), HelpMenu);
+
+  Content = gtk_menu_item_new_with_mnemonic ("Content");
+  gtk_widget_show (Content);
+  gtk_container_add (GTK_CONTAINER (HelpMenu), Content);
+
+  HelpmenuSeparator = gtk_menu_item_new ();
+  gtk_widget_show (HelpmenuSeparator);
+  gtk_container_add (GTK_CONTAINER (HelpMenu), HelpmenuSeparator);
+  gtk_widget_set_sensitive (HelpmenuSeparator, FALSE);
+
+  About = gtk_menu_item_new_with_mnemonic ("About...");
+  gtk_widget_show (About);
+  gtk_container_add (GTK_CONTAINER (HelpMenu), About);
+
+  MToolbar1 = gtk_toolbar_new ();
+  gtk_widget_show (MToolbar1);
+  gtk_box_pack_start (GTK_BOX (MVbox), MToolbar1, FALSE, FALSE, 0);
+  gtk_toolbar_set_style (GTK_TOOLBAR (MToolbar1), GTK_TOOLBAR_ICONS);
+
+  tmp_toolbar_icon = create_pixmap (MWindow, "filenew.png");
+  tlbEmptyTraceset = gtk_toolbar_append_element (GTK_TOOLBAR (MToolbar1),
+                                GTK_TOOLBAR_CHILD_BUTTON,
+                                NULL,
+                                "",
+                                "New window", NULL,
+                               //"New window with empty trace set", NULL,
+                                tmp_toolbar_icon, NULL, NULL);
+  gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (MToolbar1)->children)->data))->label), TRUE);
+  gtk_widget_show (tlbEmptyTraceset);
+  gtk_container_set_border_width (GTK_CONTAINER (tlbEmptyTraceset), 1);
+
+  tmp_toolbar_icon = create_pixmap (MWindow, "filenew.png");
+  tlbTab = gtk_toolbar_append_element (GTK_TOOLBAR (MToolbar1),
+                                GTK_TOOLBAR_CHILD_BUTTON,
+                                NULL,
+                                "",
+                                "New tab", NULL,
+                                tmp_toolbar_icon, NULL, NULL);
+  gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (MToolbar1)->children)->data))->label), TRUE);
+  gtk_widget_show (tlbTab);
+  gtk_container_set_border_width (GTK_CONTAINER (tlbTab), 1);
+
+/*
+  tmp_toolbar_icon = create_pixmap (MWindow, "fileopen.png");
+  tlbOpenTraceset = gtk_toolbar_append_element (GTK_TOOLBAR (MToolbar1),
+                                GTK_TOOLBAR_CHILD_BUTTON,
+                                NULL,
+                                "",
+                                "open a trace set", NULL,
+                                tmp_toolbar_icon, NULL, NULL);
+  gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (MToolbar1)->children)->data))->label), TRUE);
+  gtk_widget_show (tlbOpenTraceset);
+  gtk_container_set_border_width (GTK_CONTAINER (tlbOpenTraceset), 1);
+*/
+  tmp_toolbar_icon = create_pixmap (MWindow, "edit_add_22.png");
+  tlbAddTrace = gtk_toolbar_append_element (GTK_TOOLBAR (MToolbar1),
+                                GTK_TOOLBAR_CHILD_BUTTON,
+                                NULL,
+                                "",
+                                "Add a trace ", NULL,
+                                tmp_toolbar_icon, NULL, NULL);
+  gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (MToolbar1)->children)->data))->label), TRUE);
+  gtk_widget_show (tlbAddTrace);
+  gtk_container_set_border_width (GTK_CONTAINER (tlbAddTrace), 1);
+
+  tmp_toolbar_icon = create_pixmap (MWindow, "edit_remove_22.png");
+  tlbRemoveTrace = gtk_toolbar_append_element (GTK_TOOLBAR (MToolbar1),
+                                GTK_TOOLBAR_CHILD_BUTTON,
+                                NULL,
+                                "",
+                                "Remove a trace", NULL,
+                                tmp_toolbar_icon, NULL, NULL);
+  gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (MToolbar1)->children)->data))->label), TRUE);
+  gtk_widget_show (tlbRemoveTrace);
+  gtk_container_set_border_width (GTK_CONTAINER (tlbRemoveTrace), 1);
+/*
+  tmp_toolbar_icon = create_pixmap (MWindow, "filesave.png");
+  tlbSave = gtk_toolbar_append_element (GTK_TOOLBAR (MToolbar1),
+                                GTK_TOOLBAR_CHILD_BUTTON,
+                                NULL,
+                                "",
+                                "save the current trace set", NULL,
+                                tmp_toolbar_icon, NULL, NULL);
+  gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (MToolbar1)->children)->data))->label), TRUE);
+  gtk_widget_show (tlbSave);
+  gtk_container_set_border_width (GTK_CONTAINER (tlbSave), 1);
+
+  tmp_toolbar_icon = create_pixmap (MWindow, "filesaveas.png");
+  tlbSaveAs = gtk_toolbar_append_element (GTK_TOOLBAR (MToolbar1),
+                                GTK_TOOLBAR_CHILD_BUTTON,
+                                NULL,
+                                "",
+                                "save as ", NULL,
+                                tmp_toolbar_icon, NULL, NULL);
+  gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (MToolbar1)->children)->data))->label), TRUE);
+  gtk_widget_show (tlbSaveAs);
+  gtk_container_set_border_width (GTK_CONTAINER (tlbSaveAs), 1);
+*/
+  gtk_toolbar_append_space (GTK_TOOLBAR (MToolbar1));
+
+  tmp_toolbar_icon = create_pixmap (MWindow, "stock_zoom_in_24.png");
+  tlbZoomIn = gtk_toolbar_append_element (GTK_TOOLBAR (MToolbar1),
+                                GTK_TOOLBAR_CHILD_BUTTON,
+                                NULL,
+                                "",
+                                "Zoom in", NULL,
+                                tmp_toolbar_icon, NULL, NULL);
+  gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (MToolbar1)->children)->data))->label), TRUE);
+  gtk_widget_show (tlbZoomIn);
+  gtk_container_set_border_width (GTK_CONTAINER (tlbZoomIn), 1);
+
+  tmp_toolbar_icon = create_pixmap (MWindow, "stock_zoom_out_24.png");
+  tlbZoomOut = gtk_toolbar_append_element (GTK_TOOLBAR (MToolbar1),
+                                GTK_TOOLBAR_CHILD_BUTTON,
+                                NULL,
+                                "",
+                                "Zoom out", NULL,
+                                tmp_toolbar_icon, NULL, NULL);
+  gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (MToolbar1)->children)->data))->label), TRUE);
+  gtk_widget_show (tlbZoomOut);
+  gtk_container_set_border_width (GTK_CONTAINER (tlbZoomOut), 1);
+
+  tmp_toolbar_icon = create_pixmap (MWindow, "stock_zoom_fit_24.png");
+  tlbZoomExtended = gtk_toolbar_append_element (GTK_TOOLBAR (MToolbar1),
+                                GTK_TOOLBAR_CHILD_BUTTON,
+                                NULL,
+                                "",
+                                "Zoom extended", NULL,
+                                tmp_toolbar_icon, NULL, NULL);
+  gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (MToolbar1)->children)->data))->label), TRUE);
+  gtk_widget_show (tlbZoomExtended);
+  gtk_container_set_border_width (GTK_CONTAINER (tlbZoomExtended), 1);
+/*
+  tmp_toolbar_icon = create_pixmap (MWindow, "gtk-jump-to.png");
+  tlbGoToTime = gtk_toolbar_append_element (GTK_TOOLBAR (MToolbar1),
+                                GTK_TOOLBAR_CHILD_BUTTON,
+                                NULL,
+                                "",
+                                "Go to time", NULL,
+                                tmp_toolbar_icon, NULL, NULL);
+  gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (MToolbar1)->children)->data))->label), TRUE);
+  gtk_widget_show (tlbGoToTime);
+  gtk_container_set_border_width (GTK_CONTAINER (tlbGoToTime), 1);
+
+  tmp_toolbar_icon = create_pixmap (MWindow, "mini-display.xpm");
+  tlbShowTimeFrame = gtk_toolbar_append_element (GTK_TOOLBAR (MToolbar1),
+                                GTK_TOOLBAR_CHILD_BUTTON,
+                                NULL,
+                                "",
+                                "Show time frame", NULL,
+                                tmp_toolbar_icon, NULL, NULL);
+  gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (MToolbar1)->children)->data))->label), TRUE);
+  gtk_widget_show (tlbShowTimeFrame);
+  gtk_container_set_border_width (GTK_CONTAINER (tlbShowTimeFrame), 1);
+*/
+  gtk_toolbar_append_space (GTK_TOOLBAR (MToolbar1));
+
+  tmp_toolbar_icon = create_pixmap (MWindow, "1uparrow.png");
+  tlbMoveViewerUp = gtk_toolbar_append_element (GTK_TOOLBAR (MToolbar1),
+                                GTK_TOOLBAR_CHILD_BUTTON,
+                                NULL,
+                                "",
+                                "Move up current viewer", NULL,
+                                tmp_toolbar_icon, NULL, NULL);
+  gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (MToolbar1)->children)->data))->label), TRUE);
+  gtk_widget_show (tlbMoveViewerUp);
+  gtk_container_set_border_width (GTK_CONTAINER (tlbMoveViewerUp), 1);
+
+  tmp_toolbar_icon = create_pixmap (MWindow, "1downarrow.png");
+  tlbMoveViewerDown = gtk_toolbar_append_element (GTK_TOOLBAR (MToolbar1),
+                                GTK_TOOLBAR_CHILD_BUTTON,
+                                NULL,
+                                "",
+                                "Move down current viewer", NULL,
+                                tmp_toolbar_icon, NULL, NULL);
+  gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (MToolbar1)->children)->data))->label), TRUE);
+  gtk_widget_show (tlbMoveViewerDown);
+  gtk_container_set_border_width (GTK_CONTAINER (tlbMoveViewerDown), 1);
+
+  tmp_toolbar_icon = create_pixmap (MWindow, "remove.png");
+  tlbRemoveViewer = gtk_toolbar_append_element (GTK_TOOLBAR (MToolbar1),
+                                GTK_TOOLBAR_CHILD_BUTTON,
+                                NULL,
+                                "",
+                                "Delete current viewer", NULL,
+                                tmp_toolbar_icon, NULL, NULL);
+  gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (MToolbar1)->children)->data))->label), TRUE);
+  gtk_widget_show (tlbRemoveViewer);
+  gtk_container_set_border_width (GTK_CONTAINER (tlbRemoveViewer), 1);
+
+  gtk_toolbar_append_space (GTK_TOOLBAR (MToolbar1));
+
+  //  MToolbar2 = gtk_toolbar_new ();
+  //  gtk_widget_show (MToolbar2);
+  //  gtk_box_pack_start (GTK_BOX (MVbox), MToolbar2, FALSE, FALSE, 0);
+  //  gtk_toolbar_set_style (GTK_TOOLBAR (MToolbar2), GTK_TOOLBAR_ICONS);
+
+  MNotebook = gtk_notebook_new ();
+  gtk_widget_show (MNotebook);
+  gtk_notebook_set_show_tabs((GtkNotebook*)MNotebook, FALSE);
+  gtk_box_pack_start (GTK_BOX (MVbox), MNotebook, TRUE, TRUE, 0);
+/*
+  empty_notebook_page = gtk_vbox_new (FALSE, 0);
+  gtk_widget_show (empty_notebook_page);
+  gtk_container_add (GTK_CONTAINER (MNotebook), empty_notebook_page);
+
+  label1 = gtk_label_new ("");
+  gtk_widget_show (label1);
+  gtk_notebook_set_tab_label (GTK_NOTEBOOK (MNotebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (MNotebook), 0), label1);
+  gtk_label_set_justify (GTK_LABEL (label1), GTK_JUSTIFY_LEFT);
+*/
+  MStatusbar = gtk_statusbar_new ();
+  gtk_widget_show (MStatusbar);
+  gtk_box_pack_start (GTK_BOX (MVbox), MStatusbar, FALSE, FALSE, 0);
+
+  g_signal_connect ((gpointer) MWindow, "destroy",
+                    G_CALLBACK (on_MWindow_destroy),
+                    NULL);
+  g_signal_connect ((gpointer) MWindow, "configure-event",
+                    G_CALLBACK (on_MWindow_configure),
+                    NULL);
+  //  g_signal_connect ((gpointer) EmptyTraceset, "activate",
+  //                    G_CALLBACK (on_empty_traceset_activate),
+  //                    NULL);
+  g_signal_connect ((gpointer) CloneTraceset, "activate",
+                    G_CALLBACK (on_clone_traceset_activate),
+                    NULL);
+  g_signal_connect ((gpointer) Tab, "activate",
+                    G_CALLBACK (on_tab_activate),
+                    NULL);
+/*
+  g_signal_connect ((gpointer) OpenTraceset, "activate",
+                    G_CALLBACK (on_open_activate),
+                    NULL);
+*/
+  g_signal_connect ((gpointer) Close, "activate",
+                    G_CALLBACK (on_close_activate),
+                    NULL);
+  g_signal_connect ((gpointer) CloseTab, "activate",
+                    G_CALLBACK (on_close_tab_activate),
+                    NULL);
+  g_signal_connect ((gpointer) AddTrace, "activate",
+                    G_CALLBACK (on_add_trace_activate),
+                    NULL);
+  g_signal_connect ((gpointer) RemoveTrace, "activate",
+                    G_CALLBACK (on_remove_trace_activate),
+                    NULL);
+/*
+  g_signal_connect ((gpointer) Save, "activate",
+                    G_CALLBACK (on_save_activate),
+                    NULL);
+  g_signal_connect ((gpointer) SaveAs, "activate",
+                    G_CALLBACK (on_save_as_activate),
+                    NULL);
+*/
+  g_signal_connect ((gpointer) Quit, "activate",
+                    G_CALLBACK (on_quit_activate),
+                    NULL);
+/*
+  g_signal_connect ((gpointer) Cut, "activate",
+                    G_CALLBACK (on_cut_activate),
+                    NULL);
+  g_signal_connect ((gpointer) Copy, "activate",
+                    G_CALLBACK (on_copy_activate),
+                    NULL);
+  g_signal_connect ((gpointer) Paste, "activate",
+                    G_CALLBACK (on_paste_activate),
+                    NULL);
+  g_signal_connect ((gpointer) Delete, "activate",
+                    G_CALLBACK (on_delete_activate),
+                    NULL);
+*/
+  g_signal_connect ((gpointer) ZoomIn, "activate",
+                    G_CALLBACK (on_zoom_in_activate),
+                    NULL);
+  g_signal_connect ((gpointer) ZoomOut, "activate",
+                    G_CALLBACK (on_zoom_out_activate),
+                    NULL);
+  g_signal_connect ((gpointer) ZoomExtended, "activate",
+                    G_CALLBACK (on_zoom_extended_activate),
+                    NULL);
+/*
+  g_signal_connect ((gpointer) GoToTime, "activate",
+                   G_CALLBACK (on_go_to_time_activate),
+                   NULL);
+  g_signal_connect ((gpointer) ShowTimeFrame, "activate",
+                    G_CALLBACK (on_show_time_frame_activate),
+                    NULL);
+*/
+  g_signal_connect ((gpointer) MoveViewerUp, "activate",
+                    G_CALLBACK (on_move_viewer_up_activate),
+                    NULL);
+  g_signal_connect ((gpointer) MoveViewerDown, "activate",
+                    G_CALLBACK (on_move_viewer_down_activate),
+                    NULL);
+  g_signal_connect ((gpointer) RemoveViewer, "activate",
+                    G_CALLBACK (on_remove_viewer_activate),
+                    NULL);
+  g_signal_connect ((gpointer) Filter, "activate",
+                    G_CALLBACK (on_trace_filter_activate),
+                    NULL);
+  //  g_signal_connect ((gpointer) Facility, "activate",
+  //                    G_CALLBACK (on_trace_facility_activate),
+  //                    NULL);
+  //  g_signal_connect ((gpointer) insert_viewer_test, "activate",
+  //                    G_CALLBACK (on_insert_viewer_test_activate),
+  //                    NULL);
+  g_signal_connect ((gpointer) LoadModule, "activate",
+                    G_CALLBACK (on_load_module_activate),
+                    NULL);
+  g_signal_connect ((gpointer) UnloadModule, "activate",
+                    G_CALLBACK (on_unload_module_activate),
+                    NULL);
+  g_signal_connect ((gpointer) AddModuleSearchPath, "activate",
+                    G_CALLBACK (on_add_module_search_path_activate),
+                    NULL);
+/*
+  g_signal_connect ((gpointer) Color, "activate",
+                    G_CALLBACK (on_color_activate),
+                    NULL);
+  g_signal_connect ((gpointer) OpenFilter, "activate",
+                    G_CALLBACK (on_filter_activate),
+                    NULL);
+  g_signal_connect ((gpointer) SaveConfiguration, "activate",
+                    G_CALLBACK (on_save_configuration_activate),
+                    NULL);
+*/
+  g_signal_connect ((gpointer) Content, "activate",
+                    G_CALLBACK (on_content_activate),
+                    NULL);
+  g_signal_connect ((gpointer) About, "activate",
+                    G_CALLBACK (on_about_activate),
+                    NULL);
+  g_signal_connect ((gpointer) tlbEmptyTraceset, "clicked",
+                    G_CALLBACK (on_button_new_clicked),
+                    NULL);
+  g_signal_connect ((gpointer) tlbTab, "clicked",
+                    G_CALLBACK (on_button_new_tab_clicked),
+                    NULL);
+/*
+  g_signal_connect ((gpointer) tlbOpenTraceset, "clicked",
+                    G_CALLBACK (on_button_open_clicked),
+                    NULL);
+*/
+  g_signal_connect ((gpointer) tlbAddTrace, "clicked",
+                    G_CALLBACK (on_button_add_trace_clicked),
+                    NULL);
+  g_signal_connect ((gpointer) tlbRemoveTrace, "clicked",
+                    G_CALLBACK (on_button_remove_trace_clicked),
+                    NULL);
+/*
+  g_signal_connect ((gpointer) tlbSave, "clicked",
+                    G_CALLBACK (on_button_save_clicked),
+                    NULL);
+  g_signal_connect ((gpointer) tlbSaveAs, "clicked",
+                    G_CALLBACK (on_button_save_as_clicked),
+                    NULL);
+*/
+  g_signal_connect ((gpointer) tlbZoomIn, "clicked",
+                    G_CALLBACK (on_button_zoom_in_clicked),
+                    NULL);
+  g_signal_connect ((gpointer) tlbZoomOut, "clicked",
+                    G_CALLBACK (on_button_zoom_out_clicked),
+                    NULL);
+  g_signal_connect ((gpointer) tlbZoomExtended, "clicked",
+                    G_CALLBACK (on_button_zoom_extended_clicked),
+                    NULL);
+/*
+  g_signal_connect ((gpointer) tlbGoToTime, "clicked",
+                    G_CALLBACK (on_button_go_to_time_clicked),
+                    NULL);
+  g_signal_connect ((gpointer) tlbShowTimeFrame, "clicked",
+                    G_CALLBACK (on_button_show_time_frame_clicked),
+                    NULL);
+*/
+  g_signal_connect ((gpointer) tlbMoveViewerUp, "clicked",
+                    G_CALLBACK (on_button_move_up_clicked),
+                    NULL);
+  g_signal_connect ((gpointer) tlbMoveViewerDown, "clicked",
+                    G_CALLBACK (on_button_move_down_clicked),
+                    NULL);
+  g_signal_connect ((gpointer) tlbRemoveViewer, "clicked",
+                    G_CALLBACK (on_button_delete_viewer_clicked),
+                    NULL);
+  g_signal_connect ((gpointer) MNotebook, "switch_page",
+                    G_CALLBACK (on_MNotebook_switch_page),
+                    NULL);
+
+  /* Store pointers to all widgets, for use by lookup_widget(). */
+  GLADE_HOOKUP_OBJECT_NO_REF (MWindow, MWindow, "MWindow");
+  GLADE_HOOKUP_OBJECT (MWindow, MVbox, "MVbox");
+  GLADE_HOOKUP_OBJECT (MWindow, MMenuBox, "MMenuBox");
+  GLADE_HOOKUP_OBJECT (MWindow, MenuMain, "MenuMain");
+  GLADE_HOOKUP_OBJECT (MWindow, FileMenuTitle, "FileMenuTitle");
+  GLADE_HOOKUP_OBJECT (MWindow, FileMenuTitle_menu, "FileMenuTitle_menu");
+  GLADE_HOOKUP_OBJECT (MWindow, FileMenuNewTitle, "FileMenuNewTitle");
+  GLADE_HOOKUP_OBJECT (MWindow, FileMenuNewTitle_menu, "FileMenuNewTitle_menu");
+  //  GLADE_HOOKUP_OBJECT (MWindow, EmptyTraceset, "EmptyTraceset");
+  GLADE_HOOKUP_OBJECT (MWindow, CloneTraceset, "CloneTraceset");
+  GLADE_HOOKUP_OBJECT (MWindow, FileMenuNewSep, "FileMenuNewSep");
+  GLADE_HOOKUP_OBJECT (MWindow, Tab, "Tab");
+  //  GLADE_HOOKUP_OBJECT (MWindow, OpenTraceset, "OpenTraceset");
+  GLADE_HOOKUP_OBJECT (MWindow, Close, "Close");
+  GLADE_HOOKUP_OBJECT (MWindow, CloseTab, "CloseTab");
+  GLADE_HOOKUP_OBJECT (MWindow, FileMenuSeparator1, "FileMenuSeparator1");
+  GLADE_HOOKUP_OBJECT (MWindow, AddTrace, "AddTrace");
+  GLADE_HOOKUP_OBJECT (MWindow, RemoveTrace, "RemoveTrace");
+  //  GLADE_HOOKUP_OBJECT (MWindow, Save, "Save");
+  //  GLADE_HOOKUP_OBJECT (MWindow, SaveAs, "SaveAs");
+  GLADE_HOOKUP_OBJECT (MWindow, FileMenuSeparator2, "FileMenuSeparator2");
+  GLADE_HOOKUP_OBJECT (MWindow, Quit, "Quit");
+  //  GLADE_HOOKUP_OBJECT (MWindow, EditMenuTitle, "EditMenuTitle");
+  //  GLADE_HOOKUP_OBJECT (MWindow, EditMenuTitle_menu, "EditMenuTitle_menu");
+  //  GLADE_HOOKUP_OBJECT (MWindow, Cut, "Cut");
+  //  GLADE_HOOKUP_OBJECT (MWindow, Copy, "Copy");
+  //  GLADE_HOOKUP_OBJECT (MWindow, Paste, "Paste");
+  //  GLADE_HOOKUP_OBJECT (MWindow, Delete, "Delete");
+  GLADE_HOOKUP_OBJECT (MWindow, ViewMenuTitle, "ViewMenuTitle");
+  GLADE_HOOKUP_OBJECT (MWindow, ViewMenuTitle_menu, "ViewMenuTitle_menu");
+  GLADE_HOOKUP_OBJECT (MWindow, ZoomIn, "ZoomIn");
+  GLADE_HOOKUP_OBJECT (MWindow, ZoomOut, "ZoomOut");
+  GLADE_HOOKUP_OBJECT (MWindow, ZoomExtended, "ZoomExtended");
+  GLADE_HOOKUP_OBJECT (MWindow, ViewMenuSeparator, "ViewMenuSeparator");
+  //  GLADE_HOOKUP_OBJECT (MWindow, GoToTime, "GoToTime");
+  //  GLADE_HOOKUP_OBJECT (MWindow, ShowTimeFrame, "ShowTimeFrame");
+  GLADE_HOOKUP_OBJECT (MWindow, ToolMenuTitle, "ToolMenuTitle");
+  GLADE_HOOKUP_OBJECT (MWindow, ToolMenuTitle_menu, "ToolMenuTitle_menu");
+  GLADE_HOOKUP_OBJECT (MWindow, MoveViewerUp, "MoveViewerUp");
+  GLADE_HOOKUP_OBJECT (MWindow, MoveViewerDown, "MoveViewerDown");
+  GLADE_HOOKUP_OBJECT (MWindow, RemoveViewer, "RemoveViewer");
+  GLADE_HOOKUP_OBJECT (MWindow, ToolMenuSeparator, "ToolMenuSeparator");
+  GLADE_HOOKUP_OBJECT (MWindow, Filter, "Filter");
+  //  GLADE_HOOKUP_OBJECT (MWindow, Facility, "Facility");
+  GLADE_HOOKUP_OBJECT (MWindow, ToolMenuSeparator1, "ToolMenuSeparator1");
+  //  GLADE_HOOKUP_OBJECT (MWindow, insert_viewer_test, "insert_viewer_test");
+  GLADE_HOOKUP_OBJECT (MWindow, PluginMenuTitle, "PluginMenuTitle");
+  GLADE_HOOKUP_OBJECT (MWindow, PluginMenuTitle_menu, "PluginMenuTitle_menu");
+  GLADE_HOOKUP_OBJECT (MWindow, LoadModule, "LoadModule");
+  GLADE_HOOKUP_OBJECT (MWindow, UnloadModule, "UnloadModule");
+  GLADE_HOOKUP_OBJECT (MWindow, AddModuleSearchPath, "AddModuleSearchPath");
+  //  GLADE_HOOKUP_OBJECT (MWindow, OptionMenuTitle, "OptionMenuTitle");
+  //  GLADE_HOOKUP_OBJECT (MWindow, OptionMenuTitle_menu, "OptionMenuTitle_menu");
+  //  GLADE_HOOKUP_OBJECT (MWindow, Color, "Color");
+  //  GLADE_HOOKUP_OBJECT (MWindow, OptMenuSeparator, "OptMenuSeparator");
+  //  GLADE_HOOKUP_OBJECT (MWindow, OpenFilter, "OpenFilter");
+  //  GLADE_HOOKUP_OBJECT (MWindow, SaveConfiguration, "SaveConfiguration");
+  GLADE_HOOKUP_OBJECT (MWindow, MenuHelp, "MenuHelp");
+  GLADE_HOOKUP_OBJECT (MWindow, HelpMenuTitle, "HelpMenuTitle");
+  GLADE_HOOKUP_OBJECT (MWindow, HelpMenu, "HelpMenu");
+  GLADE_HOOKUP_OBJECT (MWindow, Content, "Content");
+  GLADE_HOOKUP_OBJECT (MWindow, HelpmenuSeparator, "HelpmenuSeparator");
+  GLADE_HOOKUP_OBJECT (MWindow, About, "About");
+  GLADE_HOOKUP_OBJECT (MWindow, MToolbar1, "MToolbar1");
+  GLADE_HOOKUP_OBJECT (MWindow, tlbEmptyTraceset, "tlbEmptyTraceset");
+  GLADE_HOOKUP_OBJECT (MWindow, tlbTab, "tlbTab");
+  //  GLADE_HOOKUP_OBJECT (MWindow, tlbOpenTraceset, "tlbOpenTraceset");
+  GLADE_HOOKUP_OBJECT (MWindow, tlbAddTrace, "tlbAddTrace");
+  GLADE_HOOKUP_OBJECT (MWindow, tlbRemoveTrace, "tlbRemoveTrace");
+  //  GLADE_HOOKUP_OBJECT (MWindow, tlbSave, "tlbSave");
+  //  GLADE_HOOKUP_OBJECT (MWindow, tlbSaveAs, "tlbSaveAs");
+  GLADE_HOOKUP_OBJECT (MWindow, tlbZoomIn, "tlbZoomIn");
+  GLADE_HOOKUP_OBJECT (MWindow, tlbZoomOut, "tlbZoomOut");
+  GLADE_HOOKUP_OBJECT (MWindow, tlbZoomExtended, "tlbZoomExtended");
+  //  GLADE_HOOKUP_OBJECT (MWindow, tlbGoToTime, "tlbGoToTime");
+  // GLADE_HOOKUP_OBJECT (MWindow, tlbShowTimeFrame, "tlbShowTimeFrame");
+  GLADE_HOOKUP_OBJECT (MWindow, tlbMoveViewerUp, "tlbMoveViewerUp");
+  GLADE_HOOKUP_OBJECT (MWindow, tlbMoveViewerDown, "tlbMoveViewerDown");
+  GLADE_HOOKUP_OBJECT (MWindow, tlbRemoveViewer, "tlbRemoveViewer");
+  //  GLADE_HOOKUP_OBJECT (MWindow, MToolbar2, "MToolbar2");
+  GLADE_HOOKUP_OBJECT (MWindow, MNotebook, "MNotebook");
+  //  GLADE_HOOKUP_OBJECT (MWindow, label1, "label1");
+  GLADE_HOOKUP_OBJECT (MWindow, MStatusbar, "MStatusbar");
+
+  gtk_window_add_accel_group (GTK_WINDOW (MWindow), accel_group);
+
+  return MWindow;
+}
+
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/interface.h b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/interface.h
new file mode 100644 (file)
index 0000000..05d8846
--- /dev/null
@@ -0,0 +1,23 @@
+/* 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.
+ */
+
+/*
+ * DO NOT EDIT THIS FILE - it is generated by Glade.
+ */
+
+GtkWidget* create_MWindow (void);
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvfilter.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvfilter.c
new file mode 100644 (file)
index 0000000..2ab00de
--- /dev/null
@@ -0,0 +1,312 @@
+/* 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.
+ */
+
+
+#include <lttvwindow/lttvfilter.h>
+#include <stdio.h>
+#include <ltt/trace.h>
+#include <ltt/type.h>
+
+struct _LttvTracesetSelector {
+  char      * traceset_name;
+  GPtrArray * traces;
+};
+
+
+struct _LttvTraceSelector {
+  char      * trace_name;
+  GPtrArray * tracefiles;
+  GPtrArray * eventtypes;
+  gboolean    selected;
+};
+
+struct _LttvTracefileSelector {
+  char      * tracefile_name;
+  GPtrArray * eventtypes;
+  gboolean    selected;
+};
+
+struct _LttvEventtypeSelector {
+  char      * eventtype_name;
+  gboolean    selected;
+};
+
+
+LttvTracesetSelector *lttv_traceset_selector_new(char * name) 
+{
+  LttvTracesetSelector *s;
+
+  s = g_new(LttvTracesetSelector, 1);
+  if(name)
+    s->traceset_name = g_strdup(name);
+  else
+    s->traceset_name = NULL;    
+  s->traces = g_ptr_array_new();
+  return s;
+}
+
+LttvTraceSelector *lttv_trace_selector_new(LttTrace *t) 
+{
+  LttvTraceSelector * trace;
+
+  trace = g_new(LttvTraceSelector, 1);
+  trace->trace_name = g_strdup(ltt_trace_name(t));
+  trace->tracefiles = g_ptr_array_new();
+  trace->eventtypes = g_ptr_array_new();
+  trace->selected = TRUE;
+  return trace;
+}
+
+LttvTracefileSelector *lttv_tracefile_selector_new(LttTracefile *t) 
+{
+  LttvTracefileSelector * tracefile;
+
+  tracefile = g_new(LttvTracefileSelector, 1);
+  tracefile->tracefile_name = g_strdup(ltt_tracefile_name(t));
+  tracefile->eventtypes = g_ptr_array_new();
+  tracefile->selected = TRUE;
+  return tracefile;
+}
+
+LttvEventtypeSelector *lttv_eventtype_selector_new(LttEventType * et)
+{
+  LttvEventtypeSelector * ev;
+  ev = g_new(LttvEventtypeSelector, 1);
+  ev->eventtype_name = g_strdup(ltt_eventtype_name(et));
+  ev->selected = TRUE;
+  return ev;
+}
+
+void lttv_traceset_selector_destroy(LttvTracesetSelector *s) 
+{
+  int i;
+  LttvTraceSelector * t;
+
+  for(i=0;i<s->traces->len;i++){
+    t = (LttvTraceSelector*)s->traces->pdata[i];
+    lttv_trace_selector_destroy(t);
+  }
+  g_ptr_array_free(s->traces, TRUE);
+  if(s->traceset_name) g_free(s->traceset_name);
+  g_free(s);
+}
+
+void lttv_trace_selector_destroy(LttvTraceSelector *s) 
+{
+  int i;
+  LttvTracefileSelector * t;
+  LttvEventtypeSelector * e;
+
+  for(i=0;i<s->tracefiles->len;i++){
+    t = (LttvTracefileSelector*)s->tracefiles->pdata[i];
+    lttv_tracefile_selector_destroy(t);
+  }
+  for(i=0;i<s->eventtypes->len;i++){
+    e = (LttvEventtypeSelector*)s->eventtypes->pdata[i];
+    lttv_eventtype_selector_destroy(e);
+  }
+  if(s->trace_name) g_free(s->trace_name);
+  g_free(s);
+}
+
+void lttv_tracefile_selector_destroy(LttvTracefileSelector *t) 
+{
+  int i;
+  LttvEventtypeSelector * e;
+
+  for(i=0;i<t->eventtypes->len;i++){
+    e = (LttvEventtypeSelector*)t->eventtypes->pdata[i];
+    lttv_eventtype_selector_destroy(e);
+  }
+
+  if(t->tracefile_name) g_free(t->tracefile_name);
+  g_free(t);
+}
+
+void lttv_eventtype_selector_destroy(LttvEventtypeSelector *e)
+{
+  if(e->eventtype_name) g_free(e->eventtype_name);
+  free(e);
+}
+
+void lttv_traceset_selector_trace_add(LttvTracesetSelector *s, 
+                                     LttvTraceSelector *t) 
+{
+  g_ptr_array_add(s->traces, t);
+}
+
+void lttv_trace_selector_tracefile_add(LttvTraceSelector *s, 
+                                      LttvTracefileSelector *t) 
+{
+  g_ptr_array_add(s->tracefiles, t);
+}
+
+void lttv_trace_selector_eventtype_add(LttvTraceSelector *s, 
+                                      LttvEventtypeSelector *et)
+{  
+  g_ptr_array_add(s->eventtypes, et);
+}
+
+void lttv_tracefile_selector_eventtype_add(LttvTracefileSelector *s, 
+                                          LttvEventtypeSelector *et)
+{
+  g_ptr_array_add(s->eventtypes, et);
+}
+
+unsigned lttv_traceset_selector_trace_number(LttvTracesetSelector *s) 
+{
+  return s->traces->len;
+}
+
+unsigned lttv_trace_selector_tracefile_number(LttvTraceSelector *s) 
+{
+  return s->tracefiles->len;
+}
+
+unsigned lttv_trace_selector_eventtype_number(LttvTraceSelector *s)
+{
+  return s->eventtypes->len;
+}
+
+unsigned lttv_tracefile_selector_eventtype_number(LttvTracefileSelector *s)
+{
+  return s->eventtypes->len;
+}
+
+LttvTraceSelector *lttv_traceset_selector_trace_get(LttvTracesetSelector *s,
+                                                   unsigned i) 
+{
+  g_assert(s->traces->len > i);
+  return ((LttvTraceSelector *)s->traces->pdata[i]);
+}
+
+LttvTracefileSelector *lttv_trace_selector_tracefile_get(LttvTraceSelector *s,
+                                                        unsigned i) 
+{
+  g_assert(s->tracefiles->len > i);
+  return ((LttvTracefileSelector *)s->tracefiles->pdata[i]);
+}
+
+LttvEventtypeSelector *lttv_trace_selector_eventtype_get(LttvTraceSelector *s,
+                                                        unsigned i)
+{
+  g_assert(s->eventtypes->len > i);
+  return ((LttvEventtypeSelector *)s->eventtypes->pdata[i]);
+}
+
+LttvEventtypeSelector *lttv_tracefile_selector_eventtype_get(LttvTracefileSelector *s,
+                                                            unsigned i)
+{
+  g_assert(s->eventtypes->len > i);
+  return ((LttvEventtypeSelector *)s->eventtypes->pdata[i]);
+}
+
+void lttv_traceset_selector_trace_remove(LttvTracesetSelector *s, unsigned i) 
+{
+  g_assert(s->traces->len > i);
+  g_ptr_array_remove_index(s->traces, i);
+}
+
+void lttv_trace_selector_tracefile_remove(LttvTraceSelector *s, unsigned i) 
+{
+  g_assert(s->tracefiles->len > i);
+  g_ptr_array_remove_index(s->tracefiles, i);
+}
+
+void lttv_trace_selector_eventtype_remove(LttvTraceSelector *s, unsigned i)
+{
+  g_assert(s->eventtypes->len > i);
+  g_ptr_array_remove_index(s->eventtypes, i);
+}
+
+void lttv_tracefile_selector_eventtype_remove(LttvTracefileSelector *s, unsigned i)
+{
+  g_assert(s->eventtypes->len > i);
+  g_ptr_array_remove_index(s->eventtypes, i);
+}
+
+void lttv_trace_selector_set_selected(LttvTraceSelector *s, gboolean g)
+{
+  s->selected = g;
+}
+
+void lttv_tracefile_selector_set_selected(LttvTracefileSelector *s, gboolean g)
+{
+  s->selected = g;
+}
+
+void lttv_eventtype_selector_set_selected(LttvEventtypeSelector *s, gboolean g)
+{
+  s->selected = g;
+}
+
+gboolean lttv_trace_selector_get_selected(LttvTraceSelector *s)
+{
+  return s->selected;
+}
+
+gboolean lttv_tracefile_selector_get_selected(LttvTracefileSelector *s)
+{
+  return s->selected;
+}
+
+gboolean lttv_eventtype_selector_get_selected(LttvEventtypeSelector *s)
+{
+  return s->selected;
+}
+
+char * lttv_traceset_selector_get_name(LttvTracesetSelector *s)
+{
+  return s->traceset_name;
+}
+
+char * lttv_trace_selector_get_name(LttvTraceSelector *s)
+{
+  return s->trace_name;
+}
+
+char * lttv_tracefile_selector_get_name(LttvTracefileSelector *s)
+{
+  return s->tracefile_name;
+}
+
+char * lttv_eventtype_selector_get_name(LttvEventtypeSelector *s)
+{
+  return s->eventtype_name;
+}
+
+LttvEventtypeSelector * lttv_eventtype_selector_clone(LttvEventtypeSelector * s)
+{
+  LttvEventtypeSelector * ev = g_new(LttvEventtypeSelector, 1);
+  ev->eventtype_name = g_strdup(s->eventtype_name);
+  ev->selected = s->selected;
+  return ev;
+}
+
+void lttv_eventtype_selector_copy(LttvTraceSelector * s, LttvTracefileSelector * d)
+{
+  int i, len;
+  LttvEventtypeSelector * ev, *ev1;
+
+  len = s->eventtypes->len;
+  for(i=0;i<len;i++){
+    ev = lttv_trace_selector_eventtype_get(s,i);
+    ev1 = lttv_eventtype_selector_clone(ev);
+    lttv_tracefile_selector_eventtype_add(d,ev1);
+  }
+}
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvfilter.h b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/lttvfilter.h
new file mode 100644 (file)
index 0000000..f2dab41
--- /dev/null
@@ -0,0 +1,89 @@
+/* This file is part of the Linux Trace Toolkit viewer
+ * Copyright (C) 2003-2004 Xiangxiu 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.
+ */
+
+#ifndef LTTV_FILTER_H
+#define LTTV_FILTER_H
+
+#include <ltt/ltt.h>
+
+
+typedef struct _LttvTracesetSelector  LttvTracesetSelector;
+typedef struct _LttvTraceSelector     LttvTraceSelector;
+typedef struct _LttvTracefileSelector LttvTracefileSelector;
+typedef struct _LttvEventtypeSelector LttvEventtypeSelector;
+
+
+LttvTracesetSelector *lttv_traceset_selector_new(char * name);
+LttvTraceSelector *lttv_trace_selector_new(LttTrace *t);
+LttvTracefileSelector *lttv_tracefile_selector_new(LttTracefile *t);
+LttvEventtypeSelector *lttv_eventtype_selector_new(LttEventType * et);
+void lttv_traceset_selector_destroy(LttvTracesetSelector *s);
+void lttv_trace_selector_destroy(LttvTraceSelector *t);
+void lttv_tracefile_selector_destroy(LttvTracefileSelector *t);
+void lttv_eventtype_selector_destroy(LttvEventtypeSelector *t);
+
+
+void lttv_traceset_selector_trace_add(LttvTracesetSelector *s, 
+                                     LttvTraceSelector *t);
+unsigned lttv_traceset_selector_trace_number(LttvTracesetSelector *s);
+LttvTraceSelector *lttv_traceset_selector_trace_get(LttvTracesetSelector *s,
+                                                   unsigned i);
+void lttv_traceset_selector_trace_remove(LttvTracesetSelector *s,
+                                        unsigned i);
+
+
+void lttv_trace_selector_tracefile_add(LttvTraceSelector *s,
+                                      LttvTracefileSelector *t);
+unsigned lttv_trace_selector_tracefile_number(LttvTraceSelector *s);
+LttvTracefileSelector *lttv_trace_selector_tracefile_get(LttvTraceSelector *s,
+                                                        unsigned i);
+void lttv_trace_selector_tracefile_remove(LttvTraceSelector *s, unsigned i);
+
+void lttv_trace_selector_eventtype_add(LttvTraceSelector *s,
+                                      LttvEventtypeSelector *et);
+unsigned lttv_trace_selector_eventtype_number(LttvTraceSelector *s);
+LttvEventtypeSelector *lttv_trace_selector_eventtype_get(LttvTraceSelector *s,
+                                                        unsigned i);
+void lttv_trace_selector_eventtype_remove(LttvTraceSelector *s, unsigned i);
+
+
+void lttv_tracefile_selector_eventtype_add(LttvTracefileSelector *s,
+                                          LttvEventtypeSelector *et);
+unsigned lttv_tracefile_selector_eventtype_number(LttvTracefileSelector *s);
+LttvEventtypeSelector *lttv_tracefile_selector_eventtype_get(LttvTracefileSelector *s,
+                                                            unsigned i);
+void lttv_tracefile_selector_eventtype_remove(LttvTracefileSelector *s, unsigned i);
+
+
+void lttv_trace_selector_set_selected(LttvTraceSelector *s, gboolean g);
+void lttv_tracefile_selector_set_selected(LttvTracefileSelector *s, gboolean g);
+void lttv_eventtype_selector_set_selected(LttvEventtypeSelector *s, gboolean g);
+gboolean lttv_trace_selector_get_selected(LttvTraceSelector *s);
+gboolean lttv_tracefile_selector_get_selected(LttvTracefileSelector *s);
+gboolean lttv_eventtype_selector_get_selected(LttvEventtypeSelector *s);
+char * lttv_traceset_selector_get_name(LttvTracesetSelector *s);
+char * lttv_trace_selector_get_name(LttvTraceSelector *s);
+char * lttv_tracefile_selector_get_name(LttvTracefileSelector *s);
+char * lttv_eventtype_selector_get_name(LttvEventtypeSelector *s);
+
+LttvEventtypeSelector * lttv_eventtype_selector_clone(LttvEventtypeSelector * s);
+void lttv_eventtype_selector_copy(LttvTraceSelector *s, LttvTracefileSelector *d);
+
+
+#endif // LTTV_FILTER_H
+
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/main.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/main.c
new file mode 100644 (file)
index 0000000..7b31ac6
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * Initial main.c file generated by Glade. Edit as required.
+ * Glade will not overwrite this file.
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include <gtk/gtk.h>
+#include <gmodule.h>
+
+#include "interface.h"
+#include "support.h"
+#include <lttvwindow/mainWindow.h>
+#include "callbacks.h"
+
+/* global variable */
+systemView * gSysView;
+
+typedef view_constructor (* constructor)();
+constructor get_constructor = NULL;
+typedef void (*call_Event_Selected_Hook)(void * call_data);
+call_Event_Selected_Hook selected_hook = NULL;
+GModule *gm;
+view_constructor gConstructor = NULL;
+
+int
+main (int argc, char *argv[])
+{
+  GModule *gm;
+  GtkWidget * ToolMenuTitle_menu, *insert_view;
+  GtkWidget *window1;
+  mainWindow * mw = g_new(mainWindow, 1);
+  gSysView = g_new(systemView, 1);
+
+#ifdef ENABLE_NLS
+  bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+  textdomain (GETTEXT_PACKAGE);
+#endif
+
+  gtk_set_locale ();
+  gtk_init (&argc, &argv);
+
+  add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps");
+  add_pixmap_directory ("pixmaps");
+  add_pixmap_directory ("../pixmaps");
+
+  /*
+   * The following code was added by Glade to create one of each component
+   * (except popup menus), just so that you see something after building
+   * the project. Delete any components that you don't want shown initially.
+   */
+  window1 = create_MWindow ();
+  gtk_widget_show (window1);
+
+  mw->MWindow = window1;
+  mw->SystemView = gSysView;
+  mw->Tab = NULL;
+  mw->CurrentTab = NULL;
+  //  mw->Attributes = lttv_attributes_new();
+
+  //test
+
+  gm = g_module_open("/home1/yangxx/poly/lttv/modules/libguiEvents.la",0);
+  printf("Main : the address of gm : %d\n", gm);
+  if(!g_module_symbol(gm, "get_constructor", (gpointer)&get_constructor)){
+    g_error("can not get constructor\n");
+  }  
+  if(!g_module_symbol(gm, "call_Event_Selected_Hook", (gpointer)&selected_hook)){
+    g_error("can not get selected hook\n");
+  }  
+
+  gConstructor = get_constructor();
+  ToolMenuTitle_menu = lookup_widget(mw->MWindow,"ToolMenuTitle_menu");
+  insert_view = gtk_menu_item_new_with_mnemonic ("insert_view");
+  gtk_widget_show (insert_view);
+  gtk_container_add (GTK_CONTAINER (ToolMenuTitle_menu), insert_view);
+  g_signal_connect ((gpointer) insert_view, "activate",
+                    G_CALLBACK (insertViewTest),
+                    NULL);  
+  //end
+
+  gSysView->EventDB = NULL;
+  gSysView->SystemInfo = NULL;
+  gSysView->Options  = NULL;
+  gSysView->Window = mw;
+  gSysView->Next = NULL;
+
+  g_object_set_data(G_OBJECT(window1), "systemView", (gpointer)gSysView);
+  g_object_set_data(G_OBJECT(window1), "mainWindow", (gpointer)mw);
+
+  gtk_main ();
+  return 0;
+}
+
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/mainwindow.h b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/mainwindow.h
new file mode 100644 (file)
index 0000000..9349687
--- /dev/null
@@ -0,0 +1,100 @@
+/* This file is part of the Linux Trace Toolkit viewer
+ * Copyright (C) 2003-2004 Xiangxiu 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.
+ */
+
+#ifndef _MAIN_WINDOW_
+#define _MAIN_WINDOW_
+
+#include <gtk/gtk.h>
+
+#include <ltt/ltt.h>
+#include <lttv/attribute.h>
+#include <lttv/traceset.h>
+#include <lttv/tracecontext.h>
+
+#include <lttvwindow/common.h>
+#include <lttvwindow/gtkmultivpaned.h>
+#include <lttv/hook.h>
+#include <lttv/stats.h>
+
+typedef struct _TracesetInfo {
+  //FIXME? TracesetContext and stats in same or different variable ?
+  LttvTracesetStats * traceset_context;
+  LttvTraceset * traceset;
+} TracesetInfo ;
+
+
+struct _MainWindow{
+  GtkWidget*      mwindow;            /* Main Window */
+  int             window_width;
+
+  /* Status bar information */
+  //  guint         MainSBarContextID;    /* Context ID of main status bar */
+  //  guint         BegTimeSBarContextID; /* Context ID of BegTime status bar */
+  //  guint         EndTimeSBarContextID; /* Context ID of EndTime status bar */
+  
+  /* Child windows */
+  //openTracesetWindow*  OpenTracesetWindow;/* Window to get prof and proc file*/
+  //viewTimeFrameWindow* ViewTimeFrameWindow;/*Window to select time frame */
+  //gotoEventWindow*     GotoEventWindow; /*search for event description*/
+  //openFilterWindow*    OpenFilterWindow; /* Open a filter selection window */
+  GtkWidget*           help_contents;/* Window to display help contents */
+  GtkWidget*           about_box;    /* Window  about information */
+  //  lttv_trace_filter * filter; /* trace filter associated with the window */
+
+  /* Attributes for trace reading hooks local to the main window */
+  LttvIAttribute * attributes;
+  
+  Tab * tab;
+  Tab * current_tab;
+
+  GHashTable * hash_menu_item;
+  GHashTable * hash_toolbar_item;
+};
+
+
+struct _Tab{
+  GtkWidget * label;
+  GtkMultiVPaned * multi_vpaned;
+   
+  // startTime is the left of the visible area. Corresponds to the scrollbar
+  // value.
+  // Time_Width is a zoom dependant value (corresponding to page size)
+  TimeWindow time_window;
+  
+  // The current time is the time selected in the visible area by the user,
+  // not the scrollbar value.
+  LttTime current_time;
+  LttvIAttribute * attributes;
+
+  struct _Tab * next;
+  MainWindow  * mw;
+
+  /* Traceset related information */
+  TracesetInfo * traceset_info; 
+};
+
+/**
+ * Remove menu and toolbar item when a module unloaded
+ */
+void main_window_remove_menu_item(lttv_constructor view_constructor);
+void main_window_remove_toolbar_item(lttv_constructor view_constructor);
+
+#endif /* _MAIN_WINDOW_ */
+
+
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/menu.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/menu.c
new file mode 100644 (file)
index 0000000..32c35c2
--- /dev/null
@@ -0,0 +1,68 @@
+/* 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.
+ */
+
+#include <lttv/lttv.h>
+#include <lttvwindow/menu.h>
+
+
+inline LttvMenus *lttv_menus_new() {
+  return g_array_new(FALSE, FALSE, sizeof(lttv_menu_closure));
+}
+
+/* MD: delete elements of the array also, but don't free pointed addresses
+ * (functions).
+ */
+inline void lttv_menus_destroy(LttvMenus *h) {
+  g_debug("lttv_menus_destroy()");
+  g_array_free(h, TRUE);
+}
+
+inline void lttv_menus_add(LttvMenus *h, lttv_constructor f, char* menuPath, char* menuText)
+{
+  lttv_menu_closure c;
+
+  /* if h is null, do nothing, or popup a warning message */
+  if(h == NULL)return;
+
+  c.con = f;
+  c.menuPath = menuPath;
+  c.menuText = menuText;
+  g_array_append_val(h,c);
+}
+
+gboolean lttv_menus_remove(LttvMenus *h, lttv_constructor f)
+{
+  lttv_menu_closure * tmp;
+  gint i;
+  for(i=0;i<h->len;i++){
+    tmp = & g_array_index(h, lttv_menu_closure, i);
+    if(tmp->con == f)break;
+  }
+  if(i<h->len){
+    g_array_remove_index(h, i);
+    return TRUE;
+  }else return FALSE;
+  
+}
+
+unsigned lttv_menus_number(LttvMenus *h)
+{
+  return h->len;
+}
+
+
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/menu.h b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/menu.h
new file mode 100644 (file)
index 0000000..3253bf7
--- /dev/null
@@ -0,0 +1,47 @@
+/* This file is part of the Linux Trace Toolkit viewer
+ * Copyright (C) 2003-2004 Xiangxiu 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.
+ */
+
+#ifndef MENU_H
+#define MENU_H
+
+#include <lttvwindow/common.h>
+
+/* constructor of the viewer */
+//typedef GtkWidget* (*lttv_constructor)(void * main_window);
+
+
+typedef GArray LttvMenus;
+
+typedef struct _lttv_menu_closure {
+  lttv_constructor con;
+  char * menuPath;
+  char * menuText;
+} lttv_menu_closure;
+
+
+LttvMenus *lttv_menus_new();
+
+void lttv_menus_destroy(LttvMenus *h);
+
+void lttv_menus_add(LttvMenus *h, lttv_constructor f, char* menuPath, char * menuText);
+
+gboolean lttv_menus_remove(LttvMenus *h, lttv_constructor f);
+
+unsigned lttv_menus_number(LttvMenus *h);
+
+#endif // MENU_H
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/support.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/support.c
new file mode 100644 (file)
index 0000000..fddd4cf
--- /dev/null
@@ -0,0 +1,162 @@
+/* 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.
+ */
+
+/*
+ * DO NOT EDIT THIS FILE - it is generated by Glade.
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <gtk/gtk.h>
+
+#include "support.h"
+
+GtkWidget*
+lookup_widget                          (GtkWidget       *widget,
+                                        const gchar     *widget_name)
+{
+  GtkWidget *parent, *found_widget;
+
+  for (;;)
+    {
+      if (GTK_IS_MENU (widget))
+        parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
+      else
+        parent = widget->parent;
+      if (!parent)
+        parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey");
+      if (parent == NULL)
+        break;
+      widget = parent;
+    }
+
+  found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget),
+                                                 widget_name);
+  if (!found_widget)
+    g_warning ("Widget not found: %s", widget_name);
+  return found_widget;
+}
+
+static GList *pixmaps_directories = NULL;
+
+/* Use this function to set the directory containing installed pixmaps. */
+void
+add_pixmap_directory                   (const gchar     *directory)
+{
+  pixmaps_directories = g_list_prepend (pixmaps_directories,
+                                        g_strdup (directory));
+}
+
+/* This is an internally used function to find pixmap files. */
+static gchar*
+find_pixmap_file                       (const gchar     *filename)
+{
+  GList *elem;
+
+  /* We step through each of the pixmaps directory to find it. */
+  elem = pixmaps_directories;
+  while (elem)
+    {
+      gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data,
+                                         G_DIR_SEPARATOR_S, filename);
+      if (g_file_test (pathname, G_FILE_TEST_EXISTS))
+        return pathname;
+      g_free (pathname);
+      elem = elem->next;
+    }
+  return NULL;
+}
+
+/* This is an internally used function to create pixmaps. */
+GtkWidget*
+create_pixmap                          (GtkWidget       *widget,
+                                        const gchar     *filename)
+{
+  gchar *pathname = NULL;
+  GtkWidget *pixmap;
+
+  if (!filename || !filename[0])
+      return gtk_image_new ();
+
+  pathname = find_pixmap_file (filename);
+
+  if (!pathname)
+    {
+      g_warning ("Couldn't find pixmap file: %s", filename);
+      return gtk_image_new ();
+    }
+
+  pixmap = gtk_image_new_from_file (pathname);
+  g_free (pathname);
+  return pixmap;
+}
+
+/* This is an internally used function to create pixmaps. */
+GdkPixbuf*
+create_pixbuf                          (const gchar     *filename)
+{
+  gchar *pathname = NULL;
+  GdkPixbuf *pixbuf;
+  GError *error = NULL;
+
+  if (!filename || !filename[0])
+      return NULL;
+
+  pathname = find_pixmap_file (filename);
+
+  if (!pathname)
+    {
+      g_warning ("Couldn't find pixmap file: %s", filename);
+      return NULL;
+    }
+
+  pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
+  if (!pixbuf)
+    {
+      fprintf (stderr, "Failed to load pixbuf file: %s: %s\n",
+               pathname, error->message);
+      g_error_free (error);
+    }
+  g_free (pathname);
+  return pixbuf;
+}
+
+/* This is used to set ATK action descriptions. */
+void
+glade_set_atk_action_description       (AtkAction       *action,
+                                        const gchar     *action_name,
+                                        const gchar     *description)
+{
+  gint n_actions, i;
+
+  n_actions = atk_action_get_n_actions (action);
+  for (i = 0; i < n_actions; i++)
+    {
+      if (!strcmp (atk_action_get_name (action, i), action_name))
+        atk_action_set_description (action, i, description);
+    }
+}
+
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/support.h b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/support.h
new file mode 100644 (file)
index 0000000..6297519
--- /dev/null
@@ -0,0 +1,62 @@
+/* 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.
+ */
+
+/*
+ * DO NOT EDIT THIS FILE - it is generated by Glade.
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include <gtk/gtk.h>
+
+/*
+ * Public Functions.
+ */
+
+/*
+ * This function returns a widget in a component created by Glade.
+ * Call it with the toplevel widget in the component (i.e. a window/dialog),
+ * or alternatively any widget in the component, and the name of the widget
+ * you want returned.
+ */
+GtkWidget*  lookup_widget              (GtkWidget       *widget,
+                                        const gchar     *widget_name);
+
+
+/* Use this function to set the directory containing installed pixmaps. */
+void        add_pixmap_directory       (const gchar     *directory);
+
+
+/*
+ * Private Functions.
+ */
+
+/* This is used to create the pixmaps used in the interface. */
+GtkWidget*  create_pixmap              (GtkWidget       *widget,
+                                        const gchar     *filename);
+
+/* This is used to create the pixbufs used in the interface. */
+GdkPixbuf*  create_pixbuf              (const gchar     *filename);
+
+/* This is used to set ATK action descriptions. */
+void        glade_set_atk_action_description (AtkAction       *action,
+                                              const gchar     *action_name,
+                                              const gchar     *description);
+
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/toolbar.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/toolbar.c
new file mode 100644 (file)
index 0000000..2a1dbb1
--- /dev/null
@@ -0,0 +1,67 @@
+/* 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.
+ */
+
+#include <lttv/lttv.h>
+#include <lttvwindow/toolbar.h>
+
+
+inline LttvToolbars *lttv_toolbars_new() {
+  return g_array_new(FALSE, FALSE, sizeof(lttv_toolbar_closure));
+}
+
+/* MD: delete elements of the array also, but don't free pointed addresses
+ * (functions).
+ */
+inline void lttv_toolbars_destroy(LttvToolbars *h) {
+  g_debug("lttv_toolbars_destroy");
+  g_array_free(h, TRUE);
+}
+
+inline void lttv_toolbars_add(LttvToolbars *h, lttv_constructor f, char* tooltip, char ** pixmap)
+{
+  lttv_toolbar_closure c;
+
+  /* if h is null, do nothing, or popup a warning message */
+  if(h == NULL)return;
+
+  c.con = f;
+  c.tooltip = tooltip;
+  c.pixmap = pixmap;
+  g_array_append_val(h,c);
+}
+
+gboolean lttv_toolbars_remove(LttvToolbars *h, lttv_constructor f)
+{
+  lttv_toolbar_closure * tmp;
+  gint i;
+  for(i=0;i<h->len;i++){
+    tmp = & g_array_index(h, lttv_toolbar_closure, i);
+    if(tmp->con == f)break;
+  }
+  if(i<h->len){
+    g_array_remove_index(h, i);
+    return TRUE;
+  }else return FALSE;
+}
+
+unsigned lttv_toolbars_number(LttvToolbars *h)
+{
+  return h->len;
+}
+
+
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/toolbar.h b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/toolbar.h
new file mode 100644 (file)
index 0000000..681311b
--- /dev/null
@@ -0,0 +1,46 @@
+/* This file is part of the Linux Trace Toolkit viewer
+ * Copyright (C) 2003-2004 Xiangxiu 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.
+ */
+
+#ifndef TOOLBAR_H
+#define TOOLBAR_H
+
+#include <lttvwindow/common.h>
+
+/* constructor of the viewer */
+//typedef GtkWidget* (*lttv_constructor)(void * main_window);
+
+
+typedef GArray LttvToolbars;
+
+typedef struct _lttv_toolbar_closure {
+  lttv_constructor con;
+  char * tooltip;
+  char ** pixmap;
+} lttv_toolbar_closure;
+
+LttvToolbars *lttv_toolbars_new();
+
+void lttv_toolbars_destroy(LttvToolbars *h);
+
+void lttv_toolbars_add(LttvToolbars *h, lttv_constructor f, char* tooltip, char ** pixmap);
+
+gboolean lttv_toolbars_remove(LttvToolbars *h, lttv_constructor f);
+
+unsigned lttv_toolbars_number(LttvToolbars *h);
+
+#endif // TOOLBAR_H
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/Makefile.am b/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/Makefile.am
deleted file mode 100644 (file)
index cf6aa23..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-AM_CFLAGS = $(GLIB_CFLAGS) 
-AM_CFLAGS += $(GTK_CFLAGS)
-LIBS += $(GLIB_LIBS)
-LIBS += $(GTK_LIBS) -lcustomBox
-
-INCLUDES = \
-       -DPACKAGE_DATA_DIR=\""$(datadir)"\" \
-       -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
-       @PACKAGE_CFLAGS@ \
-       $(DEFAULT_INCLUDES)
-
-libdir = ${lttvplugindir}
-
-#bin_PROGRAMS = lttvwindow
-lib_LTLIBRARIES = liblttvwindow.la
-
-
-liblttvwindow_la_LDFLAGS = -module
-liblttvwindow_la_SOURCES = \
-       toolbar.c\
-       menu.c\
-       gtkdirsel.c\
-       gtkmultivpaned.c\
-       gtktraceset.c \
-       init_module.c \
-       support.c \
-       interface.c \
-       callbacks.c \
-       lttvfilter.c
-
-noinst_HEADERS = \
-       support.h \
-       interface.h \
-       callbacks.h
-
-lttvguiinclude_HEADERS = \
-       common.h\
-       gtkdirsel.h\
-       gtkmultivpaned.h\
-       gtktraceset.h\
-       lttvfilter.h\
-       mainwindow.h\
-       menu.h\
-       toolbar.h
-
-liblttvwindow_la_LIBADD = @PACKAGE_LIBS@ $(INTLLIBS)
-
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/callbacks.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/callbacks.c
deleted file mode 100644 (file)
index 3dfaad1..0000000
+++ /dev/null
@@ -1,2075 +0,0 @@
-/* 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 "callbacks.h"
-#include "interface.h"
-#include "support.h"
-#include <lttv/lttv.h>
-#include <lttvwindow/mainwindow.h>
-#include <lttvwindow/menu.h>
-#include <lttvwindow/toolbar.h>
-#include <lttvwindow/gtktraceset.h>
-#include <lttv/module.h>
-#include <lttvwindow/gtkdirsel.h>
-#include <lttv/iattribute.h>
-#include <lttvwindow/lttvfilter.h>
-#include <ltt/trace.h>
-#include <ltt/facility.h>
-
-#define PATH_LENGTH          256
-#define DEFAULT_TIME_WIDTH_S   1
-
-extern LttvTrace *g_init_trace ;
-
-
-/** Array containing instanced objects. */
-extern GSList * g_main_window_list;
-
-static int g_win_count = 0;
-
-// MD : keep old directory
-static char remember_plugins_dir[PATH_LENGTH] = "";
-static char remember_trace_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);
-char * get_selection(char ** all_name, int nb, char *title, char * column_title);
-gboolean get_filter_selection(LttvTracesetSelector *s, char *title, char * column_title);
-void * create_tab(MainWindow * parent, MainWindow * current_window,
-                 GtkNotebook * notebook, char * label);
-
-void insert_viewer(GtkWidget* widget, view_constructor constructor);
-void update_filter(LttvTracesetSelector *s,  GtkTreeStore *store );
-
-void checkbox_changed(GtkTreeView *treeview,
-                     GtkTreePath *arg1,
-                     GtkTreeViewColumn *arg2,
-                     gpointer user_data);
-void remove_trace_from_traceset_selector(GtkMultiVPaned * paned, unsigned i);
-void add_trace_into_traceset_selector(GtkMultiVPaned * paned, LttTrace * trace);
-
-LttvTracesetSelector * construct_traceset_selector(LttvTraceset * traceset);
-
-void redraw_viewer(MainWindow * mw_data, TimeWindow * time_window);
-unsigned get_max_event_number(MainWindow * mw_data);
-
-enum {
-  CHECKBOX_COLUMN,
-  NAME_COLUMN,
-  TOTAL_COLUMNS
-};
-
-enum
-{
-  MODULE_COLUMN,
-  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)
-{
-  LttvTracesetSelector  * s;
-  LttvTraceSelector     * trace;
-  LttvTracefileSelector * tracefile;
-  LttvEventtypeSelector * eventtype;
-  int i, j, k, m;
-  int nb_trace, nb_tracefile, nb_control, nb_per_cpu, nb_facility, nb_event;
-  LttvTrace * trace_v;
-  LttTrace  * t;
-  LttTracefile *tf;
-  LttFacility * fac;
-  LttEventType * et;
-
-  s = lttv_traceset_selector_new(lttv_traceset_name(traceset));
-  nb_trace = lttv_traceset_number(traceset);
-  for(i=0;i<nb_trace;i++){
-    trace_v = lttv_traceset_get(traceset, i);
-    t       = lttv_trace(trace_v);
-    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);
-    }
-  } 
-  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)
-{
-  guint val = 20;
-
-  insert_viewer((GtkWidget*)menuitem, (view_constructor)user_data);
-  //  selected_hook(&val);
-}
-
-
-/* internal functions */
-void insert_viewer(GtkWidget* widget, view_constructor constructor)
-{
-  GtkMultiVPaned * multi_vpaned;
-  MainWindow * mw_data;  
-  GtkWidget * viewer;
-  LttvTracesetSelector  * s;
-  TimeInterval * time_interval;
-  TimeWindow  time_window, t;
-
-  mw_data = get_window_data_struct(widget);
-  if(!mw_data->current_tab) return;
-  multi_vpaned = mw_data->current_tab->multi_vpaned;
-
-  s = construct_traceset_selector(mw_data->current_tab->traceset_info->traceset);
-  viewer = (GtkWidget*)constructor(mw_data, s, "Traceset_Selector");
-  if(viewer)
-  {
-    gtk_multi_vpaned_widget_add(multi_vpaned, viewer); 
-    // Added by MD
-    //    g_object_unref(G_OBJECT(viewer));
-
-    time_window = mw_data->current_tab->time_window;
-    time_interval = (TimeInterval*)g_object_get_data(G_OBJECT(viewer), TRACESET_TIME_SPAN);
-    if(time_interval){
-      t = time_window;
-      time_window.start_time = time_interval->startTime;
-      time_window.time_width = ltt_time_sub(time_interval->endTime,time_interval->startTime);
-    }
-
-    redraw_viewer(mw_data,&time_window);
-    set_current_time(mw_data,&(mw_data->current_tab->current_time));
-    if(time_interval){
-      set_time_window(mw_data,&t);
-    }
-  }
-}
-
-
-/* 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;
-  if(strlen(gtk_entry_get_text(entry))!=0)
-    strcpy(label,gtk_entry_get_text(entry)); 
-}
-
-gboolean get_label(MainWindow * mw, gchar * str, gchar* dialogue_title, gchar * label_str)
-{
-  GtkWidget * dialogue;
-  GtkWidget * text;
-  GtkWidget * label;
-  gint id;
-
-  dialogue = gtk_dialog_new_with_buttons(dialogue_title,NULL,
-                                        GTK_DIALOG_MODAL,
-                                        GTK_STOCK_OK,GTK_RESPONSE_ACCEPT,
-                                        GTK_STOCK_CANCEL,GTK_RESPONSE_REJECT,
-                                        NULL); 
-
-  label = gtk_label_new(label_str);
-  gtk_widget_show(label);
-
-  text = gtk_entry_new();
-  gtk_widget_show(text);
-
-  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialogue)->vbox), label,TRUE, TRUE,0);
-  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialogue)->vbox), text,FALSE, FALSE,0);
-
-  id = gtk_dialog_run(GTK_DIALOG(dialogue));
-  switch(id){
-    case GTK_RESPONSE_ACCEPT:
-      get_label_string(text,str);
-      gtk_widget_destroy(dialogue);
-      break;
-    case GTK_RESPONSE_REJECT:
-    default:
-      gtk_widget_destroy(dialogue);
-      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;
-  MainWindow * mw_data;
-
-  mw = lookup_widget(widget, "MWindow");
-  if(mw == NULL){
-    g_printf("Main window does not exist\n");
-    return;
-  }
-  
-  mw_data = (MainWindow *) g_object_get_data(G_OBJECT(mw),"mainWindow");
-  if(mw_data == NULL){
-    g_printf("Main window data does not exist\n");
-    return;
-  }
-  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);
-  }else{
-    g_printf("Empty : traceset is set to NULL\n");
-    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);
-  if(!mw->current_tab) return;
-  gtk_multi_vpaned_widget_move_up(mw->current_tab->multi_vpaned);
-}
-
-void move_down_viewer(GtkWidget * widget, gpointer user_data)
-{
-  MainWindow * mw = get_window_data_struct(widget);
-  if(!mw->current_tab) return;
-  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);
-  if(!mw->current_tab) return;
-  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;
-  gint id;
-  LttvTraceset * traceset;
-  MainWindow * mw_data = get_window_data_struct(widget);
-  GtkFileSelection * file_selector = 
-    (GtkFileSelection *)gtk_file_selection_new("Select a traceset");
-
-  gtk_file_selection_hide_fileop_buttons(file_selector);
-  
-  id = gtk_dialog_run(GTK_DIALOG(file_selector));
-  switch(id){
-    case GTK_RESPONSE_ACCEPT:
-    case GTK_RESPONSE_OK:
-      dir = gtk_file_selection_get_selections (file_selector);
-      traceset = lttv_traceset_load(dir[0]);
-      g_printf("Open a trace set %s\n", dir[0]); 
-      //Not finished yet
-      g_strfreev(dir);
-    case GTK_RESPONSE_REJECT:
-    case GTK_RESPONSE_CANCEL:
-    default:
-      gtk_widget_destroy((GtkWidget*)file_selector);
-      break;
-  }
-
-}
-
-
-/* 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;
-  GtkWidget * w;
-
-  w = gtk_multi_vpaned_get_first_widget(mw_data->current_tab->multi_vpaned);  
-  while(w){
-    size = (unsigned*)g_object_get_data(G_OBJECT(w), MAX_NUMBER_EVENT);
-    if(size == NULL){
-      nb = G_MAXULONG;
-      break;
-    }else{
-      if(nb < *size)
-       nb = *size;
-    }
-    w = gtk_multi_vpaned_get_next_widget(mw_data->current_tab->multi_vpaned);  
-  }  
-  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;
-  GdkWindow * win;
-  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, "MToolbar1");
-  win = gtk_widget_get_parent_window(widget);  
-  gdk_window_set_cursor(win, new);
-  gdk_cursor_unref(new);  
-  gdk_window_stick(win);
-  gdk_window_unstick(win);
-  //update time window of each viewer, let viewer insert hooks needed by process_traceset
-  set_time_window(mw_data, time_window);
-  
-  max_nb_events = get_max_event_number(mw_data);
-
-  process_traceset_api(mw_data, time_window->start_time, 
-                      ltt_time_add(time_window->start_time,time_window->time_width),
-                      max_nb_events);
-
-  //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;
-  LttvTracesetSelector  * s;
-  LttvTraceSelector     * trace;
-  LttvTracefileSelector * tracefile;
-  LttvEventtypeSelector * eventtype;
-  LttTracefile          * tf;
-  GtkWidget             * w;
-  LttFacility           * fac;
-  LttEventType          * et;
-
-  w = gtk_multi_vpaned_get_first_widget(paned);  
-  while(w){
-    s = g_object_get_data(G_OBJECT(w), "Traceset_Selector");
-    
-    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;
-  const char * dir;
-  gint id;
-  MainWindow * mw_data = get_window_data_struct(widget);
-  GtkDirSelection * file_selector = (GtkDirSelection *)gtk_dir_selection_new("Select a trace");
-  gtk_dir_selection_hide_fileop_buttons(file_selector);
-  if(remember_trace_dir[0] != '\0')
-    gtk_dir_selection_set_filename(file_selector, remember_trace_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);
-      strncpy(remember_trace_dir, dir, PATH_LENGTH);
-      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);
-      traceset = mw_data->current_tab->traceset_info->traceset;
-      if(mw_data->current_tab->traceset_info->traceset_context != NULL){
-       lttv_context_fini(LTTV_TRACESET_CONTEXT(mw_data->current_tab->
-                                               traceset_info->traceset_context));
-       g_object_unref(mw_data->current_tab->traceset_info->traceset_context);
-      }
-      lttv_traceset_add(traceset, trace_v);
-      mw_data->current_tab->traceset_info->traceset_context =
-       g_object_new(LTTV_TRACESET_STATS_TYPE, NULL);
-      lttv_context_init(
-       LTTV_TRACESET_CONTEXT(mw_data->current_tab->traceset_info->
-                             traceset_context),traceset); 
-      add_trace_into_traceset_selector(mw_data->current_tab->multi_vpaned, trace);
-
-      gtk_widget_destroy((GtkWidget*)file_selector);
-      
-      //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;
-    case GTK_RESPONSE_REJECT:
-    case GTK_RESPONSE_CANCEL:
-    default:
-      gtk_widget_destroy((GtkWidget*)file_selector);
-      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;
-  LttvTraceSelector * t;
-  GtkWidget * w; 
-  
-  w = gtk_multi_vpaned_get_first_widget(paned);  
-  while(w){
-    s = g_object_get_data(G_OBJECT(w), "Traceset_Selector");
-    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;
-  LttvTrace * trace_v;
-  LttvTraceset * traceset;
-  gint i, nb_trace;
-  char ** name, *remove_trace_name;
-  MainWindow * mw_data = get_window_data_struct(widget);
-  LttvTracesetSelector * s;
-  LttvTraceSelector * t;
-  GtkWidget * w; 
-  gboolean selected;
-  
-  nb_trace =lttv_traceset_number(mw_data->current_tab->traceset_info->traceset); 
-  name = g_new(char*,nb_trace);
-  for(i = 0; i < nb_trace; i++){
-    trace_v = lttv_traceset_get(mw_data->current_tab->
-                               traceset_info->traceset, i);
-    trace = lttv_trace(trace_v);
-    name[i] = ltt_trace_name(trace);
-  }
-
-  remove_trace_name = get_remove_trace(name, nb_trace);
-
-  if(remove_trace_name){
-    for(i=0; i<nb_trace; i++){
-      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);  
-       if(w){
-         s = g_object_get_data(G_OBJECT(w), "Traceset_Selector");
-         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){
-         remove_trace_from_traceset_selector(mw_data->current_tab->multi_vpaned, i);
-
-         traceset = mw_data->current_tab->traceset_info->traceset;
-         trace_v = lttv_traceset_get(traceset, i);
-         if(lttv_trace_get_ref_number(trace_v) <= 1)
-           ltt_trace_close(lttv_trace(trace_v));
-
-         if(mw_data->current_tab->traceset_info->traceset_context != NULL){
-           lttv_context_fini(LTTV_TRACESET_CONTEXT(mw_data->current_tab->
-                                                   traceset_info->traceset_context));
-           g_object_unref(mw_data->current_tab->traceset_info->traceset_context);
-         }
-         lttv_traceset_remove(traceset, i);
-         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(
-                           LTTV_TRACESET_CONTEXT(mw_data->current_tab->
-                                     traceset_info->traceset_context),traceset);      
-         //update current tab
-         update_traceset(mw_data);
-         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");
-}
-
-void save_as(GtkWidget * widget, gpointer user_data)
-{
-  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;
-  TimeWindow time_window;
-  LttTime    current_time, time_delta, time_s, time_e, time_t;
-  MainWindow * mw_data = get_window_data_struct(widget);
-
-  if(size == 1) return;
-
-  time_span = LTTV_TRACESET_CONTEXT(mw_data->current_tab->
-                                   traceset_info->traceset_context)->Time_Span;
-  time_window =  mw_data->current_tab->time_window;
-  current_time = mw_data->current_tab->current_time;
-  
-  time_delta = ltt_time_sub(time_span->endTime,time_span->startTime);
-  if(size == 0){
-    time_window.start_time = time_span->startTime;
-    time_window.time_width = time_delta;
-  }else{
-    time_window.time_width = ltt_time_div(time_window.time_width, size);
-    if(ltt_time_compare(time_window.time_width,time_delta) > 0)
-      time_window.time_width = time_delta;
-
-    time_t = ltt_time_div(time_window.time_width, 2);
-    if(ltt_time_compare(current_time, time_t) < 0){
-      time_s = time_span->startTime;
-    } else {
-      time_s = ltt_time_sub(current_time,time_t);
-    }
-    time_e = ltt_time_add(current_time,time_t);
-    if(ltt_time_compare(time_span->startTime, time_s) > 0){
-      time_s = time_span->startTime;
-    }else if(ltt_time_compare(time_span->endTime, time_e) < 0){
-      time_e = time_span->endTime;
-      time_s = ltt_time_sub(time_e,time_window.time_width);
-    }
-    time_window.start_time = time_s;    
-  }
-  redraw_viewer(mw_data, &time_window);
-  set_current_time(mw_data,&(mw_data->current_tab->current_time));
-  gtk_multi_vpaned_set_adjust(mw_data->current_tab->multi_vpaned, FALSE);
-}
-
-void zoom_in(GtkWidget * widget, gpointer user_data)
-{
-  zoom(widget, 2);
-}
-
-void zoom_out(GtkWidget * widget, gpointer user_data)
-{
-  zoom(widget, 0.5);
-}
-
-void zoom_extended(GtkWidget * widget, gpointer user_data)
-{
-  zoom(widget, 0);
-}
-
-void go_to_time(GtkWidget * widget, gpointer user_data)
-{
-  g_printf("Go to time\n");
-}
-
-void show_time_frame(GtkWidget * widget, gpointer user_data)
-{
-  g_printf("Show time frame\n");  
-}
-
-
-/* callback function */
-
-void
-on_empty_traceset_activate             (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-  create_new_window((GtkWidget*)menuitem, user_data, FALSE);
-}
-
-
-void
-on_clone_traceset_activate             (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-  create_new_window((GtkWidget*)menuitem, user_data, TRUE);
-}
-
-
-/* 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(widget);
-  GtkNotebook * notebook = (GtkNotebook *)lookup_widget(widget, "MNotebook");
-  if(notebook == NULL){
-    g_printf("Notebook does not exist\n");
-    return;
-  }
-
-  strcpy(label,"Page");
-  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);
-}
-
-void
-on_tab_activate                        (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-  create_new_tab((GtkWidget*)menuitem, user_data);
-}
-
-
-void
-on_open_activate                       (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-  open_traceset((GtkWidget*)menuitem, user_data);
-}
-
-
-void
-on_close_activate                      (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-  MainWindow * mw_data = get_window_data_struct((GtkWidget*)menuitem);
-  main_window_destructor(mw_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;
-  MainWindow * mw_data = get_window_data_struct((GtkWidget*)menuitem);
-  notebook = lookup_widget((GtkWidget*)menuitem, "MNotebook");
-  if(notebook == NULL){
-    g_printf("Notebook does not exist\n");
-    return;
-  }
-  
-  if(mw_data->tab == mw_data->current_tab){
-    //    tmp = mw_data->current_tb;
-    //    mw_data->tab = mw_data->current_tab->next;
-    g_printf("The default TAB can not be deleted\n");
-    return;
-  }else{
-    tmp = mw_data->tab;
-    while(tmp != mw_data->current_tab){
-      tmp = tmp->next;
-      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);
-}
-
-
-void
-on_add_trace_activate                  (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-  add_trace((GtkWidget*)menuitem, user_data);
-}
-
-
-void
-on_remove_trace_activate               (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-  remove_trace((GtkWidget*)menuitem, user_data);
-}
-
-
-void
-on_save_activate                       (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-  save((GtkWidget*)menuitem, user_data);
-}
-
-
-void
-on_save_as_activate                    (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-  save_as((GtkWidget*)menuitem, user_data);
-}
-
-
-void
-on_quit_activate                       (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-  gtk_main_quit ();
-}
-
-
-void
-on_cut_activate                        (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-  g_printf("Cut\n");
-}
-
-
-void
-on_copy_activate                       (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-  g_printf("Copye\n");
-}
-
-
-void
-on_paste_activate                      (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-  g_printf("Paste\n");
-}
-
-
-void
-on_delete_activate                     (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-  g_printf("Delete\n");
-}
-
-
-void
-on_zoom_in_activate                    (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-   zoom_in((GtkWidget*)menuitem, user_data); 
-}
-
-
-void
-on_zoom_out_activate                   (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-   zoom_out((GtkWidget*)menuitem, user_data); 
-}
-
-
-void
-on_zoom_extended_activate              (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-   zoom_extended((GtkWidget*)menuitem, user_data); 
-}
-
-
-void
-on_go_to_time_activate                 (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-   go_to_time((GtkWidget*)menuitem, user_data); 
-}
-
-
-void
-on_show_time_frame_activate            (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-   show_time_frame((GtkWidget*)menuitem, user_data); 
-}
-
-
-void
-on_move_viewer_up_activate             (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-  move_up_viewer((GtkWidget*)menuitem, user_data);
-}
-
-
-void
-on_move_viewer_down_activate           (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-  move_down_viewer((GtkWidget*)menuitem, user_data);
-}
-
-
-void
-on_remove_viewer_activate              (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-  delete_viewer((GtkWidget*)menuitem, user_data);
-}
-
-void
-on_trace_filter_activate              (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-  MainWindow * mw_data = get_window_data_struct((GtkWidget*)menuitem);
-  LttvTracesetSelector * s;
-  GtkWidget * w = gtk_multi_vpaned_get_widget(mw_data->current_tab->multi_vpaned);
-  
-  s = g_object_get_data(G_OBJECT(w), "Traceset_Selector");
-  if(!s){
-    g_printf("There is no viewer yet\n");      
-    return;
-  }
-  if(get_filter_selection(s, "Configure trace and tracefile filter", "Select traces and tracefiles")){
-    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));
-  }
-}
-
-void
-on_trace_facility_activate              (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-  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 ** dir;
-  gint id;
-  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_plugins_dir[0] != '\0')
-    gtk_file_selection_set_filename(file_selector, remember_plugins_dir);
-  gtk_file_selection_hide_fileop_buttons(file_selector);
-  
-  str[0] = '\0';
-  id = gtk_dialog_run(GTK_DIALOG(file_selector));
-  switch(id){
-    case GTK_RESPONSE_ACCEPT:
-    case GTK_RESPONSE_OK:
-      dir = gtk_file_selection_get_selections (file_selector);
-      strncpy(str,dir[0],PATH_LENGTH);
-      strncpy(remember_plugins_dir,dir[0],PATH_LENGTH);
-      str1 = strrchr(str,'/');
-      if(str1)str1++;
-      else{
-       str1 = strrchr(str,'\\');
-       str1++;
-      }
-      lttv_module_require(str1, NULL);
-      g_slist_foreach(g_main_window_list, (gpointer)insert_menu_toolbar_item,
-          NULL);
-      g_strfreev(dir);
-    case GTK_RESPONSE_REJECT:
-    case GTK_RESPONSE_CANCEL:
-    default:
-      gtk_widget_destroy((GtkWidget*)file_selector);
-      break;
-  }
-  g_printf("Load module: %s\n", str);
-}
-
-
-/* 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;
-  GPtrArray *name;
-  char *unload_module_name;
-  guint nb;
-  LttvLibrary *library;
-  LttvLibraryInfo library_info;
-  MainWindow * mw_data = get_window_data_struct((GtkWidget*)menuitem);
-  
-  name  = g_ptr_array_new();
-  nb = lttv_library_number();
-
-  for(i=0;i<nb;i++){
-    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((char **)(name->pdata), name->len);
-  
-  if(unload_module_name){
-    for(i=0;i<nb;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_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");
-  const char * dir;
-  gint id;
-
-  MainWindow * mw_data = get_window_data_struct((GtkWidget*)menuitem);
-  if(remember_plugins_dir[0] != '\0')
-    gtk_dir_selection_set_filename(file_selector, remember_plugins_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);
-      strncpy(remember_plugins_dir,dir,PATH_LENGTH);
-      strncat(remember_plugins_dir,"/",PATH_LENGTH);
-      lttv_library_path_add(dir);
-    case GTK_RESPONSE_REJECT:
-    case GTK_RESPONSE_CANCEL:
-    default:
-      gtk_widget_destroy((GtkWidget*)file_selector);
-      break;
-  }
-}
-
-
-void
-on_color_activate                      (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-  g_printf("Color\n");
-}
-
-
-void
-on_filter_activate                     (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-  g_printf("Filter\n");
-}
-
-
-void
-on_save_configuration_activate         (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-  g_printf("Save configuration\n");
-}
-
-
-void
-on_content_activate                    (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-  g_printf("Content\n");
-}
-
-
-void
-on_about_activate                      (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-  g_printf("About...\n");
-}
-
-
-void
-on_button_new_clicked                  (GtkButton       *button,
-                                        gpointer         user_data)
-{
-  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,
-                                        gpointer         user_data)
-{
-  open_traceset((GtkWidget*)button, user_data);
-}
-
-
-void
-on_button_add_trace_clicked            (GtkButton       *button,
-                                        gpointer         user_data)
-{
-  add_trace((GtkWidget*)button, user_data);
-}
-
-
-void
-on_button_remove_trace_clicked         (GtkButton       *button,
-                                        gpointer         user_data)
-{
-  remove_trace((GtkWidget*)button, user_data);
-}
-
-
-void
-on_button_save_clicked                 (GtkButton       *button,
-                                        gpointer         user_data)
-{
-  save((GtkWidget*)button, user_data);
-}
-
-
-void
-on_button_save_as_clicked              (GtkButton       *button,
-                                        gpointer         user_data)
-{
-  save_as((GtkWidget*)button, user_data);
-}
-
-
-void
-on_button_zoom_in_clicked              (GtkButton       *button,
-                                        gpointer         user_data)
-{
-   zoom_in((GtkWidget*)button, user_data); 
-}
-
-
-void
-on_button_zoom_out_clicked             (GtkButton       *button,
-                                        gpointer         user_data)
-{
-   zoom_out((GtkWidget*)button, user_data); 
-}
-
-
-void
-on_button_zoom_extended_clicked        (GtkButton       *button,
-                                        gpointer         user_data)
-{
-   zoom_extended((GtkWidget*)button, user_data); 
-}
-
-
-void
-on_button_go_to_time_clicked           (GtkButton       *button,
-                                        gpointer         user_data)
-{
-   go_to_time((GtkWidget*)button, user_data); 
-}
-
-
-void
-on_button_show_time_frame_clicked      (GtkButton       *button,
-                                        gpointer         user_data)
-{
-   show_time_frame((GtkWidget*)button, user_data); 
-}
-
-
-void
-on_button_move_up_clicked              (GtkButton       *button,
-                                        gpointer         user_data)
-{
-  move_up_viewer((GtkWidget*)button, user_data);
-}
-
-
-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                     (GtkObject       *object,
-                                        gpointer         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--;
-  if(g_win_count == 0)
-    gtk_main_quit ();
-}
-
-gboolean    
-on_MWindow_configure                   (GtkWidget         *widget,
-                                        GdkEventConfigure *event,
-                                        gpointer           user_data)
-{
-  MainWindow * mw_data = get_window_data_struct((GtkWidget*)widget);
-  float width = event->width;
-  Tab * tab = mw_data->tab;
-  TimeWindow time_win;
-  double ratio;
-  TimeInterval *time_span;
-  LttTime time;
-       
-       // 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)
-{
-  MainWindow * mw = get_window_data_struct((GtkWidget*)notebook);
-  Tab * tab = mw->tab;
-  while(page_num){
-    tab = tab->next;
-    page_num--;
-  }
-  mw->current_tab = tab;
-}
-
-
-/* callback function to check or uncheck the check box (filter)
- */
-
-void checkbox_changed(GtkTreeView *treeview,
-                     GtkTreePath *arg1,
-                     GtkTreeViewColumn *arg2,
-                     gpointer user_data)
-{
-  GtkTreeStore * store = (GtkTreeStore *)gtk_tree_view_get_model (treeview);
-  GtkTreeIter iter;
-  gboolean value;
-
-  if (gtk_tree_model_get_iter ((GtkTreeModel *)store, &iter, arg1)){
-    gtk_tree_model_get ((GtkTreeModel *)store, &iter, CHECKBOX_COLUMN, &value, -1);
-    value = value? FALSE : TRUE;
-    gtk_tree_store_set (GTK_TREE_STORE (store), &iter, CHECKBOX_COLUMN, value, -1);    
-  }  
-  
-}
-
-
-/* According to user's selection, update selector(filter)
- */
-
-void update_filter(LttvTracesetSelector *s,  GtkTreeStore *store )
-{
-  GtkTreeIter iter, child_iter, child_iter1, child_iter2;
-  int i, j, k, nb_eventtype;
-  LttvTraceSelector     * trace;
-  LttvTracefileSelector * tracefile;
-  LttvEventtypeSelector * eventtype;
-  gboolean value, value1, value2;
-
-  if(gtk_tree_model_get_iter_first((GtkTreeModel*)store, &iter)){
-    i = 0;
-    do{
-      trace = lttv_traceset_selector_trace_get(s, i);
-      nb_eventtype = lttv_trace_selector_eventtype_number(trace);
-      gtk_tree_model_get ((GtkTreeModel*)store, &iter, CHECKBOX_COLUMN, &value,-1);
-      if(value){
-       j = 0;
-       if(gtk_tree_model_iter_children ((GtkTreeModel*)store, &child_iter, &iter)){
-         do{
-           if(j<1){//eventtype selector for trace
-             gtk_tree_model_get ((GtkTreeModel*)store, &child_iter, CHECKBOX_COLUMN, &value2,-1);
-             if(value2){
-               k=0;
-               if(gtk_tree_model_iter_children ((GtkTreeModel*)store, &child_iter1, &child_iter)){
-                 do{
-                   eventtype = lttv_trace_selector_eventtype_get(trace,k);
-                   gtk_tree_model_get ((GtkTreeModel*)store, &child_iter1, CHECKBOX_COLUMN, &value2,-1);
-                   lttv_eventtype_selector_set_selected(eventtype,value2);
-                   k++;
-                 }while(gtk_tree_model_iter_next((GtkTreeModel*)store, &child_iter1));
-               }
-             }
-           }else{ //tracefile selector
-             tracefile = lttv_trace_selector_tracefile_get(trace, j - 1);
-             gtk_tree_model_get ((GtkTreeModel*)store, &child_iter, CHECKBOX_COLUMN, &value1,-1);
-             lttv_tracefile_selector_set_selected(tracefile,value1);
-             if(value1){
-               gtk_tree_model_iter_children((GtkTreeModel*)store, &child_iter1, &child_iter); //eventtype selector
-               gtk_tree_model_get ((GtkTreeModel*)store, &child_iter1, CHECKBOX_COLUMN, &value2,-1);
-               if(value2){
-                 k = 0;
-                 if(gtk_tree_model_iter_children ((GtkTreeModel*)store, &child_iter2, &child_iter1)){
-                   do{//eventtype selector for tracefile
-                     eventtype = lttv_tracefile_selector_eventtype_get(tracefile,k);
-                     gtk_tree_model_get ((GtkTreeModel*)store, &child_iter2, CHECKBOX_COLUMN, &value2,-1);
-                     lttv_eventtype_selector_set_selected(eventtype,value2);
-                     k++;
-                   }while(gtk_tree_model_iter_next((GtkTreeModel*)store, &child_iter2));
-                 }
-               }
-             }
-           }
-           j++;
-         }while(gtk_tree_model_iter_next((GtkTreeModel*)store, &child_iter));
-       }
-      }
-      lttv_trace_selector_set_selected(trace,value);
-      i++;
-    }while(gtk_tree_model_iter_next((GtkTreeModel*)store, &iter));
-  }
-}
-
-
-/* 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;
-  GtkTreeStore      * store;
-  GtkWidget         * tree;
-  GtkWidget         * scroll_win;
-  GtkCellRenderer   * renderer;
-  GtkTreeViewColumn * column;
-  GtkTreeIter         iter, child_iter, child_iter1, child_iter2;
-  int i, j, k, id, nb_trace, nb_tracefile, nb_eventtype;
-  LttvTraceSelector     * trace;
-  LttvTracefileSelector * tracefile;
-  LttvEventtypeSelector * eventtype;
-  char * name;
-  gboolean checked;
-
-  dialogue = gtk_dialog_new_with_buttons(title,
-                                        NULL,
-                                        GTK_DIALOG_MODAL,
-                                        GTK_STOCK_OK,GTK_RESPONSE_ACCEPT,
-                                        GTK_STOCK_CANCEL,GTK_RESPONSE_REJECT,
-                                        NULL); 
-  gtk_window_set_default_size((GtkWindow*)dialogue, 300, 500);
-
-  store = gtk_tree_store_new (TOTAL_COLUMNS, G_TYPE_BOOLEAN, G_TYPE_STRING);
-  tree  = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
-  g_object_unref (G_OBJECT (store));
-  g_signal_connect (G_OBJECT (tree), "row-activated",
-                   G_CALLBACK (checkbox_changed),
-                   NULL);  
-
-
-  renderer = gtk_cell_renderer_toggle_new ();
-  gtk_cell_renderer_toggle_set_radio((GtkCellRendererToggle *)renderer, FALSE);
-
-  g_object_set (G_OBJECT (renderer),"activatable", TRUE, NULL);
-
-  column   = gtk_tree_view_column_new_with_attributes ("Checkbox",
-                                                      renderer,
-                                                      "active", CHECKBOX_COLUMN,
-                                                      NULL);
-  gtk_tree_view_column_set_alignment (column, 0.5);
-  gtk_tree_view_column_set_fixed_width (column, 20);
-  gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
-
-  renderer = gtk_cell_renderer_text_new ();
-  column   = gtk_tree_view_column_new_with_attributes (column_title,
-                                                      renderer,
-                                                      "text", NAME_COLUMN,
-                                                      NULL);
-  gtk_tree_view_column_set_alignment (column, 0.0);
-  gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
-  gtk_tree_view_set_headers_visible(GTK_TREE_VIEW (tree), FALSE);
-
-  scroll_win = gtk_scrolled_window_new (NULL, NULL);
-  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_win), 
-                                GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
-  gtk_container_add (GTK_CONTAINER (scroll_win), tree);
-
-  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialogue)->vbox), scroll_win,TRUE, TRUE,0);
-
-  gtk_widget_show(scroll_win);
-  gtk_widget_show(tree);
-  
-  nb_trace = lttv_traceset_selector_trace_number(s);
-  for(i=0;i<nb_trace;i++){
-    trace = lttv_traceset_selector_trace_get(s, i);
-    name  = lttv_trace_selector_get_name(trace);    
-    gtk_tree_store_append (store, &iter, NULL);
-    checked = lttv_trace_selector_get_selected(trace);
-    gtk_tree_store_set (store, &iter, 
-                       CHECKBOX_COLUMN,checked,
-                       NAME_COLUMN,name,
-                       -1);
-
-    gtk_tree_store_append (store, &child_iter, &iter);      
-    gtk_tree_store_set (store, &child_iter, 
-                       CHECKBOX_COLUMN, checked,
-                       NAME_COLUMN,"eventtype",
-                       -1);
-    
-    nb_eventtype = lttv_trace_selector_eventtype_number(trace);
-    for(j=0;j<nb_eventtype;j++){
-      eventtype = lttv_trace_selector_eventtype_get(trace,j);
-      name      = lttv_eventtype_selector_get_name(eventtype);    
-      checked   = lttv_eventtype_selector_get_selected(eventtype);
-      gtk_tree_store_append (store, &child_iter1, &child_iter);      
-      gtk_tree_store_set (store, &child_iter1, 
-                         CHECKBOX_COLUMN, checked,
-                         NAME_COLUMN,name,
-                         -1);
-    }
-
-    nb_tracefile = lttv_trace_selector_tracefile_number(trace);
-    for(j=0;j<nb_tracefile;j++){
-      tracefile = lttv_trace_selector_tracefile_get(trace, j);
-      name      = lttv_tracefile_selector_get_name(tracefile);    
-      gtk_tree_store_append (store, &child_iter, &iter);
-      checked = lttv_tracefile_selector_get_selected(tracefile);
-      gtk_tree_store_set (store, &child_iter, 
-                         CHECKBOX_COLUMN, checked,
-                         NAME_COLUMN,name,
-                         -1);
-
-      gtk_tree_store_append (store, &child_iter1, &child_iter);      
-      gtk_tree_store_set (store, &child_iter1, 
-                         CHECKBOX_COLUMN, checked,
-                         NAME_COLUMN,"eventtype",
-                         -1);
-    
-      for(k=0;k<nb_eventtype;k++){
-       eventtype = lttv_tracefile_selector_eventtype_get(tracefile,k);
-       name      = lttv_eventtype_selector_get_name(eventtype);    
-       checked   = lttv_eventtype_selector_get_selected(eventtype);
-       gtk_tree_store_append (store, &child_iter2, &child_iter1);      
-       gtk_tree_store_set (store, &child_iter2, 
-                           CHECKBOX_COLUMN, checked,
-                           NAME_COLUMN,name,
-                           -1);
-      }
-    }
-  }
-
-  id = gtk_dialog_run(GTK_DIALOG(dialogue));
-  switch(id){
-    case GTK_RESPONSE_ACCEPT:
-    case GTK_RESPONSE_OK:
-      update_filter(s, store);
-      gtk_widget_destroy(dialogue);
-      return TRUE;
-    case GTK_RESPONSE_REJECT:
-    case GTK_RESPONSE_CANCEL:
-    default:
-      gtk_widget_destroy(dialogue);
-      break;
-  }
-  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)
-{
-  GtkWidget         * dialogue;
-  GtkWidget         * scroll_win;
-  GtkWidget         * tree;
-  GtkListStore      * store;
-  GtkTreeViewColumn * column;
-  GtkCellRenderer   * renderer;
-  GtkTreeSelection  * select;
-  GtkTreeIter         iter;
-  gint                id, i;
-  char              * unload_module_name = NULL;
-
-  dialogue = gtk_dialog_new_with_buttons(title,
-                                        NULL,
-                                        GTK_DIALOG_MODAL,
-                                        GTK_STOCK_OK,GTK_RESPONSE_ACCEPT,
-                                        GTK_STOCK_CANCEL,GTK_RESPONSE_REJECT,
-                                        NULL); 
-  gtk_window_set_default_size((GtkWindow*)dialogue, 500, 200);
-
-  scroll_win = gtk_scrolled_window_new (NULL, NULL);
-  gtk_widget_show ( scroll_win);
-  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_win), 
-                                GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
-
-  store = gtk_list_store_new (N_COLUMNS,G_TYPE_STRING);
-  tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL (store));
-  gtk_widget_show ( tree);
-  g_object_unref (G_OBJECT (store));
-               
-  renderer = gtk_cell_renderer_text_new ();
-  column   = gtk_tree_view_column_new_with_attributes (column_title,
-                                                    renderer,
-                                                    "text", MODULE_COLUMN,
-                                                    NULL);
-  gtk_tree_view_column_set_alignment (column, 0.5);
-  gtk_tree_view_column_set_fixed_width (column, 150);
-  gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
-
-  select = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree));
-  gtk_tree_selection_set_mode (select, GTK_SELECTION_SINGLE);
-
-  gtk_container_add (GTK_CONTAINER (scroll_win), tree);  
-
-  gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialogue)->vbox), scroll_win,TRUE, TRUE,0);
-
-  for(i=0;i<nb_module;i++){
-    gtk_list_store_append (store, &iter);
-    gtk_list_store_set (store, &iter, MODULE_COLUMN,loaded_module_name[i],-1);
-  }
-
-  id = gtk_dialog_run(GTK_DIALOG(dialogue));
-  switch(id){
-    case GTK_RESPONSE_ACCEPT:
-    case GTK_RESPONSE_OK:
-      if (gtk_tree_selection_get_selected (select, (GtkTreeModel**)&store, &iter)){
-         gtk_tree_model_get ((GtkTreeModel*)store, &iter, MODULE_COLUMN, &unload_module_name, -1);
-      }
-    case GTK_RESPONSE_REJECT:
-    case GTK_RESPONSE_CANCEL:
-    default:
-      gtk_widget_destroy(dialogue);
-      break;
-  }
-
-  return unload_module_name;
-}
-
-
-/* hash funtions 
- */
-
-void main_window_destroy_hash_key(gpointer key)
-{
-  g_free(key);
-}
-
-void main_window_destroy_hash_data(gpointer data)
-{
-}
-
-
-/* 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;
-  GdkPixbuf *pixbuf;
-  view_constructor constructor;
-  LttvMenus * menu;
-  LttvToolbars * toolbar;
-  lttv_menu_closure *menu_item;
-  lttv_toolbar_closure *toolbar_item;
-  LttvAttributeValue value;
-  LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes());
-  GtkWidget * tool_menu_title_menu, *insert_view, *pixmap, *tmp;
-
-  g_assert(lttv_iattribute_find_by_path(attributes,
-          "viewers/menu", LTTV_POINTER, &value));
-  menu = (LttvMenus*)*(value.v_pointer);
-
-  if(menu){
-    for(i=0;i<menu->len;i++){
-      menu_item = &g_array_index(menu, lttv_menu_closure, i);
-      tmp = g_hash_table_lookup(mw->hash_menu_item, g_strdup(menu_item->menuText));
-      if(tmp)continue;
-      constructor = menu_item->con;
-      tool_menu_title_menu = lookup_widget(mw->mwindow,"ToolMenuTitle_menu");
-      insert_view = gtk_menu_item_new_with_mnemonic (menu_item->menuText);
-      gtk_widget_show (insert_view);
-      gtk_container_add (GTK_CONTAINER (tool_menu_title_menu), insert_view);
-      g_signal_connect ((gpointer) insert_view, "activate",
-                       G_CALLBACK (insert_viewer_wrap),
-                       constructor);  
-      g_hash_table_insert(mw->hash_menu_item, g_strdup(menu_item->menuText),
-                         insert_view);
-    }
-  }
-
-  g_assert(lttv_iattribute_find_by_path(attributes,
-          "viewers/toolbar", LTTV_POINTER, &value));
-  toolbar = (LttvToolbars*)*(value.v_pointer);
-
-  if(toolbar){
-    for(i=0;i<toolbar->len;i++){
-      toolbar_item = &g_array_index(toolbar, lttv_toolbar_closure, 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,"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),
-                                               GTK_TOOLBAR_CHILD_BUTTON,
-                                               NULL,
-                                               "",
-                                               toolbar_item->tooltip, NULL,
-                                               pixmap, NULL, NULL);
-      gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (tool_menu_title_menu)->children)->data))->label), TRUE);
-      gtk_widget_show (insert_view);
-      gtk_container_set_border_width (GTK_CONTAINER (insert_view), 1);
-      g_signal_connect ((gpointer) insert_view, "clicked",G_CALLBACK (insert_viewer_wrap),constructor);       
-      g_hash_table_insert(mw->hash_toolbar_item, g_strdup(toolbar_item->tooltip),
-                         insert_view);
-    }
-  }
-}
-
-
-/* Create a main window
- */
-
-void construct_main_window(MainWindow * parent)
-{
-  g_debug("construct_main_window()");
-  GtkWidget  * new_window; /* New generated main window */
-  MainWindow * new_m_window;/* New main window structure */
-  GtkNotebook * notebook;
-  LttvIAttribute *attributes =
-         LTTV_IATTRIBUTE(g_object_new(LTTV_ATTRIBUTE_TYPE, NULL));
-  LttvAttributeValue value;
-         
-  new_m_window = g_new(MainWindow, 1);
-
-  // Add the object's information to the module's array 
-  g_main_window_list = g_slist_append(g_main_window_list, new_m_window);
-
-
-  new_window  = create_MWindow();
-  gtk_widget_show (new_window);
-    
-  new_m_window->attributes = attributes;
-  
-  new_m_window->mwindow = new_window;
-  new_m_window->tab = NULL;
-  new_m_window->current_tab = NULL;
-  new_m_window->attributes = LTTV_IATTRIBUTE(g_object_new(LTTV_ATTRIBUTE_TYPE, NULL));
-
-  new_m_window->hash_menu_item = g_hash_table_new_full (g_str_hash, g_str_equal,
-                                             main_window_destroy_hash_key, 
-                                             main_window_destroy_hash_data);
-  new_m_window->hash_toolbar_item = g_hash_table_new_full (g_str_hash, g_str_equal,
-                                             main_window_destroy_hash_key, 
-                                             main_window_destroy_hash_data);
-
-  insert_menu_toolbar_item(new_m_window, NULL);
-  
-  g_object_set_data(G_OBJECT(new_window), "mainWindow", (gpointer)new_m_window);    
-
-  //create a default tab
-  notebook = (GtkNotebook *)lookup_widget(new_m_window->mwindow, "MNotebook");
-  if(notebook == NULL){
-    g_printf("Notebook does not exist\n");
-    return;
-  }
-  //for now there is no name field in LttvTraceset structure
-  //Use "Traceset" as the label for the default tab
-  create_tab(parent, new_m_window, notebook,"Traceset");
-
-  g_object_set_data_full(
-                       G_OBJECT(new_m_window->mwindow),
-                       "Main_Window_Data",
-                       new_m_window,
-                       (GDestroyNotify)main_window_free);
-
-  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;
-  LttvTrace * trace;
-
-  if(tab_instance->attributes)
-    g_object_unref(tab_instance->attributes);  
-
-  if(tab_instance->mw->tab == tab_instance){
-    tab_instance->mw->tab = tab_instance->next;
-  }else{
-    Tab * tmp1, *tmp = tab_instance->mw->tab;
-    while(tmp != tab_instance){
-      tmp1 = tmp;
-      tmp = tmp->next;
-    }
-    tmp1->next = tab_instance->next;
-  }
-
-  if(tab_instance->traceset_info->traceset_context != NULL){
-    lttv_context_fini(LTTV_TRACESET_CONTEXT(tab_instance->traceset_info->
-                                           traceset_context));
-    g_object_unref(tab_instance->traceset_info->traceset_context);
-  }
-  if(tab_instance->traceset_info->traceset != NULL) {
-    nb = lttv_traceset_number(tab_instance->traceset_info->traceset);
-    for(i = 0 ; i < nb ; i++) {
-      trace = lttv_traceset_get(tab_instance->traceset_info->traceset, i);
-      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_traceset_destroy(tab_instance->traceset_info->traceset); 
-  g_free(tab_instance->traceset_info);
-  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)
-{
-  GList * list;
-  Tab * tmp_tab;
-  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){
-    mw_data->current_tab = NULL;
-    tmp_tab = g_new(Tab,1);
-    mw_data->tab = tmp_tab;    
-  }else{
-    tmp_tab->next = g_new(Tab,1);
-    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_copy(parent->current_tab->traceset_info->traceset);
-  }else{
-    if(mw_data->current_tab){
-      tmp_tab->traceset_info->traceset = 
-        lttv_traceset_copy(mw_data->current_tab->traceset_info->traceset);
-    }else{
-      tmp_tab->traceset_info->traceset = lttv_traceset_new();    
-      /* Add the command line trace */
-      if(g_init_trace != NULL)
-       lttv_traceset_add(tmp_tab->traceset_info->traceset, g_init_trace);
-    }
-  }
-  //FIXME copy not implemented in lower level
-  tmp_tab->traceset_info->traceset_context =
-    g_object_new(LTTV_TRACESET_STATS_TYPE, NULL);
-  lttv_context_init(
-           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->time_window      = mw_data->current_tab->time_window;
-    tmp_tab->current_time     = mw_data->current_tab->current_time;
-  }else{
-    // Will have to read directly at the main window level, as we want
-    // to be able to modify a traceset on the fly.
-    // get_traceset_time_span(mw_data,&tmp_tab->traceStartTime, &tmp_tab->traceEndTime);
-    tmp_tab->time_window.start_time   = 
-           LTTV_TRACESET_CONTEXT(tmp_tab->traceset_info->traceset_context)->Time_Span->startTime;
-    if(DEFAULT_TIME_WIDTH_S <
-              LTTV_TRACESET_CONTEXT(tmp_tab->traceset_info->traceset_context)->Time_Span->endTime.tv_sec)
-      tmp_time.tv_sec = DEFAULT_TIME_WIDTH_S;
-    else
-      tmp_time.tv_sec =
-              LTTV_TRACESET_CONTEXT(tmp_tab->traceset_info->traceset_context)->Time_Span->endTime.tv_sec;
-    tmp_time.tv_nsec = 0;
-    tmp_tab->time_window.time_width = tmp_time ;
-    tmp_tab->current_time.tv_sec = 
-       LTTV_TRACESET_CONTEXT(tmp_tab->traceset_info->traceset_context)->Time_Span->startTime.tv_sec;
-    tmp_tab->current_time.tv_nsec = 
-       LTTV_TRACESET_CONTEXT(tmp_tab->traceset_info->traceset_context)->Time_Span->startTime.tv_nsec;
-  }
-  tmp_tab->attributes = LTTV_IATTRIBUTE(g_object_new(LTTV_ATTRIBUTE_TYPE, NULL));
-  //  mw_data->current_tab = tmp_tab;
-  tmp_tab->multi_vpaned = (GtkMultiVPaned*)gtk_multi_vpaned_new();
-  tmp_tab->multi_vpaned->mw = mw_data;
-  gtk_widget_show((GtkWidget*)tmp_tab->multi_vpaned);
-  tmp_tab->next = NULL;    
-  tmp_tab->mw   = mw_data;
-
-  tmp_tab->label = gtk_label_new (label);
-  gtk_widget_show (tmp_tab->label);
-
-  g_object_set_data_full(
-           G_OBJECT(tmp_tab->multi_vpaned),
-           "Tab_Info",
-          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;
-  lttv_menu_closure *menu_item = (lttv_menu_closure *)user_data;
-  GtkWidget * tool_menu_title_menu, *insert_view;
-
-  tool_menu_title_menu = lookup_widget(mw->mwindow,"ToolMenuTitle_menu");
-  insert_view = (GtkWidget*)g_hash_table_lookup(mw->hash_menu_item,
-                                               menu_item->menuText);
-  if(insert_view){
-    g_hash_table_remove(mw->hash_menu_item, menu_item->menuText);
-    gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu), insert_view);
-  }
-}
-
-void remove_toolbar_item(gpointer main_win, gpointer user_data)
-{
-  MainWindow * mw = (MainWindow *) main_win;
-  lttv_toolbar_closure *toolbar_item = (lttv_toolbar_closure *)user_data;
-  GtkWidget * tool_menu_title_menu, *insert_view;
-
-
-  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){
-    g_hash_table_remove(mw->hash_toolbar_item, toolbar_item->tooltip);
-    gtk_container_remove (GTK_CONTAINER (tool_menu_title_menu), insert_view);
-  }
-}
-
-/**
- * Remove menu and toolbar item when a module unloaded from all 
- * main windows
- */
-
-void main_window_remove_menu_item(lttv_constructor constructor)
-{
-  int i;
-  LttvMenus * menu;
-  lttv_menu_closure *menu_item;
-  LttvAttributeValue value;
-  LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes());
-
-  g_assert(lttv_iattribute_find_by_path(attributes,
-          "viewers/menu", LTTV_POINTER, &value));
-  menu = (LttvMenus*)*(value.v_pointer);
-
-  if(menu){
-    for(i=0;i<menu->len;i++){
-      menu_item = &g_array_index(menu, lttv_menu_closure, i);
-      if(menu_item->con != constructor) continue;
-      if(g_main_window_list){
-       g_slist_foreach(g_main_window_list, remove_menu_item, menu_item);
-      }
-      break;
-    }
-  }
-  
-}
-
-void main_window_remove_toolbar_item(lttv_constructor constructor)
-{
-  int i;
-  LttvToolbars * toolbar;
-  lttv_toolbar_closure *toolbar_item;
-  LttvAttributeValue value;
-  LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes());
-
-  g_assert(lttv_iattribute_find_by_path(attributes,
-          "viewers/toolbar", LTTV_POINTER, &value));
-  toolbar = (LttvToolbars*)*(value.v_pointer);
-
-  if(toolbar){
-    for(i=0;i<toolbar->len;i++){
-      toolbar_item = &g_array_index(toolbar, lttv_toolbar_closure, i);
-      if(toolbar_item->con != constructor) continue;
-      if(g_main_window_list){
-       g_slist_foreach(g_main_window_list, remove_toolbar_item, toolbar_item);
-      }
-      break;
-    }
-  }
-}
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/callbacks.h b/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/callbacks.h
deleted file mode 100644 (file)
index 96cc541..0000000
+++ /dev/null
@@ -1,243 +0,0 @@
-/* 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.
- */
-
-#include <gtk/gtk.h>
-#include <lttvwindow/common.h>
-#include <lttvwindow/mainwindow.h>
-
-/* internal functions */
-
-void create_new_window(GtkWidget* widget, gpointer user_data, gboolean clone);
-void insert_menu_toolbar_item(MainWindow * mw, gpointer user_data);
-void construct_main_window(MainWindow * parent);
-void main_window_free(MainWindow * mw);
-void main_window_destructor(MainWindow * mw);
-
-/* callback functions*/
-
-void
-on_empty_traceset_activate             (GtkMenuItem     *menuitem,
-                                        gpointer         user_data);
-
-void
-on_clone_traceset_activate             (GtkMenuItem     *menuitem,
-                                        gpointer         user_data);
-
-void
-on_tab_activate                        (GtkMenuItem     *menuitem,
-                                        gpointer         user_data);
-
-void
-on_open_activate                       (GtkMenuItem     *menuitem,
-                                        gpointer         user_data);
-
-void
-on_close_activate                      (GtkMenuItem     *menuitem,
-                                        gpointer         user_data);
-
-void
-on_close_tab_activate                  (GtkMenuItem     *menuitem,
-                                        gpointer         user_data);
-
-void
-on_add_trace_activate                  (GtkMenuItem     *menuitem,
-                                        gpointer         user_data);
-
-void
-on_remove_trace_activate               (GtkMenuItem     *menuitem,
-                                        gpointer         user_data);
-
-void
-on_save_activate                       (GtkMenuItem     *menuitem,
-                                        gpointer         user_data);
-
-void
-on_save_as_activate                    (GtkMenuItem     *menuitem,
-                                        gpointer         user_data);
-
-void
-on_quit_activate                       (GtkMenuItem     *menuitem,
-                                        gpointer         user_data);
-
-void
-on_cut_activate                        (GtkMenuItem     *menuitem,
-                                        gpointer         user_data);
-
-void
-on_copy_activate                       (GtkMenuItem     *menuitem,
-                                        gpointer         user_data);
-
-void
-on_paste_activate                      (GtkMenuItem     *menuitem,
-                                        gpointer         user_data);
-
-void
-on_delete_activate                     (GtkMenuItem     *menuitem,
-                                        gpointer         user_data);
-
-void
-on_zoom_in_activate                    (GtkMenuItem     *menuitem,
-                                        gpointer         user_data);
-
-void
-on_zoom_out_activate                   (GtkMenuItem     *menuitem,
-                                        gpointer         user_data);
-
-void
-on_zoom_extended_activate              (GtkMenuItem     *menuitem,
-                                        gpointer         user_data);
-
-void
-on_go_to_time_activate                 (GtkMenuItem     *menuitem,
-                                        gpointer         user_data);
-
-void
-on_show_time_frame_activate            (GtkMenuItem     *menuitem,
-                                        gpointer         user_data);
-
-void
-on_move_viewer_up_activate             (GtkMenuItem     *menuitem,
-                                        gpointer         user_data);
-
-void
-on_move_viewer_down_activate           (GtkMenuItem     *menuitem,
-                                        gpointer         user_data);
-
-void
-on_remove_viewer_activate              (GtkMenuItem     *menuitem,
-                                        gpointer         user_data);
-
-void
-on_trace_filter_activate              (GtkMenuItem     *menuitem,
-                                      gpointer         user_data);
-
-void
-on_trace_facility_activate              (GtkMenuItem     *menuitem,
-                                      gpointer         user_data);
-
-void
-on_load_module_activate                (GtkMenuItem     *menuitem,
-                                        gpointer         user_data);
-
-void
-on_unload_module_activate              (GtkMenuItem     *menuitem,
-                                        gpointer         user_data);
-
-void
-on_add_module_search_path_activate     (GtkMenuItem     *menuitem,
-                                        gpointer         user_data);
-
-void
-on_color_activate                      (GtkMenuItem     *menuitem,
-                                        gpointer         user_data);
-
-void
-on_filter_activate                     (GtkMenuItem     *menuitem,
-                                        gpointer         user_data);
-
-void
-on_save_configuration_activate         (GtkMenuItem     *menuitem,
-                                        gpointer         user_data);
-
-void
-on_content_activate                    (GtkMenuItem     *menuitem,
-                                        gpointer         user_data);
-
-void
-on_about_activate                      (GtkMenuItem     *menuitem,
-                                        gpointer         user_data);
-
-void
-on_button_new_clicked                  (GtkButton       *button,
-                                        gpointer         user_data);
-void
-on_button_new_tab_clicked              (GtkButton       *button,
-                                        gpointer         user_data);
-void
-on_button_open_clicked                 (GtkButton       *button,
-                                        gpointer         user_data);
-
-void
-on_button_add_trace_clicked            (GtkButton       *button,
-                                        gpointer         user_data);
-
-void
-on_button_remove_trace_clicked         (GtkButton       *button,
-                                        gpointer         user_data);
-
-void
-on_button_save_clicked                 (GtkButton       *button,
-                                        gpointer         user_data);
-
-void
-on_button_save_as_clicked              (GtkButton       *button,
-                                        gpointer         user_data);
-
-void
-on_button_zoom_in_clicked              (GtkButton       *button,
-                                        gpointer         user_data);
-
-void
-on_button_zoom_out_clicked             (GtkButton       *button,
-                                        gpointer         user_data);
-
-void
-on_button_zoom_extended_clicked        (GtkButton       *button,
-                                        gpointer         user_data);
-
-void
-on_button_go_to_time_clicked           (GtkButton       *button,
-                                        gpointer         user_data);
-
-void
-on_button_show_time_frame_clicked      (GtkButton       *button,
-                                        gpointer         user_data);
-
-void
-on_button_move_up_clicked              (GtkButton       *button,
-                                        gpointer         user_data);
-
-void
-on_button_move_down_clicked            (GtkButton       *button,
-                                        gpointer         user_data);
-
-void
-on_button_delete_viewer_clicked        (GtkButton       *button,
-                                        gpointer         user_data);
-
-void
-on_MWindow_destroy                     (GtkObject       *object,
-                                        gpointer         user_data);
-
-gboolean    
-on_MWindow_configure                   (GtkWidget         *widget,
-                                        GdkEventConfigure *event,
-                                        gpointer           user_data);
-
-void
-on_insert_viewer_test_activate         (GtkMenuItem     *menuitem,
-                                        gpointer         user_data);
-
-void
-insertViewTest(GtkMenuItem *menuitem, gpointer user_data);
-
-void
-on_MNotebook_switch_page               (GtkNotebook     *notebook,
-                                        GtkNotebookPage *page,
-                                        guint            page_num,
-                                        gpointer         user_data);
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/common.h b/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/common.h
deleted file mode 100644 (file)
index e41a735..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/* This file is part of the Linux Trace Toolkit viewer
- * Copyright (C) 2003-2004 Xiangxiu 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.
- */
-
-#ifndef COMMON_H
-#define COMMON_H
-
-#include <stdio.h>
-#include <ltt/ltt.h>
-#include <gtk/gtk.h>
-#include <lttvwindow/lttvfilter.h>
-
-#define MAX_NUMBER_EVENT     "MAX_NUMBER_EVENT"
-#define TRACESET_TIME_SPAN   "TRACESET_TIME_SPAN"
-
-typedef struct _MainWindow MainWindow;
-typedef struct _Tab Tab;
-
-/* constructor of the viewer */
-typedef GtkWidget * (*lttv_constructor)(MainWindow * main_window, 
-                           LttvTracesetSelector * s, char *key);
-typedef lttv_constructor view_constructor;
-
-typedef struct _TimeWindow {
-       LttTime start_time;
-       LttTime time_width;
-} TimeWindow;
-
-#endif // COMMON_H
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/gtkdirsel.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/gtkdirsel.c
deleted file mode 100644 (file)
index a52e877..0000000
+++ /dev/null
@@ -1,4064 +0,0 @@
-/* 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.
- */
-
-#include "config.h"
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#ifdef HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-#include <stdlib.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <string.h>
-#include <errno.h>
-#ifdef HAVE_PWD_H
-#include <pwd.h>
-#endif
-
-#include <glib.h>              /* Include early to get G_OS_WIN32 and
-                                * G_WITH_CYGWIN */
-
-#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
-#include <ctype.h>
-#define STRICT
-#include <windows.h>
-#undef STRICT
-#endif /* G_OS_WIN32 || G_WITH_CYGWIN */
-#ifdef G_OS_WIN32
-#include <winsock.h>           /* For gethostname */
-#endif
-
-#include "gdk/gdkkeysyms.h"
-#include <gtk/gtk.h>
-#include <lttvwindow/gtkdirsel.h>
-
-#define _(A) A
-#define WANT_HPANED 1
-
-#ifdef G_OS_WIN32
-#include <direct.h>
-#include <io.h>
-#define mkdir(p,m) _mkdir(p)
-#ifndef S_ISDIR
-#define S_ISDIR(mode) ((mode)&_S_IFDIR)
-#endif
-#endif /* G_OS_WIN32 */
-
-#ifdef G_WITH_CYGWIN
-#include <sys/cygwin.h>                /* For cygwin_conv_to_posix_path */
-#endif
-
-#define DIR_LIST_WIDTH   180
-#define DIR_LIST_HEIGHT  180
-#define FILE_LIST_WIDTH  180
-#define FILE_LIST_HEIGHT 180
-
-/* The Hurd doesn't define either PATH_MAX or MAXPATHLEN, so we put this
- * in here, since the rest of the code in the file does require some
- * fixed maximum.
- */
-#ifndef MAXPATHLEN
-#  ifdef PATH_MAX
-#    define MAXPATHLEN PATH_MAX
-#  else
-#    define MAXPATHLEN 2048
-#  endif
-#endif
-
-/* I've put this here so it doesn't get confused with the 
- * file completion interface */
-typedef struct _HistoryCallbackArg HistoryCallbackArg;
-
-struct _HistoryCallbackArg
-{
-  gchar *directory;
-  GtkWidget *menu_item;
-};
-
-
-typedef struct _CompletionState    CompletionState;
-typedef struct _CompletionDir      CompletionDir;
-typedef struct _CompletionDirSent  CompletionDirSent;
-typedef struct _CompletionDirEntry CompletionDirEntry;
-typedef struct _CompletionUserDir  CompletionUserDir;
-typedef struct _PossibleCompletion PossibleCompletion;
-
-/* Non-external file completion decls and structures */
-
-/* A contant telling PRCS how many directories to cache.  Its actually
- * kept in a list, so the geometry isn't important. */
-#define CMPL_DIRECTORY_CACHE_SIZE 10
-
-/* A constant used to determine whether a substring was an exact
- * match by first_diff_index()
- */
-#define PATTERN_MATCH -1
-#define CMPL_ERRNO_TOO_LONG ((1<<16)-1)
-#define CMPL_ERRNO_DID_NOT_CONVERT ((1<<16)-2)
-
-/* This structure contains all the useful information about a directory
- * for the purposes of filename completion.  These structures are cached
- * in the CompletionState struct.  CompletionDir's are reference counted.
- */
-struct _CompletionDirSent
-{
-  ino_t inode;
-  time_t mtime;
-  dev_t device;
-
-  gint entry_count;
-  struct _CompletionDirEntry *entries;
-};
-
-struct _CompletionDir
-{
-  CompletionDirSent *sent;
-
-  gchar *fullname;
-  gint fullname_len;
-
-  struct _CompletionDir *cmpl_parent;
-  gint cmpl_index;
-  gchar *cmpl_text;
-};
-
-/* This structure contains pairs of directory entry names with a flag saying
- * whether or not they are a valid directory.  NOTE: This information is used
- * to provide the caller with information about whether to update its completions
- * or try to open a file.  Since directories are cached by the directory mtime,
- * a symlink which points to an invalid file (which will not be a directory),
- * will not be reevaluated if that file is created, unless the containing
- * directory is touched.  I consider this case to be worth ignoring (josh).
- */
-struct _CompletionDirEntry
-{
-  gboolean is_dir;
-  gchar *entry_name;
-  gchar *sort_key;
-};
-
-struct _CompletionUserDir
-{
-  gchar *login;
-  gchar *homedir;
-};
-
-struct _PossibleCompletion
-{
-  /* accessible fields, all are accessed externally by functions
-   * declared above
-   */
-  gchar *text;
-  gint is_a_completion;
-  gboolean is_directory;
-
-  /* Private fields
-   */
-  gint text_alloc;
-};
-
-struct _CompletionState
-{
-  gint last_valid_char;
-  gchar *updated_text;
-  gint updated_text_len;
-  gint updated_text_alloc;
-  gboolean re_complete;
-
-  gchar *user_dir_name_buffer;
-  gint user_directories_len;
-
-  gchar *last_completion_text;
-
-  gint user_completion_index; /* if >= 0, currently completing ~user */
-
-  struct _CompletionDir *completion_dir; /* directory completing from */
-  struct _CompletionDir *active_completion_dir;
-
-  struct _PossibleCompletion the_completion;
-
-  struct _CompletionDir *reference_dir; /* initial directory */
-
-  GList* directory_storage;
-  GList* directory_sent_storage;
-
-  struct _CompletionUserDir *user_directories;
-};
-
-enum {
-  PROP_0,
-  PROP_SHOW_FILEOPS,
-  PROP_FILENAME,
-  PROP_SELECT_MULTIPLE
-};
-
-enum {
-  DIR_COLUMN
-};
-
-enum {
-  FILE_COLUMN
-};
-
-/* File completion functions which would be external, were they used
- * outside of this file.
- */
-
-static CompletionState*    cmpl_init_state        (void);
-static void                cmpl_free_state        (CompletionState *cmpl_state);
-static gint                cmpl_state_okay        (CompletionState* cmpl_state);
-static const gchar*        cmpl_strerror          (gint);
-
-static PossibleCompletion* cmpl_completion_matches(gchar           *text_to_complete,
-                                                  gchar          **remaining_text,
-                                                  CompletionState *cmpl_state);
-
-/* Returns a name for consideration, possibly a completion, this name
- * will be invalid after the next call to cmpl_next_completion.
- */
-static char*               cmpl_this_completion   (PossibleCompletion*);
-
-/* True if this completion matches the given text.  Otherwise, this
- * output can be used to have a list of non-completions.
- */
-static gint                cmpl_is_a_completion   (PossibleCompletion*);
-
-/* True if the completion is a directory
- */
-static gboolean            cmpl_is_directory      (PossibleCompletion*);
-
-/* Obtains the next completion, or NULL
- */
-static PossibleCompletion* cmpl_next_completion   (CompletionState*);
-
-/* Updating completions: the return value of cmpl_updated_text() will
- * be text_to_complete completed as much as possible after the most
- * recent call to cmpl_completion_matches.  For the present
- * application, this is the suggested replacement for the user's input
- * string.  You must CALL THIS AFTER ALL cmpl_text_completions have
- * been received.
- */
-static gchar*              cmpl_updated_text       (CompletionState* cmpl_state);
-
-/* After updating, to see if the completion was a directory, call
- * this.  If it was, you should consider re-calling completion_matches.
- */
-static gboolean            cmpl_updated_dir        (CompletionState* cmpl_state);
-
-/* Current location: if using file completion, return the current
- * directory, from which file completion begins.  More specifically,
- * the cwd concatenated with all exact completions up to the last
- * directory delimiter('/').
- */
-static gchar*              cmpl_reference_position (CompletionState* cmpl_state);
-
-/* backing up: if cmpl_completion_matches returns NULL, you may query
- * the index of the last completable character into cmpl_updated_text.
- */
-static gint                cmpl_last_valid_char    (CompletionState* cmpl_state);
-
-/* When the user selects a non-directory, call cmpl_completion_fullname
- * to get the full name of the selected file.
- */
-static const gchar*        cmpl_completion_fullname (const gchar*, CompletionState* cmpl_state);
-
-
-/* Directory operations. */
-static CompletionDir* open_ref_dir         (gchar* text_to_complete,
-                                           gchar** remaining_text,
-                                           CompletionState* cmpl_state);
-#if !defined(G_OS_WIN32) && !defined(G_WITH_CYGWIN)
-static gboolean       check_dir            (gchar *dir_name, 
-                                           struct stat *result, 
-                                           gboolean *stat_subdirs);
-#endif
-static CompletionDir* open_dir             (gchar* dir_name,
-                                           CompletionState* cmpl_state);
-#ifdef HAVE_PWD_H
-static CompletionDir* open_user_dir        (const gchar* text_to_complete,
-                                           CompletionState *cmpl_state);
-#endif
-static CompletionDir* open_relative_dir    (gchar* dir_name, CompletionDir* dir,
-                                           CompletionState *cmpl_state);
-static CompletionDirSent* open_new_dir     (gchar* dir_name, 
-                                           struct stat* sbuf,
-                                           gboolean stat_subdirs);
-static gint           correct_dir_fullname (CompletionDir* cmpl_dir);
-static gint           correct_parent       (CompletionDir* cmpl_dir,
-                                           struct stat *sbuf);
-#ifndef G_OS_WIN32
-static gchar*         find_parent_dir_fullname    (gchar* dirname);
-#endif
-static CompletionDir* attach_dir           (CompletionDirSent* sent,
-                                           gchar* dir_name,
-                                           CompletionState *cmpl_state);
-static void           free_dir_sent (CompletionDirSent* sent);
-static void           free_dir      (CompletionDir  *dir);
-static void           prune_memory_usage(CompletionState *cmpl_state);
-
-/* Completion operations */
-#ifdef HAVE_PWD_H
-static PossibleCompletion* attempt_homedir_completion(gchar* text_to_complete,
-                                                     CompletionState *cmpl_state);
-#endif
-static PossibleCompletion* attempt_dir_completion(CompletionState *cmpl_state);
-static CompletionDir* find_completion_dir(gchar* text_to_complete,
-                                         gchar** remaining_text,
-                                         CompletionState* cmpl_state);
-static PossibleCompletion* append_completion_text(gchar* text,
-                                                 CompletionState* cmpl_state);
-#ifdef HAVE_PWD_H
-static gint get_pwdb(CompletionState* cmpl_state);
-static gint compare_user_dir(const void* a, const void* b);
-#endif
-static gint first_diff_index(gchar* pat, gchar* text);
-static gint compare_cmpl_dir(const void* a, const void* b);
-static void update_cmpl(PossibleCompletion* poss,
-                       CompletionState* cmpl_state);
-
-static void gtk_dir_selection_class_init    (GtkDirSelectionClass *klass);
-static void gtk_dir_selection_set_property  (GObject         *object,
-                                             guint            prop_id,
-                                             const GValue    *value,
-                                             GParamSpec      *pspec);
-static void gtk_dir_selection_get_property  (GObject         *object,
-                                             guint            prop_id,
-                                             GValue          *value,
-                                             GParamSpec      *pspec);
-static void gtk_dir_selection_init          (GtkDirSelection      *filesel);
-static void gtk_dir_selection_finalize      (GObject               *object);
-static void gtk_dir_selection_destroy       (GtkObject             *object);
-static void gtk_dir_selection_map           (GtkWidget             *widget);
-static gint gtk_dir_selection_key_press     (GtkWidget             *widget,
-                                             GdkEventKey           *event,
-                                             gpointer               user_data);
-static gint gtk_dir_selection_insert_text   (GtkWidget             *widget,
-                                             const gchar           *new_text,
-                                             gint                   new_text_length,
-                                             gint                  *position,
-                                             gpointer               user_data);
-static void gtk_dir_selection_update_fileops (GtkDirSelection     *filesel);
-
-static void gtk_dir_selection_file_activate (GtkTreeView       *tree_view,
-                                             GtkTreePath       *path,
-                                             GtkTreeViewColumn *column,
-                                             gpointer           user_data);
-static void gtk_dir_selection_file_changed  (GtkTreeSelection  *selection,
-                                             gpointer           user_data);
-static void gtk_dir_selection_dir_activate  (GtkTreeView       *tree_view,
-                                             GtkTreePath       *path,
-                                             GtkTreeViewColumn *column,
-                                             gpointer           user_data);
-static void gtk_dir_selection_dir_changed  (GtkTreeSelection  *selection,
-                                             gpointer           user_data);
-static void gtk_dir_selection_populate      (GtkDirSelection      *fs,
-                                             gchar                 *rel_path,
-                                             gboolean               try_complete,
-                                             gboolean               reset_entry);
-static void gtk_dir_selection_abort         (GtkDirSelection      *fs);
-
-static void gtk_dir_selection_update_history_menu (GtkDirSelection       *fs,
-                                                   gchar                  *current_dir);
-
-static void gtk_dir_selection_create_dir  (GtkWidget *widget, gpointer data);
-static void gtk_dir_selection_delete_file (GtkWidget *widget, gpointer data);
-static void gtk_dir_selection_rename_file (GtkWidget *widget, gpointer data);
-
-static void free_selected_names (GPtrArray *names);
-
-#if !defined(G_OS_WIN32) && !defined(G_WITH_CYGWIN)
-#define compare_filenames(a, b) strcmp(a, b)
-#else
-#define compare_filenames(a, b) g_ascii_strcasecmp(a, b)
-#endif
-
-
-static GtkWindowClass *parent_class = NULL;
-
-/* Saves errno when something cmpl does fails. */
-static gint cmpl_errno;
-
-#ifdef G_WITH_CYGWIN
-/*
- * Take the path currently in the file selection
- * entry field and translate as necessary from
- * a WIN32 style to CYGWIN32 style path.  For
- * instance translate:
- * x:\somepath\file.jpg
- * to:
- * /cygdrive/x/somepath/file.jpg
- *
- * Replace the path in the selection text field.
- * Return a boolean value concerning whether a
- * translation had to be made.
- */
-static int
-translate_win32_path (GtkDirSelection *filesel)
-{
-  int updated = 0;
-  const gchar *path;
-  gchar newPath[MAX_PATH];
-
-  /*
-   * Retrieve the current path
-   */
-  path = gtk_entry_get_text (GTK_ENTRY (filesel->selection_entry));
-
-  cygwin_conv_to_posix_path (path, newPath);
-  updated = (strcmp (path, newPath) != 0);
-
-  if (updated)
-    gtk_entry_set_text (GTK_ENTRY (filesel->selection_entry), newPath);
-    
-  return updated;
-}
-#endif
-
-GType
-gtk_dir_selection_get_type (void)
-{
-  static GType file_selection_type = 0;
-
-  if (!file_selection_type)
-    {
-      static const GTypeInfo filesel_info =
-      {
-       sizeof (GtkDirSelectionClass),
-       NULL,           /* base_init */
-       NULL,           /* base_finalize */
-       (GClassInitFunc) gtk_dir_selection_class_init,
-       NULL,           /* class_finalize */
-       NULL,           /* class_data */
-       sizeof (GtkDirSelection),
-       0,              /* n_preallocs */
-       (GInstanceInitFunc) gtk_dir_selection_init,
-      };
-
-      file_selection_type =
-       g_type_register_static (GTK_TYPE_DIALOG, "GtkDirSelection",
-                               &filesel_info, 0);
-    }
-
-  return file_selection_type;
-}
-
-static void
-gtk_dir_selection_class_init (GtkDirSelectionClass *class)
-{
-  GObjectClass *gobject_class;
-  GtkObjectClass *object_class;
-  GtkWidgetClass *widget_class;
-
-  gobject_class = (GObjectClass*) class;
-  object_class = (GtkObjectClass*) class;
-  widget_class = (GtkWidgetClass*) class;
-
-  parent_class = g_type_class_peek_parent (class);
-
-  gobject_class->finalize = gtk_dir_selection_finalize;
-  gobject_class->set_property = gtk_dir_selection_set_property;
-  gobject_class->get_property = gtk_dir_selection_get_property;
-   
-  g_object_class_install_property (gobject_class,
-                                   PROP_FILENAME,
-                                   g_param_spec_string ("filename",
-                                                        _("Filename"),
-                                                        _("The currently selected filename"),
-                                                        NULL,
-                                                        G_PARAM_READABLE | G_PARAM_WRITABLE));
-  g_object_class_install_property (gobject_class,
-                                  PROP_SHOW_FILEOPS,
-                                  g_param_spec_boolean ("show_fileops",
-                                                        _("Show file operations"),
-                                                        _("Whether buttons for creating/manipulating files should be displayed"),
-                                                        FALSE,
-                                                        G_PARAM_READABLE |
-                                                        G_PARAM_WRITABLE));
-  g_object_class_install_property (gobject_class,
-                                  PROP_SELECT_MULTIPLE,
-                                  g_param_spec_boolean ("select_multiple",
-                                                        _("Select multiple"),
-                                                        _("Whether to allow multiple files to be selected"),
-                                                        FALSE,
-                                                        G_PARAM_READABLE |
-                                                        G_PARAM_WRITABLE));
-  object_class->destroy = gtk_dir_selection_destroy;
-  widget_class->map = gtk_dir_selection_map;
-}
-
-static void gtk_dir_selection_set_property (GObject         *object,
-                                            guint            prop_id,
-                                            const GValue    *value,
-                                            GParamSpec      *pspec)
-{
-  GtkDirSelection *filesel;
-
-  filesel = GTK_DIR_SELECTION (object);
-
-  switch (prop_id)
-    {
-    case PROP_FILENAME:
-      gtk_dir_selection_set_filename (filesel,
-                                       g_value_get_string (value));
-      break;
-    case PROP_SHOW_FILEOPS:
-      if (g_value_get_boolean (value))
-        gtk_dir_selection_show_fileop_buttons (filesel);
-      else
-        gtk_dir_selection_hide_fileop_buttons (filesel);
-      break;
-    case PROP_SELECT_MULTIPLE:
-      gtk_dir_selection_set_select_multiple (filesel, g_value_get_boolean (value));
-      break;
-    default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-      break;
-    }
-}
-
-static void gtk_dir_selection_get_property (GObject         *object,
-                                            guint            prop_id,
-                                            GValue          *value,
-                                            GParamSpec      *pspec)
-{
-  GtkDirSelection *filesel;
-
-  filesel = GTK_DIR_SELECTION (object);
-
-  switch (prop_id)
-    {
-    case PROP_FILENAME:
-      g_value_set_string (value,
-                          gtk_dir_selection_get_filename(filesel));
-      break;
-
-    case PROP_SHOW_FILEOPS:
-      /* This is a little bit hacky, but doing otherwise would require
-       * adding a field to the object.
-       */
-      g_value_set_boolean (value, (filesel->fileop_c_dir && 
-                                  filesel->fileop_del_file &&
-                                  filesel->fileop_ren_file));
-      break;
-    case PROP_SELECT_MULTIPLE:
-      g_value_set_boolean (value, gtk_dir_selection_get_select_multiple (filesel));
-      break;
-    default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-      break;
-    }
-}
-
-static gboolean
-grab_default (GtkWidget *widget)
-{
-  gtk_widget_grab_default (widget);
-  return FALSE;
-}
-     
-static void
-gtk_dir_selection_init (GtkDirSelection *filesel)
-{
-  GtkWidget *entry_vbox;
-  GtkWidget *label;
-  GtkWidget *list_hbox, *list_container;
-  GtkWidget *confirm_area;
-  GtkWidget *pulldown_hbox;
-  GtkWidget *scrolled_win;
-  GtkWidget *eventbox;
-  GtkWidget *spacer;
-  GtkDialog *dialog;
-
-  GtkListStore *model;
-  GtkTreeViewColumn *column;
-  
-  gtk_widget_push_composite_child ();
-
-  dialog = GTK_DIALOG (filesel);
-
-  filesel->cmpl_state = cmpl_init_state ();
-
-  /* The dialog-sized vertical box  */
-  filesel->main_vbox = dialog->vbox;
-  gtk_container_set_border_width (GTK_CONTAINER (filesel), 10);
-
-  /* The horizontal box containing create, rename etc. buttons */
-  filesel->button_area = gtk_hbutton_box_new ();
-  gtk_button_box_set_layout (GTK_BUTTON_BOX (filesel->button_area), GTK_BUTTONBOX_START);
-  gtk_box_set_spacing (GTK_BOX (filesel->button_area), 0);
-  gtk_box_pack_start (GTK_BOX (filesel->main_vbox), filesel->button_area, 
-                     FALSE, FALSE, 0);
-  gtk_widget_show (filesel->button_area);
-  
-  gtk_dir_selection_show_fileop_buttons (filesel);
-
-  /* hbox for pulldown menu */
-  pulldown_hbox = gtk_hbox_new (TRUE, 5);
-  gtk_box_pack_start (GTK_BOX (filesel->main_vbox), pulldown_hbox, FALSE, FALSE, 0);
-  gtk_widget_show (pulldown_hbox);
-  
-  /* Pulldown menu */
-  filesel->history_pulldown = gtk_option_menu_new ();
-  //  gtk_widget_show (filesel->history_pulldown);
-  //  gtk_box_pack_start (GTK_BOX (pulldown_hbox), filesel->history_pulldown, 
-  //                 FALSE, FALSE, 0);
-    
-  /*  The horizontal box containing the directory and file listboxes  */
-
-  spacer = gtk_hbox_new (FALSE, 0);
-  gtk_widget_set_size_request (spacer, -1, 5);
-  gtk_box_pack_start (GTK_BOX (filesel->main_vbox), spacer, FALSE, FALSE, 0);
-  gtk_widget_show (spacer);
-  
-  list_hbox = gtk_hbox_new (FALSE, 5);
-  gtk_box_pack_start (GTK_BOX (filesel->main_vbox), list_hbox, TRUE, TRUE, 0);
-  gtk_widget_show (list_hbox);
-  if (WANT_HPANED)
-    list_container = g_object_new (GTK_TYPE_HPANED,
-                                  "visible", TRUE,
-                                  "parent", list_hbox,
-                                  "border_width", 0,
-                                  NULL);
-  else
-    list_container = list_hbox;
-
-  spacer = gtk_hbox_new (FALSE, 0);
-  gtk_widget_set_size_request (spacer, -1, 5);
-  gtk_box_pack_start (GTK_BOX (filesel->main_vbox), spacer, FALSE, FALSE, 0);  
-  gtk_widget_show (spacer);
-  
-  /* The directories list */
-
-  model = gtk_list_store_new (1, G_TYPE_STRING);
-  filesel->dir_list = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
-  g_object_unref (model);
-
-  column = gtk_tree_view_column_new_with_attributes (_("Folders"),
-                                                    gtk_cell_renderer_text_new (),
-                                                    "text", DIR_COLUMN,
-                                                    NULL);
-  label = gtk_label_new_with_mnemonic (_("Fol_ders"));
-  gtk_label_set_mnemonic_widget (GTK_LABEL (label), filesel->dir_list);
-  gtk_widget_show (label);
-  gtk_tree_view_column_set_widget (column, label);
-  gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
-  gtk_tree_view_append_column (GTK_TREE_VIEW (filesel->dir_list), column);
-
-  gtk_widget_set_size_request (filesel->dir_list,
-                              DIR_LIST_WIDTH, DIR_LIST_HEIGHT);
-  g_signal_connect (filesel->dir_list, "row_activated",
-                   G_CALLBACK (gtk_dir_selection_dir_activate), filesel);
-  g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (filesel->dir_list)), "changed",
-                   G_CALLBACK (gtk_dir_selection_dir_changed), filesel);
-
-  /*  gtk_clist_column_titles_passive (GTK_CLIST (filesel->dir_list)); */
-
-  scrolled_win = gtk_scrolled_window_new (NULL, NULL);
-  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win), GTK_SHADOW_IN);  
-  gtk_container_add (GTK_CONTAINER (scrolled_win), filesel->dir_list);
-  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
-                                 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
-  gtk_container_set_border_width (GTK_CONTAINER (scrolled_win), 0);
-  if (GTK_IS_PANED (list_container))
-    gtk_paned_pack1 (GTK_PANED (list_container), scrolled_win, TRUE, TRUE);
-  else
-    gtk_container_add (GTK_CONTAINER (list_container), scrolled_win);
-  gtk_widget_show (filesel->dir_list);
-  gtk_widget_show (scrolled_win);
-
-  /* The files list */
-  model = gtk_list_store_new (1, G_TYPE_STRING);
-  filesel->file_list = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
-  g_object_unref (model);
-
-  column = gtk_tree_view_column_new_with_attributes (_("Files"),
-                                                    gtk_cell_renderer_text_new (),
-                                                    "text", FILE_COLUMN,
-                                                    NULL);
-  label = gtk_label_new_with_mnemonic (_("_Files"));
-  gtk_label_set_mnemonic_widget (GTK_LABEL (label), filesel->file_list);
-  gtk_widget_show (label);
-  gtk_tree_view_column_set_widget (column, label);
-  gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
-  gtk_tree_view_append_column (GTK_TREE_VIEW (filesel->file_list), column);
-
-  gtk_widget_set_size_request (filesel->file_list,
-                              FILE_LIST_WIDTH, FILE_LIST_HEIGHT);
-  g_signal_connect (filesel->file_list, "row_activated",
-                   G_CALLBACK (gtk_dir_selection_file_activate), filesel);
-  g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (filesel->file_list)), "changed",
-                   G_CALLBACK (gtk_dir_selection_file_changed), filesel);
-
-  /* gtk_clist_column_titles_passive (GTK_CLIST (filesel->file_list)); */
-
-  scrolled_win = gtk_scrolled_window_new (NULL, NULL);
-  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win), GTK_SHADOW_IN);
-  gtk_container_add (GTK_CONTAINER (scrolled_win), filesel->file_list);
-  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
-                                 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
-  gtk_container_set_border_width (GTK_CONTAINER (scrolled_win), 0);
-  //  gtk_container_add (GTK_CONTAINER (list_container), scrolled_win);
-  //  gtk_widget_show (filesel->file_list);
-  //  gtk_widget_show (scrolled_win);
-
-  /* action area for packing buttons into. */
-  filesel->action_area = gtk_hbox_new (TRUE, 0);
-  gtk_box_pack_start (GTK_BOX (filesel->main_vbox), filesel->action_area, 
-                     FALSE, FALSE, 0);
-  gtk_widget_show (filesel->action_area);
-  
-  /*  The OK/Cancel button area */
-  confirm_area = dialog->action_area;
-
-  /*  The Cancel button  */
-  filesel->cancel_button = gtk_dialog_add_button (dialog,
-                                                  GTK_STOCK_CANCEL,
-                                                  GTK_RESPONSE_CANCEL);
-  /*  The OK button  */
-  filesel->ok_button = gtk_dialog_add_button (dialog,
-                                              GTK_STOCK_OK,
-                                              GTK_RESPONSE_OK);
-  
-  gtk_widget_grab_default (filesel->ok_button);
-
-  /*  The selection entry widget  */
-  entry_vbox = gtk_vbox_new (FALSE, 2);
-  gtk_box_pack_end (GTK_BOX (filesel->main_vbox), entry_vbox, FALSE, FALSE, 2);
-  gtk_widget_show (entry_vbox);
-  
-  eventbox = gtk_event_box_new ();
-  filesel->selection_text = label = gtk_label_new ("");
-  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
-  gtk_container_add (GTK_CONTAINER (eventbox), label);
-  gtk_box_pack_start (GTK_BOX (entry_vbox), eventbox, FALSE, FALSE, 0);
-  gtk_widget_show (label);
-  gtk_widget_show (eventbox);
-
-  filesel->selection_entry = gtk_entry_new ();
-  g_signal_connect (filesel->selection_entry, "key_press_event",
-                   G_CALLBACK (gtk_dir_selection_key_press), filesel);
-  g_signal_connect (filesel->selection_entry, "insert_text",
-                   G_CALLBACK (gtk_dir_selection_insert_text), NULL);
-  g_signal_connect_swapped (filesel->selection_entry, "changed",
-                           G_CALLBACK (gtk_dir_selection_update_fileops), filesel);
-  g_signal_connect_swapped (filesel->selection_entry, "focus_in_event",
-                           G_CALLBACK (grab_default),
-                           filesel->ok_button);
-  g_signal_connect_swapped (filesel->selection_entry, "activate",
-                           G_CALLBACK (gtk_button_clicked),
-                           filesel->ok_button);
-  
-  gtk_box_pack_start (GTK_BOX (entry_vbox), filesel->selection_entry, TRUE, TRUE, 0);
-  gtk_widget_show (filesel->selection_entry);
-
-  gtk_label_set_mnemonic_widget (GTK_LABEL (filesel->selection_text),
-                                filesel->selection_entry);
-
-  if (!cmpl_state_okay (filesel->cmpl_state))
-    {
-      gchar err_buf[256];
-
-      g_snprintf (err_buf, sizeof (err_buf), _("Folder unreadable: %s"), cmpl_strerror (cmpl_errno));
-
-      gtk_label_set_text (GTK_LABEL (filesel->selection_text), err_buf);
-    }
-  else
-    {
-      gtk_dir_selection_populate (filesel, "", FALSE, TRUE);
-    }
-
-  gtk_widget_grab_focus (filesel->selection_entry);
-
-  gtk_widget_pop_composite_child ();
-}
-
-static gchar *
-uri_list_extract_first_uri (const gchar* uri_list)
-{
-  const gchar *p, *q;
-  
-  g_return_val_if_fail (uri_list != NULL, NULL);
-  
-  p = uri_list;
-  /* We don't actually try to validate the URI according to RFC
-   * 2396, or even check for allowed characters - we just ignore
-   * comments and trim whitespace off the ends.  We also
-   * allow LF delimination as well as the specified CRLF.
-   *
-   * We do allow comments like specified in RFC 2483.
-   */
-  while (p)
-    {
-      if (*p != '#')
-       {
-         while (g_ascii_isspace(*p))
-           p++;
-         
-         q = p;
-         while (*q && (*q != '\n') && (*q != '\r'))
-           q++;
-         
-         if (q > p)
-           {
-             q--;
-             while (q > p && g_ascii_isspace (*q))
-               q--;
-
-             if (q > p)
-               return g_strndup (p, q - p + 1);
-           }
-       }
-      p = strchr (p, '\n');
-      if (p)
-       p++;
-    }
-  return NULL;
-}
-
-static void
-dnd_really_drop  (GtkWidget *dialog, gint response_id, GtkDirSelection *fs)
-{
-  gchar *filename;
-  
-  if (response_id == GTK_RESPONSE_YES)
-    {
-      filename = g_object_get_data (G_OBJECT (dialog), "gtk-fs-dnd-filename");
-
-      gtk_dir_selection_set_filename (fs, filename);
-    }
-  
-  gtk_widget_destroy (dialog);
-}
-
-
-static void
-filenames_dropped (GtkWidget        *widget,
-                  GdkDragContext   *context,
-                  gint              x,
-                  gint              y,
-                  GtkSelectionData *selection_data,
-                  guint             info,
-                  guint             time)
-{
-  char *uri = NULL;
-  char *filename = NULL;
-  char *hostname;
-  char this_hostname[257];
-  int res;
-  GError *error = NULL;
-       
-  if (!selection_data->data)
-    return;
-
-  uri = uri_list_extract_first_uri ((char *)selection_data->data);
-  
-  if (!uri)
-    return;
-
-  filename = g_filename_from_uri (uri, &hostname, &error);
-  g_free (uri);
-  
-  if (!filename)
-    {
-      g_warning ("Error getting dropped filename: %s\n",
-                error->message);
-      g_error_free (error);
-      return;
-    }
-
-  res = gethostname (this_hostname, 256);
-  this_hostname[256] = 0;
-  
-  if ((hostname == NULL) ||
-      (res == 0 && strcmp (hostname, this_hostname) == 0) ||
-      (strcmp (hostname, "localhost") == 0))
-    gtk_dir_selection_set_filename (GTK_DIR_SELECTION (widget),
-                                    filename);
-  else
-    {
-      GtkWidget *dialog;
-      gchar *filename_utf8;
-
-      /* Conversion back to UTF-8 should always succeed for the result
-       * of g_filename_from_uri()
-       */
-      filename_utf8 = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL);
-      g_assert (filename_utf8);
-      
-      dialog = gtk_message_dialog_new (GTK_WINDOW (widget),
-                                      GTK_DIALOG_DESTROY_WITH_PARENT,
-                                      GTK_MESSAGE_QUESTION,
-                                      GTK_BUTTONS_YES_NO,
-                                      _("The file \"%s\" resides on another machine (called %s) and may not be available to this program.\n"
-                                        "Are you sure that you want to select it?"), filename_utf8, hostname);
-      g_free (filename_utf8);
-
-      g_object_set_data_full (G_OBJECT (dialog), "gtk-fs-dnd-filename", g_strdup (filename), g_free);
-      
-      g_signal_connect_data (dialog, "response",
-                            (GCallback) dnd_really_drop, 
-                            widget, NULL, 0);
-      
-      gtk_widget_show (dialog);
-    }
-
-  g_free (hostname);
-  g_free (filename);
-}
-
-enum
-{
-  TARGET_URILIST,
-  TARGET_UTF8_STRING,
-  TARGET_STRING,
-  TARGET_TEXT,
-  TARGET_COMPOUND_TEXT
-};
-
-
-static void
-filenames_drag_get (GtkWidget        *widget,
-                   GdkDragContext   *context,
-                   GtkSelectionData *selection_data,
-                   guint             info,
-                   guint             time,
-                   GtkDirSelection *filesel)
-{
-  const gchar *file;
-  gchar *uri_list;
-  char hostname[256];
-  int res;
-  GError *error;
-
-  file = gtk_dir_selection_get_filename (filesel);
-
-  if (file)
-    {
-      if (info == TARGET_URILIST)
-       {
-         res = gethostname (hostname, 256);
-         
-         error = NULL;
-         uri_list = g_filename_to_uri (file, (!res)?hostname:NULL, &error);
-         if (!uri_list)
-           {
-             g_warning ("Error getting filename: %s\n",
-                        error->message);
-             g_error_free (error);
-             return;
-           }
-         
-         gtk_selection_data_set (selection_data,
-                                 selection_data->target, 8,
-                                 (void *)uri_list, strlen((char *)uri_list));
-         g_free (uri_list);
-       }
-      else
-       {
-         gchar *filename_utf8 = g_filename_to_utf8 (file, -1, NULL, NULL, NULL);
-         g_assert (filename_utf8);
-         gtk_selection_data_set_text (selection_data, filename_utf8, -1);
-         g_free (filename_utf8);
-       }
-    }
-}
-
-static void
-file_selection_setup_dnd (GtkDirSelection *filesel)
-{
-  GtkWidget *eventbox;
-  static const GtkTargetEntry drop_types[] = {
-    { "text/uri-list", 0, TARGET_URILIST}
-  };
-  static gint n_drop_types = sizeof(drop_types)/sizeof(drop_types[0]);
-  static const GtkTargetEntry drag_types[] = {
-    { "text/uri-list", 0, TARGET_URILIST},
-    { "UTF8_STRING", 0, TARGET_UTF8_STRING },
-    { "STRING", 0, 0 },
-    { "TEXT",   0, 0 }, 
-    { "COMPOUND_TEXT", 0, 0 }
-  };
-  static gint n_drag_types = sizeof(drag_types)/sizeof(drag_types[0]);
-
-  gtk_drag_dest_set (GTK_WIDGET (filesel),
-                    GTK_DEST_DEFAULT_ALL,
-                    drop_types, n_drop_types,
-                    GDK_ACTION_COPY);
-
-  g_signal_connect (filesel, "drag_data_received",
-                   G_CALLBACK (filenames_dropped), NULL);
-
-  eventbox = gtk_widget_get_parent (filesel->selection_text);
-  gtk_drag_source_set (eventbox,
-                      GDK_BUTTON1_MASK,
-                      drag_types, n_drag_types,
-                      GDK_ACTION_COPY);
-
-  g_signal_connect (eventbox, "drag_data_get",
-                   G_CALLBACK (filenames_drag_get), filesel);
-}
-
-GtkWidget*
-gtk_dir_selection_new (const gchar *title)
-{
-  GtkDirSelection *filesel;
-
-  filesel = g_object_new (GTK_TYPE_DIR_SELECTION, NULL);
-  gtk_window_set_title (GTK_WINDOW (filesel), title);
-  gtk_dialog_set_has_separator (GTK_DIALOG (filesel), FALSE);
-
-  file_selection_setup_dnd (filesel);
-  
-  return GTK_WIDGET (filesel);
-}
-
-void
-gtk_dir_selection_show_fileop_buttons (GtkDirSelection *filesel)
-{
-  g_return_if_fail (GTK_IS_DIR_SELECTION (filesel));
-    
-  /* delete, create directory, and rename */
-  if (!filesel->fileop_c_dir) 
-    {
-      filesel->fileop_c_dir = gtk_button_new_with_mnemonic (_("_New Folder"));
-      g_signal_connect (filesel->fileop_c_dir, "clicked",
-                       G_CALLBACK (gtk_dir_selection_create_dir),
-                       filesel);
-      //      gtk_box_pack_start (GTK_BOX (filesel->button_area), 
-      //                         filesel->fileop_c_dir, TRUE, TRUE, 0);
-      //      gtk_widget_show (filesel->fileop_c_dir);
-    }
-       
-  if (!filesel->fileop_del_file) 
-    {
-      filesel->fileop_del_file = gtk_button_new_with_mnemonic (_("De_lete File"));
-      g_signal_connect (filesel->fileop_del_file, "clicked",
-                       G_CALLBACK (gtk_dir_selection_delete_file),
-                       filesel);
-      //      gtk_box_pack_start (GTK_BOX (filesel->button_area), 
-      //                         filesel->fileop_del_file, TRUE, TRUE, 0);
-      //      gtk_widget_show (filesel->fileop_del_file);
-    }
-
-  if (!filesel->fileop_ren_file)
-    {
-      filesel->fileop_ren_file = gtk_button_new_with_mnemonic (_("_Rename File"));
-      g_signal_connect (filesel->fileop_ren_file, "clicked",
-                       G_CALLBACK (gtk_dir_selection_rename_file),
-                       filesel);
-      //      gtk_box_pack_start (GTK_BOX (filesel->button_area), 
-      //                         filesel->fileop_ren_file, TRUE, TRUE, 0);
-      //      gtk_widget_show (filesel->fileop_ren_file);
-    }
-  
-  gtk_dir_selection_update_fileops (filesel);
-  
-  g_object_notify (G_OBJECT (filesel), "show_fileops");
-}
-
-void       
-gtk_dir_selection_hide_fileop_buttons (GtkDirSelection *filesel)
-{
-  g_return_if_fail (GTK_IS_DIR_SELECTION (filesel));
-    
-  if (filesel->fileop_ren_file)
-    {
-      gtk_widget_destroy (filesel->fileop_ren_file);
-      filesel->fileop_ren_file = NULL;
-    }
-
-  if (filesel->fileop_del_file)
-    {
-      gtk_widget_destroy (filesel->fileop_del_file);
-      filesel->fileop_del_file = NULL;
-    }
-
-  if (filesel->fileop_c_dir)
-    {
-      gtk_widget_destroy (filesel->fileop_c_dir);
-      filesel->fileop_c_dir = NULL;
-    }
-  g_object_notify (G_OBJECT (filesel), "show_fileops");
-}
-
-
-
-/**
- * gtk_dir_selection_set_filename:
- * @filesel: a #GtkDirSelection.
- * @filename:  a string to set as the default file name.
- * 
- * Sets a default path for the file requestor. If @filename includes a
- * directory path, then the requestor will open with that path as its
- * current working directory.
- *
- * The encoding of @filename is the on-disk encoding, which
- * may not be UTF-8. See g_filename_from_utf8().
- **/
-void
-gtk_dir_selection_set_filename (GtkDirSelection *filesel,
-                                const gchar      *filename)
-{
-  gchar *buf;
-  const char *name, *last_slash;
-  char *filename_utf8;
-
-  g_return_if_fail (GTK_IS_DIR_SELECTION (filesel));
-  g_return_if_fail (filename != NULL);
-
-  filename_utf8 = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL);
-  g_return_if_fail (filename_utf8 != NULL);
-
-  last_slash = strrchr (filename_utf8, G_DIR_SEPARATOR);
-
-  if (!last_slash)
-    {
-      buf = g_strdup ("");
-      name = filename_utf8;
-    }
-  else
-    {
-      buf = g_strdup (filename_utf8);
-      buf[last_slash - filename_utf8 + 1] = 0;
-      name = last_slash + 1;
-    }
-
-  gtk_dir_selection_populate (filesel, buf, FALSE, TRUE);
-
-  if (filesel->selection_entry)
-    gtk_entry_set_text (GTK_ENTRY (filesel->selection_entry), name);
-  g_free (buf);
-  g_object_notify (G_OBJECT (filesel), "filename");
-
-  g_free (filename_utf8);
-}
-
-/**
- * gtk_dir_selection_get_filename:
- * @filesel: a #GtkDirSelection
- * 
- * This function returns the selected filename in the on-disk encoding
- * (see g_filename_from_utf8()), which may or may not be the same as that
- * used by GTK+ (UTF-8). To convert to UTF-8, call g_filename_to_utf8().
- * The returned string points to a statically allocated buffer and
- * should be copied if you plan to keep it around.
- *
- * If no file is selected then the selected directory path is returned.
- * 
- * Return value: currently-selected filename in the on-disk encoding.
- **/
-G_CONST_RETURN gchar*
-gtk_dir_selection_get_filename (GtkDirSelection *filesel)
-{
-  static const gchar nothing[2] = "";
-  static gchar something[MAXPATHLEN*2];
-  char *sys_filename;
-  const char *text;
-
-  g_return_val_if_fail (GTK_IS_DIR_SELECTION (filesel), nothing);
-
-#ifdef G_WITH_CYGWIN
-  translate_win32_path (filesel);
-#endif
-  text = gtk_entry_get_text (GTK_ENTRY (filesel->selection_entry));
-  if (text)
-    {
-      sys_filename = g_filename_from_utf8 (cmpl_completion_fullname (text, filesel->cmpl_state), -1, NULL, NULL, NULL);
-      if (!sys_filename)
-       return nothing;
-      strncpy (something, sys_filename, sizeof (something));
-      g_free (sys_filename);
-      return something;
-    }
-
-  return nothing;
-}
-
-void
-gtk_dir_selection_complete (GtkDirSelection *filesel,
-                            const gchar      *pattern)
-{
-  g_return_if_fail (GTK_IS_DIR_SELECTION (filesel));
-  g_return_if_fail (pattern != NULL);
-
-  if (filesel->selection_entry)
-    gtk_entry_set_text (GTK_ENTRY (filesel->selection_entry), pattern);
-  gtk_dir_selection_populate (filesel, (gchar*) pattern, TRUE, TRUE);
-}
-
-static void
-gtk_dir_selection_destroy (GtkObject *object)
-{
-  GtkDirSelection *filesel;
-  GList *list;
-  HistoryCallbackArg *callback_arg;
-  
-  g_return_if_fail (GTK_IS_DIR_SELECTION (object));
-  
-  filesel = GTK_DIR_SELECTION (object);
-  
-  if (filesel->fileop_dialog)
-    {
-      gtk_widget_destroy (filesel->fileop_dialog);
-      filesel->fileop_dialog = NULL;
-    }
-  
-  if (filesel->history_list)
-    {
-      list = filesel->history_list;
-      while (list)
-       {
-         callback_arg = list->data;
-         g_free (callback_arg->directory);
-         g_free (callback_arg);
-         list = list->next;
-       }
-      g_list_free (filesel->history_list);
-      filesel->history_list = NULL;
-    }
-
-  if (filesel->cmpl_state)
-    {
-      cmpl_free_state (filesel->cmpl_state);
-      filesel->cmpl_state = NULL;
-    }
-  if (filesel->selected_names)
-    {
-      free_selected_names (filesel->selected_names);
-      filesel->selected_names = NULL;
-    } 
-
-  if (filesel->last_selected)
-    {
-      g_free (filesel->last_selected);
-      filesel->last_selected = NULL;
-    }
-
-  GTK_OBJECT_CLASS (parent_class)->destroy (object);
-}
-
-static void
-gtk_dir_selection_map (GtkWidget *widget)
-{
-  GtkDirSelection *filesel = GTK_DIR_SELECTION (widget);
-
-  /* Refresh the contents */
-  gtk_dir_selection_populate (filesel, "", FALSE, FALSE);
-  
-  GTK_WIDGET_CLASS (parent_class)->map (widget);
-}
-
-static void
-gtk_dir_selection_finalize (GObject *object)
-{
-  GtkDirSelection *filesel = GTK_DIR_SELECTION (object);
-
-  g_free (filesel->fileop_file);
-
-  G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-/* Begin file operations callbacks */
-
-static void
-gtk_dir_selection_fileop_error (GtkDirSelection *fs,
-                                gchar            *error_message)
-{
-  GtkWidget *dialog;
-    
-  g_return_if_fail (error_message != NULL);
-
-  /* main dialog */
-  dialog = gtk_message_dialog_new (GTK_WINDOW (fs),
-                                  GTK_DIALOG_DESTROY_WITH_PARENT,
-                                  GTK_MESSAGE_ERROR,
-                                  GTK_BUTTONS_CLOSE,
-                                  "%s", error_message);
-
-  /* yes, we free it */
-  g_free (error_message);
-
-  gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
-  g_signal_connect_swapped (dialog, "response",
-                           G_CALLBACK (gtk_widget_destroy),
-                           dialog);
-
-  gtk_widget_show (dialog);
-}
-
-static void
-gtk_dir_selection_fileop_destroy (GtkWidget *widget,
-                                  gpointer   data)
-{
-  GtkDirSelection *fs = data;
-
-  g_return_if_fail (GTK_IS_DIR_SELECTION (fs));
-  
-  fs->fileop_dialog = NULL;
-}
-
-static gboolean
-entry_is_empty (GtkEntry *entry)
-{
-  const gchar *text = gtk_entry_get_text (entry);
-  
-  return *text == '\0';
-}
-
-static void
-gtk_dir_selection_fileop_entry_changed (GtkEntry   *entry,
-                                        GtkWidget  *button)
-{
-  gtk_widget_set_sensitive (button, !entry_is_empty (entry));
-}
-
-static void
-gtk_dir_selection_create_dir_confirmed (GtkWidget *widget,
-                                        gpointer   data)
-{
-  GtkDirSelection *fs = data;
-  const gchar *dirname;
-  gchar *path;
-  gchar *full_path;
-  gchar *sys_full_path;
-  gchar *buf;
-  GError *error = NULL;
-  CompletionState *cmpl_state;
-  
-  g_return_if_fail (GTK_IS_DIR_SELECTION (fs));
-
-  dirname = gtk_entry_get_text (GTK_ENTRY (fs->fileop_entry));
-  cmpl_state = (CompletionState*) fs->cmpl_state;
-  path = cmpl_reference_position (cmpl_state);
-  
-  full_path = g_strconcat (path, G_DIR_SEPARATOR_S, dirname, NULL);
-  sys_full_path = g_filename_from_utf8 (full_path, -1, NULL, NULL, &error);
-  if (error)
-    {
-      if (g_error_matches (error, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE))
-       buf = g_strdup_printf (_("The folder name \"%s\" contains symbols that are not allowed in filenames"), dirname);
-      else
-       buf = g_strdup_printf (_("Error creating folder \"%s\": %s\n%s"), dirname, error->message,
-                              _("You probably used symbols not allowed in filenames."));
-      gtk_dir_selection_fileop_error (fs, buf);
-      g_error_free (error);
-      goto out;
-    }
-
-  if (mkdir (sys_full_path, 0755) < 0) 
-    {
-      buf = g_strdup_printf (_("Error creating folder \"%s\": %s\n"), dirname,
-                            g_strerror (errno));
-      gtk_dir_selection_fileop_error (fs, buf);
-    }
-
- out:
-  g_free (full_path);
-  g_free (sys_full_path);
-  
-  gtk_widget_destroy (fs->fileop_dialog);
-  gtk_dir_selection_populate (fs, "", FALSE, FALSE);
-}
-  
-static void
-gtk_dir_selection_create_dir (GtkWidget *widget,
-                              gpointer   data)
-{
-  GtkDirSelection *fs = data;
-  GtkWidget *label;
-  GtkWidget *dialog;
-  GtkWidget *vbox;
-  GtkWidget *button;
-
-  g_return_if_fail (GTK_IS_DIR_SELECTION (fs));
-
-  if (fs->fileop_dialog)
-    return;
-  
-  /* main dialog */
-  dialog = gtk_dialog_new ();
-  fs->fileop_dialog = dialog;
-  g_signal_connect (dialog, "destroy",
-                   G_CALLBACK (gtk_dir_selection_fileop_destroy),
-                   fs);
-  gtk_window_set_title (GTK_WINDOW (dialog), _("New Folder"));
-  gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
-  gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (fs));
-
-  /* If file dialog is grabbed, grab option dialog */
-  /* When option dialog is closed, file dialog will be grabbed again */
-  if (GTK_WINDOW (fs)->modal)
-      gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
-
-  vbox = gtk_vbox_new (FALSE, 0);
-  gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
-  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), vbox,
-                    FALSE, FALSE, 0);
-  gtk_widget_show( vbox);
-  
-  label = gtk_label_new_with_mnemonic (_("_Folder name:"));
-  gtk_misc_set_alignment(GTK_MISC (label), 0.0, 0.0);
-  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 5);
-  gtk_widget_show (label);
-
-  /*  The directory entry widget  */
-  fs->fileop_entry = gtk_entry_new ();
-  gtk_label_set_mnemonic_widget (GTK_LABEL (label), fs->fileop_entry);
-  gtk_box_pack_start (GTK_BOX (vbox), fs->fileop_entry, 
-                     TRUE, TRUE, 5);
-  GTK_WIDGET_SET_FLAGS (fs->fileop_entry, GTK_CAN_DEFAULT);
-  gtk_widget_show (fs->fileop_entry);
-  
-  /* buttons */
-  button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
-  g_signal_connect_swapped (button, "clicked",
-                           G_CALLBACK (gtk_widget_destroy),
-                           dialog);
-  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area),
-                    button, TRUE, TRUE, 0);
-  GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
-  gtk_widget_grab_default (button);
-  gtk_widget_show (button);
-
-  gtk_widget_grab_focus (fs->fileop_entry);
-
-  button = gtk_button_new_with_mnemonic (_("C_reate"));
-  gtk_widget_set_sensitive (button, FALSE);
-  g_signal_connect (button, "clicked",
-                   G_CALLBACK (gtk_dir_selection_create_dir_confirmed),
-                   fs);
-  g_signal_connect (fs->fileop_entry, "changed",
-                    G_CALLBACK (gtk_dir_selection_fileop_entry_changed),
-                   button);
-
-  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area),
-                    button, TRUE, TRUE, 0);
-  GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
-  gtk_widget_show (button);
-  
-  gtk_widget_show (dialog);
-}
-
-static void
-gtk_dir_selection_delete_dir_response (GtkDialog *dialog, 
-                                         gint       response_id,
-                                         gpointer   data)
-{
-  GtkDirSelection *fs = data;
-  CompletionState *cmpl_state;
-  gchar *path;
-  gchar *full_path;
-  gchar *sys_full_path;
-  GError *error = NULL;
-  gchar *buf;
-  
-  g_return_if_fail (GTK_IS_DIR_SELECTION (fs));
-
-  if (response_id != GTK_RESPONSE_OK)
-    {
-      gtk_widget_destroy (GTK_WIDGET (dialog));
-      return;
-    }
-
-  cmpl_state = (CompletionState*) fs->cmpl_state;
-  path = cmpl_reference_position (cmpl_state);
-  
-  full_path = g_strconcat (path, G_DIR_SEPARATOR_S, fs->fileop_file, NULL);
-  sys_full_path = g_filename_from_utf8 (full_path, -1, NULL, NULL, &error);
-  if (error)
-    {
-      if (g_error_matches (error, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE))
-       buf = g_strdup_printf (_("The filename \"%s\" contains symbols that are not allowed in filenames"),
-                              fs->fileop_file);
-      else
-       buf = g_strdup_printf (_("Error deleting file \"%s\": %s\n%s"),
-                              fs->fileop_file, error->message,
-                              _("It probably contains symbols not allowed in filenames."));
-      
-      gtk_dir_selection_fileop_error (fs, buf);
-      g_error_free (error);
-      goto out;
-    }
-
-  if (unlink (sys_full_path) < 0) 
-    {
-      buf = g_strdup_printf (_("Error deleting file \"%s\": %s"),
-                            fs->fileop_file, g_strerror (errno));
-      gtk_dir_selection_fileop_error (fs, buf);
-    }
-  
- out:
-  g_free (full_path);
-  g_free (sys_full_path);
-  
-  gtk_widget_destroy (fs->fileop_dialog);
-  gtk_dir_selection_populate (fs, "", FALSE, TRUE);
-}
-
-static void
-gtk_dir_selection_delete_file (GtkWidget *widget,
-                               gpointer   data)
-{
-  GtkDirSelection *fs = data;
-  GtkWidget *dialog;
-  const gchar *filename;
-  
-  g_return_if_fail (GTK_IS_DIR_SELECTION (fs));
-
-  if (fs->fileop_dialog)
-    return;
-
-#ifdef G_WITH_CYGWIN
-  translate_win32_path (fs);
-#endif
-
-  filename = gtk_entry_get_text (GTK_ENTRY (fs->selection_entry));
-  if (strlen (filename) < 1)
-    return;
-
-  g_free (fs->fileop_file);
-  fs->fileop_file = g_strdup (filename);
-  
-  /* main dialog */
-  fs->fileop_dialog = dialog = 
-    gtk_message_dialog_new (GTK_WINDOW (fs),
-                            GTK_WINDOW (fs)->modal ? GTK_DIALOG_MODAL : 0,
-                            GTK_MESSAGE_QUESTION,
-                            GTK_BUTTONS_NONE,
-                            _("Really delete file \"%s\" ?"), filename);
-
-  g_signal_connect (dialog, "destroy",
-                   G_CALLBACK (gtk_dir_selection_fileop_destroy),
-                   fs);
-  gtk_window_set_title (GTK_WINDOW (dialog), _("Delete File"));
-  gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
-  
-  /* buttons */
-  gtk_dialog_add_buttons (GTK_DIALOG (dialog),
-                          GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-                          GTK_STOCK_DELETE, GTK_RESPONSE_OK,
-                          NULL);
-
-  gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
-
-  g_signal_connect (dialog, "response",
-                    G_CALLBACK (gtk_dir_selection_delete_dir_response),
-                    fs);
-  
-  gtk_widget_show (dialog);
-}
-
-static void
-gtk_dir_selection_rename_dir_confirmed (GtkWidget *widget,
-                                         gpointer   data)
-{
-  GtkDirSelection *fs = data;
-  gchar *buf;
-  const gchar *file;
-  gchar *path;
-  gchar *new_filename;
-  gchar *old_filename;
-  gchar *sys_new_filename;
-  gchar *sys_old_filename;
-  CompletionState *cmpl_state;
-  GError *error = NULL;
-  
-  g_return_if_fail (GTK_IS_DIR_SELECTION (fs));
-
-  file = gtk_entry_get_text (GTK_ENTRY (fs->fileop_entry));
-  cmpl_state = (CompletionState*) fs->cmpl_state;
-  path = cmpl_reference_position (cmpl_state);
-  
-  new_filename = g_strconcat (path, G_DIR_SEPARATOR_S, file, NULL);
-  old_filename = g_strconcat (path, G_DIR_SEPARATOR_S, fs->fileop_file, NULL);
-
-  sys_new_filename = g_filename_from_utf8 (new_filename, -1, NULL, NULL, &error);
-  if (error)
-    {
-      if (g_error_matches (error, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE))
-       buf = g_strdup_printf (_("The file name \"%s\" contains symbols that are not allowed in filenames"), new_filename);
-      else
-       buf = g_strdup_printf (_("Error renaming file to \"%s\": %s\n%s"),
-                              new_filename, error->message,
-                              _("You probably used symbols not allowed in filenames."));
-      gtk_dir_selection_fileop_error (fs, buf);
-      g_error_free (error);
-      goto out1;
-    }
-
-  sys_old_filename = g_filename_from_utf8 (old_filename, -1, NULL, NULL, &error);
-  if (error)
-    {
-      if (g_error_matches (error, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE))
-       buf = g_strdup_printf (_("The file name \"%s\" contains symbols that are not allowed in filenames"), old_filename);
-      else
-       buf = g_strdup_printf (_("Error renaming file \"%s\": %s\n%s"),
-                              old_filename, error->message,
-                              _("It probably contains symbols not allowed in filenames."));
-      gtk_dir_selection_fileop_error (fs, buf);
-      g_error_free (error);
-      goto out2;
-    }
-  
-  if (rename (sys_old_filename, sys_new_filename) < 0) 
-    {
-      buf = g_strdup_printf (_("Error renaming file \"%s\" to \"%s\": %s"),
-                            sys_old_filename, sys_new_filename,
-                            g_strerror (errno));
-      gtk_dir_selection_fileop_error (fs, buf);
-      goto out2;
-    }
-  
-  gtk_dir_selection_populate (fs, "", FALSE, FALSE);
-  gtk_entry_set_text (GTK_ENTRY (fs->selection_entry), file);
-  
- out2:
-  g_free (sys_old_filename);
-
- out1:
-  g_free (new_filename);
-  g_free (old_filename);
-  g_free (sys_new_filename);
-  
-  gtk_widget_destroy (fs->fileop_dialog);
-}
-  
-static void
-gtk_dir_selection_rename_file (GtkWidget *widget,
-                               gpointer   data)
-{
-  GtkDirSelection *fs = data;
-  GtkWidget *label;
-  GtkWidget *dialog;
-  GtkWidget *vbox;
-  GtkWidget *button;
-  gchar *buf;
-  
-  g_return_if_fail (GTK_IS_DIR_SELECTION (fs));
-
-  if (fs->fileop_dialog)
-         return;
-
-  g_free (fs->fileop_file);
-  fs->fileop_file = g_strdup (gtk_entry_get_text (GTK_ENTRY (fs->selection_entry)));
-  if (strlen (fs->fileop_file) < 1)
-    return;
-  
-  /* main dialog */
-  fs->fileop_dialog = dialog = gtk_dialog_new ();
-  g_signal_connect (dialog, "destroy",
-                   G_CALLBACK (gtk_dir_selection_fileop_destroy),
-                   fs);
-  gtk_window_set_title (GTK_WINDOW (dialog), _("Rename File"));
-  gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
-  gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (fs));
-
-  /* If file dialog is grabbed, grab option dialog */
-  /* When option dialog  closed, file dialog will be grabbed again */
-  if (GTK_WINDOW (fs)->modal)
-    gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
-  
-  vbox = gtk_vbox_new (FALSE, 0);
-  gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
-  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), vbox,
-                     FALSE, FALSE, 0);
-  gtk_widget_show(vbox);
-  
-  buf = g_strdup_printf (_("Rename file \"%s\" to:"), fs->fileop_file);
-  label = gtk_label_new (buf);
-  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
-  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 5);
-  gtk_widget_show (label);
-  g_free (buf);
-
-  /* New filename entry */
-  fs->fileop_entry = gtk_entry_new ();
-  gtk_box_pack_start (GTK_BOX (vbox), fs->fileop_entry, 
-                     TRUE, TRUE, 5);
-  GTK_WIDGET_SET_FLAGS (fs->fileop_entry, GTK_CAN_DEFAULT);
-  gtk_widget_show (fs->fileop_entry);
-  
-  gtk_entry_set_text (GTK_ENTRY (fs->fileop_entry), fs->fileop_file);
-  gtk_editable_select_region (GTK_EDITABLE (fs->fileop_entry),
-                             0, strlen (fs->fileop_file));
-
-  /* buttons */
-  button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
-  g_signal_connect_swapped (button, "clicked",
-                           G_CALLBACK (gtk_widget_destroy),
-                           dialog);
-  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area),
-                     button, TRUE, TRUE, 0);
-  GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
-  gtk_widget_grab_default (button);
-  gtk_widget_show (button);
-
-  gtk_widget_grab_focus (fs->fileop_entry);
-
-  button = gtk_button_new_with_mnemonic (_("_Rename"));
-  g_signal_connect (button, "clicked",
-                   G_CALLBACK (gtk_dir_selection_rename_dir_confirmed),
-                   fs);
-  g_signal_connect (fs->fileop_entry, "changed",
-                   G_CALLBACK (gtk_dir_selection_fileop_entry_changed),
-                   button);
-
-  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area),
-                     button, TRUE, TRUE, 0);
-  GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
-  gtk_widget_show (button);
-  
-  gtk_widget_show (dialog);
-}
-
-static gint
-gtk_dir_selection_insert_text (GtkWidget   *widget,
-                               const gchar *new_text,
-                               gint         new_text_length,
-                               gint        *position,
-                               gpointer     user_data)
-{
-  gchar *filename;
-
-  filename = g_filename_from_utf8 (new_text, new_text_length, NULL, NULL, NULL);
-
-  if (!filename)
-    {
-      gdk_display_beep (gtk_widget_get_display (widget));
-      g_signal_stop_emission_by_name (widget, "insert_text");
-      return FALSE;
-    }
-  
-  g_free (filename);
-  
-  return TRUE;
-}
-
-static void
-gtk_dir_selection_update_fileops (GtkDirSelection *fs)
-{
-  gboolean sensitive;
-
-  if (!fs->selection_entry)
-    return;
-
-  sensitive = !entry_is_empty (GTK_ENTRY (fs->selection_entry));
-
-  if (fs->fileop_del_file)
-    gtk_widget_set_sensitive (fs->fileop_del_file, sensitive);
-  
-  if (fs->fileop_ren_file)
-    gtk_widget_set_sensitive (fs->fileop_ren_file, sensitive);
-}
-
-static gint
-gtk_dir_selection_key_press (GtkWidget   *widget,
-                             GdkEventKey *event,
-                             gpointer     user_data)
-{
-  GtkDirSelection *fs;
-  char *text;
-
-  g_return_val_if_fail (widget != NULL, FALSE);
-  g_return_val_if_fail (event != NULL, FALSE);
-
-  if ((event->keyval == GDK_Tab || event->keyval == GDK_KP_Tab) &&
-      (event->state & gtk_accelerator_get_default_mod_mask ()) == 0)
-    {
-      fs = GTK_DIR_SELECTION (user_data);
-#ifdef G_WITH_CYGWIN
-      translate_win32_path (fs);
-#endif
-      text = g_strdup (gtk_entry_get_text (GTK_ENTRY (fs->selection_entry)));
-
-      gtk_dir_selection_populate (fs, text, TRUE, TRUE);
-
-      g_free (text);
-
-      return TRUE;
-    }
-
-  return FALSE;
-}
-
-static void
-gtk_dir_selection_history_callback (GtkWidget *widget,
-                                    gpointer   data)
-{
-  GtkDirSelection *fs = data;
-  HistoryCallbackArg *callback_arg;
-  GList *list;
-
-  g_return_if_fail (GTK_IS_DIR_SELECTION (fs));
-
-  list = fs->history_list;
-  
-  while (list) {
-    callback_arg = list->data;
-    
-    if (callback_arg->menu_item == widget)
-      {
-       gtk_dir_selection_populate (fs, callback_arg->directory, FALSE, FALSE);
-       break;
-      }
-    
-    list = list->next;
-  }
-}
-
-static void 
-gtk_dir_selection_update_history_menu (GtkDirSelection *fs,
-                                       gchar            *current_directory)
-{
-  HistoryCallbackArg *callback_arg;
-  GtkWidget *menu_item;
-  GList *list;
-  gchar *current_dir;
-  gint dir_len;
-  gint i;
-  
-  g_return_if_fail (GTK_IS_DIR_SELECTION (fs));
-  g_return_if_fail (current_directory != NULL);
-  
-  list = fs->history_list;
-
-  if (fs->history_menu) 
-    {
-      while (list) {
-       callback_arg = list->data;
-       g_free (callback_arg->directory);
-       g_free (callback_arg);
-       list = list->next;
-      }
-      g_list_free (fs->history_list);
-      fs->history_list = NULL;
-      
-      gtk_widget_destroy (fs->history_menu);
-    }
-  
-  fs->history_menu = gtk_menu_new ();
-
-  current_dir = g_strdup (current_directory);
-
-  dir_len = strlen (current_dir);
-
-  for (i = dir_len; i >= 0; i--)
-    {
-      /* the i == dir_len is to catch the full path for the first 
-       * entry. */
-      if ( (current_dir[i] == G_DIR_SEPARATOR) || (i == dir_len))
-       {
-         /* another small hack to catch the full path */
-         if (i != dir_len) 
-                 current_dir[i + 1] = '\0';
-#ifdef G_WITH_CYGWIN
-         if (!strcmp (current_dir, "//"))
-           continue;
-#endif
-         menu_item = gtk_menu_item_new_with_label (current_dir);
-         
-         callback_arg = g_new (HistoryCallbackArg, 1);
-         callback_arg->menu_item = menu_item;
-         
-         /* since the autocompletion gets confused if you don't 
-          * supply a trailing '/' on a dir entry, set the full
-          * (current) path to "" which just refreshes the filesel */
-         if (dir_len == i)
-           {
-             callback_arg->directory = g_strdup ("");
-           }
-         else
-           {
-             callback_arg->directory = g_strdup (current_dir);
-           }
-         
-         fs->history_list = g_list_append (fs->history_list, callback_arg);
-         
-         g_signal_connect (menu_item, "activate",
-                           G_CALLBACK (gtk_dir_selection_history_callback),
-                           fs);
-         gtk_menu_shell_append (GTK_MENU_SHELL (fs->history_menu), menu_item);
-         gtk_widget_show (menu_item);
-       }
-    }
-
-  gtk_option_menu_set_menu (GTK_OPTION_MENU (fs->history_pulldown), 
-                           fs->history_menu);
-  g_free (current_dir);
-}
-
-static gchar *
-get_real_filename (gchar    *filename,
-                   gboolean  free_old)
-{
-#ifdef G_WITH_CYGWIN
-  /* Check to see if the selection was a drive selector */
-  if (isalpha (filename[0]) && (filename[1] == ':'))
-    {
-      gchar temp_filename[MAX_PATH];
-      int len;
-
-      cygwin_conv_to_posix_path (filename, temp_filename);
-
-      /* we need trailing '/'. */
-      len = strlen (temp_filename);
-      if (len > 0 && temp_filename[len-1] != '/')
-        {
-          temp_filename[len]   = '/';
-          temp_filename[len+1] = '\0';
-        }
-      
-      if (free_old)
-       g_free (filename);
-
-      return g_strdup (temp_filename);
-    }
-#endif /* G_WITH_CYGWIN */
-  return filename;
-}
-
-static void
-gtk_dir_selection_file_activate (GtkTreeView       *tree_view,
-                                 GtkTreePath       *path,
-                                 GtkTreeViewColumn *column,
-                                 gpointer           user_data)
-{
-  GtkDirSelection *fs = GTK_DIR_SELECTION (user_data);
-  GtkTreeModel *model = gtk_tree_view_get_model (tree_view);
-  GtkTreeIter iter;  
-  gchar *filename;
-  
-  gtk_tree_model_get_iter (model, &iter, path);
-  gtk_tree_model_get (model, &iter, FILE_COLUMN, &filename, -1);
-  filename = get_real_filename (filename, TRUE);
-  gtk_entry_set_text (GTK_ENTRY (fs->selection_entry), filename);
-  gtk_button_clicked (GTK_BUTTON (fs->ok_button));
-
-  g_free (filename);
-}
-
-static void
-gtk_dir_selection_dir_activate (GtkTreeView       *tree_view,
-                                GtkTreePath       *path,
-                                GtkTreeViewColumn *column,
-                                gpointer           user_data)
-{
-  GtkDirSelection *fs = GTK_DIR_SELECTION (user_data);
-  GtkTreeModel *model = gtk_tree_view_get_model (tree_view);
-  GtkTreeIter iter;
-  gchar *filename;
-
-  gtk_tree_model_get_iter (model, &iter, path);
-  gtk_tree_model_get (model, &iter, DIR_COLUMN, &filename, -1);
-  filename = get_real_filename (filename, TRUE);
-  gtk_dir_selection_populate (fs, filename, FALSE, FALSE);
-  g_free (filename);
-}
-
-#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
-
-static void
-win32_gtk_add_drives_to_dir_list (GtkListStore *model)
-{
-  gchar *textPtr;
-  gchar buffer[128];
-  char formatBuffer[128];
-  GtkTreeIter iter;
-
-  /* Get the drives string */
-  GetLogicalDriveStrings (sizeof (buffer), buffer);
-
-  /* Add the drives as necessary */
-  textPtr = buffer;
-  while (*textPtr != '\0')
-    {
-      /* Ignore floppies (?) */
-      if ((tolower (textPtr[0]) != 'a') && (tolower (textPtr[0]) != 'b'))
-       {
-         /* Build the actual displayable string */
-         g_snprintf (formatBuffer, sizeof (formatBuffer), "%c:\\", toupper (textPtr[0]));
-
-         /* Add to the list */
-         gtk_list_store_append (model, &iter);
-         gtk_list_store_set (model, &iter, DIR_COLUMN, formatBuffer, -1);
-       }
-      textPtr += (strlen (textPtr) + 1);
-    }
-}
-#endif
-
-static gchar *
-escape_underscores (const gchar *str)
-{
-  GString *result = g_string_new (NULL);
-  while (*str)
-    {
-      if (*str == '_')
-       g_string_append_c (result, '_');
-
-      g_string_append_c (result, *str);
-      str++;
-    }
-
-  return g_string_free (result, FALSE);
-}
-
-static void
-gtk_dir_selection_populate (GtkDirSelection *fs,
-                            gchar            *rel_path,
-                            gboolean          try_complete,
-                            gboolean          reset_entry)
-{
-  CompletionState *cmpl_state;
-  PossibleCompletion* poss;
-  GtkTreeIter iter;
-  GtkListStore *dir_model;
-  GtkListStore *file_model;
-  gchar* filename;
-  gchar* rem_path = rel_path;
-  gchar* sel_text;
-  gint did_recurse = FALSE;
-  gint possible_count = 0;
-  gint selection_index = -1;
-  
-  g_return_if_fail (GTK_IS_DIR_SELECTION (fs));
-
-  cmpl_state = (CompletionState*) fs->cmpl_state;
-  poss = cmpl_completion_matches (rel_path, &rem_path, cmpl_state);
-
-  if (!cmpl_state_okay (cmpl_state))
-    {
-      /* Something went wrong. */
-      gtk_dir_selection_abort (fs);
-      return;
-    }
-
-  g_assert (cmpl_state->reference_dir);
-
-  dir_model = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (fs->dir_list)));
-  file_model = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (fs->file_list)));
-
-  gtk_list_store_clear (dir_model);
-  gtk_list_store_clear (file_model);
-
-  /* Set the dir list to include ./ and ../ */
-  gtk_list_store_append (dir_model, &iter);
-  gtk_list_store_set (dir_model, &iter, DIR_COLUMN, "." G_DIR_SEPARATOR_S, -1);
-  gtk_list_store_append (dir_model, &iter);
-  gtk_list_store_set (dir_model, &iter, DIR_COLUMN, ".." G_DIR_SEPARATOR_S, -1);
-
-  while (poss)
-    {
-      if (cmpl_is_a_completion (poss))
-        {
-          possible_count += 1;
-
-          filename = cmpl_this_completion (poss);
-
-          if (cmpl_is_directory (poss))
-            {
-              if (strcmp (filename, "." G_DIR_SEPARATOR_S) != 0 &&
-                  strcmp (filename, ".." G_DIR_SEPARATOR_S) != 0)
-               {
-                 gtk_list_store_append (dir_model, &iter);
-                 gtk_list_store_set (dir_model, &iter, DIR_COLUMN, filename, -1);
-               }
-           }
-          else
-           {
-             gtk_list_store_append (file_model, &iter);
-             gtk_list_store_set (file_model, &iter, DIR_COLUMN, filename, -1);
-            }
-       }
-
-      poss = cmpl_next_completion (cmpl_state);
-    }
-
-#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
-  /* For Windows, add drives as potential selections */
-  win32_gtk_add_drives_to_dir_list (dir_model);
-#endif
-
-  /* File lists are set. */
-
-  g_assert (cmpl_state->reference_dir);
-
-  if (try_complete)
-    {
-
-      /* User is trying to complete filenames, so advance the user's input
-       * string to the updated_text, which is the common leading substring
-       * of all possible completions, and if its a directory attempt
-       * attempt completions in it. */
-
-      if (cmpl_updated_text (cmpl_state)[0])
-        {
-
-          if (cmpl_updated_dir (cmpl_state))
-            {
-             gchar* dir_name = g_strdup (cmpl_updated_text (cmpl_state));
-
-              did_recurse = TRUE;
-
-              gtk_dir_selection_populate (fs, dir_name, TRUE, TRUE);
-
-              g_free (dir_name);
-            }
-          else
-            {
-             if (fs->selection_entry)
-                     gtk_entry_set_text (GTK_ENTRY (fs->selection_entry),
-                                         cmpl_updated_text (cmpl_state));
-            }
-        }
-      else
-        {
-          selection_index = cmpl_last_valid_char (cmpl_state) -
-                            (strlen (rel_path) - strlen (rem_path));
-         if (fs->selection_entry)
-           gtk_entry_set_text (GTK_ENTRY (fs->selection_entry), rem_path);
-        }
-    }
-  else if (reset_entry)
-    {
-      if (fs->selection_entry)
-       gtk_entry_set_text (GTK_ENTRY (fs->selection_entry), "");
-    }
-
-  if (!did_recurse)
-    {
-      if (fs->selection_entry)
-       gtk_editable_set_position (GTK_EDITABLE (fs->selection_entry),
-                                  selection_index);
-
-      if (fs->selection_entry)
-       {
-         char *escaped = escape_underscores (cmpl_reference_position (cmpl_state));
-         sel_text = g_strconcat (_("_Selection: "), escaped, NULL);
-         g_free (escaped);
-
-         gtk_label_set_text_with_mnemonic (GTK_LABEL (fs->selection_text), sel_text);
-         gtk_entry_set_text (GTK_ENTRY (fs->selection_entry), cmpl_reference_position (cmpl_state));
-         g_free (sel_text);
-       }
-
-      if (fs->history_pulldown) 
-       {
-         gtk_dir_selection_update_history_menu (fs, cmpl_reference_position (cmpl_state));
-       }
-      
-    }
-}
-
-static void
-gtk_dir_selection_abort (GtkDirSelection *fs)
-{
-  gchar err_buf[256];
-
-  g_snprintf (err_buf, sizeof (err_buf), _("Folder unreadable: %s"), cmpl_strerror (cmpl_errno));
-
-  /*  BEEP gdk_beep();  */
-
-  if (fs->selection_entry)
-    gtk_label_set_text (GTK_LABEL (fs->selection_text), err_buf);
-}
-
-/**
- * gtk_dir_selection_set_select_multiple:
- * @filesel: a #GtkDirSelection
- * @select_multiple: whether or not the user is allowed to select multiple
- * files in the file list.
- *
- * Sets whether the user is allowed to select multiple files in the file list.
- * Use gtk_dir_selection_get_selections () to get the list of selected files.
- **/
-void
-gtk_dir_selection_set_select_multiple (GtkDirSelection *filesel,
-                                       gboolean          select_multiple)
-{
-  GtkTreeSelection *sel;
-  GtkSelectionMode mode;
-
-  g_return_if_fail (GTK_IS_DIR_SELECTION (filesel));
-
-  sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (filesel->file_list));
-
-  mode = select_multiple ? GTK_SELECTION_MULTIPLE : GTK_SELECTION_SINGLE;
-
-  if (mode != gtk_tree_selection_get_mode (sel))
-    {
-      gtk_tree_selection_set_mode (sel, mode);
-
-      g_object_notify (G_OBJECT (filesel), "select-multiple");
-    }
-}
-
-/**
- * gtk_dir_selection_get_select_multiple:
- * @filesel: a #GtkDirSelection
- *
- * Determines whether or not the user is allowed to select multiple files in
- * the file list. See gtk_dir_selection_set_select_multiple().
- *
- * Return value: %TRUE if the user is allowed to select multiple files in the
- * file list
- **/
-gboolean
-gtk_dir_selection_get_select_multiple (GtkDirSelection *filesel)
-{
-  GtkTreeSelection *sel;
-
-  g_return_val_if_fail (GTK_IS_DIR_SELECTION (filesel), FALSE);
-
-  sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (filesel->file_list));
-  return (gtk_tree_selection_get_mode (sel) == GTK_SELECTION_MULTIPLE);
-}
-
-static void
-multiple_changed_foreach (GtkTreeModel *model,
-                         GtkTreePath  *path,
-                         GtkTreeIter  *iter,
-                         gpointer      data)
-{
-  GPtrArray *names = data;
-  gchar *filename;
-
-  gtk_tree_model_get (model, iter, FILE_COLUMN, &filename, -1);
-
-  g_ptr_array_add (names, filename);
-}
-
-static void
-free_selected_names (GPtrArray *names)
-{
-  gint i;
-
-  for (i = 0; i < names->len; i++)
-    g_free (g_ptr_array_index (names, i));
-
-  g_ptr_array_free (names, TRUE);
-}
-
-static void
-gtk_dir_selection_file_changed (GtkTreeSelection *selection,
-                                gpointer          user_data)
-{
-  GtkDirSelection *fs = GTK_DIR_SELECTION (user_data);
-  GPtrArray *new_names;
-  gchar *filename;
-  const gchar *entry;
-  gint index = -1;
-
-  new_names = g_ptr_array_sized_new (8);
-
-  gtk_tree_selection_selected_foreach (selection,
-                                      multiple_changed_foreach,
-                                      new_names);
-
-  /* nothing selected */
-  if (new_names->len == 0)
-    {
-      g_ptr_array_free (new_names, TRUE);
-
-      if (fs->selected_names != NULL)
-       {
-         free_selected_names (fs->selected_names);
-         fs->selected_names = NULL;
-       }
-
-      goto maybe_clear_entry;
-    }
-
-  if (new_names->len != 1)
-    {
-      GPtrArray *old_names = fs->selected_names;
-
-      if (old_names != NULL)
-       {
-         /* A common case is selecting a range of files from top to bottom,
-          * so quickly check for that to avoid looping over the entire list
-          */
-         if (compare_filenames (g_ptr_array_index (old_names, old_names->len - 1),
-                                g_ptr_array_index (new_names, new_names->len - 1)) != 0)
-           index = new_names->len - 1;
-         else
-           {
-             gint i = 0, j = 0, cmp;
-
-             /* do a quick diff, stopping at the first file not in the
-              * old list
-              */
-             while (i < old_names->len && j < new_names->len)
-               {
-                 cmp = compare_filenames (g_ptr_array_index (old_names, i),
-                                          g_ptr_array_index (new_names, j));
-                 if (cmp < 0)
-                   {
-                     i++;
-                   }
-                 else if (cmp == 0)
-                   {
-                     i++;
-                     j++;
-                   }
-                 else if (cmp > 0)
-                   {
-                     index = j;
-                     break;
-                   }
-               }
-
-             /* we ran off the end of the old list */
-             if (index == -1 && i < new_names->len)
-               index = j;
-           }
-       }
-      else
-       {
-         /* A phantom anchor still exists at the point where the last item
-          * was selected, which is used for subsequent range selections.
-          * So search up from there.
-          */
-         if (fs->last_selected &&
-             compare_filenames (fs->last_selected,
-                                g_ptr_array_index (new_names, 0)) == 0)
-           index = new_names->len - 1;
-         else
-           index = 0;
-       }
-    }
-  else
-    index = 0;
-
-  if (fs->selected_names != NULL)
-    free_selected_names (fs->selected_names);
-
-  fs->selected_names = new_names;
-
-  if (index != -1)
-    {
-      if (fs->last_selected != NULL)
-       g_free (fs->last_selected);
-
-      fs->last_selected = g_strdup (g_ptr_array_index (new_names, index));
-      filename = get_real_filename (fs->last_selected, FALSE);
-
-      gtk_entry_set_text (GTK_ENTRY (fs->selection_entry), filename);
-
-      if (filename != fs->last_selected)
-       g_free (filename);
-      
-      return;
-    }
-  
-maybe_clear_entry:
-
-  entry = gtk_entry_get_text (GTK_ENTRY (fs->selection_entry));
-  if ((entry != NULL) && (fs->last_selected != NULL) &&
-      (compare_filenames (entry, fs->last_selected) == 0))
-    gtk_entry_set_text (GTK_ENTRY (fs->selection_entry), "");
-}
-
-static void
-gtk_dir_selection_dir_changed (GtkTreeSelection *selection,
-                                gpointer          user_data)
-{
-  GtkDirSelection *fs = GTK_DIR_SELECTION (user_data);
-  GPtrArray *new_names;
-  gchar *filename;
-  const gchar *entry;
-  gint index = -1;
-
-  new_names = g_ptr_array_sized_new (8);
-
-  gtk_tree_selection_selected_foreach (selection,
-                                      multiple_changed_foreach,
-                                      new_names);
-
-  /* nothing selected */
-  if (new_names->len == 0)
-    {
-      g_ptr_array_free (new_names, TRUE);
-
-      if (fs->selected_names != NULL)
-       {
-         free_selected_names (fs->selected_names);
-         fs->selected_names = NULL;
-       }
-
-      goto maybe_clear_entry;
-    }
-
-  if (new_names->len != 1)
-    {
-      GPtrArray *old_names = fs->selected_names;
-
-      if (old_names != NULL)
-       {
-         /* A common case is selecting a range of files from top to bottom,
-          * so quickly check for that to avoid looping over the entire list
-          */
-         if (compare_filenames (g_ptr_array_index (old_names, old_names->len - 1),
-                                g_ptr_array_index (new_names, new_names->len - 1)) != 0)
-           index = new_names->len - 1;
-         else
-           {
-             gint i = 0, j = 0, cmp;
-
-             /* do a quick diff, stopping at the first file not in the
-              * old list
-              */
-             while (i < old_names->len && j < new_names->len)
-               {
-                 cmp = compare_filenames (g_ptr_array_index (old_names, i),
-                                          g_ptr_array_index (new_names, j));
-                 if (cmp < 0)
-                   {
-                     i++;
-                   }
-                 else if (cmp == 0)
-                   {
-                     i++;
-                     j++;
-                   }
-                 else if (cmp > 0)
-                   {
-                     index = j;
-                     break;
-                   }
-               }
-
-             /* we ran off the end of the old list */
-             if (index == -1 && i < new_names->len)
-               index = j;
-           }
-       }
-      else
-       {
-         /* A phantom anchor still exists at the point where the last item
-          * was selected, which is used for subsequent range selections.
-          * So search up from there.
-          */
-         if (fs->last_selected &&
-             compare_filenames (fs->last_selected,
-                                g_ptr_array_index (new_names, 0)) == 0)
-           index = new_names->len - 1;
-         else
-           index = 0;
-       }
-    }
-  else
-    index = 0;
-
-  if (fs->selected_names != NULL)
-    free_selected_names (fs->selected_names);
-
-  fs->selected_names = new_names;
-
-  if (index != -1)
-    {
-      const gchar * err;
-      gchar str[256];
-      err = gtk_label_get_text (GTK_LABEL (fs->selection_text));
-      err += 11;  //pass over "Selection: "
-      sprintf(str,"%s\0",err);
-      
-      
-      if (fs->last_selected != NULL)
-       g_free (fs->last_selected);
-
-      fs->last_selected = g_strdup (g_ptr_array_index (new_names, index));
-      filename = get_real_filename (fs->last_selected, FALSE);
-      
-      strcat(str,"/");
-      strcat(str,filename);
-      str[strlen(str)-1] = '\0';
-
-      gtk_entry_set_text (GTK_ENTRY (fs->selection_entry), str);
-
-      if (filename != fs->last_selected)
-       g_free (filename);
-      
-      return;
-    }
-  
-maybe_clear_entry:
-
-  entry = gtk_entry_get_text (GTK_ENTRY (fs->selection_entry));
-  if ((entry != NULL) && (fs->last_selected != NULL) &&
-      (compare_filenames (entry, fs->last_selected) == 0))
-    gtk_entry_set_text (GTK_ENTRY (fs->selection_entry), "");
-}
-
-/**
- * gtk_dir_selection_get_selections:
- * @filesel: a #GtkDirSelection
- *
- * Retrieves the list of file selections the user has made in the dialog box.
- * This function is intended for use when the user can select multiple files
- * in the file list. The first file in the list is equivalent to what
- * gtk_dir_selection_get_filename() would return.
- *
- * The filenames are in the encoding of g_filename_from_utf8(), which may or 
- * may not be the same as that used by GTK+ (UTF-8). To convert to UTF-8, call
- * g_filename_to_utf8() on each string.
- *
- * Return value: a newly-allocated %NULL-terminated array of strings. Use
- * g_strfreev() to free it.
- **/
-gchar **
-gtk_dir_selection_get_selections (GtkDirSelection *filesel)
-{
-  GPtrArray *names;
-  gchar **selections;
-  gchar *filename, *dirname;
-  gchar *current, *buf;
-  gint i, count;
-  gboolean unselected_entry;
-
-  g_return_val_if_fail (GTK_IS_DIR_SELECTION (filesel), NULL);
-
-  filename = g_strdup (gtk_dir_selection_get_filename (filesel));
-
-  if (strlen (filename) == 0)
-    {
-      g_free (filename);
-      return NULL;
-    }
-
-  names = filesel->selected_names;
-
-  if (names != NULL)
-    selections = g_new (gchar *, names->len + 2);
-  else
-    selections = g_new (gchar *, 2);
-
-  count = 0;
-  unselected_entry = TRUE;
-
-  if (names != NULL)
-    {
-      dirname = g_path_get_dirname (filename);
-
-      for (i = 0; i < names->len; i++)
-       {
-         buf = g_filename_from_utf8 (g_ptr_array_index (names, i), -1,
-                                     NULL, NULL, NULL);
-         current = g_build_filename (dirname, buf, NULL);
-         g_free (buf);
-
-         selections[count++] = current;
-
-         if (unselected_entry && compare_filenames (current, filename) == 0)
-           unselected_entry = FALSE;
-       }
-
-      g_free (dirname);
-    }
-
-  if (unselected_entry)
-    selections[count++] = filename;
-  else
-    g_free (filename);
-
-  selections[count] = NULL;
-
-  return selections;
-}
-
-/**********************************************************************/
-/*                       External Interface                          */
-/**********************************************************************/
-
-/* The four completion state selectors
- */
-static gchar*
-cmpl_updated_text (CompletionState *cmpl_state)
-{
-  return cmpl_state->updated_text;
-}
-
-static gboolean
-cmpl_updated_dir (CompletionState *cmpl_state)
-{
-  return cmpl_state->re_complete;
-}
-
-static gchar*
-cmpl_reference_position (CompletionState *cmpl_state)
-{
-  return cmpl_state->reference_dir->fullname;
-}
-
-static gint
-cmpl_last_valid_char (CompletionState *cmpl_state)
-{
-  return cmpl_state->last_valid_char;
-}
-
-static const gchar*
-cmpl_completion_fullname (const gchar     *text,
-                         CompletionState *cmpl_state)
-{
-  static const char nothing[2] = "";
-
-  if (!cmpl_state_okay (cmpl_state))
-    {
-      return nothing;
-    }
-  else if (g_path_is_absolute (text))
-    {
-      strcpy (cmpl_state->updated_text, text);
-    }
-#ifdef HAVE_PWD_H
-  else if (text[0] == '~')
-    {
-      CompletionDir* dir;
-      char* slash;
-
-      dir = open_user_dir (text, cmpl_state);
-
-      if (!dir)
-       {
-         /* spencer says just return ~something, so
-          * for now just do it. */
-         strcpy (cmpl_state->updated_text, text);
-       }
-      else
-       {
-
-         strcpy (cmpl_state->updated_text, dir->fullname);
-
-         slash = strchr (text, G_DIR_SEPARATOR);
-
-         if (slash)
-           strcat (cmpl_state->updated_text, slash);
-       }
-    }
-#endif
-  else
-    {
-      strcpy (cmpl_state->updated_text, cmpl_state->reference_dir->fullname);
-      if (cmpl_state->updated_text[strlen (cmpl_state->updated_text) - 1] != G_DIR_SEPARATOR)
-       strcat (cmpl_state->updated_text, G_DIR_SEPARATOR_S);
-      strcat (cmpl_state->updated_text, text);
-    }
-
-  return cmpl_state->updated_text;
-}
-
-/* The three completion selectors
- */
-static gchar*
-cmpl_this_completion (PossibleCompletion* pc)
-{
-  return pc->text;
-}
-
-static gboolean
-cmpl_is_directory (PossibleCompletion* pc)
-{
-  return pc->is_directory;
-}
-
-static gint
-cmpl_is_a_completion (PossibleCompletion* pc)
-{
-  return pc->is_a_completion;
-}
-
-/**********************************************************************/
-/*                      Construction, deletion                       */
-/**********************************************************************/
-
-static CompletionState*
-cmpl_init_state (void)
-{
-  gchar *sys_getcwd_buf;
-  gchar *utf8_cwd;
-  CompletionState *new_state;
-
-  new_state = g_new (CompletionState, 1);
-
-  /* g_get_current_dir() returns a string in the "system" charset */
-  sys_getcwd_buf = g_get_current_dir ();
-  utf8_cwd = g_filename_to_utf8 (sys_getcwd_buf, -1, NULL, NULL, NULL);
-  g_free (sys_getcwd_buf);
-
-tryagain:
-
-  new_state->reference_dir = NULL;
-  new_state->completion_dir = NULL;
-  new_state->active_completion_dir = NULL;
-  new_state->directory_storage = NULL;
-  new_state->directory_sent_storage = NULL;
-  new_state->last_valid_char = 0;
-  new_state->updated_text = g_new (gchar, MAXPATHLEN);
-  new_state->updated_text_alloc = MAXPATHLEN;
-  new_state->the_completion.text = g_new (gchar, MAXPATHLEN);
-  new_state->the_completion.text_alloc = MAXPATHLEN;
-  new_state->user_dir_name_buffer = NULL;
-  new_state->user_directories = NULL;
-
-  new_state->reference_dir = open_dir (utf8_cwd, new_state);
-
-  if (!new_state->reference_dir)
-    {
-      /* Directories changing from underneath us, grumble */
-      strcpy (utf8_cwd, G_DIR_SEPARATOR_S);
-      goto tryagain;
-    }
-
-  g_free (utf8_cwd);
-  return new_state;
-}
-
-static void
-cmpl_free_dir_list (GList* dp0)
-{
-  GList *dp = dp0;
-
-  while (dp)
-    {
-      free_dir (dp->data);
-      dp = dp->next;
-    }
-
-  g_list_free (dp0);
-}
-
-static void
-cmpl_free_dir_sent_list (GList* dp0)
-{
-  GList *dp = dp0;
-
-  while (dp)
-    {
-      free_dir_sent (dp->data);
-      dp = dp->next;
-    }
-
-  g_list_free (dp0);
-}
-
-static void
-cmpl_free_state (CompletionState* cmpl_state)
-{
-  g_return_if_fail (cmpl_state != NULL);
-
-  cmpl_free_dir_list (cmpl_state->directory_storage);
-  cmpl_free_dir_sent_list (cmpl_state->directory_sent_storage);
-
-  if (cmpl_state->user_dir_name_buffer)
-    g_free (cmpl_state->user_dir_name_buffer);
-  if (cmpl_state->user_directories)
-    g_free (cmpl_state->user_directories);
-  if (cmpl_state->the_completion.text)
-    g_free (cmpl_state->the_completion.text);
-  if (cmpl_state->updated_text)
-    g_free (cmpl_state->updated_text);
-
-  g_free (cmpl_state);
-}
-
-static void
-free_dir (CompletionDir* dir)
-{
-  g_free (dir->cmpl_text);
-  g_free (dir->fullname);
-  g_free (dir);
-}
-
-static void
-free_dir_sent (CompletionDirSent* sent)
-{
-  gint i;
-  for (i = 0; i < sent->entry_count; i++)
-    {
-      g_free (sent->entries[i].entry_name);
-      g_free (sent->entries[i].sort_key);
-    }
-  g_free (sent->entries);
-  g_free (sent);
-}
-
-static void
-prune_memory_usage (CompletionState *cmpl_state)
-{
-  GList* cdsl = cmpl_state->directory_sent_storage;
-  GList* cdl = cmpl_state->directory_storage;
-  GList* cdl0 = cdl;
-  gint len = 0;
-
-  for (; cdsl && len < CMPL_DIRECTORY_CACHE_SIZE; len += 1)
-    cdsl = cdsl->next;
-
-  if (cdsl)
-    {
-      cmpl_free_dir_sent_list (cdsl->next);
-      cdsl->next = NULL;
-    }
-
-  cmpl_state->directory_storage = NULL;
-  while (cdl)
-    {
-      if (cdl->data == cmpl_state->reference_dir)
-       cmpl_state->directory_storage = g_list_prepend (NULL, cdl->data);
-      else
-       free_dir (cdl->data);
-      cdl = cdl->next;
-    }
-
-  g_list_free (cdl0);
-}
-
-/**********************************************************************/
-/*                        The main entrances.                         */
-/**********************************************************************/
-
-static PossibleCompletion*
-cmpl_completion_matches (gchar           *text_to_complete,
-                        gchar          **remaining_text,
-                        CompletionState *cmpl_state)
-{
-  gchar* first_slash;
-  PossibleCompletion *poss;
-
-  prune_memory_usage (cmpl_state);
-
-  g_assert (text_to_complete != NULL);
-
-  cmpl_state->user_completion_index = -1;
-  cmpl_state->last_completion_text = text_to_complete;
-  cmpl_state->the_completion.text[0] = 0;
-  cmpl_state->last_valid_char = 0;
-  cmpl_state->updated_text_len = -1;
-  cmpl_state->updated_text[0] = 0;
-  cmpl_state->re_complete = FALSE;
-
-#ifdef HAVE_PWD_H
-  first_slash = strchr (text_to_complete, G_DIR_SEPARATOR);
-
-  if (text_to_complete[0] == '~' && !first_slash)
-    {
-      /* Text starts with ~ and there is no slash, show all the
-       * home directory completions.
-       */
-      poss = attempt_homedir_completion (text_to_complete, cmpl_state);
-
-      update_cmpl (poss, cmpl_state);
-
-      return poss;
-    }
-#endif
-  cmpl_state->reference_dir =
-    open_ref_dir (text_to_complete, remaining_text, cmpl_state);
-
-  if (!cmpl_state->reference_dir)
-    return NULL;
-
-  cmpl_state->completion_dir =
-    find_completion_dir (*remaining_text, remaining_text, cmpl_state);
-
-  cmpl_state->last_valid_char = *remaining_text - text_to_complete;
-
-  if (!cmpl_state->completion_dir)
-    return NULL;
-
-  cmpl_state->completion_dir->cmpl_index = -1;
-  cmpl_state->completion_dir->cmpl_parent = NULL;
-  cmpl_state->completion_dir->cmpl_text = g_strdup (*remaining_text);
-
-  cmpl_state->active_completion_dir = cmpl_state->completion_dir;
-
-  cmpl_state->reference_dir = cmpl_state->completion_dir;
-
-  poss = attempt_dir_completion (cmpl_state);
-
-  update_cmpl (poss, cmpl_state);
-
-  return poss;
-}
-
-static PossibleCompletion*
-cmpl_next_completion (CompletionState* cmpl_state)
-{
-  PossibleCompletion* poss = NULL;
-
-  cmpl_state->the_completion.text[0] = 0;
-
-#ifdef HAVE_PWD_H
-  if (cmpl_state->user_completion_index >= 0)
-    poss = attempt_homedir_completion (cmpl_state->last_completion_text, cmpl_state);
-  else
-    poss = attempt_dir_completion (cmpl_state);
-#else
-  poss = attempt_dir_completion (cmpl_state);
-#endif
-
-  update_cmpl (poss, cmpl_state);
-
-  return poss;
-}
-
-/**********************************************************************/
-/*                      Directory Operations                         */
-/**********************************************************************/
-
-/* Open the directory where completion will begin from, if possible. */
-static CompletionDir*
-open_ref_dir (gchar           *text_to_complete,
-             gchar          **remaining_text,
-             CompletionState *cmpl_state)
-{
-  gchar* first_slash;
-  CompletionDir *new_dir;
-
-  first_slash = strchr (text_to_complete, G_DIR_SEPARATOR);
-
-#ifdef G_WITH_CYGWIN
-  if (text_to_complete[0] == '/' && text_to_complete[1] == '/')
-    {
-      char root_dir[5];
-      g_snprintf (root_dir, sizeof (root_dir), "//%c", text_to_complete[2]);
-
-      new_dir = open_dir (root_dir, cmpl_state);
-
-      if (new_dir) {
-       *remaining_text = text_to_complete + 4;
-      }
-    }
-#else
-  if (FALSE)
-    ;
-#endif
-#ifdef HAVE_PWD_H
-  else if (text_to_complete[0] == '~')
-    {
-      new_dir = open_user_dir (text_to_complete, cmpl_state);
-
-      if (new_dir)
-       {
-         if (first_slash)
-           *remaining_text = first_slash + 1;
-         else
-           *remaining_text = text_to_complete + strlen (text_to_complete);
-       }
-      else
-       {
-         return NULL;
-       }
-    }
-#endif
-  else if (g_path_is_absolute (text_to_complete) || !cmpl_state->reference_dir)
-    {
-      gchar *tmp = g_strdup (text_to_complete);
-      gchar *p;
-
-      p = tmp;
-      while (*p && *p != '*' && *p != '?')
-       p++;
-
-      *p = '\0';
-      p = strrchr (tmp, G_DIR_SEPARATOR);
-      if (p)
-       {
-         if (p == tmp)
-           p++;
-      
-         *p = '\0';
-
-         new_dir = open_dir (tmp, cmpl_state);
-
-         if (new_dir)
-           *remaining_text = text_to_complete + 
-             ((p == tmp + 1) ? (p - tmp) : (p + 1 - tmp));
-       }
-      else
-       {
-         /* If no possible candidates, use the cwd */
-         gchar *sys_curdir = g_get_current_dir ();
-         gchar *utf8_curdir = g_filename_to_utf8 (sys_curdir, -1, NULL, NULL, NULL);
-
-         g_free (sys_curdir);
-
-         new_dir = open_dir (utf8_curdir, cmpl_state);
-
-         if (new_dir)
-           *remaining_text = text_to_complete;
-
-         g_free (utf8_curdir);
-       }
-
-      g_free (tmp);
-    }
-  else
-    {
-      *remaining_text = text_to_complete;
-
-      new_dir = open_dir (cmpl_state->reference_dir->fullname, cmpl_state);
-    }
-
-  if (new_dir)
-    {
-      new_dir->cmpl_index = -1;
-      new_dir->cmpl_parent = NULL;
-    }
-
-  return new_dir;
-}
-
-#ifdef HAVE_PWD_H
-
-/* open a directory by user name */
-static CompletionDir*
-open_user_dir (const gchar     *text_to_complete,
-              CompletionState *cmpl_state)
-{
-  CompletionDir *result;
-  gchar *first_slash;
-  gint cmp_len;
-
-  g_assert (text_to_complete && text_to_complete[0] == '~');
-
-  first_slash = strchr (text_to_complete, G_DIR_SEPARATOR);
-
-  if (first_slash)
-    cmp_len = first_slash - text_to_complete - 1;
-  else
-    cmp_len = strlen (text_to_complete + 1);
-
-  if (!cmp_len)
-    {
-      /* ~/ */
-      const gchar *homedir = g_get_home_dir ();
-      gchar *utf8_homedir = g_filename_to_utf8 (homedir, -1, NULL, NULL, NULL);
-
-      if (utf8_homedir)
-       result = open_dir (utf8_homedir, cmpl_state);
-      else
-       result = NULL;
-      
-      g_free (utf8_homedir);
-    }
-  else
-    {
-      /* ~user/ */
-      gchar* copy = g_new (char, cmp_len + 1);
-      gchar *utf8_dir;
-      struct passwd *pwd;
-
-      strncpy (copy, text_to_complete + 1, cmp_len);
-      copy[cmp_len] = 0;
-      pwd = getpwnam (copy);
-      g_free (copy);
-      if (!pwd)
-       {
-         cmpl_errno = errno;
-         return NULL;
-       }
-      utf8_dir = g_filename_to_utf8 (pwd->pw_dir, -1, NULL, NULL, NULL);
-      result = open_dir (utf8_dir, cmpl_state);
-      g_free (utf8_dir);
-    }
-  return result;
-}
-
-#endif
-
-/* open a directory relative the the current relative directory */
-static CompletionDir*
-open_relative_dir (gchar           *dir_name,
-                  CompletionDir   *dir,
-                  CompletionState *cmpl_state)
-{
-  CompletionDir *result;
-  GString *path;
-
-  path = g_string_sized_new (dir->fullname_len + strlen (dir_name) + 10);
-  g_string_assign (path, dir->fullname);
-
-  if (dir->fullname_len > 1
-      && path->str[dir->fullname_len - 1] != G_DIR_SEPARATOR)
-    g_string_append_c (path, G_DIR_SEPARATOR);
-  g_string_append (path, dir_name);
-
-  result = open_dir (path->str, cmpl_state);
-
-  g_string_free (path, TRUE);
-
-  return result;
-}
-
-/* after the cache lookup fails, really open a new directory */
-static CompletionDirSent*
-open_new_dir (gchar       *dir_name,
-             struct stat *sbuf,
-             gboolean     stat_subdirs)
-{
-  CompletionDirSent *sent;
-  GDir *directory;
-  const char *dirent;
-  GError *error = NULL;
-  gint entry_count = 0;
-  gint n_entries = 0;
-  gint i;
-  struct stat ent_sbuf;
-  GString *path;
-  gchar *sys_dir_name;
-
-  sent = g_new (CompletionDirSent, 1);
-  sent->mtime = sbuf->st_mtime;
-  sent->inode = sbuf->st_ino;
-  sent->device = sbuf->st_dev;
-
-  path = g_string_sized_new (2*MAXPATHLEN + 10);
-
-  sys_dir_name = g_filename_from_utf8 (dir_name, -1, NULL, NULL, NULL);
-  if (!sys_dir_name)
-    {
-      cmpl_errno = CMPL_ERRNO_DID_NOT_CONVERT;
-      return NULL;
-    }
-  
-  directory = g_dir_open (sys_dir_name, 0, &error);
-  if (!directory)
-    {
-      cmpl_errno = error->code; /* ??? */
-      g_free (sys_dir_name);
-      return NULL;
-    }
-
-  while ((dirent = g_dir_read_name (directory)) != NULL)
-    entry_count++;
-
-  entry_count += 2;            /* For ".",".." */
-
-  sent->entries = g_new (CompletionDirEntry, entry_count);
-  sent->entry_count = entry_count;
-
-  g_dir_rewind (directory);
-
-  for (i = 0; i < entry_count; i += 1)
-    {
-      GError *error = NULL;
-
-      if (i == 0)
-       dirent = ".";
-      else if (i == 1)
-       dirent = "..";
-      else
-       {
-         dirent = g_dir_read_name (directory);
-         if (!dirent)          /* Directory changed */
-           break;
-       }
-
-      sent->entries[n_entries].entry_name = g_filename_to_utf8 (dirent, -1, NULL, NULL, &error);
-      if (sent->entries[n_entries].entry_name == NULL
-         || !g_utf8_validate (sent->entries[n_entries].entry_name, -1, NULL))
-       {
-         gchar *escaped_str = g_strescape (dirent, NULL);
-         g_message (_("The filename \"%s\" couldn't be converted to UTF-8 "
-                      "(try setting the environment variable G_BROKEN_FILENAMES): %s"),
-                    escaped_str,
-                    error->message ? error->message : _("Invalid Utf-8"));
-         g_free (escaped_str);
-         g_clear_error (&error);
-         continue;
-       }
-      g_clear_error (&error);
-      
-      sent->entries[n_entries].sort_key = g_utf8_collate_key (sent->entries[n_entries].entry_name, -1);
-      
-      g_string_assign (path, sys_dir_name);
-      if (path->str[path->len-1] != G_DIR_SEPARATOR)
-       {
-         g_string_append_c (path, G_DIR_SEPARATOR);
-       }
-      g_string_append (path, dirent);
-
-      if (stat_subdirs)
-       {
-         /* Here we know path->str is a "system charset" string */
-         if (stat (path->str, &ent_sbuf) >= 0 && S_ISDIR (ent_sbuf.st_mode))
-           sent->entries[n_entries].is_dir = TRUE;
-         else
-           /* stat may fail, and we don't mind, since it could be a
-            * dangling symlink. */
-           sent->entries[n_entries].is_dir = FALSE;
-       }
-      else
-       sent->entries[n_entries].is_dir = 1;
-
-      n_entries++;
-    }
-  sent->entry_count = n_entries;
-  
-  g_free (sys_dir_name);
-  g_string_free (path, TRUE);
-  qsort (sent->entries, sent->entry_count, sizeof (CompletionDirEntry), compare_cmpl_dir);
-
-  g_dir_close (directory);
-
-  return sent;
-}
-
-#if !defined(G_OS_WIN32) && !defined(G_WITH_CYGWIN)
-
-static gboolean
-check_dir (gchar       *dir_name,
-          struct stat *result,
-          gboolean    *stat_subdirs)
-{
-  /* A list of directories that we know only contain other directories.
-   * Trying to stat every file in these directories would be very
-   * expensive.
-   */
-
-  static struct {
-    gchar *name;
-    gboolean present;
-    struct stat statbuf;
-  } no_stat_dirs[] = {
-    { "/afs", FALSE, { 0 } },
-    { "/net", FALSE, { 0 } }
-  };
-
-  static const gint n_no_stat_dirs = G_N_ELEMENTS (no_stat_dirs);
-  static gboolean initialized = FALSE;
-  gchar *sys_dir_name;
-  gint i;
-
-  if (!initialized)
-    {
-      initialized = TRUE;
-      for (i = 0; i < n_no_stat_dirs; i++)
-       {
-         if (stat (no_stat_dirs[i].name, &no_stat_dirs[i].statbuf) == 0)
-           no_stat_dirs[i].present = TRUE;
-       }
-    }
-
-  sys_dir_name = g_filename_from_utf8 (dir_name, -1, NULL, NULL, NULL);
-  if (!sys_dir_name)
-    {
-      cmpl_errno = CMPL_ERRNO_DID_NOT_CONVERT;
-      return FALSE;
-    }
-  
-  if (stat (sys_dir_name, result) < 0)
-    {
-      g_free (sys_dir_name);
-      cmpl_errno = errno;
-      return FALSE;
-    }
-  g_free (sys_dir_name);
-
-  *stat_subdirs = TRUE;
-  for (i = 0; i < n_no_stat_dirs; i++)
-    {
-      if (no_stat_dirs[i].present &&
-         (no_stat_dirs[i].statbuf.st_dev == result->st_dev) &&
-         (no_stat_dirs[i].statbuf.st_ino == result->st_ino))
-       {
-         *stat_subdirs = FALSE;
-         break;
-       }
-    }
-
-  return TRUE;
-}
-
-#endif
-
-/* open a directory by absolute pathname */
-static CompletionDir*
-open_dir (gchar           *dir_name,
-         CompletionState *cmpl_state)
-{
-  struct stat sbuf;
-  gboolean stat_subdirs;
-  CompletionDirSent *sent;
-  GList* cdsl;
-
-#if !defined(G_OS_WIN32) && !defined(G_WITH_CYGWIN)
-  if (!check_dir (dir_name, &sbuf, &stat_subdirs))
-    return NULL;
-
-  cdsl = cmpl_state->directory_sent_storage;
-
-  while (cdsl)
-    {
-      sent = cdsl->data;
-
-      if (sent->inode == sbuf.st_ino &&
-         sent->mtime == sbuf.st_mtime &&
-         sent->device == sbuf.st_dev)
-       return attach_dir (sent, dir_name, cmpl_state);
-
-      cdsl = cdsl->next;
-    }
-#else
-  stat_subdirs = TRUE;
-#endif
-
-  sent = open_new_dir (dir_name, &sbuf, stat_subdirs);
-
-  if (sent)
-    {
-      cmpl_state->directory_sent_storage =
-       g_list_prepend (cmpl_state->directory_sent_storage, sent);
-
-      return attach_dir (sent, dir_name, cmpl_state);
-    }
-
-  return NULL;
-}
-
-static CompletionDir*
-attach_dir (CompletionDirSent *sent,
-           gchar             *dir_name,
-           CompletionState   *cmpl_state)
-{
-  CompletionDir* new_dir;
-
-  new_dir = g_new (CompletionDir, 1);
-
-  cmpl_state->directory_storage =
-    g_list_prepend (cmpl_state->directory_storage, new_dir);
-
-  new_dir->sent = sent;
-  new_dir->fullname = g_strdup (dir_name);
-  new_dir->fullname_len = strlen (dir_name);
-  new_dir->cmpl_text = NULL;
-
-  return new_dir;
-}
-
-static gint
-correct_dir_fullname (CompletionDir* cmpl_dir)
-{
-  gint length = strlen (cmpl_dir->fullname);
-  gchar *first_slash = strchr (cmpl_dir->fullname, G_DIR_SEPARATOR);
-  gchar *sys_filename;
-  struct stat sbuf;
-
-  /* Does it end with /. (\.) ? */
-  if (length >= 2 &&
-      strcmp (cmpl_dir->fullname + length - 2, G_DIR_SEPARATOR_S ".") == 0)
-    {
-      /* Is it just the root directory (on a drive) ? */
-      if (cmpl_dir->fullname + length - 2 == first_slash)
-       {
-         cmpl_dir->fullname[length - 1] = 0;
-         cmpl_dir->fullname_len = length - 1;
-         return TRUE;
-       }
-      else
-       {
-         cmpl_dir->fullname[length - 2] = 0;
-       }
-    }
-
-  /* Ends with /./ (\.\)? */
-  else if (length >= 3 &&
-          strcmp (cmpl_dir->fullname + length - 3,
-                  G_DIR_SEPARATOR_S "." G_DIR_SEPARATOR_S) == 0)
-    cmpl_dir->fullname[length - 2] = 0;
-
-  /* Ends with /.. (\..) ? */
-  else if (length >= 3 &&
-          strcmp (cmpl_dir->fullname + length - 3,
-                  G_DIR_SEPARATOR_S "..") == 0)
-    {
-      /* Is it just /.. (X:\..)? */
-      if (cmpl_dir->fullname + length - 3 == first_slash)
-       {
-         cmpl_dir->fullname[length - 2] = 0;
-         cmpl_dir->fullname_len = length - 2;
-         return TRUE;
-       }
-
-      sys_filename = g_filename_from_utf8 (cmpl_dir->fullname, -1, NULL, NULL, NULL);
-      if (!sys_filename)
-       {
-         cmpl_errno = CMPL_ERRNO_DID_NOT_CONVERT;
-         return FALSE;
-       }
-      
-      if (stat (sys_filename, &sbuf) < 0)
-       {
-         g_free (sys_filename);
-         cmpl_errno = errno;
-         return FALSE;
-       }
-      g_free (sys_filename);
-
-      cmpl_dir->fullname[length - 3] = 0;
-
-      if (!correct_parent (cmpl_dir, &sbuf))
-       return FALSE;
-    }
-
-  /* Ends with /../ (\..\)? */
-  else if (length >= 4 &&
-          strcmp (cmpl_dir->fullname + length - 4,
-                  G_DIR_SEPARATOR_S ".." G_DIR_SEPARATOR_S) == 0)
-    {
-      /* Is it just /../ (X:\..\)? */
-      if (cmpl_dir->fullname + length - 4 == first_slash)
-       {
-         cmpl_dir->fullname[length - 3] = 0;
-         cmpl_dir->fullname_len = length - 3;
-         return TRUE;
-       }
-
-      sys_filename = g_filename_from_utf8 (cmpl_dir->fullname, -1, NULL, NULL, NULL);
-      if (!sys_filename)
-       {
-         cmpl_errno = CMPL_ERRNO_DID_NOT_CONVERT;
-         return FALSE;
-       }
-      
-      if (stat (sys_filename, &sbuf) < 0)
-       {
-         g_free (sys_filename);
-         cmpl_errno = errno;
-         return FALSE;
-       }
-      g_free (sys_filename);
-
-      cmpl_dir->fullname[length - 4] = 0;
-
-      if (!correct_parent (cmpl_dir, &sbuf))
-       return FALSE;
-    }
-
-  cmpl_dir->fullname_len = strlen (cmpl_dir->fullname);
-
-  return TRUE;
-}
-
-static gint
-correct_parent (CompletionDir *cmpl_dir,
-               struct stat   *sbuf)
-{
-  struct stat parbuf;
-  gchar *last_slash;
-  gchar *first_slash;
-  gchar *new_name;
-  gchar *sys_filename;
-  gchar c = 0;
-
-  last_slash = strrchr (cmpl_dir->fullname, G_DIR_SEPARATOR);
-  g_assert (last_slash);
-  first_slash = strchr (cmpl_dir->fullname, G_DIR_SEPARATOR);
-
-  /* Clever (?) way to check for top-level directory that works also on
-   * Win32, where there is a drive letter and colon prefixed...
-   */
-  if (last_slash != first_slash)
-    {
-      last_slash[0] = 0;
-    }
-  else
-    {
-      c = last_slash[1];
-      last_slash[1] = 0;
-    }
-
-  sys_filename = g_filename_from_utf8 (cmpl_dir->fullname, -1, NULL, NULL, NULL);
-  if (!sys_filename)
-    {
-      cmpl_errno = CMPL_ERRNO_DID_NOT_CONVERT;
-      if (!c)
-       last_slash[0] = G_DIR_SEPARATOR;
-      return FALSE;
-    }
-  
-  if (stat (sys_filename, &parbuf) < 0)
-    {
-      g_free (sys_filename);
-      cmpl_errno = errno;
-      if (!c)
-       last_slash[0] = G_DIR_SEPARATOR;
-      return FALSE;
-    }
-  g_free (sys_filename);
-
-#ifndef G_OS_WIN32             /* No inode numbers on Win32 */
-  if (parbuf.st_ino == sbuf->st_ino && parbuf.st_dev == sbuf->st_dev)
-    /* it wasn't a link */
-    return TRUE;
-
-  if (c)
-    last_slash[1] = c;
-  else
-    last_slash[0] = G_DIR_SEPARATOR;
-
-  /* it was a link, have to figure it out the hard way */
-
-  new_name = find_parent_dir_fullname (cmpl_dir->fullname);
-
-  if (!new_name)
-    return FALSE;
-
-  g_free (cmpl_dir->fullname);
-
-  cmpl_dir->fullname = new_name;
-#endif
-
-  return TRUE;
-}
-
-#ifndef G_OS_WIN32
-
-static gchar*
-find_parent_dir_fullname (gchar* dirname)
-{
-  gchar *sys_orig_dir;
-  gchar *result;
-  gchar *sys_cwd;
-  gchar *sys_dirname;
-
-  sys_orig_dir = g_get_current_dir ();
-  sys_dirname = g_filename_from_utf8 (dirname, -1, NULL, NULL, NULL);
-  if (!sys_dirname)
-    {
-      g_free (sys_orig_dir);
-      cmpl_errno = CMPL_ERRNO_DID_NOT_CONVERT;
-      return NULL;
-    }
-  
-  if (chdir (sys_dirname) != 0 || chdir ("..") != 0)
-    {
-      cmpl_errno = errno;
-      chdir (sys_orig_dir);
-      g_free (sys_dirname);
-      g_free (sys_orig_dir);
-      return NULL;
-    }
-  g_free (sys_dirname);
-
-  sys_cwd = g_get_current_dir ();
-  result = g_filename_to_utf8 (sys_cwd, -1, NULL, NULL, NULL);
-  g_free (sys_cwd);
-
-  if (chdir (sys_orig_dir) != 0)
-    {
-      cmpl_errno = errno;
-      g_free (sys_orig_dir);
-      return NULL;
-    }
-
-  g_free (sys_orig_dir);
-  return result;
-}
-
-#endif
-
-/**********************************************************************/
-/*                        Completion Operations                       */
-/**********************************************************************/
-
-#ifdef HAVE_PWD_H
-
-static PossibleCompletion*
-attempt_homedir_completion (gchar           *text_to_complete,
-                           CompletionState *cmpl_state)
-{
-  gint index, length;
-
-  if (!cmpl_state->user_dir_name_buffer &&
-      !get_pwdb (cmpl_state))
-    return NULL;
-  length = strlen (text_to_complete) - 1;
-
-  cmpl_state->user_completion_index += 1;
-
-  while (cmpl_state->user_completion_index < cmpl_state->user_directories_len)
-    {
-      index = first_diff_index (text_to_complete + 1,
-                               cmpl_state->user_directories
-                               [cmpl_state->user_completion_index].login);
-
-      switch (index)
-       {
-       case PATTERN_MATCH:
-         break;
-       default:
-         if (cmpl_state->last_valid_char < (index + 1))
-           cmpl_state->last_valid_char = index + 1;
-         cmpl_state->user_completion_index += 1;
-         continue;
-       }
-
-      cmpl_state->the_completion.is_a_completion = 1;
-      cmpl_state->the_completion.is_directory = TRUE;
-
-      append_completion_text ("~", cmpl_state);
-
-      append_completion_text (cmpl_state->
-                             user_directories[cmpl_state->user_completion_index].login,
-                             cmpl_state);
-
-      return append_completion_text (G_DIR_SEPARATOR_S, cmpl_state);
-    }
-
-  if (text_to_complete[1]
-      || cmpl_state->user_completion_index > cmpl_state->user_directories_len)
-    {
-      cmpl_state->user_completion_index = -1;
-      return NULL;
-    }
-  else
-    {
-      cmpl_state->user_completion_index += 1;
-      cmpl_state->the_completion.is_a_completion = 1;
-      cmpl_state->the_completion.is_directory = TRUE;
-
-      return append_completion_text ("~" G_DIR_SEPARATOR_S, cmpl_state);
-    }
-}
-
-#endif
-
-#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN)
-#define FOLD(c) (tolower(c))
-#else
-#define FOLD(c) (c)
-#endif
-
-/* returns the index (>= 0) of the first differing character,
- * PATTERN_MATCH if the completion matches */
-static gint
-first_diff_index (gchar *pat,
-                 gchar *text)
-{
-  gint diff = 0;
-
-  while (*pat && *text && FOLD (*text) == FOLD (*pat))
-    {
-      pat += 1;
-      text += 1;
-      diff += 1;
-    }
-
-  if (*pat)
-    return diff;
-
-  return PATTERN_MATCH;
-}
-
-static PossibleCompletion*
-append_completion_text (gchar           *text,
-                       CompletionState *cmpl_state)
-{
-  gint len, i = 1;
-
-  if (!cmpl_state->the_completion.text)
-    return NULL;
-
-  len = strlen (text) + strlen (cmpl_state->the_completion.text) + 1;
-
-  if (cmpl_state->the_completion.text_alloc > len)
-    {
-      strcat (cmpl_state->the_completion.text, text);
-      return &cmpl_state->the_completion;
-    }
-
-  while (i < len)
-    i <<= 1;
-
-  cmpl_state->the_completion.text_alloc = i;
-
-  cmpl_state->the_completion.text = (gchar*) g_realloc (cmpl_state->the_completion.text, i);
-
-  if (!cmpl_state->the_completion.text)
-    return NULL;
-  else
-    {
-      strcat (cmpl_state->the_completion.text, text);
-      return &cmpl_state->the_completion;
-    }
-}
-
-static CompletionDir*
-find_completion_dir (gchar          *text_to_complete,
-                   gchar          **remaining_text,
-                   CompletionState *cmpl_state)
-{
-  gchar* first_slash = strchr (text_to_complete, G_DIR_SEPARATOR);
-  CompletionDir* dir = cmpl_state->reference_dir;
-  CompletionDir* next;
-  *remaining_text = text_to_complete;
-
-  while (first_slash)
-    {
-      gint len = first_slash - *remaining_text;
-      gint found = 0;
-      gchar *found_name = NULL;         /* Quiet gcc */
-      gint i;
-      gchar* pat_buf = g_new (gchar, len + 1);
-
-      strncpy (pat_buf, *remaining_text, len);
-      pat_buf[len] = 0;
-
-      for (i = 0; i < dir->sent->entry_count; i += 1)
-       {
-         if (dir->sent->entries[i].is_dir &&
-             _gtk_fnmatch (pat_buf, dir->sent->entries[i].entry_name))
-           {
-             if (found)
-               {
-                 g_free (pat_buf);
-                 return dir;
-               }
-             else
-               {
-                 found = 1;
-                 found_name = dir->sent->entries[i].entry_name;
-               }
-           }
-       }
-
-      if (!found)
-       {
-         /* Perhaps we are trying to open an automount directory */
-         found_name = pat_buf;
-       }
-
-      next = open_relative_dir (found_name, dir, cmpl_state);
-      
-      if (!next)
-       {
-         g_free (pat_buf);
-         return NULL;
-}
-      
-      next->cmpl_parent = dir;
-      
-      dir = next;
-      
-      if (!correct_dir_fullname (dir))
-       {
-         g_free (pat_buf);
-         return NULL;
-       }
-      
-      *remaining_text = first_slash + 1;
-      first_slash = strchr (*remaining_text, G_DIR_SEPARATOR);
-
-      g_free (pat_buf);
-    }
-
-  return dir;
-}
-
-static void
-update_cmpl (PossibleCompletion *poss,
-            CompletionState    *cmpl_state)
-{
-  gint cmpl_len;
-
-  if (!poss || !cmpl_is_a_completion (poss))
-    return;
-
-  cmpl_len = strlen (cmpl_this_completion (poss));
-
-  if (cmpl_state->updated_text_alloc < cmpl_len + 1)
-    {
-      cmpl_state->updated_text =
-       (gchar*)g_realloc (cmpl_state->updated_text,
-                          cmpl_state->updated_text_alloc);
-      cmpl_state->updated_text_alloc = 2*cmpl_len;
-    }
-
-  if (cmpl_state->updated_text_len < 0)
-    {
-      strcpy (cmpl_state->updated_text, cmpl_this_completion (poss));
-      cmpl_state->updated_text_len = cmpl_len;
-      cmpl_state->re_complete = cmpl_is_directory (poss);
-    }
-  else if (cmpl_state->updated_text_len == 0)
-    {
-      cmpl_state->re_complete = FALSE;
-    }
-  else
-    {
-      gint first_diff =
-       first_diff_index (cmpl_state->updated_text,
-                         cmpl_this_completion (poss));
-
-      cmpl_state->re_complete = FALSE;
-
-      if (first_diff == PATTERN_MATCH)
-       return;
-
-      if (first_diff > cmpl_state->updated_text_len)
-       strcpy (cmpl_state->updated_text, cmpl_this_completion (poss));
-
-      cmpl_state->updated_text_len = first_diff;
-      cmpl_state->updated_text[first_diff] = 0;
-    }
-}
-
-static PossibleCompletion*
-attempt_dir_completion (CompletionState *cmpl_state)
-{
-  gchar *pat_buf, *first_slash;
-  CompletionDir *dir = cmpl_state->active_completion_dir;
-
-  dir->cmpl_index += 1;
-
-  if (dir->cmpl_index == dir->sent->entry_count)
-    {
-      if (dir->cmpl_parent == NULL)
-       {
-         cmpl_state->active_completion_dir = NULL;
-
-         return NULL;
-       }
-      else
-       {
-         cmpl_state->active_completion_dir = dir->cmpl_parent;
-
-         return attempt_dir_completion (cmpl_state);
-       }
-    }
-
-  g_assert (dir->cmpl_text);
-
-  first_slash = strchr (dir->cmpl_text, G_DIR_SEPARATOR);
-
-  if (first_slash)
-    {
-      gint len = first_slash - dir->cmpl_text;
-
-      pat_buf = g_new (gchar, len + 1);
-      strncpy (pat_buf, dir->cmpl_text, len);
-      pat_buf[len] = 0;
-    }
-  else
-    {
-      gint len = strlen (dir->cmpl_text);
-
-      pat_buf = g_new (gchar, len + 2);
-      strcpy (pat_buf, dir->cmpl_text);
-      /* Don't append a * if the user entered one herself.
-       * This way one can complete *.h and don't get matches
-       * on any .help files, for instance.
-       */
-      if (strchr (pat_buf, '*') == NULL)
-       strcpy (pat_buf + len, "*");
-    }
-
-  if (first_slash)
-    {
-      if (dir->sent->entries[dir->cmpl_index].is_dir)
-       {
-         if (_gtk_fnmatch (pat_buf, dir->sent->entries[dir->cmpl_index].entry_name))
-           {
-             CompletionDir* new_dir;
-
-             new_dir = open_relative_dir (dir->sent->entries[dir->cmpl_index].entry_name,
-                                          dir, cmpl_state);
-
-             if (!new_dir)
-               {
-                 g_free (pat_buf);
-                 return NULL;
-               }
-
-             new_dir->cmpl_parent = dir;
-
-             new_dir->cmpl_index = -1;
-             new_dir->cmpl_text = g_strdup (first_slash + 1);
-
-             cmpl_state->active_completion_dir = new_dir;
-
-             g_free (pat_buf);
-             return attempt_dir_completion (cmpl_state);
-           }
-         else
-           {
-             g_free (pat_buf);
-             return attempt_dir_completion (cmpl_state);
-           }
-       }
-      else
-       {
-         g_free (pat_buf);
-         return attempt_dir_completion (cmpl_state);
-       }
-    }
-  else
-    {
-      if (dir->cmpl_parent != NULL)
-       {
-         append_completion_text (dir->fullname +
-                                 strlen (cmpl_state->completion_dir->fullname) + 1,
-                                 cmpl_state);
-         append_completion_text (G_DIR_SEPARATOR_S, cmpl_state);
-       }
-
-      append_completion_text (dir->sent->entries[dir->cmpl_index].entry_name, cmpl_state);
-
-      cmpl_state->the_completion.is_a_completion =
-       _gtk_fnmatch (pat_buf, dir->sent->entries[dir->cmpl_index].entry_name);
-
-      cmpl_state->the_completion.is_directory = dir->sent->entries[dir->cmpl_index].is_dir;
-      if (dir->sent->entries[dir->cmpl_index].is_dir)
-       append_completion_text (G_DIR_SEPARATOR_S, cmpl_state);
-
-      g_free (pat_buf);
-      return &cmpl_state->the_completion;
-    }
-}
-
-#ifdef HAVE_PWD_H
-
-static gint
-get_pwdb (CompletionState* cmpl_state)
-{
-  struct passwd *pwd_ptr;
-  gchar* buf_ptr;
-  gchar *utf8;
-  gint len = 0, i, count = 0;
-
-  if (cmpl_state->user_dir_name_buffer)
-    return TRUE;
-  setpwent ();
-
-  while ((pwd_ptr = getpwent ()) != NULL)
-    {
-      utf8 = g_filename_to_utf8 (pwd_ptr->pw_name, -1, NULL, NULL, NULL);
-      len += strlen (utf8);
-      g_free (utf8);
-      utf8 = g_filename_to_utf8 (pwd_ptr->pw_dir, -1, NULL, NULL, NULL);
-      len += strlen (utf8);
-      g_free (utf8);
-      len += 2;
-      count += 1;
-    }
-
-  setpwent ();
-
-  cmpl_state->user_dir_name_buffer = g_new (gchar, len);
-  cmpl_state->user_directories = g_new (CompletionUserDir, count);
-  cmpl_state->user_directories_len = count;
-
-  buf_ptr = cmpl_state->user_dir_name_buffer;
-
-  for (i = 0; i < count; i += 1)
-    {
-      pwd_ptr = getpwent ();
-      if (!pwd_ptr)
-       {
-         cmpl_errno = errno;
-         goto error;
-       }
-
-      utf8 = g_filename_to_utf8 (pwd_ptr->pw_name, -1, NULL, NULL, NULL);
-      strcpy (buf_ptr, utf8);
-      g_free (utf8);
-
-      cmpl_state->user_directories[i].login = buf_ptr;
-
-      buf_ptr += strlen (buf_ptr);
-      buf_ptr += 1;
-
-      utf8 = g_filename_to_utf8 (pwd_ptr->pw_dir, -1, NULL, NULL, NULL);
-      strcpy (buf_ptr, utf8);
-      g_free (utf8);
-
-      cmpl_state->user_directories[i].homedir = buf_ptr;
-
-      buf_ptr += strlen (buf_ptr);
-      buf_ptr += 1;
-    }
-
-  qsort (cmpl_state->user_directories,
-        cmpl_state->user_directories_len,
-        sizeof (CompletionUserDir),
-        compare_user_dir);
-
-  endpwent ();
-
-  return TRUE;
-
-error:
-
-  if (cmpl_state->user_dir_name_buffer)
-    g_free (cmpl_state->user_dir_name_buffer);
-  if (cmpl_state->user_directories)
-    g_free (cmpl_state->user_directories);
-
-  cmpl_state->user_dir_name_buffer = NULL;
-  cmpl_state->user_directories = NULL;
-
-  return FALSE;
-}
-
-static gint
-compare_user_dir (const void *a,
-                 const void *b)
-{
-  return strcmp ((((CompletionUserDir*)a))->login,
-                (((CompletionUserDir*)b))->login);
-}
-
-#endif
-
-static gint
-compare_cmpl_dir (const void *a,
-                 const void *b)
-{
-  
-  return strcmp (((CompletionDirEntry*)a)->sort_key,
-                (((CompletionDirEntry*)b))->sort_key);
-}
-
-static gint
-cmpl_state_okay (CompletionState* cmpl_state)
-{
-  return  cmpl_state && cmpl_state->reference_dir;
-}
-
-static const gchar*
-cmpl_strerror (gint err)
-{
-  if (err == CMPL_ERRNO_TOO_LONG)
-    return _("Name too long");
-  else if (err == CMPL_ERRNO_DID_NOT_CONVERT)
-    return _("Couldn't convert filename");
-  else
-    return g_strerror (err);
-}
-
-const gchar *    gtk_dir_selection_get_dir (GtkDirSelection *filesel)
-{
-  return     gtk_entry_get_text (GTK_ENTRY (filesel->selection_entry));
-}
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/gtkdirsel.h b/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/gtkdirsel.h
deleted file mode 100644 (file)
index 103ced2..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-/* This file is part of the Linux Trace Toolkit viewer
- * Copyright (C) 2003-2004 Xiangxiu 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.
- */
-
-
-#ifndef __GTK_DIR_SEL_H__
-#define __GTK_DIR_SEL_H__
-
-
-#include <gdk/gdk.h>
-#include <gtk/gtkdialog.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-
-#define GTK_TYPE_DIR_SELECTION            (gtk_dir_selection_get_type ())
-#define GTK_DIR_SELECTION(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_DIR_SELECTION, GtkDirSelection))
-#define GTK_DIR_SELECTION_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_DIR_SELECTION, GtkDirSelectionClass))
-#define GTK_IS_DIR_SELECTION(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_DIR_SELECTION))
-#define GTK_IS_DIR_SELECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_DIR_SELECTION))
-#define GTK_DIR_SELECTION_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_DIR_SELECTION, GtkDirSelectionClass))
-
-
-typedef struct _GtkDirSelection       GtkDirSelection;
-typedef struct _GtkDirSelectionClass  GtkDirSelectionClass;
-
-struct _GtkDirSelection
-{
-  GtkDialog parent_instance;
-
-  GtkWidget *dir_list;
-  GtkWidget *file_list;
-  GtkWidget *selection_entry;
-  GtkWidget *selection_text;
-  GtkWidget *main_vbox;
-  GtkWidget *ok_button;
-  GtkWidget *cancel_button;
-  GtkWidget *help_button;
-  GtkWidget *history_pulldown;
-  GtkWidget *history_menu;
-  GList     *history_list;
-  GtkWidget *fileop_dialog;
-  GtkWidget *fileop_entry;
-  gchar     *fileop_file;
-  gpointer   cmpl_state;
-  
-  GtkWidget *fileop_c_dir;
-  GtkWidget *fileop_del_file;
-  GtkWidget *fileop_ren_file;
-  
-  GtkWidget *button_area;
-  GtkWidget *action_area;
-
-  GPtrArray *selected_names;
-  gchar     *last_selected;
-};
-
-struct _GtkDirSelectionClass
-{
-  GtkDialogClass parent_class;
-
-  /* Padding for future expansion */
-  void (*_gtk_reserved1) (void);
-  void (*_gtk_reserved2) (void);
-  void (*_gtk_reserved3) (void);
-  void (*_gtk_reserved4) (void);
-};
-
-
-GType      gtk_dir_selection_get_type            (void) G_GNUC_CONST;
-GtkWidget* gtk_dir_selection_new                 (const gchar      *title);
-void       gtk_dir_selection_set_filename        (GtkDirSelection *filesel,
-                                                  const gchar      *filename);
-/* This function returns the selected filename in the C runtime's
- * multibyte string encoding, which may or may not be the same as that
- * used by GDK (UTF-8). To convert to UTF-8, call g_filename_to_utf8().
- * The returned string points to a statically allocated buffer and
- * should be copied away.
- */
-G_CONST_RETURN gchar* gtk_dir_selection_get_filename        (GtkDirSelection *filesel);
-
-void      gtk_dir_selection_complete             (GtkDirSelection *filesel,
-                                                  const gchar      *pattern);
-void       gtk_dir_selection_show_fileop_buttons (GtkDirSelection *filesel);
-void       gtk_dir_selection_hide_fileop_buttons (GtkDirSelection *filesel);
-
-gchar**    gtk_dir_selection_get_selections      (GtkDirSelection *filesel);
-const gchar *    gtk_dir_selection_get_dir (GtkDirSelection *filesel);
-void       gtk_dir_selection_set_select_multiple (GtkDirSelection *filesel,
-                                                  gboolean          select_multiple);
-gboolean   gtk_dir_selection_get_select_multiple (GtkDirSelection *filesel);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
-#endif /* __GTK_DIR_SEL_H__ */
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/gtkmultivpaned.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/gtkmultivpaned.c
deleted file mode 100644 (file)
index 93d87c5..0000000
+++ /dev/null
@@ -1,567 +0,0 @@
-/* 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.
- */
-
-#include <gtk/gtk.h>
-
-#include <lttvwindow/gtkmultivpaned.h>
-//#include "gtkintl.h"
-#include <lttvwindow/mainwindow.h>
-#include <lttvwindow/gtktraceset.h>
-
-static void gtk_multi_vpaned_class_init (GtkMultiVPanedClass    *klass);
-static void gtk_multi_vpaned_init       (GtkMultiVPaned         *multi_vpaned);
-
-
-static void     gtk_multi_vpaned_size_request   (GtkWidget      *widget,
-                                          GtkRequisition *requisition);
-static void     gtk_multi_vpaned_size_allocate  (GtkWidget      *widget,
-                                          GtkAllocation  *allocation);
-
-void gtk_multi_vpaned_scroll_value_changed (GtkRange *range, gpointer multi_vpaned);
-
-gboolean gtk_multi_vpaned_destroy(GtkObject       *object,
-                                  gpointer           user_data)
-{
-  GtkMultiVPaned * multi_vpaned = (GtkMultiVPaned * )object;
-  while(multi_vpaned->num_children){
-    gtk_multi_vpaned_widget_delete(multi_vpaned);
-  }    
-  return FALSE;
-}
-
-GType
-gtk_multi_vpaned_get_type (void)
-{
-  static GType multi_vpaned_type = 0;
-
-  if (!multi_vpaned_type)
-    {
-      static const GTypeInfo multi_vpaned_info =
-      {
-       sizeof (GtkMultiVPanedClass),
-       NULL,           /* base_init */
-       NULL,           /* base_finalize */
-       (GClassInitFunc) gtk_multi_vpaned_class_init,
-       NULL,           /* class_finalize */
-       NULL,           /* class_data */
-       sizeof (GtkMultiVPaned),
-       0,              /* n_preallocs */
-       (GInstanceInitFunc) gtk_multi_vpaned_init,
-       NULL,           /* value_table */
-      };
-
-      multi_vpaned_type = g_type_register_static (GTK_TYPE_PANED, "GtkMultiVPaned", 
-                                        &multi_vpaned_info, 0);
-    }
-
-  return multi_vpaned_type;
-}
-
-static void
-gtk_multi_vpaned_class_init (GtkMultiVPanedClass *class)
-{
-  GtkWidgetClass *widget_class;
-  
-  widget_class = (GtkWidgetClass *) class;
-
-  widget_class->size_request = gtk_multi_vpaned_size_request;
-  widget_class->size_allocate = gtk_multi_vpaned_size_allocate;
-}
-
-static void
-gtk_multi_vpaned_init (GtkMultiVPaned * multi_vpaned)
-{
-  GtkWidget * button;
-
-  GTK_WIDGET_SET_FLAGS (multi_vpaned, GTK_NO_WINDOW);
-  gtk_widget_set_redraw_on_allocate (GTK_WIDGET (multi_vpaned), FALSE);
-  
-  multi_vpaned->first_pane    = NULL;
-  multi_vpaned->last_pane     = NULL;
-  multi_vpaned->focused_pane  = NULL;
-  multi_vpaned->iter          = NULL;
-  multi_vpaned->num_children  = 0;
-
-  multi_vpaned->vbox         = NULL;
-  //  multi_vpaned->scrollWindow = NULL;
-  //  multi_vpaned->viewport     = NULL;
-  multi_vpaned->hscrollbar   = NULL;
-}
-
-
-GtkWidget* gtk_multi_vpaned_new ()
-{
-  GtkWidget * widget = GTK_WIDGET (g_object_new (gtk_multi_vpaned_get_type (), NULL));
-  g_signal_connect(G_OBJECT(widget), "destroy",
-                  G_CALLBACK(gtk_multi_vpaned_destroy),NULL);
-  
-  return widget;
-}
-
-GtkWidget * gtk_multi_vpaned_get_widget(GtkMultiVPaned * multi_vpaned)
-{
-  if(multi_vpaned->focused_pane == NULL)return NULL;
-  return (GtkWidget*)multi_vpaned->focused_pane->child2;
-}
-
-GtkWidget * gtk_multi_vpaned_get_first_widget(GtkMultiVPaned * multi_vpaned)
-{
-  if(multi_vpaned->first_pane == NULL)return NULL;
-  multi_vpaned->iter = multi_vpaned->first_pane;
-  return multi_vpaned->first_pane->child2;
-}
-
-GtkWidget * gtk_multi_vpaned_get_next_widget(GtkMultiVPaned * multi_vpaned)
-{
-  if(multi_vpaned->iter != multi_vpaned->last_pane){
-    multi_vpaned->iter = (GtkPaned *)multi_vpaned->iter->child1;
-    return multi_vpaned->iter->child2;
-  }else {
-    return NULL;
-  }
-}
-
-void gtk_multi_vpaned_set_data(GtkMultiVPaned * multi_vpaned,char * key, gpointer value)
-{
-  g_object_set_data(G_OBJECT(multi_vpaned->focused_pane), key, value);    
-}
-
-gpointer gtk_multi_vpaned_get_data(GtkMultiVPaned * multi_vpaned,char * key)
-{
-  if(multi_vpaned->focused_pane == NULL)return NULL;
-  return g_object_get_data(G_OBJECT(multi_vpaned->focused_pane), key);
-}
-
-void gtk_multi_vpaned_set_focus (GtkWidget * widget, gpointer user_data)
-{
-  GtkMultiVPaned * multi_vpaned = (GtkMultiVPaned*) widget;
-  GtkPaned * pane;
-  if(!multi_vpaned->first_pane) return;
-  
-
-  pane = multi_vpaned->first_pane;
-  while(1){
-    if((GtkWidget*)pane == (GtkWidget*)user_data){
-      multi_vpaned->focused_pane = pane;
-      break;
-    }
-    if(pane == multi_vpaned->last_pane){
-      multi_vpaned->focused_pane = NULL;
-      break;
-    }
-    pane = (GtkPaned*)pane->child1;
-  }
-}
-
-void gtk_multi_vpaned_set_adjust(GtkMultiVPaned * multi_vpaned, gboolean first_time)
-{
-  TimeWindow time_window;
-  TimeInterval *time_span;
-  double tmp, start;
-  double range = 0;
-
-  get_time_window(multi_vpaned->mw,&time_window);
-  if(first_time){
-    time_span = LTTV_TRACESET_CONTEXT(multi_vpaned->mw->current_tab->traceset_info->
-                                     traceset_context)->Time_Span ;
-  
-    multi_vpaned->hadjust->lower = ltt_time_to_double(time_span->startTime) * 
-                             NANOSECONDS_PER_SECOND;
-    multi_vpaned->hadjust->value = multi_vpaned->hadjust->lower;
-    multi_vpaned->hadjust->upper = ltt_time_to_double(time_span->endTime) *
-                             NANOSECONDS_PER_SECOND;
-  }
-
-  /* Page increment of whole visible area */
-  if(multi_vpaned->hadjust == NULL){
-    g_warning("Insert a viewer first");
-    return;
-  }
-
-  start = ltt_time_to_double(time_window.start_time) * NANOSECONDS_PER_SECOND;
-  tmp = multi_vpaned->hadjust->upper - multi_vpaned->hadjust->lower;
-
-  multi_vpaned->hadjust->page_increment = ltt_time_to_double(
-                       time_window.time_width) * NANOSECONDS_PER_SECOND;
-
-  if(multi_vpaned->hadjust->page_increment >= tmp - range)
-    multi_vpaned->hadjust->value = multi_vpaned->hadjust->lower;
-  if(start + multi_vpaned->hadjust->page_increment >= multi_vpaned->hadjust->upper - range)
-    multi_vpaned->hadjust->value = start;
-
-  /* page_size to the whole visible area will take care that the
-     * scroll value + the shown area will never be more than what is
-     * in the trace. */
-  multi_vpaned->hadjust->page_size = multi_vpaned->hadjust->page_increment;
-  multi_vpaned->hadjust->step_increment = multi_vpaned->hadjust->page_increment / 10;
-
-  gtk_adjustment_changed (multi_vpaned->hadjust);
-}
-
-void gtk_multi_vpaned_widget_add(GtkMultiVPaned * multi_vpaned, GtkWidget * widget1)
-{
-  GtkPaned * tmpPane; 
-  GtkWidget * w;
-  
-  g_return_if_fail(GTK_IS_MULTI_VPANED(multi_vpaned));
-  g_object_ref(G_OBJECT(widget1));
-
-  if(!multi_vpaned->first_pane){
-    multi_vpaned->first_pane = (GtkPaned *)gtk_vpaned_new();
-    multi_vpaned->last_pane = multi_vpaned->first_pane;
-
-    multi_vpaned->hscrollbar = gtk_hscrollbar_new (NULL);
-    gtk_widget_show(multi_vpaned->hscrollbar);
-
-    multi_vpaned->hadjust = gtk_range_get_adjustment(GTK_RANGE(multi_vpaned->hscrollbar));
-    gtk_multi_vpaned_set_adjust(multi_vpaned, TRUE);
-
-    gtk_range_set_update_policy (GTK_RANGE(multi_vpaned->hscrollbar),
-                                                                                                                                GTK_UPDATE_CONTINUOUS);
-                                                                                                                                //changed by Mathieu Desnoyers, was :
-                                 // GTK_UPDATE_DISCONTINUOUS);
-    g_signal_connect(G_OBJECT(multi_vpaned->hscrollbar), "value-changed",
-                    G_CALLBACK(gtk_multi_vpaned_scroll_value_changed), multi_vpaned);
-
-    multi_vpaned->vbox = gtk_vbox_new(FALSE,0);
-    gtk_widget_show(multi_vpaned->vbox);
-    
-    //    multi_vpaned->viewport = gtk_viewport_new (NULL,NULL);
-    //    gtk_widget_show(multi_vpaned->viewport);
-    
-    //    gtk_container_add(GTK_CONTAINER(multi_vpaned->viewport), (GtkWidget*)multi_vpaned->vbox);
-    gtk_box_pack_end(GTK_BOX(multi_vpaned->vbox),(GtkWidget*)multi_vpaned->hscrollbar,FALSE,FALSE,0);
-    gtk_box_pack_end(GTK_BOX(multi_vpaned->vbox),(GtkWidget*)multi_vpaned->first_pane,TRUE,TRUE,0);
-    
-    //    multi_vpaned->scrollWindow = gtk_scrolled_window_new (NULL, NULL);
-    //    gtk_widget_show(multi_vpaned->scrollWindow);
-    //    gtk_container_add (GTK_CONTAINER (multi_vpaned->scrollWindow), (GtkWidget*)multi_vpaned->viewport);    
-    //    gtk_paned_pack1(GTK_PANED(multi_vpaned), (GtkWidget*)multi_vpaned->scrollWindow,FALSE, TRUE);
-
-    gtk_paned_pack1(GTK_PANED(multi_vpaned), (GtkWidget*)multi_vpaned->vbox,FALSE, TRUE);
-  }else{
-    tmpPane = multi_vpaned->last_pane;
-    multi_vpaned->last_pane = (GtkPaned *)gtk_vpaned_new();
-    gtk_paned_pack1 (tmpPane,(GtkWidget*)multi_vpaned->last_pane, FALSE,TRUE);
-  }
-  gtk_widget_show((GtkWidget *)multi_vpaned->last_pane);  
-
-  gtk_paned_pack2 (multi_vpaned->last_pane,widget1, TRUE, TRUE);      
-  multi_vpaned->focused_pane = multi_vpaned->last_pane;
-  multi_vpaned->num_children++;
-  
-}
-
-void gtk_multi_vpaned_widget_delete(GtkMultiVPaned * multi_vpaned)
-{
-  GtkPaned * tmp, *prev, *next;
-
-  if(!multi_vpaned->focused_pane) return;
-  tmp = (GtkPaned*)multi_vpaned->focused_pane->child2; //widget in vpaned
-  g_object_unref(G_OBJECT(tmp));
-
-  if(multi_vpaned->focused_pane == multi_vpaned->first_pane &&
-     multi_vpaned->focused_pane == multi_vpaned->last_pane){
-    //    gtk_container_remove(GTK_CONTAINER(multi_vpaned),(GtkWidget*)multi_vpaned->scrollWindow);
-    gtk_container_remove(GTK_CONTAINER(multi_vpaned),(GtkWidget*)multi_vpaned->vbox);
-    multi_vpaned->first_pane = NULL;
-    multi_vpaned->last_pane = NULL;
-    multi_vpaned->focused_pane = NULL;
-  }else if(multi_vpaned->focused_pane == multi_vpaned->first_pane &&
-          multi_vpaned->focused_pane != multi_vpaned->last_pane){
-    next = (GtkPaned*)multi_vpaned->first_pane->child1;
-    g_object_ref(G_OBJECT(next));
-    gtk_container_remove(GTK_CONTAINER(multi_vpaned->first_pane),(GtkWidget*)next);
-    gtk_container_remove(GTK_CONTAINER(multi_vpaned->vbox),(GtkWidget*)multi_vpaned->first_pane);
-    multi_vpaned->first_pane = next;
-    gtk_box_pack_end(GTK_BOX(multi_vpaned->vbox),(GtkWidget*)multi_vpaned->first_pane,TRUE,TRUE,0);
-    multi_vpaned->focused_pane = multi_vpaned->first_pane;
-    g_object_unref(G_OBJECT(next));
-  }else if(multi_vpaned->focused_pane != multi_vpaned->first_pane &&
-          multi_vpaned->focused_pane == multi_vpaned->last_pane){
-    tmp = multi_vpaned->last_pane;
-    multi_vpaned->last_pane = (GtkPaned*)gtk_widget_get_parent((GtkWidget*)multi_vpaned->last_pane);
-    multi_vpaned->focused_pane = multi_vpaned->last_pane;
-    gtk_container_remove(GTK_CONTAINER(multi_vpaned->last_pane),(GtkWidget*)tmp);
-  }else{
-    tmp = multi_vpaned->focused_pane;
-    prev = (GtkPaned*)gtk_widget_get_parent((GtkWidget*)tmp);
-    next = (GtkPaned*)tmp->child1;
-    g_object_ref(G_OBJECT(next));
-    gtk_container_remove(GTK_CONTAINER(multi_vpaned->focused_pane),(GtkWidget*)next);
-    gtk_container_remove(GTK_CONTAINER(prev),(GtkWidget*)multi_vpaned->focused_pane);
-    gtk_paned_pack1(prev, (GtkWidget*)next, FALSE, TRUE);
-    multi_vpaned->focused_pane = next;
-    g_object_unref(G_OBJECT(next));
-  }
-
-  multi_vpaned->num_children--;
-}
-
-
-void gtk_multi_vpaned_widget_move_up(GtkMultiVPaned * multi_vpaned)
-{
-  GtkWidget* upWidget, *downWidget;
-  GtkPaned * prev,*next, *prevPrev;
-
-  if(multi_vpaned->last_pane == multi_vpaned->focused_pane) return;
-
-  // move VPane
-  prev = (GtkPaned*)multi_vpaned->focused_pane->child1;
-  g_object_ref(G_OBJECT(prev));
-  gtk_container_remove(GTK_CONTAINER(multi_vpaned->focused_pane),(GtkWidget*)prev);
-
-  if(prev == multi_vpaned->last_pane){
-    prevPrev = NULL;
-    multi_vpaned->last_pane = multi_vpaned->focused_pane;
-  }else{    
-    prevPrev = (GtkPaned*)prev->child1;
-    g_object_ref(G_OBJECT(prevPrev));
-    gtk_container_remove(GTK_CONTAINER(prev),(GtkWidget*)prevPrev);   
-  }
-
-  g_object_ref(G_OBJECT(multi_vpaned->focused_pane));
-  if(multi_vpaned->first_pane == multi_vpaned->focused_pane){
-    gtk_container_remove(GTK_CONTAINER(multi_vpaned->vbox),(GtkWidget*)multi_vpaned->focused_pane);
-    gtk_box_pack_end(GTK_BOX(multi_vpaned->vbox),(GtkWidget*)prev,TRUE,TRUE,0);
-    multi_vpaned->first_pane = prev;
-  }else{
-    next = (GtkPaned*)gtk_widget_get_parent((GtkWidget*)multi_vpaned->focused_pane);
-    gtk_container_remove(GTK_CONTAINER(next),(GtkWidget*)multi_vpaned->focused_pane);
-    gtk_paned_pack1(GTK_PANED(next), (GtkWidget*)prev, FALSE,TRUE);
-  }
-  gtk_paned_pack1(GTK_PANED(prev),(GtkWidget*)multi_vpaned->focused_pane, FALSE,TRUE);
-  if(prevPrev)
-    gtk_paned_pack1(GTK_PANED(multi_vpaned->focused_pane),(GtkWidget*)prevPrev, FALSE,TRUE);
-
-  g_object_unref(G_OBJECT(prev));
-  if(prevPrev) g_object_unref(G_OBJECT(prevPrev));
-  g_object_unref(G_OBJECT(multi_vpaned->focused_pane));
-}
-
-
-void gtk_multi_vpaned_widget_move_down(GtkMultiVPaned * multi_vpaned)
-{
-  GtkWidget* upWidget, *downWidget;
-  GtkPaned * prev,*next, *nextNext;
-
-  if(multi_vpaned->first_pane == multi_vpaned->focused_pane) return;
-
-  //move VPane
-  next = (GtkPaned*)gtk_widget_get_parent((GtkWidget*)multi_vpaned->focused_pane);
-  g_object_ref(G_OBJECT(next));
-
-  if(multi_vpaned->last_pane == multi_vpaned->focused_pane){
-    prev = NULL;
-    multi_vpaned->last_pane = next;
-  }else{
-    prev = (GtkPaned*)multi_vpaned->focused_pane->child1;
-    g_object_ref(G_OBJECT(prev));
-    gtk_container_remove(GTK_CONTAINER(multi_vpaned->focused_pane),(GtkWidget*)prev);    
-  }
-
-  g_object_ref(G_OBJECT(multi_vpaned->focused_pane));
-  gtk_container_remove(GTK_CONTAINER(next),(GtkWidget*)multi_vpaned->focused_pane);
-  
-  if(next == multi_vpaned->first_pane){
-    multi_vpaned->first_pane = multi_vpaned->focused_pane;
-    gtk_container_remove(GTK_CONTAINER(multi_vpaned->vbox),(GtkWidget*)next);       
-    gtk_box_pack_end(GTK_BOX(multi_vpaned->vbox),(GtkWidget*)multi_vpaned->focused_pane,TRUE,TRUE,0);
-  }else{    
-    nextNext = (GtkPaned*)gtk_widget_get_parent((GtkWidget*)next);
-    gtk_container_remove(GTK_CONTAINER(nextNext),(GtkWidget*)next);       
-    gtk_paned_pack1(nextNext, (GtkWidget*)multi_vpaned->focused_pane, FALSE, TRUE);
-  }
-  gtk_paned_pack1(multi_vpaned->focused_pane,(GtkWidget*)next, FALSE,TRUE);
-  if(prev)
-    gtk_paned_pack1(next,(GtkWidget*)prev, FALSE,TRUE);
-
-  if(prev)g_object_unref(G_OBJECT(prev));
-  g_object_unref(G_OBJECT(next));
-  g_object_unref(G_OBJECT(multi_vpaned->focused_pane));
-}
-
-void gtk_multi_vpaned_set_scroll_value(GtkMultiVPaned * multi_vpaned, double value)
-{
-  gtk_adjustment_set_value(multi_vpaned->hadjust, value);
-  g_signal_stop_emission_by_name(G_OBJECT(multi_vpaned->hscrollbar), "value-changed");  
-}
-
-void gtk_multi_vpaned_scroll_value_changed(GtkRange *range, gpointer multi_vpaned_arg)
-{
-  TimeWindow time_window;
-  TimeInterval *time_span;
-  LttTime time;
-  GtkMultiVPaned * multi_vpaned = (GtkMultiVPaned*)multi_vpaned_arg;
-  gdouble value = gtk_range_get_value(range);
-  gdouble upper, lower, ratio;
-
-  time_window = multi_vpaned->mw->current_tab->time_window;
-
-  time_span = LTTV_TRACESET_CONTEXT(multi_vpaned->mw->current_tab->traceset_info->
-                                   traceset_context)->Time_Span ;
-  lower = multi_vpaned->hadjust->lower;
-  upper = multi_vpaned->hadjust->upper;
-  ratio = (value - lower) / (upper - lower);
-  
-  time = ltt_time_sub(time_span->endTime, time_span->startTime);
-  time = ltt_time_mul(time, (float)ratio);
-  time = ltt_time_add(time_span->startTime, time);
-
-  time_window.start_time = time;
-
-  time = ltt_time_sub(time_span->endTime, time);
-  if(ltt_time_compare(time,time_window.time_width) < 0){
-    time_window.time_width = time;
-  }
-  set_time_window(multi_vpaned->mw, &time_window); 
-}
-
-
-static void
-gtk_multi_vpaned_size_request (GtkWidget      *widget,
-                        GtkRequisition *requisition)
-{
-  GtkPaned *paned = GTK_PANED (widget);
-  GtkRequisition child_requisition;
-
-  requisition->width = 0;
-  requisition->height = 0;
-
-  if (paned->child1 && GTK_WIDGET_VISIBLE (paned->child1))
-    {
-      gtk_widget_size_request (paned->child1, &child_requisition);
-
-      requisition->height = child_requisition.height;
-      requisition->width = child_requisition.width;
-    }
-
-  if (paned->child2 && GTK_WIDGET_VISIBLE (paned->child2))
-    {
-      gtk_widget_size_request (paned->child2, &child_requisition);
-
-      requisition->width = MAX (requisition->width, child_requisition.width);
-      requisition->height += child_requisition.height;
-    }
-
-  requisition->height += GTK_CONTAINER (paned)->border_width * 2;
-  requisition->width += GTK_CONTAINER (paned)->border_width * 2;
-  
-  if (paned->child1 && GTK_WIDGET_VISIBLE (paned->child1) &&
-      paned->child2 && GTK_WIDGET_VISIBLE (paned->child2))
-    {
-      gint handle_size;
-
-      gtk_widget_style_get (widget, "handle_size", &handle_size, NULL);
-      requisition->height += handle_size;
-    }
-
-}
-
-static void
-gtk_multi_vpaned_size_allocate (GtkWidget     *widget,
-                         GtkAllocation *allocation)
-{
-  GtkPaned *paned = GTK_PANED (widget);
-  gint border_width = GTK_CONTAINER (paned)->border_width;
-
-  widget->allocation = *allocation;
-
-  if (paned->child1 && GTK_WIDGET_VISIBLE (paned->child1) &&
-      paned->child2 && GTK_WIDGET_VISIBLE (paned->child2))
-    {
-      GtkRequisition child1_requisition;
-      GtkRequisition child2_requisition;
-      GtkAllocation child1_allocation;
-      GtkAllocation child2_allocation;
-      gint handle_size;
-      
-      gtk_widget_style_get (widget, "handle_size", &handle_size, NULL);
-
-      gtk_widget_get_child_requisition (paned->child1, &child1_requisition);
-      gtk_widget_get_child_requisition (paned->child2, &child2_requisition);
-    
-      gtk_paned_compute_position (paned,
-                                 MAX (1, widget->allocation.height
-                                      - handle_size
-                                      - 2 * border_width),
-                                 child1_requisition.height,
-                                 child2_requisition.height);
-
-      paned->handle_pos.x = widget->allocation.x + border_width;
-      paned->handle_pos.y = widget->allocation.y + paned->child1_size + border_width;
-      paned->handle_pos.width = MAX (1, (gint) widget->allocation.width - 2 * border_width);
-      paned->handle_pos.height = handle_size;
-      
-      if (GTK_WIDGET_REALIZED (widget))
-       {
-         if (GTK_WIDGET_MAPPED (widget))
-           gdk_window_show (paned->handle);
-         gdk_window_move_resize (paned->handle,
-                                 paned->handle_pos.x,
-                                 paned->handle_pos.y,
-                                 paned->handle_pos.width,
-                                 handle_size);
-       }
-
-      child1_allocation.width = child2_allocation.width = MAX (1, (gint) allocation->width - border_width * 2);
-      child1_allocation.height = MAX (1, paned->child1_size);
-      child1_allocation.x = child2_allocation.x = widget->allocation.x + border_width;
-      child1_allocation.y = widget->allocation.y + border_width;
-      
-      child2_allocation.y = child1_allocation.y + paned->child1_size + paned->handle_pos.height;
-      child2_allocation.height = MAX (1, widget->allocation.y + widget->allocation.height - child2_allocation.y - border_width);
-      
-      if (GTK_WIDGET_MAPPED (widget) &&
-         paned->child1->allocation.height < child1_allocation.height)
-       {
-         gtk_widget_size_allocate (paned->child2, &child2_allocation);
-         gtk_widget_size_allocate (paned->child1, &child1_allocation);
-       }
-      else
-       {
-         gtk_widget_size_allocate (paned->child1, &child1_allocation);
-         gtk_widget_size_allocate (paned->child2, &child2_allocation);
-       }
-    }
-  else
-    {
-      GtkAllocation child_allocation;
-
-      if (GTK_WIDGET_REALIZED (widget))      
-       gdk_window_hide (paned->handle);
-
-      if (paned->child1)
-       gtk_widget_set_child_visible (paned->child1, TRUE);
-      if (paned->child2)
-       gtk_widget_set_child_visible (paned->child2, TRUE);
-
-      child_allocation.x = widget->allocation.x + border_width;
-      child_allocation.y = widget->allocation.y + border_width;
-      child_allocation.width = MAX (1, allocation->width - 2 * border_width);
-      child_allocation.height = MAX (1, allocation->height - 2 * border_width);
-      
-      if (paned->child1 && GTK_WIDGET_VISIBLE (paned->child1))
-       gtk_widget_size_allocate (paned->child1, &child_allocation);
-      else if (paned->child2 && GTK_WIDGET_VISIBLE (paned->child2))
-       gtk_widget_size_allocate (paned->child2, &child_allocation);
-    }
-}
-
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/gtkmultivpaned.h b/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/gtkmultivpaned.h
deleted file mode 100644 (file)
index 316ec4d..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-
-/* This file is part of the Linux Trace Toolkit viewer
- * Copyright (C) 2003-2004 Xiangxiu 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.
- */
-
-#ifndef __GTK_MULTI_VPANED_H__
-#define __GTK_MULTI_VPANED_H__
-
-
-#include <glib.h>
-#include <glib-object.h>
-#include <gdk/gdk.h>
-#include <gtk/gtkcontainer.h>
-#include <lttvwindow/common.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-
-#define GTK_TYPE_MULTI_VPANED            (gtk_multi_vpaned_get_type ())
-#define GTK_MULTI_VPANED(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_MULTI_VPANED, GtkMultiVPaned))
-#define GTK_MULTI_VPANED_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_MULTI_VPANED, GtkMultiVPanedClass))
-#define GTK_IS_MULTI_VPANED(obj   )      (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_MULTI_VPANED))
-#define GTK_IS_MULTI_VPANED_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_MULTI_VPANED))
-#define GTK_MULTI_VPANED_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_MULTI_VPANED, GtkMultiVPanedClass))
-
-
-typedef struct _GtkMultiVPaned  GtkMultiVPaned;
-typedef struct _GtkMultiVPanedClass   GtkMultiVPanedClass;
-
-struct _GtkMultiVPaned
-{
-  GtkPaned container;
-
-  /*< public >*/
-  GtkPaned * first_pane;
-  GtkPaned * last_pane;
-  GtkPaned * focused_pane;
-  GtkPaned * iter;
-  guint num_children;
-
-  GtkWidget * vbox;
-  //  GtkWidget * scrollWindow;
-  //  GtkWidget * viewport;
-  GtkWidget * hscrollbar;  
-  GtkAdjustment *hadjust;
-  MainWindow * mw;
-};
-
-struct _GtkMultiVPanedClass
-{
-  GtkPanedClass parent_class;
-};
-
-
-GType     gtk_multi_vpaned_get_type (void) G_GNUC_CONST;
-GtkWidget* gtk_multi_vpaned_new (void);
-
-void gtk_multi_vpaned_set_focus (GtkWidget * widget, gpointer user_data);     
-void gtk_multi_vpaned_widget_add(GtkMultiVPaned * multi_vpaned, GtkWidget * widget1);
-void gtk_multi_vpaned_widget_delete(GtkMultiVPaned * multi_vpaned);
-void gtk_multi_vpaned_widget_move_up(GtkMultiVPaned * multi_vpaned);
-void gtk_multi_vpaned_widget_move_down(GtkMultiVPaned * multi_vpaned);
-void gtk_multi_vpaned_set_adjust(GtkMultiVPaned * multi_vpaned, gboolean first_time);
-void gtk_multi_vpaned_set_data(GtkMultiVPaned * multi_vpaned, char * key, gpointer value);
-gpointer gtk_multi_vpaned_get_data(GtkMultiVPaned * multi_vpaned, char * key);
-GtkWidget * gtk_multi_vpaned_get_widget(GtkMultiVPaned * multi_vpaned);
-GtkWidget * gtk_multi_vpaned_get_first_widget(GtkMultiVPaned * multi_vpaned);
-GtkWidget * gtk_multi_vpaned_get_next_widget(GtkMultiVPaned * multi_vpaned);
-void gtk_multi_vpaned_set_scroll_value(GtkMultiVPaned * multi_vpaned, double value);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
-#endif /* __GTK_MULTI_VPANED_H__ */
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/gtktraceset.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/gtktraceset.c
deleted file mode 100644 (file)
index 9d0fc7f..0000000
+++ /dev/null
@@ -1,807 +0,0 @@
-/* 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.
- */
-
-/*! \file gtktraceset.h
- * \brief API used by the graphical viewers to interact with their top window.
- * 
- * Main window (gui module) is the place to contain and display viewers. 
- * Viewers (lttv plugins) interacte with main window through this API and
- * events sent by gtk.
- * This header file should be included in each graphic module.
- * This library is used by graphical modules to interact with the
- * tracesetWindow.
- * 
- */
-
-#include <lttvwindow/common.h>
-#include <ltt/ltt.h>
-#include <lttv/lttv.h>
-#include <lttvwindow/mainwindow.h>   
-#include <lttvwindow/gtktraceset.h>
-#include <lttv/tracecontext.h>
-#include <lttvwindow/toolbar.h>
-#include <lttvwindow/menu.h>
-#include <lttv/state.h>
-#include <lttv/stats.h>
-
-
-/**
- * Internal function parts
- */
-
-/**
- * Function to set/update traceset for the viewers
- * @param main_win main window 
- * @param traceset traceset of the main window.
- */
-
-void SetTraceset(MainWindow * main_win, gpointer traceset)
-{
-  LttvHooks * tmp;
-  LttvAttributeValue value;
-
-  g_assert(lttv_iattribute_find_by_path(main_win->attributes,
-     "hooks/updatetraceset", LTTV_POINTER, &value));
-  tmp = (LttvHooks*)*(value.v_pointer);
-  if(tmp == NULL)return;
-  lttv_hooks_call(tmp,traceset);
-}
-
-
-/**
- * Function to set/update filter for the viewers
- * @param main_win main window 
- * @param filter filter of the main window.
- */
-
-void SetFilter(MainWindow * main_win, gpointer filter)
-{
-  LttvHooks * tmp;
-  LttvAttributeValue value;
-
-  g_assert(lttv_iattribute_find_by_path(main_win->attributes,
-     "hooks/updatefilter", LTTV_POINTER, &value));
-  tmp = (LttvHooks*)*(value.v_pointer);
-
-  if(tmp == NULL)return;
-  lttv_hooks_call(tmp,filter);
-}
-
-
-
-/**
- * API parts
- */
-
-/**
- * Function to register a view constructor so that main window can generate
- * a toolbar item for the viewer in order to generate a new instance easily. 
- * It will be called by init function of the module.
- * @param ButtonPixmap image shown on the toolbar item.
- * @param tooltip tooltip of the toolbar item.
- * @param view_constructor constructor of the viewer. 
- */
-
-void toolbar_item_reg(char ** pixmap, char *tooltip, lttv_constructor view_constructor)
-{
-  LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes());
-  LttvToolbars * toolbar;
-  LttvAttributeValue value;
-
-  g_assert(lttv_iattribute_find_by_path(attributes_global,
-     "viewers/toolbar", LTTV_POINTER, &value));
-  toolbar = (LttvToolbars*)*(value.v_pointer);
-
-  if(toolbar == NULL){    
-    toolbar = lttv_toolbars_new();
-    *(value.v_pointer) = toolbar;
-  }
-  lttv_toolbars_add(toolbar, view_constructor, tooltip, pixmap);
-}
-
-
-/**
- * Function to unregister the viewer's constructor, release the space 
- * occupied by pixmap, tooltip and constructor of the viewer.
- * It will be called when a module is unloaded.
- * @param view_constructor constructor of the viewer which is used as 
- * a reference to find out where the pixmap and tooltip are.
- */
-
-void toolbar_item_unreg(lttv_constructor view_constructor)
-{
-  LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes());
-  LttvToolbars * toolbar;
-  LttvAttributeValue value;
-
-  g_assert(lttv_iattribute_find_by_path(attributes_global,
-     "viewers/toolbar", LTTV_POINTER, &value));
-  toolbar = (LttvToolbars*)*(value.v_pointer);
-  
-  main_window_remove_toolbar_item(view_constructor);
-
-  lttv_toolbars_remove(toolbar, view_constructor);
-}
-
-
-/**
- * Function to register a view constructor so that main window can generate
- * a menu item for the viewer in order to generate a new instance easily.
- * It will be called by init function of the module.
- * @param menu_path path of the menu item.
- * @param menu_text text of the menu item.
- * @param view_constructor constructor of the viewer. 
- */
-
-void menu_item_reg(char *menu_path, char *menu_text, lttv_constructor view_constructor)
-{
-  LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes());
-  LttvMenus * menu;
-  LttvAttributeValue value;
-
-  g_assert(lttv_iattribute_find_by_path(attributes_global,
-     "viewers/menu", LTTV_POINTER, &value));
-  menu = (LttvMenus*)*(value.v_pointer);
-  
-  if(menu == NULL){    
-    menu = lttv_menus_new();
-    *(value.v_pointer) = menu;
-  }
-  lttv_menus_add(menu, view_constructor, menu_path, menu_text);
-}
-
-/**
- * Function to unregister the viewer's constructor, release the space 
- * occupied by menu_path, menu_text and constructor of the viewer.
- * It will be called when a module is unloaded.
- * @param view_constructor constructor of the viewer which is used as 
- * a reference to find out where the menu_path and menu_text are.
- */
-
-void menu_item_unreg(lttv_constructor view_constructor)
-{
-  LttvIAttribute *attributes_global = LTTV_IATTRIBUTE(lttv_global_attributes());
-  LttvMenus * menu;
-  LttvAttributeValue value;
-
-  g_assert(lttv_iattribute_find_by_path(attributes_global,
-                              "viewers/menu", LTTV_POINTER, &value));
-  menu = (LttvMenus*)*(value.v_pointer);
-
-  main_window_remove_menu_item(view_constructor);
-
-  lttv_menus_remove(menu, view_constructor);
-}
-
-
-/**
- * Update the status bar whenever something changed in the viewer.
- * @param main_win the main window the viewer belongs to.
- * @param info the message which will be shown in the status bar.
- */
-
-void update_status(MainWindow *main_win, char *info)
-{
-}
-
-
-/**
- * Function to get the current time interval shown on the current tab.
- * It will be called by a viewer's hook function to update the 
- * shown time interval of the viewer and also be called by the constructor
- * of the viewer.
- * @param main_win the main window the viewer belongs to.
- * @param time_interval a pointer where time interval will be stored.
- */
-
-void get_time_window(MainWindow *main_win, TimeWindow *time_window)
-{
-  //time_window->start_time = main_win->current_tab->time_window.start_time;
-  //time_window->time_width = main_win->current_tab->time_window.time_width;
-  *time_window = main_win->current_tab->time_window;
-}
-
-/**
- * Function to get the current time interval of the current traceset.
- * It will be called by a viewer's hook function to update the 
- * time interval of the viewer and also be called by the constructor
- * of the viewer.
- * @param main_win the main window the viewer belongs to.
- * @param time_interval a pointer where time interval will be stored.
- */
-
-void get_traceset_time_span(MainWindow *main_win, TimeInterval *time_interval)
-{
-  //time_window->start_time = main_win->current_tab->time_window.start_time;
-  //time_window->time_width = main_win->current_tab->time_window.time_width;
-  *time_interval = *(LTTV_TRACESET_CONTEXT(main_win->current_tab->traceset_info->
-             traceset_context)->Time_Span);
-}
-
-
-
-/**
- * Function to set the time interval of the current tab.
- * It will be called by a viewer's signal handle associated with 
- * the move_slider signal
- * @param main_win the main window the viewer belongs to.
- * @param time_interval a pointer where time interval is stored.
- */
-
-void set_time_window(MainWindow *main_win, TimeWindow *time_window)
-{
-  LttvAttributeValue value;
-  LttvHooks * tmp;
-  main_win->current_tab->time_window = *time_window;
-  gtk_multi_vpaned_set_scroll_value(main_win->current_tab->multi_vpaned,
-            ltt_time_to_double(time_window->start_time)
-            * NANOSECONDS_PER_SECOND );
-  g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
-           "hooks/updatetimewindow", LTTV_POINTER, &value));
-  tmp = (LttvHooks*)*(value.v_pointer);
-  if(tmp == NULL) return;
-  lttv_hooks_call(tmp, time_window);
-}
-
-
-/**
- * Function to get the current time/event of the current tab.
- * It will be called by a viewer's hook function to update the 
- * current time/event of the viewer.
- * @param main_win the main window the viewer belongs to.
- * @param time a pointer where time will be stored.
- */
-
-void get_current_time(MainWindow *main_win, LttTime *time)
-{
-  time = &main_win->current_tab->current_time;
-}
-
-
-/**
- * Function to set the current time/event of the current tab.
- * It will be called by a viewer's signal handle associated with 
- * the button-release-event signal
- * @param main_win the main window the viewer belongs to.
- * @param time a pointer where time is stored.
- */
-
-void set_current_time(MainWindow *main_win, LttTime *time)
-{
-  LttvAttributeValue value;
-  LttvHooks * tmp;
-  main_win->current_tab->current_time = *time;
-  g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
-           "hooks/updatecurrenttime", LTTV_POINTER, &value));
-  tmp = (LttvHooks*)*(value.v_pointer);
-
-  if(tmp == NULL)return;
-  lttv_hooks_call(tmp, time);
-}
-
-
-/**
- * Function to get the traceset from the current tab.
- * It will be called by the constructor of the viewer and also be
- * called by a hook funtion of the viewer to update its traceset.
- * @param main_win the main window the viewer belongs to.
- * @param traceset a pointer to a traceset.
- */
-/*
-void get_traceset(MainWindow *main_win, Traceset *traceset)
-{
-}
-*/
-
-/**
- * Function to get the filter of the current tab.
- * It will be called by the constructor of the viewer and also be
- * called by a hook funtion of the viewer to update its filter.
- * @param main_win, the main window the viewer belongs to.
- * @param filter, a pointer to a filter.
- */
-/*
-void get_filter(MainWindow *main_win, Filter *filter)
-{
-}
-*/
-
-/**
- * Function to register a hook function for a viewer to set/update its
- * time interval.
- * It will be called by the constructor of the viewer.
- * @param hook hook function of the viewer.
- * @param hook_data hook data associated with the hook function.
- * @param main_win the main window the viewer belongs to.
- */
-
-void reg_update_time_window(LttvHook hook, gpointer hook_data,
-         MainWindow * main_win)
-{
-  LttvAttributeValue value;
-  LttvHooks * tmp;
-  g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
-           "hooks/updatetimewindow", LTTV_POINTER, &value));
-  tmp = (LttvHooks*)*(value.v_pointer);
-  if(tmp == NULL){    
-    tmp = lttv_hooks_new();
-    *(value.v_pointer) = tmp;
-  }
-  lttv_hooks_add(tmp, hook,hook_data);
-}
-
-
-/**
- * Function to unregister a viewer's hook function which is used to 
- * set/update the time interval of the viewer.
- * It will be called by the destructor of the viewer.
- * @param hook hook function of the viewer.
- * @param hook_data hook data associated with the hook function.
- * @param main_win the main window the viewer belongs to.
- */
-
-void unreg_update_time_window(LttvHook hook, gpointer hook_data,
-           MainWindow * main_win)
-{
-  LttvAttributeValue value;
-  LttvHooks * tmp;
-  g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
-           "hooks/updatetimewindow", LTTV_POINTER, &value));
-  tmp = (LttvHooks*)*(value.v_pointer);
-  if(tmp == NULL) return;
-  lttv_hooks_remove_data(tmp, hook, hook_data);
-}
-
-
-/**
- * Function to register a hook function for a viewer to set/update its 
- * traceset.
- * It will be called by the constructor of the viewer.
- * @param hook hook function of the viewer.
- * @param hook_data hook data associated with the hook function.
- * @param main_win the main window the viewer belongs to.
- */
-
-void reg_update_traceset(LttvHook hook, gpointer hook_data,
-           MainWindow * main_win)
-{
-  LttvAttributeValue value;
-  LttvHooks * tmp;
-  g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
-           "hooks/updatetraceset", LTTV_POINTER, &value));
-  tmp = (LttvHooks*)*(value.v_pointer);
-  if(tmp == NULL){    
-    tmp = lttv_hooks_new();
-    *(value.v_pointer) = tmp;
-  }
-  lttv_hooks_add(tmp, hook, hook_data);
-}
-
-
-/**
- * Function to unregister a viewer's hook function which is used to 
- * set/update the traceset of the viewer.
- * It will be called by the destructor of the viewer.
- * @param hook hook function of the viewer.
- * @param hook_data hook data associated with the hook function.
- * @param main_win the main window the viewer belongs to.
- */
-
-void unreg_update_traceset(LttvHook hook, gpointer hook_data,
-       MainWindow * main_win)
-{
-  LttvAttributeValue value;
-  LttvHooks * tmp;
-  g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
-           "hooks/updatetraceset", LTTV_POINTER, &value));
-  tmp = (LttvHooks*)*(value.v_pointer);
-  if(tmp == NULL) return;
-  lttv_hooks_remove_data(tmp, hook, hook_data);
-}
-
-
-/**
- * Function to redraw each viewer belonging to the current tab 
- * @param main_win the main window the viewer belongs to.
- */
-
-void update_traceset(MainWindow * main_win)
-{
-  LttvAttributeValue value;
-  LttvHooks * tmp;
-  g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
-           "hooks/updatetraceset", LTTV_POINTER, &value));
-  tmp = (LttvHooks*)*(value.v_pointer);
-  if(tmp == NULL) return;
-  lttv_hooks_call(tmp, NULL);
-}
-
-
-/**
- * Function to register a hook function for a viewer to set/update its 
- * filter.
- * It will be called by the constructor of the viewer.
- * @param hook hook function of the viewer.
- * @param hook_data hook data associated with the hook function.
- * @param main_win the main window the viewer belongs to.
- */
-
-void reg_update_filter(LttvHook hook, gpointer hook_data,
-         MainWindow *main_win)
-{
-  LttvAttributeValue value;
-  LttvHooks * tmp;
-  g_assert(lttv_iattribute_find_by_path(main_win->attributes,
-           "hooks/updatefilter", LTTV_POINTER, &value));
-  tmp = (LttvHooks*)*(value.v_pointer);
-  if(tmp == NULL){    
-    tmp = lttv_hooks_new();
-    *(value.v_pointer) = tmp;
-  }
-  lttv_hooks_add(tmp, hook, hook_data);
-}
-
-
-/**
- * Function to unregister a viewer's hook function which is used to 
- * set/update the filter of the viewer.
- * It will be called by the destructor of the viewer.
- * @param hook hook function of the viewer.
- * @param hook_data hook data associated with the hook function.
- * @param main_win the main window the viewer belongs to.
- */
-
-void unreg_update_filter(LttvHook hook, gpointer hook_data,
-           MainWindow * main_win)
-{
-  LttvAttributeValue value;
-  LttvHooks * tmp;
-  g_assert(lttv_iattribute_find_by_path(main_win->attributes,
-           "hooks/updatefilter", LTTV_POINTER, &value));
-  tmp = (LttvHooks*)*(value.v_pointer);
-  if(tmp == NULL) return;
-  lttv_hooks_remove_data(tmp, hook, hook_data);
-}
-
-
-/**
- * Function to register a hook function for a viewer to set/update its 
- * current time.
- * It will be called by the constructor of the viewer.
- * @param hook hook function of the viewer.
- * @param hook_data hook data associated with the hook function.
- * @param main_win the main window the viewer belongs to.
- */
-
-void reg_update_current_time(LttvHook hook, gpointer hook_data, 
-        MainWindow *main_win)
-{
-  LttvAttributeValue value;
-  LttvHooks * tmp;
-  g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
-           "hooks/updatecurrenttime", LTTV_POINTER, &value));
-  tmp = (LttvHooks*)*(value.v_pointer);
-  if(tmp == NULL){    
-    tmp = lttv_hooks_new();
-    *(value.v_pointer) = tmp;
-  }
-  lttv_hooks_add(tmp, hook, hook_data);
-}
-
-
-/**
- * Function to unregister a viewer's hook function which is used to 
- * set/update the current time of the viewer.
- * It will be called by the destructor of the viewer.
- * @param hook hook function of the viewer.
- * @param hook_data hook data associated with the hook function.
- * @param main_win the main window the viewer belongs to.
- */
-
-void unreg_update_current_time(LttvHook hook, gpointer hook_data,
-          MainWindow * main_win)
-{
-  LttvAttributeValue value;
-  LttvHooks * tmp;
-  g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
-           "hooks/updatecurrenttime", LTTV_POINTER, &value));
-  tmp = (LttvHooks*)*(value.v_pointer);
-  if(tmp == NULL) return;
-  lttv_hooks_remove_data(tmp, hook, hook_data);
-}
-
-
-/**
- * Function to register a hook function for a viewer to show 
- *the content of the viewer.
- * It will be called by the constructor of the viewer.
- * @param hook hook function of the viewer.
- * @param hook_data hook data associated with the hook function.
- * @param main_win the main window the viewer belongs to.
- */
-
-void reg_show_viewer(LttvHook hook, gpointer hook_data, 
-         MainWindow *main_win)
-{
-  LttvAttributeValue value;
-  LttvHooks * tmp;
-  g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
-           "hooks/showviewer", LTTV_POINTER, &value));
-  tmp = (LttvHooks*)*(value.v_pointer);
-  if(tmp == NULL){    
-    tmp = lttv_hooks_new();
-    *(value.v_pointer) = tmp;
-  }
-  lttv_hooks_add(tmp, hook, hook_data);
-}
-
-
-/**
- * Function to unregister a viewer's hook function which is used to 
- * show the content of the viewer..
- * It will be called by the destructor of the viewer.
- * @param hook hook function of the viewer.
- * @param hook_data hook data associated with the hook function.
- * @param main_win the main window the viewer belongs to.
- */
-
-void unreg_show_viewer(LttvHook hook, gpointer hook_data,
-           MainWindow * main_win)
-{
-  LttvAttributeValue value;
-  LttvHooks * tmp;
-  g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
-           "hooks/showviewer", LTTV_POINTER, &value));
-  tmp = (LttvHooks*)*(value.v_pointer);
-  if(tmp == NULL) return;
-  lttv_hooks_remove_data(tmp, hook, hook_data);
-}
-
-
-/**
- * Function to show each viewer in the current tab.
- * It will be called by main window after it called process_traceset 
- * @param main_win the main window the viewer belongs to.
- */
-
-void show_viewer(MainWindow *main_win)
-{
-  LttvAttributeValue value;
-  LttvHooks * tmp;
-  g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
-           "hooks/showviewer", LTTV_POINTER, &value));
-  tmp = (LttvHooks*)*(value.v_pointer);
-  if(tmp == NULL) return;
-  lttv_hooks_call(tmp, NULL);
-}
-
-
-/**
- * Function to set the focused pane (viewer).
- * It will be called by a viewer's signal handle associated with 
- * the grab_focus signal
- * @param main_win the main window the viewer belongs to.
- * @param paned a pointer to a pane where the viewer is contained.
- */
-
-void set_focused_pane(MainWindow *main_win, gpointer paned)
-{
-  gtk_multi_vpaned_set_focus((GtkWidget*)main_win->current_tab->multi_vpaned,paned);  
-}
-
-
-/**
- * Function to register a hook function for a viewer to set/update the 
- * dividor of the hpane.
- * It will be called by the constructor of the viewer.
- * @param hook hook function of the viewer.
- * @param hook_data hook data associated with the hook function.
- * @param main_win the main window the viewer belongs to.
- */
-
-void reg_update_dividor(LttvHook hook, gpointer hook_data, 
-          MainWindow *main_win)
-{
-  LttvAttributeValue value;
-  LttvHooks * tmp;
-  g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
-           "hooks/hpanedividor", LTTV_POINTER, &value));
-  tmp = (LttvHooks*)*(value.v_pointer);
-  if(tmp == NULL){    
-    tmp = lttv_hooks_new();
-    *(value.v_pointer) = tmp;
-  }
-  lttv_hooks_add(tmp, hook, hook_data);
-}
-
-
-/**
- * Function to unregister a viewer's hook function which is used to 
- * set/update hpane's dividor of the viewer.
- * It will be called by the destructor of the viewer.
- * @param hook hook function of the viewer.
- * @param hook_data hook data associated with the hook function.
- * @param main_win the main window the viewer belongs to.
- */
-
-void unreg_update_dividor(LttvHook hook, gpointer hook_data, 
-      MainWindow *main_win)
-{
-  LttvAttributeValue value;
-  LttvHooks * tmp;
-  g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
-           "hooks/hpanedividor", LTTV_POINTER, &value));
-  tmp = (LttvHooks*)*(value.v_pointer);
-  if(tmp == NULL) return;
-  lttv_hooks_remove_data(tmp, hook, hook_data);
-}
-
-
-/**
- * Function to set the position of the hpane's dividor (viewer).
- * It will be called by a viewer's signal handle associated with 
- * the motion_notify_event event/signal
- * @param main_win the main window the viewer belongs to.
- * @param position position of the hpane's dividor.
- */
-
-void set_hpane_dividor(MainWindow *main_win, gint position)
-{
-  LttvAttributeValue value;
-  LttvHooks * tmp;
-  g_assert(lttv_iattribute_find_by_path(main_win->current_tab->attributes,
-           "hooks/hpanedividor", LTTV_POINTER, &value));
-  tmp = (LttvHooks*)*(value.v_pointer);
-  if(tmp == NULL) return;
-  lttv_hooks_call(tmp, &position);
-}
-
-
-/**
- * Function to process traceset. It will call lttv_process_trace, 
- * each view will call this api to get events.
- * @param main_win the main window the viewer belongs to.
- * @param start the start time of the first event to be processed.
- * @param end the end time of the last event to be processed.
- */
-
-void process_traceset_api(MainWindow *main_win, LttTime start, 
-        LttTime end, unsigned maxNumEvents)
-{
-  lttv_process_traceset_seek_time(
-     LTTV_TRACESET_CONTEXT(main_win->current_tab->traceset_info->
-           traceset_context),
-      start);
-  lttv_process_traceset(
-     LTTV_TRACESET_CONTEXT(main_win->current_tab->traceset_info->
-           traceset_context),
-      end,
-      maxNumEvents);
-}
-
-/**
- * Function to add hooks into the context of a traceset,
- * before reading events from traceset, viewer will call this api to
- * register hooks
- * @param main_win the main window the viewer belongs to.
- * @param LttvHooks hooks to be registered.
- */
-
-void context_add_hooks_api(MainWindow *main_win ,
-         LttvHooks *before_traceset, 
-         LttvHooks *after_traceset,
-         LttvHooks *check_trace, 
-         LttvHooks *before_trace, 
-         LttvHooks *after_trace, 
-         LttvHooks *check_tracefile,
-         LttvHooks *before_tracefile,
-         LttvHooks *after_tracefile,
-         LttvHooks *check_event, 
-         LttvHooks *before_event, 
-         LttvHooks *after_event)
-{
-  LttvTracesetContext * tsc = 
-    LTTV_TRACESET_CONTEXT(main_win->current_tab->traceset_info->
-        traceset_context);
-  lttv_traceset_context_add_hooks(tsc,before_traceset,after_traceset,
-          check_trace,before_trace,after_trace,
-          check_tracefile,before_tracefile,after_tracefile,
-          check_event,before_event, after_event);
-}
-
-
-/**
- * Function to remove hooks from the context of a traceset,
- * before reading events from traceset, viewer will call this api to
- * unregister hooks
- * @param main_win the main window the viewer belongs to.
- * @param LttvHooks hooks to be registered.
- */
-
-void context_remove_hooks_api(MainWindow *main_win ,
-            LttvHooks *before_traceset, 
-            LttvHooks *after_traceset,
-            LttvHooks *check_trace, 
-            LttvHooks *before_trace, 
-            LttvHooks *after_trace, 
-            LttvHooks *check_tracefile,
-            LttvHooks *before_tracefile,
-            LttvHooks *after_tracefile,
-            LttvHooks *check_event, 
-            LttvHooks *before_event, 
-            LttvHooks *after_event)
-{
-  LttvTracesetContext * tsc =
-        LTTV_TRACESET_CONTEXT(main_win->current_tab->traceset_info->traceset_context);
-  lttv_traceset_context_remove_hooks(tsc,before_traceset,after_traceset,
-             check_trace,before_trace,after_trace,
-             check_tracefile,before_tracefile,after_tracefile,
-             check_event,before_event, after_event);
-}
-
-
-/**
- * Function to add/remove event hooks for state 
- * @param main_win the main window the viewer belongs to.
- */
-
-void state_add_event_hooks_api(MainWindow *main_win )
-{
-  lttv_state_add_event_hooks(
-       (LttvTracesetState*)main_win->current_tab->traceset_info->traceset_context);
-}
-
-void state_remove_event_hooks_api(MainWindow *main_win )
-{
-  lttv_state_remove_event_hooks(
-       (LttvTracesetState*)main_win->current_tab->traceset_info->traceset_context);
-}
-
-
-/**
- * Function to add/remove event hooks for stats 
- * @param main_win the main window the viewer belongs to.
- */
-
-void stats_add_event_hooks_api(MainWindow *main_win )
-{
-  lttv_stats_add_event_hooks(
-        (LttvTracesetStats*)main_win->current_tab->traceset_info->traceset_context);
-}
-
-void stats_remove_event_hooks_api(MainWindow *main_win )
-{
-  lttv_stats_remove_event_hooks(
-        (LttvTracesetStats*)main_win->current_tab->traceset_info->traceset_context);
-}
-
-/**
- * Function to get the stats of the traceset 
- * @param main_win the main window the viewer belongs to.
- */
-
-LttvTracesetStats* get_traceset_stats_api(MainWindow *main_win)
-{
-  return main_win->current_tab->traceset_info->traceset_context;
-}
-
-
-LttvTracesetContext* get_traceset_context(MainWindow *main_win)
-{
-  return (LttvTracesetContext*)main_win->current_tab->traceset_info->traceset_context;
-}
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/gtktraceset.h b/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/gtktraceset.h
deleted file mode 100644 (file)
index e26e718..0000000
+++ /dev/null
@@ -1,476 +0,0 @@
-/* This file is part of the Linux Trace Toolkit viewer
- * Copyright (C) 2003-2004 Xiangxiu 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.
- */
-
-/*
-CHECK Rename to viewer.h
-
-Things that can happen to a viewer:
-
-update_time_window
-update_current_time
-update_traceset
-update_filter
-show_viewer
-update_dividor
-?? Reshape, damage ??
-
-Things that a viewer can do:
-
-update_status
-set_time_window
-set_current_time
-update_traceset?
-update_filter?
-show_viewer?
-set_focused_pane
-set_hpane_dividor
-*/
-
-
-
-
-/*! \file gtktraceset.h
- * \brief API used by the graphical viewers to interact with their top window.
- * 
- * Main window (gui module) is the place to contain and display viewers. 
- * Viewers (lttv plugins) interacte with main window through this API and
- * events sent by gtk.
- * This header file should be included in each graphic module.
- * This library is used by graphical modules to interact with the
- * tracesetWindow.
- * 
- */
-
-#include <gtk/gtk.h>
-#include <ltt/ltt.h>
-#include <lttv/hook.h>
-#include <lttvwindow/common.h>
-#include <lttv/stats.h>
-
-/**
- * Function to register a view constructor so that main window can generate
- * a toolbar item for the viewer in order to generate a new instance easily. 
- * It will be called by init function of the module.
- * @param ButtonPixmap image shown on the toolbar item.
- * @param tooltip tooltip of the toolbar item.
- * @param view_constructor constructor of the viewer. 
- */
-
-void toolbar_item_reg(char ** pixmap, char *tooltip, lttv_constructor view_constructor);
-
-
-/**
- * Function to unregister the viewer's constructor, release the space 
- * occupied by pixmap, tooltip and constructor of the viewer.
- * It will be called when a module is unloaded.
- * @param view_constructor constructor of the viewer which is used as 
- * a reference to find out where the pixmap and tooltip are.
- */
-
-void toolbar_item_unreg(lttv_constructor view_constructor);
-
-
-/**
- * Function to register a view constructor so that main window can generate
- * a menu item for the viewer in order to generate a new instance easily.
- * It will be called by init function of the module.
- * @param menu_path path of the menu item.
- * @param menu_text text of the menu item.
- * @param view_constructor constructor of the viewer. 
- */
-
-void menu_item_reg(char *menu_path, char *menu_text, lttv_constructor view_constructor);
-
-
-/**
- * Function to unregister the viewer's constructor, release the space 
- * occupied by menu_path, menu_text and constructor of the viewer.
- * It will be called when a module is unloaded.
- * @param view_constructor constructor of the viewer which is used as 
- * a reference to find out where the menu_path and menu_text are.
- */
-
-void menu_item_unreg(lttv_constructor view_constructor);
-
-
-/**
- * Update the status bar whenever something changed in the viewer.
- * @param main_win the main window the viewer belongs to.
- * @param info the message which will be shown in the status bar.
- */
-
-void update_status(MainWindow *main_win, char *info);
-
-
-/**
- * Function to get the current time window of the current tab.
- * It will be called by a viewer's hook function to update the 
- * time window of the viewer and also be called by the constructor
- * of the viewer.
- * @param main_win the main window the viewer belongs to.
- * @param time_interval a pointer where time interval will be stored.
- */
-
-void get_time_window(MainWindow *main_win, TimeWindow *time_window);
-
-
-/**
- * Function to set the time interval of the current tab.
- * It will be called by a viewer's signal handle associated with 
- * the move_slider signal
- * @param main_win the main window the viewer belongs to.
- * @param time_interval a pointer where time interval is stored.
- */
-
-void set_time_window(MainWindow *main_win, TimeWindow *time_window);
-
-/**
- * Function to get the current time/event of the current tab.
- * It will be called by a viewer's hook function to update the 
- * current time/event of the viewer.
- * @param main_win the main window the viewer belongs to.
- * @param time a pointer where time will be stored.
- */
-
-void get_current_time(MainWindow *main_win, LttTime *time);
-
-
-/**
- * Function to set the current time/event of the current tab.
- * It will be called by a viewer's signal handle associated with 
- * the button-release-event signal
- * @param main_win the main window the viewer belongs to.
- * @param time a pointer where time is stored.
- */
-
-void set_current_time(MainWindow *main_win, LttTime *time);
-
-
-/**
- * Function to get the traceset from the current tab.
- * It will be called by the constructor of the viewer and also be
- * called by a hook funtion of the viewer to update its traceset.
- * @param main_win the main window the viewer belongs to.
- * @param traceset a pointer to a traceset.
- */
-
-//void get_traceset(MainWindow *main_win, Traceset *traceset);
-
-
-/**
- * Function to get the filter of the current tab.
- * It will be called by the constructor of the viewer and also be
- * called by a hook funtion of the viewer to update its filter.
- * @param main_win, the main window the viewer belongs to.
- * @param filter, a pointer to a filter.
- */
-
-//void get_filter(MainWindow *main_win, Filter *filter);
-
-
-/**
- * Function to register a hook function for a viewer to set/update its
- * time interval.
- * It will be called by the constructor of the viewer.
- * @param hook hook function of the viewer. Takes a TimeInterval* as call_data.
- * @param hook_data hook data associated with the hook function.
- * @param main_win the main window the viewer belongs to.
- */
-
-void reg_update_time_window(LttvHook hook, gpointer hook_data,
-                           MainWindow * main_win);
-
-
-/**
- * Function to unregister a viewer's hook function which is used to 
- * set/update the time interval of the viewer.
- * It will be called by the destructor of the viewer.
- * @param hook hook function of the viewer. Takes a TimeInterval as call_data.
- * @param hook_data hook data associated with the hook function.
- * @param main_win the main window the viewer belongs to.
- */
-
-void unreg_update_time_window(LttvHook hook, gpointer hook_data,
-                             MainWindow * main_win);
-
-
-/**
- * Function to register a hook function for a viewer to set/update its 
- * traceset.
- * It will be called by the constructor of the viewer.
- * @param hook hook function of the viewer.
- * @param hook_data hook data associated with the hook function.
- * @param main_win the main window the viewer belongs to.
- */
-
-void reg_update_traceset(LttvHook hook, gpointer hook_data,
-                      MainWindow * main_win);
-
-
-/**
- * Function to unregister a viewer's hook function which is used to 
- * set/update the traceset of the viewer.
- * It will be called by the destructor of the viewer.
- * @param hook hook function of the viewer.
- * @param hook_data hook data associated with the hook function.
- * @param main_win the main window the viewer belongs to.
- */
-
-void unreg_update_traceset(LttvHook hook, gpointer hook_data,
-                        MainWindow * main_win);
-
-
-/**
- * Function to redraw each viewer belonging to the current tab 
- * @param main_win the main window the viewer belongs to.
- */
-
-void update_traceset(MainWindow * main_win);
-
-
-/**
- * Function to register a hook function for a viewer to set/update its 
- * filter.
- * It will be called by the constructor of the viewer.
- * @param hook hook function of the viewer.
- * @param hook_data hook data associated with the hook function.
- * @param main_win the main window the viewer belongs to.
- */
-
-void reg_update_filter(LttvHook hook, gpointer hook_data, 
-                    MainWindow *main_win);
-
-
-/**
- * Function to unregister a viewer's hook function which is used to 
- * set/update the filter of the viewer.
- * It will be called by the destructor of the viewer.
- * @param hook hook function of the viewer.
- * @param hook_data hook data associated with the hook function.
- * @param main_win the main window the viewer belongs to.
- */
-
-void unreg_update_filter(LttvHook hook,  gpointer hook_data,
-                      MainWindow * main_win);
-
-
-/**
- * Function to register a hook function for a viewer to set/update its 
- * current time.
- * It will be called by the constructor of the viewer.
- * @param hook hook function of the viewer.
- * @param hook_data hook data associated with the hook function.
- * @param main_win the main window the viewer belongs to.
- */
-
-void reg_update_current_time(LttvHook hook, gpointer hook_data, 
-                         MainWindow *main_win);
-
-
-/**
- * Function to unregister a viewer's hook function which is used to 
- * set/update the current time of the viewer.
- * It will be called by the destructor of the viewer.
- * @param hook hook function of the viewer.
- * @param hook_data hook data associated with the hook function.
- * @param main_win the main window the viewer belongs to.
- */
-
-void unreg_update_current_time(LttvHook hook, gpointer hook_data,
-                           MainWindow * main_win);
-
-
-/**
- * Function to register a hook function for a viewer to show 
- *the content of the viewer.
- * It will be called by the constructor of the viewer.
- * @param hook hook function of the viewer.
- * @param hook_data hook data associated with the hook function.
- * @param main_win the main window the viewer belongs to.
- */
-
-void reg_show_viewer(LttvHook hook, gpointer hook_data, 
-                    MainWindow *main_win);
-
-
-/**
- * Function to unregister a viewer's hook function which is used to 
- * show the content of the viewer..
- * It will be called by the destructor of the viewer.
- * @param hook hook function of the viewer.
- * @param hook_data hook data associated with the hook function.
- * @param main_win the main window the viewer belongs to.
- */
-
-void unreg_show_viewer(LttvHook hook, gpointer hook_data,
-                      MainWindow * main_win);
-
-
-/**
- * Function to show each viewer in the current tab.
- * It will be called by main window after it called process_traceset 
- * @param main_win the main window the viewer belongs to.
- */
-
-void show_viewer(MainWindow *main_win);
-
-
-/**
- * Function to set the focused pane (viewer).
- * It will be called by a viewer's signal handle associated with 
- * the grab_focus signal
- * @param main_win the main window the viewer belongs to.
- * @param paned a pointer to a pane where the viewer is contained.
- */
-
-void set_focused_pane(MainWindow *main_win, gpointer paned);
-
-
-/**
- * Function to register a hook function for a viewer to set/update the 
- * dividor of the hpane.
- * It will be called by the constructor of the viewer.
- * @param hook hook function of the viewer.
- * @param hook_data hook data associated with the hook function.
- * @param main_win the main window the viewer belongs to.
- */
-
-void reg_update_dividor(LttvHook hook, gpointer hook_data, 
-                     MainWindow *main_win);
-
-
-/**
- * Function to unregister a viewer's hook function which is used to 
- * set/update hpane's dividor of the viewer.
- * It will be called by the destructor of the viewer.
- * @param hook hook function of the viewer.
- * @param hook_data hook data associated with the hook function.
- * @param main_win the main window the viewer belongs to.
- */
-
-void unreg_update_dividor(LttvHook hook, gpointer hook_data, 
-                       MainWindow *main_win);
-
-
-/**
- * Function to set the position of the hpane's dividor (viewer).
- * It will be called by a viewer's signal handle associated with 
- * the motion_notify_event event/signal
- * @param main_win the main window the viewer belongs to.
- * @param position position of the hpane's dividor.
- */
-
-void set_hpane_dividor(MainWindow *main_win, gint position);
-
-
-/*
-CHECK These functions really should not appear here. Directr calls would
-be OK unless there is a linker problem.
-*/
-/**
- * Function to process traceset. It will call lttv_process_trace, 
- * each view will call this api to get events.
- * @param main_win the main window the viewer belongs to.
- * @param start the start time of the first event to be processed.
- * @param end the end time of the last event to be processed.
- */
-
-void process_traceset_api(MainWindow *main_win, LttTime start, 
-                         LttTime end, unsigned maxNumEvents);
-
-
-/**
- * Function to add hooks into the context of a traceset,
- * before reading events from traceset, viewer will call this api to
- * register hooks
- * @param main_win the main window the viewer belongs to.
- * @param LttvHooks hooks to be registered.
- */
-
-void context_add_hooks_api(MainWindow *main_win ,
-                          LttvHooks *before_traceset, 
-                          LttvHooks *after_traceset,
-                          LttvHooks *check_trace, 
-                          LttvHooks *before_trace, 
-                          LttvHooks *after_trace, 
-                          LttvHooks *check_tracefile,
-                          LttvHooks *before_tracefile,
-                          LttvHooks *after_tracefile,
-                          LttvHooks *check_event, 
-                          LttvHooks *before_event, 
-                          LttvHooks *after_event);
-
-
-/**
- * Function to remove hooks from the context of a traceset,
- * before reading events from traceset, viewer will call this api to
- * unregister hooks
- * @param main_win the main window the viewer belongs to.
- * @param LttvHooks hooks to be registered.
- */
-
-void context_remove_hooks_api(MainWindow *main_win ,
-                             LttvHooks *before_traceset, 
-                             LttvHooks *after_traceset,
-                             LttvHooks *check_trace, 
-                             LttvHooks *before_trace, 
-                             LttvHooks *after_trace, 
-                             LttvHooks *check_tracefile,
-                             LttvHooks *before_tracefile,
-                             LttvHooks *after_tracefile,
-                             LttvHooks *check_event, 
-                             LttvHooks *before_event, 
-                             LttvHooks *after_event);
-
-
-/**
- * Function to get the life span of the traceset
- * @param main_win the main window the viewer belongs to.
- * @param start start time of the traceset.
- * @param end end time of the traceset.
- */
-
-void get_traceset_time_span(MainWindow *main_win, TimeInterval *time_span);
-
-
-/**
- * Function to add/remove event hooks for state 
- * @param main_win the main window the viewer belongs to.
- */
-
-void state_add_event_hooks_api(MainWindow *main_win );
-void state_remove_event_hooks_api(MainWindow *main_win );
-
-
-/**
- * Function to add/remove event hooks for stats 
- * @param main_win the main window the viewer belongs to.
- */
-
-void stats_add_event_hooks_api(MainWindow *main_win );
-void stats_remove_event_hooks_api(MainWindow *main_win );
-
-
-/**
- * Function to get the stats of the traceset 
- * @param main_win the main window the viewer belongs to.
- */
-
-LttvTracesetStats* get_traceset_stats_api(MainWindow *main_win);
-
-LttvTracesetContext* get_traceset_context(MainWindow *main_win);
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/init_module.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/init_module.c
deleted file mode 100644 (file)
index a6d63cb..0000000
+++ /dev/null
@@ -1,190 +0,0 @@
-/* This file is part of the Linux Trace Toolkit viewer
- * Copyright (C) 2003-2004 Mathieu Desnoyers and 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.
- */
-
-/*
- * Initial main.c file generated by Glade. Edit as required.
- * Glade will not overwrite this file.
- */
-
-#ifdef HAVE_CONFIG_H
-#  include <config.h>
-#endif
-
-#include <gtk/gtk.h>
-
-#include <lttv/lttv.h>
-#include <lttv/attribute.h>
-#include <lttv/hook.h>
-#include <lttv/option.h>
-#include <lttv/module.h>
-#include <lttv/tracecontext.h>
-#include <lttv/state.h>
-#include <lttv/stats.h>
-#include <lttvwindow/menu.h>
-#include <lttvwindow/toolbar.h>
-
-#include "interface.h"
-#include "support.h"
-#include <lttvwindow/mainwindow.h>
-#include "callbacks.h"
-#include <ltt/trace.h>
-
-
-/** Array containing instanced objects. */
-GSList * g_main_window_list = NULL ;
-
-LttvHooks
-  *main_hooks;
-
-/* Initial trace from command line */
-LttvTrace *g_init_trace = NULL;
-
-static char *a_trace;
-
-void lttv_trace_option(void *hook_data)
-{ 
-  LttTrace *trace;
-
-  trace = ltt_trace_open(a_trace);
-  if(trace == NULL) g_critical("cannot open trace %s", a_trace);
-  g_init_trace = lttv_trace_new(trace);
-}
-
-/*****************************************************************************
- *                 Functions for module loading/unloading                    *
- *****************************************************************************/
-/**
- * plugin's init function
- *
- * This function initializes the GUI.
- */
-
-static gboolean window_creation_hook(void *hook_data, void *call_data)
-{
-  g_debug("GUI window_creation_hook()");
-#ifdef ENABLE_NLS
-  bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
-  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
-  textdomain (GETTEXT_PACKAGE);
-#endif
-
-  gtk_set_locale ();
-  gtk_init (&lttv_argc, &lttv_argv);
-
-  add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps");
-  add_pixmap_directory ("pixmaps");
-  add_pixmap_directory ("../modules/gui/main/pixmaps");
-
-  construct_main_window(NULL);
-
-  gtk_main ();
-
-  return FALSE;
-}
-
-static void init() {
-
-  LttvAttributeValue value;
-  // Global attributes only used for interaction with main() here.
-  LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes());
-  
-  g_debug("GUI init()");
-  
-  lttv_option_add("trace", 't', 
-      "add a trace to the trace set to analyse", 
-      "pathname of the directory containing the trace", 
-      LTTV_OPT_STRING, &a_trace, lttv_trace_option, NULL);
-
-  g_assert(lttv_iattribute_find_by_path(attributes, "hooks/main/before",
-      LTTV_POINTER, &value));
-  g_assert((main_hooks = *(value.v_pointer)) != NULL);
-
-  lttv_hooks_add(main_hooks, window_creation_hook, NULL);
-
-}
-
-void
-main_window_free(MainWindow * mw)
-{ 
-  if(mw){
-    while(mw->tab){
-      lttv_state_remove_event_hooks(
-           (LttvTracesetState*)mw->tab->traceset_info->traceset_context);
-      mw->tab = mw->tab->next;
-    }
-    g_object_unref(mw->attributes);
-    g_main_window_list = g_slist_remove(g_main_window_list, mw);
-
-    g_hash_table_destroy(mw->hash_menu_item);
-    g_hash_table_destroy(mw->hash_toolbar_item);
-    
-    g_free(mw);
-    mw = NULL;
-  }
-}
-
-void
-main_window_destructor(MainWindow * mw)
-{
-  if(GTK_IS_WIDGET(mw->mwindow)){
-    gtk_widget_destroy(mw->mwindow);
-    //    gtk_widget_destroy(mw->HelpContents);
-    //    gtk_widget_destroy(mw->AboutBox);    
-    mw = NULL;
-  }
-  //main_window_free called when the object mw in the widget is unref.
-  //main_window_free(mw);
-}
-
-
-void main_window_destroy_walk(gpointer data, gpointer user_data)
-{
-  main_window_destructor((MainWindow*)data);
-}
-
-
-
-/**
- * plugin's destroy function
- *
- * This function releases the memory reserved by the module and unregisters
- * everything that has been registered in the gtkTraceSet API.
- */
-static void destroy() {
-
-  LttvAttributeValue value;  
-  LttvTrace *trace;
-
-  lttv_option_remove("trace");
-
-  lttv_hooks_remove_data(main_hooks, window_creation_hook, NULL);
-
-  g_debug("GUI destroy()");
-
-  if(g_main_window_list){
-    g_slist_foreach(g_main_window_list, main_window_destroy_walk, NULL );
-    g_slist_free(g_main_window_list);
-  }
-  
-}
-
-
-LTTV_MODULE("lttvwindow", "Viewer main window", \
-    "Viewer with multiple windows, tabs and panes for graphical modules", \
-           init, destroy, "stats")
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/interface.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/interface.c
deleted file mode 100644 (file)
index ee08b8e..0000000
+++ /dev/null
@@ -1,856 +0,0 @@
-/* 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.
- */
-
-/*
- * DO NOT EDIT THIS FILE - it is generated by Glade.
- */
-
-#ifdef HAVE_CONFIG_H
-#  include <config.h>
-#endif
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdio.h>
-
-#include <gdk/gdkkeysyms.h>
-#include <gtk/gtk.h>
-
-#include "callbacks.h"
-#include "interface.h"
-#include "support.h"
-
-#define GLADE_HOOKUP_OBJECT(component,widget,name) \
-  g_object_set_data_full (G_OBJECT (component), name, \
-    gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref)
-
-#define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \
-  g_object_set_data (G_OBJECT (component), name, widget)
-
-GtkWidget*
-create_MWindow (void)
-{
-  GtkWidget *MWindow;
-  GtkWidget *MVbox;
-  GtkWidget *MMenuBox;
-  GtkWidget *MenuMain;
-  GtkWidget *FileMenuTitle;
-  GtkWidget *FileMenuTitle_menu;
-  GtkWidget *FileMenuNewTitle;
-  GtkWidget *FileMenuNewTitle_menu;
-  //  GtkWidget *EmptyTraceset;
-  GtkWidget *CloneTraceset;
-  GtkWidget *FileMenuNewSep;
-  GtkWidget *Tab;
-  //  GtkWidget *OpenTraceset;
-  GtkWidget *Close;
-  GtkWidget *CloseTab;
-  GtkWidget *FileMenuSeparator1;
-  GtkWidget *AddTrace;
-  GtkWidget *RemoveTrace;
-  //  GtkWidget *Save;
-  //  GtkWidget *SaveAs;
-  GtkWidget *FileMenuSeparator2;
-  GtkWidget *Quit;
-  //  GtkWidget *EditMenuTitle;
-  //  GtkWidget *EditMenuTitle_menu;
-  //  GtkWidget *Cut;
-  //  GtkWidget *Copy;
-  //  GtkWidget *Paste;
-  //  GtkWidget *Delete;
-  GtkWidget *ViewMenuTitle;
-  GtkWidget *ViewMenuTitle_menu;
-  GtkWidget *ZoomIn;
-  GtkWidget *ZoomOut;
-  GtkWidget *ZoomExtended;
-  GtkWidget *ViewMenuSeparator;
-  //  GtkWidget *GoToTime;
-  //  GtkWidget *ShowTimeFrame;
-  GtkWidget *ToolMenuTitle;
-  GtkWidget *ToolMenuTitle_menu;
-  GtkWidget *MoveViewerUp;
-  GtkWidget *MoveViewerDown;
-  GtkWidget *RemoveViewer;
-  GtkWidget *ToolMenuSeparator;
-  GtkWidget *Filter;
-  //  GtkWidget *Facility;
-  GtkWidget *ToolMenuSeparator1;
-  //  GtkWidget *insert_viewer_test;
-  GtkWidget *PluginMenuTitle;
-  GtkWidget *PluginMenuTitle_menu;
-  GtkWidget *LoadModule;
-  GtkWidget *UnloadModule;
-  GtkWidget *AddModuleSearchPath;
-  //  GtkWidget *OptionMenuTitle;
-  //  GtkWidget *OptionMenuTitle_menu;
-  //  GtkWidget *Color;
-  //  GtkWidget *OptMenuSeparator;
-  //  GtkWidget *OpenFilter;
-  //  GtkWidget *SaveConfiguration;
-  GtkWidget *MenuHelp;
-  GtkWidget *HelpMenuTitle;
-  GtkWidget *HelpMenu;
-  GtkWidget *Content;
-  GtkWidget *HelpmenuSeparator;
-  GtkWidget *About;
-  GtkWidget *MToolbar1;
-  GtkWidget *tmp_toolbar_icon;
-  GtkWidget *tlbEmptyTraceset;
-  GtkWidget *tlbTab;
-  //  GtkWidget *tlbOpenTraceset;
-  GtkWidget *tlbAddTrace;
-  GtkWidget *tlbRemoveTrace;
-  //  GtkWidget *tlbSave;
-  //  GtkWidget *tlbSaveAs;
-  GtkWidget *tlbZoomIn;
-  GtkWidget *tlbZoomOut;
-  GtkWidget *tlbZoomExtended;
-  //  GtkWidget *tlbGoToTime;
-  //  GtkWidget *tlbShowTimeFrame;
-  GtkWidget *tlbMoveViewerUp;
-  GtkWidget *tlbMoveViewerDown;
-  GtkWidget *tlbRemoveViewer;
-  GtkWidget *MToolbar2;
-  GtkWidget *MNotebook;
-  //  GtkWidget *empty_notebook_page;
-  //  GtkWidget *label1;
-  GtkWidget *MStatusbar;
-  GtkAccelGroup *accel_group;
-
-  accel_group = gtk_accel_group_new ();
-
-  MWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-  gtk_widget_set_size_request (MWindow, 100, 50);
-  gtk_window_set_title (GTK_WINDOW (MWindow), "LTT");
-  gtk_window_set_default_size (GTK_WINDOW (MWindow), 600, 400);
-
-  MVbox = gtk_vbox_new (FALSE, 0);
-  gtk_widget_show (MVbox);
-  gtk_container_add (GTK_CONTAINER (MWindow), MVbox);
-
-  MMenuBox = gtk_hbox_new (FALSE, 0);
-  gtk_widget_show (MMenuBox);
-  gtk_box_pack_start (GTK_BOX (MVbox), MMenuBox, FALSE, FALSE, 0);
-
-  MenuMain = gtk_menu_bar_new ();
-  gtk_widget_show (MenuMain);
-  gtk_box_pack_start (GTK_BOX (MMenuBox), MenuMain, FALSE, FALSE, 0);
-
-  FileMenuTitle = gtk_menu_item_new_with_mnemonic ("_File");
-  gtk_widget_show (FileMenuTitle);
-  gtk_container_add (GTK_CONTAINER (MenuMain), FileMenuTitle);
-
-  FileMenuTitle_menu = gtk_menu_new ();
-  gtk_menu_item_set_submenu (GTK_MENU_ITEM (FileMenuTitle), FileMenuTitle_menu);
-
-  FileMenuNewTitle = gtk_menu_item_new_with_mnemonic ("New");
-  gtk_widget_show (FileMenuNewTitle);
-  gtk_container_add (GTK_CONTAINER (FileMenuTitle_menu), FileMenuNewTitle);
-
-  FileMenuNewTitle_menu = gtk_menu_new ();
-  gtk_menu_item_set_submenu (GTK_MENU_ITEM (FileMenuNewTitle), FileMenuNewTitle_menu);
-
-  //  EmptyTraceset = gtk_menu_item_new_with_mnemonic ("Empty trace set");
-  //  gtk_widget_show (EmptyTraceset);
-  //  gtk_container_add (GTK_CONTAINER (FileMenuNewTitle_menu), EmptyTraceset);
-
-  //  CloneTraceset = gtk_menu_item_new_with_mnemonic ("Clone trace set");
-  CloneTraceset = gtk_menu_item_new_with_mnemonic ("New window");
-  gtk_widget_show (CloneTraceset);
-  gtk_container_add (GTK_CONTAINER (FileMenuNewTitle_menu), CloneTraceset);
-
-  FileMenuNewSep = gtk_menu_item_new ();
-  gtk_widget_show (FileMenuNewSep);
-  gtk_container_add (GTK_CONTAINER (FileMenuNewTitle_menu), FileMenuNewSep);
-  gtk_widget_set_sensitive (FileMenuNewSep, FALSE);
-
-  Tab = gtk_menu_item_new_with_mnemonic ("Tab");
-  gtk_widget_show (Tab);
-  gtk_container_add (GTK_CONTAINER (FileMenuNewTitle_menu), Tab);
-/*
-  OpenTraceset = gtk_menu_item_new_with_mnemonic ("Open");
-  gtk_widget_show (OpenTraceset);
-  gtk_container_add (GTK_CONTAINER (FileMenuTitle_menu), OpenTraceset);
-*/
-  Close = gtk_menu_item_new_with_mnemonic ("Close");
-  gtk_widget_show (Close);
-  gtk_container_add (GTK_CONTAINER (FileMenuTitle_menu), Close);
-
-  CloseTab = gtk_menu_item_new_with_mnemonic ("Close Tab");
-  gtk_widget_show (CloseTab);
-  gtk_container_add (GTK_CONTAINER (FileMenuTitle_menu), CloseTab);
-
-  FileMenuSeparator1 = gtk_menu_item_new ();
-  gtk_widget_show (FileMenuSeparator1);
-  gtk_container_add (GTK_CONTAINER (FileMenuTitle_menu), FileMenuSeparator1);
-  gtk_widget_set_sensitive (FileMenuSeparator1, FALSE);
-
-  AddTrace = gtk_menu_item_new_with_mnemonic ("Add Trace");
-  gtk_widget_show (AddTrace);
-  gtk_container_add (GTK_CONTAINER (FileMenuTitle_menu), AddTrace);
-
-  RemoveTrace = gtk_menu_item_new_with_mnemonic ("Remove Trace");
-  gtk_widget_show (RemoveTrace);
-  gtk_container_add (GTK_CONTAINER (FileMenuTitle_menu), RemoveTrace);
-/*
-  Save = gtk_menu_item_new_with_mnemonic ("Save");
-  gtk_widget_show (Save);
-  gtk_container_add (GTK_CONTAINER (FileMenuTitle_menu), Save);
-
-  SaveAs = gtk_menu_item_new_with_mnemonic ("Save As");
-  gtk_widget_show (SaveAs);
-  gtk_container_add (GTK_CONTAINER (FileMenuTitle_menu), SaveAs);
-*/
-  FileMenuSeparator2 = gtk_menu_item_new ();
-  gtk_widget_show (FileMenuSeparator2);
-  gtk_container_add (GTK_CONTAINER (FileMenuTitle_menu), FileMenuSeparator2);
-  gtk_widget_set_sensitive (FileMenuSeparator2, FALSE);
-
-  Quit = gtk_menu_item_new_with_mnemonic ("Quit");
-  gtk_widget_show (Quit);
-  gtk_container_add (GTK_CONTAINER (FileMenuTitle_menu), Quit);
-/*
-  EditMenuTitle = gtk_menu_item_new_with_mnemonic ("_Edit");
-  gtk_widget_show (EditMenuTitle);
-  gtk_container_add (GTK_CONTAINER (MenuMain), EditMenuTitle);
-
-  EditMenuTitle_menu = gtk_menu_new ();
-  gtk_menu_item_set_submenu (GTK_MENU_ITEM (EditMenuTitle), EditMenuTitle_menu);
-
-  Cut = gtk_image_menu_item_new_from_stock ("gtk-cut", accel_group);
-  gtk_widget_show (Cut);
-  gtk_container_add (GTK_CONTAINER (EditMenuTitle_menu), Cut);
-
-  Copy = gtk_image_menu_item_new_from_stock ("gtk-copy", accel_group);
-  gtk_widget_show (Copy);
-  gtk_container_add (GTK_CONTAINER (EditMenuTitle_menu), Copy);
-
-  Paste = gtk_image_menu_item_new_from_stock ("gtk-paste", accel_group);
-  gtk_widget_show (Paste);
-  gtk_container_add (GTK_CONTAINER (EditMenuTitle_menu), Paste);
-
-  Delete = gtk_image_menu_item_new_from_stock ("gtk-delete", accel_group);
-  gtk_widget_show (Delete);
-  gtk_container_add (GTK_CONTAINER (EditMenuTitle_menu), Delete);
-*/
-  ViewMenuTitle = gtk_menu_item_new_with_mnemonic ("_View");
-  gtk_widget_show (ViewMenuTitle);
-  gtk_container_add (GTK_CONTAINER (MenuMain), ViewMenuTitle);
-
-  ViewMenuTitle_menu = gtk_menu_new ();
-  gtk_menu_item_set_submenu (GTK_MENU_ITEM (ViewMenuTitle), ViewMenuTitle_menu);
-
-  ZoomIn = gtk_menu_item_new_with_mnemonic ("Zoom in");
-  gtk_widget_show (ZoomIn);
-  gtk_container_add (GTK_CONTAINER (ViewMenuTitle_menu), ZoomIn);
-
-  ZoomOut = gtk_menu_item_new_with_mnemonic ("Zoom out");
-  gtk_widget_show (ZoomOut);
-  gtk_container_add (GTK_CONTAINER (ViewMenuTitle_menu), ZoomOut);
-
-  ZoomExtended = gtk_menu_item_new_with_mnemonic ("Zoom extended");
-  gtk_widget_show (ZoomExtended);
-  gtk_container_add (GTK_CONTAINER (ViewMenuTitle_menu), ZoomExtended);
-
-  ViewMenuSeparator = gtk_menu_item_new ();
-  gtk_widget_show (ViewMenuSeparator);
-  gtk_container_add (GTK_CONTAINER (ViewMenuTitle_menu), ViewMenuSeparator);
-  gtk_widget_set_sensitive (ViewMenuSeparator, FALSE);
-/*
-  GoToTime = gtk_menu_item_new_with_mnemonic ("Go to time");
-  gtk_widget_show (GoToTime);
-  gtk_container_add (GTK_CONTAINER (ViewMenuTitle_menu), GoToTime);
-
-  ShowTimeFrame = gtk_menu_item_new_with_mnemonic ("Show time frame");
-  gtk_widget_show (ShowTimeFrame);
-  gtk_container_add (GTK_CONTAINER (ViewMenuTitle_menu), ShowTimeFrame);
-*/
-  ToolMenuTitle = gtk_menu_item_new_with_mnemonic ("Tools");
-  gtk_widget_show (ToolMenuTitle);
-  gtk_container_add (GTK_CONTAINER (MenuMain), ToolMenuTitle);
-
-  ToolMenuTitle_menu = gtk_menu_new ();
-  gtk_menu_item_set_submenu (GTK_MENU_ITEM (ToolMenuTitle), ToolMenuTitle_menu);
-
-  MoveViewerUp = gtk_menu_item_new_with_mnemonic ("Move viewer up");
-  gtk_widget_show (MoveViewerUp);
-  gtk_container_add (GTK_CONTAINER (ToolMenuTitle_menu), MoveViewerUp);
-
-  MoveViewerDown = gtk_menu_item_new_with_mnemonic ("Move viewer down");
-  gtk_widget_show (MoveViewerDown);
-  gtk_container_add (GTK_CONTAINER (ToolMenuTitle_menu), MoveViewerDown);
-
-  RemoveViewer = gtk_menu_item_new_with_mnemonic ("Remove viewer");
-  gtk_widget_show (RemoveViewer);
-  gtk_container_add (GTK_CONTAINER (ToolMenuTitle_menu), RemoveViewer);
-
-  ToolMenuSeparator = gtk_menu_item_new ();
-  gtk_widget_show (ToolMenuSeparator);
-  gtk_container_add (GTK_CONTAINER (ToolMenuTitle_menu), ToolMenuSeparator);
-  gtk_widget_set_sensitive (ToolMenuSeparator, FALSE);
-
-  Filter = gtk_menu_item_new_with_mnemonic ("Trace Filter Selector");
-  gtk_widget_show (Filter);
-  gtk_container_add (GTK_CONTAINER (ToolMenuTitle_menu), Filter);
-
-  //  Facility = gtk_menu_item_new_with_mnemonic ("Facility Selector");
-  //  gtk_widget_show (Facility);
-  //  gtk_container_add (GTK_CONTAINER (ToolMenuTitle_menu), Facility);
-
-  ToolMenuSeparator1 = gtk_menu_item_new ();
-  gtk_widget_show (ToolMenuSeparator1);
-  gtk_container_add (GTK_CONTAINER (ToolMenuTitle_menu), ToolMenuSeparator1);
-  gtk_widget_set_sensitive (ToolMenuSeparator1, FALSE);
-
-  //  insert_viewer_test = gtk_menu_item_new_with_mnemonic ("Insert viewer test");
-  //  gtk_widget_show (insert_viewer_test);
-  //  gtk_container_add (GTK_CONTAINER (ToolMenuTitle_menu), insert_viewer_test);
-
-  PluginMenuTitle = gtk_menu_item_new_with_mnemonic ("Plugins");
-  gtk_widget_show (PluginMenuTitle);
-  gtk_container_add (GTK_CONTAINER (MenuMain), PluginMenuTitle);
-
-  PluginMenuTitle_menu = gtk_menu_new ();
-  gtk_menu_item_set_submenu (GTK_MENU_ITEM (PluginMenuTitle), PluginMenuTitle_menu);
-
-  LoadModule = gtk_menu_item_new_with_mnemonic ("Load module");
-  gtk_widget_show (LoadModule);
-  gtk_container_add (GTK_CONTAINER (PluginMenuTitle_menu), LoadModule);
-
-  UnloadModule = gtk_menu_item_new_with_mnemonic ("Unload module");
-  gtk_widget_show (UnloadModule);
-  gtk_container_add (GTK_CONTAINER (PluginMenuTitle_menu), UnloadModule);
-
-  AddModuleSearchPath = gtk_menu_item_new_with_mnemonic ("Add module search path");
-  gtk_widget_show (AddModuleSearchPath);
-  gtk_container_add (GTK_CONTAINER (PluginMenuTitle_menu), AddModuleSearchPath);
-/*
-  OptionMenuTitle = gtk_menu_item_new_with_mnemonic ("Options");
-  gtk_widget_show (OptionMenuTitle);
-  gtk_container_add (GTK_CONTAINER (MenuMain), OptionMenuTitle);
-
-  OptionMenuTitle_menu = gtk_menu_new ();
-  gtk_menu_item_set_submenu (GTK_MENU_ITEM (OptionMenuTitle), OptionMenuTitle_menu);
-
-  Color = gtk_menu_item_new_with_mnemonic ("Color");
-  gtk_widget_show (Color);
-  gtk_container_add (GTK_CONTAINER (OptionMenuTitle_menu), Color);
-
-  OptMenuSeparator = gtk_menu_item_new ();
-  gtk_widget_show (OptMenuSeparator);
-  gtk_container_add (GTK_CONTAINER (OptionMenuTitle_menu), OptMenuSeparator);
-  gtk_widget_set_sensitive (OptMenuSeparator, FALSE);
-
-  OpenFilter = gtk_menu_item_new_with_mnemonic ("Filter");
-  gtk_widget_show (OpenFilter);
-  gtk_container_add (GTK_CONTAINER (OptionMenuTitle_menu), OpenFilter);
-
-  SaveConfiguration = gtk_menu_item_new_with_mnemonic ("Save configuration");
-  gtk_widget_show (SaveConfiguration);
-  gtk_container_add (GTK_CONTAINER (OptionMenuTitle_menu), SaveConfiguration);
-*/
-  MenuHelp = gtk_menu_bar_new ();
-  gtk_widget_show (MenuHelp);
-  gtk_box_pack_end (GTK_BOX (MMenuBox), MenuHelp, FALSE, FALSE, 0);
-
-  HelpMenuTitle = gtk_menu_item_new_with_mnemonic ("_Help");
-  gtk_widget_show (HelpMenuTitle);
-  gtk_container_add (GTK_CONTAINER (MenuHelp), HelpMenuTitle);
-
-  HelpMenu = gtk_menu_new ();
-  gtk_menu_item_set_submenu (GTK_MENU_ITEM (HelpMenuTitle), HelpMenu);
-
-  Content = gtk_menu_item_new_with_mnemonic ("Content");
-  gtk_widget_show (Content);
-  gtk_container_add (GTK_CONTAINER (HelpMenu), Content);
-
-  HelpmenuSeparator = gtk_menu_item_new ();
-  gtk_widget_show (HelpmenuSeparator);
-  gtk_container_add (GTK_CONTAINER (HelpMenu), HelpmenuSeparator);
-  gtk_widget_set_sensitive (HelpmenuSeparator, FALSE);
-
-  About = gtk_menu_item_new_with_mnemonic ("About...");
-  gtk_widget_show (About);
-  gtk_container_add (GTK_CONTAINER (HelpMenu), About);
-
-  MToolbar1 = gtk_toolbar_new ();
-  gtk_widget_show (MToolbar1);
-  gtk_box_pack_start (GTK_BOX (MVbox), MToolbar1, FALSE, FALSE, 0);
-  gtk_toolbar_set_style (GTK_TOOLBAR (MToolbar1), GTK_TOOLBAR_ICONS);
-
-  tmp_toolbar_icon = create_pixmap (MWindow, "filenew.png");
-  tlbEmptyTraceset = gtk_toolbar_append_element (GTK_TOOLBAR (MToolbar1),
-                                GTK_TOOLBAR_CHILD_BUTTON,
-                                NULL,
-                                "",
-                                "New window", NULL,
-                               //"New window with empty trace set", NULL,
-                                tmp_toolbar_icon, NULL, NULL);
-  gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (MToolbar1)->children)->data))->label), TRUE);
-  gtk_widget_show (tlbEmptyTraceset);
-  gtk_container_set_border_width (GTK_CONTAINER (tlbEmptyTraceset), 1);
-
-  tmp_toolbar_icon = create_pixmap (MWindow, "filenew.png");
-  tlbTab = gtk_toolbar_append_element (GTK_TOOLBAR (MToolbar1),
-                                GTK_TOOLBAR_CHILD_BUTTON,
-                                NULL,
-                                "",
-                                "New tab", NULL,
-                                tmp_toolbar_icon, NULL, NULL);
-  gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (MToolbar1)->children)->data))->label), TRUE);
-  gtk_widget_show (tlbTab);
-  gtk_container_set_border_width (GTK_CONTAINER (tlbTab), 1);
-
-/*
-  tmp_toolbar_icon = create_pixmap (MWindow, "fileopen.png");
-  tlbOpenTraceset = gtk_toolbar_append_element (GTK_TOOLBAR (MToolbar1),
-                                GTK_TOOLBAR_CHILD_BUTTON,
-                                NULL,
-                                "",
-                                "open a trace set", NULL,
-                                tmp_toolbar_icon, NULL, NULL);
-  gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (MToolbar1)->children)->data))->label), TRUE);
-  gtk_widget_show (tlbOpenTraceset);
-  gtk_container_set_border_width (GTK_CONTAINER (tlbOpenTraceset), 1);
-*/
-  tmp_toolbar_icon = create_pixmap (MWindow, "edit_add_22.png");
-  tlbAddTrace = gtk_toolbar_append_element (GTK_TOOLBAR (MToolbar1),
-                                GTK_TOOLBAR_CHILD_BUTTON,
-                                NULL,
-                                "",
-                                "Add a trace ", NULL,
-                                tmp_toolbar_icon, NULL, NULL);
-  gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (MToolbar1)->children)->data))->label), TRUE);
-  gtk_widget_show (tlbAddTrace);
-  gtk_container_set_border_width (GTK_CONTAINER (tlbAddTrace), 1);
-
-  tmp_toolbar_icon = create_pixmap (MWindow, "edit_remove_22.png");
-  tlbRemoveTrace = gtk_toolbar_append_element (GTK_TOOLBAR (MToolbar1),
-                                GTK_TOOLBAR_CHILD_BUTTON,
-                                NULL,
-                                "",
-                                "Remove a trace", NULL,
-                                tmp_toolbar_icon, NULL, NULL);
-  gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (MToolbar1)->children)->data))->label), TRUE);
-  gtk_widget_show (tlbRemoveTrace);
-  gtk_container_set_border_width (GTK_CONTAINER (tlbRemoveTrace), 1);
-/*
-  tmp_toolbar_icon = create_pixmap (MWindow, "filesave.png");
-  tlbSave = gtk_toolbar_append_element (GTK_TOOLBAR (MToolbar1),
-                                GTK_TOOLBAR_CHILD_BUTTON,
-                                NULL,
-                                "",
-                                "save the current trace set", NULL,
-                                tmp_toolbar_icon, NULL, NULL);
-  gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (MToolbar1)->children)->data))->label), TRUE);
-  gtk_widget_show (tlbSave);
-  gtk_container_set_border_width (GTK_CONTAINER (tlbSave), 1);
-
-  tmp_toolbar_icon = create_pixmap (MWindow, "filesaveas.png");
-  tlbSaveAs = gtk_toolbar_append_element (GTK_TOOLBAR (MToolbar1),
-                                GTK_TOOLBAR_CHILD_BUTTON,
-                                NULL,
-                                "",
-                                "save as ", NULL,
-                                tmp_toolbar_icon, NULL, NULL);
-  gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (MToolbar1)->children)->data))->label), TRUE);
-  gtk_widget_show (tlbSaveAs);
-  gtk_container_set_border_width (GTK_CONTAINER (tlbSaveAs), 1);
-*/
-  gtk_toolbar_append_space (GTK_TOOLBAR (MToolbar1));
-
-  tmp_toolbar_icon = create_pixmap (MWindow, "stock_zoom_in_24.png");
-  tlbZoomIn = gtk_toolbar_append_element (GTK_TOOLBAR (MToolbar1),
-                                GTK_TOOLBAR_CHILD_BUTTON,
-                                NULL,
-                                "",
-                                "Zoom in", NULL,
-                                tmp_toolbar_icon, NULL, NULL);
-  gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (MToolbar1)->children)->data))->label), TRUE);
-  gtk_widget_show (tlbZoomIn);
-  gtk_container_set_border_width (GTK_CONTAINER (tlbZoomIn), 1);
-
-  tmp_toolbar_icon = create_pixmap (MWindow, "stock_zoom_out_24.png");
-  tlbZoomOut = gtk_toolbar_append_element (GTK_TOOLBAR (MToolbar1),
-                                GTK_TOOLBAR_CHILD_BUTTON,
-                                NULL,
-                                "",
-                                "Zoom out", NULL,
-                                tmp_toolbar_icon, NULL, NULL);
-  gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (MToolbar1)->children)->data))->label), TRUE);
-  gtk_widget_show (tlbZoomOut);
-  gtk_container_set_border_width (GTK_CONTAINER (tlbZoomOut), 1);
-
-  tmp_toolbar_icon = create_pixmap (MWindow, "stock_zoom_fit_24.png");
-  tlbZoomExtended = gtk_toolbar_append_element (GTK_TOOLBAR (MToolbar1),
-                                GTK_TOOLBAR_CHILD_BUTTON,
-                                NULL,
-                                "",
-                                "Zoom extended", NULL,
-                                tmp_toolbar_icon, NULL, NULL);
-  gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (MToolbar1)->children)->data))->label), TRUE);
-  gtk_widget_show (tlbZoomExtended);
-  gtk_container_set_border_width (GTK_CONTAINER (tlbZoomExtended), 1);
-/*
-  tmp_toolbar_icon = create_pixmap (MWindow, "gtk-jump-to.png");
-  tlbGoToTime = gtk_toolbar_append_element (GTK_TOOLBAR (MToolbar1),
-                                GTK_TOOLBAR_CHILD_BUTTON,
-                                NULL,
-                                "",
-                                "Go to time", NULL,
-                                tmp_toolbar_icon, NULL, NULL);
-  gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (MToolbar1)->children)->data))->label), TRUE);
-  gtk_widget_show (tlbGoToTime);
-  gtk_container_set_border_width (GTK_CONTAINER (tlbGoToTime), 1);
-
-  tmp_toolbar_icon = create_pixmap (MWindow, "mini-display.xpm");
-  tlbShowTimeFrame = gtk_toolbar_append_element (GTK_TOOLBAR (MToolbar1),
-                                GTK_TOOLBAR_CHILD_BUTTON,
-                                NULL,
-                                "",
-                                "Show time frame", NULL,
-                                tmp_toolbar_icon, NULL, NULL);
-  gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (MToolbar1)->children)->data))->label), TRUE);
-  gtk_widget_show (tlbShowTimeFrame);
-  gtk_container_set_border_width (GTK_CONTAINER (tlbShowTimeFrame), 1);
-*/
-  gtk_toolbar_append_space (GTK_TOOLBAR (MToolbar1));
-
-  tmp_toolbar_icon = create_pixmap (MWindow, "1uparrow.png");
-  tlbMoveViewerUp = gtk_toolbar_append_element (GTK_TOOLBAR (MToolbar1),
-                                GTK_TOOLBAR_CHILD_BUTTON,
-                                NULL,
-                                "",
-                                "Move up current viewer", NULL,
-                                tmp_toolbar_icon, NULL, NULL);
-  gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (MToolbar1)->children)->data))->label), TRUE);
-  gtk_widget_show (tlbMoveViewerUp);
-  gtk_container_set_border_width (GTK_CONTAINER (tlbMoveViewerUp), 1);
-
-  tmp_toolbar_icon = create_pixmap (MWindow, "1downarrow.png");
-  tlbMoveViewerDown = gtk_toolbar_append_element (GTK_TOOLBAR (MToolbar1),
-                                GTK_TOOLBAR_CHILD_BUTTON,
-                                NULL,
-                                "",
-                                "Move down current viewer", NULL,
-                                tmp_toolbar_icon, NULL, NULL);
-  gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (MToolbar1)->children)->data))->label), TRUE);
-  gtk_widget_show (tlbMoveViewerDown);
-  gtk_container_set_border_width (GTK_CONTAINER (tlbMoveViewerDown), 1);
-
-  tmp_toolbar_icon = create_pixmap (MWindow, "remove.png");
-  tlbRemoveViewer = gtk_toolbar_append_element (GTK_TOOLBAR (MToolbar1),
-                                GTK_TOOLBAR_CHILD_BUTTON,
-                                NULL,
-                                "",
-                                "Delete current viewer", NULL,
-                                tmp_toolbar_icon, NULL, NULL);
-  gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (MToolbar1)->children)->data))->label), TRUE);
-  gtk_widget_show (tlbRemoveViewer);
-  gtk_container_set_border_width (GTK_CONTAINER (tlbRemoveViewer), 1);
-
-  gtk_toolbar_append_space (GTK_TOOLBAR (MToolbar1));
-
-  //  MToolbar2 = gtk_toolbar_new ();
-  //  gtk_widget_show (MToolbar2);
-  //  gtk_box_pack_start (GTK_BOX (MVbox), MToolbar2, FALSE, FALSE, 0);
-  //  gtk_toolbar_set_style (GTK_TOOLBAR (MToolbar2), GTK_TOOLBAR_ICONS);
-
-  MNotebook = gtk_notebook_new ();
-  gtk_widget_show (MNotebook);
-  gtk_notebook_set_show_tabs((GtkNotebook*)MNotebook, FALSE);
-  gtk_box_pack_start (GTK_BOX (MVbox), MNotebook, TRUE, TRUE, 0);
-/*
-  empty_notebook_page = gtk_vbox_new (FALSE, 0);
-  gtk_widget_show (empty_notebook_page);
-  gtk_container_add (GTK_CONTAINER (MNotebook), empty_notebook_page);
-
-  label1 = gtk_label_new ("");
-  gtk_widget_show (label1);
-  gtk_notebook_set_tab_label (GTK_NOTEBOOK (MNotebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (MNotebook), 0), label1);
-  gtk_label_set_justify (GTK_LABEL (label1), GTK_JUSTIFY_LEFT);
-*/
-  MStatusbar = gtk_statusbar_new ();
-  gtk_widget_show (MStatusbar);
-  gtk_box_pack_start (GTK_BOX (MVbox), MStatusbar, FALSE, FALSE, 0);
-
-  g_signal_connect ((gpointer) MWindow, "destroy",
-                    G_CALLBACK (on_MWindow_destroy),
-                    NULL);
-  g_signal_connect ((gpointer) MWindow, "configure-event",
-                    G_CALLBACK (on_MWindow_configure),
-                    NULL);
-  //  g_signal_connect ((gpointer) EmptyTraceset, "activate",
-  //                    G_CALLBACK (on_empty_traceset_activate),
-  //                    NULL);
-  g_signal_connect ((gpointer) CloneTraceset, "activate",
-                    G_CALLBACK (on_clone_traceset_activate),
-                    NULL);
-  g_signal_connect ((gpointer) Tab, "activate",
-                    G_CALLBACK (on_tab_activate),
-                    NULL);
-/*
-  g_signal_connect ((gpointer) OpenTraceset, "activate",
-                    G_CALLBACK (on_open_activate),
-                    NULL);
-*/
-  g_signal_connect ((gpointer) Close, "activate",
-                    G_CALLBACK (on_close_activate),
-                    NULL);
-  g_signal_connect ((gpointer) CloseTab, "activate",
-                    G_CALLBACK (on_close_tab_activate),
-                    NULL);
-  g_signal_connect ((gpointer) AddTrace, "activate",
-                    G_CALLBACK (on_add_trace_activate),
-                    NULL);
-  g_signal_connect ((gpointer) RemoveTrace, "activate",
-                    G_CALLBACK (on_remove_trace_activate),
-                    NULL);
-/*
-  g_signal_connect ((gpointer) Save, "activate",
-                    G_CALLBACK (on_save_activate),
-                    NULL);
-  g_signal_connect ((gpointer) SaveAs, "activate",
-                    G_CALLBACK (on_save_as_activate),
-                    NULL);
-*/
-  g_signal_connect ((gpointer) Quit, "activate",
-                    G_CALLBACK (on_quit_activate),
-                    NULL);
-/*
-  g_signal_connect ((gpointer) Cut, "activate",
-                    G_CALLBACK (on_cut_activate),
-                    NULL);
-  g_signal_connect ((gpointer) Copy, "activate",
-                    G_CALLBACK (on_copy_activate),
-                    NULL);
-  g_signal_connect ((gpointer) Paste, "activate",
-                    G_CALLBACK (on_paste_activate),
-                    NULL);
-  g_signal_connect ((gpointer) Delete, "activate",
-                    G_CALLBACK (on_delete_activate),
-                    NULL);
-*/
-  g_signal_connect ((gpointer) ZoomIn, "activate",
-                    G_CALLBACK (on_zoom_in_activate),
-                    NULL);
-  g_signal_connect ((gpointer) ZoomOut, "activate",
-                    G_CALLBACK (on_zoom_out_activate),
-                    NULL);
-  g_signal_connect ((gpointer) ZoomExtended, "activate",
-                    G_CALLBACK (on_zoom_extended_activate),
-                    NULL);
-/*
-  g_signal_connect ((gpointer) GoToTime, "activate",
-                   G_CALLBACK (on_go_to_time_activate),
-                   NULL);
-  g_signal_connect ((gpointer) ShowTimeFrame, "activate",
-                    G_CALLBACK (on_show_time_frame_activate),
-                    NULL);
-*/
-  g_signal_connect ((gpointer) MoveViewerUp, "activate",
-                    G_CALLBACK (on_move_viewer_up_activate),
-                    NULL);
-  g_signal_connect ((gpointer) MoveViewerDown, "activate",
-                    G_CALLBACK (on_move_viewer_down_activate),
-                    NULL);
-  g_signal_connect ((gpointer) RemoveViewer, "activate",
-                    G_CALLBACK (on_remove_viewer_activate),
-                    NULL);
-  g_signal_connect ((gpointer) Filter, "activate",
-                    G_CALLBACK (on_trace_filter_activate),
-                    NULL);
-  //  g_signal_connect ((gpointer) Facility, "activate",
-  //                    G_CALLBACK (on_trace_facility_activate),
-  //                    NULL);
-  //  g_signal_connect ((gpointer) insert_viewer_test, "activate",
-  //                    G_CALLBACK (on_insert_viewer_test_activate),
-  //                    NULL);
-  g_signal_connect ((gpointer) LoadModule, "activate",
-                    G_CALLBACK (on_load_module_activate),
-                    NULL);
-  g_signal_connect ((gpointer) UnloadModule, "activate",
-                    G_CALLBACK (on_unload_module_activate),
-                    NULL);
-  g_signal_connect ((gpointer) AddModuleSearchPath, "activate",
-                    G_CALLBACK (on_add_module_search_path_activate),
-                    NULL);
-/*
-  g_signal_connect ((gpointer) Color, "activate",
-                    G_CALLBACK (on_color_activate),
-                    NULL);
-  g_signal_connect ((gpointer) OpenFilter, "activate",
-                    G_CALLBACK (on_filter_activate),
-                    NULL);
-  g_signal_connect ((gpointer) SaveConfiguration, "activate",
-                    G_CALLBACK (on_save_configuration_activate),
-                    NULL);
-*/
-  g_signal_connect ((gpointer) Content, "activate",
-                    G_CALLBACK (on_content_activate),
-                    NULL);
-  g_signal_connect ((gpointer) About, "activate",
-                    G_CALLBACK (on_about_activate),
-                    NULL);
-  g_signal_connect ((gpointer) tlbEmptyTraceset, "clicked",
-                    G_CALLBACK (on_button_new_clicked),
-                    NULL);
-  g_signal_connect ((gpointer) tlbTab, "clicked",
-                    G_CALLBACK (on_button_new_tab_clicked),
-                    NULL);
-/*
-  g_signal_connect ((gpointer) tlbOpenTraceset, "clicked",
-                    G_CALLBACK (on_button_open_clicked),
-                    NULL);
-*/
-  g_signal_connect ((gpointer) tlbAddTrace, "clicked",
-                    G_CALLBACK (on_button_add_trace_clicked),
-                    NULL);
-  g_signal_connect ((gpointer) tlbRemoveTrace, "clicked",
-                    G_CALLBACK (on_button_remove_trace_clicked),
-                    NULL);
-/*
-  g_signal_connect ((gpointer) tlbSave, "clicked",
-                    G_CALLBACK (on_button_save_clicked),
-                    NULL);
-  g_signal_connect ((gpointer) tlbSaveAs, "clicked",
-                    G_CALLBACK (on_button_save_as_clicked),
-                    NULL);
-*/
-  g_signal_connect ((gpointer) tlbZoomIn, "clicked",
-                    G_CALLBACK (on_button_zoom_in_clicked),
-                    NULL);
-  g_signal_connect ((gpointer) tlbZoomOut, "clicked",
-                    G_CALLBACK (on_button_zoom_out_clicked),
-                    NULL);
-  g_signal_connect ((gpointer) tlbZoomExtended, "clicked",
-                    G_CALLBACK (on_button_zoom_extended_clicked),
-                    NULL);
-/*
-  g_signal_connect ((gpointer) tlbGoToTime, "clicked",
-                    G_CALLBACK (on_button_go_to_time_clicked),
-                    NULL);
-  g_signal_connect ((gpointer) tlbShowTimeFrame, "clicked",
-                    G_CALLBACK (on_button_show_time_frame_clicked),
-                    NULL);
-*/
-  g_signal_connect ((gpointer) tlbMoveViewerUp, "clicked",
-                    G_CALLBACK (on_button_move_up_clicked),
-                    NULL);
-  g_signal_connect ((gpointer) tlbMoveViewerDown, "clicked",
-                    G_CALLBACK (on_button_move_down_clicked),
-                    NULL);
-  g_signal_connect ((gpointer) tlbRemoveViewer, "clicked",
-                    G_CALLBACK (on_button_delete_viewer_clicked),
-                    NULL);
-  g_signal_connect ((gpointer) MNotebook, "switch_page",
-                    G_CALLBACK (on_MNotebook_switch_page),
-                    NULL);
-
-  /* Store pointers to all widgets, for use by lookup_widget(). */
-  GLADE_HOOKUP_OBJECT_NO_REF (MWindow, MWindow, "MWindow");
-  GLADE_HOOKUP_OBJECT (MWindow, MVbox, "MVbox");
-  GLADE_HOOKUP_OBJECT (MWindow, MMenuBox, "MMenuBox");
-  GLADE_HOOKUP_OBJECT (MWindow, MenuMain, "MenuMain");
-  GLADE_HOOKUP_OBJECT (MWindow, FileMenuTitle, "FileMenuTitle");
-  GLADE_HOOKUP_OBJECT (MWindow, FileMenuTitle_menu, "FileMenuTitle_menu");
-  GLADE_HOOKUP_OBJECT (MWindow, FileMenuNewTitle, "FileMenuNewTitle");
-  GLADE_HOOKUP_OBJECT (MWindow, FileMenuNewTitle_menu, "FileMenuNewTitle_menu");
-  //  GLADE_HOOKUP_OBJECT (MWindow, EmptyTraceset, "EmptyTraceset");
-  GLADE_HOOKUP_OBJECT (MWindow, CloneTraceset, "CloneTraceset");
-  GLADE_HOOKUP_OBJECT (MWindow, FileMenuNewSep, "FileMenuNewSep");
-  GLADE_HOOKUP_OBJECT (MWindow, Tab, "Tab");
-  //  GLADE_HOOKUP_OBJECT (MWindow, OpenTraceset, "OpenTraceset");
-  GLADE_HOOKUP_OBJECT (MWindow, Close, "Close");
-  GLADE_HOOKUP_OBJECT (MWindow, CloseTab, "CloseTab");
-  GLADE_HOOKUP_OBJECT (MWindow, FileMenuSeparator1, "FileMenuSeparator1");
-  GLADE_HOOKUP_OBJECT (MWindow, AddTrace, "AddTrace");
-  GLADE_HOOKUP_OBJECT (MWindow, RemoveTrace, "RemoveTrace");
-  //  GLADE_HOOKUP_OBJECT (MWindow, Save, "Save");
-  //  GLADE_HOOKUP_OBJECT (MWindow, SaveAs, "SaveAs");
-  GLADE_HOOKUP_OBJECT (MWindow, FileMenuSeparator2, "FileMenuSeparator2");
-  GLADE_HOOKUP_OBJECT (MWindow, Quit, "Quit");
-  //  GLADE_HOOKUP_OBJECT (MWindow, EditMenuTitle, "EditMenuTitle");
-  //  GLADE_HOOKUP_OBJECT (MWindow, EditMenuTitle_menu, "EditMenuTitle_menu");
-  //  GLADE_HOOKUP_OBJECT (MWindow, Cut, "Cut");
-  //  GLADE_HOOKUP_OBJECT (MWindow, Copy, "Copy");
-  //  GLADE_HOOKUP_OBJECT (MWindow, Paste, "Paste");
-  //  GLADE_HOOKUP_OBJECT (MWindow, Delete, "Delete");
-  GLADE_HOOKUP_OBJECT (MWindow, ViewMenuTitle, "ViewMenuTitle");
-  GLADE_HOOKUP_OBJECT (MWindow, ViewMenuTitle_menu, "ViewMenuTitle_menu");
-  GLADE_HOOKUP_OBJECT (MWindow, ZoomIn, "ZoomIn");
-  GLADE_HOOKUP_OBJECT (MWindow, ZoomOut, "ZoomOut");
-  GLADE_HOOKUP_OBJECT (MWindow, ZoomExtended, "ZoomExtended");
-  GLADE_HOOKUP_OBJECT (MWindow, ViewMenuSeparator, "ViewMenuSeparator");
-  //  GLADE_HOOKUP_OBJECT (MWindow, GoToTime, "GoToTime");
-  //  GLADE_HOOKUP_OBJECT (MWindow, ShowTimeFrame, "ShowTimeFrame");
-  GLADE_HOOKUP_OBJECT (MWindow, ToolMenuTitle, "ToolMenuTitle");
-  GLADE_HOOKUP_OBJECT (MWindow, ToolMenuTitle_menu, "ToolMenuTitle_menu");
-  GLADE_HOOKUP_OBJECT (MWindow, MoveViewerUp, "MoveViewerUp");
-  GLADE_HOOKUP_OBJECT (MWindow, MoveViewerDown, "MoveViewerDown");
-  GLADE_HOOKUP_OBJECT (MWindow, RemoveViewer, "RemoveViewer");
-  GLADE_HOOKUP_OBJECT (MWindow, ToolMenuSeparator, "ToolMenuSeparator");
-  GLADE_HOOKUP_OBJECT (MWindow, Filter, "Filter");
-  //  GLADE_HOOKUP_OBJECT (MWindow, Facility, "Facility");
-  GLADE_HOOKUP_OBJECT (MWindow, ToolMenuSeparator1, "ToolMenuSeparator1");
-  //  GLADE_HOOKUP_OBJECT (MWindow, insert_viewer_test, "insert_viewer_test");
-  GLADE_HOOKUP_OBJECT (MWindow, PluginMenuTitle, "PluginMenuTitle");
-  GLADE_HOOKUP_OBJECT (MWindow, PluginMenuTitle_menu, "PluginMenuTitle_menu");
-  GLADE_HOOKUP_OBJECT (MWindow, LoadModule, "LoadModule");
-  GLADE_HOOKUP_OBJECT (MWindow, UnloadModule, "UnloadModule");
-  GLADE_HOOKUP_OBJECT (MWindow, AddModuleSearchPath, "AddModuleSearchPath");
-  //  GLADE_HOOKUP_OBJECT (MWindow, OptionMenuTitle, "OptionMenuTitle");
-  //  GLADE_HOOKUP_OBJECT (MWindow, OptionMenuTitle_menu, "OptionMenuTitle_menu");
-  //  GLADE_HOOKUP_OBJECT (MWindow, Color, "Color");
-  //  GLADE_HOOKUP_OBJECT (MWindow, OptMenuSeparator, "OptMenuSeparator");
-  //  GLADE_HOOKUP_OBJECT (MWindow, OpenFilter, "OpenFilter");
-  //  GLADE_HOOKUP_OBJECT (MWindow, SaveConfiguration, "SaveConfiguration");
-  GLADE_HOOKUP_OBJECT (MWindow, MenuHelp, "MenuHelp");
-  GLADE_HOOKUP_OBJECT (MWindow, HelpMenuTitle, "HelpMenuTitle");
-  GLADE_HOOKUP_OBJECT (MWindow, HelpMenu, "HelpMenu");
-  GLADE_HOOKUP_OBJECT (MWindow, Content, "Content");
-  GLADE_HOOKUP_OBJECT (MWindow, HelpmenuSeparator, "HelpmenuSeparator");
-  GLADE_HOOKUP_OBJECT (MWindow, About, "About");
-  GLADE_HOOKUP_OBJECT (MWindow, MToolbar1, "MToolbar1");
-  GLADE_HOOKUP_OBJECT (MWindow, tlbEmptyTraceset, "tlbEmptyTraceset");
-  GLADE_HOOKUP_OBJECT (MWindow, tlbTab, "tlbTab");
-  //  GLADE_HOOKUP_OBJECT (MWindow, tlbOpenTraceset, "tlbOpenTraceset");
-  GLADE_HOOKUP_OBJECT (MWindow, tlbAddTrace, "tlbAddTrace");
-  GLADE_HOOKUP_OBJECT (MWindow, tlbRemoveTrace, "tlbRemoveTrace");
-  //  GLADE_HOOKUP_OBJECT (MWindow, tlbSave, "tlbSave");
-  //  GLADE_HOOKUP_OBJECT (MWindow, tlbSaveAs, "tlbSaveAs");
-  GLADE_HOOKUP_OBJECT (MWindow, tlbZoomIn, "tlbZoomIn");
-  GLADE_HOOKUP_OBJECT (MWindow, tlbZoomOut, "tlbZoomOut");
-  GLADE_HOOKUP_OBJECT (MWindow, tlbZoomExtended, "tlbZoomExtended");
-  //  GLADE_HOOKUP_OBJECT (MWindow, tlbGoToTime, "tlbGoToTime");
-  // GLADE_HOOKUP_OBJECT (MWindow, tlbShowTimeFrame, "tlbShowTimeFrame");
-  GLADE_HOOKUP_OBJECT (MWindow, tlbMoveViewerUp, "tlbMoveViewerUp");
-  GLADE_HOOKUP_OBJECT (MWindow, tlbMoveViewerDown, "tlbMoveViewerDown");
-  GLADE_HOOKUP_OBJECT (MWindow, tlbRemoveViewer, "tlbRemoveViewer");
-  //  GLADE_HOOKUP_OBJECT (MWindow, MToolbar2, "MToolbar2");
-  GLADE_HOOKUP_OBJECT (MWindow, MNotebook, "MNotebook");
-  //  GLADE_HOOKUP_OBJECT (MWindow, label1, "label1");
-  GLADE_HOOKUP_OBJECT (MWindow, MStatusbar, "MStatusbar");
-
-  gtk_window_add_accel_group (GTK_WINDOW (MWindow), accel_group);
-
-  return MWindow;
-}
-
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/interface.h b/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/interface.h
deleted file mode 100644 (file)
index 05d8846..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/* 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.
- */
-
-/*
- * DO NOT EDIT THIS FILE - it is generated by Glade.
- */
-
-GtkWidget* create_MWindow (void);
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/lttvfilter.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/lttvfilter.c
deleted file mode 100644 (file)
index 2ab00de..0000000
+++ /dev/null
@@ -1,312 +0,0 @@
-/* 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.
- */
-
-
-#include <lttvwindow/lttvfilter.h>
-#include <stdio.h>
-#include <ltt/trace.h>
-#include <ltt/type.h>
-
-struct _LttvTracesetSelector {
-  char      * traceset_name;
-  GPtrArray * traces;
-};
-
-
-struct _LttvTraceSelector {
-  char      * trace_name;
-  GPtrArray * tracefiles;
-  GPtrArray * eventtypes;
-  gboolean    selected;
-};
-
-struct _LttvTracefileSelector {
-  char      * tracefile_name;
-  GPtrArray * eventtypes;
-  gboolean    selected;
-};
-
-struct _LttvEventtypeSelector {
-  char      * eventtype_name;
-  gboolean    selected;
-};
-
-
-LttvTracesetSelector *lttv_traceset_selector_new(char * name) 
-{
-  LttvTracesetSelector *s;
-
-  s = g_new(LttvTracesetSelector, 1);
-  if(name)
-    s->traceset_name = g_strdup(name);
-  else
-    s->traceset_name = NULL;    
-  s->traces = g_ptr_array_new();
-  return s;
-}
-
-LttvTraceSelector *lttv_trace_selector_new(LttTrace *t) 
-{
-  LttvTraceSelector * trace;
-
-  trace = g_new(LttvTraceSelector, 1);
-  trace->trace_name = g_strdup(ltt_trace_name(t));
-  trace->tracefiles = g_ptr_array_new();
-  trace->eventtypes = g_ptr_array_new();
-  trace->selected = TRUE;
-  return trace;
-}
-
-LttvTracefileSelector *lttv_tracefile_selector_new(LttTracefile *t) 
-{
-  LttvTracefileSelector * tracefile;
-
-  tracefile = g_new(LttvTracefileSelector, 1);
-  tracefile->tracefile_name = g_strdup(ltt_tracefile_name(t));
-  tracefile->eventtypes = g_ptr_array_new();
-  tracefile->selected = TRUE;
-  return tracefile;
-}
-
-LttvEventtypeSelector *lttv_eventtype_selector_new(LttEventType * et)
-{
-  LttvEventtypeSelector * ev;
-  ev = g_new(LttvEventtypeSelector, 1);
-  ev->eventtype_name = g_strdup(ltt_eventtype_name(et));
-  ev->selected = TRUE;
-  return ev;
-}
-
-void lttv_traceset_selector_destroy(LttvTracesetSelector *s) 
-{
-  int i;
-  LttvTraceSelector * t;
-
-  for(i=0;i<s->traces->len;i++){
-    t = (LttvTraceSelector*)s->traces->pdata[i];
-    lttv_trace_selector_destroy(t);
-  }
-  g_ptr_array_free(s->traces, TRUE);
-  if(s->traceset_name) g_free(s->traceset_name);
-  g_free(s);
-}
-
-void lttv_trace_selector_destroy(LttvTraceSelector *s) 
-{
-  int i;
-  LttvTracefileSelector * t;
-  LttvEventtypeSelector * e;
-
-  for(i=0;i<s->tracefiles->len;i++){
-    t = (LttvTracefileSelector*)s->tracefiles->pdata[i];
-    lttv_tracefile_selector_destroy(t);
-  }
-  for(i=0;i<s->eventtypes->len;i++){
-    e = (LttvEventtypeSelector*)s->eventtypes->pdata[i];
-    lttv_eventtype_selector_destroy(e);
-  }
-  if(s->trace_name) g_free(s->trace_name);
-  g_free(s);
-}
-
-void lttv_tracefile_selector_destroy(LttvTracefileSelector *t) 
-{
-  int i;
-  LttvEventtypeSelector * e;
-
-  for(i=0;i<t->eventtypes->len;i++){
-    e = (LttvEventtypeSelector*)t->eventtypes->pdata[i];
-    lttv_eventtype_selector_destroy(e);
-  }
-
-  if(t->tracefile_name) g_free(t->tracefile_name);
-  g_free(t);
-}
-
-void lttv_eventtype_selector_destroy(LttvEventtypeSelector *e)
-{
-  if(e->eventtype_name) g_free(e->eventtype_name);
-  free(e);
-}
-
-void lttv_traceset_selector_trace_add(LttvTracesetSelector *s, 
-                                     LttvTraceSelector *t) 
-{
-  g_ptr_array_add(s->traces, t);
-}
-
-void lttv_trace_selector_tracefile_add(LttvTraceSelector *s, 
-                                      LttvTracefileSelector *t) 
-{
-  g_ptr_array_add(s->tracefiles, t);
-}
-
-void lttv_trace_selector_eventtype_add(LttvTraceSelector *s, 
-                                      LttvEventtypeSelector *et)
-{  
-  g_ptr_array_add(s->eventtypes, et);
-}
-
-void lttv_tracefile_selector_eventtype_add(LttvTracefileSelector *s, 
-                                          LttvEventtypeSelector *et)
-{
-  g_ptr_array_add(s->eventtypes, et);
-}
-
-unsigned lttv_traceset_selector_trace_number(LttvTracesetSelector *s) 
-{
-  return s->traces->len;
-}
-
-unsigned lttv_trace_selector_tracefile_number(LttvTraceSelector *s) 
-{
-  return s->tracefiles->len;
-}
-
-unsigned lttv_trace_selector_eventtype_number(LttvTraceSelector *s)
-{
-  return s->eventtypes->len;
-}
-
-unsigned lttv_tracefile_selector_eventtype_number(LttvTracefileSelector *s)
-{
-  return s->eventtypes->len;
-}
-
-LttvTraceSelector *lttv_traceset_selector_trace_get(LttvTracesetSelector *s,
-                                                   unsigned i) 
-{
-  g_assert(s->traces->len > i);
-  return ((LttvTraceSelector *)s->traces->pdata[i]);
-}
-
-LttvTracefileSelector *lttv_trace_selector_tracefile_get(LttvTraceSelector *s,
-                                                        unsigned i) 
-{
-  g_assert(s->tracefiles->len > i);
-  return ((LttvTracefileSelector *)s->tracefiles->pdata[i]);
-}
-
-LttvEventtypeSelector *lttv_trace_selector_eventtype_get(LttvTraceSelector *s,
-                                                        unsigned i)
-{
-  g_assert(s->eventtypes->len > i);
-  return ((LttvEventtypeSelector *)s->eventtypes->pdata[i]);
-}
-
-LttvEventtypeSelector *lttv_tracefile_selector_eventtype_get(LttvTracefileSelector *s,
-                                                            unsigned i)
-{
-  g_assert(s->eventtypes->len > i);
-  return ((LttvEventtypeSelector *)s->eventtypes->pdata[i]);
-}
-
-void lttv_traceset_selector_trace_remove(LttvTracesetSelector *s, unsigned i) 
-{
-  g_assert(s->traces->len > i);
-  g_ptr_array_remove_index(s->traces, i);
-}
-
-void lttv_trace_selector_tracefile_remove(LttvTraceSelector *s, unsigned i) 
-{
-  g_assert(s->tracefiles->len > i);
-  g_ptr_array_remove_index(s->tracefiles, i);
-}
-
-void lttv_trace_selector_eventtype_remove(LttvTraceSelector *s, unsigned i)
-{
-  g_assert(s->eventtypes->len > i);
-  g_ptr_array_remove_index(s->eventtypes, i);
-}
-
-void lttv_tracefile_selector_eventtype_remove(LttvTracefileSelector *s, unsigned i)
-{
-  g_assert(s->eventtypes->len > i);
-  g_ptr_array_remove_index(s->eventtypes, i);
-}
-
-void lttv_trace_selector_set_selected(LttvTraceSelector *s, gboolean g)
-{
-  s->selected = g;
-}
-
-void lttv_tracefile_selector_set_selected(LttvTracefileSelector *s, gboolean g)
-{
-  s->selected = g;
-}
-
-void lttv_eventtype_selector_set_selected(LttvEventtypeSelector *s, gboolean g)
-{
-  s->selected = g;
-}
-
-gboolean lttv_trace_selector_get_selected(LttvTraceSelector *s)
-{
-  return s->selected;
-}
-
-gboolean lttv_tracefile_selector_get_selected(LttvTracefileSelector *s)
-{
-  return s->selected;
-}
-
-gboolean lttv_eventtype_selector_get_selected(LttvEventtypeSelector *s)
-{
-  return s->selected;
-}
-
-char * lttv_traceset_selector_get_name(LttvTracesetSelector *s)
-{
-  return s->traceset_name;
-}
-
-char * lttv_trace_selector_get_name(LttvTraceSelector *s)
-{
-  return s->trace_name;
-}
-
-char * lttv_tracefile_selector_get_name(LttvTracefileSelector *s)
-{
-  return s->tracefile_name;
-}
-
-char * lttv_eventtype_selector_get_name(LttvEventtypeSelector *s)
-{
-  return s->eventtype_name;
-}
-
-LttvEventtypeSelector * lttv_eventtype_selector_clone(LttvEventtypeSelector * s)
-{
-  LttvEventtypeSelector * ev = g_new(LttvEventtypeSelector, 1);
-  ev->eventtype_name = g_strdup(s->eventtype_name);
-  ev->selected = s->selected;
-  return ev;
-}
-
-void lttv_eventtype_selector_copy(LttvTraceSelector * s, LttvTracefileSelector * d)
-{
-  int i, len;
-  LttvEventtypeSelector * ev, *ev1;
-
-  len = s->eventtypes->len;
-  for(i=0;i<len;i++){
-    ev = lttv_trace_selector_eventtype_get(s,i);
-    ev1 = lttv_eventtype_selector_clone(ev);
-    lttv_tracefile_selector_eventtype_add(d,ev1);
-  }
-}
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/lttvfilter.h b/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/lttvfilter.h
deleted file mode 100644 (file)
index f2dab41..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/* This file is part of the Linux Trace Toolkit viewer
- * Copyright (C) 2003-2004 Xiangxiu 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.
- */
-
-#ifndef LTTV_FILTER_H
-#define LTTV_FILTER_H
-
-#include <ltt/ltt.h>
-
-
-typedef struct _LttvTracesetSelector  LttvTracesetSelector;
-typedef struct _LttvTraceSelector     LttvTraceSelector;
-typedef struct _LttvTracefileSelector LttvTracefileSelector;
-typedef struct _LttvEventtypeSelector LttvEventtypeSelector;
-
-
-LttvTracesetSelector *lttv_traceset_selector_new(char * name);
-LttvTraceSelector *lttv_trace_selector_new(LttTrace *t);
-LttvTracefileSelector *lttv_tracefile_selector_new(LttTracefile *t);
-LttvEventtypeSelector *lttv_eventtype_selector_new(LttEventType * et);
-void lttv_traceset_selector_destroy(LttvTracesetSelector *s);
-void lttv_trace_selector_destroy(LttvTraceSelector *t);
-void lttv_tracefile_selector_destroy(LttvTracefileSelector *t);
-void lttv_eventtype_selector_destroy(LttvEventtypeSelector *t);
-
-
-void lttv_traceset_selector_trace_add(LttvTracesetSelector *s, 
-                                     LttvTraceSelector *t);
-unsigned lttv_traceset_selector_trace_number(LttvTracesetSelector *s);
-LttvTraceSelector *lttv_traceset_selector_trace_get(LttvTracesetSelector *s,
-                                                   unsigned i);
-void lttv_traceset_selector_trace_remove(LttvTracesetSelector *s,
-                                        unsigned i);
-
-
-void lttv_trace_selector_tracefile_add(LttvTraceSelector *s,
-                                      LttvTracefileSelector *t);
-unsigned lttv_trace_selector_tracefile_number(LttvTraceSelector *s);
-LttvTracefileSelector *lttv_trace_selector_tracefile_get(LttvTraceSelector *s,
-                                                        unsigned i);
-void lttv_trace_selector_tracefile_remove(LttvTraceSelector *s, unsigned i);
-
-void lttv_trace_selector_eventtype_add(LttvTraceSelector *s,
-                                      LttvEventtypeSelector *et);
-unsigned lttv_trace_selector_eventtype_number(LttvTraceSelector *s);
-LttvEventtypeSelector *lttv_trace_selector_eventtype_get(LttvTraceSelector *s,
-                                                        unsigned i);
-void lttv_trace_selector_eventtype_remove(LttvTraceSelector *s, unsigned i);
-
-
-void lttv_tracefile_selector_eventtype_add(LttvTracefileSelector *s,
-                                          LttvEventtypeSelector *et);
-unsigned lttv_tracefile_selector_eventtype_number(LttvTracefileSelector *s);
-LttvEventtypeSelector *lttv_tracefile_selector_eventtype_get(LttvTracefileSelector *s,
-                                                            unsigned i);
-void lttv_tracefile_selector_eventtype_remove(LttvTracefileSelector *s, unsigned i);
-
-
-void lttv_trace_selector_set_selected(LttvTraceSelector *s, gboolean g);
-void lttv_tracefile_selector_set_selected(LttvTracefileSelector *s, gboolean g);
-void lttv_eventtype_selector_set_selected(LttvEventtypeSelector *s, gboolean g);
-gboolean lttv_trace_selector_get_selected(LttvTraceSelector *s);
-gboolean lttv_tracefile_selector_get_selected(LttvTracefileSelector *s);
-gboolean lttv_eventtype_selector_get_selected(LttvEventtypeSelector *s);
-char * lttv_traceset_selector_get_name(LttvTracesetSelector *s);
-char * lttv_trace_selector_get_name(LttvTraceSelector *s);
-char * lttv_tracefile_selector_get_name(LttvTracefileSelector *s);
-char * lttv_eventtype_selector_get_name(LttvEventtypeSelector *s);
-
-LttvEventtypeSelector * lttv_eventtype_selector_clone(LttvEventtypeSelector * s);
-void lttv_eventtype_selector_copy(LttvTraceSelector *s, LttvTracefileSelector *d);
-
-
-#endif // LTTV_FILTER_H
-
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/main.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/main.c
deleted file mode 100644 (file)
index 7b31ac6..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Initial main.c file generated by Glade. Edit as required.
- * Glade will not overwrite this file.
- */
-
-#ifdef HAVE_CONFIG_H
-#  include <config.h>
-#endif
-
-#include <gtk/gtk.h>
-#include <gmodule.h>
-
-#include "interface.h"
-#include "support.h"
-#include <lttvwindow/mainWindow.h>
-#include "callbacks.h"
-
-/* global variable */
-systemView * gSysView;
-
-typedef view_constructor (* constructor)();
-constructor get_constructor = NULL;
-typedef void (*call_Event_Selected_Hook)(void * call_data);
-call_Event_Selected_Hook selected_hook = NULL;
-GModule *gm;
-view_constructor gConstructor = NULL;
-
-int
-main (int argc, char *argv[])
-{
-  GModule *gm;
-  GtkWidget * ToolMenuTitle_menu, *insert_view;
-  GtkWidget *window1;
-  mainWindow * mw = g_new(mainWindow, 1);
-  gSysView = g_new(systemView, 1);
-
-#ifdef ENABLE_NLS
-  bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
-  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
-  textdomain (GETTEXT_PACKAGE);
-#endif
-
-  gtk_set_locale ();
-  gtk_init (&argc, &argv);
-
-  add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps");
-  add_pixmap_directory ("pixmaps");
-  add_pixmap_directory ("../pixmaps");
-
-  /*
-   * The following code was added by Glade to create one of each component
-   * (except popup menus), just so that you see something after building
-   * the project. Delete any components that you don't want shown initially.
-   */
-  window1 = create_MWindow ();
-  gtk_widget_show (window1);
-
-  mw->MWindow = window1;
-  mw->SystemView = gSysView;
-  mw->Tab = NULL;
-  mw->CurrentTab = NULL;
-  //  mw->Attributes = lttv_attributes_new();
-
-  //test
-
-  gm = g_module_open("/home1/yangxx/poly/lttv/modules/libguiEvents.la",0);
-  printf("Main : the address of gm : %d\n", gm);
-  if(!g_module_symbol(gm, "get_constructor", (gpointer)&get_constructor)){
-    g_error("can not get constructor\n");
-  }  
-  if(!g_module_symbol(gm, "call_Event_Selected_Hook", (gpointer)&selected_hook)){
-    g_error("can not get selected hook\n");
-  }  
-
-  gConstructor = get_constructor();
-  ToolMenuTitle_menu = lookup_widget(mw->MWindow,"ToolMenuTitle_menu");
-  insert_view = gtk_menu_item_new_with_mnemonic ("insert_view");
-  gtk_widget_show (insert_view);
-  gtk_container_add (GTK_CONTAINER (ToolMenuTitle_menu), insert_view);
-  g_signal_connect ((gpointer) insert_view, "activate",
-                    G_CALLBACK (insertViewTest),
-                    NULL);  
-  //end
-
-  gSysView->EventDB = NULL;
-  gSysView->SystemInfo = NULL;
-  gSysView->Options  = NULL;
-  gSysView->Window = mw;
-  gSysView->Next = NULL;
-
-  g_object_set_data(G_OBJECT(window1), "systemView", (gpointer)gSysView);
-  g_object_set_data(G_OBJECT(window1), "mainWindow", (gpointer)mw);
-
-  gtk_main ();
-  return 0;
-}
-
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/mainwindow.h b/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/mainwindow.h
deleted file mode 100644 (file)
index 9349687..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/* This file is part of the Linux Trace Toolkit viewer
- * Copyright (C) 2003-2004 Xiangxiu 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.
- */
-
-#ifndef _MAIN_WINDOW_
-#define _MAIN_WINDOW_
-
-#include <gtk/gtk.h>
-
-#include <ltt/ltt.h>
-#include <lttv/attribute.h>
-#include <lttv/traceset.h>
-#include <lttv/tracecontext.h>
-
-#include <lttvwindow/common.h>
-#include <lttvwindow/gtkmultivpaned.h>
-#include <lttv/hook.h>
-#include <lttv/stats.h>
-
-typedef struct _TracesetInfo {
-  //FIXME? TracesetContext and stats in same or different variable ?
-  LttvTracesetStats * traceset_context;
-  LttvTraceset * traceset;
-} TracesetInfo ;
-
-
-struct _MainWindow{
-  GtkWidget*      mwindow;            /* Main Window */
-  int             window_width;
-
-  /* Status bar information */
-  //  guint         MainSBarContextID;    /* Context ID of main status bar */
-  //  guint         BegTimeSBarContextID; /* Context ID of BegTime status bar */
-  //  guint         EndTimeSBarContextID; /* Context ID of EndTime status bar */
-  
-  /* Child windows */
-  //openTracesetWindow*  OpenTracesetWindow;/* Window to get prof and proc file*/
-  //viewTimeFrameWindow* ViewTimeFrameWindow;/*Window to select time frame */
-  //gotoEventWindow*     GotoEventWindow; /*search for event description*/
-  //openFilterWindow*    OpenFilterWindow; /* Open a filter selection window */
-  GtkWidget*           help_contents;/* Window to display help contents */
-  GtkWidget*           about_box;    /* Window  about information */
-  //  lttv_trace_filter * filter; /* trace filter associated with the window */
-
-  /* Attributes for trace reading hooks local to the main window */
-  LttvIAttribute * attributes;
-  
-  Tab * tab;
-  Tab * current_tab;
-
-  GHashTable * hash_menu_item;
-  GHashTable * hash_toolbar_item;
-};
-
-
-struct _Tab{
-  GtkWidget * label;
-  GtkMultiVPaned * multi_vpaned;
-   
-  // startTime is the left of the visible area. Corresponds to the scrollbar
-  // value.
-  // Time_Width is a zoom dependant value (corresponding to page size)
-  TimeWindow time_window;
-  
-  // The current time is the time selected in the visible area by the user,
-  // not the scrollbar value.
-  LttTime current_time;
-  LttvIAttribute * attributes;
-
-  struct _Tab * next;
-  MainWindow  * mw;
-
-  /* Traceset related information */
-  TracesetInfo * traceset_info; 
-};
-
-/**
- * Remove menu and toolbar item when a module unloaded
- */
-void main_window_remove_menu_item(lttv_constructor view_constructor);
-void main_window_remove_toolbar_item(lttv_constructor view_constructor);
-
-#endif /* _MAIN_WINDOW_ */
-
-
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/menu.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/menu.c
deleted file mode 100644 (file)
index 32c35c2..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/* 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.
- */
-
-#include <lttv/lttv.h>
-#include <lttvwindow/menu.h>
-
-
-inline LttvMenus *lttv_menus_new() {
-  return g_array_new(FALSE, FALSE, sizeof(lttv_menu_closure));
-}
-
-/* MD: delete elements of the array also, but don't free pointed addresses
- * (functions).
- */
-inline void lttv_menus_destroy(LttvMenus *h) {
-  g_debug("lttv_menus_destroy()");
-  g_array_free(h, TRUE);
-}
-
-inline void lttv_menus_add(LttvMenus *h, lttv_constructor f, char* menuPath, char* menuText)
-{
-  lttv_menu_closure c;
-
-  /* if h is null, do nothing, or popup a warning message */
-  if(h == NULL)return;
-
-  c.con = f;
-  c.menuPath = menuPath;
-  c.menuText = menuText;
-  g_array_append_val(h,c);
-}
-
-gboolean lttv_menus_remove(LttvMenus *h, lttv_constructor f)
-{
-  lttv_menu_closure * tmp;
-  gint i;
-  for(i=0;i<h->len;i++){
-    tmp = & g_array_index(h, lttv_menu_closure, i);
-    if(tmp->con == f)break;
-  }
-  if(i<h->len){
-    g_array_remove_index(h, i);
-    return TRUE;
-  }else return FALSE;
-  
-}
-
-unsigned lttv_menus_number(LttvMenus *h)
-{
-  return h->len;
-}
-
-
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/menu.h b/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/menu.h
deleted file mode 100644 (file)
index 3253bf7..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/* This file is part of the Linux Trace Toolkit viewer
- * Copyright (C) 2003-2004 Xiangxiu 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.
- */
-
-#ifndef MENU_H
-#define MENU_H
-
-#include <lttvwindow/common.h>
-
-/* constructor of the viewer */
-//typedef GtkWidget* (*lttv_constructor)(void * main_window);
-
-
-typedef GArray LttvMenus;
-
-typedef struct _lttv_menu_closure {
-  lttv_constructor con;
-  char * menuPath;
-  char * menuText;
-} lttv_menu_closure;
-
-
-LttvMenus *lttv_menus_new();
-
-void lttv_menus_destroy(LttvMenus *h);
-
-void lttv_menus_add(LttvMenus *h, lttv_constructor f, char* menuPath, char * menuText);
-
-gboolean lttv_menus_remove(LttvMenus *h, lttv_constructor f);
-
-unsigned lttv_menus_number(LttvMenus *h);
-
-#endif // MENU_H
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/support.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/support.c
deleted file mode 100644 (file)
index fddd4cf..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-/* 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.
- */
-
-/*
- * DO NOT EDIT THIS FILE - it is generated by Glade.
- */
-
-#ifdef HAVE_CONFIG_H
-#  include <config.h>
-#endif
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdio.h>
-
-#include <gtk/gtk.h>
-
-#include "support.h"
-
-GtkWidget*
-lookup_widget                          (GtkWidget       *widget,
-                                        const gchar     *widget_name)
-{
-  GtkWidget *parent, *found_widget;
-
-  for (;;)
-    {
-      if (GTK_IS_MENU (widget))
-        parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
-      else
-        parent = widget->parent;
-      if (!parent)
-        parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey");
-      if (parent == NULL)
-        break;
-      widget = parent;
-    }
-
-  found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget),
-                                                 widget_name);
-  if (!found_widget)
-    g_warning ("Widget not found: %s", widget_name);
-  return found_widget;
-}
-
-static GList *pixmaps_directories = NULL;
-
-/* Use this function to set the directory containing installed pixmaps. */
-void
-add_pixmap_directory                   (const gchar     *directory)
-{
-  pixmaps_directories = g_list_prepend (pixmaps_directories,
-                                        g_strdup (directory));
-}
-
-/* This is an internally used function to find pixmap files. */
-static gchar*
-find_pixmap_file                       (const gchar     *filename)
-{
-  GList *elem;
-
-  /* We step through each of the pixmaps directory to find it. */
-  elem = pixmaps_directories;
-  while (elem)
-    {
-      gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data,
-                                         G_DIR_SEPARATOR_S, filename);
-      if (g_file_test (pathname, G_FILE_TEST_EXISTS))
-        return pathname;
-      g_free (pathname);
-      elem = elem->next;
-    }
-  return NULL;
-}
-
-/* This is an internally used function to create pixmaps. */
-GtkWidget*
-create_pixmap                          (GtkWidget       *widget,
-                                        const gchar     *filename)
-{
-  gchar *pathname = NULL;
-  GtkWidget *pixmap;
-
-  if (!filename || !filename[0])
-      return gtk_image_new ();
-
-  pathname = find_pixmap_file (filename);
-
-  if (!pathname)
-    {
-      g_warning ("Couldn't find pixmap file: %s", filename);
-      return gtk_image_new ();
-    }
-
-  pixmap = gtk_image_new_from_file (pathname);
-  g_free (pathname);
-  return pixmap;
-}
-
-/* This is an internally used function to create pixmaps. */
-GdkPixbuf*
-create_pixbuf                          (const gchar     *filename)
-{
-  gchar *pathname = NULL;
-  GdkPixbuf *pixbuf;
-  GError *error = NULL;
-
-  if (!filename || !filename[0])
-      return NULL;
-
-  pathname = find_pixmap_file (filename);
-
-  if (!pathname)
-    {
-      g_warning ("Couldn't find pixmap file: %s", filename);
-      return NULL;
-    }
-
-  pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
-  if (!pixbuf)
-    {
-      fprintf (stderr, "Failed to load pixbuf file: %s: %s\n",
-               pathname, error->message);
-      g_error_free (error);
-    }
-  g_free (pathname);
-  return pixbuf;
-}
-
-/* This is used to set ATK action descriptions. */
-void
-glade_set_atk_action_description       (AtkAction       *action,
-                                        const gchar     *action_name,
-                                        const gchar     *description)
-{
-  gint n_actions, i;
-
-  n_actions = atk_action_get_n_actions (action);
-  for (i = 0; i < n_actions; i++)
-    {
-      if (!strcmp (atk_action_get_name (action, i), action_name))
-        atk_action_set_description (action, i, description);
-    }
-}
-
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/support.h b/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/support.h
deleted file mode 100644 (file)
index 6297519..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/* 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.
- */
-
-/*
- * DO NOT EDIT THIS FILE - it is generated by Glade.
- */
-
-#ifdef HAVE_CONFIG_H
-#  include <config.h>
-#endif
-
-#include <gtk/gtk.h>
-
-/*
- * Public Functions.
- */
-
-/*
- * This function returns a widget in a component created by Glade.
- * Call it with the toplevel widget in the component (i.e. a window/dialog),
- * or alternatively any widget in the component, and the name of the widget
- * you want returned.
- */
-GtkWidget*  lookup_widget              (GtkWidget       *widget,
-                                        const gchar     *widget_name);
-
-
-/* Use this function to set the directory containing installed pixmaps. */
-void        add_pixmap_directory       (const gchar     *directory);
-
-
-/*
- * Private Functions.
- */
-
-/* This is used to create the pixmaps used in the interface. */
-GtkWidget*  create_pixmap              (GtkWidget       *widget,
-                                        const gchar     *filename);
-
-/* This is used to create the pixbufs used in the interface. */
-GdkPixbuf*  create_pixbuf              (const gchar     *filename);
-
-/* This is used to set ATK action descriptions. */
-void        glade_set_atk_action_description (AtkAction       *action,
-                                              const gchar     *action_name,
-                                              const gchar     *description);
-
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/toolbar.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/toolbar.c
deleted file mode 100644 (file)
index 2a1dbb1..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/* 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.
- */
-
-#include <lttv/lttv.h>
-#include <lttvwindow/toolbar.h>
-
-
-inline LttvToolbars *lttv_toolbars_new() {
-  return g_array_new(FALSE, FALSE, sizeof(lttv_toolbar_closure));
-}
-
-/* MD: delete elements of the array also, but don't free pointed addresses
- * (functions).
- */
-inline void lttv_toolbars_destroy(LttvToolbars *h) {
-  g_debug("lttv_toolbars_destroy");
-  g_array_free(h, TRUE);
-}
-
-inline void lttv_toolbars_add(LttvToolbars *h, lttv_constructor f, char* tooltip, char ** pixmap)
-{
-  lttv_toolbar_closure c;
-
-  /* if h is null, do nothing, or popup a warning message */
-  if(h == NULL)return;
-
-  c.con = f;
-  c.tooltip = tooltip;
-  c.pixmap = pixmap;
-  g_array_append_val(h,c);
-}
-
-gboolean lttv_toolbars_remove(LttvToolbars *h, lttv_constructor f)
-{
-  lttv_toolbar_closure * tmp;
-  gint i;
-  for(i=0;i<h->len;i++){
-    tmp = & g_array_index(h, lttv_toolbar_closure, i);
-    if(tmp->con == f)break;
-  }
-  if(i<h->len){
-    g_array_remove_index(h, i);
-    return TRUE;
-  }else return FALSE;
-}
-
-unsigned lttv_toolbars_number(LttvToolbars *h)
-{
-  return h->len;
-}
-
-
diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/toolbar.h b/ltt/branches/poly/lttv/modules/gui/lttvwindow/src/toolbar.h
deleted file mode 100644 (file)
index 681311b..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/* This file is part of the Linux Trace Toolkit viewer
- * Copyright (C) 2003-2004 Xiangxiu 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.
- */
-
-#ifndef TOOLBAR_H
-#define TOOLBAR_H
-
-#include <lttvwindow/common.h>
-
-/* constructor of the viewer */
-//typedef GtkWidget* (*lttv_constructor)(void * main_window);
-
-
-typedef GArray LttvToolbars;
-
-typedef struct _lttv_toolbar_closure {
-  lttv_constructor con;
-  char * tooltip;
-  char ** pixmap;
-} lttv_toolbar_closure;
-
-LttvToolbars *lttv_toolbars_new();
-
-void lttv_toolbars_destroy(LttvToolbars *h);
-
-void lttv_toolbars_add(LttvToolbars *h, lttv_constructor f, char* tooltip, char ** pixmap);
-
-gboolean lttv_toolbars_remove(LttvToolbars *h, lttv_constructor f);
-
-unsigned lttv_toolbars_number(LttvToolbars *h);
-
-#endif // TOOLBAR_H
This page took 0.216091 seconds and 4 git commands to generate.