traceset per tab
[lttv.git] / ltt / branches / poly / lttv / modules / gui / mainWin / src / init_module.c
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
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>
22
23 #include "interface.h"
24 #include "support.h"
25 #include <lttv/mainWindow.h>
26 #include "callbacks.h"
27
28 /* global variable */
29 static WindowCreationData win_creation_data;
30
31 /** Array containing instanced objects. */
32 GSList * g_main_window_list = NULL ;
33
34 LttvHooks
35 *main_hooks;
36
37 /* Initial trace from command line */
38 LttvTrace *g_init_trace = NULL;
39
40 static char *a_trace;
41
42 void lttv_trace_option(void *hook_data)
43 {
44 LttTrace *trace;
45
46 trace = ltt_trace_open(a_trace);
47 if(trace == NULL) g_critical("cannot open trace %s", a_trace);
48 g_init_trace = lttv_trace_new(trace);
49 }
50
51 /*****************************************************************************
52 * Functions for module loading/unloading *
53 *****************************************************************************/
54 /**
55 * plugin's init function
56 *
57 * This function initializes the GUI.
58 */
59
60 static gboolean window_creation_hook(void *hook_data, void *call_data)
61 {
62 WindowCreationData* window_creation_data = (WindowCreationData*)hook_data;
63
64 g_critical("GUI window_creation_hook()");
65 #ifdef ENABLE_NLS
66 bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
67 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
68 textdomain (GETTEXT_PACKAGE);
69 #endif
70
71 gtk_set_locale ();
72 gtk_init (&(window_creation_data->argc), &(window_creation_data->argv));
73
74 add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps");
75 add_pixmap_directory ("pixmaps");
76 add_pixmap_directory ("modules/gui/mainWin/pixmaps");
77
78 construct_main_window(NULL, window_creation_data);
79
80 gtk_main ();
81
82 return FALSE;
83 }
84
85 G_MODULE_EXPORT void init(LttvModule *self, int argc, char *argv[]) {
86
87 LttvAttributeValue value;
88
89 // Global attributes only used for interaction with main() here.
90 LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes());
91
92 g_critical("GUI init()");
93
94 lttv_option_add("trace", 't',
95 "add a trace to the trace set to analyse",
96 "pathname of the directory containing the trace",
97 LTTV_OPT_STRING, &a_trace, lttv_trace_option, NULL);
98
99 g_assert(lttv_iattribute_find_by_path(attributes, "hooks/main/before",
100 LTTV_POINTER, &value));
101 g_assert((main_hooks = *(value.v_pointer)) != NULL);
102
103 win_creation_data.argc = argc;
104 win_creation_data.argv = argv;
105
106 lttv_hooks_add(main_hooks, window_creation_hook, &win_creation_data);
107
108 }
109
110 void
111 main_window_free(MainWindow * mw)
112 {
113 if(mw){
114 g_object_unref(mw->attributes);
115 g_main_window_list = g_slist_remove(g_main_window_list, mw);
116
117 g_hash_table_destroy(mw->hash_menu_item);
118 g_hash_table_destroy(mw->hash_toolbar_item);
119
120 g_free(mw);
121 mw = NULL;
122 }
123 }
124
125 void
126 main_window_destructor(MainWindow * mw)
127 {
128 if(GTK_IS_WIDGET(mw->mwindow)){
129 gtk_widget_destroy(mw->mwindow);
130 // gtk_widget_destroy(mw->HelpContents);
131 // gtk_widget_destroy(mw->AboutBox);
132 mw = NULL;
133 }
134 //main_window_free called when the object mw in the widget is unref.
135 //main_window_free(mw);
136 }
137
138
139 void main_window_destroy_walk(gpointer data, gpointer user_data)
140 {
141 main_window_destructor((MainWindow*)data);
142 }
143
144
145
146 /**
147 * plugin's destroy function
148 *
149 * This function releases the memory reserved by the module and unregisters
150 * everything that has been registered in the gtkTraceSet API.
151 */
152 G_MODULE_EXPORT void destroy() {
153
154 LttvAttributeValue value;
155 LttvTrace *trace;
156
157 lttv_option_remove("trace");
158
159 lttv_hooks_remove_data(main_hooks, window_creation_hook, &win_creation_data);
160
161 g_critical("GUI destroy()");
162
163 if(g_main_window_list){
164 g_slist_foreach(g_main_window_list, main_window_destroy_walk, NULL );
165 g_slist_free(g_main_window_list);
166 }
167
168 }
169
170
171
172
This page took 0.032645 seconds and 4 git commands to generate.