Commit 33b69d2574530311deb46a04f3c28a89fb9479c2
1 parent
32cedac0
Exists in
master
and in
1 other branch
Implementing method to save terminal properties to file.
Showing
10 changed files
with
97 additions
and
69 deletions
Show diff stats
src/include/internals.h
@@ -72,7 +72,7 @@ | @@ -72,7 +72,7 @@ | ||
72 | ENTRY_FIELD_HEAD | 72 | ENTRY_FIELD_HEAD |
73 | }; | 73 | }; |
74 | 74 | ||
75 | -/*--[ Signals ]--------------------------------------------------------------------------------------*/ | 75 | +//--[ Globals ]-------------------------------------------------------------------------------------- |
76 | 76 | ||
77 | /// @brief V3270 Signal list | 77 | /// @brief V3270 Signal list |
78 | enum | 78 | enum |
src/include/terminal.h
@@ -32,6 +32,22 @@ | @@ -32,6 +32,22 @@ | ||
32 | 32 | ||
33 | G_BEGIN_DECLS | 33 | G_BEGIN_DECLS |
34 | 34 | ||
35 | + /// @brief V3270 Properties saved to the configuration file. | ||
36 | + typedef enum | ||
37 | + { | ||
38 | + V3270_SETTING_URL, | ||
39 | + V3270_SETTING_FONT_FAMILY, | ||
40 | + V3270_SETTING_AUTO_DISCONNECT, | ||
41 | + V3270_SETTING_REMAP_FILE, | ||
42 | + V3270_SETTING_DYNAMIC_SPACING, | ||
43 | + V3270_SETTING_LU_NAMES, | ||
44 | + V3270_SETTING_MODEL_NUMBER, | ||
45 | + | ||
46 | + V3270_SETTING_COUNT ///< @brief Number of setting properties. | ||
47 | + } V3270_SETTING; | ||
48 | + | ||
49 | + G_GNUC_INTERNAL void v3270_notify_setting(GtkWidget *widget, V3270_SETTING id); | ||
50 | + | ||
35 | struct _v3270Class | 51 | struct _v3270Class |
36 | { | 52 | { |
37 | GtkWidgetClass parent_class; | 53 | GtkWidgetClass parent_class; |
@@ -41,20 +57,17 @@ G_BEGIN_DECLS | @@ -41,20 +57,17 @@ G_BEGIN_DECLS | ||
41 | 57 | ||
42 | size_t count; // Number of properties. | 58 | size_t count; // Number of properties. |
43 | 59 | ||
44 | - GParamSpec * font_family; | ||
45 | GParamSpec * toggle[LIB3270_TOGGLE_COUNT]; // Toggle properties. | 60 | GParamSpec * toggle[LIB3270_TOGGLE_COUNT]; // Toggle properties. |
46 | 61 | ||
62 | + // Properties saved to the configuration file. | ||
63 | + GParamSpec * settings[V3270_SETTING_COUNT]; | ||
64 | + | ||
47 | // Signal related properties | 65 | // Signal related properties |
48 | GParamSpec * online; | 66 | GParamSpec * online; |
49 | - GParamSpec * url; | ||
50 | GParamSpec * associated_lu; | 67 | GParamSpec * associated_lu; |
51 | GParamSpec * model; | 68 | GParamSpec * model; |
52 | GParamSpec * selection; | 69 | GParamSpec * selection; |
53 | GParamSpec * session_name; | 70 | GParamSpec * session_name; |
54 | - GParamSpec * auto_disconnect; | ||
55 | - GParamSpec * remap_file; | ||
56 | - GParamSpec * dynamic_spacing; | ||
57 | - GParamSpec * lu_names; | ||
58 | GParamSpec * trace; | 71 | GParamSpec * trace; |
59 | 72 | ||
60 | struct | 73 | struct |
src/include/v3270/settings.h
@@ -43,6 +43,14 @@ | @@ -43,6 +43,14 @@ | ||
43 | /// @brief This function adds the terminal settings from widget to key_file. | 43 | /// @brief This function adds the terminal settings from widget to key_file. |
44 | LIB3270_EXPORT void v3270_to_key_file(GtkWidget *widget, GKeyFile *key_file, const gchar *group_name); | 44 | LIB3270_EXPORT void v3270_to_key_file(GtkWidget *widget, GKeyFile *key_file, const gchar *group_name); |
45 | 45 | ||
46 | +#ifdef _WIN32 | ||
47 | + | ||
48 | + LIB3270_EXPORT gboolean v3270_load_registry(GtkWidget *widget, HKEY *key, const gchar *group_name, GError **error); | ||
49 | + | ||
50 | + LIB3270_EXPORT void v3270_to_registry(GtkWidget *widget, HKEY *key, const gchar *group_name); | ||
51 | + | ||
52 | +#endif // _WIN32 | ||
53 | + | ||
46 | /*--[ V3270 Settings Widget ]------------------------------------------------------------------------*/ | 54 | /*--[ V3270 Settings Widget ]------------------------------------------------------------------------*/ |
47 | 55 | ||
48 | #define GTK_TYPE_V3270_SETTINGS (V3270Settings_get_type()) | 56 | #define GTK_TYPE_V3270_SETTINGS (V3270Settings_get_type()) |
src/terminal/callbacks.c
@@ -105,7 +105,7 @@ static void update_luname(H3270 *session, const char G_GNUC_UNUSED(*name)) | @@ -105,7 +105,7 @@ static void update_luname(H3270 *session, const char G_GNUC_UNUSED(*name)) | ||
105 | static gboolean v3270_update_url(v3270 *terminal) | 105 | static gboolean v3270_update_url(v3270 *terminal) |
106 | { | 106 | { |
107 | debug("url=%s",v3270_get_url(GTK_WIDGET(terminal))); | 107 | debug("url=%s",v3270_get_url(GTK_WIDGET(terminal))); |
108 | - g_object_notify_by_pspec(G_OBJECT(terminal), GTK_V3270_GET_CLASS(terminal)->properties.url); | 108 | + v3270_notify_setting(GTK_WIDGET(terminal),V3270_SETTING_URL); |
109 | return FALSE; | 109 | return FALSE; |
110 | } | 110 | } |
111 | 111 |
src/terminal/charset.c
@@ -337,8 +337,8 @@ | @@ -337,8 +337,8 @@ | ||
337 | g_free(cfg.host); | 337 | g_free(cfg.host); |
338 | g_free(cfg.display); | 338 | g_free(cfg.display); |
339 | 339 | ||
340 | - debug("%s=%p",__FUNCTION__,GTK_V3270_GET_CLASS(widget)->properties.remap_file); | ||
341 | - g_object_notify_by_pspec(G_OBJECT(widget), GTK_V3270_GET_CLASS(widget)->properties.remap_file); | 340 | + debug("%s=%p",__FUNCTION__,GTK_V3270_GET_CLASS(widget)->properties.settings[V3270_SETTING_REMAP_FILE]); |
341 | + v3270_notify_setting(widget,V3270_SETTING_REMAP_FILE); | ||
342 | 342 | ||
343 | } | 343 | } |
344 | 344 |
src/terminal/font/properties.c
@@ -107,8 +107,8 @@ LIB3270_EXPORT void v3270_set_font_family(GtkWidget *widget, const gchar *name) | @@ -107,8 +107,8 @@ LIB3270_EXPORT void v3270_set_font_family(GtkWidget *widget, const gchar *name) | ||
107 | 107 | ||
108 | g_signal_emit(widget,v3270_widget_signal[V3270_SIGNAL_UPDATE_CONFIG], 0, "font-family", name); | 108 | g_signal_emit(widget,v3270_widget_signal[V3270_SIGNAL_UPDATE_CONFIG], 0, "font-family", name); |
109 | 109 | ||
110 | - debug("%s: %p",__FUNCTION__,GTK_V3270_GET_CLASS(widget)->properties.font_family); | ||
111 | - g_object_notify_by_pspec(G_OBJECT(widget), GTK_V3270_GET_CLASS(widget)->properties.font_family); | 110 | + debug("%s: %p",__FUNCTION__,GTK_V3270_GET_CLASS(widget)->properties.settings[V3270_SETTING_FONT_FAMILY]); |
111 | + v3270_notify_setting(widget,V3270_SETTING_FONT_FAMILY); | ||
112 | 112 | ||
113 | if(gtk_widget_get_realized(widget) && gtk_widget_get_has_window(widget)) | 113 | if(gtk_widget_get_realized(widget) && gtk_widget_get_has_window(widget)) |
114 | { | 114 | { |
@@ -120,6 +120,12 @@ LIB3270_EXPORT void v3270_set_font_family(GtkWidget *widget, const gchar *name) | @@ -120,6 +120,12 @@ LIB3270_EXPORT void v3270_set_font_family(GtkWidget *widget, const gchar *name) | ||
120 | 120 | ||
121 | } | 121 | } |
122 | 122 | ||
123 | +void v3270_notify_setting(GtkWidget *widget, V3270_SETTING id) | ||
124 | +{ | ||
125 | + g_object_notify_by_pspec(G_OBJECT(widget), GTK_V3270_GET_CLASS(widget)->properties.settings[id]); | ||
126 | + v3270_emit_save_settings(widget); | ||
127 | +} | ||
128 | + | ||
123 | LIB3270_EXPORT const gchar * v3270_get_font_family(GtkWidget *widget) | 129 | LIB3270_EXPORT const gchar * v3270_get_font_family(GtkWidget *widget) |
124 | { | 130 | { |
125 | g_return_val_if_fail(GTK_IS_V3270(widget),NULL); | 131 | g_return_val_if_fail(GTK_IS_V3270(widget),NULL); |
src/terminal/keyfile.c
@@ -179,13 +179,8 @@ | @@ -179,13 +179,8 @@ | ||
179 | save_by_pspec(widget,klass->responses[ix],key_file,group_name); | 179 | save_by_pspec(widget,klass->responses[ix],key_file,group_name); |
180 | 180 | ||
181 | // Save V3270 properties | 181 | // Save V3270 properties |
182 | - save_by_pspec(widget,klass->properties.font_family,key_file,group_name); | ||
183 | - save_by_pspec(widget,klass->properties.url,key_file,group_name); | ||
184 | - save_by_pspec(widget,klass->properties.session_name,key_file,group_name); | ||
185 | - save_by_pspec(widget,klass->properties.auto_disconnect,key_file,group_name); | ||
186 | - save_by_pspec(widget,klass->properties.remap_file,key_file,group_name); | ||
187 | - save_by_pspec(widget,klass->properties.dynamic_spacing,key_file,group_name); | ||
188 | - save_by_pspec(widget,klass->properties.lu_names,key_file,group_name); | 182 | + for(ix = 0; ix < V3270_SETTING_COUNT; ix++) |
183 | + save_by_pspec(widget,klass->properties.settings[ix],key_file,group_name); | ||
189 | 184 | ||
190 | // Save V3270 colors | 185 | // Save V3270 colors |
191 | str = g_string_new(""); | 186 | str = g_string_new(""); |
src/terminal/properties/init.c
@@ -41,11 +41,11 @@ | @@ -41,11 +41,11 @@ | ||
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.url }, | ||
47 | - { "model-number", &klass->properties.model }, | ||
48 | - { "has-selection", &klass->properties.selection }, | 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 | }; | 49 | }; |
50 | 50 | ||
51 | size_t ix; | 51 | size_t ix; |
@@ -77,18 +77,19 @@ | @@ -77,18 +77,19 @@ | ||
77 | // Setup internal properties. | 77 | // Setup internal properties. |
78 | 78 | ||
79 | // Font family | 79 | // Font family |
80 | - klass->properties.font_family = g_param_spec_string( | ||
81 | - "font_family", | ||
82 | - "font_family", | ||
83 | - _("Font family for terminal contents"), | ||
84 | - v3270_get_default_font_name(), | ||
85 | - G_PARAM_READABLE|G_PARAM_WRITABLE | ||
86 | - ); | 80 | + klass->properties.settings[V3270_SETTING_FONT_FAMILY] = |
81 | + g_param_spec_string( | ||
82 | + "font_family", | ||
83 | + "font_family", | ||
84 | + _("Font family for terminal contents"), | ||
85 | + v3270_get_default_font_name(), | ||
86 | + G_PARAM_READABLE|G_PARAM_WRITABLE | ||
87 | + ); | ||
87 | 88 | ||
88 | g_object_class_install_property( | 89 | g_object_class_install_property( |
89 | gobject_class, | 90 | gobject_class, |
90 | V3270_PROPERTY_FONT_FAMILY, | 91 | V3270_PROPERTY_FONT_FAMILY, |
91 | - klass->properties.font_family | 92 | + klass->properties.settings[V3270_SETTING_FONT_FAMILY] |
92 | ); | 93 | ); |
93 | 94 | ||
94 | // Session name. | 95 | // Session name. |
@@ -107,20 +108,21 @@ | @@ -107,20 +108,21 @@ | ||
107 | ); | 108 | ); |
108 | 109 | ||
109 | // Auto disconnect | 110 | // Auto disconnect |
110 | - klass->properties.auto_disconnect = g_param_spec_uint( | ||
111 | - "auto_disconnect", | ||
112 | - "auto_disconnect", | ||
113 | - _("IDLE minutes for automatic disconnection"), | ||
114 | - 0, | ||
115 | - G_MAXUINT, | ||
116 | - 0, | ||
117 | - G_PARAM_READABLE|G_PARAM_WRITABLE | ||
118 | - ); | 111 | + klass->properties.settings[V3270_SETTING_AUTO_DISCONNECT] = |
112 | + g_param_spec_uint( | ||
113 | + "auto_disconnect", | ||
114 | + "auto_disconnect", | ||
115 | + _("IDLE minutes for automatic disconnection"), | ||
116 | + 0, | ||
117 | + G_MAXUINT, | ||
118 | + 0, | ||
119 | + G_PARAM_READABLE|G_PARAM_WRITABLE | ||
120 | + ); | ||
119 | 121 | ||
120 | g_object_class_install_property( | 122 | g_object_class_install_property( |
121 | gobject_class, | 123 | gobject_class, |
122 | V3270_PROPERTY_AUTO_DISCONNECT, | 124 | V3270_PROPERTY_AUTO_DISCONNECT, |
123 | - klass->properties.auto_disconnect | 125 | + klass->properties.settings[V3270_SETTING_AUTO_DISCONNECT] |
124 | ); | 126 | ); |
125 | 127 | ||
126 | // Clipboard | 128 | // Clipboard |
@@ -139,47 +141,51 @@ | @@ -139,47 +141,51 @@ | ||
139 | ); | 141 | ); |
140 | 142 | ||
141 | // Remap file | 143 | // Remap file |
142 | - klass->properties.remap_file = g_param_spec_string( | ||
143 | - "remap_file", | ||
144 | - "remap_file", | ||
145 | - _("XML file with remap table"), | ||
146 | - FALSE, | ||
147 | - G_PARAM_READABLE|G_PARAM_WRITABLE | ||
148 | - ); | 144 | + klass->properties.settings[V3270_SETTING_REMAP_FILE] = |
145 | + g_param_spec_string( | ||
146 | + "remap_file", | ||
147 | + "remap_file", | ||
148 | + _("XML file with remap table"), | ||
149 | + FALSE, | ||
150 | + G_PARAM_READABLE|G_PARAM_WRITABLE | ||
151 | + ); | ||
149 | 152 | ||
150 | g_object_class_install_property( | 153 | g_object_class_install_property( |
151 | gobject_class, | 154 | gobject_class, |
152 | V3270_PROPERTY_REMAP_FILE, | 155 | V3270_PROPERTY_REMAP_FILE, |
153 | - klass->properties.remap_file | 156 | + klass->properties.settings[V3270_SETTING_REMAP_FILE] |
154 | ); | 157 | ); |
155 | 158 | ||
156 | // Dynamic font spacing | 159 | // Dynamic font spacing |
157 | - klass->properties.dynamic_spacing = g_param_spec_boolean( | ||
158 | - "dynamic_font_spacing", | ||
159 | - "dynamic_font_spacing", | ||
160 | - _( "State of the dynamic font spacing" ), | ||
161 | - FALSE, | ||
162 | - G_PARAM_READABLE|G_PARAM_WRITABLE); | 160 | + klass->properties.settings[V3270_SETTING_DYNAMIC_SPACING] = |
161 | + g_param_spec_boolean( | ||
162 | + "dynamic_font_spacing", | ||
163 | + "dynamic_font_spacing", | ||
164 | + _( "State of the dynamic font spacing" ), | ||
165 | + FALSE, | ||
166 | + G_PARAM_READABLE|G_PARAM_WRITABLE | ||
167 | + ); | ||
163 | 168 | ||
164 | g_object_class_install_property( | 169 | g_object_class_install_property( |
165 | gobject_class, | 170 | gobject_class, |
166 | V3270_PROPERTY_DYNAMIC_SPACING, | 171 | V3270_PROPERTY_DYNAMIC_SPACING, |
167 | - klass->properties.dynamic_spacing | 172 | + klass->properties.settings[V3270_SETTING_DYNAMIC_SPACING] |
168 | ); | 173 | ); |
169 | 174 | ||
170 | // Lu names | 175 | // Lu names |
171 | - klass->properties.lu_names = g_param_spec_string( | ||
172 | - "lu_names", | ||
173 | - "lu_names", | ||
174 | - _("Comma separated list of LU names"), | ||
175 | - FALSE, | ||
176 | - G_PARAM_READABLE|G_PARAM_WRITABLE | ||
177 | - ); | 176 | + klass->properties.settings[V3270_SETTING_LU_NAMES] = |
177 | + g_param_spec_string( | ||
178 | + "lu_names", | ||
179 | + "lu_names", | ||
180 | + _("Comma separated list of LU names"), | ||
181 | + NULL, | ||
182 | + G_PARAM_READABLE|G_PARAM_WRITABLE | ||
183 | + ); | ||
178 | 184 | ||
179 | g_object_class_install_property( | 185 | g_object_class_install_property( |
180 | gobject_class, | 186 | gobject_class, |
181 | V3270_PROPERTY_LU_NAMES, | 187 | V3270_PROPERTY_LU_NAMES, |
182 | - klass->properties.lu_names | 188 | + klass->properties.settings[V3270_SETTING_LU_NAMES] |
183 | ); | 189 | ); |
184 | 190 | ||
185 | // Trace | 191 | // Trace |
src/terminal/properties/private.h
@@ -61,7 +61,7 @@ | @@ -61,7 +61,7 @@ | ||
61 | V3270_PROPERTY_DYNAMIC = 10 ///< @brief Id of the first LIB3270 internal property. | 61 | V3270_PROPERTY_DYNAMIC = 10 ///< @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); |
65 | G_GNUC_INTERNAL void v3270_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); | 65 | G_GNUC_INTERNAL void v3270_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); |
66 | 66 | ||
67 | 67 |
src/terminal/properties/set.c
@@ -219,7 +219,7 @@ LIB3270_EXPORT void v3270_set_auto_disconnect(GtkWidget *widget, guint minutes) | @@ -219,7 +219,7 @@ LIB3270_EXPORT void v3270_set_auto_disconnect(GtkWidget *widget, guint minutes) | ||
219 | if(terminal->activity.disconnect != minutes) | 219 | if(terminal->activity.disconnect != minutes) |
220 | { | 220 | { |
221 | terminal->activity.disconnect = minutes; | 221 | terminal->activity.disconnect = minutes; |
222 | - g_object_notify_by_pspec(G_OBJECT(widget), GTK_V3270_GET_CLASS(widget)->properties.auto_disconnect); | 222 | + v3270_notify_setting(widget,V3270_SETTING_AUTO_DISCONNECT); |
223 | } | 223 | } |
224 | 224 | ||
225 | } | 225 | } |
@@ -236,7 +236,7 @@ LIB3270_EXPORT void v3270_set_dynamic_font_spacing(GtkWidget *widget, gboolean s | @@ -236,7 +236,7 @@ LIB3270_EXPORT void v3270_set_dynamic_font_spacing(GtkWidget *widget, gboolean s | ||
236 | terminal->font.spacing.dynamic = state; | 236 | terminal->font.spacing.dynamic = state; |
237 | v3270_reconfigure(terminal); | 237 | v3270_reconfigure(terminal); |
238 | gtk_widget_queue_draw(widget); | 238 | gtk_widget_queue_draw(widget); |
239 | - g_object_notify_by_pspec(G_OBJECT(widget), GTK_V3270_GET_CLASS(widget)->properties.dynamic_spacing); | 239 | + v3270_notify_setting(widget,V3270_SETTING_DYNAMIC_SPACING); |
240 | } | 240 | } |
241 | 241 | ||
242 | } | 242 | } |
@@ -245,6 +245,6 @@ LIB3270_EXPORT void v3270_set_lunames(GtkWidget *widget, const gchar *lunames) | @@ -245,6 +245,6 @@ LIB3270_EXPORT void v3270_set_lunames(GtkWidget *widget, const gchar *lunames) | ||
245 | { | 245 | { |
246 | g_return_if_fail(GTK_IS_V3270(widget)); | 246 | g_return_if_fail(GTK_IS_V3270(widget)); |
247 | lib3270_set_lunames(GTK_V3270(widget)->host,(lunames && *lunames ? lunames : NULL)); | 247 | lib3270_set_lunames(GTK_V3270(widget)->host,(lunames && *lunames ? lunames : NULL)); |
248 | - g_object_notify_by_pspec(G_OBJECT(widget), GTK_V3270_GET_CLASS(widget)->properties.lu_names); | 248 | + v3270_notify_setting(widget,V3270_SETTING_LU_NAMES); |
249 | } | 249 | } |
250 | 250 |