Commit 1087372a78c72e3429f10202e28f662258ff6e52
1 parent
40c5ed32
Exists in
master
and in
1 other branch
Color theme are now standard widget properties.
The CRL preferred download protocol can now be set from configuration file or windows registry.
Showing
7 changed files
with
74 additions
and
48 deletions
Show diff stats
src/include/terminal.h
@@ -47,6 +47,8 @@ G_BEGIN_DECLS | @@ -47,6 +47,8 @@ G_BEGIN_DECLS | ||
47 | V3270_SETTING_UNLOCK_DELAY, | 47 | V3270_SETTING_UNLOCK_DELAY, |
48 | V3270_SETTING_COLOR_TYPE, | 48 | V3270_SETTING_COLOR_TYPE, |
49 | V3270_SETTING_HOST_TYPE, | 49 | V3270_SETTING_HOST_TYPE, |
50 | + V3270_SETTING_CRL_PROTOCOL, | ||
51 | + V3270_SETTING_TERMINAL_COLORS, | ||
50 | 52 | ||
51 | V3270_SETTING_COUNT ///< @brief Number of setting properties. | 53 | V3270_SETTING_COUNT ///< @brief Number of setting properties. |
52 | } V3270_SETTING; | 54 | } V3270_SETTING; |
src/terminal/keyfile.c
@@ -39,6 +39,12 @@ | @@ -39,6 +39,12 @@ | ||
39 | 39 | ||
40 | static void save_by_pspec(GtkWidget *widget, GParamSpec *pspec, GKeyFile *key_file, const gchar *group_name) | 40 | static void save_by_pspec(GtkWidget *widget, GParamSpec *pspec, GKeyFile *key_file, const gchar *group_name) |
41 | { | 41 | { |
42 | + if(!pspec) | ||
43 | + { | ||
44 | + g_warning("Invalid property"); | ||
45 | + return; | ||
46 | + } | ||
47 | + | ||
42 | const gchar * name = g_param_spec_get_name(pspec); | 48 | const gchar * name = g_param_spec_get_name(pspec); |
43 | GValue value = G_VALUE_INIT; | 49 | GValue value = G_VALUE_INIT; |
44 | 50 | ||
@@ -162,6 +168,12 @@ | @@ -162,6 +168,12 @@ | ||
162 | 168 | ||
163 | static void load_by_pspec(GtkWidget *widget, GParamSpec *pspec, GKeyFile *key_file, const gchar *group_name) | 169 | static void load_by_pspec(GtkWidget *widget, GParamSpec *pspec, GKeyFile *key_file, const gchar *group_name) |
164 | { | 170 | { |
171 | + if(!pspec) | ||
172 | + { | ||
173 | + g_warning("Invalid property"); | ||
174 | + return; | ||
175 | + } | ||
176 | + | ||
165 | const gchar * name = g_param_spec_get_name(pspec); | 177 | const gchar * name = g_param_spec_get_name(pspec); |
166 | GError * error = NULL; | 178 | GError * error = NULL; |
167 | 179 | ||
@@ -214,8 +226,6 @@ | @@ -214,8 +226,6 @@ | ||
214 | g_return_if_fail(GTK_IS_V3270(widget)); | 226 | g_return_if_fail(GTK_IS_V3270(widget)); |
215 | 227 | ||
216 | size_t ix; | 228 | size_t ix; |
217 | - GString * str; | ||
218 | - | ||
219 | v3270 * terminal = GTK_V3270(widget); | 229 | v3270 * terminal = GTK_V3270(widget); |
220 | v3270Class * klass = GTK_V3270_GET_CLASS(widget); | 230 | v3270Class * klass = GTK_V3270_GET_CLASS(widget); |
221 | 231 | ||
@@ -231,24 +241,6 @@ | @@ -231,24 +241,6 @@ | ||
231 | for(ix = 0; ix < V3270_SETTING_COUNT; ix++) | 241 | for(ix = 0; ix < V3270_SETTING_COUNT; ix++) |
232 | save_by_pspec(widget,klass->properties.settings[ix],key_file,group_name); | 242 | save_by_pspec(widget,klass->properties.settings[ix],key_file,group_name); |
233 | 243 | ||
234 | - // Save V3270 colors | ||
235 | - str = g_string_new(""); | ||
236 | - for(ix=0; ix<V3270_COLOR_COUNT; ix++) | ||
237 | - { | ||
238 | - if(ix) | ||
239 | - g_string_append_c(str,';'); | ||
240 | - g_string_append_printf(str,"%s",gdk_rgba_to_string(v3270_get_color(widget,ix))); | ||
241 | - } | ||
242 | - | ||
243 | - g_key_file_set_string( | ||
244 | - key_file, | ||
245 | - group_name, | ||
246 | - "colors", | ||
247 | - str->str | ||
248 | - ); | ||
249 | - | ||
250 | - g_string_free(str,TRUE); | ||
251 | - | ||
252 | } | 244 | } |
253 | 245 | ||
254 | /// @brief This function adds the terminal settings from widget to key_file. | 246 | /// @brief This function adds the terminal settings from widget to key_file. |
@@ -275,9 +267,6 @@ | @@ -275,9 +267,6 @@ | ||
275 | for(ix = 0; ix < V3270_SETTING_COUNT; ix++) | 267 | for(ix = 0; ix < V3270_SETTING_COUNT; ix++) |
276 | load_by_pspec(widget,klass->properties.settings[ix],key_file,group_name); | 268 | load_by_pspec(widget,klass->properties.settings[ix],key_file,group_name); |
277 | 269 | ||
278 | - // Load V3270 colors | ||
279 | - v3270_set_colors(widget,g_key_file_get_string(key_file,group_name,"colors",NULL)); | ||
280 | - | ||
281 | g_object_thaw_notify(G_OBJECT(widget)); | 270 | g_object_thaw_notify(G_OBJECT(widget)); |
282 | 271 | ||
283 | return TRUE; | 272 | return TRUE; |
src/terminal/properties/get.c
@@ -121,6 +121,22 @@ | @@ -121,6 +121,22 @@ | ||
121 | g_value_set_boolean(value,v3270_get_trace(GTK_WIDGET(object))); | 121 | g_value_set_boolean(value,v3270_get_trace(GTK_WIDGET(object))); |
122 | break; | 122 | break; |
123 | 123 | ||
124 | + case V3270_PROPERTY_TERMINAL_COLORS: | ||
125 | + { | ||
126 | + size_t ix; | ||
127 | + GString * str = g_string_new(""); | ||
128 | + for(ix=0; ix<V3270_COLOR_COUNT; ix++) | ||
129 | + { | ||
130 | + if(ix) | ||
131 | + g_string_append_c(str,';'); | ||
132 | + g_string_append_printf(str,"%s",gdk_rgba_to_string(v3270_get_color(GTK_WIDGET(object),ix))); | ||
133 | + } | ||
134 | + | ||
135 | + g_value_take_string(value,g_string_free(str,FALSE)); | ||
136 | + | ||
137 | + } | ||
138 | + break; | ||
139 | + | ||
124 | default: | 140 | default: |
125 | G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); | 141 | G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); |
126 | 142 |
src/terminal/properties/init.c
@@ -41,16 +41,17 @@ | @@ -41,16 +41,17 @@ | ||
41 | const char *name; | 41 | const char *name; |
42 | GParamSpec **prop; | 42 | GParamSpec **prop; |
43 | } properties[] = { | 43 | } properties[] = { |
44 | - { "connected", &klass->properties.online }, | ||
45 | - { "associated-lu", &klass->properties.associated_lu }, | ||
46 | - { "url", &klass->properties.settings[V3270_SETTING_URL] }, | ||
47 | - { "model-number", &klass->properties.settings[V3270_SETTING_MODEL_NUMBER] }, | ||
48 | - { "has-selection", &klass->properties.selection }, | ||
49 | - { "oversize", &klass->properties.settings[V3270_SETTING_OVERSIZE] }, | ||
50 | - { "host-charset", &klass->properties.settings[V3270_SETTING_HOST_CHARSET] }, | ||
51 | - { "unlock-delay", &klass->properties.settings[V3270_SETTING_UNLOCK_DELAY] }, | ||
52 | - { "color-type", &klass->properties.settings[V3270_SETTING_COLOR_TYPE] }, | ||
53 | - { "host-type", &klass->properties.settings[V3270_SETTING_HOST_TYPE] }, | 44 | + { "connected", &klass->properties.online }, |
45 | + { "associated-lu", &klass->properties.associated_lu }, | ||
46 | + { "url", &klass->properties.settings[V3270_SETTING_URL] }, | ||
47 | + { "model-number", &klass->properties.settings[V3270_SETTING_MODEL_NUMBER] }, | ||
48 | + { "has-selection", &klass->properties.selection }, | ||
49 | + { "oversize", &klass->properties.settings[V3270_SETTING_OVERSIZE] }, | ||
50 | + { "host-charset", &klass->properties.settings[V3270_SETTING_HOST_CHARSET] }, | ||
51 | + { "unlock-delay", &klass->properties.settings[V3270_SETTING_UNLOCK_DELAY] }, | ||
52 | + { "color-type", &klass->properties.settings[V3270_SETTING_COLOR_TYPE] }, | ||
53 | + { "host-type", &klass->properties.settings[V3270_SETTING_HOST_TYPE] }, | ||
54 | + { "crl-preferred-protocol", &klass->properties.settings[V3270_SETTING_CRL_PROTOCOL] }, | ||
54 | }; | 55 | }; |
55 | 56 | ||
56 | size_t ix; | 57 | size_t ix; |
@@ -207,6 +208,21 @@ | @@ -207,6 +208,21 @@ | ||
207 | klass->properties.trace | 208 | klass->properties.trace |
208 | ); | 209 | ); |
209 | 210 | ||
211 | + // Colors | ||
212 | + klass->properties.settings[V3270_SETTING_TERMINAL_COLORS] = | ||
213 | + g_param_spec_string( | ||
214 | + "colors", | ||
215 | + "colors", | ||
216 | + _("The terminal colors"), | ||
217 | + v3270_default_colors, | ||
218 | + G_PARAM_READABLE|G_PARAM_WRITABLE | ||
219 | + ); | ||
220 | + | ||
221 | + g_object_class_install_property( | ||
222 | + gobject_class, | ||
223 | + V3270_PROPERTY_TERMINAL_COLORS, | ||
224 | + klass->properties.settings[V3270_SETTING_TERMINAL_COLORS] | ||
225 | + ); | ||
210 | 226 | ||
211 | // | 227 | // |
212 | // Create dynamic properties | 228 | // Create dynamic properties |
src/terminal/properties/private.h
@@ -56,9 +56,9 @@ | @@ -56,9 +56,9 @@ | ||
56 | V3270_PROPERTY_DYNAMIC_SPACING = 7, ///< @brief Toggle dynamic font spacing. | 56 | V3270_PROPERTY_DYNAMIC_SPACING = 7, ///< @brief Toggle dynamic font spacing. |
57 | V3270_PROPERTY_LU_NAMES = 8, ///< @brief The LU names list. | 57 | V3270_PROPERTY_LU_NAMES = 8, ///< @brief The LU names list. |
58 | V3270_PROPERTY_TRACE = 9, ///< @brief Is the trace widget active? | 58 | V3270_PROPERTY_TRACE = 9, ///< @brief Is the trace widget active? |
59 | + V3270_PROPERTY_TERMINAL_COLORS = 10, ///< @brief Terminal colors. | ||
59 | 60 | ||
60 | - | ||
61 | - V3270_PROPERTY_DYNAMIC = 10 ///< @brief Id of the first LIB3270 internal property. | 61 | + V3270_PROPERTY_DYNAMIC = 11 ///< @brief Id of the first LIB3270 internal property. |
62 | }; | 62 | }; |
63 | 63 | ||
64 | G_GNUC_INTERNAL void v3270_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); | 64 | G_GNUC_INTERNAL void v3270_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); |
src/terminal/properties/set.c
@@ -135,6 +135,10 @@ | @@ -135,6 +135,10 @@ | ||
135 | v3270_set_trace(GTK_WIDGET(object), g_value_get_boolean(value)); | 135 | v3270_set_trace(GTK_WIDGET(object), g_value_get_boolean(value)); |
136 | break; | 136 | break; |
137 | 137 | ||
138 | + case V3270_PROPERTY_TERMINAL_COLORS: | ||
139 | + v3270_set_colors(GTK_WIDGET(object),g_value_get_string(value)); | ||
140 | + break; | ||
141 | + | ||
138 | default: | 142 | default: |
139 | G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); | 143 | G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); |
140 | 144 |
src/terminal/windows/registry.c
@@ -41,6 +41,12 @@ | @@ -41,6 +41,12 @@ | ||
41 | 41 | ||
42 | static void save_by_pspec(GtkWidget *widget, GParamSpec *pspec, HKEY hKey) | 42 | static void save_by_pspec(GtkWidget *widget, GParamSpec *pspec, HKEY hKey) |
43 | { | 43 | { |
44 | + if(!pspec) | ||
45 | + { | ||
46 | + g_warning("Invalid property"); | ||
47 | + return; | ||
48 | + } | ||
49 | + | ||
44 | const gchar * name = g_param_spec_get_name(pspec); | 50 | const gchar * name = g_param_spec_get_name(pspec); |
45 | 51 | ||
46 | GValue value = G_VALUE_INIT; | 52 | GValue value = G_VALUE_INIT; |
@@ -127,6 +133,12 @@ | @@ -127,6 +133,12 @@ | ||
127 | 133 | ||
128 | static void load_by_pspec(GtkWidget *widget, GParamSpec *pspec, HKEY hKey) | 134 | static void load_by_pspec(GtkWidget *widget, GParamSpec *pspec, HKEY hKey) |
129 | { | 135 | { |
136 | + if(!pspec) | ||
137 | + { | ||
138 | + g_warning("Invalid property"); | ||
139 | + return; | ||
140 | + } | ||
141 | + | ||
130 | const gchar * name = g_param_spec_get_name(pspec); | 142 | const gchar * name = g_param_spec_get_name(pspec); |
131 | 143 | ||
132 | BYTE data[4097]; | 144 | BYTE data[4097]; |
@@ -210,19 +222,6 @@ | @@ -210,19 +222,6 @@ | ||
210 | for(ix = 0; ix < V3270_SETTING_COUNT; ix++) | 222 | for(ix = 0; ix < V3270_SETTING_COUNT; ix++) |
211 | save_by_pspec(widget,klass->properties.settings[ix],hKey); | 223 | save_by_pspec(widget,klass->properties.settings[ix],hKey); |
212 | 224 | ||
213 | - // Save V3270 colors | ||
214 | - str = g_string_new(""); | ||
215 | - for(ix=0; ix<V3270_COLOR_COUNT; ix++) | ||
216 | - { | ||
217 | - if(ix) | ||
218 | - g_string_append_c(str,';'); | ||
219 | - g_string_append_printf(str,"%s",gdk_rgba_to_string(v3270_get_color(widget,ix))); | ||
220 | - } | ||
221 | - | ||
222 | - RegSetValueEx(hKey,"colors",0,REG_SZ,(const BYTE *) str->str,strlen(str->str)+1); | ||
223 | - | ||
224 | - g_string_free(str,TRUE); | ||
225 | - | ||
226 | RegCloseKey(hKey); | 225 | RegCloseKey(hKey); |
227 | 226 | ||
228 | } | 227 | } |