changeset 29636:d75813811637

Add a new signal, drawing-buddy, to allow plugins to handle markup in buddy names, or anything else a plugin author might choose to dream up. Fixes #4598.
author John Bailey <rekkanoryo@rekkanoryo.org>
date Thu, 25 Mar 2010 02:21:03 +0000
parents 33a4d72232a7
children 9bc297399b98
files ChangeLog ChangeLog.API doc/gtkblist-signals.dox pidgin/gtkblist.c
diffstat 4 files changed, 35 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Mar 24 02:38:56 2010 +0000
+++ b/ChangeLog	Thu Mar 25 02:21:03 2010 +0000
@@ -28,6 +28,8 @@
 	* Default binding of Ctrl+Shift+v to 'Paste as Plain Text' in
 	  conversation windows. This can be changed in .gtkrc-2.0. For example,
 	  Ctrl+v can be bound to 'Paste as Plain Text' by default.
+	* Plugins can now handle markup in buddy names by attaching to the signal
+	  "drawing-buddy".
 
 	Bonjour:
 	* Added support for IPv6. (Thanks to T_X for testing)
--- a/ChangeLog.API	Wed Mar 24 02:38:56 2010 +0000
+++ b/ChangeLog.API	Thu Mar 25 02:21:03 2010 +0000
@@ -32,6 +32,7 @@
 		* pidgin_dialogs_translators (should not be used by anything but Pidgin)
 		* gtk_imhtmltoolbar_switch_active_conversation
 		* 'paste' signal for GtkIMHtml (more in gtkimhtml-signals.dox)
+		* 'drawing-buddy' signal for gtkblist (more in gtkblist-signals.dox)
 
 version 2.6.6 (02/18/2010):
 	libpurple:
--- a/doc/gtkblist-signals.dox	Wed Mar 24 02:38:56 2010 +0000
+++ b/doc/gtkblist-signals.dox	Thu Mar 25 02:21:03 2010 +0000
@@ -5,6 +5,7 @@
   @signal gtkblist-unhiding
   @signal gtkblist-created
   @signal drawing-tooltip
+  @signal drawing-buddy
  @endsignals
 
  @see gtkblist.h
@@ -53,5 +54,17 @@
   @param full Whether we're doing a full tooltip for the priority buddy or
               a compact tooltip for a non-priority buddy.
  @endsignaldef
+
+ @signaldef drawing-buddy
+  @signalproto
+char *(*drawing-buddy)(PurpleBuddy *buddy);
+  @endsignalproto
+  @signaldesc
+   Emitted to allow plugins to handle markup within a buddy's name or to
+   override the default of no formatting for names shown in the buddy list.
+   @param buddy A pointer to the PurpleBuddy that will be displayed.
+   @return The text to display (must be allocated), or @c NULL if no
+           changes to the default behavior are desired.
+ @endsignaldef
 */
 // vim: syntax=c.doxygen tw=75 et
--- a/pidgin/gtkblist.c	Wed Mar 24 02:38:56 2010 +0000
+++ b/pidgin/gtkblist.c	Thu Mar 25 02:21:03 2010 +0000
@@ -4271,7 +4271,12 @@
 	else
 		name = purple_buddy_get_alias(b);
 
-	nametext = g_markup_escape_text(name, strlen(name));
+	/* Raise a contact pre-draw signal here.  THe callback will return an
+	 * escaped version of the name. */
+	nametext = purple_signal_emit_return_1(pidgin_blist_get_handle(), "drawing-buddy", b);
+
+	if(!nametext)
+		nametext = g_markup_escape_text(name, strlen(name));
 
 	presence = purple_buddy_get_presence(b);
 
@@ -7595,10 +7600,19 @@
 	                     purple_value_new_outgoing(PURPLE_TYPE_BOXED, "GString *"),
 	                     purple_value_new(PURPLE_TYPE_BOOLEAN));
 
-
-	purple_signal_connect(purple_blist_get_handle(), "buddy-signed-on", gtk_blist_handle, PURPLE_CALLBACK(buddy_signonoff_cb), NULL);
-	purple_signal_connect(purple_blist_get_handle(), "buddy-signed-off", gtk_blist_handle, PURPLE_CALLBACK(buddy_signonoff_cb), NULL);
-	purple_signal_connect(purple_blist_get_handle(), "buddy-privacy-changed", gtk_blist_handle, PURPLE_CALLBACK(pidgin_blist_update_privacy_cb), NULL);
+	purple_signal_register(gtk_blist_handle, "drawing-buddy",
+						purple_marshal_POINTER__POINTER,
+						purple_value_new(PURPLE_TYPE_STRING), 1,
+						purple_value_new(PURPLE_TYPE_SUBTYPE,
+										PURPLE_SUBTYPE_BLIST_BUDDY));
+
+	purple_signal_connect(purple_blist_get_handle(), "buddy-signed-on",
+			gtk_blist_handle, PURPLE_CALLBACK(buddy_signonoff_cb), NULL);
+	purple_signal_connect(purple_blist_get_handle(), "buddy-signed-off",
+			gtk_blist_handle, PURPLE_CALLBACK(buddy_signonoff_cb), NULL);
+	purple_signal_connect(purple_blist_get_handle(), "buddy-privacy-changed",
+			gtk_blist_handle, PURPLE_CALLBACK(pidgin_blist_update_privacy_cb), NULL);
+
 }
 
 void