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"
27 #include <ltt/trace.h>
31 static WindowCreationData win_creation_data
;
33 /** Array containing instanced objects. */
34 GSList
* g_main_window_list
= NULL
;
39 /* Initial trace from command line */
40 LttvTrace
*g_init_trace
= NULL
;
44 void lttv_trace_option(void *hook_data
)
48 trace
= ltt_trace_open(a_trace
);
49 if(trace
== NULL
) g_critical("cannot open trace %s", a_trace
);
50 g_init_trace
= lttv_trace_new(trace
);
53 /*****************************************************************************
54 * Functions for module loading/unloading *
55 *****************************************************************************/
57 * plugin's init function
59 * This function initializes the GUI.
62 static gboolean
window_creation_hook(void *hook_data
, void *call_data
)
64 WindowCreationData
* window_creation_data
= (WindowCreationData
*)hook_data
;
66 g_critical("GUI window_creation_hook()");
68 bindtextdomain (GETTEXT_PACKAGE
, PACKAGE_LOCALE_DIR
);
69 bind_textdomain_codeset (GETTEXT_PACKAGE
, "UTF-8");
70 textdomain (GETTEXT_PACKAGE
);
74 gtk_init (&(window_creation_data
->argc
), &(window_creation_data
->argv
));
76 add_pixmap_directory (PACKAGE_DATA_DIR
"/" PACKAGE
"/pixmaps");
77 add_pixmap_directory ("pixmaps");
78 add_pixmap_directory ("modules/gui/mainWin/pixmaps");
80 construct_main_window(NULL
, window_creation_data
);
87 G_MODULE_EXPORT
void init(LttvModule
*self
, int argc
, char *argv
[]) {
89 LttvAttributeValue value
;
91 // Global attributes only used for interaction with main() here.
92 LttvIAttribute
*attributes
= LTTV_IATTRIBUTE(lttv_global_attributes());
94 g_critical("GUI init()");
96 lttv_option_add("trace", 't',
97 "add a trace to the trace set to analyse",
98 "pathname of the directory containing the trace",
99 LTTV_OPT_STRING
, &a_trace
, lttv_trace_option
, NULL
);
101 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/main/before",
102 LTTV_POINTER
, &value
));
103 g_assert((main_hooks
= *(value
.v_pointer
)) != NULL
);
105 win_creation_data
.argc
= argc
;
106 win_creation_data
.argv
= argv
;
108 lttv_hooks_add(main_hooks
, window_creation_hook
, &win_creation_data
);
113 main_window_free(MainWindow
* mw
)
116 g_object_unref(mw
->attributes
);
117 g_main_window_list
= g_slist_remove(g_main_window_list
, mw
);
119 g_hash_table_destroy(mw
->hash_menu_item
);
120 g_hash_table_destroy(mw
->hash_toolbar_item
);
128 main_window_destructor(MainWindow
* mw
)
130 if(GTK_IS_WIDGET(mw
->mwindow
)){
131 gtk_widget_destroy(mw
->mwindow
);
132 // gtk_widget_destroy(mw->HelpContents);
133 // gtk_widget_destroy(mw->AboutBox);
136 //main_window_free called when the object mw in the widget is unref.
137 //main_window_free(mw);
141 void main_window_destroy_walk(gpointer data
, gpointer user_data
)
143 main_window_destructor((MainWindow
*)data
);
149 * plugin's destroy function
151 * This function releases the memory reserved by the module and unregisters
152 * everything that has been registered in the gtkTraceSet API.
154 G_MODULE_EXPORT
void destroy() {
156 LttvAttributeValue value
;
159 lttv_option_remove("trace");
161 lttv_hooks_remove_data(main_hooks
, window_creation_hook
, &win_creation_data
);
163 g_critical("GUI destroy()");
165 if(g_main_window_list
){
166 g_slist_foreach(g_main_window_list
, main_window_destroy_walk
, NULL
);
167 g_slist_free(g_main_window_list
);