/pidgin/main: 3d1148d9cb71: Added the Unity integration plugin
Ankit Vani
a at nevitus.org
Tue Dec 31 12:41:51 EST 2013
Changeset: 3d1148d9cb7156e2c19128b6534dec01f06390ad
Author: Ankit Vani <a at nevitus.org>
Date: 2013-12-31 23:08 +0530
Branch: default
URL: https://hg.pidgin.im/pidgin/main/rev/3d1148d9cb71
Description:
Added the Unity integration plugin
Configure with --enable-unity to build the plugin.
diffstat:
ChangeLog | 1 +
configure.ac | 22 +
pidgin.desktop.in | 1 +
pidgin/plugins/Makefile.am | 8 +
pidgin/plugins/unity.c | 637 +++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 669 insertions(+), 0 deletions(-)
diffs (truncated from 755 to 300 lines):
diff --git a/ChangeLog b/ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,7 @@ version 3.0.0 (??/??/????):
the docklet notification. (Momchil) (#12598)
* Complete support for receiving a limited amount of history when
joining a room. (Kha) (#15458)
+ * Add Unity integration plugin.
Finch:
* Support the conversation-extended signal for extending the
diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -1566,6 +1566,26 @@ else
fi
dnl #######################################################################
+dnl # Check for Unity and Messaging Menu
+dnl #######################################################################
+AC_ARG_ENABLE(unity, [AC_HELP_STRING([--enable-unity],
+ [compile with support for unity integration plugin])], enable_unity="$enableval", enable_unity="no")
+if test "$enable_unity" = yes; then
+ PKG_CHECK_MODULES(UNITY, [unity >= 6.8 messaging-menu >= 12.10], , [
+ AC_MSG_RESULT(no)
+ AC_MSG_ERROR([
+You must have libunity9 >= 6.8 and libmessaging-menu >= 12.10 to build the unity integration plugin.
+ ])])
+ USES_MM_CHAT_SECTION="X-MessagingMenu-UsesChatSection=true"
+ AC_SUBST(UNITY_CFLAGS)
+ AC_SUBST(UNITY_LIBS)
+ AC_SUBST(USES_MM_CHAT_SECTION)
+else
+ enable_unity=no
+fi
+AM_CONDITIONAL(ENABLE_UNITY, [test "x$enable_unity" = "xyes"])
+
+dnl #######################################################################
dnl # Check for Secret Service headers
dnl #######################################################################
@@ -2960,6 +2980,7 @@ AC_CONFIG_FILES([Makefile
finch/libgnt/wms/Makefile
finch/plugins/Makefile
po/Makefile.in
+ pidgin.desktop.in
pidgin.spec
])
AC_OUTPUT
@@ -3006,6 +3027,7 @@ echo Use X Session Management...... : $e
echo Use startup notification...... : $enable_startup_notification
echo Build with GtkSpell support... : $enable_gtkspell
echo Build with GCR widgets........ : $enable_gcr
+echo Build Unity integration plugin.: $enable_unity
echo
echo Build with GNOME Keyring...... : $enable_gnome_keyring
echo Build with KWallet............ : $enable_kwallet
diff --git a/pidgin.desktop.in b/pidgin.desktop.in.in
rename from pidgin.desktop.in
rename to pidgin.desktop.in.in
--- a/pidgin.desktop.in
+++ b/pidgin.desktop.in.in
@@ -8,3 +8,4 @@ StartupNotify=true
Terminal=false
Type=Application
Categories=Network;InstantMessaging;
+ at USES_MM_CHAT_SECTION@
diff --git a/pidgin/plugins/Makefile.am b/pidgin/plugins/Makefile.am
--- a/pidgin/plugins/Makefile.am
+++ b/pidgin/plugins/Makefile.am
@@ -45,6 +45,7 @@ relnot_la_LDFLAGS = -module -a
sendbutton_la_LDFLAGS = -module -avoid-version
spellchk_la_LDFLAGS = -module -avoid-version
themeedit_la_LDFLAGS = -module -avoid-version
+unity_la_LDFLAGS = -module -avoid-version
webkit_la_LDFLAGS = -module -avoid-version
xmppconsole_la_LDFLAGS = -module -avoid-version
@@ -66,6 +67,10 @@ plugin_LTLIBRARIES = \
webkit.la \
xmppconsole.la
+if ENABLE_UNITY
+plugin_LTLIBRARIES += unity.la
+endif
+
noinst_LTLIBRARIES = \
contact_priority.la \
gtk_signals_test.la
@@ -84,6 +89,7 @@ relnot_la_SOURCES = relnot.c
sendbutton_la_SOURCES = sendbutton.c
spellchk_la_SOURCES = spellchk.c
themeedit_la_SOURCES = themeedit.c themeedit-icon.c themeedit-icon.h
+unity_la_SOURCES = unity.c
webkit_la_SOURCES = webkit.c
xmppconsole_la_SOURCES = xmppconsole.c
@@ -101,6 +107,7 @@ relnot_la_LIBADD = $(GLIB_LIB
sendbutton_la_LIBADD = $(GTK_LIBS)
spellchk_la_LIBADD = $(GTK_LIBS)
themeedit_la_LIBADD = $(GTK_LIBS)
+unity_la_LIBADD = $(GTK_LIBS) $(UNITY_LIBS)
webkit_la_LIBADD = $(GTK_LIBS) $(WEBKIT_LIBS)
xmppconsole_la_LIBADD = $(GTK_LIBS)
@@ -125,6 +132,7 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/pidgin \
$(DEBUG_CFLAGS) \
$(GTK_CFLAGS) \
+ $(UNITY_CFLAGS) \
$(WEBKIT_CFLAGS) \
$(GSTREAMER_CFLAGS) \
$(PLUGIN_CFLAGS)
diff --git a/pidgin/plugins/unity.c b/pidgin/plugins/unity.c
new file mode 100644
--- /dev/null
+++ b/pidgin/plugins/unity.c
@@ -0,0 +1,637 @@
+/*
+ * Integration with Unity's messaging menu and launcher
+ * Copyright (C) 2013 Ankit Vani <a at nevitus.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
+ */
+#include "internal.h"
+#include "version.h"
+#include "account.h"
+#include "savedstatuses.h"
+
+#include "gtkplugin.h"
+#include "gtkconv.h"
+#include "gtkutils.h"
+
+#include <unity.h>
+#include <messaging-menu.h>
+
+#define UNITY_PLUGIN_ID "gtk-unity-integration"
+
+static MessagingMenuApp *mmapp = NULL;
+static UnityLauncherEntry *launcher = NULL;
+static guint n_sources = 0;
+static gint launcher_count;
+static gint messaging_menu_text;
+static gboolean alert_chat_nick = TRUE;
+
+enum {
+ LAUNCHER_COUNT_DISABLE,
+ LAUNCHER_COUNT_MESSAGES,
+ LAUNCHER_COUNT_SOURCES,
+};
+
+enum {
+ MESSAGING_MENU_COUNT,
+ MESSAGING_MENU_TIME,
+};
+
+static int attach_signals(PurpleConversation *conv);
+static void detach_signals(PurpleConversation *conv);
+
+static void
+update_launcher()
+{
+ guint count = 0;
+ GList *convs = NULL;
+ g_return_if_fail(launcher != NULL);
+ if (launcher_count == LAUNCHER_COUNT_DISABLE)
+ return;
+
+ if (launcher_count == LAUNCHER_COUNT_MESSAGES) {
+ for (convs = purple_conversations_get_all(); convs != NULL; convs = convs->next) {
+ PurpleConversation *conv = convs->data;
+ count += GPOINTER_TO_INT(g_object_get_data(G_OBJECT(conv),
+ "unity-message-count"));
+ }
+ } else {
+ count = n_sources;
+ }
+
+ if (launcher != NULL) {
+ if (count > 0)
+ unity_launcher_entry_set_count_visible(launcher, TRUE);
+ else
+ unity_launcher_entry_set_count_visible(launcher, FALSE);
+ unity_launcher_entry_set_count(launcher, count);
+ }
+}
+
+static gchar *
+conversation_id(PurpleConversation *conv)
+{
+ PurpleAccount *account = purple_conversation_get_account(conv);
+
+ return g_strconcat((PURPLE_IS_IM_CONVERSATION(conv) ? "im" :
+ PURPLE_IS_CHAT_CONVERSATION(conv) ? "chat" : "misc"), ":",
+ purple_conversation_get_name(conv), ":",
+ purple_account_get_username(account), ":",
+ purple_account_get_protocol_id(account), NULL);
+}
+
+static void
+messaging_menu_add_conversation(PurpleConversation *conv, gint count)
+{
+ gchar *id;
+ g_return_if_fail(count > 0);
+ id = conversation_id(conv);
+
+ /* GBytesIcon may be useful for messaging menu source icons using buddy
+ icon data for IMs */
+ if (!messaging_menu_app_has_source(mmapp, id))
+ messaging_menu_app_append_source(mmapp, id, NULL,
+ purple_conversation_get_title(conv));
+
+ if (messaging_menu_text == MESSAGING_MENU_TIME)
+ messaging_menu_app_set_source_time(mmapp, id, g_get_real_time());
+ else if (messaging_menu_text == MESSAGING_MENU_COUNT)
+ messaging_menu_app_set_source_count(mmapp, id, count);
+ messaging_menu_app_draw_attention(mmapp, id);
+
+ g_free(id);
+}
+
+static void
+messaging_menu_remove_conversation(PurpleConversation *conv)
+{
+ gchar *id = conversation_id(conv);
+ if (messaging_menu_app_has_source(mmapp, id))
+ messaging_menu_app_remove_source(mmapp, id);
+ g_free(id);
+}
+
+static void
+refill_messaging_menu()
+{
+ GList *convs;
+
+ for (convs = purple_conversations_get_all(); convs != NULL; convs = convs->next) {
+ PurpleConversation *conv = convs->data;
+ messaging_menu_add_conversation(conv,
+ GPOINTER_TO_INT(g_object_get_data(G_OBJECT(conv),
+ "unity-message-count")));
+ }
+}
+
+static int
+alert(PurpleConversation *conv)
+{
+ gint count;
+ PidginWindow *purplewin = NULL;
+ if (conv == NULL || PIDGIN_CONVERSATION(conv) == NULL)
+ return 0;
+
+ purplewin = PIDGIN_CONVERSATION(conv)->win;
+
+ if (!pidgin_conv_window_has_focus(purplewin) ||
+ !pidgin_conv_window_is_active_conversation(conv))
+ {
+ count = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(conv),
+ "unity-message-count"));
+ if (!count++)
+ ++n_sources;
+
+ g_object_set_data(G_OBJECT(conv), "unity-message-count",
+ GINT_TO_POINTER(count));
+ messaging_menu_add_conversation(conv, count);
+ update_launcher();
+ }
+
+ return 0;
+}
+
+static void
+unalert(PurpleConversation *conv)
+{
+ if (GPOINTER_TO_INT(g_object_get_data(G_OBJECT(conv), "unity-message-count")) > 0)
+ --n_sources;
+
+ g_object_set_data(G_OBJECT(conv), "unity-message-count",
+ GINT_TO_POINTER(0));
+ messaging_menu_remove_conversation(conv);
+ update_launcher();
+}
+
+static int
+unalert_cb(GtkWidget *widget, gpointer data, PurpleConversation *conv)
+{
+ unalert(conv);
+ return 0;
+}
More information about the Commits
mailing list