1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Mathieu Desnoyers and XangXiu Yang
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License Version 2 as
6 * published by the Free Software Foundation;
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20 * Initial main.c file generated by Glade. Edit as required.
21 * Glade will not overwrite this file.
30 #include <lttv/lttv.h>
31 #include <lttv/attribute.h>
32 #include <lttv/hook.h>
33 #include <lttv/option.h>
34 #include <lttv/module.h>
35 #include <lttv/processTrace.h>
36 #include <lttv/state.h>
37 #include <lttv/stats.h>
38 #include <lttv/menu.h>
39 #include <lttv/toolbar.h>
41 #include "interface.h"
43 #include <lttv/mainwindow.h>
44 #include "callbacks.h"
45 #include <ltt/trace.h>
49 static WindowCreationData win_creation_data
;
51 /** Array containing instanced objects. */
52 GSList
* g_main_window_list
= NULL
;
57 /* Initial trace from command line */
58 LttvTrace
*g_init_trace
= NULL
;
62 void lttv_trace_option(void *hook_data
)
66 trace
= ltt_trace_open(a_trace
);
67 if(trace
== NULL
) g_critical("cannot open trace %s", a_trace
);
68 g_init_trace
= lttv_trace_new(trace
);
71 /*****************************************************************************
72 * Functions for module loading/unloading *
73 *****************************************************************************/
75 * plugin's init function
77 * This function initializes the GUI.
80 static gboolean
window_creation_hook(void *hook_data
, void *call_data
)
82 WindowCreationData
* window_creation_data
= (WindowCreationData
*)hook_data
;
84 g_critical("GUI window_creation_hook()");
86 bindtextdomain (GETTEXT_PACKAGE
, PACKAGE_LOCALE_DIR
);
87 bind_textdomain_codeset (GETTEXT_PACKAGE
, "UTF-8");
88 textdomain (GETTEXT_PACKAGE
);
92 gtk_init (&(window_creation_data
->argc
), &(window_creation_data
->argv
));
94 add_pixmap_directory (PACKAGE_DATA_DIR
"/" PACKAGE
"/pixmaps");
95 add_pixmap_directory ("pixmaps");
96 add_pixmap_directory ("modules/gui/mainWin/pixmaps");
98 construct_main_window(NULL
, window_creation_data
);
105 G_MODULE_EXPORT
void init(LttvModule
*self
, int argc
, char *argv
[]) {
107 LttvAttributeValue value
;
109 // Global attributes only used for interaction with main() here.
110 LttvIAttribute
*attributes
= LTTV_IATTRIBUTE(lttv_global_attributes());
112 g_critical("GUI init()");
114 lttv_option_add("trace", 't',
115 "add a trace to the trace set to analyse",
116 "pathname of the directory containing the trace",
117 LTTV_OPT_STRING
, &a_trace
, lttv_trace_option
, NULL
);
119 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/main/before",
120 LTTV_POINTER
, &value
));
121 g_assert((main_hooks
= *(value
.v_pointer
)) != NULL
);
123 win_creation_data
.argc
= argc
;
124 win_creation_data
.argv
= argv
;
126 lttv_hooks_add(main_hooks
, window_creation_hook
, &win_creation_data
);
131 main_window_free(MainWindow
* mw
)
135 lttv_state_remove_event_hooks(
136 (LttvTracesetState
*)mw
->tab
->traceset_info
->traceset_context
);
137 mw
->tab
= mw
->tab
->next
;
139 g_object_unref(mw
->attributes
);
140 g_main_window_list
= g_slist_remove(g_main_window_list
, mw
);
142 g_hash_table_destroy(mw
->hash_menu_item
);
143 g_hash_table_destroy(mw
->hash_toolbar_item
);
151 main_window_destructor(MainWindow
* mw
)
153 if(GTK_IS_WIDGET(mw
->mwindow
)){
154 gtk_widget_destroy(mw
->mwindow
);
155 // gtk_widget_destroy(mw->HelpContents);
156 // gtk_widget_destroy(mw->AboutBox);
159 //main_window_free called when the object mw in the widget is unref.
160 //main_window_free(mw);
164 void main_window_destroy_walk(gpointer data
, gpointer user_data
)
166 main_window_destructor((MainWindow
*)data
);
172 * plugin's destroy function
174 * This function releases the memory reserved by the module and unregisters
175 * everything that has been registered in the gtkTraceSet API.
177 G_MODULE_EXPORT
void destroy() {
179 LttvAttributeValue value
;
182 lttv_option_remove("trace");
184 lttv_hooks_remove_data(main_hooks
, window_creation_hook
, &win_creation_data
);
186 g_critical("GUI destroy()");
188 if(g_main_window_list
){
189 g_slist_foreach(g_main_window_list
, main_window_destroy_walk
, NULL
);
190 g_slist_free(g_main_window_list
);