From a6c648c6401a9f7db2b077fd8b5a38a4501bc6a2 Mon Sep 17 00:00:00 2001
From: c4pp4
Date: Thu, 14 Feb 2019 22:56:15 +0100
Subject: [PATCH 1/2] Fix Ubuntu notify support

Show new message/conversation popup when enabled by plugin extension
Libnotify Popups (fix debian/patches/ubuntu_notify_support.patch).

Bug-Ubuntu: https://launchpad.net/bugs/1339405
Signed-off-by: c4pp4
---
 src/pidgin-libnotify.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/src/pidgin-libnotify.c b/src/pidgin-libnotify.c
index bfb516c..71c5872 100644
--- a/src/pidgin-libnotify.c
+++ b/src/pidgin-libnotify.c
@@ -58,6 +58,7 @@
 
 /* Prototypes */
 static void notify_new_message_cb (PurpleAccount *account, const gchar *sender, const gchar *message, int flags, gpointer data);
+static gboolean pidgin_conversation_has_focus (PurpleConversation *);
 
 /* Globals */
 static GHashTable *buddy_hash;
@@ -637,20 +638,13 @@ notify_new_message_cb (PurpleAccount *account,
 		return;
 	}
 
-	if (conv == NULL) {
-		return;
-	}
-
 	if (!should_notify_unavailable (account))
 		return;
 
-	PidginConversation * pconv = PIDGIN_CONVERSATION(conv);
-	if (pconv != NULL) {
-	if (pconv->entry != NULL && pconv->imhtml != NULL) {
-	if (GTK_WIDGET_HAS_FOCUS(pconv->entry) || GTK_WIDGET_HAS_FOCUS(pconv->imhtml)) {
+	if (pidgin_conversation_has_focus (conv)) {
 		purple_debug_warning(PLUGIN_ID, "Pidgin conversation's widgets are in focus");
 		return;
-	}}}
+	}
 
 	notify_msg_sent (account, sender, message, conv);
 }
@@ -671,13 +665,10 @@ notify_chat_nick (PurpleAccount *account,
 	if (!purple_utf8_has_word (message, nick))
 		return;
 
-	PidginConversation * pconv = PIDGIN_CONVERSATION(conv);
-	if (pconv != NULL) {
-	if (pconv->entry != NULL && pconv->imhtml != NULL) {
-	if (GTK_WIDGET_HAS_FOCUS(pconv->entry) || GTK_WIDGET_HAS_FOCUS(pconv->imhtml)) {
+	if (pidgin_conversation_has_focus (conv)) {
 		purple_debug_warning(PLUGIN_ID, "Pidgin conversation's widgets are in focus");
 		return;
-	}}}
+	}
 
 	if (name_blacklisted(account, sender)) return;
 
-- 
2.19.2

