Commit 0921aee91a646bd2c0c2cf772baecab3d84dae02
1 parent
666e3234
Exists in
master
and in
4 other branches
Saving keypad visibility in session file.
Showing
3 changed files
with
41 additions
and
4 deletions
Show diff stats
src/include/pw3270.h
| @@ -70,6 +70,7 @@ | @@ -70,6 +70,7 @@ | ||
| 70 | 70 | ||
| 71 | const gchar * v3270_get_session_filename(GtkWidget *widget); | 71 | const gchar * v3270_get_session_filename(GtkWidget *widget); |
| 72 | void v3270_set_session_filename(GtkWidget *widget, const gchar *filename); | 72 | void v3270_set_session_filename(GtkWidget *widget, const gchar *filename); |
| 73 | + GKeyFile * v3270_get_session_keyfile(GtkWidget *widget); | ||
| 73 | 74 | ||
| 74 | /// @brief Check if the terminal has a customized session file. | 75 | /// @brief Check if the terminal has a customized session file. |
| 75 | gboolean v3270_allow_custom_settings(GtkWidget *widget); | 76 | gboolean v3270_allow_custom_settings(GtkWidget *widget); |
src/objects/window/terminal.c
| @@ -82,6 +82,7 @@ | @@ -82,6 +82,7 @@ | ||
| 82 | v3270_to_key_file(terminal,session->key_file,"terminal"); | 82 | v3270_to_key_file(terminal,session->key_file,"terminal"); |
| 83 | v3270_accelerator_map_to_key_file(terminal, session->key_file, "accelerators"); | 83 | v3270_accelerator_map_to_key_file(terminal, session->key_file, "accelerators"); |
| 84 | 84 | ||
| 85 | + /* | ||
| 85 | GtkWidget * window = gtk_widget_get_toplevel(terminal); | 86 | GtkWidget * window = gtk_widget_get_toplevel(terminal); |
| 86 | 87 | ||
| 87 | if(PW3270_IS_APPLICATION_WINDOW(window) && pw3270_application_window_get_active_terminal(window) == terminal) { | 88 | if(PW3270_IS_APPLICATION_WINDOW(window) && pw3270_application_window_get_active_terminal(window) == terminal) { |
| @@ -102,6 +103,7 @@ | @@ -102,6 +103,7 @@ | ||
| 102 | } | 103 | } |
| 103 | 104 | ||
| 104 | } | 105 | } |
| 106 | + */ | ||
| 105 | 107 | ||
| 106 | g_key_file_save_to_file(session->key_file,session->filename,NULL); | 108 | g_key_file_save_to_file(session->key_file,session->filename,NULL); |
| 107 | 109 | ||
| @@ -218,6 +220,18 @@ | @@ -218,6 +220,18 @@ | ||
| 218 | 220 | ||
| 219 | } | 221 | } |
| 220 | 222 | ||
| 223 | + GKeyFile * v3270_get_session_keyfile(GtkWidget *widget) { | ||
| 224 | + | ||
| 225 | + g_return_val_if_fail(GTK_IS_V3270(widget),NULL); | ||
| 226 | + | ||
| 227 | + const struct SessionDescriptor * descriptor = (const struct SessionDescriptor *) g_object_get_data(G_OBJECT(widget),"session-descriptor"); | ||
| 228 | + | ||
| 229 | + if(descriptor) | ||
| 230 | + return descriptor->key_file; | ||
| 231 | + | ||
| 232 | + return NULL; | ||
| 233 | + } | ||
| 234 | + | ||
| 221 | GtkWidget * pw3270_terminal_new(const gchar *session_file) { | 235 | GtkWidget * pw3270_terminal_new(const gchar *session_file) { |
| 222 | 236 | ||
| 223 | GtkWidget * terminal = v3270_new(); | 237 | GtkWidget * terminal = v3270_new(); |
src/objects/window/window.c
| @@ -33,6 +33,7 @@ | @@ -33,6 +33,7 @@ | ||
| 33 | #include <pw3270/application.h> | 33 | #include <pw3270/application.h> |
| 34 | #include <pw3270/actions.h> | 34 | #include <pw3270/actions.h> |
| 35 | #include <pw3270/keypad.h> | 35 | #include <pw3270/keypad.h> |
| 36 | + #include <v3270/settings.h> | ||
| 36 | 37 | ||
| 37 | static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); | 38 | static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); |
| 38 | static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); | 39 | static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); |
| @@ -184,12 +185,33 @@ | @@ -184,12 +185,33 @@ | ||
| 184 | 185 | ||
| 185 | } | 186 | } |
| 186 | 187 | ||
| 187 | - static void keypad_hide(GtkWidget *keypad, GObject * model) { | 188 | + static void save_keypad_state(GtkWidget *keypad, GtkWidget *window, gboolean visible) { |
| 189 | + | ||
| 190 | + GtkWidget * terminal = pw3270_application_window_get_active_terminal(window); | ||
| 191 | + if(!terminal) | ||
| 192 | + return; | ||
| 193 | + | ||
| 194 | + GKeyFile * keyfile = v3270_get_session_keyfile(terminal); | ||
| 195 | + if(!terminal) | ||
| 196 | + return; | ||
| 197 | + | ||
| 198 | + g_key_file_set_boolean( | ||
| 199 | + keyfile, | ||
| 200 | + "keypads", | ||
| 201 | + gtk_widget_get_name(keypad), | ||
| 202 | + visible | ||
| 203 | + ); | ||
| 204 | + | ||
| 205 | + v3270_emit_save_settings(terminal); | ||
| 188 | 206 | ||
| 189 | } | 207 | } |
| 190 | 208 | ||
| 191 | - static void keypad_show(GtkWidget *keypad, GObject * model) { | 209 | + static void keypad_hide(GtkWidget *keypad, GtkWidget *window) { |
| 210 | + save_keypad_state(keypad,window,FALSE); | ||
| 211 | + } | ||
| 192 | 212 | ||
| 213 | + static void keypad_show(GtkWidget *keypad, GtkWidget *window) { | ||
| 214 | + save_keypad_state(keypad,window,TRUE); | ||
| 193 | } | 215 | } |
| 194 | 216 | ||
| 195 | static GtkWidget * setup_keypad(pw3270ApplicationWindow *window, GObject * model) { | 217 | static GtkWidget * setup_keypad(pw3270ApplicationWindow *window, GObject * model) { |
| @@ -206,8 +228,8 @@ | @@ -206,8 +228,8 @@ | ||
| 206 | 228 | ||
| 207 | gtk_widget_set_name(widget,name); | 229 | gtk_widget_set_name(widget,name); |
| 208 | 230 | ||
| 209 | - g_signal_connect(widget,"hide",G_CALLBACK(keypad_hide),model); | ||
| 210 | - g_signal_connect(widget,"show",G_CALLBACK(keypad_show),model); | 231 | + g_signal_connect(widget,"hide",G_CALLBACK(keypad_hide),window); |
| 232 | + g_signal_connect(widget,"show",G_CALLBACK(keypad_show),window); | ||
| 211 | 233 | ||
| 212 | g_autofree gchar * action_name = g_strconcat("keypad.",name,NULL); | 234 | g_autofree gchar * action_name = g_strconcat("keypad.",name,NULL); |
| 213 | 235 |