Commit 33cbc7b27a141202097352246e51cb21c92c11b0
1 parent
de3713cb
Exists in
master
and in
2 other branches
Adding gsetting for default session filename.
Showing
4 changed files
with
34 additions
and
1 deletions
Show diff stats
pw3270.cbp
| @@ -52,7 +52,6 @@ | @@ -52,7 +52,6 @@ | ||
| 52 | <Unit filename="src/include/pw3270/keypad.h" /> | 52 | <Unit filename="src/include/pw3270/keypad.h" /> |
| 53 | <Unit filename="src/include/pw3270/settings.h" /> | 53 | <Unit filename="src/include/pw3270/settings.h" /> |
| 54 | <Unit filename="src/include/pw3270/toolbar.h" /> | 54 | <Unit filename="src/include/pw3270/toolbar.h" /> |
| 55 | - <Unit filename="src/include/pw3270/tools.h" /> | ||
| 56 | <Unit filename="src/include/pw3270/window.h" /> | 55 | <Unit filename="src/include/pw3270/window.h" /> |
| 57 | <Unit filename="src/include/v3270/keyfile.h" /> | 56 | <Unit filename="src/include/v3270/keyfile.h" /> |
| 58 | <Unit filename="src/main/main.c"> | 57 | <Unit filename="src/main/main.c"> |
schemas/linux/application.gschema.xml.in
| @@ -56,6 +56,12 @@ | @@ -56,6 +56,12 @@ | ||
| 56 | <description>Enable new window actions</description> | 56 | <description>Enable new window actions</description> |
| 57 | </key> | 57 | </key> |
| 58 | 58 | ||
| 59 | + <key name="default-session-file" type="s"> | ||
| 60 | + <default>'~/.config/default.3270'</default> | ||
| 61 | + <summary>Path of the default session file</summary> | ||
| 62 | + <description></description> | ||
| 63 | + </key> | ||
| 64 | + | ||
| 59 | </schema> | 65 | </schema> |
| 60 | 66 | ||
| 61 | </schemalist> | 67 | </schemalist> |
schemas/linux/window.gschema.xml.in
| @@ -116,6 +116,12 @@ | @@ -116,6 +116,12 @@ | ||
| 116 | <description></description> | 116 | <description></description> |
| 117 | </key> | 117 | </key> |
| 118 | 118 | ||
| 119 | + <key name="default-session-file" type="s"> | ||
| 120 | + <default>''</default> | ||
| 121 | + <summary>Path of the default session file</summary> | ||
| 122 | + <description></description> | ||
| 123 | + </key> | ||
| 124 | + | ||
| 119 | </schema> | 125 | </schema> |
| 120 | 126 | ||
| 121 | </schemalist> | 127 | </schemalist> |
src/objects/window/keyfile.c
| @@ -42,6 +42,7 @@ | @@ -42,6 +42,7 @@ | ||
| 42 | #include <lib3270/properties.h> | 42 | #include <lib3270/properties.h> |
| 43 | #include <string.h> | 43 | #include <string.h> |
| 44 | #include <stdlib.h> | 44 | #include <stdlib.h> |
| 45 | + #include <pw3270/application.h> | ||
| 45 | 46 | ||
| 46 | struct _V3270KeyFile | 47 | struct _V3270KeyFile |
| 47 | { | 48 | { |
| @@ -276,12 +277,33 @@ void v3270_key_file_close(GtkWidget *terminal) { | @@ -276,12 +277,33 @@ void v3270_key_file_close(GtkWidget *terminal) { | ||
| 276 | 277 | ||
| 277 | gchar * v3270_keyfile_get_default_filename(void) { | 278 | gchar * v3270_keyfile_get_default_filename(void) { |
| 278 | 279 | ||
| 280 | + GSettings *settings = pw3270_application_get_settings(g_application_get_default()); | ||
| 281 | + if(settings) { | ||
| 282 | + | ||
| 283 | + g_autofree gchar * def_key_file = g_settings_get_string(settings,"default-session-file"); | ||
| 284 | + | ||
| 285 | + if(def_key_file && *def_key_file) { | ||
| 286 | + | ||
| 287 | + if(g_file_test(def_key_file,G_FILE_TEST_IS_REGULAR)) | ||
| 288 | + return g_strdup(def_key_file); | ||
| 289 | + | ||
| 290 | + g_autofree gchar * def_key_full = g_build_filename(g_get_user_config_dir(),def_key_file,NULL); | ||
| 291 | + | ||
| 292 | + if(g_file_test(def_key_full,G_FILE_TEST_IS_REGULAR)) | ||
| 293 | + return g_strdup(def_key_full); | ||
| 294 | + } | ||
| 295 | + | ||
| 296 | + } | ||
| 297 | + | ||
| 298 | + // No default key file, use the old scheme. | ||
| 299 | + | ||
| 279 | gchar * filename = g_build_filename(g_get_user_config_dir(),"default.3270",NULL); | 300 | gchar * filename = g_build_filename(g_get_user_config_dir(),"default.3270",NULL); |
| 280 | 301 | ||
| 281 | g_autofree gchar * compatible = g_build_filename(g_get_user_config_dir(),G_STRINGIFY(PRODUCT_NAME) ".conf",NULL); | 302 | g_autofree gchar * compatible = g_build_filename(g_get_user_config_dir(),G_STRINGIFY(PRODUCT_NAME) ".conf",NULL); |
| 282 | if(g_file_test(compatible,G_FILE_TEST_IS_REGULAR)) | 303 | if(g_file_test(compatible,G_FILE_TEST_IS_REGULAR)) |
| 283 | g_rename(compatible,filename); | 304 | g_rename(compatible,filename); |
| 284 | 305 | ||
| 306 | + | ||
| 285 | return filename; | 307 | return filename; |
| 286 | } | 308 | } |
| 287 | 309 |