Commit d72a21f5629a926fcbd1b50a8c5ca3518136b539
1 parent
7a5b4786
Exists in
master
and in
1 other branch
Reimplementing property signals based on lib3270 updates.
Showing
4 changed files
with
48 additions
and
77 deletions
Show diff stats
src/v3270/oia.c
@@ -711,7 +711,7 @@ void v3270_update_luname(GtkWidget *widget,const gchar *name) | @@ -711,7 +711,7 @@ void v3270_update_luname(GtkWidget *widget,const gchar *name) | ||
711 | v3270_queue_draw_area(GTK_WIDGET(terminal),rect->x,rect->y,rect->width,rect->height); | 711 | v3270_queue_draw_area(GTK_WIDGET(terminal),rect->x,rect->y,rect->width,rect->height); |
712 | } | 712 | } |
713 | 713 | ||
714 | -// g_object_notify_by_pspec(G_OBJECT(widget), v3270_properties[PROP_LUNAME]); | 714 | + g_object_notify_by_pspec(G_OBJECT(widget), v3270_properties.luname); |
715 | 715 | ||
716 | } | 716 | } |
717 | 717 |
src/v3270/private.h
@@ -246,6 +246,11 @@ G_BEGIN_DECLS | @@ -246,6 +246,11 @@ G_BEGIN_DECLS | ||
246 | guint str; | 246 | guint str; |
247 | } type; | 247 | } type; |
248 | 248 | ||
249 | + GParamSpec * online; | ||
250 | + GParamSpec * luname; | ||
251 | + GParamSpec * model; | ||
252 | + GParamSpec * selection; | ||
253 | + | ||
249 | } v3270_properties; | 254 | } v3270_properties; |
250 | 255 | ||
251 | 256 |
src/v3270/properties.c
@@ -141,6 +141,36 @@ | @@ -141,6 +141,36 @@ | ||
141 | 141 | ||
142 | } | 142 | } |
143 | 143 | ||
144 | + void v3270_install_property(GObjectClass *oclass, guint property_id, GParamSpec *pspec) | ||
145 | + { | ||
146 | + static const struct | ||
147 | + { | ||
148 | + const char *name; | ||
149 | + GParamSpec **prop; | ||
150 | + } properties[] = { | ||
151 | + { "connected", &v3270_properties.online }, | ||
152 | + { "luname", &v3270_properties.luname }, | ||
153 | + { "model", &v3270_properties.model }, | ||
154 | + { "has-selection", &v3270_properties.selection } | ||
155 | + }; | ||
156 | + | ||
157 | + size_t ix; | ||
158 | + | ||
159 | + debug("Property %s=%u",g_param_spec_get_name(pspec),(unsigned int) property_id); | ||
160 | + g_object_class_install_property(oclass, property_id, pspec); | ||
161 | + | ||
162 | + for(ix = 0; ix < G_N_ELEMENTS(properties); ix++) | ||
163 | + { | ||
164 | + if(!g_ascii_strcasecmp(properties[ix].name,g_param_spec_get_name(pspec))) | ||
165 | + { | ||
166 | + debug("Property \"%s\" is special",g_param_spec_get_name(pspec)); | ||
167 | + *properties[ix].prop = pspec; | ||
168 | + break; | ||
169 | + } | ||
170 | + } | ||
171 | + | ||
172 | + } | ||
173 | + | ||
144 | void v3270_init_properties(GObjectClass * gobject_class) | 174 | void v3270_init_properties(GObjectClass * gobject_class) |
145 | { | 175 | { |
146 | size_t ix; | 176 | size_t ix; |
@@ -185,7 +215,7 @@ | @@ -185,7 +215,7 @@ | ||
185 | { | 215 | { |
186 | debug("Property %u=%s (Toggle)",(unsigned int) v3270_properties.type.toggle + ix, lib3270_get_toggle_name(ix)); | 216 | debug("Property %u=%s (Toggle)",(unsigned int) v3270_properties.type.toggle + ix, lib3270_get_toggle_name(ix)); |
187 | spec = g_param_spec_boolean(lib3270_get_toggle_name(ix),lib3270_get_toggle_name(ix),lib3270_get_toggle_description(ix),FALSE,G_PARAM_WRITABLE|G_PARAM_READABLE); | 217 | spec = g_param_spec_boolean(lib3270_get_toggle_name(ix),lib3270_get_toggle_name(ix),lib3270_get_toggle_description(ix),FALSE,G_PARAM_WRITABLE|G_PARAM_READABLE); |
188 | - g_object_class_install_property(gobject_class, v3270_properties.type.toggle + ix, spec); | 218 | + v3270_install_property(gobject_class, v3270_properties.type.toggle + ix, spec); |
189 | } | 219 | } |
190 | 220 | ||
191 | 221 | ||
@@ -194,7 +224,7 @@ | @@ -194,7 +224,7 @@ | ||
194 | { | 224 | { |
195 | debug("Property %u=%s (Boolean)",(unsigned int) v3270_properties.type.boolean + ix, bool_props[ix].name); | 225 | debug("Property %u=%s (Boolean)",(unsigned int) v3270_properties.type.boolean + ix, bool_props[ix].name); |
196 | spec = g_param_spec_boolean(bool_props[ix].name, bool_props[ix].name, bool_props[ix].description, FALSE,(bool_props[ix].set == NULL ? G_PARAM_READABLE : (G_PARAM_READABLE|G_PARAM_WRITABLE))); | 226 | spec = g_param_spec_boolean(bool_props[ix].name, bool_props[ix].name, bool_props[ix].description, FALSE,(bool_props[ix].set == NULL ? G_PARAM_READABLE : (G_PARAM_READABLE|G_PARAM_WRITABLE))); |
197 | - g_object_class_install_property(gobject_class, v3270_properties.type.boolean + ix, spec); | 227 | + v3270_install_property(gobject_class, v3270_properties.type.boolean + ix, spec); |
198 | 228 | ||
199 | } | 229 | } |
200 | 230 | ||
@@ -213,7 +243,7 @@ | @@ -213,7 +243,7 @@ | ||
213 | (int_props[ix].set == NULL ? G_PARAM_READABLE : (G_PARAM_READABLE|G_PARAM_WRITABLE)) | 243 | (int_props[ix].set == NULL ? G_PARAM_READABLE : (G_PARAM_READABLE|G_PARAM_WRITABLE)) |
214 | ); | 244 | ); |
215 | 245 | ||
216 | - g_object_class_install_property(gobject_class, v3270_properties.type.integer + ix, spec); | 246 | + v3270_install_property(gobject_class, v3270_properties.type.integer + ix, spec); |
217 | 247 | ||
218 | } | 248 | } |
219 | 249 | ||
@@ -222,79 +252,10 @@ | @@ -222,79 +252,10 @@ | ||
222 | { | 252 | { |
223 | debug("Property %u=%s (String)",(unsigned int) v3270_properties.type.str + ix, str_props[ix].name); | 253 | debug("Property %u=%s (String)",(unsigned int) v3270_properties.type.str + ix, str_props[ix].name); |
224 | spec = g_param_spec_string(str_props[ix].name, str_props[ix].name, str_props[ix].description, FALSE,(str_props[ix].set == NULL ? G_PARAM_READABLE : (G_PARAM_READABLE|G_PARAM_WRITABLE))); | 254 | spec = g_param_spec_string(str_props[ix].name, str_props[ix].name, str_props[ix].description, FALSE,(str_props[ix].set == NULL ? G_PARAM_READABLE : (G_PARAM_READABLE|G_PARAM_WRITABLE))); |
225 | - g_object_class_install_property(gobject_class, v3270_properties.type.str + ix, spec); | 255 | + v3270_install_property(gobject_class, v3270_properties.type.str + ix, spec); |
226 | 256 | ||
227 | } | 257 | } |
228 | 258 | ||
229 | - | ||
230 | - /* | ||
231 | - v3270_properties[PROP_ONLINE] = g_param_spec_boolean( | ||
232 | - "online", | ||
233 | - "online", | ||
234 | - "True if is online", | ||
235 | - FALSE,G_PARAM_READABLE); | ||
236 | - g_object_class_install_property(gobject_class,PROP_ONLINE,v3270_properties[PROP_ONLINE]); | ||
237 | - | ||
238 | - v3270_properties[PROP_SELECTION] = g_param_spec_boolean( | ||
239 | - "selection", | ||
240 | - "selection", | ||
241 | - "True on selected area", | ||
242 | - FALSE,G_PARAM_READABLE); | ||
243 | - g_object_class_install_property(gobject_class,PROP_SELECTION,v3270_properties[PROP_SELECTION]); | ||
244 | - | ||
245 | - v3270_properties[PROP_MODEL] = g_param_spec_string( | ||
246 | - "model", | ||
247 | - "model", | ||
248 | - "The model of 3270 display to be emulated", | ||
249 | - NULL, | ||
250 | - G_PARAM_READABLE|G_PARAM_WRITABLE); | ||
251 | - | ||
252 | - g_object_class_install_property(gobject_class,PROP_MODEL,v3270_properties[PROP_MODEL]); | ||
253 | - | ||
254 | - v3270_properties[PROP_LUNAME] = g_param_spec_string( | ||
255 | - "luname", | ||
256 | - "luname", | ||
257 | - "The logical Unit (LU) name", | ||
258 | - NULL, | ||
259 | - G_PARAM_READABLE|G_PARAM_WRITABLE); | ||
260 | - g_object_class_install_property(gobject_class,PROP_LUNAME,v3270_properties[PROP_LUNAME]); | ||
261 | - | ||
262 | - v3270_properties[PROP_AUTO_DISCONNECT] = g_param_spec_uint( | ||
263 | - "auto_disconnect", | ||
264 | - "auto_disconnect", | ||
265 | - "Minutes to disconnect when idle", | ||
266 | - 0, // Minimo | ||
267 | - 3600, // Máximo | ||
268 | - 0, // Default | ||
269 | - G_PARAM_READABLE|G_PARAM_WRITABLE); | ||
270 | - g_object_class_install_property(gobject_class,PROP_AUTO_DISCONNECT,v3270_properties[PROP_AUTO_DISCONNECT]); | ||
271 | - | ||
272 | - v3270_properties[PROP_URL] = g_param_spec_string( | ||
273 | - "url", | ||
274 | - "url", | ||
275 | - "Host URL", | ||
276 | - NULL, | ||
277 | - G_PARAM_READABLE|G_PARAM_WRITABLE); | ||
278 | - g_object_class_install_property(gobject_class,PROP_AUTO_DISCONNECT,v3270_properties[PROP_URL]); | ||
279 | - | ||
280 | - v3270_properties[PROP_SESSION_NAME] = g_param_spec_string( | ||
281 | - "session_name", | ||
282 | - "session_name", | ||
283 | - "The TN3270 Session Name", | ||
284 | - g_get_application_name(), | ||
285 | - G_PARAM_READABLE|G_PARAM_WRITABLE); | ||
286 | - g_object_class_install_property(gobject_class,PROP_SESSION_NAME,v3270_properties[PROP_SESSION_NAME]); | ||
287 | - | ||
288 | - // Toggle properties | ||
289 | - int f; | ||
290 | - | ||
291 | - for(f=0;f<LIB3270_TOGGLE_COUNT;f++) | ||
292 | - { | ||
293 | - 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); | ||
294 | - g_object_class_install_property(gobject_class,PROP_TOGGLE+f,v3270_properties[PROP_TOGGLE+f]); | ||
295 | - } | ||
296 | - debug("%s",__FUNCTION__); | ||
297 | - */ | ||
298 | } | 259 | } |
299 | 260 | ||
300 | void v3270_set_auto_disconnect(GtkWidget *widget, guint minutes) | 261 | void v3270_set_auto_disconnect(GtkWidget *widget, guint minutes) |
src/v3270/widget.c
@@ -782,7 +782,8 @@ static void update_connect(H3270 *session, unsigned char connected) | @@ -782,7 +782,8 @@ static void update_connect(H3270 *session, unsigned char connected) | ||
782 | g_signal_emit(GTK_WIDGET(widget), v3270_widget_signal[SIGNAL_DISCONNECTED], 0); | 782 | g_signal_emit(GTK_WIDGET(widget), v3270_widget_signal[SIGNAL_DISCONNECTED], 0); |
783 | } | 783 | } |
784 | 784 | ||
785 | - // g_object_notify_by_pspec(G_OBJECT(widget), v3270_properties[PROP_ONLINE]); | 785 | + if(v3270_properties.online) |
786 | + g_object_notify_by_pspec(G_OBJECT(widget), v3270_properties.online); | ||
786 | 787 | ||
787 | widget->activity.timestamp = time(0); | 788 | widget->activity.timestamp = time(0); |
788 | 789 | ||
@@ -797,7 +798,9 @@ static void update_screen_size(H3270 *session,unsigned short rows, unsigned shor | @@ -797,7 +798,9 @@ static void update_screen_size(H3270 *session,unsigned short rows, unsigned shor | ||
797 | 798 | ||
798 | static void update_model(H3270 *session, const char *name, int model, int rows, int cols) | 799 | static void update_model(H3270 *session, const char *name, int model, int rows, int cols) |
799 | { | 800 | { |
800 | -// g_object_notify_by_pspec(G_OBJECT(lib3270_get_user_data(session)), v3270_properties[PROP_MODEL]); | 801 | + if(v3270_properties.model) |
802 | + g_object_notify_by_pspec(G_OBJECT(lib3270_get_user_data(session)), v3270_properties.model); | ||
803 | + | ||
801 | g_signal_emit(GTK_WIDGET(lib3270_get_user_data(session)),v3270_widget_signal[SIGNAL_MODEL_CHANGED], 0, (guint) model, name); | 804 | g_signal_emit(GTK_WIDGET(lib3270_get_user_data(session)),v3270_widget_signal[SIGNAL_MODEL_CHANGED], 0, (guint) model, name); |
802 | } | 805 | } |
803 | 806 | ||
@@ -852,7 +855,9 @@ static void set_selection(H3270 *session, unsigned char status) | @@ -852,7 +855,9 @@ static void set_selection(H3270 *session, unsigned char status) | ||
852 | { | 855 | { |
853 | GtkWidget * widget = GTK_WIDGET(lib3270_get_user_data(session)); | 856 | GtkWidget * widget = GTK_WIDGET(lib3270_get_user_data(session)); |
854 | 857 | ||
855 | -// g_object_notify_by_pspec(G_OBJECT(widget), v3270_properties[PROP_SELECTION]); | 858 | + if(v3270_properties.selection) |
859 | + g_object_notify_by_pspec(G_OBJECT(widget), v3270_properties.selection); | ||
860 | + | ||
856 | g_signal_emit(widget,v3270_widget_signal[SIGNAL_SELECTING], 0, status ? TRUE : FALSE); | 861 | g_signal_emit(widget,v3270_widget_signal[SIGNAL_SELECTING], 0, status ? TRUE : FALSE); |
857 | 862 | ||
858 | } | 863 | } |