X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttv%2Fmodules%2Fgui%2FmainWin%2Fsrc%2Finit_module.c;h=2201eadc1f6d5167055fab578fdebcb5a2d4783b;hb=540edb40ef20c2ce40132b3189e183d055dbe711;hp=1aa9c19df9784aa6348a8abfc3944e80b9c668e0;hpb=95cd67ef6c80afe4ab7c30e7aa3773f1628ee1de;p=lttv.git diff --git a/ltt/branches/poly/lttv/modules/gui/mainWin/src/init_module.c b/ltt/branches/poly/lttv/modules/gui/mainWin/src/init_module.c index 1aa9c19d..2201eadc 100644 --- a/ltt/branches/poly/lttv/modules/gui/mainWin/src/init_module.c +++ b/ltt/branches/poly/lttv/modules/gui/mainWin/src/init_module.c @@ -14,27 +14,41 @@ #include #include #include - +#include +#include +#include +#include +#include #include "interface.h" #include "support.h" #include #include "callbacks.h" +#include + /* global variable */ -systemView * gSysView; +static WindowCreationData win_creation_data; + +/** Array containing instanced objects. */ +GSList * g_main_window_list = NULL ; -typedef view_constructor (* constructor)(); -constructor get_constructor = NULL; -typedef void (*call_Event_Selected_Hook)(void * call_data); -call_Event_Selected_Hook selected_hook = NULL; -GModule *gm; -view_constructor gConstructor = NULL; +LttvHooks + *main_hooks; +/* Initial trace from command line */ +LttvTrace *g_init_trace = NULL; -static LttvHooks - *main_hooks; +static char *a_trace; +void lttv_trace_option(void *hook_data) +{ + LttTrace *trace; + + trace = ltt_trace_open(a_trace); + if(trace == NULL) g_critical("cannot open trace %s", a_trace); + g_init_trace = lttv_trace_new(trace); +} /***************************************************************************** * Functions for module loading/unloading * @@ -45,22 +59,11 @@ static LttvHooks * This function initializes the GUI. */ -typedef struct _WindowCreationData { - int argc; - char ** argv; -} WindowCreationData; - - -static gboolean Window_Creation_Hook(void *hook_data, void *call_data) +static gboolean window_creation_hook(void *hook_data, void *call_data) { - GModule *gm; - GtkWidget * ToolMenuTitle_menu, *insert_view; - GtkWidget *window1; - mainWindow * mw = g_new(mainWindow, 1); - gSysView = g_new(systemView, 1); - WindowCreationData *Window_Creation_Data = (WindowCreationData*)call_data; - - g_critical("GUI init()"); + WindowCreationData* window_creation_data = (WindowCreationData*)hook_data; + + g_critical("GUI window_creation_hook()"); #ifdef ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); @@ -68,87 +71,81 @@ static gboolean Window_Creation_Hook(void *hook_data, void *call_data) #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"); - /* - * The following code was added by Glade to create one of each component - * (except popup menus), just so that you see something after building - * the project. Delete any components that you don't want shown initially. - */ - window1 = create_MWindow (); - gtk_widget_show (window1); - - mw->MWindow = window1; - mw->SystemView = gSysView; - mw->Tab = NULL; - mw->CurrentTab = NULL; - // mw->Attributes = lttv_attributes_new(); - - //test - - gm = g_module_open("/home1/yangxx/poly/lttv/modules/libguiEvents.la",0); - printf("Main : the address of gm : %d\n", gm); - if(!g_module_symbol(gm, "get_constructor", (gpointer)&get_constructor)){ - g_error("can not get constructor\n"); - } - if(!g_module_symbol(gm, "call_Event_Selected_Hook", (gpointer)&selected_hook)){ - g_error("can not get selected hook\n"); - } - - gConstructor = get_constructor(); - ToolMenuTitle_menu = lookup_widget(mw->MWindow,"ToolMenuTitle_menu"); - insert_view = gtk_menu_item_new_with_mnemonic ("insert_view"); - gtk_widget_show (insert_view); - gtk_container_add (GTK_CONTAINER (ToolMenuTitle_menu), insert_view); - g_signal_connect ((gpointer) insert_view, "activate", - G_CALLBACK (insertViewTest), - NULL); - //end - - gSysView->EventDB = NULL; - gSysView->SystemInfo = NULL; - gSysView->Options = NULL; - gSysView->Window = mw; - gSysView->Next = NULL; - - g_object_set_data(G_OBJECT(window1), "systemView", (gpointer)gSysView); - g_object_set_data(G_OBJECT(window1), "mainWindow", (gpointer)mw); + construct_main_window(NULL, window_creation_data); gtk_main (); - return FALSE; + return FALSE; } - - - G_MODULE_EXPORT void init(LttvModule *self, int argc, char *argv[]) { - LttvAttributeValue value; - WindowCreationData *Window_Creation_Data = g_new(WindowCreationData, 1); - - LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes()); + LttvAttributeValue value; + + // Global attributes only used for interaction with main() here. + LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes()); + + g_critical("GUI init()"); + + lttv_option_add("trace", 't', + "add a trace to the trace set to analyse", + "pathname of the directory containing the trace", + LTTV_OPT_STRING, &a_trace, lttv_trace_option, NULL); + + g_assert(lttv_iattribute_find_by_path(attributes, "hooks/main/before", + LTTV_POINTER, &value)); + g_assert((main_hooks = *(value.v_pointer)) != NULL); + + win_creation_data.argc = argc; + win_creation_data.argv = argv; + + lttv_hooks_add(main_hooks, window_creation_hook, &win_creation_data); - Window_Creation_Data->argc = argc; - Window_Creation_Data->argv = argv; - - g_assert(lttv_iattribute_find_by_path( - attributes, - "hooks/main/before", LTTV_POINTER, &value)); - - g_assert((main_hooks = *(value.v_pointer)) != NULL); +} - lttv_hooks_add(main_hooks, Window_Creation_Hook, Window_Creation_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) +{ + 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 destroy_walk(gpointer data, gpointer user_data) + +void main_window_destroy_walk(gpointer data, gpointer user_data) { - //GuiControlFlow_Destructor((ControlFlowData*)data); + main_window_destructor((MainWindow*)data); } @@ -161,26 +158,20 @@ void destroy_walk(gpointer data, gpointer user_data) */ G_MODULE_EXPORT void destroy() { - WindowCreationData *Window_Creation_Data; - LttvAttributeValue value; - - g_critical("GUI destroy()"); - //int i; - - //ControlFlowData *Control_Flow_Data; - - - //g_slist_foreach(sControl_Flow_Data_List, destroy_walk, NULL ); - - lttv_iattribute_find_by_path(LTTV_IATTRIBUTE(lttv_global_attributes()), - "/hooks/main/before", LTTV_POINTER, &value); + LttvAttributeValue value; + LttvTrace *trace; - Window_Creation_Data = lttv_hooks_remove(*(value.v_pointer), - Window_Creation_Hook); + lttv_option_remove("trace"); - g_free(Window_Creation_Data); + lttv_hooks_remove_data(main_hooks, window_creation_hook, &win_creation_data); + g_critical("GUI destroy()"); + if(g_main_window_list){ + g_slist_foreach(g_main_window_list, main_window_destroy_walk, NULL ); + g_slist_free(g_main_window_list); + } + }