From 9e71aed818c72fe2ab0f80153865af3aa72c184f Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Tue, 12 Nov 2019 15:01:32 -0300 Subject: [PATCH] Adding property and setting option for the LU names list. --- src/dialogs/hostselect.c | 28 +++++++++++++++++++++++++++- src/include/internals.h | 2 +- src/include/terminal.h | 3 ++- src/include/v3270.h | 4 ++++ src/terminal/callbacks.c | 8 +++++++- src/terminal/drawing/oia.c | 5 +++-- src/terminal/properties/get.c | 14 ++++++++++++++ src/terminal/properties/init.c | 27 +++++++++++++++++++++------ src/terminal/properties/private.h | 3 ++- src/terminal/properties/set.c | 13 ++++++++++++- 10 files changed, 93 insertions(+), 14 deletions(-) diff --git a/src/dialogs/hostselect.c b/src/dialogs/hostselect.c index e7dc42a..0780ce8 100644 --- a/src/dialogs/hostselect.c +++ b/src/dialogs/hostselect.c @@ -69,6 +69,7 @@ ENTRY_SRVCNAME, ENTRY_OVERSIZE, ENTRY_REMAP_FILE, + ENTRY_LU_NAMES, ENTRY_COUNT }; @@ -228,7 +229,20 @@ .tooltip = N_("Path to XML file with custom charset mapping."), .max_length = 0xFF, .width_chars = 50, - } + }, + + { + .left = 0, + .top = 2, + .width = 4, + .height = 1, + + .label = N_( "L_U Names" ), + .tooltip = N_("Comma separated list of LU names."), + .max_length = 0xFF, + .width_chars = 50, + }, + }; @@ -439,6 +453,11 @@ static void V3270HostSelectWidget_init(V3270HostSelectWidget *widget) GTK_WIDGET(widget->input.entry[3]) ); + v3270_grid_attach( + GTK_GRID(connection), + (struct v3270_entry_field *) & entryfields[4], + GTK_WIDGET(widget->input.entry[4]) + ); } @@ -626,6 +645,9 @@ static void apply(GtkWidget *w, GtkWidget *terminal) } + // Apply LU names + v3270_set_lunames(terminal,gtk_entry_get_text(widget->input.entry[ENTRY_LU_NAMES])); + // Apply combos. size_t combo; for(combo = 0; combo < G_N_ELEMENTS(combos); combo++) @@ -718,6 +740,10 @@ static void load(GtkWidget *w, GtkWidget *terminal) } + // Load LU names + g_autofree gchar * lunames = v3270_get_lunames(terminal); + gtk_entry_set_text(widget->input.entry[ENTRY_LU_NAMES],lunames ? lunames : ""); + // Load unsigned int combos size_t combo; for(combo = 0; combo < G_N_ELEMENTS(combos); combo++) diff --git a/src/include/internals.h b/src/include/internals.h index abf8f18..5765a77 100644 --- a/src/include/internals.h +++ b/src/include/internals.h @@ -329,7 +329,7 @@ G_GNUC_INTERNAL void v3270_draw_element(cairo_t *cr, unsigned char chr, unsigned G_GNUC_INTERNAL gchar * v3270_translate_rgba_to_text(GdkRGBA *clr); // Properties - G_GNUC_INTERNAL gboolean v3270_update_luname(v3270 *terminal); + G_GNUC_INTERNAL gboolean v3270_update_associated_lu(v3270 *terminal); G_GNUC_INTERNAL void v3270_update_toggle(GtkWidget *widget, LIB3270_TOGGLE_ID id, unsigned char value, const char *name); G_END_DECLS diff --git a/src/include/terminal.h b/src/include/terminal.h index 319f176..a1ba8f9 100644 --- a/src/include/terminal.h +++ b/src/include/terminal.h @@ -47,13 +47,14 @@ G_BEGIN_DECLS // Signal related properties GParamSpec * online; GParamSpec * url; - GParamSpec * luname; + GParamSpec * associated_lu; GParamSpec * model; GParamSpec * selection; GParamSpec * session_name; GParamSpec * auto_disconnect; GParamSpec * remap_file; GParamSpec * dynamic_spacing; + GParamSpec * lu_names; struct { diff --git a/src/include/v3270.h b/src/include/v3270.h index 8b323e6..3af26cd 100644 --- a/src/include/v3270.h +++ b/src/include/v3270.h @@ -186,12 +186,16 @@ LIB3270_EXPORT int v3270_reconnect(GtkWidget *widget); LIB3270_EXPORT void v3270_disconnect(GtkWidget *widget); LIB3270_EXPORT int v3270_set_host_charset(GtkWidget *widget, const gchar *name); + LIB3270_EXPORT void v3270_set_auto_disconnect(GtkWidget *widget, guint minutes); LIB3270_EXPORT guint v3270_get_auto_disconnect(GtkWidget *widget); LIB3270_EXPORT void v3270_set_dynamic_font_spacing(GtkWidget *widget, gboolean state); LIB3270_EXPORT gboolean v3270_get_dynamic_font_spacing(GtkWidget *widget); + LIB3270_EXPORT void v3270_set_lunames(GtkWidget *widget, const gchar *lunames); + LIB3270_EXPORT gchar * v3270_get_lunames(GtkWidget *widget); + // Clipboard typedef enum _v3270_select_format { diff --git a/src/terminal/callbacks.c b/src/terminal/callbacks.c index 6390edb..82d4291 100644 --- a/src/terminal/callbacks.c +++ b/src/terminal/callbacks.c @@ -99,7 +99,7 @@ static void update_message(H3270 *session, G_GNUC_UNUSED LIB3270_MESSAGE id) static void update_luname(H3270 *session, const char G_GNUC_UNUSED(*name)) { - g_idle_add((GSourceFunc) v3270_update_luname, lib3270_get_user_data(session)); + g_idle_add((GSourceFunc) v3270_update_associated_lu, lib3270_get_user_data(session)); } static gboolean v3270_update_url(v3270 *terminal) @@ -171,6 +171,7 @@ static void update_connect(H3270 *session, unsigned char connected) g_signal_emit(GTK_WIDGET(widget), v3270_widget_signal[V3270_SIGNAL_DISCONNECTED], 0); } + debug("%s(%p)",__FUNCTION__,GTK_V3270_GET_CLASS(widget)->properties.online); g_object_notify_by_pspec(G_OBJECT(widget), GTK_V3270_GET_CLASS(widget)->properties.online); widget->activity.timestamp = time(0); @@ -191,7 +192,10 @@ static void update_screen_size(H3270 *session, G_GNUC_UNUSED unsigned short rows static void update_model(H3270 *session, const char *name, int model, G_GNUC_UNUSED int rows, G_GNUC_UNUSED int cols) { GtkWidget * widget = GTK_WIDGET(lib3270_get_user_data(session)); + + debug("%s(%p)",__FUNCTION__,GTK_V3270_GET_CLASS(widget)->properties.model); g_object_notify_by_pspec(G_OBJECT(lib3270_get_user_data(session)), GTK_V3270_GET_CLASS(widget)->properties.model); + g_signal_emit(widget,v3270_widget_signal[V3270_SIGNAL_MODEL_CHANGED], 0, (guint) model, name); } @@ -246,7 +250,9 @@ static void set_selection(H3270 *session, unsigned char status) { GtkWidget * widget = GTK_WIDGET(lib3270_get_user_data(session)); + debug("%s(%p)",__FUNCTION__,GTK_V3270_GET_CLASS(widget)->properties.selection); g_object_notify_by_pspec(G_OBJECT(widget), GTK_V3270_GET_CLASS(widget)->properties.selection); + g_signal_emit(widget,v3270_widget_signal[V3270_SIGNAL_SELECTING], 0, status ? TRUE : FALSE); } diff --git a/src/terminal/drawing/oia.c b/src/terminal/drawing/oia.c index b05bad7..17fc8a0 100644 --- a/src/terminal/drawing/oia.c +++ b/src/terminal/drawing/oia.c @@ -694,7 +694,7 @@ cairo_t * v3270_oia_set_update_region(v3270 * terminal, GdkRectangle **r, V3270_ return cr; } -gboolean v3270_update_luname(v3270 *terminal) +gboolean v3270_update_associated_lu(v3270 *terminal) { if(terminal->surface) { @@ -713,7 +713,8 @@ gboolean v3270_update_luname(v3270 *terminal) v3270_queue_draw_area(GTK_WIDGET(terminal),rect->x,rect->y,rect->width,rect->height); } - g_object_notify_by_pspec(G_OBJECT(terminal), GTK_V3270_GET_CLASS(terminal)->properties.luname); + debug("%s(%p)",__FUNCTION__,GTK_V3270_GET_CLASS(terminal)->properties.associated_lu); + g_object_notify_by_pspec(G_OBJECT(terminal), GTK_V3270_GET_CLASS(terminal)->properties.associated_lu); return FALSE; } diff --git a/src/terminal/properties/get.c b/src/terminal/properties/get.c index 4c2fae0..a5b55b1 100644 --- a/src/terminal/properties/get.c +++ b/src/terminal/properties/get.c @@ -108,6 +108,10 @@ g_value_set_boolean(value,v3270_get_dynamic_font_spacing(GTK_WIDGET(object))); break; + case V3270_PROPERTY_LU_NAMES: + g_value_take_string(value,v3270_get_lunames(GTK_WIDGET(object))); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); @@ -182,5 +186,15 @@ LIB3270_EXPORT guint v3270_get_auto_disconnect(GtkWidget *widget) return GTK_V3270(widget)->activity.disconnect; } +LIB3270_EXPORT gchar * v3270_get_lunames(GtkWidget *widget) +{ + g_return_val_if_fail(GTK_IS_V3270(widget),NULL); + const char ** lunames = lib3270_get_lunames(GTK_V3270(widget)->host); + + if(!lunames) + return NULL; + + return g_strjoinv(",",(gchar **) lunames); +} diff --git a/src/terminal/properties/init.c b/src/terminal/properties/init.c index 17559cb..38f6e48 100644 --- a/src/terminal/properties/init.c +++ b/src/terminal/properties/init.c @@ -40,16 +40,16 @@ const char *name; GParamSpec **prop; } properties[] = { - { "connected", &klass->properties.online }, - { "luname", &klass->properties.luname }, - { "url", &klass->properties.url }, - { "model", &klass->properties.model }, - { "has-selection", &klass->properties.selection }, + { "connected", &klass->properties.online }, + { "associated_lu", &klass->properties.associated_lu }, + { "url", &klass->properties.url }, + { "model", &klass->properties.model }, + { "has_selection", &klass->properties.selection }, }; size_t ix; -// debug("Property %s=%u",g_param_spec_get_name(pspec),(unsigned int) property_id); + debug("Property %s=%u",g_param_spec_get_name(pspec),(unsigned int) property_id); g_object_class_install_property(oclass, property_id, pspec); for(ix = 0; ix < G_N_ELEMENTS(properties); ix++) @@ -166,6 +166,21 @@ klass->properties.dynamic_spacing ); + // Lu names + klass->properties.lu_names = g_param_spec_string( + "lu_names", + "lu_names", + _("Comma separated list of LU names"), + FALSE, + G_PARAM_READABLE|G_PARAM_WRITABLE + ); + + g_object_class_install_property( + gobject_class, + V3270_PROPERTY_LU_NAMES, + klass->properties.lu_names + ); + // // Create dynamic properties diff --git a/src/terminal/properties/private.h b/src/terminal/properties/private.h index 69b3841..708f2c4 100644 --- a/src/terminal/properties/private.h +++ b/src/terminal/properties/private.h @@ -54,9 +54,10 @@ V3270_PROPERTY_AUTO_DISCONNECT = 5, ///< @brief Auto disconnect. V3270_PROPERTY_REMAP_FILE = 6, ///< @brief Path of the remap file. V3270_PROPERTY_DYNAMIC_SPACING = 7, ///< @brief Toggle dynamic font spacing. + V3270_PROPERTY_LU_NAMES = 8, ///< @brief The LU names list. - V3270_PROPERTY_DYNAMIC = 8 ///< @brief Id of the first LIB3270 internal property. + V3270_PROPERTY_DYNAMIC = 9 ///< @brief Id of the first LIB3270 internal property. }; G_GNUC_INTERNAL void v3270_get_property(GObject *object,guint prop_id, GValue *value, GParamSpec *pspec); diff --git a/src/terminal/properties/set.c b/src/terminal/properties/set.c index 51f1f42..16bf1a8 100644 --- a/src/terminal/properties/set.c +++ b/src/terminal/properties/set.c @@ -126,6 +126,10 @@ v3270_set_dynamic_font_spacing(GTK_WIDGET(object), g_value_get_boolean(value)); break; + case V3270_PROPERTY_LU_NAMES: + v3270_set_lunames(GTK_WIDGET(object),g_value_get_string(value)); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); @@ -215,7 +219,8 @@ LIB3270_EXPORT void v3270_set_auto_disconnect(GtkWidget *widget, guint minutes) } -LIB3270_EXPORT void v3270_set_dynamic_font_spacing(GtkWidget *widget, gboolean state) { +LIB3270_EXPORT void v3270_set_dynamic_font_spacing(GtkWidget *widget, gboolean state) +{ g_return_if_fail(GTK_IS_V3270(widget)); @@ -231,4 +236,10 @@ LIB3270_EXPORT void v3270_set_dynamic_font_spacing(GtkWidget *widget, gboolean s } +LIB3270_EXPORT void v3270_set_lunames(GtkWidget *widget, const gchar *lunames) +{ + g_return_if_fail(GTK_IS_V3270(widget)); + lib3270_set_lunames(GTK_V3270(widget)->host,(lunames && *lunames ? lunames : NULL)); + g_object_notify_by_pspec(G_OBJECT(widget), GTK_V3270_GET_CLASS(widget)->properties.lu_names); +} -- libgit2 0.21.2