Commit c6893aaffa28ce1fcdb7d2c2adfcc5bee03dc94b
Exists in
master
and in
2 other branches
Merge branch 'master' into develop
Showing
2 changed files
with
72 additions
and
16 deletions
Show diff stats
src/objects/application/open.c
| ... | ... | @@ -94,6 +94,14 @@ void pw3270_application_open(GApplication *application, GFile **files, gint n_fi |
| 94 | 94 | if(sz > 0 && uri[sz-1] == '/') |
| 95 | 95 | uri[sz-1] = 0; |
| 96 | 96 | |
| 97 | + if(!window) { | |
| 98 | + debug("%s: Creating new window",__FUNCTION__); | |
| 99 | + window = pw3270_application_window_new(GTK_APPLICATION(application), NULL); | |
| 100 | + } else { | |
| 101 | + debug("%s: Creating new tab",__FUNCTION__); | |
| 102 | + window = pw3270_application_window_new_tab(window, NULL); | |
| 103 | + } | |
| 104 | + | |
| 97 | 105 | v3270_set_url(pw3270_application_window_get_active_terminal(window),uri); |
| 98 | 106 | |
| 99 | 107 | } | ... | ... |
src/objects/window/keyfile.c
| ... | ... | @@ -83,6 +83,69 @@ static void close_keyfile(V3270KeyFile * session) { |
| 83 | 83 | g_free(session); |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | +static void search_for_defaults(V3270KeyFile *session) { | |
| 87 | + | |
| 88 | + GError *error = NULL; | |
| 89 | + size_t ix; | |
| 90 | + | |
| 91 | + // Search for user defaults. | |
| 92 | + static const gchar *usernames[] = { | |
| 93 | + "defaults.3270", | |
| 94 | + "default.3270", | |
| 95 | + }; | |
| 96 | + | |
| 97 | + for(ix = 0; ix < G_N_ELEMENTS(usernames);ix++) { | |
| 98 | + | |
| 99 | + g_autofree gchar * default_settings = g_build_filename(g_get_user_config_dir(),usernames[ix],NULL); | |
| 100 | + | |
| 101 | +#ifdef DEBUG | |
| 102 | + g_message("Searching for %s", default_settings); | |
| 103 | +#endif // DEBUG | |
| 104 | + | |
| 105 | + if(g_file_test(default_settings,G_FILE_TEST_IS_REGULAR)) { | |
| 106 | + if(!g_key_file_load_from_file(session->key_file,default_settings,G_KEY_FILE_NONE,&error)) { | |
| 107 | + g_warning("Can't load \"%s\": %s",default_settings,error->message); | |
| 108 | + g_error_free(error); | |
| 109 | + } else { | |
| 110 | + g_message("Loading session preferences from %s",default_settings); | |
| 111 | + return; | |
| 112 | + } | |
| 113 | + } | |
| 114 | + | |
| 115 | + } | |
| 116 | + | |
| 117 | + // Search for system defaults. | |
| 118 | + static const gchar *sysnames[] = { | |
| 119 | + "defaults.3270", | |
| 120 | + "default.3270", | |
| 121 | + "defaults.conf", | |
| 122 | + "default.conf", | |
| 123 | + }; | |
| 124 | + | |
| 125 | + for(ix = 0; ix < G_N_ELEMENTS(sysnames);ix++) { | |
| 126 | + | |
| 127 | + lib3270_autoptr(char) default_settings = lib3270_build_data_filename(sysnames[ix],NULL); | |
| 128 | + | |
| 129 | +#ifdef DEBUG | |
| 130 | + g_message("Searching for %s", default_settings); | |
| 131 | +#endif // DEBUG | |
| 132 | + | |
| 133 | + if(g_file_test(default_settings,G_FILE_TEST_IS_REGULAR)) { | |
| 134 | + if(!g_key_file_load_from_file(session->key_file,default_settings,G_KEY_FILE_NONE,&error)) { | |
| 135 | + g_warning("Can't load \"%s\": %s",default_settings,error->message); | |
| 136 | + g_error_free(error); | |
| 137 | + } else { | |
| 138 | + g_message("Loading session preferences from %s",default_settings); | |
| 139 | + return; | |
| 140 | + } | |
| 141 | + } | |
| 142 | + | |
| 143 | + } | |
| 144 | + | |
| 145 | + g_message("Can't find default session file"); | |
| 146 | + | |
| 147 | +} | |
| 148 | + | |
| 86 | 149 | V3270KeyFile * v3270_key_file_open(GtkWidget *terminal, const gchar *filename, GError **error) { |
| 87 | 150 | |
| 88 | 151 | g_return_val_if_fail(GTK_IS_V3270(terminal),FALSE); |
| ... | ... | @@ -113,21 +176,7 @@ V3270KeyFile * v3270_key_file_open(GtkWidget *terminal, const gchar *filename, G |
| 113 | 176 | } else { |
| 114 | 177 | |
| 115 | 178 | // No session file, load the defaults (if available) and save file |
| 116 | - lib3270_autoptr(char) default_settings = lib3270_build_data_filename("defaults.conf",NULL); | |
| 117 | - | |
| 118 | - if(g_file_test(default_settings,G_FILE_TEST_IS_REGULAR)) { | |
| 119 | - if(!g_key_file_load_from_file(new_session->key_file,default_settings,G_KEY_FILE_NONE,error)) { | |
| 120 | - g_warning("Can't load \"%s\"",default_settings); | |
| 121 | - } else { | |
| 122 | - g_message("Loading session preferences from %s",default_settings); | |
| 123 | - } | |
| 124 | - } else { | |
| 125 | -#ifdef DEBUG | |
| 126 | - g_message("Can't find default settings file \"%s\"",default_settings); | |
| 127 | -#else | |
| 128 | - g_warning("Can't find default settings file \"%s\"",default_settings); | |
| 129 | -#endif // DEBUG | |
| 130 | - } | |
| 179 | + search_for_defaults(new_session); | |
| 131 | 180 | |
| 132 | 181 | } |
| 133 | 182 | |
| ... | ... | @@ -423,4 +472,3 @@ gboolean v3270_key_file_can_write(GtkWidget *widget) { |
| 423 | 472 | } |
| 424 | 473 | |
| 425 | 474 | |
| 426 | - | ... | ... |