quit menu complete
[lttv.git] / ltt / branches / poly / lttv / modules / gui / mainWin / src / init_module.c
CommitLineData
fb87279e 1/*
2 * Initial main.c file generated by Glade. Edit as required.
3 * Glade will not overwrite this file.
4 */
5
6#ifdef HAVE_CONFIG_H
7# include <config.h>
8#endif
9
10#include <gtk/gtk.h>
11
fb87279e 12#include <lttv/lttv.h>
0a6808c0 13#include <lttv/attribute.h>
14#include <lttv/hook.h>
15#include <lttv/option.h>
16#include <lttv/module.h>
ec25ff5e 17#include <lttv/processTrace.h>
18#include <lttv/state.h>
6b1d3120 19#include <lttv/stats.h>
37d0eca6 20#include <lttv/menu.h>
21#include <lttv/toolbar.h>
fb87279e 22
23#include "interface.h"
24#include "support.h"
95cd67ef 25#include <lttv/mainWindow.h>
fb87279e 26#include "callbacks.h"
27
28/* global variable */
6b1d3120 29LttvTracesetStats * gTracesetContext = NULL;
ec25ff5e 30static LttvTraceset * traceset;
7a859036 31WindowCreationData gWinCreationData;
0a6808c0 32
ec25ff5e 33/** Array containing instanced objects. */
34GSList * Main_Window_List = NULL ;
35
36static LttvHooks
37 *before_traceset,
38 *after_traceset,
39 *before_trace,
40 *after_trace,
41 *before_tracefile,
42 *after_tracefile,
43 *before_event,
44 *after_event,
45 *main_hooks;
46
47static char *a_trace;
48
49void lttv_trace_option(void *hook_data)
50{
51 LttTrace *trace;
52
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);
56}
fb87279e 57
58/*****************************************************************************
59 * Functions for module loading/unloading *
60 *****************************************************************************/
61/**
62 * plugin's init function
63 *
64 * This function initializes the GUI.
65 */
66
0a6808c0 67static gboolean Window_Creation_Hook(void *hook_data, void *call_data)
fb87279e 68{
5723fa24 69 WindowCreationData* Window_Creation_Data = (WindowCreationData*)hook_data;
fb87279e 70
558aa013 71 g_critical("GUI Window_Creation_Hook()");
fb87279e 72#ifdef ENABLE_NLS
73 bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
74 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
75 textdomain (GETTEXT_PACKAGE);
76#endif
77
78 gtk_set_locale ();
79 gtk_init (&(Window_Creation_Data->argc), &(Window_Creation_Data->argv));
80
81 add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps");
82 add_pixmap_directory ("pixmaps");
0a6808c0 83 add_pixmap_directory ("modules/gui/mainWin/pixmaps");
fb87279e 84
5723fa24 85
ec25ff5e 86 if(!gTracesetContext){
6b1d3120 87 gTracesetContext = g_object_new(LTTV_TRACESET_STATS_TYPE, NULL);
ec25ff5e 88 lttv_context_init(LTTV_TRACESET_CONTEXT(gTracesetContext), traceset);
89 }
fb87279e 90
5723fa24 91 constructMainWin(NULL, Window_Creation_Data);
fb87279e 92
93 gtk_main ();
0a6808c0 94
ec25ff5e 95 return FALSE;
0a6808c0 96}
97
98
99
100
101G_MODULE_EXPORT void init(LttvModule *self, int argc, char *argv[]) {
102
ec25ff5e 103 LttvAttributeValue value;
ec25ff5e 104
105 LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes());
106
558aa013 107 g_critical("GUI init()");
108
ec25ff5e 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);
113
114 traceset = lttv_traceset_new();
115
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();
124
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;
149
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);
153
7a859036 154 gWinCreationData.argc = argc;
155 gWinCreationData.argv = argv;
ec25ff5e 156
7a859036 157 lttv_hooks_add(main_hooks, Window_Creation_Hook, &gWinCreationData);
0a6808c0 158
fb87279e 159}
160
7a859036 161void
162free_system_view(systemView * SystemView)
163{
164 if(!SystemView)return;
165 //free_EventDB(SystemView->EventDB);
166 //free_SystemInfo(SystemView->SystemInfo);
167 //free_Options(SystemView->Options);
168 if(SystemView->Next)
169 free_system_view(SystemView->Next);
170 g_free(SystemView);
171}
172
173void free_tab(tab * Tab)
174{
175 if(!Tab) return;
176 if(Tab->custom->vbox)
177 gtk_widget_destroy(Tab->custom->vbox);
178 if(Tab->Attributes)
179 g_object_unref(Tab->Attributes);
180
181 if(Tab->Next) free_tab(Tab->Next);
182 g_free(Tab);
183}
184
185void
186mainWindow_free(mainWindow * mw)
187{
188 if(mw){
189 Main_Window_List = g_slist_remove(Main_Window_List, mw);
190
191 //should free memory allocated dynamically first
192 free_system_view(mw->SystemView);
193 free_tab(mw->Tab);
194 g_object_unref(mw->Attributes);
195
196 g_free(mw);
197 }
198}
199
200void
201mainWindow_Destructor(mainWindow * mw)
202{
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);
207 mw = NULL;
208 }
209
210 mainWindow_free(mw);
211}
212
213
fb87279e 214void destroy_walk(gpointer data, gpointer user_data)
215{
7a859036 216 mainWindow_Destructor((mainWindow*)data);
fb87279e 217}
218
219
220
221/**
222 * plugin's destroy function
223 *
224 * This function releases the memory reserved by the module and unregisters
225 * everything that has been registered in the gtkTraceSet API.
226 */
227G_MODULE_EXPORT void destroy() {
228
7a859036 229 LttvAttributeValue value;
ec25ff5e 230
231 guint i, nb;
232
233 lttv_option_remove("trace");
234
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);
7a859036 243 lttv_hooks_remove_data(main_hooks, Window_Creation_Hook, &gWinCreationData);
ec25ff5e 244
245 nb = lttv_traceset_number(traceset);
246 for(i = 0 ; i < nb ; i++) {
247 ltt_trace_close(lttv_traceset_get(traceset, i));
248 }
249
250 lttv_traceset_destroy(traceset);
fb87279e 251
ec25ff5e 252 g_critical("GUI destroy()");
fb87279e 253
ec25ff5e 254 g_slist_foreach(Main_Window_List, destroy_walk, NULL );
7a859036 255 g_slist_free(Main_Window_List);
ec25ff5e 256
fb87279e 257
ec25ff5e 258 g_object_unref(gTracesetContext);
fb87279e 259}
260
261
262
263
This page took 0.033005 seconds and 4 git commands to generate.