Commit 94534245f0759d523a81dedfe43eb1b1fbe4d949
1 parent
88883384
Exists in
master
and in
5 other branches
Incluindo suporte para tag "script"
Showing
11 changed files
with
95 additions
and
44 deletions
Show diff stats
src/pw3270/uiparser/accelerator.c
... | ... | @@ -34,7 +34,7 @@ |
34 | 34 | |
35 | 35 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
36 | 36 | |
37 | - GObject * ui_create_accelerator(GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error) | |
37 | + GObject * ui_create_accelerator(GMarkupParseContext *context,GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error) | |
38 | 38 | { |
39 | 39 | if(info->element) |
40 | 40 | { |
... | ... | @@ -51,6 +51,6 @@ |
51 | 51 | return NULL; |
52 | 52 | } |
53 | 53 | |
54 | - void ui_end_accelerator(GObject *widget,struct parser *info,GError **error) | |
54 | + void ui_end_accelerator(GMarkupParseContext *context,GObject *widget,struct parser *info,GError **error) | |
55 | 55 | { |
56 | 56 | } | ... | ... |
src/pw3270/uiparser/menu.c
... | ... | @@ -33,7 +33,7 @@ |
33 | 33 | |
34 | 34 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
35 | 35 | |
36 | - GObject * ui_create_menu(GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error) | |
36 | + GObject * ui_create_menu(GMarkupParseContext *context,GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error) | |
37 | 37 | { |
38 | 38 | GtkWidget * widget; |
39 | 39 | GtkWidget * menu = GTK_WIDGET(info->element); |
... | ... | @@ -77,6 +77,6 @@ |
77 | 77 | return ui_insert_element(info, action, UI_ELEMENT_MENU, names, values, G_OBJECT(widget), error); |
78 | 78 | } |
79 | 79 | |
80 | - void ui_end_menu(GObject *widget,struct parser *info,GError **error) | |
80 | + void ui_end_menu(GMarkupParseContext *context,GObject *widget,struct parser *info,GError **error) | |
81 | 81 | { |
82 | 82 | } | ... | ... |
src/pw3270/uiparser/menubar.c
... | ... | @@ -33,7 +33,7 @@ |
33 | 33 | |
34 | 34 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
35 | 35 | |
36 | - GObject * ui_create_menubar(GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error) | |
36 | + GObject * ui_create_menubar(GMarkupParseContext *context,GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error) | |
37 | 37 | { |
38 | 38 | if(info->element) |
39 | 39 | { |
... | ... | @@ -50,6 +50,6 @@ |
50 | 50 | return ui_insert_element(info, action, UI_ELEMENT_MENUBAR, names, values, G_OBJECT(gtk_menu_bar_new()),error); |
51 | 51 | } |
52 | 52 | |
53 | - void ui_end_menubar(GObject *widget,struct parser *info,GError **error) | |
53 | + void ui_end_menubar(GMarkupParseContext *context,GObject *widget,struct parser *info,GError **error) | |
54 | 54 | { |
55 | 55 | } | ... | ... |
src/pw3270/uiparser/menuitem.c
... | ... | @@ -33,7 +33,7 @@ |
33 | 33 | |
34 | 34 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
35 | 35 | |
36 | - GObject * ui_create_menuitem(GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error) | |
36 | + GObject * ui_create_menuitem(GMarkupParseContext *context,GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error) | |
37 | 37 | { |
38 | 38 | GtkWidget * widget = NULL; |
39 | 39 | GtkWidget * menu = GTK_WIDGET(info->element); |
... | ... | @@ -111,7 +111,7 @@ |
111 | 111 | return G_OBJECT(widget); |
112 | 112 | } |
113 | 113 | |
114 | - void ui_end_menuitem(GObject *widget,struct parser *info,GError **error) | |
114 | + void ui_end_menuitem(GMarkupParseContext *context,GObject *widget,struct parser *info,GError **error) | |
115 | 115 | { |
116 | 116 | } |
117 | 117 | ... | ... |
src/pw3270/uiparser/parsefile.c
... | ... | @@ -38,8 +38,8 @@ |
38 | 38 | { |
39 | 39 | const gchar * name; |
40 | 40 | enum ui_element id; |
41 | - GObject * (*create)(GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error); | |
42 | - void (*end)(GObject *widget,struct parser *info,GError **error); | |
41 | + GObject * (*create)(GMarkupParseContext *context,GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error); | |
42 | + void (*end)(GMarkupParseContext *context,GObject *widget,struct parser *info,GError **error); | |
43 | 43 | } element_builder[] = |
44 | 44 | { |
45 | 45 | { "menubar", UI_ELEMENT_MENUBAR, ui_create_menubar, ui_end_menubar }, |
... | ... | @@ -168,12 +168,14 @@ |
168 | 168 | GtkWidget * widget = NULL; |
169 | 169 | int f; |
170 | 170 | |
171 | +/* | |
171 | 172 | if(info->disabled) |
172 | 173 | { |
173 | 174 | info->disabled++; |
174 | 175 | trace("%s: <%s> disabled=%d",__FUNCTION__,element_name,info->disabled); |
175 | 176 | return; |
176 | 177 | } |
178 | +*/ | |
177 | 179 | |
178 | 180 | for(f=0;f<G_N_ELEMENTS(element_builder);f++) |
179 | 181 | { |
... | ... | @@ -218,7 +220,7 @@ |
218 | 220 | } |
219 | 221 | |
220 | 222 | if(!widget) |
221 | - widget = GTK_WIDGET(element_builder[id].create(action,info,names,values,error)); | |
223 | + widget = GTK_WIDGET(element_builder[id].create(context,action,info,names,values,error)); | |
222 | 224 | |
223 | 225 | if(widget) |
224 | 226 | { |
... | ... | @@ -235,10 +237,12 @@ |
235 | 237 | #endif // GTK(2,18,0) |
236 | 238 | |
237 | 239 | } |
240 | +/* | |
238 | 241 | else |
239 | 242 | { |
240 | 243 | info->disabled++; |
241 | 244 | } |
245 | +*/ | |
242 | 246 | } |
243 | 247 | |
244 | 248 | static void element_end(GMarkupParseContext *context, const gchar *element_name, struct parser *info, GError **error) |
... | ... | @@ -246,18 +250,20 @@ |
246 | 250 | GtkWidget *widget = GTK_WIDGET(info->element); |
247 | 251 | int f; |
248 | 252 | |
253 | +/* | |
249 | 254 | if(info->disabled) |
250 | 255 | { |
251 | 256 | info->disabled--; |
252 | 257 | // trace("%s: <%s> disabled=%d",__FUNCTION__,element_name,info->disabled); |
253 | 258 | return; |
254 | 259 | } |
260 | +*/ | |
255 | 261 | |
256 | 262 | for(f=0;f<G_N_ELEMENTS(element_builder);f++) |
257 | 263 | { |
258 | 264 | if(!g_ascii_strcasecmp(element_name,element_builder[f].name)) |
259 | 265 | { |
260 | - element_builder[f].end(info->element,info,error); | |
266 | + element_builder[f].end(context,info->element,info,error); | |
261 | 267 | break; |
262 | 268 | } |
263 | 269 | } |
... | ... | @@ -353,7 +359,7 @@ |
353 | 359 | g_free(text); |
354 | 360 | |
355 | 361 | // trace("%s exits with rc=%d",__FUNCTION__,rc); |
356 | - info->disabled = 0; | |
362 | +// info->disabled = 0; | |
357 | 363 | if(info->element) |
358 | 364 | { |
359 | 365 | g_object_set_data(G_OBJECT(info->element),"parent",NULL); | ... | ... |
src/pw3270/uiparser/popup.c
... | ... | @@ -33,7 +33,7 @@ |
33 | 33 | |
34 | 34 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
35 | 35 | |
36 | - GObject * ui_create_popup(GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error) | |
36 | + GObject * ui_create_popup(GMarkupParseContext *context,GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error) | |
37 | 37 | { |
38 | 38 | GtkWidget * widget = NULL; |
39 | 39 | const gchar * id; |
... | ... | @@ -93,7 +93,7 @@ |
93 | 93 | return G_OBJECT(ui_insert_element(info, action, UI_ELEMENT_POPUP, names, values, G_OBJECT(widget), error)); |
94 | 94 | } |
95 | 95 | |
96 | - void ui_end_popup(GObject *widget,struct parser *info,GError **error) | |
96 | + void ui_end_popup(GMarkupParseContext *context,GObject *widget,struct parser *info,GError **error) | |
97 | 97 | { |
98 | 98 | |
99 | 99 | } | ... | ... |
src/pw3270/uiparser/private.h
... | ... | @@ -54,9 +54,11 @@ |
54 | 54 | |
55 | 55 | struct parser |
56 | 56 | { |
57 | - int disabled; | |
57 | +// int disabled; | |
58 | 58 | GtkWidget * toplevel; |
59 | 59 | GObject * element; |
60 | + GtkAction * action; | |
61 | + GCallback callback; | |
60 | 62 | GtkWidget * center_widget; |
61 | 63 | GtkWidget ** popup; /**< Popup widgets */ |
62 | 64 | GStringChunk * strings; |
... | ... | @@ -73,24 +75,24 @@ |
73 | 75 | GObject * ui_get_element(struct parser *info, GtkAction *action, enum ui_element id, const gchar **names, const gchar **values, GError **error); |
74 | 76 | GObject * ui_insert_element(struct parser *info, GtkAction *action, enum ui_element id, const gchar **names, const gchar **values, GObject *widget, GError **error); |
75 | 77 | |
76 | - GObject * ui_create_menubar(GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error); | |
77 | - GObject * ui_create_menu(GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error); | |
78 | - GObject * ui_create_menuitem(GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error); | |
79 | - GObject * ui_create_toolbar(GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error); | |
80 | - GObject * ui_create_toolitem(GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error); | |
81 | - GObject * ui_create_separator(GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error); | |
82 | - GObject * ui_create_accelerator(GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error); | |
83 | - GObject * ui_create_popup(GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error); | |
84 | - GObject * ui_create_script(GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error); | |
78 | + GObject * ui_create_menubar(GMarkupParseContext *context,GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error); | |
79 | + GObject * ui_create_menu(GMarkupParseContext *context,GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error); | |
80 | + GObject * ui_create_menuitem(GMarkupParseContext *context,GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error); | |
81 | + GObject * ui_create_toolbar(GMarkupParseContext *context,GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error); | |
82 | + GObject * ui_create_toolitem(GMarkupParseContext *context,GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error); | |
83 | + GObject * ui_create_separator(GMarkupParseContext *context,GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error); | |
84 | + GObject * ui_create_accelerator(GMarkupParseContext *context,GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error); | |
85 | + GObject * ui_create_popup(GMarkupParseContext *context,GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error); | |
86 | + GObject * ui_create_script(GMarkupParseContext *context,GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error); | |
85 | 87 | |
86 | - void ui_end_menubar(GObject *widget,struct parser *info,GError **error); | |
87 | - void ui_end_menu(GObject *widget,struct parser *info,GError **error); | |
88 | - void ui_end_menuitem(GObject *widget,struct parser *info,GError **error); | |
89 | - void ui_end_toolbar(GObject *widget,struct parser *info,GError **error); | |
90 | - void ui_end_toolitem(GObject *widget,struct parser *info,GError **error); | |
91 | - void ui_end_separator(GObject *widget,struct parser *info,GError **error); | |
92 | - void ui_end_accelerator(GObject *widget,struct parser *info,GError **error); | |
93 | - void ui_end_popup(GObject *widget,struct parser *info,GError **error); | |
94 | - void ui_end_script(GObject *widget,struct parser *info,GError **error); | |
88 | + void ui_end_menubar(GMarkupParseContext *context,GObject *widget,struct parser *info,GError **error); | |
89 | + void ui_end_menu(GMarkupParseContext *context,GObject *widget,struct parser *info,GError **error); | |
90 | + void ui_end_menuitem(GMarkupParseContext *context,GObject *widget,struct parser *info,GError **error); | |
91 | + void ui_end_toolbar(GMarkupParseContext *context,GObject *widget,struct parser *info,GError **error); | |
92 | + void ui_end_toolitem(GMarkupParseContext *context,GObject *widget,struct parser *info,GError **error); | |
93 | + void ui_end_separator(GMarkupParseContext *context,GObject *widget,struct parser *info,GError **error); | |
94 | + void ui_end_accelerator(GMarkupParseContext *context,GObject *widget,struct parser *info,GError **error); | |
95 | + void ui_end_popup(GMarkupParseContext *context,GObject *widget,struct parser *info,GError **error); | |
96 | + void ui_end_script(GMarkupParseContext *context,GObject *widget,struct parser *info,GError **error); | |
95 | 97 | |
96 | 98 | #include "parser.h" | ... | ... |
src/pw3270/uiparser/script.c
... | ... | @@ -36,19 +36,62 @@ |
36 | 36 | |
37 | 37 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
38 | 38 | |
39 | - GObject * ui_create_script(GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error) | |
39 | + static void element_start(GMarkupParseContext *context, const gchar *element_name, const gchar **names,const gchar **values, struct parser *info, GError **error) | |
40 | 40 | { |
41 | - if(!(info->element && action)) | |
41 | + trace("%s: %s",__FUNCTION__,element_name); | |
42 | + } | |
43 | + | |
44 | + static void element_end(GMarkupParseContext *context, const gchar *element_name, struct parser *info, GError **error) | |
45 | + { | |
46 | + trace("%s: %s",__FUNCTION__,element_name); | |
47 | + } | |
48 | + | |
49 | + static void script_text(GMarkupParseContext *context, const gchar *element_text, gsize text_len, GtkAction *action, GError **error) | |
50 | + { | |
51 | + gchar *text = g_strstrip(g_strdup(element_text)); | |
52 | + g_object_set_data_full(G_OBJECT(action),"script_text",g_strdup(text),g_free); | |
53 | + g_free(text); | |
54 | + } | |
55 | + | |
56 | + GObject * ui_create_script(GMarkupParseContext *context,GtkAction *action, struct parser *info, const gchar **names, const gchar **values, GError **error) | |
57 | + { | |
58 | + static const GMarkupParser parser = | |
59 | + { | |
60 | + (void (*)(GMarkupParseContext *, const gchar *, const gchar **, const gchar **, gpointer, GError **)) | |
61 | + element_start, | |
62 | + (void (*)(GMarkupParseContext *, const gchar *, gpointer, GError **)) | |
63 | + element_end, | |
64 | + (void (*)(GMarkupParseContext *, const gchar *, gsize, gpointer, GError **)) | |
65 | + script_text, | |
66 | + | |
67 | +// (void (*)(GMarkupParseContext *, GError *, gpointer)) | |
68 | + NULL | |
69 | + | |
70 | + }; | |
71 | + | |
72 | + if(action) | |
73 | + { | |
74 | + *error = g_error_new(ERROR_DOMAIN,EINVAL,_( "action attribute is invalid for <%s>"),"script"); | |
75 | + return NULL; | |
76 | + } | |
77 | + | |
78 | + trace("%s: info->element: %p action: %p",__FUNCTION__,info->element, action); | |
79 | + | |
80 | + if(!info->element) | |
42 | 81 | { |
43 | 82 | *error = g_error_new(ERROR_DOMAIN,EINVAL,_( "<%s> is invalid at this context"),"script"); |
44 | 83 | return NULL; |
45 | 84 | } |
46 | 85 | |
86 | + trace("%s: Parsing script",__FUNCTION__); | |
87 | + | |
88 | + g_markup_parse_context_push(context,&parser,NULL); | |
89 | + | |
47 | 90 | return NULL; |
48 | 91 | } |
49 | 92 | |
50 | - void ui_end_script(GObject *widget,struct parser *info,GError **error) | |
93 | + void ui_end_script(GMarkupParseContext *context,GObject *widget,struct parser *info,GError **error) | |
51 | 94 | { |
52 | - | |
95 | + g_markup_parse_context_pop(context); | |
53 | 96 | } |
54 | 97 | ... | ... |
src/pw3270/uiparser/separator.c
... | ... | @@ -33,7 +33,7 @@ |
33 | 33 | |
34 | 34 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
35 | 35 | |
36 | - GObject * ui_create_separator(GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error) | |
36 | + GObject * ui_create_separator(GMarkupParseContext *context,GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error) | |
37 | 37 | { |
38 | 38 | GtkWidget *widget = NULL; |
39 | 39 | |
... | ... | @@ -99,7 +99,7 @@ |
99 | 99 | return G_OBJECT(widget); |
100 | 100 | } |
101 | 101 | |
102 | - void ui_end_separator(GObject *widget,struct parser *info,GError **error) | |
102 | + void ui_end_separator(GMarkupParseContext *context,GObject *widget,struct parser *info,GError **error) | |
103 | 103 | { |
104 | 104 | } |
105 | 105 | ... | ... |
src/pw3270/uiparser/toolbar.c
... | ... | @@ -48,7 +48,7 @@ |
48 | 48 | |
49 | 49 | } |
50 | 50 | |
51 | - GObject * ui_create_toolbar(GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error) | |
51 | + GObject * ui_create_toolbar(GMarkupParseContext *context,GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error) | |
52 | 52 | { |
53 | 53 | GtkWidget * widget = NULL; |
54 | 54 | |
... | ... | @@ -90,6 +90,6 @@ |
90 | 90 | |
91 | 91 | } |
92 | 92 | |
93 | - void ui_end_toolbar(GObject *widget,struct parser *info,GError **error) | |
93 | + void ui_end_toolbar(GMarkupParseContext *context,GObject *widget,struct parser *info,GError **error) | |
94 | 94 | { |
95 | 95 | } | ... | ... |
src/pw3270/uiparser/toolitem.c
... | ... | @@ -33,7 +33,7 @@ |
33 | 33 | |
34 | 34 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
35 | 35 | |
36 | - GObject * ui_create_toolitem(GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error) | |
36 | + GObject * ui_create_toolitem(GMarkupParseContext *context,GtkAction *action,struct parser *info,const gchar **names, const gchar **values, GError **error) | |
37 | 37 | { |
38 | 38 | GtkWidget *widget = NULL; |
39 | 39 | |
... | ... | @@ -74,7 +74,7 @@ |
74 | 74 | return G_OBJECT(ui_insert_element(info, action, UI_ELEMENT_TOOLITEM, names, values, G_OBJECT(widget), error)); |
75 | 75 | } |
76 | 76 | |
77 | - void ui_end_toolitem(GObject *widget,struct parser *info,GError **error) | |
77 | + void ui_end_toolitem(GMarkupParseContext *context,GObject *widget,struct parser *info,GError **error) | |
78 | 78 | { |
79 | 79 | } |
80 | 80 | ... | ... |