Commit dc851660d2cf8d162ac1e9de703ca7cf78be2595
1 parent
48e3b348
Exists in
master
and in
5 other branches
Incluindo notificacao quando da mudanca de um toggle
Showing
3 changed files
with
69 additions
and
50 deletions
Show diff stats
src/include/lib3270.h
| ... | ... | @@ -641,7 +641,7 @@ |
| 641 | 641 | * @return Constant string with the toggle name. |
| 642 | 642 | * |
| 643 | 643 | */ |
| 644 | - LIB3270_EXPORT const char * lib3270_get_toggle_description(LIB3270_TOGGLE_ID ix); | |
| 644 | + LIB3270_EXPORT const char * lib3270_get_toggle_description(LIB3270_TOGGLE ix); | |
| 645 | 645 | |
| 646 | 646 | /** |
| 647 | 647 | * Revert toggle status. | ... | ... |
src/lib3270/toggles.c
| ... | ... | @@ -58,36 +58,36 @@ |
| 58 | 58 | static const struct _toggle |
| 59 | 59 | { |
| 60 | 60 | const char *name; |
| 61 | - const char *descr; | |
| 61 | + const char *description; | |
| 62 | 62 | } |
| 63 | 63 | toggle_info[LIB3270_TOGGLE_COUNT] = |
| 64 | 64 | { |
| 65 | - { "monocase", "" }, | |
| 66 | - { "cursorblink", "" }, | |
| 67 | - { "showtiming", "" }, | |
| 68 | - { "cursorpos", "" }, | |
| 69 | - { "dstrace", "" }, | |
| 70 | - { "linewrap", "" }, | |
| 71 | - { "blankfill", "" }, | |
| 72 | - { "screentrace", "" }, | |
| 73 | - { "eventtrace", "" }, | |
| 74 | - { "marginedpaste", "" }, | |
| 75 | - { "rectselect", "" }, | |
| 76 | - { "crosshair", "" }, | |
| 77 | - { "fullscreen", "" }, | |
| 78 | - { "reconnect", "" }, | |
| 79 | - { "insert", "" }, | |
| 80 | - { "smartpaste", "" }, | |
| 81 | - { "bold", "" }, | |
| 82 | - { "keepselected", "" }, | |
| 83 | - { "underline", "" }, | |
| 84 | - { "autoconnect", "" }, | |
| 85 | - { "kpalternative", "" }, /**< Keypad +/- move to next/previous field */ | |
| 86 | - { "beep", "" }, /**< Beep on errors */ | |
| 87 | - { "fieldattr", "" }, /**< View Field attribute */ | |
| 88 | - { "altscreen", "" }, /**< auto resize on altscreen */ | |
| 89 | - { "keepalive", "" }, /**< Enable network keep-alive with SO_KEEPALIVE */ | |
| 90 | - { "nettrace", "" }, /**< Enable network in/out trace */ | |
| 65 | + { "monocase", N_( "" ) }, | |
| 66 | + { "cursorblink", N_( "" ) }, | |
| 67 | + { "showtiming", N_( "" ) }, | |
| 68 | + { "cursorpos", N_( "" ) }, | |
| 69 | + { "dstrace", N_( "" ) }, | |
| 70 | + { "linewrap", N_( "" ) }, | |
| 71 | + { "blankfill", N_( "" ) }, | |
| 72 | + { "screentrace", N_( "" ) }, | |
| 73 | + { "eventtrace", N_( "" ) }, | |
| 74 | + { "marginedpaste", N_( "" ) }, | |
| 75 | + { "rectselect", N_( "" ) }, | |
| 76 | + { "crosshair", N_( "" ) }, | |
| 77 | + { "fullscreen", N_( "" ) }, | |
| 78 | + { "reconnect", N_( "" ) }, | |
| 79 | + { "insert", N_( "" ) }, | |
| 80 | + { "smartpaste", N_( "" ) }, | |
| 81 | + { "bold", N_( "" ) }, | |
| 82 | + { "keepselected", N_( "" ) }, | |
| 83 | + { "underline", N_( "" ) }, | |
| 84 | + { "autoconnect", N_( "" ) }, | |
| 85 | + { "kpalternative", N_( "Keypad +/- move to next/previous field" ) }, | |
| 86 | + { "beep", N_( "Beep on errors" ) }, | |
| 87 | + { "fieldattr", N_( "Show Field attribute" ) }, | |
| 88 | + { "altscreen", N_( "Auto resize on altscreen" ) }, | |
| 89 | + { "keepalive", N_( "Enable network keep-alive with SO_KEEPALIVE" ) }, | |
| 90 | + { "nettrace", N_( "Enable network in/out trace" ) }, | |
| 91 | 91 | }; |
| 92 | 92 | |
| 93 | 93 | LIB3270_EXPORT unsigned char lib3270_get_toggle(H3270 *session, LIB3270_TOGGLE ix) |
| ... | ... | @@ -109,7 +109,7 @@ static void toggle_notify(H3270 *session, struct lib3270_toggle *t, LIB3270_TOGG |
| 109 | 109 | t->upcall(session, t, TT_INTERACTIVE); |
| 110 | 110 | |
| 111 | 111 | if(session->update_toggle) |
| 112 | - session->update_toggle(session,ix,t->value,TT_INTERACTIVE,toggle_names[ix]); | |
| 112 | + session->update_toggle(session,ix,t->value,TT_INTERACTIVE,toggle_info[ix].name); | |
| 113 | 113 | |
| 114 | 114 | } |
| 115 | 115 | |
| ... | ... | @@ -244,14 +244,14 @@ void shutdown_toggles(H3270 *session) |
| 244 | 244 | LIB3270_EXPORT const char * lib3270_get_toggle_description(LIB3270_TOGGLE_ID ix) |
| 245 | 245 | { |
| 246 | 246 | if(ix < N_TOGGLES) |
| 247 | - return toggle_names[ix]; | |
| 247 | + return toggle_info[ix].description; | |
| 248 | 248 | return ""; |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | LIB3270_EXPORT const char * lib3270_get_toggle_name(LIB3270_TOGGLE_ID ix) |
| 252 | 252 | { |
| 253 | 253 | if(ix < N_TOGGLES) |
| 254 | - return toggle_names[ix]; | |
| 254 | + return toggle_info[ix].name; | |
| 255 | 255 | return ""; |
| 256 | 256 | } |
| 257 | 257 | |
| ... | ... | @@ -262,7 +262,7 @@ LIB3270_EXPORT LIB3270_TOGGLE lib3270_get_toggle_id(const char *name) |
| 262 | 262 | int f; |
| 263 | 263 | for(f=0;f<N_TOGGLES;f++) |
| 264 | 264 | { |
| 265 | - if(!strcasecmp(name,toggle_names[f])) | |
| 265 | + if(!strcasecmp(name,toggle_info[f].name)) | |
| 266 | 266 | return f; |
| 267 | 267 | } |
| 268 | 268 | } | ... | ... |
src/pw3270/v3270/widget.c
| ... | ... | @@ -83,13 +83,17 @@ |
| 83 | 83 | PROP_TOGGLE |
| 84 | 84 | }; |
| 85 | 85 | |
| 86 | + #define PROP_LAST (PROP_TOGGLE+LIB3270_TOGGLE_COUNT) | |
| 87 | + | |
| 86 | 88 | G_DEFINE_TYPE(v3270, v3270, GTK_TYPE_WIDGET); |
| 87 | 89 | |
| 88 | -/*--[ Globals ]--------------------------------------------------------------------------------------*/ | |
| 90 | +/*--[ Globals ]----------LIB3270_TOGGLE_COUNT----------------------------------------------------------------------------*/ | |
| 89 | 91 | |
| 90 | 92 | guint v3270_widget_signal[LAST_SIGNAL] = { 0 }; |
| 91 | 93 | GdkCursor * v3270_cursor[V3270_CURSOR_COUNT] = { 0 }; |
| 92 | 94 | |
| 95 | + static GParamSpec * v3270_properties[PROP_LAST] = { 0 }; | |
| 96 | + | |
| 93 | 97 | /*--[ Prototipes ]-----------------------------------------------------------------------------------*/ |
| 94 | 98 | |
| 95 | 99 | // http://git.gnome.org/browse/gtk+/tree/gtk/gtkdrawingarea.c?h=gtk-3-0 |
| ... | ... | @@ -325,11 +329,37 @@ static void v3270_set_property(GObject *object, guint prop_id, const GValue *val |
| 325 | 329 | break; |
| 326 | 330 | |
| 327 | 331 | default: |
| 332 | + if(prop_id < (PROP_TOGGLE + LIB3270_TOGGLE_COUNT)) | |
| 333 | + { | |
| 334 | + lib3270_set_toggle(window->host,prop_id - PROP_TOGGLE, (int) g_value_get_boolean (value)); | |
| 335 | + return; | |
| 336 | + } | |
| 328 | 337 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
| 329 | 338 | } |
| 330 | 339 | |
| 331 | 340 | } |
| 332 | 341 | |
| 342 | +static void v3270_get_property(GObject *object,guint prop_id, GValue *value, GParamSpec *pspec) | |
| 343 | +{ | |
| 344 | + v3270 *window = GTK_V3270(object); | |
| 345 | + | |
| 346 | + switch (prop_id) | |
| 347 | + { | |
| 348 | + case PROP_FULLSCREEN: | |
| 349 | + #warning Get the correct value | |
| 350 | + g_value_set_boolean(value,FALSE); | |
| 351 | + break; | |
| 352 | + | |
| 353 | + default: | |
| 354 | + if(prop_id < (PROP_TOGGLE + LIB3270_TOGGLE_COUNT)) | |
| 355 | + { | |
| 356 | + g_value_set_boolean(value,lib3270_get_toggle(window->host,prop_id - PROP_TOGGLE) ? TRUE : FALSE ); | |
| 357 | + return; | |
| 358 | + } | |
| 359 | + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); | |
| 360 | + } | |
| 361 | +} | |
| 362 | + | |
| 333 | 363 | static void v3270_class_init(v3270Class *klass) |
| 334 | 364 | { |
| 335 | 365 | GObjectClass * gobject_class = G_OBJECT_CLASS(klass); |
| ... | ... | @@ -598,14 +628,10 @@ static void v3270_class_init(v3270Class *klass) |
| 598 | 628 | |
| 599 | 629 | // Properties |
| 600 | 630 | gobject_class->set_property = v3270_set_property; |
| 631 | + gobject_class->get_property = v3270_get_property; | |
| 601 | 632 | |
| 602 | - g_object_class_install_property( | |
| 603 | - gobject_class, | |
| 604 | - PROP_FULLSCREEN, | |
| 605 | - g_param_spec_boolean("fullscreen", | |
| 606 | - "Fullscreen","If TRUE, the toplevel window was set to fullscreen", | |
| 607 | - FALSE, | |
| 608 | - G_PARAM_WRITABLE|G_PARAM_READABLE)); | |
| 633 | + v3270_properties[PROP_FULLSCREEN] = g_param_spec_boolean("fullscreen","Fullscreen","If TRUE, the toplevel window was set to fullscreen",FALSE,G_PARAM_WRITABLE|G_PARAM_READABLE); | |
| 634 | + g_object_class_install_property(gobject_class,PROP_FULLSCREEN,v3270_properties[PROP_FULLSCREEN]); | |
| 609 | 635 | |
| 610 | 636 | |
| 611 | 637 | // Toggle properties |
| ... | ... | @@ -613,18 +639,10 @@ static void v3270_class_init(v3270Class *klass) |
| 613 | 639 | |
| 614 | 640 | for(f=0;f<LIB3270_TOGGLE_COUNT;f++) |
| 615 | 641 | { |
| 616 | - g_object_class_install_property( | |
| 617 | - gobject_class, | |
| 618 | - PROP_TOGGLE+f, | |
| 619 | - g_param_spec_boolean( | |
| 620 | - lib3270_get_toggle_name(f), | |
| 621 | - lib3270_get_toggle_name(f), | |
| 622 | - lib3270_get_toggle_description(f), | |
| 623 | - FALSE, | |
| 624 | - G_PARAM_WRITABLE|G_PARAM_READABLE)); | |
| 642 | + v3270_properties[PROP_TOGGLE+f] = g_param_spec_boolean(lib3270_get_toggle_name(f),lib3270_get_toggle_name(f),lib3270_get_toggle_description(f),FALSE,G_PARAM_WRITABLE|G_PARAM_READABLE); | |
| 643 | + g_object_class_install_property(gobject_class,PROP_TOGGLE+f,v3270_properties[PROP_TOGGLE+f]); | |
| 625 | 644 | } |
| 626 | 645 | |
| 627 | - | |
| 628 | 646 | } |
| 629 | 647 | |
| 630 | 648 | void v3270_update_font_metrics(v3270 *terminal, cairo_t *cr, int width, int height) |
| ... | ... | @@ -742,6 +760,7 @@ static void set_timer(H3270 *session, unsigned char on) |
| 742 | 760 | |
| 743 | 761 | static void update_toggle(H3270 *session, LIB3270_TOGGLE ix, unsigned char value, LIB3270_TOGGLE_TYPE reason, const char *name) |
| 744 | 762 | { |
| 763 | + g_object_notify_by_pspec(G_OBJECT(session->widget), v3270_properties[PROP_TOGGLE+ix]); | |
| 745 | 764 | g_signal_emit(GTK_WIDGET(session->widget), v3270_widget_signal[SIGNAL_TOGGLE_CHANGED], 0, (guint) ix, (gboolean) (value != 0), (gchar *) name); |
| 746 | 765 | } |
| 747 | 766 | ... | ... |