Commit 5f503801c68909ecd4c993b8883ca66cc2306e8f
1 parent
94534245
Exists in
master
and in
5 other branches
Implementando suporte a scripts
Showing
3 changed files
with
29 additions
and
13 deletions
Show diff stats
src/pw3270/uiparser/parsefile.c
@@ -226,6 +226,7 @@ | @@ -226,6 +226,7 @@ | ||
226 | { | 226 | { |
227 | g_object_set_data(G_OBJECT(widget),"parent",info->element); | 227 | g_object_set_data(G_OBJECT(widget),"parent",info->element); |
228 | info->element = G_OBJECT(widget); | 228 | info->element = G_OBJECT(widget); |
229 | + info->action = action; | ||
229 | 230 | ||
230 | #if GTK_CHECK_VERSION(2,18,0) | 231 | #if GTK_CHECK_VERSION(2,18,0) |
231 | gtk_widget_set_visible(widget,ui_get_bool_attribute("visible",names,values,TRUE)); | 232 | gtk_widget_set_visible(widget,ui_get_bool_attribute("visible",names,values,TRUE)); |
@@ -237,12 +238,11 @@ | @@ -237,12 +238,11 @@ | ||
237 | #endif // GTK(2,18,0) | 238 | #endif // GTK(2,18,0) |
238 | 239 | ||
239 | } | 240 | } |
240 | -/* | ||
241 | else | 241 | else |
242 | { | 242 | { |
243 | - info->disabled++; | 243 | +// info->disabled++; |
244 | + info->action = NULL; | ||
244 | } | 245 | } |
245 | -*/ | ||
246 | } | 246 | } |
247 | 247 | ||
248 | static void element_end(GMarkupParseContext *context, const gchar *element_name, struct parser *info, GError **error) | 248 | static void element_end(GMarkupParseContext *context, const gchar *element_name, struct parser *info, GError **error) |
src/pw3270/uiparser/private.h
@@ -58,7 +58,7 @@ | @@ -58,7 +58,7 @@ | ||
58 | GtkWidget * toplevel; | 58 | GtkWidget * toplevel; |
59 | GObject * element; | 59 | GObject * element; |
60 | GtkAction * action; | 60 | GtkAction * action; |
61 | - GCallback callback; | 61 | +// GCallback callback; |
62 | GtkWidget * center_widget; | 62 | GtkWidget * center_widget; |
63 | GtkWidget ** popup; /**< Popup widgets */ | 63 | GtkWidget ** popup; /**< Popup widgets */ |
64 | GStringChunk * strings; | 64 | GStringChunk * strings; |
src/pw3270/uiparser/script.c
@@ -31,26 +31,42 @@ | @@ -31,26 +31,42 @@ | ||
31 | 31 | ||
32 | #include "private.h" | 32 | #include "private.h" |
33 | 33 | ||
34 | + #ifdef X3270_TRACE | ||
35 | + #define trace_action(a,w) lib3270_trace_event(NULL,"Action %s activated on widget %p\n",gtk_action_get_name(a),w); | ||
36 | + #else | ||
37 | + #define trace_action(a,w) /* */ | ||
38 | + #endif // X3270_TRACE | ||
39 | + | ||
34 | /*--[ Parser struct ]--------------------------------------------------------------------------------*/ | 40 | /*--[ Parser struct ]--------------------------------------------------------------------------------*/ |
35 | 41 | ||
36 | 42 | ||
37 | /*--[ Implement ]------------------------------------------------------------------------------------*/ | 43 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
38 | 44 | ||
39 | - static void element_start(GMarkupParseContext *context, const gchar *element_name, const gchar **names,const gchar **values, struct parser *info, GError **error) | 45 | + static void element_start(GMarkupParseContext *context, const gchar *element_name, const gchar **names,const gchar **values, GtkAction *action, GError **error) |
40 | { | 46 | { |
41 | trace("%s: %s",__FUNCTION__,element_name); | 47 | trace("%s: %s",__FUNCTION__,element_name); |
42 | } | 48 | } |
43 | 49 | ||
44 | - static void element_end(GMarkupParseContext *context, const gchar *element_name, struct parser *info, GError **error) | 50 | + static void element_end(GMarkupParseContext *context, const gchar *element_name, GtkAction *action, GError **error) |
45 | { | 51 | { |
46 | trace("%s: %s",__FUNCTION__,element_name); | 52 | trace("%s: %s",__FUNCTION__,element_name); |
47 | } | 53 | } |
48 | 54 | ||
49 | - static void script_text(GMarkupParseContext *context, const gchar *element_text, gsize text_len, GtkAction *action, GError **error) | 55 | + static void text_action(GtkAction *action, const gchar *text) |
56 | + { | ||
57 | + trace("Script:\n%s\n",text); | ||
58 | + } | ||
59 | + | ||
60 | + static void script_text(GMarkupParseContext *context, const gchar *element_text, gsize text_len, GtkAction *action, GError **error) | ||
50 | { | 61 | { |
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); | 62 | + gchar *base = g_strstrip(g_strdup(element_text)); |
63 | + gchar *text = g_strdup(base); | ||
64 | + g_free(base); | ||
65 | + | ||
66 | + gtk_action_set_sensitive(action,TRUE); | ||
67 | + g_object_set_data_full(G_OBJECT(action),"script_text",text,g_free); | ||
68 | + g_signal_connect(action,"activate",G_CALLBACK(text_action),text); | ||
69 | + | ||
54 | } | 70 | } |
55 | 71 | ||
56 | GObject * ui_create_script(GMarkupParseContext *context,GtkAction *action, struct parser *info, const gchar **names, const gchar **values, GError **error) | 72 | GObject * ui_create_script(GMarkupParseContext *context,GtkAction *action, struct parser *info, const gchar **names, const gchar **values, GError **error) |
@@ -77,15 +93,15 @@ | @@ -77,15 +93,15 @@ | ||
77 | 93 | ||
78 | trace("%s: info->element: %p action: %p",__FUNCTION__,info->element, action); | 94 | trace("%s: info->element: %p action: %p",__FUNCTION__,info->element, action); |
79 | 95 | ||
80 | - if(!info->element) | 96 | + if(!(info->element && info->actions)) |
81 | { | 97 | { |
82 | *error = g_error_new(ERROR_DOMAIN,EINVAL,_( "<%s> is invalid at this context"),"script"); | 98 | *error = g_error_new(ERROR_DOMAIN,EINVAL,_( "<%s> is invalid at this context"),"script"); |
83 | return NULL; | 99 | return NULL; |
84 | } | 100 | } |
85 | 101 | ||
86 | - trace("%s: Parsing script",__FUNCTION__); | 102 | + trace("%s: Parsing script for action %s",__FUNCTION__,gtk_action_get_name(info->action)); |
87 | 103 | ||
88 | - g_markup_parse_context_push(context,&parser,NULL); | 104 | + g_markup_parse_context_push(context,&parser,info->action); |
89 | 105 | ||
90 | return NULL; | 106 | return NULL; |
91 | } | 107 | } |