#include "support.h"
#include <lttv/mainWindow.h>
#include "callbacks.h"
+#include <ltt/trace.h>
+
/* global variable */
-LttvTracesetStats * gTracesetContext = NULL;
-static LttvTraceset * traceset;
+static WindowCreationData win_creation_data;
/** Array containing instanced objects. */
-GSList * Main_Window_List = NULL ;
-
-static LttvHooks
- *before_traceset,
- *after_traceset,
- *before_trace,
- *after_trace,
- *before_tracefile,
- *after_tracefile,
- *before_event,
- *after_event,
+GSList * g_main_window_list = NULL ;
+
+LttvHooks
*main_hooks;
+/* Initial trace from command line */
+LttvTrace *g_init_trace = NULL;
+
static char *a_trace;
void lttv_trace_option(void *hook_data)
trace = ltt_trace_open(a_trace);
if(trace == NULL) g_critical("cannot open trace %s", a_trace);
- lttv_traceset_add(traceset, trace);
+ g_init_trace = lttv_trace_new(trace);
}
/*****************************************************************************
* This function initializes the GUI.
*/
-static gboolean Window_Creation_Hook(void *hook_data, void *call_data)
+static gboolean window_creation_hook(void *hook_data, void *call_data)
{
- WindowCreationData* Window_Creation_Data = (WindowCreationData*)hook_data;
+ WindowCreationData* window_creation_data = (WindowCreationData*)hook_data;
- g_critical("GUI Window_Creation_Hook()");
+ g_critical("GUI window_creation_hook()");
#ifdef ENABLE_NLS
bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
#endif
gtk_set_locale ();
- gtk_init (&(Window_Creation_Data->argc), &(Window_Creation_Data->argv));
+ gtk_init (&(window_creation_data->argc), &(window_creation_data->argv));
add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps");
add_pixmap_directory ("pixmaps");
add_pixmap_directory ("modules/gui/mainWin/pixmaps");
-
- if(!gTracesetContext){
- gTracesetContext = g_object_new(LTTV_TRACESET_STATS_TYPE, NULL);
- //FIXME: lttv_context_fini should be called some where.
- lttv_context_init(LTTV_TRACESET_CONTEXT(gTracesetContext), traceset);
- }
-
- constructMainWin(NULL, Window_Creation_Data);
+ construct_main_window(NULL, window_creation_data);
gtk_main ();
return FALSE;
}
-
-
-
G_MODULE_EXPORT void init(LttvModule *self, int argc, char *argv[]) {
LttvAttributeValue value;
- WindowCreationData *Window_Creation_Data = g_new(WindowCreationData, 1);
-
+
+ // Global attributes only used for interaction with main() here.
LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes());
g_critical("GUI init()");
"pathname of the directory containing the trace",
LTTV_OPT_STRING, &a_trace, lttv_trace_option, NULL);
- traceset = lttv_traceset_new();
-
- before_traceset = lttv_hooks_new();
- after_traceset = lttv_hooks_new();
- before_trace = lttv_hooks_new();
- after_trace = lttv_hooks_new();
- before_tracefile = lttv_hooks_new();
- after_tracefile = lttv_hooks_new();
- before_event = lttv_hooks_new();
- after_event = lttv_hooks_new();
-
- g_assert(lttv_iattribute_find_by_path(attributes, "hooks/traceset/before",
- LTTV_POINTER, &value));
- *(value.v_pointer) = before_traceset;
- g_assert(lttv_iattribute_find_by_path(attributes, "hooks/traceset/after",
- LTTV_POINTER, &value));
- *(value.v_pointer) = after_traceset;
- g_assert(lttv_iattribute_find_by_path(attributes, "hooks/trace/before",
- LTTV_POINTER, &value));
- *(value.v_pointer) = before_trace;
- g_assert(lttv_iattribute_find_by_path(attributes, "hooks/trace/after",
- LTTV_POINTER, &value));
- *(value.v_pointer) = after_trace;
- g_assert(lttv_iattribute_find_by_path(attributes, "hooks/tracefile/before",
- LTTV_POINTER, &value));
- *(value.v_pointer) = before_tracefile;
- g_assert(lttv_iattribute_find_by_path(attributes, "hooks/tracefile/after",
- LTTV_POINTER, &value));
- *(value.v_pointer) = after_tracefile;
- g_assert(lttv_iattribute_find_by_path(attributes, "hooks/event/before",
- LTTV_POINTER, &value));
- *(value.v_pointer) = before_event;
- g_assert(lttv_iattribute_find_by_path(attributes, "hooks/event/after",
- LTTV_POINTER, &value));
- *(value.v_pointer) = after_event;
-
g_assert(lttv_iattribute_find_by_path(attributes, "hooks/main/before",
LTTV_POINTER, &value));
g_assert((main_hooks = *(value.v_pointer)) != NULL);
- Window_Creation_Data->argc = argc;
- Window_Creation_Data->argv = argv;
+ win_creation_data.argc = argc;
+ win_creation_data.argv = argv;
- lttv_hooks_add(main_hooks, Window_Creation_Hook, Window_Creation_Data);
+ lttv_hooks_add(main_hooks, window_creation_hook, &win_creation_data);
}
-void destroy_walk(gpointer data, gpointer user_data)
+void
+main_window_free(MainWindow * mw)
+{
+ if(mw){
+ while(mw->tab){
+ lttv_state_remove_event_hooks(
+ (LttvTracesetState*)mw->tab->traceset_info->traceset_context);
+ mw->tab = mw->tab->next;
+ }
+ g_object_unref(mw->attributes);
+ g_main_window_list = g_slist_remove(g_main_window_list, mw);
+
+ g_hash_table_destroy(mw->hash_menu_item);
+ g_hash_table_destroy(mw->hash_toolbar_item);
+
+ g_free(mw);
+ mw = NULL;
+ }
+}
+
+void
+main_window_destructor(MainWindow * mw)
{
- //GuiControlFlow_Destructor((ControlFlowData*)data);
+ if(GTK_IS_WIDGET(mw->mwindow)){
+ gtk_widget_destroy(mw->mwindow);
+ // gtk_widget_destroy(mw->HelpContents);
+ // gtk_widget_destroy(mw->AboutBox);
+ mw = NULL;
+ }
+ //main_window_free called when the object mw in the widget is unref.
+ //main_window_free(mw);
+}
+
+
+void main_window_destroy_walk(gpointer data, gpointer user_data)
+{
+ main_window_destructor((MainWindow*)data);
}
*/
G_MODULE_EXPORT void destroy() {
- WindowCreationData *Window_Creation_Data;
- LttvAttributeValue value;
-
- guint i, nb;
+ LttvAttributeValue value;
+ LttvTrace *trace;
lttv_option_remove("trace");
- lttv_hooks_destroy(before_traceset);
- lttv_hooks_destroy(after_traceset);
- lttv_hooks_destroy(before_trace);
- lttv_hooks_destroy(after_trace);
- lttv_hooks_destroy(before_tracefile);
- lttv_hooks_destroy(after_tracefile);
- lttv_hooks_destroy(before_event);
- lttv_hooks_destroy(after_event);
- lttv_hooks_remove_data(main_hooks, Window_Creation_Hook, NULL);
-
- nb = lttv_traceset_number(traceset);
- for(i = 0 ; i < nb ; i++) {
- ltt_trace_close(lttv_traceset_get(traceset, i));
- }
-
- lttv_traceset_destroy(traceset);
+ lttv_hooks_remove_data(main_hooks, window_creation_hook, &win_creation_data);
g_critical("GUI destroy()");
-
-
- //ControlFlowData *Control_Flow_Data;
-
-
- g_slist_foreach(Main_Window_List, destroy_walk, NULL );
-
+ if(g_main_window_list){
+ g_slist_foreach(g_main_window_list, main_window_destroy_walk, NULL );
+ g_slist_free(g_main_window_list);
+ }
- //lttv_hooks_remove_data(main_hooks,Window_Creation_Hook, NULL);
- //lttv_hooks_remove_data(before_traceset, get_traceset_context, NULL);
-
- // g_free(Window_Creation_Data);
-
- g_object_unref(gTracesetContext);
}