Added workaround to prevent temp files hijacking active tab on session change.

What is this and where is the commit?

when closing a temp file and choosing "Save", I'd suggest using some other default directory than the one where temp files are stored so users aren't tempted to store the files there (and be surprised by the consequences if they choose a gtemp_x file name)

I would also like this but we wont be able to do it on plugin level, directory is defined and set to save-as window in core code and also very early.

You could just avoid using dialogs_show_save_as() and implement it manually similarly to e.g. target_directory_button_clicked_cb() but for saving files in this case (note the changes related to #3861 - if you copy the code of target_directory_button_clicked_cb() and modify it, you can reuse file_chooser_run() and file_chooser_destroy()).

To me such UX seems to allow user too many options ...

Fair enough, makes sense.

Instead of using GDir, storing the result into a hash table, and then iterating over integers, wouldn't it be easier to do something like

gint i;

for (i = 1; i < 1000; i++)
{
    gchar *name = g_strdup_printf("%s%c%s%d", persistent_temp_files_target_dir, G_DIR_SEPARATOR, PERSISTENT_TEMP_FILE_NAME_PREFIX, i);
    gboolean file_exists = g_file_test(dirpath_locale, G_FILE_TEST_EXISTS);
    g_free(name;)
    if (!file_exists)
        break;
}

return g_strdup_printf("%s%d", PERSISTENT_TEMP_FILE_NAME_PREFIX, i);

Untested, possibly missing some details.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <geany/geany/pull/3911/c2227463396@github.com>