[geany/geany-plugins] 3b17e5: Merge pull request #639 from eht16/issue638_addons_fix_initialization

Frank Lanitz git-noreply at xxxxx
Wed Nov 1 18:29:29 UTC 2017


Branch:      refs/heads/master
Author:      Frank Lanitz <frank at frank.uvena.de>
Committer:   GitHub <noreply at github.com>
Date:        Wed, 01 Nov 2017 18:29:29 UTC
Commit:      3b17e53f7eab4e95f816b724d9c1189e86aa35c6
             https://github.com/geany/geany-plugins/commit/3b17e53f7eab4e95f816b724d9c1189e86aa35c6

Log Message:
-----------
Merge pull request #639 from eht16/issue638_addons_fix_initialization

Connect button-press signal handlers on plugin activation


Modified Paths:
--------------
    addons/src/ao_markword.c

Modified: addons/src/ao_markword.c
40 lines changed, 32 insertions(+), 8 deletions(-)
===================================================================
@@ -65,6 +65,7 @@ enum
 
 
 static void ao_mark_word_finalize  			(GObject *object);
+static void connect_documents_button_press_signal_handler(AoMarkWord *mw);
 
 G_DEFINE_TYPE(AoMarkWord, ao_mark_word, G_TYPE_OBJECT)
 
@@ -78,6 +79,13 @@ static void ao_mark_word_set_property(GObject *object, guint prop_id,
 	{
 		case PROP_ENABLE_MARKWORD:
 			priv->enable_markword = g_value_get_boolean(value);
+			/* if the plugin is loaded while Geany is already running, we need to connect the
+			 * button press signal for open documents, if Geany is just booting,
+			 * it happens automatically */
+			if (priv->enable_markword && main_is_realized())
+			{
+				connect_documents_button_press_signal_handler(AO_MARKWORD(object));
+			}
 			break;
 		case PROP_ENABLE_MARKWORD_SINGLE_CLICK_DESELECT:
 			priv->enable_single_click_deselect = g_value_get_boolean(value);
@@ -197,14 +205,7 @@ void ao_mark_editor_notify(AoMarkWord *mw, GeanyEditor *editor, SCNotification *
 }
 
 
-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)
+static void connect_document_button_press_signal_handler(AoMarkWord *mw, GeanyDocument *document)
 {
 	g_return_if_fail(DOC_VALID(document));
 
@@ -218,6 +219,29 @@ void ao_mark_document_open(AoMarkWord *mw, GeanyDocument *document)
 }
 
 
+static void connect_documents_button_press_signal_handler(AoMarkWord *mw)
+{
+	guint i = 0;
+	/* connect the button-press event for all open documents */
+	foreach_document(i)
+	{
+		connect_document_button_press_signal_handler(mw, documents[i]);
+	}
+}
+
+
+void ao_mark_document_new(AoMarkWord *mw, GeanyDocument *document)
+{
+	connect_document_button_press_signal_handler(mw, document);
+}
+
+
+void ao_mark_document_open(AoMarkWord *mw, GeanyDocument *document)
+{
+	connect_document_button_press_signal_handler(mw, document);
+}
+
+
 void ao_mark_document_close(AoMarkWord *mw, GeanyDocument *document)
 {
 	g_return_if_fail(DOC_VALID(document));



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Plugins-Commits mailing list