changeset 17812:f2869d5facfe

Fix #318 which asked for the buddynote plugins notes to be shown in the tooltip. This was the easiest way I could think of to do it without making the buddynote plugin itself a gtk plugin. Eventually I think I'll see about moving the drawing-tooltip function to be a core plugin and this can get merged into buddynote itself. (But I don't think that can't happen until 3.0.0.)
author Etan Reisner <pidgin@unreliablesource.net>
date Sun, 10 Jun 2007 07:25:09 +0000
parents 9a96d8711303
children 04f1a6da47a2 d495103dcf88
files pidgin/plugins/Makefile.am pidgin/plugins/Makefile.mingw pidgin/plugins/gtkbuddynote.c
diffstat 3 files changed, 132 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/plugins/Makefile.am	Sun Jun 10 01:54:40 2007 +0000
+++ b/pidgin/plugins/Makefile.am	Sun Jun 10 07:25:09 2007 +0000
@@ -30,6 +30,7 @@
 contact_priority_la_LDFLAGS = -module -avoid-version
 extplacement_la_LDFLAGS     = -module -avoid-version
 gtk_signals_test_la_LDFLAGS = -module -avoid-version
+gtkbuddynote_la_LDFLAGS     = -module -avoid-version
 history_la_LDFLAGS          = -module -avoid-version
 iconaway_la_LDFLAGS         = -module -avoid-version
 markerline_la_LDFLAGS       = -module -avoid-version
@@ -46,6 +47,7 @@
 plugin_LTLIBRARIES = \
 	convcolors.la       \
 	extplacement.la     \
+	gtkbuddynote.la     \
 	history.la          \
 	iconaway.la         \
 	markerline.la       \
@@ -65,6 +67,7 @@
 contact_priority_la_SOURCES = contact_priority.c
 extplacement_la_SOURCES     = extplacement.c
 gtk_signals_test_la_SOURCES = gtk-signals-test.c
+gtkbuddynote_la_SOURCES     = gtkbuddynote.c
 history_la_SOURCES          = history.c
 iconaway_la_SOURCES         = iconaway.c
 markerline_la_SOURCES       = markerline.c
@@ -80,6 +83,7 @@
 contact_priority_la_LIBADD  = $(GTK_LIBS)
 extplacement_la_LIBADD      = $(GTK_LIBS)
 gtk_signals_test_la_LIBADD  = $(GTK_LIBS)
+gtkbuddynote_la_LIBADD      = $(GTK_LIBS)
 history_la_LIBADD           = $(GTK_LIBS)
 iconaway_la_LIBADD          = $(GTK_LIBS)
 markerline_la_LIBADD        = $(GTK_LIBS)
--- a/pidgin/plugins/Makefile.mingw	Sun Jun 10 01:54:40 2007 +0000
+++ b/pidgin/plugins/Makefile.mingw	Sun Jun 10 07:25:09 2007 +0000
@@ -77,11 +77,12 @@
 plugins: \
 		convcolors.dll \
 		extplacement.dll \
-		pidginrc.dll \
+		gtkbuddynote.dll \
 		history.dll \
 		iconaway.dll \
 		markerline.dll \
 		notify.dll \
+		pidginrc.dll \
 		relnot.dll \
 		spellchk.dll \
 		timestamp_format.dll \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/plugins/gtkbuddynote.c	Sun Jun 10 07:25:09 2007 +0000
@@ -0,0 +1,126 @@
+/*
+ * GtkBuddyNote - Store notes on particular buddies
+ * Copyright (C) 2007 Etan Reisner <deryni@pidgin.im>
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+#include "internal.h"
+
+#include <gtkblist.h>
+#include <gtkplugin.h>
+
+#include <debug.h>
+#include <version.h>
+
+static void
+append_to_tooltip(PurpleBlistNode *node, GString *text, gboolean full)
+{
+	if (full) {
+		const gchar *note = purple_blist_node_get_string(node, "notes");
+
+		if (note != NULL) {
+			g_string_append_printf(text, _("\nBuddy Note: %s"),
+			                       note);
+		}
+	}
+}
+
+static gboolean
+plugin_load(PurplePlugin *plugin)
+{
+	purple_signal_connect(pidgin_blist_get_handle(), "drawing-tooltip",
+	                      plugin, PURPLE_CALLBACK(append_to_tooltip), NULL);
+	return TRUE;
+}
+
+static gboolean
+plugin_unload(PurplePlugin *plugin)
+{
+	PurplePlugin *buddynote = NULL;
+
+	buddynote = purple_plugins_find_with_id("core-plugin_pack-buddynote");
+
+	purple_plugin_unload(buddynote);
+
+	return TRUE;
+}
+
+static PurplePluginInfo info =
+{
+	PURPLE_PLUGIN_MAGIC,
+	PURPLE_MAJOR_VERSION,                           /**< major version */
+	PURPLE_MINOR_VERSION,                           /**< minor version */
+	PURPLE_PLUGIN_STANDARD,                         /**< type */
+	PIDGIN_PLUGIN_TYPE,                             /**< ui_requirement */
+	0,                                              /**< flags */
+	NULL,                                           /**< dependencies */
+	PURPLE_PRIORITY_DEFAULT,                        /**< priority */
+	"gtkbuddynote",                                 /**< id */
+	N_("Buddy Notes"),                              /**< name */
+	VERSION,                                        /**< version */
+	N_("Store notes on particular buddies."),       /**< summary */
+	N_("Adds the option to store notes for buddies "
+	   "on your buddy list."),                      /**< description */
+	"Etan Reisner <deryni@pidgin.im>",              /**< author */
+	PURPLE_WEBSITE,                                 /**< homepage */
+	plugin_load,                                    /**< load */
+	plugin_unload,                                  /**< unload */
+	NULL,                                           /**< destroy */
+	NULL,                                           /**< ui_info */
+	NULL,                                           /**< extra_info */
+	NULL,                                           /**< prefs_info */
+	NULL,                                           /**< actions */
+
+	/* padding */
+	NULL,
+	NULL,
+	NULL,
+	NULL
+};
+
+static gboolean
+check_for_buddynote(gpointer data)
+{
+	PurplePlugin *buddynote = NULL;
+
+	buddynote = purple_plugins_find_with_id("core-plugin_pack-buddynote");
+
+	if (buddynote == NULL) {
+		buddynote = purple_plugins_find_with_basename("buddynote");
+	}
+
+	if (buddynote != NULL) {
+		PurplePluginInfo *bninfo = buddynote->info;
+
+		bninfo->flags = PURPLE_PLUGIN_FLAG_INVISIBLE;
+
+		info.dependencies = g_list_append(info.dependencies,
+		                                  "core-plugin_pack-buddynote");
+	} else {
+		info.flags = PURPLE_PLUGIN_FLAG_INVISIBLE;
+	}
+
+	return FALSE;
+}
+
+static void
+init_plugin(PurplePlugin *plugin)
+{
+	/* Use g_idle_add so that the rest of the plugins can get loaded
+	 * before we do our check. */
+	g_idle_add(check_for_buddynote, plugin);
+}
+
+PURPLE_INIT_PLUGIN(gtkbuddynote, init_plugin, info)