/soc/2013/ankitkv/gobjectification: 21b1fc18a521: Merged default...
Ankit Vani
a at nevitus.org
Wed Jan 1 00:42:47 EST 2014
Changeset: 21b1fc18a5210d025916290ea28b9b6faf9296bd
Author: Ankit Vani <a at nevitus.org>
Date: 2014-01-01 11:01 +0530
Branch: soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/21b1fc18a521
Description:
Merged default branch
diffstat:
ChangeLog | 1 +
configure.ac | 22 +
pidgin.desktop.in | 1 +
pidgin/gtkimhtmltoolbar.c | 2 +-
pidgin/gtkwebviewtoolbar.c | 2 +-
pidgin/plugins/Makefile.am | 8 +
pidgin/plugins/unity.c | 637 +++++++++++++++++++++++++++++++++++++++++++++
7 files changed, 671 insertions(+), 2 deletions(-)
diffs (truncated from 779 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
@@ -1558,6 +1558,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 #######################################################################
@@ -2600,6 +2620,7 @@ AC_CONFIG_FILES([Makefile
finch/libgnt/wms/Makefile
finch/plugins/Makefile
po/Makefile.in
+ pidgin.desktop.in
pidgin.spec
])
AC_OUTPUT
@@ -2646,6 +2667,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/gtkimhtmltoolbar.c b/pidgin/gtkimhtmltoolbar.c
--- a/pidgin/gtkimhtmltoolbar.c
+++ b/pidgin/gtkimhtmltoolbar.c
@@ -1040,7 +1040,7 @@ static void update_buttons(GtkIMHtmlTool
toggle_button_set_active_block(GTK_TOGGLE_BUTTON(toolbar->font),
(tmp != NULL), toolbar);
if (tmp != NULL) {
- gchar *markup = g_strdup_printf("<span font_desc=\"%s\">%s</span>",
+ gchar *markup = g_strdup_printf("<span face=\"%s\">%s</span>",
tmp, gtk_label_get_label(label));
gtk_label_set_markup_with_mnemonic(label, markup);
g_free(markup);
diff --git a/pidgin/gtkwebviewtoolbar.c b/pidgin/gtkwebviewtoolbar.c
--- a/pidgin/gtkwebviewtoolbar.c
+++ b/pidgin/gtkwebviewtoolbar.c
@@ -1085,7 +1085,7 @@ update_buttons(GtkWebViewToolbar *toolba
toggle_action_set_active_block(GTK_TOGGLE_ACTION(priv->font),
(tmp && *tmp), toolbar);
if (tmp && *tmp) {
- gchar *markup = g_strdup_printf("<span font_desc=\"%s\">%s</span>",
+ gchar *markup = g_strdup_printf("<span face=\"%s\">%s</span>",
tmp, label);
g_free(label);
label = markup;
diff --git a/pidgin/plugins/Makefile.am b/pidgin/plugins/Makefile.am
--- a/pidgin/plugins/Makefile.am
+++ b/pidgin/plugins/Makefile.am
@@ -40,6 +40,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
@@ -61,6 +62,10 @@ plugin_LTLIBRARIES = \
webkit.la \
xmppconsole.la
+if ENABLE_UNITY
+plugin_LTLIBRARIES += unity.la
+endif
+
noinst_LTLIBRARIES = \
contact_priority.la \
gtk_signals_test.la
@@ -79,6 +84,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
@@ -96,6 +102,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)
@@ -121,6 +128,7 @@ AM_CPPFLAGS = \
$(DEBUG_CFLAGS) \
$(GTK_CFLAGS) \
$(GPLUGIN_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);
More information about the Commits
mailing list