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
;
49 void lttv_trace_option(void *hook_data
)
53 trace
= ltt_trace_open(a_trace
);
54 if(trace
== NULL
) g_critical("cannot open trace %s", a_trace
);
55 lttv_traceset_add(traceset
, trace
);
58 /*****************************************************************************
59 * Functions for module loading/unloading *
60 *****************************************************************************/
62 * plugin's init function
64 * This function initializes the GUI.
67 static gboolean
Window_Creation_Hook(void *hook_data
, void *call_data
)
69 WindowCreationData
* Window_Creation_Data
= (WindowCreationData
*)hook_data
;
71 g_critical("GUI Window_Creation_Hook()");
73 bindtextdomain (GETTEXT_PACKAGE
, PACKAGE_LOCALE_DIR
);
74 bind_textdomain_codeset (GETTEXT_PACKAGE
, "UTF-8");
75 textdomain (GETTEXT_PACKAGE
);
79 gtk_init (&(Window_Creation_Data
->argc
), &(Window_Creation_Data
->argv
));
81 add_pixmap_directory (PACKAGE_DATA_DIR
"/" PACKAGE
"/pixmaps");
82 add_pixmap_directory ("pixmaps");
83 add_pixmap_directory ("modules/gui/mainWin/pixmaps");
86 if(!gTracesetContext
){
87 gTracesetContext
= g_object_new(LTTV_TRACESET_STATS_TYPE
, NULL
);
88 lttv_context_init(LTTV_TRACESET_CONTEXT(gTracesetContext
), traceset
);
91 constructMainWin(NULL
, Window_Creation_Data
);
101 G_MODULE_EXPORT
void init(LttvModule
*self
, int argc
, char *argv
[]) {
103 LttvAttributeValue value
;
105 LttvIAttribute
*attributes
= LTTV_IATTRIBUTE(lttv_global_attributes());
107 g_critical("GUI init()");
109 lttv_option_add("trace", 't',
110 "add a trace to the trace set to analyse",
111 "pathname of the directory containing the trace",
112 LTTV_OPT_STRING
, &a_trace
, lttv_trace_option
, NULL
);
114 traceset
= lttv_traceset_new();
116 before_traceset
= lttv_hooks_new();
117 after_traceset
= lttv_hooks_new();
118 before_trace
= lttv_hooks_new();
119 after_trace
= lttv_hooks_new();
120 before_tracefile
= lttv_hooks_new();
121 after_tracefile
= lttv_hooks_new();
122 before_event
= lttv_hooks_new();
123 after_event
= lttv_hooks_new();
125 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/traceset/before",
126 LTTV_POINTER
, &value
));
127 *(value
.v_pointer
) = before_traceset
;
128 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/traceset/after",
129 LTTV_POINTER
, &value
));
130 *(value
.v_pointer
) = after_traceset
;
131 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/trace/before",
132 LTTV_POINTER
, &value
));
133 *(value
.v_pointer
) = before_trace
;
134 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/trace/after",
135 LTTV_POINTER
, &value
));
136 *(value
.v_pointer
) = after_trace
;
137 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/tracefile/before",
138 LTTV_POINTER
, &value
));
139 *(value
.v_pointer
) = before_tracefile
;
140 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/tracefile/after",
141 LTTV_POINTER
, &value
));
142 *(value
.v_pointer
) = after_tracefile
;
143 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/event/before",
144 LTTV_POINTER
, &value
));
145 *(value
.v_pointer
) = before_event
;
146 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/event/after",
147 LTTV_POINTER
, &value
));
148 *(value
.v_pointer
) = after_event
;
150 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/main/before",
151 LTTV_POINTER
, &value
));
152 g_assert((main_hooks
= *(value
.v_pointer
)) != NULL
);
154 gWinCreationData
.argc
= argc
;
155 gWinCreationData
.argv
= argv
;
157 lttv_hooks_add(main_hooks
, Window_Creation_Hook
, &gWinCreationData
);
162 free_system_view(systemView
* SystemView
)
164 if(!SystemView
)return;
165 //free_EventDB(SystemView->EventDB);
166 //free_SystemInfo(SystemView->SystemInfo);
167 //free_Options(SystemView->Options);
169 free_system_view(SystemView
->Next
);
173 void free_tab(tab
* Tab
)
176 if(Tab
->custom
->vbox
)
177 gtk_widget_destroy(Tab
->custom
->vbox
);
179 g_object_unref(Tab
->Attributes
);
181 if(Tab
->Next
) free_tab(Tab
->Next
);
186 mainWindow_free(mainWindow
* mw
)
189 Main_Window_List
= g_slist_remove(Main_Window_List
, mw
);
191 //should free memory allocated dynamically first
192 free_system_view(mw
->SystemView
);
194 g_object_unref(mw
->Attributes
);
201 mainWindow_Destructor(mainWindow
* mw
)
203 if(GTK_IS_WIDGET(mw
->MWindow
)){
204 gtk_widget_destroy(mw
->MWindow
);
205 // gtk_widget_destroy(mw->HelpContents);
206 // gtk_widget_destroy(mw->AboutBox);
214 void destroy_walk(gpointer data
, gpointer user_data
)
216 mainWindow_Destructor((mainWindow
*)data
);
222 * plugin's destroy function
224 * This function releases the memory reserved by the module and unregisters
225 * everything that has been registered in the gtkTraceSet API.
227 G_MODULE_EXPORT
void destroy() {
229 LttvAttributeValue value
;
233 lttv_option_remove("trace");
235 lttv_hooks_destroy(before_traceset
);
236 lttv_hooks_destroy(after_traceset
);
237 lttv_hooks_destroy(before_trace
);
238 lttv_hooks_destroy(after_trace
);
239 lttv_hooks_destroy(before_tracefile
);
240 lttv_hooks_destroy(after_tracefile
);
241 lttv_hooks_destroy(before_event
);
242 lttv_hooks_destroy(after_event
);
243 lttv_hooks_remove_data(main_hooks
, Window_Creation_Hook
, &gWinCreationData
);
245 nb
= lttv_traceset_number(traceset
);
246 for(i
= 0 ; i
< nb
; i
++) {
247 ltt_trace_close(lttv_traceset_get(traceset
, i
));
250 lttv_traceset_destroy(traceset
);
252 g_critical("GUI destroy()");
254 g_slist_foreach(Main_Window_List
, destroy_walk
, NULL
);
255 g_slist_free(Main_Window_List
);
258 g_object_unref(gTracesetContext
);