@techee commented on this pull request.

so i think this feature is complete, if we are considering merging it -

Agree, I think it's mostly ready.

I just had a look at the code once more and found some minor issues but nothing big.

we should settle on config UI (either keep as is or change to point #1 from #3911 (review))
And probably rename everything to "persistent notepad" or something like that.

I've been thinking about it and maybe "persistent untitled documents" would be best so there's no new terminology. I still think it would be best to merge the configuration with "instant save" but depends on what others (@b4n @eht16) think.

Note that we seem to be in the middle of the "Geany summer vacation" period and even normally it takes quite some time to get things merged (so please be patient) but from me at least this PR has full support - it's very useful and it also fixes the issue with the most thumbs up reactions.


In plugins/saveactions.c:

> +		{
+			/* we have to store old filename inside document data to be able to somehow
+			pass it to document-save callback that is called directly after this one */
+			plugin_set_document_data_full(geany_plugin, doc, "file-name-before-save-as", 
+				g_strdup(old_file_path_utf8), g_free);
+		}
+	}
+}
+
+
+static void persistent_temp_files_document_save_cb(GObject *obj, GeanyDocument *doc, gpointer user_data)
+{
+	gchar *new_file_path_utf8, *old_file_path_utf8;
+
+	new_file_path_utf8 = DOC_FILENAME(doc);
+	old_file_path_utf8 = plugin_get_document_data(geany_plugin, doc, "file-name-before-save-as");

old_file_path_utf8 isn't freed anywhere, is it?


In plugins/saveactions.c:

> +		}
+
+		g_free(locale_file_path);
+	}
+
+	g_dir_close(dir);
+
+	/* create new empty file/tab if this is a "fresh" session start without any opened files */
+	if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(geany->main_widgets->notebook)) == 0)
+		document_new_file(NULL, NULL, NULL);
+}
+
+
+static gboolean load_all_temp_files_idle(gpointer p_cur_doc)
+{
+	//remember and re-open document from originaly focused tab 

Use /* */ comments to match the rest of the code.


In plugins/saveactions.c:

> +			if (doc != NULL && document_is_empty(doc))
+				document_close(doc);
+		}
+
+		g_free(locale_file_path);
+	}
+
+	g_dir_close(dir);
+
+	/* create new empty file/tab if this is a "fresh" session start without any opened files */
+	if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(geany->main_widgets->notebook)) == 0)
+		document_new_file(NULL, NULL, NULL);
+}
+
+
+static gboolean load_all_temp_files_idle(gpointer p_cur_doc)

The p_cur_doc parameter isn't used - rename to something generic like data or whatever to avoid confusion.


In plugins/saveactions.c:

> +{
+	gint i, max = gtk_notebook_get_n_pages(GTK_NOTEBOOK(geany->main_widgets->notebook));
+
+	for (i = 0; i < max; i++)
+	{
+		GeanyDocument *doc = document_get_from_page(i);
+
+		if (doc->real_path != NULL && is_temp_saved_file(doc->file_name))
+		{
+			document_save_file(doc, FALSE);
+		}
+	}
+
+	return TRUE;
+}
+

Add one more empty line.


In plugins/saveactions.c:

> +		configdir_utf8 = utils_get_utf8_from_locale(geany->app->configdir);
+		default_persistent_temp_files_dir_utf8 = g_strconcat(configdir_utf8, G_DIR_SEPARATOR_S, "plugins",
+			G_DIR_SEPARATOR_S, "saveactions", G_DIR_SEPARATOR_S, "persistent_temp_files", NULL);
+		g_free(configdir_utf8);
+
+		g_key_file_set_string(config, "persistent_temp_files", "target_dir", 
+			default_persistent_temp_files_dir_utf8);
+
+		tmp = utils_get_locale_from_utf8(default_persistent_temp_files_dir_utf8);
+		g_free(default_persistent_temp_files_dir_utf8);
+
+		utils_mkdir(tmp, TRUE);
+		g_free(tmp);
+	}
+
+	tmp = utils_get_setting_string(config, "persistent_temp_files", "target_dir", NULL);

This tmp is leaked - use `SETPTR() on the line below.


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/review/2213059775@github.com>