Commit 1ae4cd71e10761e19c7e35b66f7d808815a4bad2
1 parent
bccf6df4
Exists in
master
and in
5 other branches
Implementando movimentação da caixa de seleção
Showing
4 changed files
with
59 additions
and
10 deletions
Show diff stats
src/gtk/actions.c
... | ... | @@ -177,9 +177,56 @@ void ui_connect_toggle(GtkAction *action, GtkWidget *widget, const gchar *name, |
177 | 177 | gtk_action_set_sensitive(action,FALSE); |
178 | 178 | } |
179 | 179 | |
180 | +static void selection_move_action(GtkAction *action, GtkWidget *widget) | |
181 | +{ | |
182 | + trace("Action %s activated on widget %p dir=%d",gtk_action_get_name(action),widget,g_object_get_data(G_OBJECT(action),"direction")); | |
183 | + lib3270_move_selection(GTK_V3270(widget)->host,(LIB3270_DIRECTION) g_object_get_data(G_OBJECT(action),"direction")); | |
184 | +} | |
185 | + | |
180 | 186 | void ui_connect_target_action(GtkAction *action, GtkWidget *widget, const gchar *target, const gchar *direction, GError **error) |
181 | 187 | { |
182 | - #warning TODO: Implementar | |
188 | + static const gchar *dirname[] = { "up", "down", "left", "right" }; | |
189 | + | |
190 | + LIB3270_DIRECTION dir = (LIB3270_DIRECTION) -1; | |
191 | + int f; | |
192 | + | |
193 | + if(!(direction && target)) | |
194 | + { | |
195 | + gtk_action_set_sensitive(action,FALSE); | |
196 | + return; | |
197 | + } | |
198 | + | |
199 | + for(f=0;f<G_N_ELEMENTS(dirname) && dir == -1;f++) | |
200 | + { | |
201 | + if(!g_strcasecmp(direction,dirname[f])) | |
202 | + { | |
203 | + dir = f; | |
204 | + break; | |
205 | + } | |
206 | + } | |
207 | + | |
208 | + if(dir == -1) | |
209 | + { | |
210 | + *error = g_error_new( g_quark_from_static_string(PACKAGE_NAME), | |
211 | + ENOENT, | |
212 | + _( "Unexpected direction \"%s\""), | |
213 | + direction); | |
214 | + } | |
215 | + | |
216 | + if(!g_strcasecmp(target,"selection")) | |
217 | + { | |
218 | + g_object_set_data(G_OBJECT(action),"direction",(gpointer) dir); | |
219 | + g_signal_connect(action,"activate",G_CALLBACK(selection_move_action),widget); | |
220 | + | |
221 | + } | |
222 | + else | |
223 | + { | |
224 | + *error = g_error_new( g_quark_from_static_string(PACKAGE_NAME), | |
225 | + ENOENT, | |
226 | + _( "Unexpected target \"%s\""), | |
227 | + target); | |
228 | + } | |
229 | + | |
183 | 230 | } |
184 | 231 | |
185 | 232 | static void action_pfkey(GtkAction *action, GtkWidget *widget) | ... | ... |
src/gtk/uiparser/parsefile.c
... | ... | @@ -155,8 +155,8 @@ |
155 | 155 | } |
156 | 156 | else if(!g_strcasecmp(name,"move")) |
157 | 157 | { |
158 | - const gchar *target = ui_get_attribute("target",names,values); | |
159 | - const gchar *direction = ui_get_attribute("direction",names,values); | |
158 | + target = ui_get_attribute("target",names,values); | |
159 | + direction = ui_get_attribute("direction",names,values); | |
160 | 160 | |
161 | 161 | if(!(target && direction)) |
162 | 162 | { |
... | ... | @@ -214,10 +214,10 @@ |
214 | 214 | |
215 | 215 | if(ix >= 0) |
216 | 216 | ui_connect_index_action(info->action[ix] = action,info->center_widget,ix,info->action); |
217 | - else if(g_strcasecmp(name,"quit")) | |
218 | - connect(action,info->center_widget,name,id); | |
219 | 217 | else if(target) |
220 | 218 | ui_connect_target_action(action,info->center_widget,target,direction,error); |
219 | + else if(g_strcasecmp(name,"quit")) | |
220 | + connect(action,info->center_widget,name,id); | |
221 | 221 | else |
222 | 222 | g_signal_connect(action,"activate",G_CALLBACK(gtk_main_quit), NULL); |
223 | 223 | ... | ... |
src/lib3270/selection.c
... | ... | @@ -376,7 +376,7 @@ LIB3270_EXPORT int lib3270_move_selection(H3270 *hSession, LIB3270_DIRECTION dir |
376 | 376 | break; |
377 | 377 | |
378 | 378 | case LIB3270_DIR_RIGHT: |
379 | - if( (hSession->select.end % hSession->cols) >= hSession->cols) | |
379 | + if( (hSession->select.end % hSession->cols) >= (hSession->cols-1)) | |
380 | 380 | return EINVAL; |
381 | 381 | hSession->select.begin++; |
382 | 382 | hSession->select.end++; |
... | ... | @@ -387,5 +387,7 @@ LIB3270_EXPORT int lib3270_move_selection(H3270 *hSession, LIB3270_DIRECTION dir |
387 | 387 | } |
388 | 388 | |
389 | 389 | update_selection(hSession); |
390 | + lib3270_set_cursor_address(hSession,hSession->select.end); | |
391 | + | |
390 | 392 | return 0; |
391 | 393 | } | ... | ... |
ui/00default.xml
... | ... | @@ -194,10 +194,10 @@ |
194 | 194 | <accelerator action='SelectUp' key='<Shift>Up' group='online' /> |
195 | 195 | <accelerator action='SelectDown' key='<Shift>Down' group='online' /> |
196 | 196 | |
197 | - <accelerator action='SelectionRight' key='<alt>Right' /> | |
198 | - <accelerator action='SelectionLeft' key='<alt>Left' /> | |
199 | - <accelerator action='SelectionUp' key='<alt>Up' /> | |
200 | - <accelerator action='SelectionDown' key='<alt>Down' /> | |
197 | + <accelerator action='move' target='selection' direction='right' key='<alt>Right' /> | |
198 | + <accelerator action='move' target='selection' direction='left' key='<alt>Left' /> | |
199 | + <accelerator action='move' target='selection' direction='up' key='<alt>Up' /> | |
200 | + <accelerator action='move' target='selection' direction='down' key='<alt>Down' /> | |
201 | 201 | |
202 | 202 | <accelerator action='CursorRight' key='Right' group='online' /> |
203 | 203 | <accelerator action='CursorLeft' key='Left' group='online' /> | ... | ... |