Commit fc337b919db2a7ec7bd23bcbd6041b8452db0628

Authored by Perry Werneck
1 parent 9bb3294a
Exists in master and in 1 other branch develop

Splitting properties get/set/init in separated sources.

remap file is now a property.
Makefile.in
... ... @@ -34,6 +34,7 @@ SOURCES= \
34 34 $(wildcard src/terminal/*.c) \
35 35 $(wildcard src/terminal/@OSNAME@/*.rc) \
36 36 $(wildcard src/terminal/@OSNAME@/*.c) \
  37 + $(wildcard src/terminal/properties/*.c) \
37 38 $(wildcard src/filetransfer/*.c) \
38 39 $(wildcard src/selection/*.c) \
39 40 $(wildcard src/selection/@OSNAME@/*.c) \
... ...
src/include/config.h.in
... ... @@ -34,6 +34,7 @@
34 34 #undef PACKAGE_NAME
35 35 #undef PACKAGE_VERSION
36 36 #undef PACKAGE_RELEASE
  37 + #undef PRODUCT_NAME
37 38  
38 39 #undef HAVE_LIBM
39 40 #undef HAVE_GNOME
... ...
src/include/terminal.h
... ... @@ -164,6 +164,7 @@ G_BEGIN_DECLS
164 164 // Session
165 165 H3270 * host; /**< Related 3270 session */
166 166 gchar * session_name; /**< Session name (for window title) */
  167 + gchar * remap_filename; /**< @brief XML file with remap table. */
167 168  
168 169 // Auto disconnect
169 170 struct
... ...
src/include/v3270.h
... ... @@ -246,7 +246,8 @@
246 246  
247 247 LIB3270_EXPORT void v3270_set_session_host_type(GtkWidget *widget, LIB3270_HOST_TYPE);
248 248  
249   - LIB3270_EXPORT void v3270_remap_from_xml(GtkWidget *widget, const gchar *path);
  249 + LIB3270_EXPORT void v3270_set_remap_filename(GtkWidget *widget, const gchar *path);
  250 + LIB3270_EXPORT const gchar * v3270_get_remap_filename(GtkWidget *widget);
250 251  
251 252 // Keyboard & Mouse special actions
252 253 LIB3270_EXPORT void v3270_set_scroll_action(GtkWidget *widget, GdkScrollDirection direction, GtkAction *action);
... ...
src/terminal/charset.c
... ... @@ -31,7 +31,6 @@
31 31 #include <v3270.h>
32 32 #include <lib3270/charset.h>
33 33 #include <lib3270/log.h>
34   -// #include <lib3270/X11keysym.h>
35 34 #include <v3270/dialogs.h>
36 35  
37 36 #define ERROR_DOMAIN g_quark_from_static_string(PACKAGE_NAME)
... ... @@ -69,258 +68,6 @@
69 68 return chr;
70 69 }
71 70  
72   - /*
73   - static unsigned short getChar(const gchar *id, GError **error) {
74   -
75   - static struct
76   - {
77   - const char * name;
78   - unsigned short keysym;
79   - } latin[] =
80   - {
81   - { "space", XK_space },
82   - { "exclam", XK_exclam },
83   - { "quotedbl", XK_quotedbl },
84   - { "numbersign", XK_numbersign },
85   - { "dollar", XK_dollar },
86   - { "percent", XK_percent },
87   - { "ampersand", XK_ampersand },
88   - { "apostrophe", XK_apostrophe },
89   - { "quoteright", XK_quoteright },
90   - { "parenleft", XK_parenleft },
91   - { "parenright", XK_parenright },
92   - { "asterisk", XK_asterisk },
93   - { "plus", XK_plus },
94   - { "comma", XK_comma },
95   - { "minus", XK_minus },
96   - { "period", XK_period },
97   - { "slash", XK_slash },
98   - { "0", XK_0 },
99   - { "1", XK_1 },
100   - { "2", XK_2 },
101   - { "3", XK_3 },
102   - { "4", XK_4 },
103   - { "5", XK_5 },
104   - { "6", XK_6 },
105   - { "7", XK_7 },
106   - { "8", XK_8 },
107   - { "9", XK_9 },
108   - { "colon", XK_colon },
109   - { "semicolon", XK_semicolon },
110   - { "less", XK_less },
111   - { "equal", XK_equal },
112   - { "greater", XK_greater },
113   - { "question", XK_question },
114   - { "at", XK_at },
115   - { "A", XK_A },
116   - { "B", XK_B },
117   - { "C", XK_C },
118   - { "D", XK_D },
119   - { "E", XK_E },
120   - { "F", XK_F },
121   - { "G", XK_G },
122   - { "H", XK_H },
123   - { "I", XK_I },
124   - { "J", XK_J },
125   - { "K", XK_K },
126   - { "L", XK_L },
127   - { "M", XK_M },
128   - { "N", XK_N },
129   - { "O", XK_O },
130   - { "P", XK_P },
131   - { "Q", XK_Q },
132   - { "R", XK_R },
133   - { "S", XK_S },
134   - { "T", XK_T },
135   - { "U", XK_U },
136   - { "V", XK_V },
137   - { "W", XK_W },
138   - { "X", XK_X },
139   - { "Y", XK_Y },
140   - { "Z", XK_Z },
141   - { "bracketleft", XK_bracketleft },
142   - { "backslash", XK_backslash },
143   - { "bracketright", XK_bracketright },
144   - { "asciicircum", XK_asciicircum },
145   - { "underscore", XK_underscore },
146   - { "grave", XK_grave },
147   - { "quoteleft", XK_quoteleft },
148   - { "a", XK_a },
149   - { "b", XK_b },
150   - { "c", XK_c },
151   - { "d", XK_d },
152   - { "e", XK_e },
153   - { "f", XK_f },
154   - { "g", XK_g },
155   - { "h", XK_h },
156   - { "i", XK_i },
157   - { "j", XK_j },
158   - { "k", XK_k },
159   - { "l", XK_l },
160   - { "m", XK_m },
161   - { "n", XK_n },
162   - { "o", XK_o },
163   - { "p", XK_p },
164   - { "q", XK_q },
165   - { "r", XK_r },
166   - { "s", XK_s },
167   - { "t", XK_t },
168   - { "u", XK_u },
169   - { "v", XK_v },
170   - { "w", XK_w },
171   - { "x", XK_x },
172   - { "y", XK_y },
173   - { "z", XK_z },
174   - { "braceleft", XK_braceleft },
175   - { "bar", XK_bar },
176   - { "braceright", XK_braceright },
177   - { "asciitilde", XK_asciitilde },
178   - { "nobreakspace", XK_nobreakspace },
179   - { "exclamdown", XK_exclamdown },
180   - { "cent", XK_cent },
181   - { "sterling", XK_sterling },
182   - { "currency", XK_currency },
183   - { "yen", XK_yen },
184   - { "brokenbar", XK_brokenbar },
185   - { "section", XK_section },
186   - { "diaeresis", XK_diaeresis },
187   - { "copyright", XK_copyright },
188   - { "ordfeminine", XK_ordfeminine },
189   - { "guillemotleft", XK_guillemotleft },
190   - { "notsign", XK_notsign },
191   - { "hyphen", XK_hyphen },
192   - { "registered", XK_registered },
193   - { "macron", XK_macron },
194   - { "degree", XK_degree },
195   - { "plusminus", XK_plusminus },
196   - { "twosuperior", XK_twosuperior },
197   - { "threesuperior", XK_threesuperior },
198   - { "acute", XK_acute },
199   - { "mu", XK_mu },
200   - { "paragraph", XK_paragraph },
201   - { "periodcentered", XK_periodcentered },
202   - { "cedilla", XK_cedilla },
203   - { "onesuperior", XK_onesuperior },
204   - { "masculine", XK_masculine },
205   - { "guillemotright", XK_guillemotright },
206   - { "onequarter", XK_onequarter },
207   - { "onehalf", XK_onehalf },
208   - { "threequarters", XK_threequarters },
209   - { "questiondown", XK_questiondown },
210   - { "Agrave", XK_Agrave },
211   - { "Aacute", XK_Aacute },
212   - { "Acircumflex", XK_Acircumflex },
213   - { "Atilde", XK_Atilde },
214   - { "Adiaeresis", XK_Adiaeresis },
215   - { "Aring", XK_Aring },
216   - { "AE", XK_AE },
217   - { "Ccedilla", XK_Ccedilla },
218   - { "Egrave", XK_Egrave },
219   - { "Eacute", XK_Eacute },
220   - { "Ecircumflex", XK_Ecircumflex },
221   - { "Ediaeresis", XK_Ediaeresis },
222   - { "Igrave", XK_Igrave },
223   - { "Iacute", XK_Iacute },
224   - { "Icircumflex", XK_Icircumflex },
225   - { "Idiaeresis", XK_Idiaeresis },
226   - { "ETH", XK_ETH },
227   - { "Eth", XK_Eth },
228   - { "Ntilde", XK_Ntilde },
229   - { "Ograve", XK_Ograve },
230   - { "Oacute", XK_Oacute },
231   - { "Ocircumflex", XK_Ocircumflex },
232   - { "Otilde", XK_Otilde },
233   - { "Odiaeresis", XK_Odiaeresis },
234   - { "multiply", XK_multiply },
235   - { "Ooblique", XK_Ooblique },
236   - { "Ugrave", XK_Ugrave },
237   - { "Uacute", XK_Uacute },
238   - { "Ucircumflex", XK_Ucircumflex },
239   - { "Udiaeresis", XK_Udiaeresis },
240   - { "Yacute", XK_Yacute },
241   - { "THORN", XK_THORN },
242   - { "Thorn", XK_Thorn },
243   - { "ssharp", XK_ssharp },
244   - { "agrave", XK_agrave },
245   - { "aacute", XK_aacute },
246   - { "acircumflex", XK_acircumflex },
247   - { "atilde", XK_atilde },
248   - { "adiaeresis", XK_adiaeresis },
249   - { "aring", XK_aring },
250   - { "ae", XK_ae },
251   - { "ccedilla", XK_ccedilla },
252   - { "egrave", XK_egrave },
253   - { "eacute", XK_eacute },
254   - { "ecircumflex", XK_ecircumflex },
255   - { "ediaeresis", XK_ediaeresis },
256   - { "igrave", XK_igrave },
257   - { "iacute", XK_iacute },
258   - { "icircumflex", XK_icircumflex },
259   - { "idiaeresis", XK_idiaeresis },
260   - { "eth", XK_eth },
261   - { "ntilde", XK_ntilde },
262   - { "ograve", XK_ograve },
263   - { "oacute", XK_oacute },
264   - { "ocircumflex", XK_ocircumflex },
265   - { "otilde", XK_otilde },
266   - { "odiaeresis", XK_odiaeresis },
267   - { "division", XK_division },
268   - { "oslash", XK_oslash },
269   - { "ugrave", XK_ugrave },
270   - { "uacute", XK_uacute },
271   - { "ucircumflex", XK_ucircumflex },
272   - { "udiaeresis", XK_udiaeresis },
273   - { "yacute", XK_yacute },
274   - { "thorn", XK_thorn },
275   - { "ydiaeresis", XK_ydiaeresis },
276   -
277   - // The following are, umm, hacks to allow symbolic names for
278   - // control codes.
279   - #if !defined(_WIN32)
280   - { "BackSpace", 0x08 },
281   - { "Tab", 0x09 },
282   - { "Linefeed", 0x0a },
283   - { "Return", 0x0d },
284   - { "Escape", 0x1b },
285   - { "Delete", 0x7f },
286   - #endif
287   - };
288   -
289   - size_t ix;
290   -
291   - if(*error) {
292   - return 0;
293   - }
294   -
295   - if(g_str_has_prefix(id,"0x")) {
296   -
297   - unsigned int rc = 0;
298   -
299   - if(sscanf(id + 2, "%x", &rc) != 1)
300   - {
301   - *error = g_error_new(ERROR_DOMAIN,EINVAL,"%s",_( "Can't parse character value" ));
302   - return 0;
303   - }
304   -
305   - return (unsigned short) rc;
306   -
307   - }
308   -
309   - for(ix=0;ix < G_N_ELEMENTS(latin);ix++) {
310   - if(!g_ascii_strcasecmp(id,latin[ix].name))
311   - return latin[ix].keysym;
312   - }
313   -
314   - if(strlen(id) != 1)
315   - {
316   - *error = g_error_new(ERROR_DOMAIN,EINVAL,"%s",_( "Invalid character value" ));
317   - return 0;
318   - }
319   -
320   - return (unsigned short) *id;
321   - }
322   - */
323   -
324 71 static lib3270_remap_scope getRemapScope(const gchar *str, GError **error) {
325 72  
326 73 static const char *text[] = { "CS_ONLY","FT_ONLY", "BOTH" };
... ... @@ -434,7 +181,37 @@
434 181 {
435 182 }
436 183  
437   - LIB3270_EXPORT void v3270_remap_from_xml(GtkWidget *widget, const gchar *path)
  184 + static gchar * get_filename(const gchar *name)
  185 + {
  186 + size_t ix;
  187 + const gchar * const * system_data_dirs = g_get_system_data_dirs();
  188 +
  189 +#ifdef _WIN32
  190 + #error Implementar.
  191 +#endif // _WIN32
  192 +
  193 + for(ix=0;system_data_dirs[ix];ix++)
  194 + {
  195 + gchar * filename = g_build_filename(system_data_dirs[ix],G_STRINGIFY(PRODUCT_NAME),"remap",name,NULL);
  196 +
  197 + debug("%s(%s)",__FUNCTION__,filename);
  198 +
  199 + if(g_file_test(filename,G_FILE_TEST_IS_REGULAR))
  200 + return filename;
  201 +
  202 + g_free(filename);
  203 + }
  204 +
  205 + return g_build_filename("remap",name,NULL);
  206 +
  207 + }
  208 +
  209 + LIB3270_EXPORT const char * v3270_get_remap_filename(GtkWidget *widget)
  210 + {
  211 + return GTK_V3270(widget)->remap_filename;
  212 + }
  213 +
  214 + LIB3270_EXPORT void v3270_set_remap_filename(GtkWidget *widget, const gchar *path)
438 215 {
439 216 static const GMarkupParser parser =
440 217 {
... ... @@ -454,12 +231,46 @@
454 231 };
455 232  
456 233 GError * error = NULL;
457   - gchar * text = NULL;
  234 + g_autofree gchar * text = NULL;
  235 + v3270 * terminal = GTK_V3270(widget);
458 236 struct parse cfg;
459 237  
  238 + debug("%s(%s)",__FUNCTION__,path);
  239 +
  240 + g_return_if_fail(GTK_IS_V3270(widget));
  241 +
  242 + if(terminal->remap_filename)
  243 + {
  244 + g_free(terminal->remap_filename);
  245 + terminal->remap_filename = NULL;
  246 + }
  247 +
  248 + if(!(path && *path))
  249 + {
  250 + lib3270_reset_charset(terminal->host,NULL,NULL,LIB3270_DEFAULT_CGEN | LIB3270_DEFAULT_CSET);
  251 + return;
  252 + }
  253 +
460 254 memset(&cfg,0,sizeof(cfg));
461 255  
462   - if(g_file_get_contents(path,&text,NULL,&error))
  256 + if(g_file_test(path,G_FILE_TEST_IS_REGULAR))
  257 + {
  258 + terminal->remap_filename = g_strdup(path);
  259 + }
  260 + else if(g_str_has_suffix(path,".xml"))
  261 + {
  262 + terminal->remap_filename = get_filename(path);
  263 + }
  264 + else
  265 + {
  266 + g_autofree gchar *name = g_strconcat(path,".xml",NULL);
  267 + terminal->remap_filename = get_filename(name);
  268 + }
  269 +
  270 + debug("Loading \"%s\"",terminal->remap_filename);
  271 + g_file_get_contents(terminal->remap_filename,&text,NULL,&error);
  272 +
  273 + if(text && !error)
463 274 {
464 275  
465 276 GMarkupParseContext * context = g_markup_parse_context_new(&parser,G_MARKUP_TREAT_CDATA_AS_TEXT|G_MARKUP_PREFIX_ERROR_POSITION,&cfg,NULL);
... ... @@ -470,42 +281,30 @@
470 281  
471 282 debug("error=%p",error);
472 283  
  284 + lib3270_reset_charset(terminal->host,NULL,NULL,LIB3270_DEFAULT_CGEN | LIB3270_DEFAULT_CSET);
  285 +
473 286 if(error)
474 287 {
475   - g_autofree gchar * name = g_path_get_basename(path);
476   -
477 288 v3270_popup_gerror(
478 289 widget,
479 290 error,
480 291 _( "Remap Failed" ),
481   - _( "Can't parse %s" ), name
  292 + _( "Can't parse %s" ), path
482 293 );
483 294  
484 295 g_error_free(error);
485 296  
486 297 } else {
487 298  
488   - H3270 * hSession = v3270_get_session(widget);
  299 + unsigned int i;
489 300  
490   -
491   - if(hSession)
  301 + for(i=0;i < cfg.len; i++)
492 302 {
493   - unsigned int i;
494   -
495   - lib3270_reset_charset(hSession, cfg.host, cfg.display, cfg.cgcsgid);
496   -
497   - for(i=0;i < cfg.len; i++)
498   - {
499   - lib3270_remap_char(hSession,cfg.map[i].ebc,cfg.map[i].iso, BOTH, 0);
500   - }
501   -
  303 + lib3270_remap_char(terminal->host,cfg.map[i].ebc,cfg.map[i].iso, BOTH, 0);
502 304 }
503 305  
504   -
505 306 }
506 307  
507   -
508   - g_free(text);
509 308 g_free(cfg.host);
510 309 g_free(cfg.display);
511 310  
... ...
src/terminal/properties.c
... ... @@ -1,485 +0,0 @@
1   -/*
2   - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
3   - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
4   - * aplicativos mainframe. Registro no INPI sob o nome G3270.
5   - *
6   - * Copyright (C) <2008> <Banco do Brasil S.A.>
7   - *
8   - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
9   - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
10   - * Free Software Foundation.
11   - *
12   - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
13   - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
14   - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
15   - * obter mais detalhes.
16   - *
17   - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
18   - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
19   - * St, Fifth Floor, Boston, MA 02110-1301 USA
20   - *
21   - * Este programa está nomeado como properties.c e possui - linhas de código.
22   - *
23   - * Contatos:
24   - *
25   - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
26   - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
27   - *
28   - */
29   -
30   -#ifdef WIN32
31   - #include <winsock2.h>
32   - #include <windows.h>
33   - #include <ws2tcpip.h>
34   -#endif // WIN32
35   -
36   - #include <gtk/gtk.h>
37   - #include <limits.h>
38   - #include <lib3270.h>
39   - #include <lib3270/session.h>
40   - #include <lib3270/actions.h>
41   - #include <lib3270/log.h>
42   - #include <lib3270/properties.h>
43   - #include <lib3270/toggle.h>
44   - #include <stdlib.h>
45   - #include <errno.h>
46   - #include <v3270.h>
47   - #include <terminal.h>
48   -
49   - enum _v3270_internal_property
50   - {
51   - V3270_PROPERTY_FONT_FAMILY = 2, ///< @brief Name of the font-family used by widget.
52   - V3270_PROPERTY_CLIPBOARD = 3, ///< @brief Name of the selected clipboard.
53   - V3270_PROPERTY_SESSION_NAME = 4, ///< @brief Widget's session name.
54   - V3270_PROPERTY_AUTO_DISCONNECT = 5, ///< @brief Auto disconnect.
55   -
56   -
57   - V3270_PROPERTY_DYNAMIC = 6 ///< @brief Id of the first LIB3270 internal property.
58   - };
59   -
60   -/*--[ Implement ]------------------------------------------------------------------------------------*/
61   -
62   - static void v3270_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
63   - {
64   - v3270 * window = GTK_V3270(object);
65   - v3270Class * klass = GTK_V3270_GET_CLASS(object);
66   -
67   - debug("%s(%u,%s)",__FUNCTION__,prop_id,g_param_spec_get_name(pspec));
68   -
69   - if(prop_id >= klass->properties.type.str)
70   - {
71   - const LIB3270_STRING_PROPERTY * prop = (lib3270_get_string_properties_list()+(prop_id - klass->properties.type.str));
72   - debug("%s.%s.%s=%s",__FUNCTION__,"string",prop->name,g_value_get_string(value));
73   -
74   - if(prop->set)
75   - prop->set(window->host,g_value_get_string(value));
76   -
77   - }
78   - else if(prop_id >= klass->properties.type.uint)
79   - {
80   - const LIB3270_UINT_PROPERTY * prop = (lib3270_get_unsigned_properties_list()+(prop_id - klass->properties.type.uint));
81   - debug("%s.%s.%s",__FUNCTION__,"unsigned",prop->name);
82   -
83   - if(prop->set)
84   - prop->set(window->host,g_value_get_uint(value));
85   -
86   - }
87   - else if(prop_id >= klass->properties.type.integer)
88   - {
89   - const LIB3270_INT_PROPERTY * prop = (lib3270_get_int_properties_list()+(prop_id - klass->properties.type.integer));
90   - debug("%s.%s.%s",__FUNCTION__,"integer",prop->name);
91   -
92   - if(prop->set)
93   - prop->set(window->host,g_value_get_int(value));
94   -
95   - }
96   - else if(prop_id >= klass->properties.type.boolean)
97   - {
98   - const LIB3270_INT_PROPERTY * prop = (lib3270_get_boolean_properties_list()+(prop_id - klass->properties.type.boolean));
99   - debug("%s.%s.%s",__FUNCTION__,"boolean",prop->name);
100   -
101   - if(prop->set)
102   - prop->set(window->host,g_value_get_boolean(value) ? 1 : 0);
103   -
104   - }
105   - else if(prop_id >= klass->properties.type.toggle)
106   - {
107   - debug("%s.%s",__FUNCTION__,"toggle");
108   - lib3270_set_toggle(window->host,prop_id - klass->properties.type.toggle, (int) g_value_get_boolean (value));
109   -
110   - }
111   - else
112   - {
113   - // Check for internal properties.
114   - switch(prop_id) {
115   - case V3270_PROPERTY_FONT_FAMILY: // Font-family
116   - v3270_set_font_family(GTK_WIDGET(object), g_value_get_string(value));
117   - break;
118   -
119   - case V3270_PROPERTY_CLIPBOARD: // Clipboard
120   - {
121   - const gchar * name = g_value_get_string(value);
122   - if(!*name) {
123   - g_message("Setting default clipboard");
124   - window->selection.target = GDK_SELECTION_CLIPBOARD;
125   - }
126   - else
127   - {
128   - GdkAtom clipboard = gdk_atom_intern(name,TRUE);
129   - if(clipboard == GDK_NONE)
130   - {
131   - g_warning("\"%s\" is not a valid clipboard name",name);
132   - }
133   - else
134   - {
135   - window->selection.target = clipboard;
136   - }
137   - }
138   - }
139   - break;
140   -
141   - case V3270_PROPERTY_SESSION_NAME: // Session Name
142   - v3270_set_session_name(GTK_WIDGET(object), g_value_get_string(value));
143   - break;
144   -
145   - case V3270_PROPERTY_AUTO_DISCONNECT:
146   - v3270_set_auto_disconnect(GTK_WIDGET(object), g_value_get_uint(value));
147   - break;
148   -
149   - default:
150   - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
151   -
152   - }
153   -
154   - }
155   -
156   -
157   - }
158   -
159   - static void v3270_get_property(GObject *object,guint prop_id, GValue *value, GParamSpec *pspec)
160   - {
161   - v3270 * window = GTK_V3270(object);
162   - v3270Class * klass = GTK_V3270_GET_CLASS(object);
163   -
164   - debug("%s(%u,%s)",__FUNCTION__,prop_id,g_param_spec_get_name(pspec));
165   -
166   - if(prop_id >= klass->properties.type.str)
167   - {
168   - const LIB3270_STRING_PROPERTY * prop = (lib3270_get_string_properties_list()+(prop_id - klass->properties.type.str));
169   - debug("%s.%s.%s",__FUNCTION__,"string",prop->name);
170   -
171   - if(prop->get)
172   - g_value_set_string(value,prop->get(window->host));
173   -
174   - }
175   - else if(prop_id >= klass->properties.type.uint)
176   - {
177   - const LIB3270_UINT_PROPERTY * prop = (lib3270_get_unsigned_properties_list()+(prop_id - klass->properties.type.uint));
178   - debug("%s.%s.%s",__FUNCTION__,"unsigned",prop->name);
179   -
180   - if(prop->get)
181   - g_value_set_uint(value,prop->get(window->host));
182   -
183   - }
184   - else if(prop_id >= klass->properties.type.integer)
185   - {
186   - const LIB3270_INT_PROPERTY * prop = (lib3270_get_int_properties_list()+(prop_id - klass->properties.type.integer));
187   - debug("%s.%s.%s",__FUNCTION__,"integer",prop->name);
188   -
189   - if(prop->get)
190   - g_value_set_int(value,prop->get(window->host));
191   -
192   - }
193   - else if(prop_id >= klass->properties.type.boolean)
194   - {
195   - const LIB3270_INT_PROPERTY * prop = (lib3270_get_boolean_properties_list()+(prop_id - klass->properties.type.boolean));
196   - debug("%s.%s.%s",__FUNCTION__,"boolean",prop->name);
197   -
198   - if(prop->get)
199   - g_value_set_boolean(value,prop->get(window->host) != 0 ? TRUE : FALSE);
200   -
201   - }
202   - else if(prop_id >= klass->properties.type.toggle)
203   - {
204   - debug("%s.%s.%s",__FUNCTION__,"toggle",lib3270_get_toggle_name(prop_id - klass->properties.type.toggle));
205   - g_value_set_boolean(value,lib3270_get_toggle(window->host,prop_id - klass->properties.type.toggle) ? TRUE : FALSE );
206   -
207   - }
208   - else
209   - {
210   - // Check for internal properties.
211   - switch(prop_id) {
212   - case V3270_PROPERTY_FONT_FAMILY: // Font-family
213   - g_value_set_string(value,v3270_get_font_family(GTK_WIDGET(object)));
214   - break;
215   -
216   - case V3270_PROPERTY_CLIPBOARD: // Clipboard
217   - g_value_take_string(value,gdk_atom_name(window->selection.target));
218   - break;
219   -
220   - case V3270_PROPERTY_SESSION_NAME:
221   - g_value_set_string(value,v3270_get_session_name(GTK_WIDGET(object)));
222   - break;
223   -
224   - case V3270_PROPERTY_AUTO_DISCONNECT:
225   - g_value_set_uint(value,window->activity.disconnect);
226   - break;
227   -
228   - default:
229   - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
230   -
231   - }
232   - }
233   -
234   - }
235   -
236   - void v3270_install_property(GObjectClass *oclass, guint property_id, GParamSpec *pspec)
237   - {
238   - v3270Class * klass = GTK_V3270_CLASS(oclass);
239   -
240   - const struct
241   - {
242   - const char *name;
243   - GParamSpec **prop;
244   - } properties[] = {
245   - { "connected", &klass->properties.online },
246   - { "luname", &klass->properties.luname },
247   - { "model", &klass->properties.model },
248   - { "has-selection", &klass->properties.selection },
249   - };
250   -
251   - size_t ix;
252   -
253   -// debug("Property %s=%u",g_param_spec_get_name(pspec),(unsigned int) property_id);
254   - g_object_class_install_property(oclass, property_id, pspec);
255   -
256   - for(ix = 0; ix < G_N_ELEMENTS(properties); ix++)
257   - {
258   - if(!g_ascii_strcasecmp(properties[ix].name,g_param_spec_get_name(pspec)))
259   - {
260   -// debug("Property \"%s\" is special",g_param_spec_get_name(pspec));
261   - *properties[ix].prop = pspec;
262   - break;
263   - }
264   - }
265   -
266   - }
267   -
268   - void v3270_init_properties(GObjectClass * gobject_class)
269   - {
270   - size_t ix;
271   - GParamSpec * spec;
272   - v3270Class * klass = GTK_V3270_CLASS(gobject_class);
273   -
274   - debug("%s",__FUNCTION__);
275   -
276   - gobject_class->set_property = v3270_set_property;
277   - gobject_class->get_property = v3270_get_property;
278   -
279   - // Setup internal properties.
280   -
281   - // Font family
282   - klass->properties.font_family = g_param_spec_string(
283   - "font_family",
284   - "font_family",
285   - _("Font family for terminal contents"),
286   - FALSE,
287   - G_PARAM_READABLE|G_PARAM_WRITABLE
288   - );
289   -
290   - g_object_class_install_property(
291   - gobject_class,
292   - V3270_PROPERTY_FONT_FAMILY,
293   - klass->properties.font_family
294   - );
295   -
296   - // Session name.
297   - spec = g_param_spec_string(
298   - "session_name",
299   - "session_name",
300   - _("TN3270 Session name"),
301   - FALSE,
302   - G_PARAM_READABLE|G_PARAM_WRITABLE
303   - );
304   -
305   - g_object_class_install_property(
306   - gobject_class,
307   - V3270_PROPERTY_SESSION_NAME,
308   - spec
309   - );
310   -
311   - // Auto disconnect
312   - spec = g_param_spec_string(
313   - "auto_disconnect",
314   - "auto_disconnect",
315   - _("IDLE minutes for automatic disconnection"),
316   - FALSE,
317   - G_PARAM_READABLE|G_PARAM_WRITABLE
318   - );
319   -
320   - g_object_class_install_property(
321   - gobject_class,
322   - V3270_PROPERTY_AUTO_DISCONNECT,
323   - spec
324   - );
325   -
326   - // Clipboard
327   - spec = g_param_spec_string(
328   - "clipboard",
329   - "clipboard",
330   - _("Clipboard name"),
331   - FALSE,
332   - G_PARAM_READABLE|G_PARAM_WRITABLE
333   - );
334   -
335   - g_object_class_install_property(
336   - gobject_class,
337   - V3270_PROPERTY_CLIPBOARD,
338   - spec
339   - );
340   -
341   - //
342   - // Create dynamic properties
343   - klass->properties.count = V3270_PROPERTY_DYNAMIC;
344   -
345   - //
346   - // Extract properties from LIB3270 control tables
347   - //
348   - // Extract toggle class.
349   - klass->properties.type.toggle = klass->properties.count;
350   - for(ix = 0; ix < LIB3270_TOGGLE_COUNT; ix++)
351   - {
352   - debug("Property %u=%s (Toggle)",(unsigned int) klass->properties.type.toggle + ix, lib3270_get_toggle_name(ix));
353   -
354   - klass->properties.toggle[ix] =
355   - g_param_spec_boolean(
356   - lib3270_get_toggle_name(ix),
357   - lib3270_get_toggle_name(ix),
358   - lib3270_get_toggle_description(ix),
359   - FALSE,
360   - G_PARAM_WRITABLE|G_PARAM_READABLE
361   - );
362   -
363   - v3270_install_property(gobject_class, klass->properties.count++, klass->properties.toggle[ix]);
364   -
365   - }
366   -
367   - // Creating boolean properties.
368   - klass->properties.type.boolean = klass->properties.count;
369   - const LIB3270_INT_PROPERTY * bool_props = lib3270_get_boolean_properties_list();
370   -
371   - for(ix = 0; bool_props[ix].name; ix++)
372   - {
373   - debug("Property %u=%s (Boolean)",(unsigned int) klass->properties.type.boolean + ix, bool_props[ix].name);
374   - spec = g_param_spec_boolean(
375   - bool_props[ix].name,
376   - bool_props[ix].name,
377   - bool_props[ix].description,
378   - FALSE,
379   - (bool_props[ix].set == NULL ? G_PARAM_READABLE : (G_PARAM_READABLE|G_PARAM_WRITABLE))
380   - );
381   -
382   - v3270_install_property(gobject_class, klass->properties.count++, spec);
383   -
384   - }
385   -
386   - // Creating signed integer properties.
387   - const LIB3270_INT_PROPERTY * int_props = lib3270_get_int_properties_list();
388   - klass->properties.type.integer = klass->properties.count;
389   -
390   - for(ix = 0; int_props[ix].name; ix++)
391   - {
392   - debug("Property %u=%s (Integer)",(unsigned int) klass->properties.type.integer + ix, int_props[ix].name);
393   -
394   - spec = g_param_spec_int(
395   - int_props[ix].name,
396   - int_props[ix].name,
397   - int_props[ix].description,
398   - 0, // Minimo
399   - INT_MAX, // Máximo
400   - 0, // Default
401   - (int_props[ix].set == NULL ? G_PARAM_READABLE : (G_PARAM_READABLE|G_PARAM_WRITABLE))
402   - );
403   -
404   - v3270_install_property(gobject_class, klass->properties.count++, spec);
405   -
406   - }
407   -
408   - // Creating unsigned integer properties.
409   - const LIB3270_UINT_PROPERTY * uint_props = lib3270_get_unsigned_properties_list();
410   - klass->properties.type.uint = klass->properties.count;
411   -
412   - for(ix = 0; uint_props[ix].name; ix++)
413   - {
414   - debug("Property %u=%s (unsigned)",(unsigned int) klass->properties.type.integer + ix, uint_props[ix].name);
415   -
416   - spec = g_param_spec_uint(
417   - uint_props[ix].name,
418   - uint_props[ix].name,
419   - uint_props[ix].description,
420   - 0, // Minimo
421   - UINT_MAX, // Máximo
422   - 0, // Default
423   - (uint_props[ix].set == NULL ? G_PARAM_READABLE : (G_PARAM_READABLE|G_PARAM_WRITABLE))
424   - );
425   -
426   - v3270_install_property(gobject_class, klass->properties.count++, spec);
427   -
428   - }
429   -
430   - // Creating string properties.
431   - const LIB3270_STRING_PROPERTY * str_props = lib3270_get_string_properties_list();
432   - klass->properties.type.str = klass->properties.count;
433   -
434   - for(ix = 0; str_props[ix].name; ix++)
435   - {
436   -
437   - debug("Property %u=%s (String)",(unsigned int) klass->properties.type.str + ix, str_props[ix].name);
438   -
439   - spec = g_param_spec_string(
440   - str_props[ix].name,
441   - str_props[ix].name,
442   - str_props[ix].description,
443   - FALSE,
444   - (str_props[ix].set == NULL ? G_PARAM_READABLE : (G_PARAM_READABLE|G_PARAM_WRITABLE))
445   - );
446   -
447   - v3270_install_property(gobject_class, klass->properties.count++, spec);
448   -
449   - }
450   -
451   - }
452   -
453   - LIB3270_EXPORT void v3270_set_auto_disconnect(GtkWidget *widget, guint minutes)
454   - {
455   - g_return_if_fail(GTK_IS_V3270(widget));
456   - GTK_V3270(widget)->activity.disconnect = minutes;
457   - }
458   -
459   - LIB3270_EXPORT guint v3270_get_auto_disconnect(GtkWidget *widget)
460   - {
461   - g_return_val_if_fail(GTK_IS_V3270(widget),0);
462   - return GTK_V3270(widget)->activity.disconnect;
463   - }
464   -
465   -LIB3270_EXPORT gboolean v3270_get_toggle(GtkWidget *widget, LIB3270_TOGGLE ix)
466   -{
467   - g_return_val_if_fail(GTK_IS_V3270(widget),FALSE);
468   -
469   - if(ix < LIB3270_TOGGLE_COUNT)
470   - return lib3270_get_toggle(GTK_V3270(widget)->host,ix) ? TRUE : FALSE;
471   -
472   - return FALSE;
473   -}
474   -
475   -LIB3270_EXPORT gboolean v3270_set_toggle(GtkWidget *widget, LIB3270_TOGGLE ix, gboolean state)
476   -{
477   - g_return_val_if_fail(GTK_IS_V3270(widget),FALSE);
478   -
479   - if(ix < LIB3270_TOGGLE_COUNT)
480   - return lib3270_set_toggle(GTK_V3270(widget)->host,ix,state ? 1 : 0) ? TRUE : FALSE;
481   -
482   - return FALSE;
483   -
484   -}
485   -
src/terminal/properties/get.c 0 → 100644
... ... @@ -0,0 +1,113 @@
  1 +/*
  2 + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
  3 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
  4 + * aplicativos mainframe. Registro no INPI sob o nome G3270.
  5 + *
  6 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  7 + *
  8 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  9 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  10 + * Free Software Foundation.
  11 + *
  12 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  13 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  14 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  15 + * obter mais detalhes.
  16 + *
  17 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  18 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  19 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  20 + *
  21 + * Este programa está nomeado como properties.c e possui - linhas de código.
  22 + *
  23 + * Contatos:
  24 + *
  25 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  26 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  27 + *
  28 + */
  29 +
  30 + #include "private.h"
  31 +
  32 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  33 +
  34 + void v3270_get_property(GObject *object,guint prop_id, GValue *value, GParamSpec *pspec)
  35 + {
  36 + v3270 * window = GTK_V3270(object);
  37 + v3270Class * klass = GTK_V3270_GET_CLASS(object);
  38 +
  39 + debug("%s(%u,%s)",__FUNCTION__,prop_id,g_param_spec_get_name(pspec));
  40 +
  41 + if(prop_id >= klass->properties.type.str)
  42 + {
  43 + const LIB3270_STRING_PROPERTY * prop = (lib3270_get_string_properties_list()+(prop_id - klass->properties.type.str));
  44 + debug("%s.%s.%s",__FUNCTION__,"string",prop->name);
  45 +
  46 + if(prop->get)
  47 + g_value_set_string(value,prop->get(window->host));
  48 +
  49 + }
  50 + else if(prop_id >= klass->properties.type.uint)
  51 + {
  52 + const LIB3270_UINT_PROPERTY * prop = (lib3270_get_unsigned_properties_list()+(prop_id - klass->properties.type.uint));
  53 + debug("%s.%s.%s",__FUNCTION__,"unsigned",prop->name);
  54 +
  55 + if(prop->get)
  56 + g_value_set_uint(value,prop->get(window->host));
  57 +
  58 + }
  59 + else if(prop_id >= klass->properties.type.integer)
  60 + {
  61 + const LIB3270_INT_PROPERTY * prop = (lib3270_get_int_properties_list()+(prop_id - klass->properties.type.integer));
  62 + debug("%s.%s.%s",__FUNCTION__,"integer",prop->name);
  63 +
  64 + if(prop->get)
  65 + g_value_set_int(value,prop->get(window->host));
  66 +
  67 + }
  68 + else if(prop_id >= klass->properties.type.boolean)
  69 + {
  70 + const LIB3270_INT_PROPERTY * prop = (lib3270_get_boolean_properties_list()+(prop_id - klass->properties.type.boolean));
  71 + debug("%s.%s.%s",__FUNCTION__,"boolean",prop->name);
  72 +
  73 + if(prop->get)
  74 + g_value_set_boolean(value,prop->get(window->host) != 0 ? TRUE : FALSE);
  75 +
  76 + }
  77 + else if(prop_id >= klass->properties.type.toggle)
  78 + {
  79 + debug("%s.%s.%s",__FUNCTION__,"toggle",lib3270_get_toggle_name(prop_id - klass->properties.type.toggle));
  80 + g_value_set_boolean(value,lib3270_get_toggle(window->host,prop_id - klass->properties.type.toggle) ? TRUE : FALSE );
  81 +
  82 + }
  83 + else
  84 + {
  85 + // Check for internal properties.
  86 + switch(prop_id) {
  87 + case V3270_PROPERTY_FONT_FAMILY: // Font-family
  88 + g_value_set_string(value,v3270_get_font_family(GTK_WIDGET(object)));
  89 + break;
  90 +
  91 + case V3270_PROPERTY_CLIPBOARD: // Clipboard
  92 + g_value_take_string(value,gdk_atom_name(window->selection.target));
  93 + break;
  94 +
  95 + case V3270_PROPERTY_SESSION_NAME:
  96 + g_value_set_string(value,v3270_get_session_name(GTK_WIDGET(object)));
  97 + break;
  98 +
  99 + case V3270_PROPERTY_AUTO_DISCONNECT:
  100 + g_value_set_uint(value,window->activity.disconnect);
  101 + break;
  102 +
  103 + case V3270_PROPERTY_REMAP_FILE: // Remap file
  104 + g_value_set_string(value,v3270_get_remap_filename(GTK_WIDGET(object)));
  105 + break;
  106 +
  107 + default:
  108 + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
  109 +
  110 + }
  111 + }
  112 +
  113 + }
... ...
src/terminal/properties/init.c 0 → 100644
... ... @@ -0,0 +1,265 @@
  1 +/*
  2 + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
  3 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
  4 + * aplicativos mainframe. Registro no INPI sob o nome G3270.
  5 + *
  6 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  7 + *
  8 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  9 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  10 + * Free Software Foundation.
  11 + *
  12 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  13 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  14 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  15 + * obter mais detalhes.
  16 + *
  17 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  18 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  19 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  20 + *
  21 + * Este programa está nomeado como properties.c e possui - linhas de código.
  22 + *
  23 + * Contatos:
  24 + *
  25 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  26 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  27 + *
  28 + */
  29 +
  30 + #include "private.h"
  31 +
  32 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  33 +
  34 + void v3270_install_property(GObjectClass *oclass, guint property_id, GParamSpec *pspec)
  35 + {
  36 + v3270Class * klass = GTK_V3270_CLASS(oclass);
  37 +
  38 + const struct
  39 + {
  40 + const char *name;
  41 + GParamSpec **prop;
  42 + } properties[] = {
  43 + { "connected", &klass->properties.online },
  44 + { "luname", &klass->properties.luname },
  45 + { "model", &klass->properties.model },
  46 + { "has-selection", &klass->properties.selection },
  47 + };
  48 +
  49 + size_t ix;
  50 +
  51 +// debug("Property %s=%u",g_param_spec_get_name(pspec),(unsigned int) property_id);
  52 + g_object_class_install_property(oclass, property_id, pspec);
  53 +
  54 + for(ix = 0; ix < G_N_ELEMENTS(properties); ix++)
  55 + {
  56 + if(!g_ascii_strcasecmp(properties[ix].name,g_param_spec_get_name(pspec)))
  57 + {
  58 +// debug("Property \"%s\" is special",g_param_spec_get_name(pspec));
  59 + *properties[ix].prop = pspec;
  60 + break;
  61 + }
  62 + }
  63 +
  64 + }
  65 +
  66 + void v3270_init_properties(GObjectClass * gobject_class)
  67 + {
  68 + size_t ix;
  69 + GParamSpec * spec;
  70 + v3270Class * klass = GTK_V3270_CLASS(gobject_class);
  71 +
  72 + debug("%s",__FUNCTION__);
  73 +
  74 + gobject_class->set_property = v3270_set_property;
  75 + gobject_class->get_property = v3270_get_property;
  76 +
  77 + // Setup internal properties.
  78 +
  79 + // Font family
  80 + klass->properties.font_family = g_param_spec_string(
  81 + "font_family",
  82 + "font_family",
  83 + _("Font family for terminal contents"),
  84 + FALSE,
  85 + G_PARAM_READABLE|G_PARAM_WRITABLE
  86 + );
  87 +
  88 + g_object_class_install_property(
  89 + gobject_class,
  90 + V3270_PROPERTY_FONT_FAMILY,
  91 + klass->properties.font_family
  92 + );
  93 +
  94 + // Session name.
  95 + spec = g_param_spec_string(
  96 + "session_name",
  97 + "session_name",
  98 + _("TN3270 Session name"),
  99 + FALSE,
  100 + G_PARAM_READABLE|G_PARAM_WRITABLE
  101 + );
  102 +
  103 + g_object_class_install_property(
  104 + gobject_class,
  105 + V3270_PROPERTY_SESSION_NAME,
  106 + spec
  107 + );
  108 +
  109 + // Auto disconnect
  110 + spec = g_param_spec_string(
  111 + "auto_disconnect",
  112 + "auto_disconnect",
  113 + _("IDLE minutes for automatic disconnection"),
  114 + FALSE,
  115 + G_PARAM_READABLE|G_PARAM_WRITABLE
  116 + );
  117 +
  118 + g_object_class_install_property(
  119 + gobject_class,
  120 + V3270_PROPERTY_AUTO_DISCONNECT,
  121 + spec
  122 + );
  123 +
  124 + // Clipboard
  125 + spec = g_param_spec_string(
  126 + "clipboard",
  127 + "clipboard",
  128 + _("Clipboard name"),
  129 + FALSE,
  130 + G_PARAM_READABLE|G_PARAM_WRITABLE
  131 + );
  132 +
  133 + g_object_class_install_property(
  134 + gobject_class,
  135 + V3270_PROPERTY_CLIPBOARD,
  136 + spec
  137 + );
  138 +
  139 + // Remap file
  140 + spec = g_param_spec_string(
  141 + "remap",
  142 + "remap",
  143 + _("XML file with remap table"),
  144 + FALSE,
  145 + G_PARAM_READABLE|G_PARAM_WRITABLE
  146 + );
  147 +
  148 + g_object_class_install_property(
  149 + gobject_class,
  150 + V3270_PROPERTY_REMAP_FILE,
  151 + spec
  152 + );
  153 +
  154 + //
  155 + // Create dynamic properties
  156 + klass->properties.count = V3270_PROPERTY_DYNAMIC;
  157 +
  158 + //
  159 + // Extract properties from LIB3270 control tables
  160 + //
  161 + // Extract toggle class.
  162 + klass->properties.type.toggle = klass->properties.count;
  163 + for(ix = 0; ix < LIB3270_TOGGLE_COUNT; ix++)
  164 + {
  165 + debug("Property %u=%s (Toggle)",(unsigned int) klass->properties.type.toggle + ix, lib3270_get_toggle_name(ix));
  166 +
  167 + klass->properties.toggle[ix] =
  168 + g_param_spec_boolean(
  169 + lib3270_get_toggle_name(ix),
  170 + lib3270_get_toggle_name(ix),
  171 + lib3270_get_toggle_description(ix),
  172 + FALSE,
  173 + G_PARAM_WRITABLE|G_PARAM_READABLE
  174 + );
  175 +
  176 + v3270_install_property(gobject_class, klass->properties.count++, klass->properties.toggle[ix]);
  177 +
  178 + }
  179 +
  180 + // Creating boolean properties.
  181 + klass->properties.type.boolean = klass->properties.count;
  182 + const LIB3270_INT_PROPERTY * bool_props = lib3270_get_boolean_properties_list();
  183 +
  184 + for(ix = 0; bool_props[ix].name; ix++)
  185 + {
  186 + debug("Property %u=%s (Boolean)",(unsigned int) klass->properties.type.boolean + ix, bool_props[ix].name);
  187 + spec = g_param_spec_boolean(
  188 + bool_props[ix].name,
  189 + bool_props[ix].name,
  190 + bool_props[ix].description,
  191 + FALSE,
  192 + (bool_props[ix].set == NULL ? G_PARAM_READABLE : (G_PARAM_READABLE|G_PARAM_WRITABLE))
  193 + );
  194 +
  195 + v3270_install_property(gobject_class, klass->properties.count++, spec);
  196 +
  197 + }
  198 +
  199 + // Creating signed integer properties.
  200 + const LIB3270_INT_PROPERTY * int_props = lib3270_get_int_properties_list();
  201 + klass->properties.type.integer = klass->properties.count;
  202 +
  203 + for(ix = 0; int_props[ix].name; ix++)
  204 + {
  205 + debug("Property %u=%s (Integer)",(unsigned int) klass->properties.type.integer + ix, int_props[ix].name);
  206 +
  207 + spec = g_param_spec_int(
  208 + int_props[ix].name,
  209 + int_props[ix].name,
  210 + int_props[ix].description,
  211 + 0, // Minimo
  212 + INT_MAX, // Máximo
  213 + 0, // Default
  214 + (int_props[ix].set == NULL ? G_PARAM_READABLE : (G_PARAM_READABLE|G_PARAM_WRITABLE))
  215 + );
  216 +
  217 + v3270_install_property(gobject_class, klass->properties.count++, spec);
  218 +
  219 + }
  220 +
  221 + // Creating unsigned integer properties.
  222 + const LIB3270_UINT_PROPERTY * uint_props = lib3270_get_unsigned_properties_list();
  223 + klass->properties.type.uint = klass->properties.count;
  224 +
  225 + for(ix = 0; uint_props[ix].name; ix++)
  226 + {
  227 + debug("Property %u=%s (unsigned)",(unsigned int) klass->properties.type.integer + ix, uint_props[ix].name);
  228 +
  229 + spec = g_param_spec_uint(
  230 + uint_props[ix].name,
  231 + uint_props[ix].name,
  232 + uint_props[ix].description,
  233 + 0, // Minimo
  234 + UINT_MAX, // Máximo
  235 + 0, // Default
  236 + (uint_props[ix].set == NULL ? G_PARAM_READABLE : (G_PARAM_READABLE|G_PARAM_WRITABLE))
  237 + );
  238 +
  239 + v3270_install_property(gobject_class, klass->properties.count++, spec);
  240 +
  241 + }
  242 +
  243 + // Creating string properties.
  244 + const LIB3270_STRING_PROPERTY * str_props = lib3270_get_string_properties_list();
  245 + klass->properties.type.str = klass->properties.count;
  246 +
  247 + for(ix = 0; str_props[ix].name; ix++)
  248 + {
  249 +
  250 + debug("Property %u=%s (String)",(unsigned int) klass->properties.type.str + ix, str_props[ix].name);
  251 +
  252 + spec = g_param_spec_string(
  253 + str_props[ix].name,
  254 + str_props[ix].name,
  255 + str_props[ix].description,
  256 + FALSE,
  257 + (str_props[ix].set == NULL ? G_PARAM_READABLE : (G_PARAM_READABLE|G_PARAM_WRITABLE))
  258 + );
  259 +
  260 + v3270_install_property(gobject_class, klass->properties.count++, spec);
  261 +
  262 + }
  263 +
  264 + }
  265 +
... ...
src/terminal/properties/methods.c 0 → 100644
... ... @@ -0,0 +1,66 @@
  1 +/*
  2 + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
  3 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
  4 + * aplicativos mainframe. Registro no INPI sob o nome G3270.
  5 + *
  6 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  7 + *
  8 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  9 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  10 + * Free Software Foundation.
  11 + *
  12 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  13 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  14 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  15 + * obter mais detalhes.
  16 + *
  17 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  18 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  19 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  20 + *
  21 + * Este programa está nomeado como properties.c e possui - linhas de código.
  22 + *
  23 + * Contatos:
  24 + *
  25 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  26 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  27 + *
  28 + */
  29 +
  30 + #include "private.h"
  31 +
  32 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  33 +
  34 + LIB3270_EXPORT void v3270_set_auto_disconnect(GtkWidget *widget, guint minutes)
  35 + {
  36 + g_return_if_fail(GTK_IS_V3270(widget));
  37 + GTK_V3270(widget)->activity.disconnect = minutes;
  38 + }
  39 +
  40 + LIB3270_EXPORT guint v3270_get_auto_disconnect(GtkWidget *widget)
  41 + {
  42 + g_return_val_if_fail(GTK_IS_V3270(widget),0);
  43 + return GTK_V3270(widget)->activity.disconnect;
  44 + }
  45 +
  46 +LIB3270_EXPORT gboolean v3270_get_toggle(GtkWidget *widget, LIB3270_TOGGLE ix)
  47 +{
  48 + g_return_val_if_fail(GTK_IS_V3270(widget),FALSE);
  49 +
  50 + if(ix < LIB3270_TOGGLE_COUNT)
  51 + return lib3270_get_toggle(GTK_V3270(widget)->host,ix) ? TRUE : FALSE;
  52 +
  53 + return FALSE;
  54 +}
  55 +
  56 +LIB3270_EXPORT gboolean v3270_set_toggle(GtkWidget *widget, LIB3270_TOGGLE ix, gboolean state)
  57 +{
  58 + g_return_val_if_fail(GTK_IS_V3270(widget),FALSE);
  59 +
  60 + if(ix < LIB3270_TOGGLE_COUNT)
  61 + return lib3270_set_toggle(GTK_V3270(widget)->host,ix,state ? 1 : 0) ? TRUE : FALSE;
  62 +
  63 + return FALSE;
  64 +
  65 +}
  66 +
... ...
src/terminal/properties/private.h 0 → 100644
... ... @@ -0,0 +1,64 @@
  1 +/*
  2 + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
  3 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
  4 + * aplicativos mainframe. Registro no INPI sob o nome G3270.
  5 + *
  6 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  7 + *
  8 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  9 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  10 + * Free Software Foundation.
  11 + *
  12 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  13 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  14 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  15 + * obter mais detalhes.
  16 + *
  17 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  18 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  19 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  20 + *
  21 + * Este programa está nomeado como properties.c e possui - linhas de código.
  22 + *
  23 + * Contatos:
  24 + *
  25 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  26 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  27 + *
  28 + */
  29 +
  30 +#ifdef WIN32
  31 + #include <winsock2.h>
  32 + #include <windows.h>
  33 + #include <ws2tcpip.h>
  34 +#endif // WIN32
  35 +
  36 + #include <gtk/gtk.h>
  37 + #include <limits.h>
  38 + #include <lib3270.h>
  39 + #include <lib3270/session.h>
  40 + #include <lib3270/actions.h>
  41 + #include <lib3270/log.h>
  42 + #include <lib3270/properties.h>
  43 + #include <lib3270/toggle.h>
  44 + #include <stdlib.h>
  45 + #include <errno.h>
  46 + #include <v3270.h>
  47 + #include <terminal.h>
  48 +
  49 + enum _v3270_internal_property
  50 + {
  51 + V3270_PROPERTY_FONT_FAMILY = 2, ///< @brief Name of the font-family used by widget.
  52 + V3270_PROPERTY_CLIPBOARD = 3, ///< @brief Name of the selected clipboard.
  53 + V3270_PROPERTY_SESSION_NAME = 4, ///< @brief Widget's session name.
  54 + V3270_PROPERTY_AUTO_DISCONNECT = 5, ///< @brief Auto disconnect.
  55 + V3270_PROPERTY_REMAP_FILE = 6, ///< @brief Path of the remap file.
  56 +
  57 +
  58 + V3270_PROPERTY_DYNAMIC = 7 ///< @brief Id of the first LIB3270 internal property.
  59 + };
  60 +
  61 + G_GNUC_INTERNAL void v3270_get_property(GObject *object,guint prop_id, GValue *value, GParamSpec *pspec);
  62 + G_GNUC_INTERNAL void v3270_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
  63 +
  64 +
... ...
src/terminal/properties/set.c 0 → 100644
... ... @@ -0,0 +1,134 @@
  1 +/*
  2 + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
  3 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
  4 + * aplicativos mainframe. Registro no INPI sob o nome G3270.
  5 + *
  6 + * Copyright (C) <2008> <Banco do Brasil S.A.>
  7 + *
  8 + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
  9 + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
  10 + * Free Software Foundation.
  11 + *
  12 + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
  13 + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
  14 + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
  15 + * obter mais detalhes.
  16 + *
  17 + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
  18 + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
  19 + * St, Fifth Floor, Boston, MA 02110-1301 USA
  20 + *
  21 + * Este programa está nomeado como properties.c e possui - linhas de código.
  22 + *
  23 + * Contatos:
  24 + *
  25 + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
  26 + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
  27 + *
  28 + */
  29 +
  30 + #include "private.h"
  31 +
  32 +/*--[ Implement ]------------------------------------------------------------------------------------*/
  33 +
  34 + void v3270_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
  35 + {
  36 + v3270 * window = GTK_V3270(object);
  37 + v3270Class * klass = GTK_V3270_GET_CLASS(object);
  38 +
  39 + debug("%s(%u,%s)",__FUNCTION__,prop_id,g_param_spec_get_name(pspec));
  40 +
  41 + if(prop_id >= klass->properties.type.str)
  42 + {
  43 + const LIB3270_STRING_PROPERTY * prop = (lib3270_get_string_properties_list()+(prop_id - klass->properties.type.str));
  44 + debug("%s.%s.%s=%s",__FUNCTION__,"string",prop->name,g_value_get_string(value));
  45 +
  46 + if(prop->set)
  47 + prop->set(window->host,g_value_get_string(value));
  48 +
  49 + }
  50 + else if(prop_id >= klass->properties.type.uint)
  51 + {
  52 + const LIB3270_UINT_PROPERTY * prop = (lib3270_get_unsigned_properties_list()+(prop_id - klass->properties.type.uint));
  53 + debug("%s.%s.%s",__FUNCTION__,"unsigned",prop->name);
  54 +
  55 + if(prop->set)
  56 + prop->set(window->host,g_value_get_uint(value));
  57 +
  58 + }
  59 + else if(prop_id >= klass->properties.type.integer)
  60 + {
  61 + const LIB3270_INT_PROPERTY * prop = (lib3270_get_int_properties_list()+(prop_id - klass->properties.type.integer));
  62 + debug("%s.%s.%s",__FUNCTION__,"integer",prop->name);
  63 +
  64 + if(prop->set)
  65 + prop->set(window->host,g_value_get_int(value));
  66 +
  67 + }
  68 + else if(prop_id >= klass->properties.type.boolean)
  69 + {
  70 + const LIB3270_INT_PROPERTY * prop = (lib3270_get_boolean_properties_list()+(prop_id - klass->properties.type.boolean));
  71 + debug("%s.%s.%s",__FUNCTION__,"boolean",prop->name);
  72 +
  73 + if(prop->set)
  74 + prop->set(window->host,g_value_get_boolean(value) ? 1 : 0);
  75 +
  76 + }
  77 + else if(prop_id >= klass->properties.type.toggle)
  78 + {
  79 + debug("%s.%s",__FUNCTION__,"toggle");
  80 + lib3270_set_toggle(window->host,prop_id - klass->properties.type.toggle, (int) g_value_get_boolean (value));
  81 +
  82 + }
  83 + else
  84 + {
  85 + // Check for internal properties.
  86 + switch(prop_id) {
  87 + case V3270_PROPERTY_FONT_FAMILY: // Font-family
  88 + v3270_set_font_family(GTK_WIDGET(object), g_value_get_string(value));
  89 + break;
  90 +
  91 + case V3270_PROPERTY_CLIPBOARD: // Clipboard
  92 + {
  93 + const gchar * name = g_value_get_string(value);
  94 + if(!*name) {
  95 + g_message("Setting default clipboard");
  96 + window->selection.target = GDK_SELECTION_CLIPBOARD;
  97 + }
  98 + else
  99 + {
  100 + GdkAtom clipboard = gdk_atom_intern(name,TRUE);
  101 + if(clipboard == GDK_NONE)
  102 + {
  103 + g_warning("\"%s\" is not a valid clipboard name",name);
  104 + }
  105 + else
  106 + {
  107 + window->selection.target = clipboard;
  108 + }
  109 + }
  110 + }
  111 + break;
  112 +
  113 + case V3270_PROPERTY_SESSION_NAME: // Session Name
  114 + v3270_set_session_name(GTK_WIDGET(object), g_value_get_string(value));
  115 + break;
  116 +
  117 + case V3270_PROPERTY_AUTO_DISCONNECT:
  118 + v3270_set_auto_disconnect(GTK_WIDGET(object), g_value_get_uint(value));
  119 + break;
  120 +
  121 + case V3270_PROPERTY_REMAP_FILE: // Remap file
  122 + v3270_set_remap_filename(GTK_WIDGET(object), g_value_get_string(value));
  123 + break;
  124 +
  125 + default:
  126 + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
  127 +
  128 + }
  129 +
  130 + }
  131 +
  132 +
  133 + }
  134 +
... ...
src/terminal/widget.c
... ... @@ -186,6 +186,12 @@ static void finalize(GObject *object)
186 186  
187 187 v3270 * terminal = GTK_V3270(object);
188 188  
  189 + if(terminal->remap_filename)
  190 + {
  191 + g_free(terminal->remap_filename);
  192 + terminal->remap_filename = NULL;
  193 + }
  194 +
189 195 if(terminal->host)
190 196 {
191 197 // Release session
... ...
src/trace/exec.c
... ... @@ -285,6 +285,14 @@
285 285 return lib3270_disconnect(hSession);
286 286 }
287 287  
  288 + if(g_str_has_prefix(cmdline,"remap"))
  289 + {
  290 + gchar *txtptr = cmdline+5;
  291 + g_strstrip(txtptr);
  292 + v3270_set_remap_filename(widget,txtptr);
  293 + return 0;
  294 + }
  295 +
288 296 if(g_str_has_prefix(cmdline,"set"))
289 297 {
290 298 gchar *txtptr = cmdline+3;
... ...
v3270.cbp
... ... @@ -239,7 +239,17 @@
239 239 <Unit filename="src/terminal/oia.c">
240 240 <Option compilerVar="CC" />
241 241 </Unit>
242   - <Unit filename="src/terminal/properties.c">
  242 + <Unit filename="src/terminal/properties/get.c">
  243 + <Option compilerVar="CC" />
  244 + </Unit>
  245 + <Unit filename="src/terminal/properties/init.c">
  246 + <Option compilerVar="CC" />
  247 + </Unit>
  248 + <Unit filename="src/terminal/properties/methods.c">
  249 + <Option compilerVar="CC" />
  250 + </Unit>
  251 + <Unit filename="src/terminal/properties/private.h" />
  252 + <Unit filename="src/terminal/properties/set.c">
243 253 <Option compilerVar="CC" />
244 254 </Unit>
245 255 <Unit filename="src/terminal/security.c">
... ...