2 * Initial main.c file generated by Glade. Edit as required.
3 * Glade will not overwrite this file.
12 #include <lttv/lttv.h>
13 #include <lttv/attribute.h>
14 #include <lttv/hook.h>
15 #include <lttv/option.h>
16 #include <lttv/module.h>
17 #include <lttv/processTrace.h>
18 #include <lttv/state.h>
19 #include <lttv/stats.h>
20 #include <lttv/menu.h>
21 #include <lttv/toolbar.h>
23 #include "interface.h"
25 #include <lttv/mainWindow.h>
26 #include "callbacks.h"
29 //LttvTracesetStats * gTracesetContext = NULL;
30 //static LttvTraceset * traceset;
31 WindowCreationData gWinCreationData
;
33 /** Array containing instanced objects. */
34 GSList
* Main_Window_List
= NULL
;
39 /* Initial trace from command line */
40 LttTrace
*gInit_Trace
= NULL
;
44 void lttv_trace_option(void *hook_data
)
46 gInit_Trace
= ltt_trace_open(a_trace
);
47 if(gInit_Trace
== NULL
) g_critical("cannot open trace %s", a_trace
);
48 g_critical("lttv_trace_option : Init_Trace is %p", gInit_Trace
);
51 /*****************************************************************************
52 * Functions for module loading/unloading *
53 *****************************************************************************/
55 * plugin's init function
57 * This function initializes the GUI.
60 static gboolean
Window_Creation_Hook(void *hook_data
, void *call_data
)
62 WindowCreationData
* Window_Creation_Data
= (WindowCreationData
*)hook_data
;
64 g_critical("GUI Window_Creation_Hook()");
66 bindtextdomain (GETTEXT_PACKAGE
, PACKAGE_LOCALE_DIR
);
67 bind_textdomain_codeset (GETTEXT_PACKAGE
, "UTF-8");
68 textdomain (GETTEXT_PACKAGE
);
72 gtk_init (&(Window_Creation_Data
->argc
), &(Window_Creation_Data
->argv
));
74 add_pixmap_directory (PACKAGE_DATA_DIR
"/" PACKAGE
"/pixmaps");
75 add_pixmap_directory ("pixmaps");
76 add_pixmap_directory ("modules/gui/mainWin/pixmaps");
78 constructMainWin(NULL
, Window_Creation_Data
);
88 G_MODULE_EXPORT
void init(LttvModule
*self
, int argc
, char *argv
[]) {
90 LttvAttributeValue value
;
92 // Global attributes only used for interaction with main() here.
93 LttvIAttribute
*attributes
= LTTV_IATTRIBUTE(lttv_global_attributes());
95 g_critical("GUI init()");
97 lttv_option_add("trace", 't',
98 "add a trace to the trace set to analyse",
99 "pathname of the directory containing the trace",
100 LTTV_OPT_STRING
, &a_trace
, lttv_trace_option
, NULL
);
102 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/main/before",
103 LTTV_POINTER
, &value
));
104 g_assert((main_hooks
= *(value
.v_pointer
)) != NULL
);
106 gWinCreationData
.argc
= argc
;
107 gWinCreationData
.argv
= argv
;
109 lttv_hooks_add(main_hooks
, Window_Creation_Hook
, &gWinCreationData
);
114 //free_system_view(systemView * SystemView)
116 // if(!SystemView)return;
117 // //free_EventDB(SystemView->EventDB);
118 // //free_SystemInfo(SystemView->SystemInfo);
119 // //free_Options(SystemView->Options);
120 // if(SystemView->Next)
121 // free_system_view(SystemView->Next);
122 // g_free(SystemView);
125 //MD : The tab is now only referenced by the notebook. The destroy will
126 //happend when notebook destroyed.
127 //void free_tab(tab * Tab)
130 // if(Tab->custom->vbox)
131 // gtk_widget_destroy(Tab->custom->vbox);
132 // if(Tab->Attributes)
133 // g_object_unref(Tab->Attributes);
135 // if(Tab->Next) free_tab(Tab->Next);
141 mainWindow_free(mainWindow
* mw
)
146 //should free memory allocated dynamically first
147 // free_system_view(mw->SystemView);
150 g_critical("begin remove");
151 lttv_hooks_destroy(mw
->Traceset_Info
->before_traceset
);
152 lttv_hooks_destroy(mw
->Traceset_Info
->after_traceset
);
153 lttv_hooks_destroy(mw
->Traceset_Info
->before_trace
);
154 lttv_hooks_destroy(mw
->Traceset_Info
->after_trace
);
155 lttv_hooks_destroy(mw
->Traceset_Info
->before_tracefile
);
156 lttv_hooks_destroy(mw
->Traceset_Info
->after_tracefile
);
157 lttv_hooks_destroy(mw
->Traceset_Info
->before_event
);
158 lttv_hooks_destroy(mw
->Traceset_Info
->after_event
);
159 g_critical("end remove");
162 if(mw
->Traceset_Info
->path
!= NULL
)
163 g_free(mw
->Traceset_Info
->path
);
164 if(mw
->Traceset_Info
->TracesetContext
!= NULL
)
165 lttv_context_fini(LTTV_TRACESET_CONTEXT(mw
->Traceset_Info
->TracesetContext
));
166 if(mw
->Traceset_Info
->traceset
!= NULL
) {
167 nb
= lttv_traceset_number(mw
->Traceset_Info
->traceset
);
168 for(i
= 0 ; i
< nb
; i
++) {
170 lttv_traceset_get(mw
->Traceset_Info
->traceset
, i
));
174 lttv_traceset_destroy(mw
->Traceset_Info
->traceset
);
176 g_object_unref(mw
->Attributes
);
178 g_free(mw
->Traceset_Info
);
179 mw
->Traceset_Info
= NULL
;
181 Main_Window_List
= g_slist_remove(Main_Window_List
, mw
);
189 mainWindow_Destructor(mainWindow
* mw
)
191 if(GTK_IS_WIDGET(mw
->MWindow
)){
192 gtk_widget_destroy(mw
->MWindow
);
193 // gtk_widget_destroy(mw->HelpContents);
194 // gtk_widget_destroy(mw->AboutBox);
197 //mainWindow_free called when the object mw in the widget is unref.
198 //mainWindow_free(mw);
202 void destroy_walk(gpointer data
, gpointer user_data
)
204 mainWindow_Destructor((mainWindow
*)data
);
210 * plugin's destroy function
212 * This function releases the memory reserved by the module and unregisters
213 * everything that has been registered in the gtkTraceSet API.
215 G_MODULE_EXPORT
void destroy() {
217 LttvAttributeValue value
;
219 lttv_option_remove("trace");
221 lttv_hooks_remove_data(main_hooks
, Window_Creation_Hook
, &gWinCreationData
);
223 g_critical("GUI destroy()");
225 g_slist_foreach(Main_Window_List
, destroy_walk
, NULL
);
226 g_slist_free(Main_Window_List
);