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/menu.h>
20 #include <lttv/toolbar.h>
22 #include "interface.h"
24 #include <lttv/mainWindow.h>
25 #include "callbacks.h"
28 systemView
* gSysView
;
30 LttvTracesetState
* gTracesetContext
= NULL
;
31 static LttvTraceset
* traceset
;
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 typedef struct _WindowCreationData
{
72 static gboolean
Window_Creation_Hook(void *hook_data
, void *call_data
)
76 view_constructor constructor
;
78 LttvToolbars
* toolbar
;
79 lttv_menu_closure
*menuItem
;
80 lttv_toolbar_closure
*toolbarItem
;
81 LttvAttributeValue value
;
82 LttvIAttribute
*attributes
= LTTV_IATTRIBUTE(lttv_global_attributes());
84 GtkWidget
* ToolMenuTitle_menu
, *insert_view
, *pixmap
;
86 mainWindow
* mw
= g_new(mainWindow
, 1);
87 gSysView
= g_new(systemView
, 1);
88 WindowCreationData
*Window_Creation_Data
= (WindowCreationData
*)call_data
;
90 /* Add the object's information to the module's array */
91 Main_Window_List
= g_slist_append(Main_Window_List
, mw
);
93 g_critical("GUI Window_Creation_Hook()");
95 bindtextdomain (GETTEXT_PACKAGE
, PACKAGE_LOCALE_DIR
);
96 bind_textdomain_codeset (GETTEXT_PACKAGE
, "UTF-8");
97 textdomain (GETTEXT_PACKAGE
);
101 gtk_init (&(Window_Creation_Data
->argc
), &(Window_Creation_Data
->argv
));
103 add_pixmap_directory (PACKAGE_DATA_DIR
"/" PACKAGE
"/pixmaps");
104 add_pixmap_directory ("pixmaps");
105 add_pixmap_directory ("modules/gui/mainWin/pixmaps");
108 * The following code was added by Glade to create one of each component
109 * (except popup menus), just so that you see something after building
110 * the project. Delete any components that you don't want shown initially.
112 window1
= create_MWindow ();
113 gtk_widget_show (window1
);
115 mw
->MWindow
= window1
;
116 mw
->SystemView
= gSysView
;
118 mw
->CurrentTab
= NULL
;
119 mw
->Attributes
= LTTV_IATTRIBUTE(g_object_new(LTTV_ATTRIBUTE_TYPE
, NULL
));
120 if(!gTracesetContext
){
121 gTracesetContext
= g_object_new(LTTV_TRACESET_STATE_TYPE
, NULL
);
122 //FIXME: lttv_context_fini should be called some where.
123 lttv_context_init(LTTV_TRACESET_CONTEXT(gTracesetContext
), traceset
);
125 mw
->traceset_context
= LTTV_TRACESET_CONTEXT(gTracesetContext
);
126 mw
->traceset
= (LTTV_TRACESET_CONTEXT(gTracesetContext
))->ts
;
127 g_object_ref(gTracesetContext
);
130 g_assert(lttv_iattribute_find_by_path(attributes
,
131 "viewers/menu", LTTV_POINTER
, &value
));
132 menu
= (LttvMenus
*)*(value
.v_pointer
);
135 for(i
=0;i
<menu
->len
;i
++){
136 menuItem
= &g_array_index(menu
, lttv_menu_closure
, i
);
137 constructor
= menuItem
->con
;
138 ToolMenuTitle_menu
= lookup_widget(mw
->MWindow
,"ToolMenuTitle_menu");
139 insert_view
= gtk_menu_item_new_with_mnemonic (menuItem
->menuText
);
140 gtk_widget_show (insert_view
);
141 gtk_container_add (GTK_CONTAINER (ToolMenuTitle_menu
), insert_view
);
142 g_signal_connect ((gpointer
) insert_view
, "activate",
143 G_CALLBACK (insertViewTest
),
148 g_assert(lttv_iattribute_find_by_path(attributes
,
149 "viewers/toolbar", LTTV_POINTER
, &value
));
150 toolbar
= (LttvToolbars
*)*(value
.v_pointer
);
153 for(i
=0;i
<toolbar
->len
;i
++){
154 toolbarItem
= &g_array_index(toolbar
, lttv_toolbar_closure
, i
);
155 constructor
= toolbarItem
->con
;
156 ToolMenuTitle_menu
= lookup_widget(mw
->MWindow
,"MToolbar2");
157 pixbuf
= gdk_pixbuf_new_from_xpm_data ((const char**)toolbarItem
->pixmap
);
158 pixmap
= gtk_image_new_from_pixbuf(pixbuf
);
159 insert_view
= gtk_toolbar_append_element (GTK_TOOLBAR (ToolMenuTitle_menu
),
160 GTK_TOOLBAR_CHILD_BUTTON
,
163 toolbarItem
->tooltip
, NULL
,
165 gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild
*) (g_list_last (GTK_TOOLBAR (ToolMenuTitle_menu
)->children
)->data
))->label
), TRUE
);
166 gtk_widget_show (insert_view
);
167 gtk_container_set_border_width (GTK_CONTAINER (insert_view
), 1);
168 g_signal_connect ((gpointer
) insert_view
, "clicked",G_CALLBACK (insertViewTest
),constructor
);
174 gSysView
->EventDB
= NULL
;
175 gSysView
->SystemInfo
= NULL
;
176 gSysView
->Options
= NULL
;
177 gSysView
->Window
= mw
;
178 gSysView
->Next
= NULL
;
180 g_object_set_data(G_OBJECT(window1
), "systemView", (gpointer
)gSysView
);
181 g_object_set_data(G_OBJECT(window1
), "mainWindow", (gpointer
)mw
);
191 G_MODULE_EXPORT
void init(LttvModule
*self
, int argc
, char *argv
[]) {
193 LttvAttributeValue value
;
194 WindowCreationData
*Window_Creation_Data
= g_new(WindowCreationData
, 1);
196 LttvIAttribute
*attributes
= LTTV_IATTRIBUTE(lttv_global_attributes());
198 g_critical("GUI init()");
200 lttv_option_add("trace", 't',
201 "add a trace to the trace set to analyse",
202 "pathname of the directory containing the trace",
203 LTTV_OPT_STRING
, &a_trace
, lttv_trace_option
, NULL
);
205 traceset
= lttv_traceset_new();
207 before_traceset
= lttv_hooks_new();
208 after_traceset
= lttv_hooks_new();
209 before_trace
= lttv_hooks_new();
210 after_trace
= lttv_hooks_new();
211 before_tracefile
= lttv_hooks_new();
212 after_tracefile
= lttv_hooks_new();
213 before_event
= lttv_hooks_new();
214 after_event
= lttv_hooks_new();
216 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/traceset/before",
217 LTTV_POINTER
, &value
));
218 *(value
.v_pointer
) = before_traceset
;
219 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/traceset/after",
220 LTTV_POINTER
, &value
));
221 *(value
.v_pointer
) = after_traceset
;
222 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/trace/before",
223 LTTV_POINTER
, &value
));
224 *(value
.v_pointer
) = before_trace
;
225 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/trace/after",
226 LTTV_POINTER
, &value
));
227 *(value
.v_pointer
) = after_trace
;
228 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/tracefile/before",
229 LTTV_POINTER
, &value
));
230 *(value
.v_pointer
) = before_tracefile
;
231 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/tracefile/after",
232 LTTV_POINTER
, &value
));
233 *(value
.v_pointer
) = after_tracefile
;
234 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/event/before",
235 LTTV_POINTER
, &value
));
236 *(value
.v_pointer
) = before_event
;
237 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/event/after",
238 LTTV_POINTER
, &value
));
239 *(value
.v_pointer
) = after_event
;
241 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/main/before",
242 LTTV_POINTER
, &value
));
243 g_assert((main_hooks
= *(value
.v_pointer
)) != NULL
);
245 Window_Creation_Data
->argc
= argc
;
246 Window_Creation_Data
->argv
= argv
;
248 lttv_hooks_add(main_hooks
, Window_Creation_Hook
, Window_Creation_Data
);
252 void destroy_walk(gpointer data
, gpointer user_data
)
254 //GuiControlFlow_Destructor((ControlFlowData*)data);
260 * plugin's destroy function
262 * This function releases the memory reserved by the module and unregisters
263 * everything that has been registered in the gtkTraceSet API.
265 G_MODULE_EXPORT
void destroy() {
267 WindowCreationData
*Window_Creation_Data
;
268 LttvAttributeValue value
;
272 lttv_option_remove("trace");
274 lttv_hooks_destroy(before_traceset
);
275 lttv_hooks_destroy(after_traceset
);
276 lttv_hooks_destroy(before_trace
);
277 lttv_hooks_destroy(after_trace
);
278 lttv_hooks_destroy(before_tracefile
);
279 lttv_hooks_destroy(after_tracefile
);
280 lttv_hooks_destroy(before_event
);
281 lttv_hooks_destroy(after_event
);
282 lttv_hooks_remove_data(main_hooks
, Window_Creation_Hook
, NULL
);
284 nb
= lttv_traceset_number(traceset
);
285 for(i
= 0 ; i
< nb
; i
++) {
286 ltt_trace_close(lttv_traceset_get(traceset
, i
));
289 lttv_traceset_destroy(traceset
);
291 g_critical("GUI destroy()");
295 //ControlFlowData *Control_Flow_Data;
298 g_slist_foreach(Main_Window_List
, destroy_walk
, NULL
);
301 //lttv_hooks_remove_data(main_hooks,Window_Creation_Hook, NULL);
302 //lttv_hooks_remove_data(before_traceset, get_traceset_context, NULL);
304 // g_free(Window_Creation_Data);
306 g_object_unref(gTracesetContext
);