Commit 10c4fc1b736fa0b31d1e9e9d268f55d5daec3709
1 parent
6dced93c
Exists in
master
and in
1 other branch
Incluindo notificacao quando da mudanca de um toggle
Showing
1 changed file
with
37 additions
and
18 deletions
Show diff stats
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 | ... | ... |