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