From 06678d16c0d373f5f1418ec0d485e86e614642d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrico=20Tr=C3=B6ger?= Date: Mon, 17 Apr 2017 23:49:54 +0200 Subject: [PATCH] Enable Mark Word also for newly opened documents This broke in 26e6906ed5eeab0adf5c7ad0ea177f99a3e49ea5, before the Addons' feature "Mark Word" was enabled for all documents but after changing the trigger to button-press-event, we connected the signal only on "document-open" not on "document-new". Fixes #562. --- addons/src/addons.c | 10 ++++++++++ addons/src/ao_markword.c | 7 +++++++ addons/src/ao_markword.h | 1 + 3 files changed, 18 insertions(+) diff --git a/addons/src/addons.c b/addons/src/addons.c index 44f541d49..a80d5feee 100644 --- a/addons/src/addons.c +++ b/addons/src/addons.c @@ -104,6 +104,7 @@ static AddonsInfo *ao_info = NULL; static void ao_update_editor_menu_cb(GObject *obj, const gchar *word, gint pos, GeanyDocument *doc, gpointer data); static void ao_document_activate_cb(GObject *obj, GeanyDocument *doc, gpointer data); +static void ao_document_new_cb(GObject *obj, GeanyDocument *doc, gpointer data); static void ao_document_open_cb(GObject *obj, GeanyDocument *doc, gpointer data); static void ao_document_save_cb(GObject *obj, GeanyDocument *doc, gpointer data); static void ao_document_before_save_cb(GObject *obj, GeanyDocument *doc, gpointer data); @@ -120,6 +121,7 @@ PluginCallback plugin_callbacks[] = { "update-editor-menu", (GCallback) &ao_update_editor_menu_cb, FALSE, NULL }, { "editor-notify", (GCallback) &ao_editor_notify_cb, TRUE, NULL }, + { "document-new", (GCallback) &ao_document_new_cb, TRUE, NULL }, { "document-open", (GCallback) &ao_document_open_cb, TRUE, NULL }, { "document-save", (GCallback) &ao_document_save_cb, TRUE, NULL }, { "document-close", (GCallback) &ao_document_close_cb, TRUE, NULL }, @@ -199,6 +201,14 @@ static void ao_document_activate_cb(GObject *obj, GeanyDocument *doc, gpointer d } +static void ao_document_new_cb(GObject *obj, GeanyDocument *doc, gpointer data) +{ + g_return_if_fail(doc != NULL && doc->is_valid); + + ao_mark_document_new(ao_info->markword, doc); +} + + static void ao_document_open_cb(GObject *obj, GeanyDocument *doc, gpointer data) { g_return_if_fail(doc != NULL && doc->is_valid); diff --git a/addons/src/ao_markword.c b/addons/src/ao_markword.c index 5133a9e28..aa5e78861 100644 --- a/addons/src/ao_markword.c +++ b/addons/src/ao_markword.c @@ -172,6 +172,13 @@ static gboolean on_editor_button_press_event(GtkWidget *widget, GdkEventButton * } +void ao_mark_document_new(AoMarkWord *mw, GeanyDocument *document) +{ + /* there is nothing different to handling open documents, so do the same */ + ao_mark_document_open(mw, document); +} + + void ao_mark_document_open(AoMarkWord *mw, GeanyDocument *document) { g_return_if_fail(DOC_VALID(document)); diff --git a/addons/src/ao_markword.h b/addons/src/ao_markword.h index c321836c4..987a3da80 100644 --- a/addons/src/ao_markword.h +++ b/addons/src/ao_markword.h @@ -41,6 +41,7 @@ typedef struct _AoMarkWordClass AoMarkWordClass; GType ao_mark_word_get_type (void); AoMarkWord* ao_mark_word_new (gboolean enable, gboolean single_click_deselect); +void ao_mark_document_new (AoMarkWord *mw, GeanyDocument *document); void ao_mark_document_open (AoMarkWord *mw, GeanyDocument *document); void ao_mark_document_close (AoMarkWord *mw, GeanyDocument *document);