Commit 9e71aed818c72fe2ab0f80153865af3aa72c184f

Authored by Perry Werneck
1 parent 67274bb2
Exists in master and in 1 other branch develop

Adding property and setting option for the LU names list.

src/dialogs/hostselect.c
... ... @@ -69,6 +69,7 @@
69 69 ENTRY_SRVCNAME,
70 70 ENTRY_OVERSIZE,
71 71 ENTRY_REMAP_FILE,
  72 + ENTRY_LU_NAMES,
72 73  
73 74 ENTRY_COUNT
74 75 };
... ... @@ -228,7 +229,20 @@
228 229 .tooltip = N_("Path to XML file with custom charset mapping."),
229 230 .max_length = 0xFF,
230 231 .width_chars = 50,
231   - }
  232 + },
  233 +
  234 + {
  235 + .left = 0,
  236 + .top = 2,
  237 + .width = 4,
  238 + .height = 1,
  239 +
  240 + .label = N_( "L_U Names" ),
  241 + .tooltip = N_("Comma separated list of LU names."),
  242 + .max_length = 0xFF,
  243 + .width_chars = 50,
  244 + },
  245 +
232 246  
233 247 };
234 248  
... ... @@ -439,6 +453,11 @@ static void V3270HostSelectWidget_init(V3270HostSelectWidget *widget)
439 453 GTK_WIDGET(widget->input.entry[3])
440 454 );
441 455  
  456 + v3270_grid_attach(
  457 + GTK_GRID(connection),
  458 + (struct v3270_entry_field *) & entryfields[4],
  459 + GTK_WIDGET(widget->input.entry[4])
  460 + );
442 461  
443 462 }
444 463  
... ... @@ -626,6 +645,9 @@ static void apply(GtkWidget *w, GtkWidget *terminal)
626 645  
627 646 }
628 647  
  648 + // Apply LU names
  649 + v3270_set_lunames(terminal,gtk_entry_get_text(widget->input.entry[ENTRY_LU_NAMES]));
  650 +
629 651 // Apply combos.
630 652 size_t combo;
631 653 for(combo = 0; combo < G_N_ELEMENTS(combos); combo++)
... ... @@ -718,6 +740,10 @@ static void load(GtkWidget *w, GtkWidget *terminal)
718 740  
719 741 }
720 742  
  743 + // Load LU names
  744 + g_autofree gchar * lunames = v3270_get_lunames(terminal);
  745 + gtk_entry_set_text(widget->input.entry[ENTRY_LU_NAMES],lunames ? lunames : "");
  746 +
721 747 // Load unsigned int combos
722 748 size_t combo;
723 749 for(combo = 0; combo < G_N_ELEMENTS(combos); combo++)
... ...
src/include/internals.h
... ... @@ -329,7 +329,7 @@ G_GNUC_INTERNAL void v3270_draw_element(cairo_t *cr, unsigned char chr, unsigned
329 329 G_GNUC_INTERNAL gchar * v3270_translate_rgba_to_text(GdkRGBA *clr);
330 330  
331 331 // Properties
332   - G_GNUC_INTERNAL gboolean v3270_update_luname(v3270 *terminal);
  332 + G_GNUC_INTERNAL gboolean v3270_update_associated_lu(v3270 *terminal);
333 333 G_GNUC_INTERNAL void v3270_update_toggle(GtkWidget *widget, LIB3270_TOGGLE_ID id, unsigned char value, const char *name);
334 334  
335 335 G_END_DECLS
... ...
src/include/terminal.h
... ... @@ -47,13 +47,14 @@ G_BEGIN_DECLS
47 47 // Signal related properties
48 48 GParamSpec * online;
49 49 GParamSpec * url;
50   - GParamSpec * luname;
  50 + GParamSpec * associated_lu;
51 51 GParamSpec * model;
52 52 GParamSpec * selection;
53 53 GParamSpec * session_name;
54 54 GParamSpec * auto_disconnect;
55 55 GParamSpec * remap_file;
56 56 GParamSpec * dynamic_spacing;
  57 + GParamSpec * lu_names;
57 58  
58 59 struct
59 60 {
... ...
src/include/v3270.h
... ... @@ -186,12 +186,16 @@
186 186 LIB3270_EXPORT int v3270_reconnect(GtkWidget *widget);
187 187 LIB3270_EXPORT void v3270_disconnect(GtkWidget *widget);
188 188 LIB3270_EXPORT int v3270_set_host_charset(GtkWidget *widget, const gchar *name);
  189 +
189 190 LIB3270_EXPORT void v3270_set_auto_disconnect(GtkWidget *widget, guint minutes);
190 191 LIB3270_EXPORT guint v3270_get_auto_disconnect(GtkWidget *widget);
191 192  
192 193 LIB3270_EXPORT void v3270_set_dynamic_font_spacing(GtkWidget *widget, gboolean state);
193 194 LIB3270_EXPORT gboolean v3270_get_dynamic_font_spacing(GtkWidget *widget);
194 195  
  196 + LIB3270_EXPORT void v3270_set_lunames(GtkWidget *widget, const gchar *lunames);
  197 + LIB3270_EXPORT gchar * v3270_get_lunames(GtkWidget *widget);
  198 +
195 199 // Clipboard
196 200 typedef enum _v3270_select_format
197 201 {
... ...
src/terminal/callbacks.c
... ... @@ -99,7 +99,7 @@ static void update_message(H3270 *session, G_GNUC_UNUSED LIB3270_MESSAGE id)
99 99  
100 100 static void update_luname(H3270 *session, const char G_GNUC_UNUSED(*name))
101 101 {
102   - g_idle_add((GSourceFunc) v3270_update_luname, lib3270_get_user_data(session));
  102 + g_idle_add((GSourceFunc) v3270_update_associated_lu, lib3270_get_user_data(session));
103 103 }
104 104  
105 105 static gboolean v3270_update_url(v3270 *terminal)
... ... @@ -171,6 +171,7 @@ static void update_connect(H3270 *session, unsigned char connected)
171 171 g_signal_emit(GTK_WIDGET(widget), v3270_widget_signal[V3270_SIGNAL_DISCONNECTED], 0);
172 172 }
173 173  
  174 + debug("%s(%p)",__FUNCTION__,GTK_V3270_GET_CLASS(widget)->properties.online);
174 175 g_object_notify_by_pspec(G_OBJECT(widget), GTK_V3270_GET_CLASS(widget)->properties.online);
175 176  
176 177 widget->activity.timestamp = time(0);
... ... @@ -191,7 +192,10 @@ static void update_screen_size(H3270 *session, G_GNUC_UNUSED unsigned short rows
191 192 static void update_model(H3270 *session, const char *name, int model, G_GNUC_UNUSED int rows, G_GNUC_UNUSED int cols)
192 193 {
193 194 GtkWidget * widget = GTK_WIDGET(lib3270_get_user_data(session));
  195 +
  196 + debug("%s(%p)",__FUNCTION__,GTK_V3270_GET_CLASS(widget)->properties.model);
194 197 g_object_notify_by_pspec(G_OBJECT(lib3270_get_user_data(session)), GTK_V3270_GET_CLASS(widget)->properties.model);
  198 +
195 199 g_signal_emit(widget,v3270_widget_signal[V3270_SIGNAL_MODEL_CHANGED], 0, (guint) model, name);
196 200 }
197 201  
... ... @@ -246,7 +250,9 @@ static void set_selection(H3270 *session, unsigned char status)
246 250 {
247 251 GtkWidget * widget = GTK_WIDGET(lib3270_get_user_data(session));
248 252  
  253 + debug("%s(%p)",__FUNCTION__,GTK_V3270_GET_CLASS(widget)->properties.selection);
249 254 g_object_notify_by_pspec(G_OBJECT(widget), GTK_V3270_GET_CLASS(widget)->properties.selection);
  255 +
250 256 g_signal_emit(widget,v3270_widget_signal[V3270_SIGNAL_SELECTING], 0, status ? TRUE : FALSE);
251 257  
252 258 }
... ...
src/terminal/drawing/oia.c
... ... @@ -694,7 +694,7 @@ cairo_t * v3270_oia_set_update_region(v3270 * terminal, GdkRectangle **r, V3270_
694 694 return cr;
695 695 }
696 696  
697   -gboolean v3270_update_luname(v3270 *terminal)
  697 +gboolean v3270_update_associated_lu(v3270 *terminal)
698 698 {
699 699 if(terminal->surface)
700 700 {
... ... @@ -713,7 +713,8 @@ gboolean v3270_update_luname(v3270 *terminal)
713 713 v3270_queue_draw_area(GTK_WIDGET(terminal),rect->x,rect->y,rect->width,rect->height);
714 714 }
715 715  
716   - g_object_notify_by_pspec(G_OBJECT(terminal), GTK_V3270_GET_CLASS(terminal)->properties.luname);
  716 + debug("%s(%p)",__FUNCTION__,GTK_V3270_GET_CLASS(terminal)->properties.associated_lu);
  717 + g_object_notify_by_pspec(G_OBJECT(terminal), GTK_V3270_GET_CLASS(terminal)->properties.associated_lu);
717 718  
718 719 return FALSE;
719 720 }
... ...
src/terminal/properties/get.c
... ... @@ -108,6 +108,10 @@
108 108 g_value_set_boolean(value,v3270_get_dynamic_font_spacing(GTK_WIDGET(object)));
109 109 break;
110 110  
  111 + case V3270_PROPERTY_LU_NAMES:
  112 + g_value_take_string(value,v3270_get_lunames(GTK_WIDGET(object)));
  113 + break;
  114 +
111 115 default:
112 116 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
113 117  
... ... @@ -182,5 +186,15 @@ LIB3270_EXPORT guint v3270_get_auto_disconnect(GtkWidget *widget)
182 186 return GTK_V3270(widget)->activity.disconnect;
183 187 }
184 188  
  189 +LIB3270_EXPORT gchar * v3270_get_lunames(GtkWidget *widget)
  190 +{
  191 + g_return_val_if_fail(GTK_IS_V3270(widget),NULL);
185 192  
  193 + const char ** lunames = lib3270_get_lunames(GTK_V3270(widget)->host);
  194 +
  195 + if(!lunames)
  196 + return NULL;
  197 +
  198 + return g_strjoinv(",",(gchar **) lunames);
  199 +}
186 200  
... ...
src/terminal/properties/init.c
... ... @@ -40,16 +40,16 @@
40 40 const char *name;
41 41 GParamSpec **prop;
42 42 } properties[] = {
43   - { "connected", &klass->properties.online },
44   - { "luname", &klass->properties.luname },
45   - { "url", &klass->properties.url },
46   - { "model", &klass->properties.model },
47   - { "has-selection", &klass->properties.selection },
  43 + { "connected", &klass->properties.online },
  44 + { "associated_lu", &klass->properties.associated_lu },
  45 + { "url", &klass->properties.url },
  46 + { "model", &klass->properties.model },
  47 + { "has_selection", &klass->properties.selection },
48 48 };
49 49  
50 50 size_t ix;
51 51  
52   -// debug("Property %s=%u",g_param_spec_get_name(pspec),(unsigned int) property_id);
  52 + debug("Property %s=%u",g_param_spec_get_name(pspec),(unsigned int) property_id);
53 53 g_object_class_install_property(oclass, property_id, pspec);
54 54  
55 55 for(ix = 0; ix < G_N_ELEMENTS(properties); ix++)
... ... @@ -166,6 +166,21 @@
166 166 klass->properties.dynamic_spacing
167 167 );
168 168  
  169 + // Lu names
  170 + klass->properties.lu_names = g_param_spec_string(
  171 + "lu_names",
  172 + "lu_names",
  173 + _("Comma separated list of LU names"),
  174 + FALSE,
  175 + G_PARAM_READABLE|G_PARAM_WRITABLE
  176 + );
  177 +
  178 + g_object_class_install_property(
  179 + gobject_class,
  180 + V3270_PROPERTY_LU_NAMES,
  181 + klass->properties.lu_names
  182 + );
  183 +
169 184  
170 185 //
171 186 // Create dynamic properties
... ...
src/terminal/properties/private.h
... ... @@ -54,9 +54,10 @@
54 54 V3270_PROPERTY_AUTO_DISCONNECT = 5, ///< @brief Auto disconnect.
55 55 V3270_PROPERTY_REMAP_FILE = 6, ///< @brief Path of the remap file.
56 56 V3270_PROPERTY_DYNAMIC_SPACING = 7, ///< @brief Toggle dynamic font spacing.
  57 + V3270_PROPERTY_LU_NAMES = 8, ///< @brief The LU names list.
57 58  
58 59  
59   - V3270_PROPERTY_DYNAMIC = 8 ///< @brief Id of the first LIB3270 internal property.
  60 + V3270_PROPERTY_DYNAMIC = 9 ///< @brief Id of the first LIB3270 internal property.
60 61 };
61 62  
62 63 G_GNUC_INTERNAL void v3270_get_property(GObject *object,guint prop_id, GValue *value, GParamSpec *pspec);
... ...
src/terminal/properties/set.c
... ... @@ -126,6 +126,10 @@
126 126 v3270_set_dynamic_font_spacing(GTK_WIDGET(object), g_value_get_boolean(value));
127 127 break;
128 128  
  129 + case V3270_PROPERTY_LU_NAMES:
  130 + v3270_set_lunames(GTK_WIDGET(object),g_value_get_string(value));
  131 + break;
  132 +
129 133 default:
130 134 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
131 135  
... ... @@ -215,7 +219,8 @@ LIB3270_EXPORT void v3270_set_auto_disconnect(GtkWidget *widget, guint minutes)
215 219  
216 220 }
217 221  
218   -LIB3270_EXPORT void v3270_set_dynamic_font_spacing(GtkWidget *widget, gboolean state) {
  222 +LIB3270_EXPORT void v3270_set_dynamic_font_spacing(GtkWidget *widget, gboolean state)
  223 +{
219 224  
220 225 g_return_if_fail(GTK_IS_V3270(widget));
221 226  
... ... @@ -231,4 +236,10 @@ LIB3270_EXPORT void v3270_set_dynamic_font_spacing(GtkWidget *widget, gboolean s
231 236  
232 237 }
233 238  
  239 +LIB3270_EXPORT void v3270_set_lunames(GtkWidget *widget, const gchar *lunames)
  240 +{
  241 + g_return_if_fail(GTK_IS_V3270(widget));
  242 + lib3270_set_lunames(GTK_V3270(widget)->host,(lunames && *lunames ? lunames : NULL));
  243 + g_object_notify_by_pspec(G_OBJECT(widget), GTK_V3270_GET_CLASS(widget)->properties.lu_names);
  244 +}
234 245  
... ...