pidgin: db6688b3: Add a new signal, drawing-buddy, to allo...

rekkanoryo at pidgin.im rekkanoryo at pidgin.im
Thu Mar 25 05:41:13 EDT 2010


-----------------------------------------------------------------
Revision: db6688b33c68fadf19bcad4f6240b476ecfc9496
Ancestor: 83880c1513774ae8550442dfe002355056d39021
Author: rekkanoryo at pidgin.im
Date: 2010-03-25T02:21:03
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/db6688b33c68fadf19bcad4f6240b476ecfc9496

Modified files:
        ChangeLog ChangeLog.API doc/gtkblist-signals.dox
        pidgin/gtkblist.c

ChangeLog: 

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.

-------------- next part --------------
============================================================
--- ChangeLog	8ee601070a86d0956c036c717f63a28383b957e3
+++ ChangeLog	9cfa61a625f293b7af11016ed30d22dd498735ce
@@ -28,6 +28,8 @@ version 2.7.0 (??/??/????):
 	* 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)
============================================================
--- ChangeLog.API	bfd6faa6704ed0051e07dca5e2ffbd30eb895ae1
+++ ChangeLog.API	8dc578fe8807312fc203315088f6ce38dbb7e75a
@@ -32,6 +32,7 @@ version 2.7.0 (??/??/????):
 		* 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:
============================================================
--- doc/gtkblist-signals.dox	5750e734ba34cd3ebb437bad654f54d4fee1c367
+++ doc/gtkblist-signals.dox	414c97cde346c9d79ba78b4bc1cff9759b333f0a
@@ -5,6 +5,7 @@
   @signal gtkblist-unhiding
   @signal gtkblist-created
   @signal drawing-tooltip
+  @signal drawing-buddy
  @endsignals
 
  @see gtkblist.h
@@ -53,5 +54,17 @@ void (*drawing-tooltip)(PurpleBlistNode 
   @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
============================================================
--- pidgin/gtkblist.c	799acee832117e652b5b8d263194b41e5d2feae4
+++ pidgin/gtkblist.c	5533f76c13a5b3c84d328b3eeaba6424de9377fe
@@ -4271,8 +4271,13 @@ pidgin_blist_get_name_markup(PurpleBuddy
 	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);
 
 	/* Name is all that is needed */
@@ -7595,10 +7600,19 @@ void pidgin_blist_init(void)
 	                     purple_value_new_outgoing(PURPLE_TYPE_BOXED, "GString *"),
 	                     purple_value_new(PURPLE_TYPE_BOOLEAN));
 
+	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);
+	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


More information about the Commits mailing list