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