781844ad04d2f7804b7173042098211dfa3fede7
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>
48 /** Array containing instanced objects. */
49 GSList
* g_main_window_list
= NULL
;
54 /* Initial trace from command line */
55 LttvTrace
*g_init_trace
= NULL
;
59 void lttv_trace_option(void *hook_data
)
63 trace
= ltt_trace_open(a_trace
);
64 if(trace
== NULL
) g_critical("cannot open trace %s", a_trace
);
65 g_init_trace
= lttv_trace_new(trace
);
68 /*****************************************************************************
69 * Functions for module loading/unloading *
70 *****************************************************************************/
72 * plugin's init function
74 * This function initializes the GUI.
77 static gboolean
window_creation_hook(void *hook_data
, void *call_data
)
79 g_debug("GUI window_creation_hook()");
81 bindtextdomain (GETTEXT_PACKAGE
, PACKAGE_LOCALE_DIR
);
82 bind_textdomain_codeset (GETTEXT_PACKAGE
, "UTF-8");
83 textdomain (GETTEXT_PACKAGE
);
87 gtk_init (<tv_argc
, <tv_argv
);
89 add_pixmap_directory (PACKAGE_DATA_DIR
"/" PACKAGE
"/pixmaps");
90 add_pixmap_directory ("pixmaps");
91 add_pixmap_directory ("../modules/gui/main/pixmaps");
93 construct_main_window(NULL
);
102 LttvAttributeValue value
;
104 // Global attributes only used for interaction with main() here.
105 LttvIAttribute
*attributes
= LTTV_IATTRIBUTE(lttv_global_attributes());
107 g_debug("GUI init()");
109 lttv_option_add("trace", 't',
110 "add a trace to the trace set to analyse",
111 "pathname of the directory containing the trace",
112 LTTV_OPT_STRING
, &a_trace
, lttv_trace_option
, NULL
);
114 g_assert(lttv_iattribute_find_by_path(attributes
, "hooks/main/before",
115 LTTV_POINTER
, &value
));
116 g_assert((main_hooks
= *(value
.v_pointer
)) != NULL
);
118 lttv_hooks_add(main_hooks
, window_creation_hook
, NULL
);
123 main_window_free(MainWindow
* mw
)
127 lttv_state_remove_event_hooks(
128 (LttvTracesetState
*)mw
->tab
->traceset_info
->traceset_context
);
129 mw
->tab
= mw
->tab
->next
;
131 g_object_unref(mw
->attributes
);
132 g_main_window_list
= g_slist_remove(g_main_window_list
, mw
);
134 g_hash_table_destroy(mw
->hash_menu_item
);
135 g_hash_table_destroy(mw
->hash_toolbar_item
);
143 main_window_destructor(MainWindow
* mw
)
145 if(GTK_IS_WIDGET(mw
->mwindow
)){
146 gtk_widget_destroy(mw
->mwindow
);
147 // gtk_widget_destroy(mw->HelpContents);
148 // gtk_widget_destroy(mw->AboutBox);
151 //main_window_free called when the object mw in the widget is unref.
152 //main_window_free(mw);
156 void main_window_destroy_walk(gpointer data
, gpointer user_data
)
158 main_window_destructor((MainWindow
*)data
);
164 * plugin's destroy function
166 * This function releases the memory reserved by the module and unregisters
167 * everything that has been registered in the gtkTraceSet API.
169 static void destroy() {
171 LttvAttributeValue value
;
174 lttv_option_remove("trace");
176 lttv_hooks_remove_data(main_hooks
, window_creation_hook
, NULL
);
178 g_debug("GUI destroy()");
180 if(g_main_window_list
){
181 g_slist_foreach(g_main_window_list
, main_window_destroy_walk
, NULL
);
182 g_slist_free(g_main_window_list
);
188 LTTV_MODULE("mainwin", "Viewer main window", \
189 "Viewer with multiple windows, tabs and panes for graphical modules", \
190 init
, destroy
, "stats")
This page took 0.033429 seconds and 4 git commands to generate.