Branch: refs/heads/master Author: Jiří Techet techet@gmail.com Committer: GitHub noreply@github.com Date: Wed, 12 Jun 2024 22:07:58 UTC Commit: 37e8618052e8cf6c4a534911625e160c40d7a5c9 https://github.com/geany/geany/commit/37e8618052e8cf6c4a534911625e160c40d7a5...
Log Message: ----------- Merge pull request #3572 from techee/document_before_save_as
Add "document-before-save-as" signal
Modified Paths: -------------- doc/pluginsignals.c src/document.c src/geanyobject.c src/geanyobject.h
Modified: doc/pluginsignals.c 11 lines changed, 11 insertions(+), 0 deletions(-) =================================================================== @@ -92,6 +92,17 @@ signal void (*document_reload)(GObject *obj, GeanyDocument *doc, gpointer user_d */ signal void (*document_before_save)(GObject *obj, GeanyDocument *doc, gpointer user_data);
+/** Sent before save as is performed with the original document. + * + * @param obj a GeanyObject instance, should be ignored. + * @param doc the original document. The document with the new file name is still + * reported by the "document-save" signal sent afterwards. + * @param user_data user data. + * + * @since 2.1 + */ +signal void (*document_before_save_as)(GObject *obj, GeanyDocument *doc, gpointer user_data); + /** Sent when a new document is saved. * * @param obj a GeanyObject instance, should be ignored.
Modified: src/document.c 2 lines changed, 2 insertions(+), 0 deletions(-) =================================================================== @@ -1835,6 +1835,8 @@ gboolean document_save_file_as(GeanyDocument *doc, const gchar *utf8_fname)
g_return_val_if_fail(doc != NULL, FALSE);
+ g_signal_emit_by_name(geany_object, "document-before-save-as", doc); + new_file = document_need_save_as(doc) || (utf8_fname != NULL && strcmp(doc->file_name, utf8_fname) != 0); if (utf8_fname != NULL) SETPTR(doc->file_name, g_strdup(utf8_fname));
Modified: src/geanyobject.c 7 lines changed, 7 insertions(+), 0 deletions(-) =================================================================== @@ -105,6 +105,13 @@ static void create_signals(GObjectClass *g_object_class) 0, NULL, NULL, g_cclosure_marshal_VOID__BOXED, G_TYPE_NONE, 1, GEANY_TYPE_DOCUMENT); + geany_object_signals[GCB_DOCUMENT_BEFORE_SAVE_AS] = g_signal_new ( + "document-before-save-as", + G_OBJECT_CLASS_TYPE (g_object_class), + G_SIGNAL_RUN_FIRST, + 0, NULL, NULL, g_cclosure_marshal_VOID__BOXED, + G_TYPE_NONE, 1, + GEANY_TYPE_DOCUMENT); geany_object_signals[GCB_DOCUMENT_SAVE] = g_signal_new ( "document-save", G_OBJECT_CLASS_TYPE (g_object_class),
Modified: src/geanyobject.h 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -57,6 +57,7 @@ typedef enum GCB_SAVE_SETTINGS, GCB_LOAD_SETTINGS, GCB_KEY_PRESS_NOTIFY, + GCB_DOCUMENT_BEFORE_SAVE_AS, GCB_MAX } GeanyCallbackId;
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).