Commit a04b1cb76fd560ecd28c874b8e031ea143e93571

Authored by Perry Werneck
1 parent 0c8d5710
Exists in master and in 1 other branch develop

Exporting session name as object property.

src/include/terminal.h
@@ -55,6 +55,7 @@ G_BEGIN_DECLS @@ -55,6 +55,7 @@ G_BEGIN_DECLS
55 guint toggle; 55 guint toggle;
56 guint boolean; 56 guint boolean;
57 guint integer; 57 guint integer;
  58 + guint uint;
58 guint str; 59 guint str;
59 } type; 60 } type;
60 61
src/terminal/properties.c
@@ -45,9 +45,13 @@ @@ -45,9 +45,13 @@
45 #include <v3270.h> 45 #include <v3270.h>
46 #include <terminal.h> 46 #include <terminal.h>
47 47
48 - #define PROP_FONT_FAMILY 2  
49 - #define PROP_CLIPBOARD 3  
50 - #define PROP_DYNAMIC 4 48 + enum _v3270_internal_property
  49 + {
  50 + V3270_PROPERTY_FONT_FAMILY = 2, ///< @brief Name of the font-family used by widget.
  51 + V3270_PROPERTY_CLIPBOARD = 3, ///< @brief Name of the selected clipboard.
  52 + V3270_PROPERTY_SESSION_NAME = 4, ///< @brief Widget's session name.
  53 + V3270_PROPERTY_DYNAMIC = 5 ///< @brief Id of the first LIB3270 internal property.
  54 + };
51 55
52 /*--[ Implement ]------------------------------------------------------------------------------------*/ 56 /*--[ Implement ]------------------------------------------------------------------------------------*/
53 57
@@ -67,6 +71,15 @@ @@ -67,6 +71,15 @@
67 prop->set(window->host,g_value_get_string(value)); 71 prop->set(window->host,g_value_get_string(value));
68 72
69 } 73 }
  74 + else if(prop_id >= klass->properties.type.uint)
  75 + {
  76 + const LIB3270_UINT_PROPERTY * prop = (lib3270_get_unsigned_properties_list()+(prop_id - klass->properties.type.uint));
  77 + debug("%s.%s.%s",__FUNCTION__,"unsigned",prop->name);
  78 +
  79 + if(prop->set)
  80 + prop->set(window->host,g_value_get_uint(value));
  81 +
  82 + }
70 else if(prop_id >= klass->properties.type.integer) 83 else if(prop_id >= klass->properties.type.integer)
71 { 84 {
72 const LIB3270_INT_PROPERTY * prop = (lib3270_get_int_properties_list()+(prop_id - klass->properties.type.integer)); 85 const LIB3270_INT_PROPERTY * prop = (lib3270_get_int_properties_list()+(prop_id - klass->properties.type.integer));
@@ -91,39 +104,47 @@ @@ -91,39 +104,47 @@
91 lib3270_set_toggle(window->host,prop_id - klass->properties.type.toggle, (int) g_value_get_boolean (value)); 104 lib3270_set_toggle(window->host,prop_id - klass->properties.type.toggle, (int) g_value_get_boolean (value));
92 105
93 } 106 }
  107 + else
  108 + {
  109 + // Check for internal properties.
  110 + switch(prop_id) {
  111 + case V3270_PROPERTY_FONT_FAMILY: // Font-family
  112 + v3270_set_font_family(GTK_WIDGET(object), g_value_get_string(value));
  113 + break;
94 114
95 - // Check for internal properties.  
96 - switch(prop_id) {  
97 - case PROP_FONT_FAMILY: // Font-family  
98 - v3270_set_font_family(GTK_WIDGET(object), g_value_get_string(value));  
99 - break;  
100 -  
101 - case PROP_CLIPBOARD: // Clipboard  
102 - {  
103 - const gchar * name = g_value_get_string(value);  
104 - if(!*name) {  
105 - g_message("Setting default clipboard");  
106 - window->selection.target = GDK_SELECTION_CLIPBOARD;  
107 - }  
108 - else 115 + case V3270_PROPERTY_CLIPBOARD: // Clipboard
109 { 116 {
110 - GdkAtom clipboard = gdk_atom_intern(name,TRUE);  
111 - if(clipboard == GDK_NONE)  
112 - {  
113 - g_warning("\"%s\" is not a valid clipboard name",name); 117 + const gchar * name = g_value_get_string(value);
  118 + if(!*name) {
  119 + g_message("Setting default clipboard");
  120 + window->selection.target = GDK_SELECTION_CLIPBOARD;
114 } 121 }
115 else 122 else
116 - {  
117 - window->selection.target = clipboard; 123 + {
  124 + GdkAtom clipboard = gdk_atom_intern(name,TRUE);
  125 + if(clipboard == GDK_NONE)
  126 + {
  127 + g_warning("\"%s\" is not a valid clipboard name",name);
  128 + }
  129 + else
  130 + {
  131 + window->selection.target = clipboard;
  132 + }
118 } 133 }
119 } 134 }
  135 + break;
  136 +
  137 + case V3270_PROPERTY_SESSION_NAME: // Session Name
  138 + v3270_set_session_name(GTK_WIDGET(object), g_value_get_string(value));
  139 + break;
  140 +
  141 + default:
  142 + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
  143 +
120 } 144 }
121 - break;  
122 145
123 - default:  
124 - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); 146 + }
125 147
126 - }  
127 148
128 } 149 }
129 150
@@ -143,6 +164,15 @@ @@ -143,6 +164,15 @@
143 g_value_set_string(value,prop->get(window->host)); 164 g_value_set_string(value,prop->get(window->host));
144 165
145 } 166 }
  167 + else if(prop_id >= klass->properties.type.uint)
  168 + {
  169 + const LIB3270_UINT_PROPERTY * prop = (lib3270_get_unsigned_properties_list()+(prop_id - klass->properties.type.uint));
  170 + debug("%s.%s.%s",__FUNCTION__,"unsigned",prop->name);
  171 +
  172 + if(prop->get)
  173 + g_value_set_uint(value,prop->get(window->host));
  174 +
  175 + }
146 else if(prop_id >= klass->properties.type.integer) 176 else if(prop_id >= klass->properties.type.integer)
147 { 177 {
148 const LIB3270_INT_PROPERTY * prop = (lib3270_get_int_properties_list()+(prop_id - klass->properties.type.integer)); 178 const LIB3270_INT_PROPERTY * prop = (lib3270_get_int_properties_list()+(prop_id - klass->properties.type.integer));
@@ -167,23 +197,27 @@ @@ -167,23 +197,27 @@
167 g_value_set_boolean(value,lib3270_get_toggle(window->host,prop_id - klass->properties.type.toggle) ? TRUE : FALSE ); 197 g_value_set_boolean(value,lib3270_get_toggle(window->host,prop_id - klass->properties.type.toggle) ? TRUE : FALSE );
168 198
169 } 199 }
  200 + else
  201 + {
  202 + // Check for internal properties.
  203 + switch(prop_id) {
  204 + case V3270_PROPERTY_FONT_FAMILY: // Font-family
  205 + g_value_set_string(value,v3270_get_font_family(GTK_WIDGET(object)));
  206 + break;
170 207
171 - // Check for internal properties.  
172 - switch(prop_id) {  
173 - case PROP_FONT_FAMILY: // Font-family  
174 - g_value_set_string(value,v3270_get_font_family(GTK_WIDGET(object)));  
175 - break;  
176 -  
177 - case PROP_CLIPBOARD: // Clipboard  
178 - g_value_take_string(value,gdk_atom_name(window->selection.target));  
179 - break;  
180 -  
181 - default:  
182 - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); 208 + case V3270_PROPERTY_CLIPBOARD: // Clipboard
  209 + g_value_take_string(value,gdk_atom_name(window->selection.target));
  210 + break;
183 211
184 - } 212 + case V3270_PROPERTY_SESSION_NAME:
  213 + g_value_set_string(value,v3270_get_session_name(GTK_WIDGET(object)));
  214 + break;
185 215
  216 + default:
  217 + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
186 218
  219 + }
  220 + }
187 221
188 } 222 }
189 223
@@ -243,10 +277,25 @@ @@ -243,10 +277,25 @@
243 277
244 g_object_class_install_property( 278 g_object_class_install_property(
245 gobject_class, 279 gobject_class,
246 - PROP_FONT_FAMILY, 280 + V3270_PROPERTY_FONT_FAMILY,
247 klass->properties.font_family 281 klass->properties.font_family
248 ); 282 );
249 283
  284 + // Session name.
  285 + spec = g_param_spec_string(
  286 + "session_name",
  287 + "session_name",
  288 + _("TN3270 Session name"),
  289 + FALSE,
  290 + G_PARAM_READABLE|G_PARAM_WRITABLE
  291 + );
  292 +
  293 + g_object_class_install_property(
  294 + gobject_class,
  295 + V3270_PROPERTY_SESSION_NAME,
  296 + spec
  297 + );
  298 +
250 // Clipboard 299 // Clipboard
251 spec = g_param_spec_string( 300 spec = g_param_spec_string(
252 "clipboard", 301 "clipboard",
@@ -258,14 +307,13 @@ @@ -258,14 +307,13 @@
258 307
259 g_object_class_install_property( 308 g_object_class_install_property(
260 gobject_class, 309 gobject_class,
261 - PROP_CLIPBOARD, 310 + V3270_PROPERTY_CLIPBOARD,
262 spec 311 spec
263 ); 312 );
264 313
265 // 314 //
266 // Create dynamic properties 315 // Create dynamic properties
267 - klass->properties.count = PROP_DYNAMIC;  
268 - 316 + klass->properties.count = V3270_PROPERTY_DYNAMIC;
269 317
270 // 318 //
271 // Extract properties from LIB3270 control tables 319 // Extract properties from LIB3270 control tables
@@ -308,7 +356,7 @@ @@ -308,7 +356,7 @@
308 356
309 } 357 }
310 358
311 - // Creating integer properties. 359 + // Creating signed integer properties.
312 const LIB3270_INT_PROPERTY * int_props = lib3270_get_int_properties_list(); 360 const LIB3270_INT_PROPERTY * int_props = lib3270_get_int_properties_list();
313 klass->properties.type.integer = klass->properties.count; 361 klass->properties.type.integer = klass->properties.count;
314 362
@@ -325,11 +373,28 @@ @@ -325,11 +373,28 @@
325 0, // Default 373 0, // Default
326 (int_props[ix].set == NULL ? G_PARAM_READABLE : (G_PARAM_READABLE|G_PARAM_WRITABLE)) 374 (int_props[ix].set == NULL ? G_PARAM_READABLE : (G_PARAM_READABLE|G_PARAM_WRITABLE))
327 ); 375 );
328 - debug("Creating %u properties", (unsigned int) klass->properties.count);  
329 376
  377 + v3270_install_property(gobject_class, klass->properties.count++, spec);
  378 +
  379 + }
330 380
  381 + // Creating unsigned integer properties.
  382 + const LIB3270_UINT_PROPERTY * uint_props = lib3270_get_unsigned_properties_list();
  383 + klass->properties.type.uint = klass->properties.count;
331 384
  385 + for(ix = 0; uint_props[ix].name; ix++)
  386 + {
  387 + debug("Property %u=%s (unsigned)",(unsigned int) klass->properties.type.integer + ix, uint_props[ix].name);
332 388
  389 + spec = g_param_spec_uint(
  390 + uint_props[ix].name,
  391 + uint_props[ix].name,
  392 + uint_props[ix].description,
  393 + 0, // Minimo
  394 + UINT_MAX, // Máximo
  395 + 0, // Default
  396 + (uint_props[ix].set == NULL ? G_PARAM_READABLE : (G_PARAM_READABLE|G_PARAM_WRITABLE))
  397 + );
333 398
334 v3270_install_property(gobject_class, klass->properties.count++, spec); 399 v3270_install_property(gobject_class, klass->properties.count++, spec);
335 400
src/trace/exec.c
@@ -98,6 +98,13 @@ @@ -98,6 +98,13 @@
98 } 98 }
99 break; 99 break;
100 100
  101 + case G_TYPE_UINT:
  102 + {
  103 + g_value_set_uint(&val,atoi(value));
  104 + g_object_set_property(G_OBJECT(widget),name,&val);
  105 + }
  106 + break;
  107 +
101 default: 108 default:
102 lib3270_write_trace(v3270_get_session(widget),"%s has an unexpected value type\n",spec->name); 109 lib3270_write_trace(v3270_get_session(widget),"%s has an unexpected value type\n",spec->name);
103 110
@@ -135,6 +142,10 @@ @@ -135,6 +142,10 @@
135 lib3270_write_trace(v3270_get_session(widget),"%s=%d\n",spec->name,g_value_get_int(&val)); 142 lib3270_write_trace(v3270_get_session(widget),"%s=%d\n",spec->name,g_value_get_int(&val));
136 break; 143 break;
137 144
  145 + case G_TYPE_UINT:
  146 + lib3270_write_trace(v3270_get_session(widget),"%s=%u\n",spec->name,g_value_get_uint(&val));
  147 + break;
  148 +
138 default: 149 default:
139 lib3270_write_trace(v3270_get_session(widget),"%s has an unexpected value type\n",spec->name); 150 lib3270_write_trace(v3270_get_session(widget),"%s has an unexpected value type\n",spec->name);
140 151