Commit 4dc56fc50c8c2d76da61a4e5359394105ee2c48a
1 parent
90c07611
Exists in
master
and in
2 other branches
Fixing startup with URL instead of session file
Fixing search for default settings.
Showing
2 changed files
with
70 additions
and
15 deletions
Show diff stats
src/objects/application/open.c
| ... | ... | @@ -91,6 +91,14 @@ |
| 91 | 91 | if(sz > 0 && uri[sz-1] == '/') |
| 92 | 92 | uri[sz-1] = 0; |
| 93 | 93 | |
| 94 | + if(!window) { | |
| 95 | + debug("%s: Creating new window",__FUNCTION__); | |
| 96 | + window = pw3270_application_window_new(GTK_APPLICATION(application), NULL); | |
| 97 | + } else { | |
| 98 | + debug("%s: Creating new tab",__FUNCTION__); | |
| 99 | + window = pw3270_application_window_new_tab(window, NULL); | |
| 100 | + } | |
| 101 | + | |
| 94 | 102 | v3270_set_url(pw3270_application_window_get_active_terminal(window),uri); |
| 95 | 103 | |
| 96 | 104 | } | ... | ... |
src/objects/window/keyfile.c
| ... | ... | @@ -75,6 +75,67 @@ |
| 75 | 75 | g_free(session); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | + static void search_for_defaults(V3270KeyFile *session) { | |
| 79 | + | |
| 80 | + GError *error = NULL; | |
| 81 | + size_t ix; | |
| 82 | + | |
| 83 | + // Search for user defaults. | |
| 84 | + static const gchar *usernames[] = { | |
| 85 | + "defaults.3270", | |
| 86 | + "default.3270", | |
| 87 | + }; | |
| 88 | + | |
| 89 | + for(ix = 0; ix < G_N_ELEMENTS(usernames);ix++) { | |
| 90 | + | |
| 91 | + g_autofree gchar * default_settings = g_build_filename(g_get_user_config_dir(),usernames[ix],NULL); | |
| 92 | + | |
| 93 | +#ifdef DEBUG | |
| 94 | + g_message("Searching for %s", default_settings); | |
| 95 | +#endif // DEBUG | |
| 96 | + | |
| 97 | + if(g_file_test(default_settings,G_FILE_TEST_IS_REGULAR)) { | |
| 98 | + if(!g_key_file_load_from_file(session->key_file,default_settings,G_KEY_FILE_NONE,&error)) { | |
| 99 | + g_warning("Can't load \"%s\": %s",default_settings,error->message); | |
| 100 | + g_error_free(error); | |
| 101 | + } else { | |
| 102 | + g_message("Loading session preferences from %s",default_settings); | |
| 103 | + } | |
| 104 | + } | |
| 105 | + | |
| 106 | + } | |
| 107 | + | |
| 108 | + // Search for system defaults. | |
| 109 | + static const gchar *sysnames[] = { | |
| 110 | + "defaults.3270", | |
| 111 | + "default.3270", | |
| 112 | + "defaults.conf", | |
| 113 | + "default.conf", | |
| 114 | + }; | |
| 115 | + | |
| 116 | + for(ix = 0; ix < G_N_ELEMENTS(sysnames);ix++) { | |
| 117 | + | |
| 118 | + lib3270_autoptr(char) default_settings = lib3270_build_data_filename(sysnames[ix],NULL); | |
| 119 | + | |
| 120 | +#ifdef DEBUG | |
| 121 | + g_message("Searching for %s", default_settings); | |
| 122 | +#endif // DEBUG | |
| 123 | + | |
| 124 | + if(g_file_test(default_settings,G_FILE_TEST_IS_REGULAR)) { | |
| 125 | + if(!g_key_file_load_from_file(session->key_file,default_settings,G_KEY_FILE_NONE,&error)) { | |
| 126 | + g_warning("Can't load \"%s\": %s",default_settings,error->message); | |
| 127 | + g_error_free(error); | |
| 128 | + } else { | |
| 129 | + g_message("Loading session preferences from %s",default_settings); | |
| 130 | + } | |
| 131 | + } | |
| 132 | + | |
| 133 | + } | |
| 134 | + | |
| 135 | + g_message("Can't find default session file"); | |
| 136 | + | |
| 137 | + } | |
| 138 | + | |
| 78 | 139 | V3270KeyFile * v3270_key_file_open(GtkWidget *terminal, const gchar *filename, GError **error) { |
| 79 | 140 | |
| 80 | 141 | g_return_val_if_fail(GTK_IS_V3270(terminal),FALSE); |
| ... | ... | @@ -105,21 +166,7 @@ |
| 105 | 166 | } else { |
| 106 | 167 | |
| 107 | 168 | // No session file, load the defaults (if available) and save file |
| 108 | - lib3270_autoptr(char) default_settings = lib3270_build_data_filename("defaults.conf",NULL); | |
| 109 | - | |
| 110 | - if(g_file_test(default_settings,G_FILE_TEST_IS_REGULAR)) { | |
| 111 | - if(!g_key_file_load_from_file(new_session->key_file,default_settings,G_KEY_FILE_NONE,error)) { | |
| 112 | - g_warning("Can't load \"%s\"",default_settings); | |
| 113 | - } else { | |
| 114 | - g_message("Loading session preferences from %s",default_settings); | |
| 115 | - } | |
| 116 | - } else { | |
| 117 | -#ifdef DEBUG | |
| 118 | - g_message("Can't find default settings file \"%s\"",default_settings); | |
| 119 | -#else | |
| 120 | - g_warning("Can't find default settings file \"%s\"",default_settings); | |
| 121 | -#endif // DEBUG | |
| 122 | - } | |
| 169 | + search_for_defaults(new_session); | |
| 123 | 170 | |
| 124 | 171 | } |
| 125 | 172 | ... | ... |