Commit f565ad1e1f9e064093565faa3861b5f617fa57be
1 parent
068bbf7b
Exists in
master
and in
4 other branches
Conditional and property actions moved to libv3270.
Showing
5 changed files
with
1 additions
and
537 deletions
Show diff stats
Makefile.in
| ... | ... | @@ -32,8 +32,6 @@ INSTALL_PACKAGES=@INSTALL_PACKAGES@ |
| 32 | 32 | |
| 33 | 33 | SOURCES= \ |
| 34 | 34 | $(wildcard src/objects/actions/*.c) \ |
| 35 | - $(wildcard src/objects/actions/lib3270/*.c) \ | |
| 36 | - $(wildcard src/objects/actions/v3270/*.c) \ | |
| 37 | 35 | $(wildcard src/objects/application/*.c) \ |
| 38 | 36 | $(wildcard src/objects/application/actions/*.c) \ |
| 39 | 37 | $(wildcard src/objects/window/*.c) \ | ... | ... |
src/include/pw3270/actions.h
| ... | ... | @@ -100,9 +100,6 @@ |
| 100 | 100 | /// @brief New generic action. |
| 101 | 101 | GAction * pw3270_action_new(); |
| 102 | 102 | |
| 103 | - /// @brief New action from LIB3270's control data. | |
| 104 | - GAction * g_action_new_from_lib3270(const LIB3270_ACTION * definition); | |
| 105 | - | |
| 106 | 103 | /// @brief Get action name. |
| 107 | 104 | const gchar * pw3270_action_get_name(GAction *action); |
| 108 | 105 | |
| ... | ... | @@ -180,57 +177,6 @@ |
| 180 | 177 | /// @brief Update simple action from LIB3270's property description. |
| 181 | 178 | void pw3270_simple_action_set_lib3270_property(pw3270SimpleAction *action, const LIB3270_PROPERTY * property); |
| 182 | 179 | |
| 183 | - /* | |
| 184 | - // | |
| 185 | - // Dialog action | |
| 186 | - // | |
| 187 | - #define PW3270_TYPE_DIALOG_ACTION (pw3270DialogAction_get_type()) | |
| 188 | - #define PW3270_DIALOG_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), PW3270_TYPE_DIALOG_ACTION, pw3270DialogAction)) | |
| 189 | - #define PW3270_DIALOG_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PW3270_TYPE_DIALOG_ACTION, pw3270DialogActionClass)) | |
| 190 | - #define PW3270_IS_DIALOG_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), PW3270_TYPE_DIALOG_ACTION)) | |
| 191 | - #define PW3270_IS_DIALOG_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PW3270_TYPE_DIALOG_ACTION)) | |
| 192 | - #define PW3270_DIALOG_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PW3270_TYPE_DIALOG_ACTION, pw3270DialogActionClass)) | |
| 193 | - | |
| 194 | - typedef struct _pw3270DialogAction pw3270DialogAction; | |
| 195 | - typedef struct _pw3270DialogActionClass pw3270DialogActionClass; | |
| 196 | - | |
| 197 | - pw3270SimpleAction * pw3270_dialog_action_new(GtkWidget * (*factory)(pw3270SimpleAction *action, GtkWidget *)); | |
| 198 | - */ | |
| 199 | - | |
| 200 | - // | |
| 201 | - // V3270 Property Action | |
| 202 | - // | |
| 203 | - GAction * v3270_property_action_new(GtkWidget *widget, const gchar *property_name); | |
| 204 | - | |
| 205 | - // | |
| 206 | - // V3270 action who can be enable based on property | |
| 207 | - // | |
| 208 | - #define V3270_TYPE_CONDITIONAL_ACTION (v3270ConditionalAction_get_type()) | |
| 209 | - #define V3270_CONDITIONAL_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), V3270_TYPE_CONDITIONAL_ACTION, v3270ConditionalAction)) | |
| 210 | - #define V3270_CONDITIONAL_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), V3270_TYPE_CONDITIONAL_ACTION, v3270ConditionalActionClass)) | |
| 211 | - #define V3270_IS_CONDITIONAL_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), V3270_TYPE_CONDITIONAL_ACTION)) | |
| 212 | - #define V3270_IS_CONDITIONAL_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), V3270_TYPE_CONDITIONAL_ACTION)) | |
| 213 | - #define V3270_CONDITIONAL_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), V3270_TYPE_CONDITIONAL_ACTION, v3270ConditionalActionClass)) | |
| 214 | - | |
| 215 | - typedef struct _v3270ConditionalAction { | |
| 216 | - | |
| 217 | - pw3270SimpleAction parent; | |
| 218 | - | |
| 219 | - GParamSpec *pspec; | |
| 220 | - | |
| 221 | - } v3270ConditionalAction; | |
| 222 | - | |
| 223 | - typedef struct _v3270CopyActionClass { | |
| 224 | - | |
| 225 | - pw3270SimpleActionClass parent_class; | |
| 226 | - | |
| 227 | - } v3270ConditionalActionClass; | |
| 228 | - | |
| 229 | - GType v3270ConditionalAction_get_type(void) G_GNUC_CONST; | |
| 230 | - | |
| 231 | - GAction * v3270_conditional_action_new(GtkWidget *widget, const gchar *property_name); | |
| 232 | - GAction * v3270_action_new(const V3270_ACTION *action_data); | |
| 233 | - | |
| 234 | 180 | // |
| 235 | 181 | // Action view |
| 236 | 182 | // | ... | ... |
src/objects/actions/v3270/conditional.c
| ... | ... | @@ -1,172 +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 - 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 | - /** | |
| 31 | - * @brief Implement GAction who enables/disable based on a v3270 boolean property. | |
| 32 | - * | |
| 33 | - * Reference: | |
| 34 | - * | |
| 35 | - * <https://github.com/GNOME/glib/blob/master/gio/gpropertyaction.c> | |
| 36 | - * | |
| 37 | - */ | |
| 38 | - | |
| 39 | - #include "../private.h" | |
| 40 | - #include <stdlib.h> | |
| 41 | - #include <pw3270/window.h> | |
| 42 | - #include <v3270.h> | |
| 43 | - #include <lib3270/properties.h> | |
| 44 | - | |
| 45 | - static void v3270ConditionalAction_class_init(v3270ConditionalActionClass *klass); | |
| 46 | - static void v3270ConditionalAction_init(v3270ConditionalAction *action); | |
| 47 | - static gboolean get_enabled(GAction *action, GtkWidget *terminal); | |
| 48 | - static void change_widget(GAction *object, GtkWidget *from, GtkWidget *to); | |
| 49 | - | |
| 50 | - G_DEFINE_TYPE(v3270ConditionalAction, v3270ConditionalAction, PW3270_TYPE_SIMPLE_ACTION); | |
| 51 | - | |
| 52 | - void v3270ConditionalAction_class_init(v3270ConditionalActionClass *klass) { | |
| 53 | - | |
| 54 | - klass->parent_class.parent_class.change_widget = change_widget; | |
| 55 | - klass->parent_class.parent_class.get_enabled = get_enabled; | |
| 56 | - | |
| 57 | - } | |
| 58 | - | |
| 59 | - static void v3270ConditionalAction_init(v3270ConditionalAction G_GNUC_UNUSED(*action)) { | |
| 60 | - } | |
| 61 | - | |
| 62 | - static void on_notify(GtkWidget G_GNUC_UNUSED(*terminal), GParamSpec G_GNUC_UNUSED(*pspec), GAction *action) { | |
| 63 | - debug("%s: Enabled of action %s has changed",__FUNCTION__, g_action_get_name(G_ACTION(action))); | |
| 64 | - pw3270_action_notify_enabled(action); | |
| 65 | - } | |
| 66 | - | |
| 67 | - GAction * v3270_conditional_action_new(GtkWidget *widget, const gchar *property_name) { | |
| 68 | - | |
| 69 | - GParamSpec *pspec = g_object_class_find_property(G_OBJECT_GET_CLASS(widget), property_name); | |
| 70 | - | |
| 71 | - if(!pspec) { | |
| 72 | - | |
| 73 | - g_warning( | |
| 74 | - "Can't find property '%s::%s'", | |
| 75 | - G_OBJECT_TYPE_NAME(G_OBJECT(widget)), | |
| 76 | - property_name | |
| 77 | - ); | |
| 78 | - | |
| 79 | - return NULL; | |
| 80 | - | |
| 81 | - } | |
| 82 | - | |
| 83 | - debug("%s: pspec(%s)=%p",__FUNCTION__,property_name,pspec); | |
| 84 | - | |
| 85 | - if(~pspec->flags & G_PARAM_READABLE || pspec->flags & G_PARAM_CONSTRUCT_ONLY) { | |
| 86 | - | |
| 87 | - g_warning( | |
| 88 | - "Property '%s::%s' must be readable and not construct-only", | |
| 89 | - G_OBJECT_TYPE_NAME(G_OBJECT(widget)), | |
| 90 | - property_name | |
| 91 | - ); | |
| 92 | - | |
| 93 | - return NULL; | |
| 94 | - } | |
| 95 | - | |
| 96 | - v3270ConditionalAction * action = (v3270ConditionalAction *) g_object_new(V3270_TYPE_CONDITIONAL_ACTION, NULL); | |
| 97 | - | |
| 98 | - pw3270_simple_action_set_lib3270_property(PW3270_SIMPLE_ACTION(action), lib3270_property_get_by_name(pspec->name)); | |
| 99 | - | |
| 100 | - action->parent.parent.name = g_param_spec_get_name(pspec); | |
| 101 | - action->parent.tooltip = g_param_spec_get_blurb(pspec); | |
| 102 | - action->pspec = pspec; | |
| 103 | - | |
| 104 | - pw3270_action_set_terminal_widget(G_ACTION(action), widget); | |
| 105 | - | |
| 106 | - return G_ACTION(action); | |
| 107 | - } | |
| 108 | - | |
| 109 | - void change_widget(GAction *object, GtkWidget *from, GtkWidget *to) { | |
| 110 | - | |
| 111 | - v3270ConditionalAction * action = V3270_CONDITIONAL_ACTION(object); | |
| 112 | - g_autofree gchar * signal_name = g_strconcat("notify::", action->pspec->name,NULL); | |
| 113 | - | |
| 114 | - if(from) { | |
| 115 | - gulong handler = g_signal_handler_find( | |
| 116 | - from, | |
| 117 | - G_SIGNAL_MATCH_FUNC|G_SIGNAL_MATCH_DATA, | |
| 118 | - 0, | |
| 119 | - 0, | |
| 120 | - NULL, | |
| 121 | - G_CALLBACK(on_notify), | |
| 122 | - action | |
| 123 | - ); | |
| 124 | - | |
| 125 | - if(handler) | |
| 126 | - g_signal_handler_disconnect(from, handler); | |
| 127 | - | |
| 128 | - } | |
| 129 | - | |
| 130 | - PW3270_ACTION_CLASS(v3270ConditionalAction_parent_class)->change_widget(object,from,to); | |
| 131 | - | |
| 132 | - if(to) { | |
| 133 | - g_signal_connect(G_OBJECT(to),signal_name,G_CALLBACK(on_notify),action); | |
| 134 | - } | |
| 135 | - | |
| 136 | - pw3270_action_notify_enabled(G_ACTION(object)); | |
| 137 | - | |
| 138 | - } | |
| 139 | - | |
| 140 | - gboolean get_enabled(GAction *object, GtkWidget *terminal) { | |
| 141 | - | |
| 142 | - gboolean enabled = PW3270_ACTION_CLASS(v3270ConditionalAction_parent_class)->get_enabled(object,terminal); | |
| 143 | - | |
| 144 | - if(enabled && terminal) { | |
| 145 | - | |
| 146 | - // The action is enabled, check property to confirm. | |
| 147 | - v3270ConditionalAction * action = V3270_CONDITIONAL_ACTION(object); | |
| 148 | - | |
| 149 | - GValue value = G_VALUE_INIT; | |
| 150 | - g_value_init(&value, action->pspec->value_type); | |
| 151 | - g_object_get_property(G_OBJECT(terminal), action->pspec->name, &value); | |
| 152 | - | |
| 153 | - switch(action->pspec->value_type) { | |
| 154 | - case G_TYPE_UINT: | |
| 155 | - enabled = g_value_get_uint(&value) != 0; | |
| 156 | - break; | |
| 157 | - | |
| 158 | - case G_TYPE_BOOLEAN: | |
| 159 | - enabled = g_value_get_boolean(&value); | |
| 160 | - break; | |
| 161 | - | |
| 162 | - default: | |
| 163 | - enabled = FALSE; | |
| 164 | - } | |
| 165 | - | |
| 166 | - g_value_unset (&value); | |
| 167 | - | |
| 168 | - } | |
| 169 | - | |
| 170 | - return enabled; | |
| 171 | - | |
| 172 | - } |
src/objects/actions/v3270/property.c
| ... | ... | @@ -1,308 +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 - 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 | - /** | |
| 31 | - * @brief Implement GAction "wrapper" for v3270 properties. | |
| 32 | - * | |
| 33 | - * Reference: | |
| 34 | - * | |
| 35 | - * <https://github.com/GNOME/glib/blob/master/gio/gpropertyaction.c> | |
| 36 | - * | |
| 37 | - */ | |
| 38 | - | |
| 39 | - #include "../private.h" | |
| 40 | - #include <stdlib.h> | |
| 41 | - #include <pw3270/window.h> | |
| 42 | - #include <v3270.h> | |
| 43 | - #include <lib3270/properties.h> | |
| 44 | - | |
| 45 | - // | |
| 46 | - // V3270 Property Action | |
| 47 | - // | |
| 48 | - #define V3270_TYPE_PROPERTY_ACTION (v3270PropertyAction_get_type()) | |
| 49 | - #define V3270_PROPERTY_ACTION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), V3270_TYPE_PROPERTY_ACTION, v3270PropertyAction)) | |
| 50 | - #define V3270_PROPERTY_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), V3270_TYPE_PROPERTY_ACTION, v3270PropertyActionClass)) | |
| 51 | - #define V3270_IS_PROPERTY_ACTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), V3270_TYPE_PROPERTY_ACTION)) | |
| 52 | - #define V3270_IS_PROPERTY_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), V3270_TYPE_PROPERTY_ACTION)) | |
| 53 | - #define V3270_PROPERTY_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), V3270_TYPE_PROPERTY_ACTION, v3270PropertyActionClass)) | |
| 54 | - | |
| 55 | - typedef struct _v3270PropertyAction { | |
| 56 | - | |
| 57 | - V3270SimpleAction parent; | |
| 58 | - | |
| 59 | - GParamSpec *pspec; | |
| 60 | - | |
| 61 | - } v3270PropertyAction; | |
| 62 | - | |
| 63 | - typedef struct _v3270PropertyActionClass { | |
| 64 | - | |
| 65 | - V3270SimpleActionClass parent_class; | |
| 66 | - | |
| 67 | - } v3270PropertyActionClass; | |
| 68 | - | |
| 69 | -// static void v3270PropertyAction_class_init(v3270PropertyActionClass *klass); | |
| 70 | -// static void v3270PropertyAction_init(v3270PropertyAction *action); | |
| 71 | - | |
| 72 | - static GVariant * get_state(GAction *action, GtkWidget *terminal); | |
| 73 | - static const GVariantType * get_state_type(GAction *object); | |
| 74 | - static const GVariantType * get_parameter_type(GAction *object); | |
| 75 | - | |
| 76 | - static void change_widget(GAction *object, GtkWidget *from, GtkWidget *to); | |
| 77 | - | |
| 78 | - G_DEFINE_TYPE(v3270PropertyAction, v3270PropertyAction, V3270_TYPE_SIMPLE_ACTION); | |
| 79 | - | |
| 80 | - void v3270PropertyAction_class_init(v3270PropertyActionClass *klass) { | |
| 81 | - klass->parent_class.parent_class.change_widget = change_widget; | |
| 82 | - klass->parent_class.parent_class.get_parameter_type = get_parameter_type; | |
| 83 | - klass->parent_class.parent_class.get_state = get_state; | |
| 84 | - klass->parent_class.parent_class.get_state_type = get_state_type; | |
| 85 | - } | |
| 86 | - | |
| 87 | - static void v3270PropertyAction_init(v3270PropertyAction G_GNUC_UNUSED(*action)) { | |
| 88 | - } | |
| 89 | - | |
| 90 | - GVariant * get_state(GAction *object, GtkWidget *terminal) { | |
| 91 | - | |
| 92 | - v3270PropertyAction * action = V3270_PROPERTY_ACTION(object); | |
| 93 | - | |
| 94 | - GVariant * result = NULL; | |
| 95 | - GValue value = G_VALUE_INIT; | |
| 96 | - | |
| 97 | - g_value_init(&value, action->pspec->value_type); | |
| 98 | - g_object_get_property(G_OBJECT(terminal), action->pspec->name, &value); | |
| 99 | - | |
| 100 | - switch(action->pspec->value_type) { | |
| 101 | - case G_TYPE_UINT: | |
| 102 | - result = g_variant_new_take_string(g_strdup_printf("%d",g_value_get_uint(&value))); | |
| 103 | - break; | |
| 104 | - | |
| 105 | - case G_TYPE_STRING: | |
| 106 | - result = g_variant_new_string(g_value_get_string(&value)); | |
| 107 | - debug("Action %s is on state \"%s\"",g_action_get_name(object),g_value_get_string(&value)); | |
| 108 | - break; | |
| 109 | - | |
| 110 | - case G_TYPE_BOOLEAN: | |
| 111 | - result = g_variant_new_boolean(g_value_get_boolean(&value)); | |
| 112 | - break; | |
| 113 | - /* | |
| 114 | - | |
| 115 | - case G_TYPE_INT: | |
| 116 | - result = g_variant_new_int32(g_value_get_int(&value)); | |
| 117 | - break; | |
| 118 | - | |
| 119 | - case G_TYPE_DOUBLE: | |
| 120 | - result = g_variant_new_double(g_value_get_double(&value)); | |
| 121 | - break; | |
| 122 | - | |
| 123 | - case G_TYPE_FLOAT: | |
| 124 | - result = g_variant_new_double(g_value_get_float(&value)); | |
| 125 | - break; | |
| 126 | - | |
| 127 | - */ | |
| 128 | - default: | |
| 129 | - g_warning("Unexpected value type getting state for action \"%s\"",g_action_get_name(object)); | |
| 130 | - } | |
| 131 | - | |
| 132 | - g_value_unset (&value); | |
| 133 | - | |
| 134 | - return result; | |
| 135 | - | |
| 136 | - } | |
| 137 | - | |
| 138 | - static void activate(GAction *object, GVariant *parameter, GtkWidget *terminal) { | |
| 139 | - | |
| 140 | - v3270PropertyAction * action = V3270_PROPERTY_ACTION(object); | |
| 141 | - | |
| 142 | - GValue value = G_VALUE_INIT; | |
| 143 | - g_value_init(&value, action->pspec->value_type); | |
| 144 | - | |
| 145 | - switch(action->pspec->value_type) | |
| 146 | - { | |
| 147 | - case G_TYPE_UINT: | |
| 148 | - debug("%s(%s,%s,%p)",__FUNCTION__,g_action_get_name(object),g_variant_get_string(parameter,NULL),terminal); | |
| 149 | - g_value_set_uint(&value,atoi(g_variant_get_string(parameter,NULL))); | |
| 150 | - break; | |
| 151 | - | |
| 152 | - case G_TYPE_BOOLEAN: | |
| 153 | - | |
| 154 | - if(parameter) { | |
| 155 | - | |
| 156 | - debug("%s(%s,%s,%p)",__FUNCTION__,g_action_get_name(object),g_variant_get_string(parameter,NULL),terminal); | |
| 157 | - | |
| 158 | - if(g_variant_is_of_type(parameter,G_VARIANT_TYPE_BOOLEAN)) | |
| 159 | - g_value_set_boolean(&value,g_variant_get_boolean(parameter)); | |
| 160 | - else | |
| 161 | - g_value_set_boolean(&value,atoi(g_variant_get_string(parameter,NULL)) != 0); | |
| 162 | - | |
| 163 | - } else { | |
| 164 | - | |
| 165 | - g_object_get_property(G_OBJECT(terminal), action->pspec->name, &value); | |
| 166 | - g_value_set_boolean(&value,!g_value_get_boolean(&value)); | |
| 167 | - | |
| 168 | - } | |
| 169 | - | |
| 170 | - break; | |
| 171 | - | |
| 172 | - case G_TYPE_STRING: | |
| 173 | - g_value_set_string(&value,g_variant_get_string(parameter,NULL)); | |
| 174 | - break; | |
| 175 | - | |
| 176 | - /* | |
| 177 | - case G_TYPE_INT: | |
| 178 | - break; | |
| 179 | - | |
| 180 | - case G_TYPE_DOUBLE: | |
| 181 | - break; | |
| 182 | - | |
| 183 | - case G_TYPE_FLOAT: | |
| 184 | - break; | |
| 185 | - | |
| 186 | - */ | |
| 187 | - | |
| 188 | - default: | |
| 189 | - g_warning("Can't activate action \"%s\"",g_action_get_name(object)); | |
| 190 | - g_value_unset(&value); | |
| 191 | - return; | |
| 192 | - } | |
| 193 | - | |
| 194 | - g_object_set_property(G_OBJECT(terminal),action->pspec->name,&value); | |
| 195 | - | |
| 196 | - g_value_unset(&value); | |
| 197 | - | |
| 198 | - } | |
| 199 | - | |
| 200 | - static void on_notify(GtkWidget G_GNUC_UNUSED(*terminal), GParamSpec G_GNUC_UNUSED(*pspec), GAction *action) { | |
| 201 | - | |
| 202 | - debug("%s: State of action %s has changed",__FUNCTION__, g_action_get_name(G_ACTION(action))); | |
| 203 | - pw3270_action_notify_state(action); | |
| 204 | - | |
| 205 | - } | |
| 206 | - | |
| 207 | - GAction * v3270_property_action_new(GtkWidget *widget, const gchar *property_name) { | |
| 208 | - | |
| 209 | - GParamSpec *pspec = g_object_class_find_property(G_OBJECT_GET_CLASS(widget), property_name); | |
| 210 | - | |
| 211 | - if(!pspec) { | |
| 212 | - | |
| 213 | - g_warning( | |
| 214 | - "Can't find property '%s::%s'", | |
| 215 | - G_OBJECT_TYPE_NAME(G_OBJECT(widget)), | |
| 216 | - property_name | |
| 217 | - ); | |
| 218 | - | |
| 219 | - return NULL; | |
| 220 | - | |
| 221 | - } | |
| 222 | - | |
| 223 | - debug("%s: pspec(%s)=%p",__FUNCTION__,property_name,pspec); | |
| 224 | - | |
| 225 | - if(~pspec->flags & G_PARAM_READABLE || ~pspec->flags & G_PARAM_WRITABLE || pspec->flags & G_PARAM_CONSTRUCT_ONLY) { | |
| 226 | - | |
| 227 | - g_warning( | |
| 228 | - "Property '%s::%s' must be readable, writable, and not construct-only", | |
| 229 | - G_OBJECT_TYPE_NAME(G_OBJECT(widget)), | |
| 230 | - property_name | |
| 231 | - ); | |
| 232 | - | |
| 233 | - return NULL; | |
| 234 | - } | |
| 235 | - | |
| 236 | - v3270PropertyAction * action = (v3270PropertyAction *) g_object_new(V3270_TYPE_PROPERTY_ACTION, NULL); | |
| 237 | - | |
| 238 | - action->parent.name = g_param_spec_get_name(pspec); | |
| 239 | - | |
| 240 | - const LIB3270_PROPERTY * lProperty = lib3270_property_get_by_name(pspec->name); | |
| 241 | - if(lProperty) { | |
| 242 | - action->parent.label = lib3270_property_get_label(lProperty); | |
| 243 | - action->parent.tooltip = lib3270_property_get_summary(lProperty); | |
| 244 | -// action->group.id = lProperty->group; | |
| 245 | - } | |
| 246 | - | |
| 247 | - if(!action->parent.tooltip) | |
| 248 | - action->parent.tooltip = g_param_spec_get_blurb(pspec); | |
| 249 | - | |
| 250 | - action->parent.parent.activate = activate; | |
| 251 | - action->pspec = pspec; | |
| 252 | - | |
| 253 | - v3270_action_set_terminal_widget(G_ACTION(action), widget); | |
| 254 | - | |
| 255 | - return G_ACTION(action); | |
| 256 | - } | |
| 257 | - | |
| 258 | - const GVariantType * get_state_type(GAction *object) { | |
| 259 | - | |
| 260 | - v3270PropertyAction * action = V3270_PROPERTY_ACTION(object); | |
| 261 | - | |
| 262 | - if(action->pspec->value_type == G_TYPE_BOOLEAN) | |
| 263 | - return G_VARIANT_TYPE_BOOLEAN; | |
| 264 | - | |
| 265 | - return G_VARIANT_TYPE_STRING; | |
| 266 | - | |
| 267 | - } | |
| 268 | - | |
| 269 | - const GVariantType * get_parameter_type(GAction *object) { | |
| 270 | - | |
| 271 | - v3270PropertyAction * action = V3270_PROPERTY_ACTION(object); | |
| 272 | - | |
| 273 | - if(action->pspec->value_type == G_TYPE_BOOLEAN) | |
| 274 | - return G_VARIANT_TYPE_BOOLEAN; | |
| 275 | - | |
| 276 | - return G_VARIANT_TYPE_STRING; | |
| 277 | - | |
| 278 | - } | |
| 279 | - | |
| 280 | - void change_widget(GAction *object, GtkWidget *from, GtkWidget *to) { | |
| 281 | - | |
| 282 | - v3270PropertyAction * action = V3270_PROPERTY_ACTION(object); | |
| 283 | - g_autofree gchar * signal_name = g_strconcat("notify::", action->pspec->name,NULL); | |
| 284 | - | |
| 285 | - if(from) { | |
| 286 | - gulong handler = g_signal_handler_find( | |
| 287 | - from, | |
| 288 | - G_SIGNAL_MATCH_FUNC|G_SIGNAL_MATCH_DATA, | |
| 289 | - 0, | |
| 290 | - 0, | |
| 291 | - NULL, | |
| 292 | - G_CALLBACK(on_notify), | |
| 293 | - action | |
| 294 | - ); | |
| 295 | - | |
| 296 | - if(handler) | |
| 297 | - g_signal_handler_disconnect(from, handler); | |
| 298 | - | |
| 299 | - } | |
| 300 | - | |
| 301 | - V3270_ACTION_CLASS(v3270PropertyAction_parent_class)->change_widget(object,from,to); | |
| 302 | - | |
| 303 | - if(to) { | |
| 304 | - g_signal_connect(G_OBJECT(to),signal_name,G_CALLBACK(on_notify),action); | |
| 305 | - } | |
| 306 | - | |
| 307 | - } | |
| 308 | - |
src/objects/window/window.c
| ... | ... | @@ -436,7 +436,7 @@ |
| 436 | 436 | |
| 437 | 437 | for(ix = 0; ix < G_N_ELEMENTS(properties); ix++) { |
| 438 | 438 | |
| 439 | - GAction * action = v3270_property_action_new(terminal,properties[ix]); | |
| 439 | + GAction * action = G_ACTION(v3270_property_action_new(terminal,properties[ix])); | |
| 440 | 440 | |
| 441 | 441 | if(!g_action_get_name(action)) { |
| 442 | 442 | g_warning("Window property action %s is unnamed",properties[ix]); | ... | ... |