pidgin: ece03c16: Add a cleared-message-history conversati...
darkrain42 at pidgin.im
darkrain42 at pidgin.im
Thu Mar 31 00:46:32 EDT 2011
----------------------------------------------------------------------
Revision: ece03c16966f58e1db43e5c20fe35a6707b468d2
Parent: 312b5a74ad324337a47554ec05943a58f68c2ae1
Author: darkrain42 at pidgin.im
Date: 03/31/11 00:41:27
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/ece03c16966f58e1db43e5c20fe35a6707b468d2
Changelog:
Add a cleared-message-history conversation signal, and use it in Pidgin and Finch
This stems out of an email discussion with Andrew Victor back in July 2010
regarding letting protocol plugins clear the message scrollback area for
UIs. At the time, nobody objected to having the libpurple-clearing function
call the UI clearing function.
This should also be happily backward-compatible.
Changes against parent 312b5a74ad324337a47554ec05943a58f68c2ae1
patched ChangeLog.API
patched doc/conversation-signals.dox
patched finch/gntconv.c
patched libpurple/conversation.c
patched pidgin/gtkconv.c
-------------- next part --------------
============================================================
--- libpurple/conversation.c 7cede383dd7d23720d80e0517411b41e088b87cd
+++ libpurple/conversation.c 5d997f74639ed482eeb33a121b140ba6d52d4ce3
@@ -575,6 +575,7 @@ purple_conversation_destroy(PurpleConver
if (ops != NULL && ops->destroy_conversation != NULL)
ops->destroy_conversation(conv);
+ conv->ui_data = NULL;
purple_conversation_close_logs(conv);
@@ -2270,6 +2271,9 @@ void purple_conversation_clear_message_h
GList *list = conv->message_history;
message_history_free(list);
conv->message_history = NULL;
+
+ purple_signal_emit(purple_conversations_get_handle(),
+ "cleared-message-history", conv);
}
GList *purple_conversation_get_message_history(PurpleConversation *conv)
@@ -2626,6 +2630,11 @@ purple_conversations_init(void)
purple_value_new(PURPLE_TYPE_STRING),
purple_value_new(PURPLE_TYPE_STRING));
+ purple_signal_register(handle, "cleared-message-history",
+ purple_marshal_VOID__POINTER, NULL, 1,
+ purple_value_new(PURPLE_TYPE_SUBTYPE,
+ PURPLE_SUBTYPE_CONVERSATION));
+
purple_signal_register(handle, "conversation-extended-menu",
purple_marshal_VOID__POINTER_POINTER, NULL, 2,
purple_value_new(PURPLE_TYPE_SUBTYPE,
============================================================
--- pidgin/gtkconv.c 84e25635f43d1febebda7de8e6a45ea9ae732f78
+++ pidgin/gtkconv.c 75b545a8073539f2aae4e9607a59b45a02044db7
@@ -373,23 +373,21 @@ debug_command_cb(PurpleConversation *con
return PURPLE_CMD_RET_OK;
}
-static void clear_conversation_scrollback(PurpleConversation *conv)
+static void clear_conversation_scrollback_cb(PurpleConversation *conv,
+ void *data)
{
PidginConversation *gtkconv = NULL;
- GList *iter;
gtkconv = PIDGIN_CONVERSATION(conv);
-
- gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml));
- for (iter = gtkconv->convs; iter; iter = iter->next)
- purple_conversation_clear_message_history(iter->data);
+ if (gtkconv)
+ 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);
+ purple_conversation_clear_message_history(conv);
return PURPLE_CMD_RET_OK;
}
@@ -397,7 +395,7 @@ clearall_command_cb(PurpleConversation *
clearall_command_cb(PurpleConversation *conv,
const char *cmd, char **args, char **error, void *data)
{
- purple_conversation_foreach(clear_conversation_scrollback);
+ purple_conversation_foreach(purple_conversation_clear_message_history);
return PURPLE_CMD_RET_OK;
}
@@ -1113,7 +1111,7 @@ menu_clear_cb(gpointer data, guint actio
PurpleConversation *conv;
conv = pidgin_conv_window_get_active_conversation(win);
- clear_conversation_scrollback(conv);
+ purple_conversation_clear_message_history(conv);
}
static void
@@ -8042,6 +8040,8 @@ pidgin_conversations_init(void)
purple_signal_connect(purple_conversations_get_handle(), "received-im-msg",
handle, G_CALLBACK(received_im_msg_cb), NULL);
+ purple_signal_connect(purple_conversations_get_handle(), "cleared-message-history",
+ handle, G_CALLBACK(clear_conversation_scrollback_cb), NULL);
purple_conversations_set_ui_ops(&conversation_ui_ops);
============================================================
--- doc/conversation-signals.dox f06464400cbec6ffa08160bb417b151bef3aa399
+++ doc/conversation-signals.dox a5115551dcbf617a6d099b0ea4ce1916a28be613
@@ -32,6 +32,7 @@
@signal chat-join-failed
@signal chat-left
@signal chat-topic-changed
+ @signal cleared-message-history
@signal conversation-extended-menu
@signal sent-attention
@signal got-attention
@@ -479,6 +480,16 @@ void (*conversation_extended_menu)(Purpl
@since 2.1.0
@endsignaldef
+ @signaldef cleared-message-history
+ @signalproto
+void (*cleared_message_history)(PurpleConversation *conv);
+ @endsignalproto
+ @signaldesc
+ Emitted when the conversation history is cleared.
+ @param conv The conversation.
+ @since 2.8.0
+ @endsignaldef
+
@signaldef sent-attention
@signalproto
void (*got_attention)(PurpleAccount *account, const char *who,
============================================================
--- ChangeLog.API 59e0fad480f101d6695f7c6b20723c3d8e3dfc95
+++ ChangeLog.API 6f06ef113960920b8ea0a23bb68db81c42e0ffca
@@ -5,6 +5,7 @@ version 2.8.0 (??/??/????):
Added:
* account-authorization-requested-with-message signal (Stefan Ott)
(#8690)
+ * cleared-message-history signal (conversation signals)
* purple_account_add_buddy_with_invite
* purple_account_add_buddies_with_invite
* purple_notify_user_info_add_pair_plaintext
============================================================
--- finch/gntconv.c f90604cda09e9264d42bfe6701836f484d439ed1
+++ finch/gntconv.c 8f20eed2313420bc2b05aecc8d16eb9fc775c75e
@@ -396,10 +396,18 @@ static void
}
static void
+cleared_message_history_cb(PurpleConversation *conv, gpointer data)
+{
+ FinchConv *ggc = FINCH_GET_DATA(conv);
+ if (ggc)
+ gnt_text_view_clear(GNT_TEXT_VIEW(ggc->tv));
+}
+
+static void
clear_scrollback_cb(GntMenuItem *item, gpointer ggconv)
{
FinchConv *ggc = ggconv;
- gnt_text_view_clear(GNT_TEXT_VIEW(ggc->tv));
+ purple_conversation_clear_message_history(ggc->active_conv);
}
static void
@@ -1264,8 +1272,6 @@ clear_command_cb(PurpleConversation *con
clear_command_cb(PurpleConversation *conv,
const char *cmd, char **args, char **error, void *data)
{
- FinchConv *ggconv = FINCH_GET_DATA(conv);
- gnt_text_view_clear(GNT_TEXT_VIEW(ggconv->tv));
purple_conversation_clear_message_history(conv);
return PURPLE_CMD_RET_OK;
}
@@ -1459,6 +1465,8 @@ void finch_conversation_init()
PURPLE_CALLBACK(update_buddy_typing), NULL);
purple_signal_connect(purple_conversations_get_handle(), "chat-left", finch_conv_get_handle(),
PURPLE_CALLBACK(chat_left_cb), NULL);
+ purple_signal_connect(purple_conversations_get_handle(), "cleared-message-history", finch_conv_get_handle(),
+ PURPLE_CALLBACK(cleared_message_history_cb), NULL);
purple_signal_connect(purple_blist_get_handle(), "buddy-signed-on", finch_conv_get_handle(),
PURPLE_CALLBACK(buddy_signed_on_off), NULL);
purple_signal_connect(purple_blist_get_handle(), "buddy-signed-off", finch_conv_get_handle(),
More information about the Commits
mailing list