Commit 004109bcb3579e250ccef96925cc78a766b1c587
1 parent
22765196
Exists in
master
and in
5 other branches
Mudando tratamento de acoes para incluir novos atributos
Showing
8 changed files
with
53 additions
and
128 deletions
Show diff stats
src/gtk/actions.c
... | ... | @@ -240,12 +240,22 @@ static void action_pakey(GtkAction *action, GtkWidget *widget) |
240 | 240 | lib3270_pakey(GTK_V3270(widget)->host,(int) g_object_get_data(G_OBJECT(action),"pakey")); |
241 | 241 | } |
242 | 242 | |
243 | -/* | |
244 | -static void action_fullscreen(GtkAction *action, GtkWidget *widget) | |
243 | +static void action_set_toggle(GtkAction *action, GtkWidget *widget) | |
244 | +{ | |
245 | + LIB3270_TOGGLE id = (LIB3270_TOGGLE) g_object_get_data(G_OBJECT(action),"toggle_id"); | |
246 | + trace("Action %s activated on widget %p toggle=%d",gtk_action_get_name(action),widget,id); | |
247 | + lib3270_set_toggle(GTK_V3270(widget)->host,id,1); | |
248 | +} | |
249 | + | |
250 | +static void action_reset_toggle(GtkAction *action, GtkWidget *widget) | |
245 | 251 | { |
246 | - lib3270_set_toggle(GTK_V3270(widget)->host,LIB3270_TOGGLE_FULL_SCREEN,1); | |
252 | + LIB3270_TOGGLE id = (LIB3270_TOGGLE) g_object_get_data(G_OBJECT(action),"toggle_id"); | |
253 | + trace("Action %s activated on widget %p toggle=%d",gtk_action_get_name(action),widget,id); | |
254 | + lib3270_set_toggle(GTK_V3270(widget)->host,id,0); | |
247 | 255 | } |
248 | 256 | |
257 | +/* | |
258 | + | |
249 | 259 | static void action_reselect(GtkAction *action, GtkWidget *widget) |
250 | 260 | { |
251 | 261 | lib3270_reselect(GTK_V3270(widget)->host); |
... | ... | @@ -261,12 +271,6 @@ static void action_pastnext(GtkAction *action, GtkWidget *widget) |
261 | 271 | lib3270_pastenext(GTK_V3270(widget)->host); |
262 | 272 | } |
263 | 273 | |
264 | -void ui_connect_pakey(GtkAction *action, GtkWidget *widget, const gchar *name, const gchar *id) | |
265 | -{ | |
266 | - g_object_set_data(G_OBJECT(action),"pakey",(gpointer) atoi(id)); | |
267 | - g_signal_connect(action,"activate",G_CALLBACK(action_pakey),widget); | |
268 | -} | |
269 | - | |
270 | 274 | void ui_connect_index_action(GtkAction *action, GtkWidget *widget, int ix, GtkAction **lst) |
271 | 275 | { |
272 | 276 | // trace("action(%d): %p",ix,action); |
... | ... | @@ -298,6 +302,11 @@ void ui_connect_index_action(GtkAction *action, GtkWidget *widget, int ix, GtkAc |
298 | 302 | |
299 | 303 | GtkAction * ui_get_action(GtkWidget *widget, const gchar *name, GHashTable *hash, const gchar **names, const gchar **values, GError **error) |
300 | 304 | { |
305 | + static const gchar *actionname[ACTION_COUNT] = { "pastenext", | |
306 | + "reselect", | |
307 | + "setfullscreen", | |
308 | + "resetfullscreen" | |
309 | + }; | |
301 | 310 | GtkAction * action = NULL; |
302 | 311 | GtkAction **toggle_action = (GtkAction **) g_object_get_data(G_OBJECT(widget),"toggle_actions"); |
303 | 312 | const gchar * direction = ui_get_attribute("direction",names,values); |
... | ... | @@ -305,6 +314,7 @@ GtkAction * ui_get_action(GtkWidget *widget, const gchar *name, GHashTable *hash |
305 | 314 | const gchar * attr; |
306 | 315 | int id = 0; |
307 | 316 | gchar * nm = NULL; |
317 | + int f; | |
308 | 318 | |
309 | 319 | enum _action_type |
310 | 320 | { |
... | ... | @@ -365,6 +375,7 @@ GtkAction * ui_get_action(GtkWidget *widget, const gchar *name, GHashTable *hash |
365 | 375 | } |
366 | 376 | else if(!g_strcasecmp(name,"set")) |
367 | 377 | { |
378 | + action_type = ACTION_TYPE_SET; | |
368 | 379 | attr = ui_get_attribute("toggle",names,values); |
369 | 380 | id = lib3270_get_toggle_id(attr); |
370 | 381 | if(id < 0) |
... | ... | @@ -376,6 +387,7 @@ GtkAction * ui_get_action(GtkWidget *widget, const gchar *name, GHashTable *hash |
376 | 387 | } |
377 | 388 | else if(!g_strcasecmp(name,"reset")) |
378 | 389 | { |
390 | + action_type = ACTION_TYPE_RESET; | |
379 | 391 | attr = ui_get_attribute("toggle",names,values); |
380 | 392 | id = lib3270_get_toggle_id(attr); |
381 | 393 | if(id < 0) |
... | ... | @@ -455,13 +467,27 @@ GtkAction * ui_get_action(GtkWidget *widget, const gchar *name, GHashTable *hash |
455 | 467 | |
456 | 468 | case ACTION_TYPE_SET: |
457 | 469 | action = gtk_action_new(nm,NULL,NULL,NULL); |
470 | + g_object_set_data(G_OBJECT(action),"toggle_id",(gpointer) id); | |
471 | + g_signal_connect(action,"activate",G_CALLBACK(action_set_toggle),widget); | |
458 | 472 | break; |
459 | 473 | |
460 | 474 | case ACTION_TYPE_RESET: |
461 | 475 | action = gtk_action_new(nm,NULL,NULL,NULL); |
476 | + g_object_set_data(G_OBJECT(action),"toggle_id",(gpointer) id); | |
477 | + g_signal_connect(action,"activate",G_CALLBACK(action_reset_toggle),widget); | |
462 | 478 | break; |
463 | 479 | } |
464 | 480 | |
481 | + for(f=0;f<ACTION_COUNT;f++) | |
482 | + { | |
483 | + if(!g_strcasecmp(actionname[f],nm)) | |
484 | + { | |
485 | + GtkAction **named_action = (GtkAction **) g_object_get_data(G_OBJECT(widget),"named_actions"); | |
486 | + named_action[f] = action; | |
487 | + break; | |
488 | + } | |
489 | + } | |
490 | + | |
465 | 491 | g_hash_table_insert(hash,nm,action); |
466 | 492 | g_free(nm); |
467 | 493 | ... | ... |
src/gtk/mainwindow.c
... | ... | @@ -32,6 +32,10 @@ |
32 | 32 | #include "globals.h" |
33 | 33 | #include "uiparser/parser.h" |
34 | 34 | |
35 | +#ifdef DEBUG | |
36 | + #include <lib3270/actions.h> | |
37 | +#endif | |
38 | + | |
35 | 39 | /*--[ Globals ]--------------------------------------------------------------------------------------*/ |
36 | 40 | |
37 | 41 | enum action_group |
... | ... | @@ -74,11 +78,6 @@ |
74 | 78 | NULL |
75 | 79 | }; |
76 | 80 | |
77 | - static const gchar *actionname[ACTION_COUNT+1] = { "pastenext", | |
78 | - "reselect", | |
79 | - "setfullscreen", | |
80 | - "resetfullscreen" | |
81 | - }; | |
82 | 81 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
83 | 82 | |
84 | 83 | static void toggle_changed(GtkWidget *widget, LIB3270_TOGGLE id, gboolean toggled, const gchar *name, GtkWindow *toplevel) |
... | ... | @@ -104,7 +103,7 @@ |
104 | 103 | static gboolean window_state_event(GtkWidget *window, GdkEventWindowState *event, GtkWidget *widget) |
105 | 104 | { |
106 | 105 | gboolean fullscreen = event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN ? TRUE : FALSE; |
107 | - GtkAction **action = (GtkAction **) g_object_get_data(G_OBJECT(window),"named_actions"); | |
106 | + GtkAction **action = (GtkAction **) g_object_get_data(G_OBJECT(widget),"named_actions"); | |
108 | 107 | |
109 | 108 | // Update fullscreen toggles |
110 | 109 | if(action[ACTION_FULLSCREEN]) |
... | ... | @@ -284,11 +283,13 @@ |
284 | 283 | H3270 * host = v3270_get_session(terminal); |
285 | 284 | gchar * path = build_data_filename("ui",NULL); |
286 | 285 | GtkActionGroup **group; |
287 | - GtkAction **action; | |
286 | + GtkAction **action = g_new0(GtkAction *,ACTION_COUNT); | |
288 | 287 | GtkWidget **popup; |
289 | 288 | int f; |
290 | 289 | |
291 | 290 | g_object_set_data_full(G_OBJECT(terminal),"toggle_actions",g_new0(GtkAction *,LIB3270_TOGGLE_COUNT),g_free); |
291 | + g_object_set_data_full(G_OBJECT(terminal),"named_actions",(gpointer) action, (GDestroyNotify) g_free); | |
292 | + | |
292 | 293 | // Initialize terminal config |
293 | 294 | for(f=0;f<G_N_ELEMENTS(widget_config);f++) |
294 | 295 | { |
... | ... | @@ -307,12 +308,9 @@ |
307 | 308 | } |
308 | 309 | |
309 | 310 | // Create window |
310 | - window = ui_parse_xml_folder(path,groupname,popupname,actionname,terminal,widget_setup); | |
311 | + window = ui_parse_xml_folder(path,groupname,popupname,terminal,widget_setup); | |
311 | 312 | group = g_object_get_data(G_OBJECT(window),"action_groups"); |
312 | 313 | popup = g_object_get_data(G_OBJECT(window),"popup_menus"); |
313 | - action = (GtkAction **) g_object_get_data(G_OBJECT(window),"named_actions"); | |
314 | - | |
315 | - g_object_set_data(G_OBJECT(terminal),"named_actions",action); | |
316 | 314 | |
317 | 315 | // Setup action groups |
318 | 316 | gtk_action_group_set_sensitive(group[ACTION_GROUP_SELECTION],FALSE); |
... | ... | @@ -359,6 +357,7 @@ |
359 | 357 | lib3270_testpattern(host); |
360 | 358 | #endif |
361 | 359 | |
360 | + trace("%s ends",__FUNCTION__); | |
362 | 361 | return window; |
363 | 362 | } |
364 | 363 | ... | ... |
src/gtk/uiparser/parsefile.c
... | ... | @@ -146,7 +146,7 @@ |
146 | 146 | action = g_hash_table_lookup(info->actions,name); |
147 | 147 | if(!action) |
148 | 148 | { |
149 | - action = gtk_action_new(name,NULL,NULL,NULL); | |
149 | + action = gtk_action_new(name,NULL,NULL,GTK_STOCK_QUIT); | |
150 | 150 | g_signal_connect(action,"activate",G_CALLBACK(gtk_main_quit), NULL); |
151 | 151 | } |
152 | 152 | } |
... | ... | @@ -155,95 +155,8 @@ |
155 | 155 | action = ui_get_action(info->center_widget,name,info->actions,names,values,error); |
156 | 156 | } |
157 | 157 | |
158 | - if(!action) | |
159 | - return action; | |
160 | - | |
161 | -/* | |
162 | - const gchar * target = NULL; | |
163 | - const gchar * direction = ui_get_attribute("direction",names,values); | |
164 | - const gchar * id = ui_get_attribute("id",names,values); | |
165 | - GtkAction * action; | |
166 | - gchar * nm; | |
167 | - void (*connect)(GtkAction *action, GtkWidget *widget, const gchar *name, const gchar *id) = ui_connect_action; | |
168 | - GtkAction * (*create)(const gchar *,const gchar *,const gchar *,const gchar *) = gtk_action_new; | |
169 | - | |
170 | - if(!g_strcasecmp(name,"toggle")) | |
171 | - { | |
172 | - nm = g_strconcat(name,id,NULL); | |
173 | - create = (GtkAction * (*)(const gchar *,const gchar *,const gchar *,const gchar *)) gtk_toggle_action_new; | |
174 | - connect = ui_connect_toggle; | |
175 | - } | |
176 | - else if(!g_strcasecmp(name,"move")) | |
177 | - { | |
178 | - target = ui_get_attribute("target",names,values); | |
179 | - | |
180 | - if(!(target && direction)) | |
181 | - { | |
182 | - *error = g_error_new(ERROR_DOMAIN,EINVAL,"%s",_("Move action needs target & direction attributes" )); | |
183 | - return NULL; | |
184 | - } | |
185 | - | |
186 | - nm = g_strconcat((flags & 0x80) ? "select" : "move",target,direction, NULL); | |
187 | - | |
188 | - } | |
189 | - else if(!g_strcasecmp(name,"toggleset")) | |
190 | - { | |
191 | - nm = g_strconcat("set",id,NULL); | |
192 | - } | |
193 | - else if(!g_strcasecmp(name,"togglereset")) | |
194 | - { | |
195 | - nm = g_strconcat("reset",id,NULL); | |
196 | - } | |
197 | - else if(!g_strcasecmp(name,"pfkey")) | |
198 | - { | |
199 | - nm = g_strdup_printf("pf%02d",atoi(id ? id : "0")); | |
200 | - connect = ui_connect_pfkey; | |
201 | - } | |
202 | - else if(!g_strcasecmp(name,"pakey")) | |
203 | - { | |
204 | - nm = g_strdup_printf("pa%02d",atoi(id ? id : "0")); | |
205 | - connect = ui_connect_pakey; | |
206 | - } | |
207 | - else | |
208 | - { | |
209 | - nm = g_strdup(name); | |
210 | - } | |
211 | - | |
212 | - action = g_hash_table_lookup(info->actions,nm); | |
213 | - | |
214 | 158 | if(action) |
215 | - { | |
216 | - g_free(nm); | |
217 | - } | |
218 | - else | |
219 | - { | |
220 | - int ix = -1; | |
221 | - | |
222 | - action = GTK_ACTION(create(nm,NULL,NULL,NULL)); | |
223 | - g_hash_table_insert(info->actions,nm,action); | |
224 | - | |
225 | - if(info->actionname) | |
226 | - { | |
227 | - int f; | |
228 | - for(f=0;info->actionname[f] && ix < 0;f++) | |
229 | - { | |
230 | - if(!g_strcasecmp(nm,info->actionname[f])) | |
231 | - ix = f; | |
232 | - } | |
233 | - } | |
234 | - | |
235 | - if(ix >= 0) | |
236 | - ui_connect_index_action(info->action[ix] = action,info->center_widget,ix,info->action); | |
237 | - else if(target) | |
238 | - ui_connect_target_action(action,info->center_widget,target,flags,error); | |
239 | - else if(g_strcasecmp(name,"quit")) | |
240 | - connect(action,info->center_widget,name,id); | |
241 | - else | |
242 | - g_signal_connect(action,"activate",G_CALLBACK(gtk_main_quit), NULL); | |
243 | - | |
244 | - } | |
245 | -*/ | |
246 | - ui_action_set_options(action,info,names,values,error); | |
159 | + ui_action_set_options(action,info,names,values,error); | |
247 | 160 | |
248 | 161 | return action; |
249 | 162 | } | ... | ... |
src/gtk/uiparser/parser.c
... | ... | @@ -217,7 +217,7 @@ static void release_list(GObject **obj) |
217 | 217 | g_free(obj); |
218 | 218 | } |
219 | 219 | |
220 | -GtkWidget * ui_parse_xml_folder(const gchar *path, const gchar ** groupname, const gchar **popupname, const gchar **actionname, GtkWidget *widget, const UI_WIDGET_SETUP *setup) | |
220 | +GtkWidget * ui_parse_xml_folder(const gchar *path, const gchar ** groupname, const gchar **popupname, GtkWidget *widget, const UI_WIDGET_SETUP *setup) | |
221 | 221 | { |
222 | 222 | struct parser p; |
223 | 223 | GDir * dir; |
... | ... | @@ -270,17 +270,12 @@ GtkWidget * ui_parse_xml_folder(const gchar *path, const gchar ** groupname, con |
270 | 270 | p.popupname = popupname; |
271 | 271 | p.strings = g_string_chunk_new(0); |
272 | 272 | p.setup = setup; |
273 | - p.actionname = actionname; | |
274 | 273 | |
275 | 274 | sz = (g_strv_length((gchar **) p.popupname)); |
276 | 275 | p.popup = g_new0(GtkWidget *,sz+1); |
277 | 276 | p.popup[sz] = (GtkWidget *) -1; |
278 | 277 | g_object_set_data_full(G_OBJECT(p.toplevel),"popup_menus",(gpointer) p.popup, (GDestroyNotify) release_list); |
279 | 278 | |
280 | - sz = (g_strv_length((gchar **) p.actionname)); | |
281 | - p.action = g_new0(GtkAction *,sz); | |
282 | - g_object_set_data_full(G_OBJECT(p.toplevel),"named_actions",(gpointer) p.action, (GDestroyNotify) g_free); | |
283 | - | |
284 | 279 | for(current = g_list_first(file);current;current = g_list_next(current)) |
285 | 280 | { |
286 | 281 | ui_parse_file(&p,(gchar *) current->data); | ... | ... |
src/gtk/uiparser/parser.h
... | ... | @@ -51,17 +51,9 @@ |
51 | 51 | void (*setup)(GtkWidget *widget, GtkWidget *obj); |
52 | 52 | } UI_WIDGET_SETUP; |
53 | 53 | |
54 | - GtkWidget * ui_parse_xml_folder(const gchar *path, const gchar ** groupname, const gchar **popupname, const gchar **actionname, GtkWidget *widget, const UI_WIDGET_SETUP *itn); | |
54 | + GtkWidget * ui_parse_xml_folder(const gchar *path, const gchar ** groupname, const gchar **popupname, GtkWidget *widget, const UI_WIDGET_SETUP *itn); | |
55 | 55 | const gchar * ui_get_attribute(const gchar *key, const gchar **name, const gchar **value); |
56 | 56 | gboolean ui_get_bool_attribute(const gchar *key, const gchar **name, const gchar **value, gboolean def); |
57 | 57 | GtkAction * ui_get_action(GtkWidget *widget, const gchar *name, GHashTable *hash, const gchar **names, const gchar **values, GError **error); |
58 | 58 | |
59 | - | |
60 | -// void ui_connect_action(GtkAction *action, GtkWidget *widget, const gchar *name, const gchar *id); | |
61 | -// void ui_connect_target_action(GtkAction *action, GtkWidget *widget, const gchar *target, unsigned short flags, GError **error); | |
62 | -// void ui_connect_index_action(GtkAction *action, GtkWidget *widget, int ix, GtkAction **lst); | |
63 | -// void ui_connect_toggle(GtkAction *action, GtkWidget *widget, const gchar *name, const gchar *id); | |
64 | -// void ui_connect_pfkey(GtkAction *action, GtkWidget *widget, const gchar *name, const gchar *id); | |
65 | -// void ui_connect_pakey(GtkAction *action, GtkWidget *widget, const gchar *name, const gchar *id); | |
66 | - | |
67 | 59 | #endif // UI_PARSER_H_INCLUDED | ... | ... |
src/gtk/uiparser/private.h
... | ... | @@ -59,11 +59,9 @@ |
59 | 59 | GObject * element; |
60 | 60 | GtkWidget * center_widget; |
61 | 61 | GtkWidget ** popup; /**< Popup widgets */ |
62 | - GtkAction ** action; /**< Named actions */ | |
63 | 62 | GStringChunk * strings; |
64 | 63 | const gchar ** group; /**< Action group list */ |
65 | 64 | const gchar ** popupname; /**< Popup names */ |
66 | - const gchar ** actionname; /**< Action names */ | |
67 | 65 | GHashTable * actions; /**< List of actions */ |
68 | 66 | GHashTable * element_list[UI_ELEMENT_COUNT]; |
69 | 67 | const UI_WIDGET_SETUP * setup; | ... | ... |
src/gtk/v3270/clipboard.c
... | ... | @@ -32,6 +32,7 @@ |
32 | 32 | #include <malloc.h> |
33 | 33 | #include "v3270.h" |
34 | 34 | #include "private.h" |
35 | + #include <lib3270/selection.h> | |
35 | 36 | |
36 | 37 | /*--[ Globals ]--------------------------------------------------------------------------------------*/ |
37 | 38 | |
... | ... | @@ -225,7 +226,7 @@ void v3270_paste_string(GtkWidget *widget, const gchar *text, const gchar *encod |
225 | 226 | return; |
226 | 227 | } |
227 | 228 | |
228 | - next = lib3270_paste(session,buffer) ? TRUE : FALSE; | |
229 | + next = lib3270_paste(session,(unsigned char *) buffer) ? TRUE : FALSE; | |
229 | 230 | |
230 | 231 | trace("Pastenext is %s",next ? "On" : "Off"); |
231 | 232 | ... | ... |
src/gtk/v3270/widget.c
... | ... | @@ -328,7 +328,6 @@ void v3270_update_font_metrics(v3270 *terminal, cairo_t *cr, int width, int heig |
328 | 328 | |
329 | 329 | cairo_set_font_size(cr,size); |
330 | 330 | |
331 | - | |
332 | 331 | /* |
333 | 332 | double sx, sy; |
334 | 333 | cairo_matrix_t font_matrix; |
... | ... | @@ -833,6 +832,8 @@ void v3270_set_font_family(GtkWidget *widget, const gchar *name) |
833 | 832 | name = "courier new"; |
834 | 833 | } |
835 | 834 | |
835 | + trace("%s(%s)",__FUNCTION__,name); | |
836 | + | |
836 | 837 | terminal->font_family = g_strdup(name); |
837 | 838 | terminal->font_weight = CAIRO_FONT_WEIGHT_NORMAL; |
838 | 839 | ... | ... |