state update hooks are added by the main window
[lttv.git] / ltt / branches / poly / lttv / modules / gui / mainWin / src / init_module.c
index f6f398ae11507aa99bc0c7111d1de2bdc806e97d..2201eadc1f6d5167055fab578fdebcb5a2d4783b 100644 (file)
 #include "support.h"
 #include <lttv/mainWindow.h>
 #include "callbacks.h"
+#include <ltt/trace.h>
+
 
 /* global variable */
-//LttvTracesetStats * gTracesetContext = NULL;
-//static LttvTraceset * traceset;
-WindowCreationData  gWinCreationData;
+static WindowCreationData  win_creation_data;
 
 /** Array containing instanced objects. */
-GSList * Main_Window_List = NULL ;
+GSList * g_main_window_list = NULL ;
 
 LttvHooks
   *main_hooks;
 
 /* Initial trace from command line */
-LttTrace *gInit_Trace = NULL;
+LttvTrace *g_init_trace = NULL;
 
 static char *a_trace;
 
 void lttv_trace_option(void *hook_data)
 { 
-  gInit_Trace = ltt_trace_open(a_trace);
-  if(gInit_Trace == NULL) g_critical("cannot open trace %s", a_trace);
-  g_critical("lttv_trace_option : Init_Trace is %p", gInit_Trace);
+  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);
 }
 
 /*****************************************************************************
@@ -57,11 +59,11 @@ void lttv_trace_option(void *hook_data)
  * This function initializes the GUI.
  */
 
-static gboolean Window_Creation_Hook(void *hook_data, void *call_data)
+static gboolean window_creation_hook(void *hook_data, void *call_data)
 {
-  WindowCreationData* Window_Creation_Data = (WindowCreationData*)hook_data;
+  WindowCreationData* window_creation_data = (WindowCreationData*)hook_data;
 
-  g_critical("GUI Window_Creation_Hook()");
+  g_critical("GUI window_creation_hook()");
 #ifdef ENABLE_NLS
   bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
   bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
@@ -69,22 +71,19 @@ static gboolean Window_Creation_Hook(void *hook_data, void *call_data)
 #endif
 
   gtk_set_locale ();
-  gtk_init (&(Window_Creation_Data->argc), &(Window_Creation_Data->argv));
+  gtk_init (&(window_creation_data->argc), &(window_creation_data->argv));
 
   add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps");
   add_pixmap_directory ("pixmaps");
   add_pixmap_directory ("modules/gui/mainWin/pixmaps");
 
-  constructMainWin(NULL, Window_Creation_Data);
+  construct_main_window(NULL, window_creation_data);
 
   gtk_main ();
 
   return FALSE;
 }
 
-
-
-
 G_MODULE_EXPORT void init(LttvModule *self, int argc, char *argv[]) {
 
   LttvAttributeValue value;
@@ -103,82 +102,27 @@ G_MODULE_EXPORT void init(LttvModule *self, int argc, char *argv[]) {
       LTTV_POINTER, &value));
   g_assert((main_hooks = *(value.v_pointer)) != NULL);
 
-  gWinCreationData.argc = argc;
-  gWinCreationData.argv = argv;
+  win_creation_data.argc = argc;
+  win_creation_data.argv = argv;
   
-  lttv_hooks_add(main_hooks, Window_Creation_Hook, &gWinCreationData);
+  lttv_hooks_add(main_hooks, window_creation_hook, &win_creation_data);
 
 }
 
-//void
-//free_system_view(systemView * SystemView)
-//{
-//  if(!SystemView)return;
-//  //free_EventDB(SystemView->EventDB);
-//  //free_SystemInfo(SystemView->SystemInfo);
-//  //free_Options(SystemView->Options);
-//  if(SystemView->Next)
-//    free_system_view(SystemView->Next);
-//  g_free(SystemView);
-//}
-
-//MD : The tab is now only referenced by the notebook. The destroy will
-//happend when notebook destroyed.
-//void free_tab(tab * Tab)
-//{
-//  if(!Tab) return;
-//  if(Tab->custom->vbox)
-//    gtk_widget_destroy(Tab->custom->vbox);
-//  if(Tab->Attributes)
-//    g_object_unref(Tab->Attributes);
-
-//  if(Tab->Next) free_tab(Tab->Next);
-//  g_free(Tab);
-//  Tab = NULL;
-//}
-
 void
-mainWindow_free(mainWindow * mw)
+main_window_free(MainWindow * mw)
 { 
-  guint i, nb;
-
   if(mw){
-    //should free memory allocated dynamically first
-//    free_system_view(mw->SystemView);
-//    
-    //free_tab(mw->Tab);
-g_critical("begin remove");
-    lttv_hooks_destroy(mw->Traceset_Info->before_traceset);
-    lttv_hooks_destroy(mw->Traceset_Info->after_traceset);
-    lttv_hooks_destroy(mw->Traceset_Info->before_trace);
-    lttv_hooks_destroy(mw->Traceset_Info->after_trace);
-    lttv_hooks_destroy(mw->Traceset_Info->before_tracefile);
-    lttv_hooks_destroy(mw->Traceset_Info->after_tracefile);
-    lttv_hooks_destroy(mw->Traceset_Info->before_event);
-    lttv_hooks_destroy(mw->Traceset_Info->after_event);
-g_critical("end remove");
-    
-
-    if(mw->Traceset_Info->path != NULL)
-      g_free(mw->Traceset_Info->path);
-    if(mw->Traceset_Info->TracesetContext != NULL)
-      lttv_context_fini(LTTV_TRACESET_CONTEXT(mw->Traceset_Info->TracesetContext));
-    if(mw->Traceset_Info->traceset != NULL) {
-      nb = lttv_traceset_number(mw->Traceset_Info->traceset);
-      for(i = 0 ; i < nb ; i++) {
-        ltt_trace_close(
-           lttv_traceset_get(mw->Traceset_Info->traceset, i));
-      }
+    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);
 
-    lttv_traceset_destroy(mw->Traceset_Info->traceset); 
-
-    g_object_unref(mw->Attributes);
-
-    g_free(mw->Traceset_Info);
-    mw->Traceset_Info = NULL;
-      
-    Main_Window_List = g_slist_remove(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;
@@ -186,22 +130,22 @@ g_critical("end remove");
 }
 
 void
-mainWindow_Destructor(mainWindow * mw)
+main_window_destructor(MainWindow * mw)
 {
-  if(GTK_IS_WIDGET(mw->MWindow)){
-    gtk_widget_destroy(mw->MWindow);
+  if(GTK_IS_WIDGET(mw->mwindow)){
+    gtk_widget_destroy(mw->mwindow);
     //    gtk_widget_destroy(mw->HelpContents);
     //    gtk_widget_destroy(mw->AboutBox);    
     mw = NULL;
   }
-  //mainWindow_free called when the object mw in the widget is unref.
-  //mainWindow_free(mw);
+  //main_window_free called when the object mw in the widget is unref.
+  //main_window_free(mw);
 }
 
 
-void destroy_walk(gpointer data, gpointer user_data)
+void main_window_destroy_walk(gpointer data, gpointer user_data)
 {
-  mainWindow_Destructor((mainWindow*)data);
+  main_window_destructor((MainWindow*)data);
 }
 
 
@@ -215,15 +159,18 @@ void destroy_walk(gpointer data, gpointer user_data)
 G_MODULE_EXPORT void destroy() {
 
   LttvAttributeValue value;  
+  LttvTrace *trace;
 
   lttv_option_remove("trace");
 
-  lttv_hooks_remove_data(main_hooks, Window_Creation_Hook, &gWinCreationData);
+  lttv_hooks_remove_data(main_hooks, window_creation_hook, &win_creation_data);
 
   g_critical("GUI destroy()");
 
-  g_slist_foreach(Main_Window_List, destroy_walk, NULL );
-  g_slist_free(Main_Window_List);
+  if(g_main_window_list){
+    g_slist_foreach(g_main_window_list, main_window_destroy_walk, NULL );
+    g_slist_free(g_main_window_list);
+  }
   
 }
 
This page took 0.026266 seconds and 4 git commands to generate.