Commit e22a9b57e6d3acdec8a4a46ff29f4bdd4394d9c3
1 parent
88e48ac9
Exists in
master
and in
5 other branches
Implementando a barra lateral
Showing
2 changed files
with
66 additions
and
7 deletions
Show diff stats
src/pw3270/uiparser/keypad.c
| @@ -50,12 +50,42 @@ | @@ -50,12 +50,42 @@ | ||
| 50 | GtkWidget * box; | 50 | GtkWidget * box; |
| 51 | GtkWidget * handle; | 51 | GtkWidget * handle; |
| 52 | GtkWidget * table; | 52 | GtkWidget * table; |
| 53 | + GtkReliefStyle relief; | ||
| 53 | UI_ATTR_DIRECTION pos; | 54 | UI_ATTR_DIRECTION pos; |
| 54 | GList * rows; | 55 | GList * rows; |
| 55 | }; | 56 | }; |
| 56 | 57 | ||
| 57 | /*--[ Implement ]------------------------------------------------------------------------------------*/ | 58 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
| 58 | 59 | ||
| 60 | + static GtkReliefStyle get_relief(const gchar **names, const gchar **values, GtkReliefStyle def) | ||
| 61 | + { | ||
| 62 | + | ||
| 63 | + const gchar *name = ui_get_attribute("relief",names,values); | ||
| 64 | + if(name) | ||
| 65 | + { | ||
| 66 | + static const struct _style | ||
| 67 | + { | ||
| 68 | + GtkReliefStyle val; | ||
| 69 | + const gchar * name; | ||
| 70 | + } style[] = | ||
| 71 | + { | ||
| 72 | + { GTK_RELIEF_NORMAL, "normal" }, | ||
| 73 | + { GTK_RELIEF_HALF, "half" }, | ||
| 74 | + { GTK_RELIEF_NONE, "none" } | ||
| 75 | + }; | ||
| 76 | + | ||
| 77 | + int f; | ||
| 78 | + | ||
| 79 | + for(f=0;f<G_N_ELEMENTS(style);f++) | ||
| 80 | + { | ||
| 81 | + if(!g_strcasecmp(style[f].name,name)) | ||
| 82 | + return style[f].val; | ||
| 83 | + } | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + return def; | ||
| 87 | + } | ||
| 88 | + | ||
| 59 | static void row_start(struct keypad *keypad, const gchar **names,const gchar **values, GError **error) | 89 | static void row_start(struct keypad *keypad, const gchar **names,const gchar **values, GError **error) |
| 60 | { | 90 | { |
| 61 | keypad->row = g_malloc0(sizeof(struct row)); | 91 | keypad->row = g_malloc0(sizeof(struct row)); |
| @@ -66,11 +96,19 @@ | @@ -66,11 +96,19 @@ | ||
| 66 | keypad->rows = g_list_append(keypad->rows,keypad->row); | 96 | keypad->rows = g_list_append(keypad->rows,keypad->row); |
| 67 | } | 97 | } |
| 68 | 98 | ||
| 99 | + static void button_clicked(GtkButton *button, GtkAction *action) | ||
| 100 | + { | ||
| 101 | + gtk_action_activate(action); | ||
| 102 | + } | ||
| 103 | + | ||
| 69 | static void button_start(struct keypad *keypad, const gchar **names,const gchar **values, GError **error) | 104 | static void button_start(struct keypad *keypad, const gchar **names,const gchar **values, GError **error) |
| 70 | { | 105 | { |
| 71 | - const gchar *label = ui_get_attribute("label", names, values); | ||
| 72 | - const gchar *icon = ui_get_attribute("icon", names, values); | ||
| 73 | - GtkWidget *widget = NULL; | 106 | + const gchar * label = ui_get_attribute("label", names, values); |
| 107 | + const gchar * icon = ui_get_attribute("icon", names, values); | ||
| 108 | + const gchar * name = ui_get_attribute("action", names, values); | ||
| 109 | + struct parser * info = keypad->parser; | ||
| 110 | + GtkAction * action; | ||
| 111 | + GtkWidget * widget = NULL; | ||
| 74 | 112 | ||
| 75 | if(++keypad->col > keypad->num_cols) | 113 | if(++keypad->col > keypad->num_cols) |
| 76 | keypad->num_cols = keypad->col; | 114 | keypad->num_cols = keypad->col; |
| @@ -102,8 +140,28 @@ | @@ -102,8 +140,28 @@ | ||
| 102 | GTK_WIDGET_UNSET_FLAGS(widget,GTK_CAN_DEFAULT); | 140 | GTK_WIDGET_UNSET_FLAGS(widget,GTK_CAN_DEFAULT); |
| 103 | #endif // GTK(2,18) | 141 | #endif // GTK(2,18) |
| 104 | 142 | ||
| 105 | - gtk_widget_set_sensitive(widget,FALSE); | 143 | + if(!name) |
| 144 | + { | ||
| 145 | + // Invalid unnamed element | ||
| 146 | + *error = g_error_new(ERROR_DOMAIN,EINVAL,_( "Can't accept unnamed %s"),"button"); | ||
| 147 | + return; | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + gtk_button_set_relief(GTK_BUTTON(widget),get_relief(names, values, keypad->relief)); | ||
| 151 | + gtk_button_set_alignment(GTK_BUTTON(widget),0.5,0.5); | ||
| 152 | + gtk_button_set_focus_on_click(GTK_BUTTON(widget),FALSE); | ||
| 153 | + | ||
| 154 | + action = ui_get_action(info->center_widget,name,info->actions,names,values,error); | ||
| 106 | 155 | ||
| 156 | + if(action) | ||
| 157 | + { | ||
| 158 | + ui_action_set_options(action,info,names,values,error); | ||
| 159 | + g_signal_connect(G_OBJECT(widget),"clicked",G_CALLBACK(button_clicked),action); | ||
| 160 | + } | ||
| 161 | + else | ||
| 162 | + { | ||
| 163 | + gtk_widget_set_sensitive(widget,FALSE); | ||
| 164 | + } | ||
| 107 | } | 165 | } |
| 108 | 166 | ||
| 109 | static void element_start(GMarkupParseContext *context, const gchar *element_name, const gchar **names,const gchar **values, struct keypad *keypad, GError **error) | 167 | static void element_start(GMarkupParseContext *context, const gchar *element_name, const gchar **names,const gchar **values, struct keypad *keypad, GError **error) |
| @@ -187,6 +245,7 @@ | @@ -187,6 +245,7 @@ | ||
| 187 | keypad->parser = info; | 245 | keypad->parser = info; |
| 188 | keypad->handle = gtk_handle_box_new(); | 246 | keypad->handle = gtk_handle_box_new(); |
| 189 | keypad->pos = ui_get_dir_attribute(names,values); | 247 | keypad->pos = ui_get_dir_attribute(names,values); |
| 248 | + keypad->relief = get_relief(names, values, GTK_RELIEF_NORMAL); | ||
| 190 | 249 | ||
| 191 | switch(keypad->pos) | 250 | switch(keypad->pos) |
| 192 | { | 251 | { |
ui/10keypad.xml
| @@ -30,7 +30,7 @@ | @@ -30,7 +30,7 @@ | ||
| 30 | 30 | ||
| 31 | <ui> | 31 | <ui> |
| 32 | 32 | ||
| 33 | - <keypad name="keypad.right" label="Lateral keypad" position="right" key='<alt>k' > | 33 | + <keypad name="keypad.right" label="Lateral keypad" position="right" key='<alt>k' relief='half' > |
| 34 | 34 | ||
| 35 | <row> | 35 | <row> |
| 36 | <button action='pfkey' id='1' label='PF1' /> | 36 | <button action='pfkey' id='1' label='PF1' /> |
| @@ -77,8 +77,8 @@ | @@ -77,8 +77,8 @@ | ||
| 77 | <button action='NextField' icon="goto-last" /> | 77 | <button action='NextField' icon="goto-last" /> |
| 78 | </row> | 78 | </row> |
| 79 | <row> | 79 | <row> |
| 80 | - <button action='Erase' label="Clear" /> | ||
| 81 | - <button action='Reset' label="Reset" /> | 80 | + <button action='erase' target='all' label="Clear" /> |
| 81 | + <button action='kybdreset' label="Reset" /> | ||
| 82 | </row> | 82 | </row> |
| 83 | <row> | 83 | <row> |
| 84 | <button action='EraseEOF' label="Erase\nEOF" /> | 84 | <button action='EraseEOF' label="Erase\nEOF" /> |