Commit 5be39e6a8d244daddff0cecace9ff52b2d1616ff

Authored by Perry Werneck
1 parent 2fba2bdc

Reimplementando keypads

src/pw3270/uiparser/button.c
@@ -84,7 +84,7 @@ @@ -84,7 +84,7 @@
84 GtkAction * action = NULL; 84 GtkAction * action = NULL;
85 85
86 if(label) { 86 if(label) {
87 - keypad->widget = gtk_button_new_with_label(label); 87 + keypad->widget = gtk_button_new_with_label(gettext(g_strcompress(label)));
88 } else { 88 } else {
89 gchar *text = g_strconcat("gtk-",icon,NULL); 89 gchar *text = g_strconcat("gtk-",icon,NULL);
90 keypad->widget = gtk_button_new(); 90 keypad->widget = gtk_button_new();
@@ -92,25 +92,6 @@ @@ -92,25 +92,6 @@
92 g_free(text); 92 g_free(text);
93 } 93 }
94 94
95 - /*  
96 - const gchar * label = ui_get_attribute("label", names, values);  
97 - const gchar * icon = ui_get_attribute("icon", names, values);  
98 - const gchar * name = ui_get_attribute("action", names, values);  
99 - GtkWidget * widget = NULL;  
100 -  
101 - if(label)  
102 - {  
103 - widget = gtk_button_new_with_label(gettext(g_strcompress(label)));  
104 - }  
105 - else if(icon)  
106 - {  
107 - gchar *text = g_strconcat("gtk-",icon,NULL);  
108 - widget = gtk_button_new();  
109 - gtk_container_add(GTK_CONTAINER(widget),gtk_image_new_from_stock(text,GTK_ICON_SIZE_SMALL_TOOLBAR));  
110 - g_free(text);  
111 - }  
112 -*/  
113 -  
114 #if GTK_CHECK_VERSION(2,18,0) 95 #if GTK_CHECK_VERSION(2,18,0)
115 gtk_widget_set_can_focus(keypad->widget,FALSE); 96 gtk_widget_set_can_focus(keypad->widget,FALSE);
116 gtk_widget_set_can_default(keypad->widget,FALSE); 97 gtk_widget_set_can_default(keypad->widget,FALSE);
src/pw3270/uiparser/keypad.c
@@ -28,11 +28,15 @@ @@ -28,11 +28,15 @@
28 */ 28 */
29 29
30 #include "keypad.h" 30 #include "keypad.h"
  31 + #include <stdlib.h>
31 32
32 /*--[ Implement ]------------------------------------------------------------------------------------*/ 33 /*--[ Implement ]------------------------------------------------------------------------------------*/
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 static void element_start(GMarkupParseContext *context, const gchar *element_name, const gchar **names,const gchar **values, struct keypad *keypad, GError **error)
35 { 36 {
  37 + int width = 1;
  38 + int height = 1;
  39 +
36 trace("%s(%s,%d,%d)",__FUNCTION__,element_name,(int) keypad->row, (int) keypad->col); 40 trace("%s(%s,%d,%d)",__FUNCTION__,element_name,(int) keypad->row, (int) keypad->col);
37 41
38 keypad->widget = NULL; 42 keypad->widget = NULL;
@@ -41,24 +45,45 @@ @@ -41,24 +45,45 @@
41 keypad_button_start(context, names, values, error, keypad); 45 keypad_button_start(context, names, values, error, keypad);
42 } 46 }
43 47
44 - }  
45 -  
46 - static void element_end(GMarkupParseContext *context, const gchar *element_name, struct keypad *keypad, GError **error)  
47 - {  
48 if(keypad->widget) { 48 if(keypad->widget) {
49 - gtk_grid_attach(keypad->grid,keypad->widget,keypad->col,keypad->row,1,1); 49 +
  50 + // Criou widget, incluir
  51 + const gchar * tmp;
  52 +
  53 + tmp = ui_get_attribute("width", names, values);
  54 + if(tmp) {
  55 + width = atoi(tmp);
  56 + }
  57 +
  58 + tmp = ui_get_attribute("height", names, values);
  59 + if(tmp) {
  60 + height = atoi(tmp);
  61 + }
  62 +
  63 + tmp = ui_get_attribute("column", names, values);
  64 + if(tmp) {
  65 + keypad->col = atoi(tmp);
  66 + }
  67 +
  68 + gtk_grid_attach(keypad->grid,keypad->widget,keypad->col,keypad->row,width,height);
50 keypad->widget = NULL; 69 keypad->widget = NULL;
  70 +
51 } 71 }
52 72
53 if(!strcasecmp(element_name,"row")) { 73 if(!strcasecmp(element_name,"row")) {
54 keypad->row++; 74 keypad->row++;
55 keypad->col = 0; 75 keypad->col = 0;
56 } else { 76 } else {
57 - keypad->col++; 77 + keypad->col += width;
58 } 78 }
59 79
60 } 80 }
61 81
  82 + static void element_end(GMarkupParseContext *context, const gchar *element_name, struct keypad *keypad, GError **error)
  83 + {
  84 +
  85 + }
  86 +
62 static void toggled(GtkToggleAction *action, GtkWidget *widget) 87 static void toggled(GtkToggleAction *action, GtkWidget *widget)
63 { 88 {
64 gboolean active = gtk_toggle_action_get_active(action); 89 gboolean active = gtk_toggle_action_get_active(action);
@@ -145,7 +170,7 @@ @@ -145,7 +170,7 @@
145 keypad->relief = ui_get_relief(names, values, GTK_RELIEF_NORMAL); 170 keypad->relief = ui_get_relief(names, values, GTK_RELIEF_NORMAL);
146 keypad->grid = GTK_GRID(gtk_grid_new()); 171 keypad->grid = GTK_GRID(gtk_grid_new());
147 172
148 - gtk_grid_set_row_homogeneous(keypad->grid,TRUE); 173 + // gtk_grid_set_row_homogeneous(keypad->grid,TRUE);
149 gtk_grid_set_column_homogeneous(keypad->grid,TRUE); 174 gtk_grid_set_column_homogeneous(keypad->grid,TRUE);
150 175
151 g_object_set_data(G_OBJECT(keypad->grid),"position",(gpointer) keypad->pos); 176 g_object_set_data(G_OBJECT(keypad->grid),"position",(gpointer) keypad->pos);
ui/10keypad.xml
@@ -34,64 +34,60 @@ @@ -34,64 +34,60 @@
34 <keypad name="keypad.right" label="Lateral keypad" position="right" key='<alt>k' relief='half' > 34 <keypad name="keypad.right" label="Lateral keypad" position="right" key='<alt>k' relief='half' >
35 35
36 <row> 36 <row>
37 - <button action='pfkey' id='1' label='PF1' />  
38 - <button action='pfkey' id='2' label='PF2' />  
39 - <button action='pfkey' id='3' label='PF3' /> 37 + <button action='pfkey' id='1' label='PF1' width='2'/>
  38 + <button action='pfkey' id='2' label='PF2' width='2' />
  39 + <button action='pfkey' id='3' label='PF3' width='2' />
40 </row> 40 </row>
41 <row> 41 <row>
42 - <button action='pfkey' id='4' label='PF4' />  
43 - <button action='pfkey' id='5' label='PF5' />  
44 - <button action='pfkey' id='6' label='PF6' /> 42 + <button action='pfkey' id='4' label='PF4' width='2' />
  43 + <button action='pfkey' id='5' label='PF5' width='2' />
  44 + <button action='pfkey' id='6' label='PF6' width='2' />
45 </row> 45 </row>
46 <row> 46 <row>
47 - <button action='pfkey' id='7' label='PF7' />  
48 - <button action='pfkey' id='8' label='PF8' />  
49 - <button action='pfkey' id='9' label='PF9' /> 47 + <button action='pfkey' id='7' label='PF7' width='2' />
  48 + <button action='pfkey' id='8' label='PF8' width='2' />
  49 + <button action='pfkey' id='9' label='PF9' width='2' />
50 </row> 50 </row>
51 <row> 51 <row>
52 - <button action='pfkey' id='10' label='PF10' />  
53 - <button action='pfkey' id='11' label='PF11' />  
54 - <button action='pfkey' id='12' label='PF12' /> 52 + <button action='pfkey' id='10' label='PF10' width='2' />
  53 + <button action='pfkey' id='11' label='PF11' width='2' />
  54 + <button action='pfkey' id='12' label='PF12' width='2' />
55 </row> 55 </row>
56 <row> 56 <row>
57 - <button />  
58 - <button action='move' target='cursor' direction='up' icon="go-up" />  
59 - <button /> 57 + <button action='move' target='cursor' direction='up' icon="go-up" column='2' width='2' />
60 </row> 58 </row>
61 <row> 59 <row>
62 - <button action='move' target='cursor' direction='left' icon="go-back" />  
63 - <button action="firstfield" icon="goto-top" />  
64 - <button action='move' target='cursor' direction='right' icon="go-forward" /> 60 + <button action='move' target='cursor' direction='left' icon="go-back" width='2' />
  61 + <button action="firstfield" icon="goto-top" width='2' />
  62 + <button action='move' target='cursor' direction='right' icon="go-forward" width='2' />
65 </row> 63 </row>
66 <row> 64 <row>
67 - <button />  
68 - <button action='move' target='cursor' direction='down' icon="go-down"/>  
69 - <button /> 65 + <button action='move' target='cursor' direction='down' icon="go-down" column='2' width='2'/>
70 </row> 66 </row>
71 <row> 67 <row>
72 - <button action='pakey' id='1' label='PA1' />  
73 - <button action='pakey' id='2' label='PA2' />  
74 - <button action='pakey' id='3' label='PA3' /> 68 + <button action='pakey' id='1' label='PA1' width='2' />
  69 + <button action='pakey' id='2' label='PA2' width='2' />
  70 + <button action='pakey' id='3' label='PA3' width='2' />
75 </row> 71 </row>
76 <row> 72 <row>
77 - <button action='PreviousField' icon="goto-first" />  
78 - <button action='NextField' icon="goto-last" /> 73 + <button action='PreviousField' icon="goto-first" width='3' />
  74 + <button action='NextField' icon="goto-last" width='3' />
79 </row> 75 </row>
80 <row> 76 <row>
81 - <button action='erase' target='all' label="Clear" />  
82 - <button action='kybdreset' label="Reset" /> 77 + <button action='erase' target='all' label="Clear" width='3' />
  78 + <button action='kybdreset' label="Reset" width='3' />
83 </row> 79 </row>
84 <row> 80 <row>
85 - <button action='EraseEOF' label="Erase\nEOF" />  
86 - <button action='EraseInput' label="Erase\nInput" /> 81 + <button action='EraseEOF' label="Erase\nEOF" width='3' />
  82 + <button action='EraseInput' label="Erase\nInput" width='3' />
87 </row> 83 </row>
88 <row> 84 <row>
89 - <button action='Attn' label="Attn" />  
90 - <button action='Break' label="Break" /> 85 + <button action='Attn' label="Attn" width='3' />
  86 + <button action='Break' label="Break" width='3' />
91 </row> 87 </row>
92 88
93 <row> 89 <row>
94 - <button action='Enter' icon="ok" /> 90 + <button action='Enter' icon="ok" width='6'/>
95 </row> 91 </row>
96 92
97 </keypad> 93 </keypad>