/pidgin/main: 30af0986aa62: Added the Unity integration plugin
Ankit Vani
a at nevitus.org
Tue Dec 31 06:12:51 EST 2013
Changeset: 30af0986aa625ecb5249f7ac012bf8f4488996ce
Author: Ankit Vani <a at nevitus.org>
Date: 2013-12-31 16:37 +0530
Branch: release-2.x.y
URL: https://hg.pidgin.im/pidgin/main/rev/30af0986aa62
Description:
Added the Unity integration plugin
Configure with --enable-unity to build the plugin.
diffstat:
ChangeLog | 3 +
configure.ac | 22 +
pidgin.desktop.in | 1 +
pidgin/plugins/Makefile.am | 8 +
pidgin/plugins/unity.c | 631 +++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 665 insertions(+), 0 deletions(-)
diffs (truncated from 751 to 300 lines):
diff --git a/ChangeLog b/ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,9 @@ version 2.10.8:
General:
* Add support for Python3 in build scripts. (Ashish Gupta) (#15624)
+ Pidgin:
+ * Add Unity integration plugin.
+
Gadu-Gadu:
* Disabled buddy list import/export from/to server (it didn't worked
anymore). Buddy list synchronization will be implemented in 3.0.0.
diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -1391,6 +1391,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 Python
dnl #######################################################################
@@ -2604,6 +2624,7 @@ AC_CONFIG_FILES([Makefile
finch/libgnt/wms/Makefile
finch/plugins/Makefile
po/Makefile.in
+ pidgin.desktop.in
pidgin.spec
])
AC_OUTPUT
@@ -2645,6 +2666,7 @@ echo Use XScreenSaver Extension.... : $e
echo Use X Session Management...... : $enable_sm
echo Use startup notification...... : $enable_startup_notification
echo Build with GtkSpell support... : $enable_gtkspell
+echo Build Unity integration plugin.: $enable_unity
echo
echo Build with plugin support..... : $enable_plugins
echo Build with Mono support....... : $enable_mono
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
@@ -47,6 +47,7 @@ spellchk_la_LDFLAGS = -module -a
themeedit_la_LDFLAGS = -module -avoid-version
timestamp_la_LDFLAGS = -module -avoid-version
timestamp_format_la_LDFLAGS = -module -avoid-version
+unity_la_LDFLAGS = -module -avoid-version
vvconfig_la_LDFLAGS = -module -avoid-version
xmppconsole_la_LDFLAGS = -module -avoid-version
@@ -73,6 +74,10 @@ if USE_VV
plugin_LTLIBRARIES += vvconfig.la
endif
+if ENABLE_UNITY
+plugin_LTLIBRARIES += unity.la
+endif
+
noinst_LTLIBRARIES = \
contact_priority.la \
gtk_signals_test.la
@@ -93,6 +98,7 @@ spellchk_la_SOURCES = spellchk.c
themeedit_la_SOURCES = themeedit.c themeedit-icon.c themeedit-icon.h
timestamp_la_SOURCES = timestamp.c
timestamp_format_la_SOURCES = timestamp_format.c
+unity_la_SOURCES = unity.c
vvconfig_la_SOURCES = vvconfig.c
xmppconsole_la_SOURCES = xmppconsole.c
@@ -112,6 +118,7 @@ spellchk_la_LIBADD = $(GTK_LIBS
themeedit_la_LIBADD = $(GTK_LIBS)
timestamp_la_LIBADD = $(GTK_LIBS)
timestamp_format_la_LIBADD = $(GTK_LIBS)
+unity_la_LIBADD = $(GTK_LIBS) $(UNITY_LIBS)
vvconfig_la_LIBADD = $(GTK_LIBS) $(GSTREAMER_LIBS)
xmppconsole_la_LIBADD = $(GTK_LIBS)
@@ -136,6 +143,7 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/pidgin \
$(DEBUG_CFLAGS) \
$(GTK_CFLAGS) \
+ $(UNITY_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,631 @@
+/*
+ * 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 && launcher_count != LAUNCHER_COUNT_DISABLE);
+
+ if (launcher_count == LAUNCHER_COUNT_MESSAGES) {
+ for (convs = purple_get_conversations(); convs != NULL; convs = convs->next) {
+ PurpleConversation *conv = convs->data;
+ count += GPOINTER_TO_INT(purple_conversation_get_data(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)
+{
+ PurpleConversationType conv_type = purple_conversation_get_type(conv);
+ PurpleAccount *account = purple_conversation_get_account(conv);
+ char type[2] = "0";
+ type[0] += conv_type;
+
+ return g_strconcat(type, ":",
+ 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_get_conversations(); convs != NULL; convs = convs->next) {
+ PurpleConversation *conv = convs->data;
+ messaging_menu_add_conversation(conv,
+ GPOINTER_TO_INT(purple_conversation_get_data(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(purple_conversation_get_data(conv,
+ "unity-message-count"));
+ if (!count++)
+ ++n_sources;
+
+ purple_conversation_set_data(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(purple_conversation_get_data(conv, "unity-message-count")) > 0)
+ --n_sources;
+ purple_conversation_set_data(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