Commit dc7828e581b1dbe3e5d87ab18e554e94b7bbdc9f
1 parent
72bdaf33
Exists in
master
and in
5 other branches
Reimplementando keypads.
Showing
3 changed files
with
34 additions
and
13 deletions
Show diff stats
src/pw3270/uiparser/button.c
... | ... | @@ -77,6 +77,18 @@ |
77 | 77 | |
78 | 78 | void keypad_button_start(GMarkupParseContext *context, const gchar **names,const gchar **values, GError **error, struct keypad *keypad) |
79 | 79 | { |
80 | + const gchar * label = ui_get_attribute("label", names, values); | |
81 | + const gchar * icon = ui_get_attribute("icon", names, values); | |
82 | + | |
83 | + if(label) { | |
84 | + keypad->widget = gtk_button_new_with_label(label); | |
85 | + } else { | |
86 | + gchar *text = g_strconcat("gtk-",icon,NULL); | |
87 | + keypad->widget = gtk_button_new(); | |
88 | + gtk_container_add(GTK_CONTAINER(keypad->widget),gtk_image_new_from_stock(text,GTK_ICON_SIZE_SMALL_TOOLBAR)); | |
89 | + g_free(text); | |
90 | + } | |
91 | + | |
80 | 92 | /* |
81 | 93 | const gchar * label = ui_get_attribute("label", names, values); |
82 | 94 | const gchar * icon = ui_get_attribute("icon", names, values); |
... | ... | @@ -85,11 +97,6 @@ |
85 | 97 | GtkAction * action = NULL; |
86 | 98 | GtkWidget * widget = NULL; |
87 | 99 | |
88 | - if(++keypad->col > keypad->num_cols) | |
89 | - keypad->num_cols = keypad->col; | |
90 | - | |
91 | - keypad->row->num_cols++; | |
92 | - | |
93 | 100 | if(label) |
94 | 101 | { |
95 | 102 | widget = gtk_button_new_with_label(gettext(g_strcompress(label))); |
... | ... | @@ -102,11 +109,6 @@ |
102 | 109 | g_free(text); |
103 | 110 | } |
104 | 111 | |
105 | - keypad->row->cols = g_list_append(keypad->row->cols,widget); | |
106 | - | |
107 | - if(!widget) | |
108 | - return; | |
109 | - | |
110 | 112 | #if GTK_CHECK_VERSION(2,18,0) |
111 | 113 | gtk_widget_set_can_focus(widget,FALSE); |
112 | 114 | gtk_widget_set_can_default(widget,FALSE); |
... | ... | @@ -133,6 +135,6 @@ |
133 | 135 | gtk_widget_set_sensitive(widget,FALSE); |
134 | 136 | g_signal_connect(G_OBJECT(widget),"clicked",G_CALLBACK(button_script),info->center_widget); |
135 | 137 | } |
136 | - */ | |
138 | +*/ | |
137 | 139 | } |
138 | 140 | ... | ... |
src/pw3270/uiparser/keypad.c
... | ... | @@ -33,12 +33,30 @@ |
33 | 33 | |
34 | 34 | static void element_start(GMarkupParseContext *context, const gchar *element_name, const gchar **names,const gchar **values, struct keypad *keypad, GError **error) |
35 | 35 | { |
36 | - trace("%s(%s)",__FUNCTION__,element_name); | |
36 | + trace("%s(%s,%d,%d)",__FUNCTION__,element_name,(int) keypad->row, (int) keypad->col); | |
37 | + | |
38 | + keypad->widget = NULL; | |
39 | + | |
40 | + if(!strcasecmp(element_name,"button")) { | |
41 | + keypad_button_start(context, names, values, error, keypad); | |
42 | + } | |
43 | + | |
37 | 44 | } |
38 | 45 | |
39 | 46 | static void element_end(GMarkupParseContext *context, const gchar *element_name, struct keypad *keypad, GError **error) |
40 | 47 | { |
41 | - trace("%s(%s)",__FUNCTION__,element_name); | |
48 | + if(keypad->widget) { | |
49 | + gtk_grid_attach(keypad->grid,keypad->widget,keypad->col,keypad->row,1,1); | |
50 | + keypad->widget = NULL; | |
51 | + } | |
52 | + | |
53 | + if(!strcasecmp(element_name,"row")) { | |
54 | + keypad->row++; | |
55 | + keypad->col = 0; | |
56 | + } else { | |
57 | + keypad->col++; | |
58 | + } | |
59 | + | |
42 | 60 | } |
43 | 61 | |
44 | 62 | static void toggled(GtkToggleAction *action, GtkWidget *widget) | ... | ... |