changeset 18306:a3469318cf35

merge of '1021f142edad27e5a1f750f8d439c3bc5bf07b81' and '194d749288549e6af3c41d354c2196295e8eac5f'
author Sean Egan <seanegan@gmail.com>
date Wed, 27 Jun 2007 17:24:32 +0000
parents db4b0aa4ed8c (current diff) ffd706ec0220 (diff)
children 4434e5c9d247 cf2fbfa205b1
files pidgin/gtkconv.c
diffstat 28 files changed, 283 insertions(+), 110 deletions(-) [+]
line wrap: on
line diff
--- a/Doxyfile.in	Wed Jun 27 17:22:24 2007 +0000
+++ b/Doxyfile.in	Wed Jun 27 17:24:32 2007 +0000
@@ -432,8 +432,9 @@
 # with spaces.
 
 INPUT                  = libpurple \
-						 finch \
-						 pidgin \
+	                     finch \
+	                     finch/libgnt \
+	                     pidgin \
                          doc
 
 # If the value of the INPUT tag contains directories, you can use the 
--- a/finch/libgnt/gnt-skel.h	Wed Jun 27 17:22:24 2007 +0000
+++ b/finch/libgnt/gnt-skel.h	Wed Jun 27 17:24:32 2007 +0000
@@ -1,4 +1,8 @@
 /**
+ * @file gnt-skel.h -skel API
+ * @ingroup gnt
+ */
+/*
  * GNT - The GLib Ncurses Toolkit
  *
  * GNT is the legal property of its developers, whose names are too numerous
--- a/finch/libgnt/gnt.h	Wed Jun 27 17:22:24 2007 +0000
+++ b/finch/libgnt/gnt.h	Wed Jun 27 17:24:32 2007 +0000
@@ -1,4 +1,14 @@
 /**
+ * @defgroup gnt GNT (GLib Ncurses Toolkit)
+ *
+ * GNT is an ncurses toolkit for creating text-mode graphical user interfaces
+ * in a fast and easy way.
+ */
+/**
+ * @file gnt.h GNT API
+ * @ingroup gnt
+ */
+/*
  * GNT - The GLib Ncurses Toolkit
  *
  * GNT is the legal property of its developers, whose names are too numerous
--- a/finch/libgnt/gntbindable.h	Wed Jun 27 17:22:24 2007 +0000
+++ b/finch/libgnt/gntbindable.h	Wed Jun 27 17:24:32 2007 +0000
@@ -1,4 +1,8 @@
 /**
+ * @file gntbindable.h Bindable API
+ * @ingroup gnt
+ */
+/*
  * GNT - The GLib Ncurses Toolkit
  *
  * GNT is the legal property of its developers, whose names are too numerous
--- a/finch/libgnt/gntbox.h	Wed Jun 27 17:22:24 2007 +0000
+++ b/finch/libgnt/gntbox.h	Wed Jun 27 17:24:32 2007 +0000
@@ -1,4 +1,8 @@
 /**
+ * @file gntbox.h Box API
+ * @ingroup gnt
+ */
+/*
  * GNT - The GLib Ncurses Toolkit
  *
  * GNT is the legal property of its developers, whose names are too numerous
@@ -84,9 +88,8 @@
 G_BEGIN_DECLS
 
 /**
- * 
- *
- * @return
+ * The GType for GntBox.
+ * @return The GType.
  */
 GType gnt_box_get_gtype(void);
 
@@ -94,98 +97,110 @@
 #define gnt_hbox_new(homo) gnt_box_new(homo, FALSE)
 
 /**
- * 
- * @param homo
- * @param vert
+ * Create a new GntBox.
  *
- * @return
+ * @param homo  If @c TRUE, all the widgets in it will have the same width (or height)
+ * @param vert  Whether the widgets in it should be stacked vertically (if @c TRUE)
+ *              or horizontally (if @c FALSE).
+ *
+ * @return The new GntBox.
  */
 GntWidget * gnt_box_new(gboolean homo, gboolean vert);
 
 /**
- * 
- * @param box
- * @param widget
+ * Add a widget in the box.
+ *
+ * @param box     The box
+ * @param widget  The widget to add
  */
 void gnt_box_add_widget(GntBox *box, GntWidget *widget);
 
 /**
- * 
- * @param box
- * @param title
+ * Set a title for the box.
+ *
+ * @param box    The box
+ * @param title	 The title to set
  */
 void gnt_box_set_title(GntBox *box, const char *title);
 
 /**
- * 
- * @param box
- * @param pad
+ * Set the padding to use between the widgets in the box.
+ *
+ * @param box The box
+ * @param pad The padding to use
  */
 void gnt_box_set_pad(GntBox *box, int pad);
 
 /**
- * 
- * @param box
- * @param set
+ * Set whether it's a toplevel box (ie, a window) or not. If a box is toplevel,
+ * then it will show borders, the title (if set) and shadow (if enabled in
+ * @e .gntrc)
+ *
+ * @param box The box
+ * @param set @c TRUE if it's a toplevel box, @c FALSE otherwise.
  */
 void gnt_box_set_toplevel(GntBox *box, gboolean set);
 
 /**
- * 
- * @param box
+ * Reposition and refresh the widgets in the box.
+ *
+ * @param box The box
  */
 void gnt_box_sync_children(GntBox *box);
 
 /**
- * 
- * @param box
- * @param alignment
+ * Set the alignment for the widgets in the box.
+ *
+ * @param box       The box
+ * @param alignment The alignment to use
  */
 void gnt_box_set_alignment(GntBox *box, GntAlignment alignment);
 
 /**
- * 
- * @param box
- * @param widget
+ * Remove a widget from the box. Calling this does NOT destroy the removed widget.
+ *
+ * @param box       The box
+ * @param widget    The widget to remove
  */
 void gnt_box_remove(GntBox *box, GntWidget *widget);
 
- /* XXX: does NOT destroy widget */
-
 /**
- * 
- * @param box
+ * Remove all widgets from the box. This DOES destroy all widgets in the box.
+ *
+ * @param box The box
  */
 void gnt_box_remove_all(GntBox *box);
 
-      /* Removes AND destroys all the widgets in it */
-
 /**
- * 
- * @param box
+ * Readjust the size of each child widget, reposition the child widgets and
+ * recalculate the size of the box.
+ *
+ * @param box  The box
  */
 void gnt_box_readjust(GntBox *box);
 
 /**
- * 
- * @param box
- * @param fill
+ * Set whether the widgets in the box should fill the empty spaces.
+ *
+ * @param box   The box
+ * @param fill  Whether the child widgets should fill the empty space
  */
 void gnt_box_set_fill(GntBox *box, gboolean fill);
 
 /**
- * 
- * @param box
- * @param dir
+ * Move the focus from one widget to the other.
+ *
+ * @param box The box
+ * @param dir The direction. If it's 1, then the focus is moved forwards, if it's
+ *            -1, the focus is moved backwards.
  */
 void gnt_box_move_focus(GntBox *box, int dir);
 
-  /* +1 to move forward, -1 for backward */
-
 /**
- * 
- * @param box
- * @param widget
+ * Give focus to a specific child widget.
+ *
+ * @param box       The box
+ * @param widget    The child widget to give focus
  */
 void gnt_box_give_focus_to_child(GntBox *box, GntWidget *widget);
 
--- a/finch/libgnt/gntbutton.h	Wed Jun 27 17:22:24 2007 +0000
+++ b/finch/libgnt/gntbutton.h	Wed Jun 27 17:24:32 2007 +0000
@@ -1,4 +1,8 @@
 /**
+ * @file gntbutton.h Button API
+ * @ingroup gnt
+ */
+/*
  * GNT - The GLib Ncurses Toolkit
  *
  * GNT is the legal property of its developers, whose names are too numerous
--- a/finch/libgnt/gntcheckbox.h	Wed Jun 27 17:22:24 2007 +0000
+++ b/finch/libgnt/gntcheckbox.h	Wed Jun 27 17:24:32 2007 +0000
@@ -1,4 +1,8 @@
 /**
+ * @file gntcheckbox.h Checkbox API
+ * @ingroup gnt
+ */
+/*
  * GNT - The GLib Ncurses Toolkit
  *
  * GNT is the legal property of its developers, whose names are too numerous
--- a/finch/libgnt/gntclipboard.h	Wed Jun 27 17:22:24 2007 +0000
+++ b/finch/libgnt/gntclipboard.h	Wed Jun 27 17:24:32 2007 +0000
@@ -1,4 +1,8 @@
 /**
+ * @file gntclipboard.h Clipboard API
+ * @ingroup gnt
+ */
+/*
  * GNT - The GLib Ncurses Toolkit
  *
  * GNT is the legal property of its developers, whose names are too numerous
--- a/finch/libgnt/gntcolors.h	Wed Jun 27 17:22:24 2007 +0000
+++ b/finch/libgnt/gntcolors.h	Wed Jun 27 17:24:32 2007 +0000
@@ -1,4 +1,8 @@
 /**
+ * @file gntcolors.h Colors API
+ * @ingroup gnt
+ */
+/*
  * GNT - The GLib Ncurses Toolkit
  *
  * GNT is the legal property of its developers, whose names are too numerous
--- a/finch/libgnt/gntcombobox.h	Wed Jun 27 17:22:24 2007 +0000
+++ b/finch/libgnt/gntcombobox.h	Wed Jun 27 17:24:32 2007 +0000
@@ -1,4 +1,8 @@
 /**
+ * @file gntcombobox.h Combobox API
+ * @ingroup gnt
+ */
+/*
  * GNT - The GLib Ncurses Toolkit
  *
  * GNT is the legal property of its developers, whose names are too numerous
--- a/finch/libgnt/gntentry.h	Wed Jun 27 17:22:24 2007 +0000
+++ b/finch/libgnt/gntentry.h	Wed Jun 27 17:24:32 2007 +0000
@@ -1,4 +1,8 @@
 /**
+ * @file gntentry.h Entry API
+ * @ingroup gnt
+ */
+/*
  * GNT - The GLib Ncurses Toolkit
  *
  * GNT is the legal property of its developers, whose names are too numerous
--- a/finch/libgnt/gntfilesel.h	Wed Jun 27 17:22:24 2007 +0000
+++ b/finch/libgnt/gntfilesel.h	Wed Jun 27 17:24:32 2007 +0000
@@ -1,4 +1,8 @@
 /**
+ * @file gntfilesel.h File selector API
+ * @ingroup gnt
+ */
+/*
  * GNT - The GLib Ncurses Toolkit
  *
  * GNT is the legal property of its developers, whose names are too numerous
--- a/finch/libgnt/gntkeys.h	Wed Jun 27 17:22:24 2007 +0000
+++ b/finch/libgnt/gntkeys.h	Wed Jun 27 17:24:32 2007 +0000
@@ -1,4 +1,8 @@
 /**
+ * @file gntkeys.h Keys API
+ * @ingroup gnt
+ */
+/*
  * GNT - The GLib Ncurses Toolkit
  *
  * GNT is the legal property of its developers, whose names are too numerous
--- a/finch/libgnt/gntlabel.h	Wed Jun 27 17:22:24 2007 +0000
+++ b/finch/libgnt/gntlabel.h	Wed Jun 27 17:24:32 2007 +0000
@@ -1,4 +1,8 @@
 /**
+ * @file gntlabel.h Label API
+ * @ingroup gnt
+ */
+/*
  * GNT - The GLib Ncurses Toolkit
  *
  * GNT is the legal property of its developers, whose names are too numerous
--- a/finch/libgnt/gntline.h	Wed Jun 27 17:22:24 2007 +0000
+++ b/finch/libgnt/gntline.h	Wed Jun 27 17:24:32 2007 +0000
@@ -1,4 +1,8 @@
 /**
+ * @file gntline.h Line API
+ * @ingroup gnt
+ */
+/*
  * GNT - The GLib Ncurses Toolkit
  *
  * GNT is the legal property of its developers, whose names are too numerous
--- a/finch/libgnt/gntmenu.h	Wed Jun 27 17:22:24 2007 +0000
+++ b/finch/libgnt/gntmenu.h	Wed Jun 27 17:24:32 2007 +0000
@@ -1,4 +1,8 @@
 /**
+ * @file gntmenu.h Menu API
+ * @ingroup gnt
+ */
+/*
  * GNT - The GLib Ncurses Toolkit
  *
  * GNT is the legal property of its developers, whose names are too numerous
--- a/finch/libgnt/gntmenuitem.h	Wed Jun 27 17:22:24 2007 +0000
+++ b/finch/libgnt/gntmenuitem.h	Wed Jun 27 17:24:32 2007 +0000
@@ -1,4 +1,8 @@
 /**
+ * @file gntmenuitem.h Menuitem API
+ * @ingroup gnt
+ */
+/*
  * GNT - The GLib Ncurses Toolkit
  *
  * GNT is the legal property of its developers, whose names are too numerous
--- a/finch/libgnt/gntmenuitemcheck.h	Wed Jun 27 17:22:24 2007 +0000
+++ b/finch/libgnt/gntmenuitemcheck.h	Wed Jun 27 17:24:32 2007 +0000
@@ -1,4 +1,8 @@
 /**
+ * @file gntmenuitemcheck.h Check Menuitem API
+ * @ingroup gnt
+ */
+/*
  * GNT - The GLib Ncurses Toolkit
  *
  * GNT is the legal property of its developers, whose names are too numerous
--- a/finch/libgnt/gntstyle.h	Wed Jun 27 17:22:24 2007 +0000
+++ b/finch/libgnt/gntstyle.h	Wed Jun 27 17:24:32 2007 +0000
@@ -1,4 +1,8 @@
 /**
+ * @file gntstyle.h Style API
+ * @ingroup gnt
+ */
+/*
  * GNT - The GLib Ncurses Toolkit
  *
  * GNT is the legal property of its developers, whose names are too numerous
--- a/finch/libgnt/gnttextview.h	Wed Jun 27 17:22:24 2007 +0000
+++ b/finch/libgnt/gnttextview.h	Wed Jun 27 17:24:32 2007 +0000
@@ -1,4 +1,8 @@
 /**
+ * @file gnttextview.h Textview API
+ * @ingroup gnt
+ */
+/*
  * GNT - The GLib Ncurses Toolkit
  *
  * GNT is the legal property of its developers, whose names are too numerous
--- a/finch/libgnt/gnttree.h	Wed Jun 27 17:22:24 2007 +0000
+++ b/finch/libgnt/gnttree.h	Wed Jun 27 17:24:32 2007 +0000
@@ -1,4 +1,8 @@
 /**
+ * @file gnttree.h Tree API
+ * @ingroup gnt
+ */
+/*
  * GNT - The GLib Ncurses Toolkit
  *
  * GNT is the legal property of its developers, whose names are too numerous
--- a/finch/libgnt/gntutils.h	Wed Jun 27 17:22:24 2007 +0000
+++ b/finch/libgnt/gntutils.h	Wed Jun 27 17:24:32 2007 +0000
@@ -1,4 +1,8 @@
 /**
+ * @file gntutils.h Some utility functions
+ * @ingroup gnt
+ */
+/*
  * GNT - The GLib Ncurses Toolkit
  *
  * GNT is the legal property of its developers, whose names are too numerous
@@ -28,87 +32,101 @@
 typedef gpointer (*GDupFunc)(gconstpointer data);
 
 /**
- * 
- * @param text
- * @param width
- * @param height
+ * Compute the width and height required to view the text on the screen.
+ *
+ * @param text     The text to be displayed.
+ * @param width    The width required is set here, if not @c NULL.
+ * @param height   The height required is set here, if not @c NULL.
  */
 void gnt_util_get_text_bound(const char *text, int *width, int *height);
 
-/* excluding *end */
 /**
- * 
- * @param start
- * @param end
+ * Get the onscreen width of a string, or a substring.
  *
- * @return
+ * @param start  The beginning of the string.
+ * @param end    The end of the string. The width returned is the width
+ *               upto (but not including) end. If end is NULL, then start
+ *               is considered as a @c NULL-terminated string.
+ *
+ * @return       The on-screen width of the string.
  */
 int gnt_util_onscreen_width(const char *start, const char *end);
 
+/**
+ * Computes and returns the string after a specific number of onscreen characters.
+ *
+ * @param str  The string.
+ * @param len  The length to consider. If non-positive, the entire screenlength is used.
+ * @param w    The actual width of the string upto the returned offset, if not @c NULL.
+ *
+ * @return     The string after len offset.
+ */
 const char *gnt_util_onscreen_width_to_pointer(const char *str, int len, int *w);
 
-/* Inserts newlines in 'string' where necessary so that its onscreen width is
+/**
+ * Inserts newlines in 'string' where necessary so that its onscreen width is 
  * no more than 'maxw'.
- * 'maxw' can be <= 0, in which case the maximum screen width is considered.
  *
- * Returns a newly allocated string.
- */
-/**
- * 
- * @param string
- * @param maxw
+ * @param string  The string.
+ * @param maxw    The width that the string should fit into. If maxw is <= 0,
+ *                then the available maximum width is used.
  *
- * @return
+ * @return  A newly allocated string that needs to be freed by the caller.
  */
 char * gnt_util_onscreen_fit_string(const char *string, int maxw);
 
 /**
- * 
- * @param src
- * @param hash
- * @param equal
- * @param key_d
- * @param value_d
- * @param key_dup
- * @param value_dup
+ * Duplicate the contents of a hastable.
  *
- * @return
+ * @param src         The source hashtable.
+ * @param hash        The hash-function to use.
+ * @param equal       The hash-equal function to use.
+ * @param key_d       The key-destroy function to use.
+ * @param value_d     The value-destroy function to use.
+ * @param key_dup     The function to use to duplicate the key.
+ * @param value_dup   The function to use to duplicate the value.
+ *
+ * @return    The new hashtable.
  */
 GHashTable * g_hash_table_duplicate(GHashTable *src, GHashFunc hash, GEqualFunc equal, GDestroyNotify key_d, GDestroyNotify value_d, GDupFunc key_dup, GDupFunc value_dup);
 
 /**
  * To be used with g_signal_new. Look in the key_pressed signal-definition in
  * gntwidget.c for usage.
- */
-/**
- * 
- * @param ihint
- * @param return_accu
- * @param handler_return
- * @param dummy
  *
- * @return
+ * @param ihint           NA
+ * @param return_accu     NA
+ * @param handler_return  NA
+ * @param dummy           NA
+ *
+ * @return  NA
  */
 gboolean gnt_boolean_handled_accumulator(GSignalInvocationHint *ihint, GValue *return_accu, const GValue *handler_return, gpointer dummy);
 
 /**
- * Returns a GntTree populated with "key" -> "binding" for the widget.
- */
-/**
+ * Get a helpful display about the bindings of a widget.
  * 
- * @param widget
+ * @param widget The widget to get bindings for.
  *
- * @return
+ * @return Returns a GntTree populated with "key" -> "binding" for the widget.
  */
 GntWidget * gnt_widget_bindings_view(GntWidget *widget);
 
 /**
- * Parse widgets from 'string'.
- */
-/**
+ * Parse widgets from an XML description. For example,
+ *
+ * @code
+ * GntWidget *win, *button;
+ * gnt_util_parse_widgets("\
+ *      <vwindow id='0' fill='0' align='2'>     \
+ *          <label>This is a test</label>       \
+ *          <button id='1'>OK</button>          \
+ *      </vwindow>",
+ *   2, &win, &button);
+ * @endcode
  * 
- * @param string
- * @param num
+ * @param string  The XML string.
+ * @param num     The number of widgets to return, followed by 'num' GntWidget **
  */
 void gnt_util_parse_widgets(const char *string, int num, ...);
 
--- a/finch/libgnt/gntwidget.h	Wed Jun 27 17:22:24 2007 +0000
+++ b/finch/libgnt/gntwidget.h	Wed Jun 27 17:24:32 2007 +0000
@@ -1,4 +1,8 @@
 /**
+ * @file gntwidget.h Widget API
+ * @ingroup gnt
+ */
+/*
  * GNT - The GLib Ncurses Toolkit
  *
  * GNT is the legal property of its developers, whose names are too numerous
--- a/finch/libgnt/gntwindow.h	Wed Jun 27 17:22:24 2007 +0000
+++ b/finch/libgnt/gntwindow.h	Wed Jun 27 17:24:32 2007 +0000
@@ -1,4 +1,8 @@
 /**
+ * @file gntwindow.h Window API
+ * @ingroup gnt
+ */
+/*
  * GNT - The GLib Ncurses Toolkit
  *
  * GNT is the legal property of its developers, whose names are too numerous
--- a/finch/libgnt/gntwm.h	Wed Jun 27 17:22:24 2007 +0000
+++ b/finch/libgnt/gntwm.h	Wed Jun 27 17:24:32 2007 +0000
@@ -1,4 +1,8 @@
 /**
+ * @file gntwm.h Window-manager API
+ * @ingroup gnt
+ */
+/*
  * GNT - The GLib Ncurses Toolkit
  *
  * GNT is the legal property of its developers, whose names are too numerous
--- a/finch/libgnt/gntws.h	Wed Jun 27 17:22:24 2007 +0000
+++ b/finch/libgnt/gntws.h	Wed Jun 27 17:24:32 2007 +0000
@@ -1,3 +1,29 @@
+/**
+ * @file gntws.h Workspace API
+ * @ingroup gnt
+ */
+/*
+ * GNT - The GLib Ncurses Toolkit
+ *
+ * GNT is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * This library 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
+ */
+
 #ifndef GNTWS_H
 #define GNTWS_H
 
--- a/libpurple/conversation.c	Wed Jun 27 17:22:24 2007 +0000
+++ b/libpurple/conversation.c	Wed Jun 27 17:24:32 2007 +0000
@@ -1563,6 +1563,7 @@
 				purple_conv_chat_is_user_ignored(chat, user);
 
 		cbuddy = purple_conv_chat_cb_new(user, alias, flag);
+		cbuddy->buddy = purple_find_buddy(conv->account, user) != NULL;
 		/* This seems dumb. Why should we set users thousands of times? */
 		purple_conv_chat_set_users(chat,
 				g_list_prepend(chat->in_room, cbuddy));
@@ -1631,11 +1632,6 @@
 	prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl);
 	g_return_if_fail(prpl_info != NULL);
 
-	flags = purple_conv_chat_user_get_flags(chat, old_user);
-	cb = purple_conv_chat_cb_new(new_user, NULL, flags);
-	purple_conv_chat_set_users(chat,
-		g_list_prepend(chat->in_room, cb));
-
 	if (!strcmp(chat->nick, purple_normalize(conv->account, old_user))) {
 		const char *alias;
 
@@ -1659,6 +1655,12 @@
 			new_alias = purple_buddy_get_contact_alias(buddy);
 	}
 
+	flags = purple_conv_chat_user_get_flags(chat, old_user);
+	cb = purple_conv_chat_cb_new(new_user, new_alias, flags);
+	cb->buddy = purple_find_buddy(conv->account, new_user) != NULL;
+	purple_conv_chat_set_users(chat,
+		g_list_prepend(chat->in_room, cb));
+
 	if (ops != NULL && ops->chat_rename_user != NULL)
 		ops->chat_rename_user(conv, old_user, new_user, new_alias);
 
@@ -1949,6 +1951,7 @@
 
 	return chat->left;
 }
+
 PurpleConvChatBuddy *
 purple_conv_chat_cb_new(const char *name, const char *alias, PurpleConvChatBuddyFlags flags)
 {
--- a/pidgin/gtkconv.c	Wed Jun 27 17:22:24 2007 +0000
+++ b/pidgin/gtkconv.c	Wed Jun 27 17:24:32 2007 +0000
@@ -347,15 +347,28 @@
 	}
 }
 
-static PurpleCmdRet
-clear_command_cb(PurpleConversation *conv,
-                 const char *cmd, char **args, char **error, void *data)
+static void clear_conversation_scrollback(PurpleConversation *conv)
 {
 	PidginConversation *gtkconv = NULL;
 
 	gtkconv = PIDGIN_CONVERSATION(conv);
 
 	gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml));
+}
+
+static PurpleCmdRet
+clear_command_cb(PurpleConversation *conv,
+                 const char *cmd, char **args, char **error, void *data)
+{
+	clear_conversation_scrollback(conv);
+	return PURPLE_CMD_STATUS_OK;
+}
+
+static PurpleCmdRet
+clearall_command_cb(PurpleConversation *conv,
+                 const char *cmd, char **args, char **error, void *data)
+{
+	purple_conversation_foreach(clear_conversation_scrollback);
 	return PURPLE_CMD_STATUS_OK;
 }
 
@@ -528,13 +541,6 @@
 
 	account = purple_conversation_get_account(conv);
 
-	if (!purple_account_is_connected(account))
-		return;
-
-	if ((purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) &&
-		purple_conv_chat_has_left(PURPLE_CONV_CHAT(conv)))
-		return;
-
 	if (check_for_and_do_command(conv)) {
 		if (gtkconv->entry_growing) {
 			reset_default_size(gtkconv);
@@ -544,6 +550,13 @@
 		return;
 	}
 
+	if ((purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) &&
+		purple_conv_chat_has_left(PURPLE_CONV_CHAT(conv)))
+		return;
+
+	if (!purple_account_is_connected(account))
+		return;
+
 	buf = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry));
 	clean = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL);
 
@@ -3671,7 +3684,7 @@
 	if (!strcmp(chat->nick, purple_normalize(conv->account, old_name != NULL ? old_name : name)))
 		is_me = TRUE;
 
-	is_buddy = (purple_find_buddy(conv->account, name) != NULL);
+	is_buddy = cb->buddy;
 
 	tmp = g_utf8_casefold(alias, -1);
 	alias_key = g_utf8_collate_key(tmp, -1);
@@ -5563,7 +5576,7 @@
 
 	g_return_if_fail(new_alias != NULL);
 
-	cbuddy = purple_conv_chat_cb_new(new_name, new_alias, flags);
+	cbuddy = purple_conv_chat_cb_find(chat, new_name);
 
 	add_chat_buddy_common(conv, cbuddy, old_name);
 }
@@ -7203,6 +7216,9 @@
 	purple_cmd_register("clear", "", PURPLE_CMD_P_DEFAULT,
 	                  PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL,
 	                  clear_command_cb, _("clear: Clears the conversation scrollback."), NULL);
+	purple_cmd_register("clearall", "", PURPLE_CMD_P_DEFAULT,
+	                  PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL,
+	                  clearall_command_cb, _("clear: Clears all conversation scrollbacks."), NULL);
 	purple_cmd_register("help", "w", PURPLE_CMD_P_DEFAULT,
 	                  PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, NULL,
 	                  help_command_cb, _("help &lt;command&gt;:  Help on a specific command."), NULL);