Commit 0b4d159597161b73681330400f43f3bd473d0360

Authored by Perry Werneck
1 parent 002efa70

Adding methods to get translated properties.

src/core/properties/get.c
... ... @@ -34,24 +34,30 @@
34 34 #include <lib3270/properties.h>
35 35 #include <utilc.h>
36 36  
37   - LIB3270_EXPORT const char * lib3270_property_get_description(const LIB3270_PROPERTY * property) {
  37 + LIB3270_EXPORT const char * lib3270_property_get_label(const LIB3270_PROPERTY * property) {
  38 +
  39 + if(property && property->label)
  40 + return dgettext(GETTEXT_PACKAGE,property->label);
  41 +
  42 + return "";
38 43  
39   - if(property->description)
40   - return property->description;
  44 + }
  45 +
  46 + LIB3270_EXPORT const char * lib3270_property_get_description(const LIB3270_PROPERTY * property) {
41 47  
42   - if(property->summary)
43   - return property->summary;
  48 + if(property && property->description)
  49 + return dgettext(GETTEXT_PACKAGE,property->description);
44 50  
45   - return property->name;
  51 + return "";
46 52  
47 53 }
48 54  
49 55 LIB3270_EXPORT const char * lib3270_property_get_summary(const LIB3270_PROPERTY * property) {
50 56  
51   - if(property->summary)
52   - return property->summary;
  57 + if(property && property->summary)
  58 + return dgettext(GETTEXT_PACKAGE,property->summary);
53 59  
54   - return property->name;
  60 + return "";
55 61  
56 62 }
57 63  
... ...
src/core/toggles/getset.c
... ... @@ -30,7 +30,7 @@
30 30  
31 31 /**
32 32 * @file toggles/getset.c
33   - * @brief This module handles toggle changes.
  33 + * @brief This module handles toggle changes and properties.
34 34 */
35 35  
36 36 #include <config.h>
... ... @@ -41,8 +41,7 @@
41 41  
42 42 /*---[ Implement ]------------------------------------------------------------------------------------------------------------*/
43 43  
44   -LIB3270_EXPORT unsigned char lib3270_get_toggle(const H3270 *hSession, LIB3270_TOGGLE_ID ix)
45   -{
  44 +LIB3270_EXPORT unsigned char lib3270_get_toggle(const H3270 *hSession, LIB3270_TOGGLE_ID ix) {
46 45  
47 46 if(ix < 0 || ix >= LIB3270_TOGGLE_COUNT) {
48 47 errno = EINVAL;
... ... @@ -55,8 +54,7 @@ LIB3270_EXPORT unsigned char lib3270_get_toggle(const H3270 *hSession, LIB3270_T
55 54 /**
56 55 * @brief Call the internal update routine and listeners.
57 56 */
58   -static void toggle_notify(H3270 *session, struct lib3270_toggle *t, LIB3270_TOGGLE_ID ix)
59   -{
  57 +static void toggle_notify(H3270 *session, struct lib3270_toggle *t, LIB3270_TOGGLE_ID ix) {
60 58 trace("%s: ix=%d upcall=%p",__FUNCTION__,ix,t->upcall);
61 59  
62 60 t->upcall(session, t, LIB3270_TOGGLE_TYPE_INTERACTIVE);
... ... @@ -89,8 +87,7 @@ static void toggle_notify(H3270 *session, struct lib3270_toggle *t, LIB3270_TOGG
89 87 *
90 88 * @returns 0 if the toggle is already at the state, 1 if the toggle was changed; < 0 on error (sets errno).
91 89 */
92   -LIB3270_EXPORT int lib3270_set_toggle(H3270 *session, LIB3270_TOGGLE_ID ix, int value)
93   -{
  90 +LIB3270_EXPORT int lib3270_set_toggle(H3270 *session, LIB3270_TOGGLE_ID ix, int value) {
94 91 char v = value ? True : False;
95 92 struct lib3270_toggle * t;
96 93  
... ... @@ -110,8 +107,7 @@ LIB3270_EXPORT int lib3270_set_toggle(H3270 *session, LIB3270_TOGGLE_ID ix, int
110 107 return 1;
111 108 }
112 109  
113   -LIB3270_EXPORT int lib3270_toggle(H3270 *session, LIB3270_TOGGLE_ID ix)
114   -{
  110 +LIB3270_EXPORT int lib3270_toggle(H3270 *session, LIB3270_TOGGLE_ID ix) {
115 111 struct lib3270_toggle *t;
116 112  
117 113 CHECK_SESSION_HANDLE(session);
... ... @@ -128,3 +124,38 @@ LIB3270_EXPORT int lib3270_toggle(H3270 *session, LIB3270_TOGGLE_ID ix)
128 124 return (int) t->value;
129 125 }
130 126  
  127 +LIB3270_EXPORT const char * lib3270_toggle_get_name(const LIB3270_TOGGLE *toggle) {
  128 +
  129 + if(toggle && toggle->name)
  130 + return dgettext(GETTEXT_PACKAGE,toggle->name);
  131 +
  132 + return "";
  133 +
  134 +}
  135 +
  136 +LIB3270_EXPORT const char * lib3270_toggle_get_label(const LIB3270_TOGGLE *toggle) {
  137 +
  138 + if(toggle && toggle->label)
  139 + return dgettext(GETTEXT_PACKAGE,toggle->label);
  140 +
  141 + return "";
  142 +
  143 +}
  144 +
  145 +LIB3270_EXPORT const char * lib3270_toggle_get_summary(const LIB3270_TOGGLE *toggle) {
  146 +
  147 + if(toggle && toggle->summary)
  148 + return dgettext(GETTEXT_PACKAGE,toggle->summary);
  149 +
  150 + return "";
  151 +
  152 +}
  153 +
  154 +LIB3270_EXPORT const char * lib3270_toggle_get_description(const LIB3270_TOGGLE *toggle) {
  155 +
  156 + if(toggle && toggle->description)
  157 + return dgettext(GETTEXT_PACKAGE,toggle->description);
  158 +
  159 + return "";
  160 +
  161 +}
... ...
src/core/toggles/table.c
... ... @@ -29,8 +29,8 @@
29 29  
30 30  
31 31 /**
32   - * @file toggles/init.c
33   - * @brief Toggle description table.
  32 + * @file toggles/table.c
  33 + * @brief Toggle description table and associated methods.
34 34 */
35 35  
36 36 #include <config.h>
... ... @@ -342,14 +342,14 @@ LIB3270_EXPORT const LIB3270_TOGGLE * lib3270_get_toggle_list()
342 342 LIB3270_EXPORT const char * lib3270_get_toggle_summary(LIB3270_TOGGLE_ID ix)
343 343 {
344 344 if(ix < LIB3270_TOGGLE_COUNT)
345   - return toggle_descriptor[ix].summary;
  345 + return lib3270_toggle_get_summary(toggle_descriptor+ix);
346 346 return "";
347 347 }
348 348  
349 349 LIB3270_EXPORT const char * lib3270_get_toggle_label(LIB3270_TOGGLE_ID ix)
350 350 {
351 351 if(ix < LIB3270_TOGGLE_COUNT)
352   - return toggle_descriptor[ix].label;
  352 + return lib3270_toggle_get_label(toggle_descriptor+ix);
353 353 return "";
354 354 }
355 355  
... ... @@ -357,14 +357,13 @@ LIB3270_EXPORT const char * lib3270_get_toggle_label(LIB3270_TOGGLE_ID ix)
357 357 LIB3270_EXPORT const char * lib3270_get_toggle_description(LIB3270_TOGGLE_ID ix)
358 358 {
359 359 if(ix < LIB3270_TOGGLE_COUNT)
360   - return toggle_descriptor[ix].description;
  360 + return lib3270_toggle_get_description(toggle_descriptor+ix);
361 361 return "";
362 362 }
363 363  
364   -LIB3270_EXPORT const char * lib3270_get_toggle_name(LIB3270_TOGGLE_ID ix)
365   -{
  364 +LIB3270_EXPORT const char * lib3270_get_toggle_name(LIB3270_TOGGLE_ID ix) {
366 365 if(ix < LIB3270_TOGGLE_COUNT)
367   - return toggle_descriptor[ix].name;
  366 + return lib3270_toggle_get_name(toggle_descriptor+ix);
368 367 return "";
369 368 }
370 369  
... ...
src/include/lib3270/properties.h
... ... @@ -181,6 +181,12 @@
181 181 LIB3270_EXPORT int lib3270_set_oversize(H3270 *hSession, const char *value);
182 182  
183 183 /**
  184 + * @brief Get property label.
  185 + *
  186 + */
  187 + LIB3270_EXPORT const char * lib3270_property_get_label(const LIB3270_PROPERTY * property);
  188 +
  189 + /**
184 190 * @brief Get property description.
185 191 *
186 192 */
... ...
src/include/lib3270/toggle.h
... ... @@ -162,6 +162,8 @@
162 162 */
163 163 LIB3270_EXPORT const char * lib3270_get_toggle_name(LIB3270_TOGGLE_ID ix);
164 164  
  165 +
  166 +
165 167 /**
166 168 * @brief Get a long description of the toggle.
167 169 *
... ... @@ -212,6 +214,12 @@
212 214 */
213 215 LIB3270_EXPORT const LIB3270_TOGGLE * lib3270_toggle_get_from_id(LIB3270_TOGGLE_ID id);
214 216  
  217 + LIB3270_EXPORT const char * lib3270_toggle_get_name(const LIB3270_TOGGLE *toggle);
  218 + LIB3270_EXPORT const char * lib3270_toggle_get_label(const LIB3270_TOGGLE *toggle);
  219 + LIB3270_EXPORT const char * lib3270_toggle_get_summary(const LIB3270_TOGGLE *toggle);
  220 + LIB3270_EXPORT const char * lib3270_toggle_get_description(const LIB3270_TOGGLE *toggle);
  221 +
  222 +
215 223 #ifdef __cplusplus
216 224 }
217 225 #endif
... ...