From 33cbc7b27a141202097352246e51cb21c92c11b0 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Mon, 1 Feb 2021 10:22:59 -0300 Subject: [PATCH] Adding gsetting for default session filename. --- pw3270.cbp | 1 - schemas/linux/application.gschema.xml.in | 6 ++++++ schemas/linux/window.gschema.xml.in | 6 ++++++ src/objects/window/keyfile.c | 22 ++++++++++++++++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/pw3270.cbp b/pw3270.cbp index 3f7af05..ec6206e 100644 --- a/pw3270.cbp +++ b/pw3270.cbp @@ -52,7 +52,6 @@ - diff --git a/schemas/linux/application.gschema.xml.in b/schemas/linux/application.gschema.xml.in index 909b803..e76893e 100644 --- a/schemas/linux/application.gschema.xml.in +++ b/schemas/linux/application.gschema.xml.in @@ -56,6 +56,12 @@ Enable new window actions + + '~/.config/default.3270' + Path of the default session file + + + diff --git a/schemas/linux/window.gschema.xml.in b/schemas/linux/window.gschema.xml.in index 0a1c574..20cc4d5 100644 --- a/schemas/linux/window.gschema.xml.in +++ b/schemas/linux/window.gschema.xml.in @@ -116,6 +116,12 @@ + + '' + Path of the default session file + + + diff --git a/src/objects/window/keyfile.c b/src/objects/window/keyfile.c index 81682d7..ed5d2ea 100644 --- a/src/objects/window/keyfile.c +++ b/src/objects/window/keyfile.c @@ -42,6 +42,7 @@ #include #include #include + #include struct _V3270KeyFile { @@ -276,12 +277,33 @@ void v3270_key_file_close(GtkWidget *terminal) { gchar * v3270_keyfile_get_default_filename(void) { + GSettings *settings = pw3270_application_get_settings(g_application_get_default()); + if(settings) { + + g_autofree gchar * def_key_file = g_settings_get_string(settings,"default-session-file"); + + if(def_key_file && *def_key_file) { + + if(g_file_test(def_key_file,G_FILE_TEST_IS_REGULAR)) + return g_strdup(def_key_file); + + g_autofree gchar * def_key_full = g_build_filename(g_get_user_config_dir(),def_key_file,NULL); + + if(g_file_test(def_key_full,G_FILE_TEST_IS_REGULAR)) + return g_strdup(def_key_full); + } + + } + + // No default key file, use the old scheme. + gchar * filename = g_build_filename(g_get_user_config_dir(),"default.3270",NULL); g_autofree gchar * compatible = g_build_filename(g_get_user_config_dir(),G_STRINGIFY(PRODUCT_NAME) ".conf",NULL); if(g_file_test(compatible,G_FILE_TEST_IS_REGULAR)) g_rename(compatible,filename); + return filename; } -- libgit2 0.21.2