Added options to run different tests in module batchtest
[lttv.git] / ltt / branches / poly / lttv / modules / gui / main / src / init_module.c
... / ...
CommitLineData
1/* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Mathieu Desnoyers and XangXiu Yang
3 *
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;
7 *
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.
12 *
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,
16 * MA 02111-1307, USA.
17 */
18
19/*
20 * Initial main.c file generated by Glade. Edit as required.
21 * Glade will not overwrite this file.
22 */
23
24#ifdef HAVE_CONFIG_H
25# include <config.h>
26#endif
27
28#include <gtk/gtk.h>
29
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>
40
41#include "interface.h"
42#include "support.h"
43#include <lttv/mainwindow.h>
44#include "callbacks.h"
45#include <ltt/trace.h>
46
47
48/* global variable */
49static WindowCreationData win_creation_data;
50
51/** Array containing instanced objects. */
52GSList * g_main_window_list = NULL ;
53
54LttvHooks
55 *main_hooks;
56
57/* Initial trace from command line */
58LttvTrace *g_init_trace = NULL;
59
60static char *a_trace;
61
62void lttv_trace_option(void *hook_data)
63{
64 LttTrace *trace;
65
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);
69}
70
71/*****************************************************************************
72 * Functions for module loading/unloading *
73 *****************************************************************************/
74/**
75 * plugin's init function
76 *
77 * This function initializes the GUI.
78 */
79
80static gboolean window_creation_hook(void *hook_data, void *call_data)
81{
82 WindowCreationData* window_creation_data = (WindowCreationData*)hook_data;
83
84 g_debug("GUI window_creation_hook()");
85#ifdef ENABLE_NLS
86 bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
87 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
88 textdomain (GETTEXT_PACKAGE);
89#endif
90
91 gtk_set_locale ();
92 gtk_init (&(window_creation_data->argc), &(window_creation_data->argv));
93
94 add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps");
95 add_pixmap_directory ("pixmaps");
96 add_pixmap_directory ("../modules/gui/main/pixmaps");
97
98 construct_main_window(NULL, window_creation_data);
99
100 gtk_main ();
101
102 return FALSE;
103}
104
105G_MODULE_EXPORT void init(LttvModule *self, int argc, char *argv[]) {
106
107 LttvAttributeValue value;
108
109 // Global attributes only used for interaction with main() here.
110 LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes());
111
112 g_debug("GUI init()");
113
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);
118
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);
122
123 win_creation_data.argc = argc;
124 win_creation_data.argv = argv;
125
126 lttv_hooks_add(main_hooks, window_creation_hook, &win_creation_data);
127
128}
129
130void
131main_window_free(MainWindow * mw)
132{
133 if(mw){
134 while(mw->tab){
135 lttv_state_remove_event_hooks(
136 (LttvTracesetState*)mw->tab->traceset_info->traceset_context);
137 mw->tab = mw->tab->next;
138 }
139 g_object_unref(mw->attributes);
140 g_main_window_list = g_slist_remove(g_main_window_list, mw);
141
142 g_hash_table_destroy(mw->hash_menu_item);
143 g_hash_table_destroy(mw->hash_toolbar_item);
144
145 g_free(mw);
146 mw = NULL;
147 }
148}
149
150void
151main_window_destructor(MainWindow * mw)
152{
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);
157 mw = NULL;
158 }
159 //main_window_free called when the object mw in the widget is unref.
160 //main_window_free(mw);
161}
162
163
164void main_window_destroy_walk(gpointer data, gpointer user_data)
165{
166 main_window_destructor((MainWindow*)data);
167}
168
169
170
171/**
172 * plugin's destroy function
173 *
174 * This function releases the memory reserved by the module and unregisters
175 * everything that has been registered in the gtkTraceSet API.
176 */
177G_MODULE_EXPORT void destroy() {
178
179 LttvAttributeValue value;
180 LttvTrace *trace;
181
182 lttv_option_remove("trace");
183
184 lttv_hooks_remove_data(main_hooks, window_creation_hook, &win_creation_data);
185
186 g_debug("GUI destroy()");
187
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);
191 }
192
193}
194
195
196
197
This page took 0.022813 seconds and 4 git commands to generate.