git-svn-id: http://ltt.polymtl.ca/svn@200 04897980-b3bd-0310-b5e0-8ef037075253
[lttv.git] / ltt / branches / poly / lttv / modules / gui / mainWin / src / init_module.c
CommitLineData
fb87279e 1/*
2 * Initial main.c file generated by Glade. Edit as required.
3 * Glade will not overwrite this file.
4 */
5
6#ifdef HAVE_CONFIG_H
7# include <config.h>
8#endif
9
10#include <gtk/gtk.h>
11
12#include <lttv/module.h>
13#include <lttv/hook.h>
14#include <lttv/lttv.h>
15
16
17#include "interface.h"
18#include "support.h"
19#include "mainWindow.h"
20#include "callbacks.h"
21
22/* global variable */
23systemView * gSysView;
24
25typedef view_constructor (* constructor)();
26constructor get_constructor = NULL;
27typedef void (*call_Event_Selected_Hook)(void * call_data);
28call_Event_Selected_Hook selected_hook = NULL;
29GModule *gm;
30view_constructor gConstructor = NULL;
31
32int Window_Creation_Hook(void *hook_data, void *call_data);
33
34/*****************************************************************************
35 * Functions for module loading/unloading *
36 *****************************************************************************/
37/**
38 * plugin's init function
39 *
40 * This function initializes the GUI.
41 */
42
43typedef struct _WindowCreationData {
44 int argc;
45 char ** argv;
46} WindowCreationData;
47
48G_MODULE_EXPORT void init(LttvModule *self, int argc, char *argv[]) {
49
50 LttvAttributeValue value;
51 WindowCreationData *Window_Creation_Data = g_new(WindowCreationData, 1);
52
53 Window_Creation_Data->argc = argc;
54 Window_Creation_Data->argv = argv;
55
56
57 lttv_iattribute_find_by_path(LTTV_IATTRIBUTE(lttv_global_attributes()),
58 "/hooks/main/before", LTTV_POINTER, &value);
59
60 lttv_hooks_add(*(value.v_pointer), Window_Creation_Hook, Window_Creation_Data);
61
62}
63
64int Window_Creation_Hook(void *hook_data, void *call_data)
65{
66 GModule *gm;
67 GtkWidget * ToolMenuTitle_menu, *insert_view;
68 GtkWidget *window1;
69 mainWindow * mw = g_new(mainWindow, 1);
70 gSysView = g_new(systemView, 1);
71 WindowCreationData *Window_Creation_Data = (WindowCreationData*)call_data;
72
73 g_critical("GUI init()");
74#ifdef ENABLE_NLS
75 bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
76 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
77 textdomain (GETTEXT_PACKAGE);
78#endif
79
80 gtk_set_locale ();
81 gtk_init (&(Window_Creation_Data->argc), &(Window_Creation_Data->argv));
82
83 add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps");
84 add_pixmap_directory ("pixmaps");
85
86 /*
87 * The following code was added by Glade to create one of each component
88 * (except popup menus), just so that you see something after building
89 * the project. Delete any components that you don't want shown initially.
90 */
91 window1 = create_MWindow ();
92 gtk_widget_show (window1);
93
94 mw->MWindow = window1;
95 mw->SystemView = gSysView;
96 mw->Tab = NULL;
97 mw->CurrentTab = NULL;
98 // mw->Attributes = lttv_attributes_new();
99
100 //test
101
102 gm = g_module_open("/home1/yangxx/poly/lttv/modules/libguiEvents.la",0);
103 printf("Main : the address of gm : %d\n", gm);
104 if(!g_module_symbol(gm, "get_constructor", (gpointer)&get_constructor)){
105 g_error("can not get constructor\n");
106 }
107 if(!g_module_symbol(gm, "call_Event_Selected_Hook", (gpointer)&selected_hook)){
108 g_error("can not get selected hook\n");
109 }
110
111 gConstructor = get_constructor();
112 ToolMenuTitle_menu = lookup_widget(mw->MWindow,"ToolMenuTitle_menu");
113 insert_view = gtk_menu_item_new_with_mnemonic ("insert_view");
114 gtk_widget_show (insert_view);
115 gtk_container_add (GTK_CONTAINER (ToolMenuTitle_menu), insert_view);
116 g_signal_connect ((gpointer) insert_view, "activate",
117 G_CALLBACK (insertViewTest),
118 NULL);
119 //end
120
121 gSysView->EventDB = NULL;
122 gSysView->SystemInfo = NULL;
123 gSysView->Options = NULL;
124 gSysView->Window = mw;
125 gSysView->Next = NULL;
126
127 g_object_set_data(G_OBJECT(window1), "systemView", (gpointer)gSysView);
128 g_object_set_data(G_OBJECT(window1), "mainWindow", (gpointer)mw);
129
130 gtk_main ();
131}
132
133void destroy_walk(gpointer data, gpointer user_data)
134{
135 //GuiControlFlow_Destructor((ControlFlowData*)data);
136}
137
138
139
140/**
141 * plugin's destroy function
142 *
143 * This function releases the memory reserved by the module and unregisters
144 * everything that has been registered in the gtkTraceSet API.
145 */
146G_MODULE_EXPORT void destroy() {
147
148 WindowCreationData *Window_Creation_Data;
149 LttvAttributeValue value;
150
151 g_critical("GUI destroy()");
152 //int i;
153
154 //ControlFlowData *Control_Flow_Data;
155
156
157 //g_slist_foreach(sControl_Flow_Data_List, destroy_walk, NULL );
158
159 lttv_iattribute_find_by_path(LTTV_IATTRIBUTE(lttv_global_attributes()),
160 "/hooks/main/before", LTTV_POINTER, &value);
161
162 Window_Creation_Data = lttv_hooks_remove(*(value.v_pointer),
163 Window_Creation_Hook);
164
165 g_free(Window_Creation_Data);
166
167
168}
169
170
171
172
This page took 0.028064 seconds and 4 git commands to generate.