# HG changeset patch # User Richard Laager # Date 1135314832 0 # Node ID 366326fa9cb447a21b8e5f764b66413c6938701a # Parent 7a2a2ca487030df68c0def9f85727f611fa8325c [gaim-migrate @ 14975] SF Patch #1323534 from Sadrul "There is a documented signal `conversation-switched', which never gets emitted. This patch emits this signal when a conversation is switched. This signal can be used by plugins that may want to deal with menu-items / menu-tray items etc." "The conversation-switched signals is moved to gtkconv, -switching signal is removed. Changelog.API and doc/.dox files are updated. I have included the changes in displaying-signals in the dox-files as well." Also, I added a cast to the code from my last commit to suppress a warning. I wish C knew about object oriented inheritance. committer: Tailor Script diff -r 7a2a2ca48703 -r 366326fa9cb4 doc/conversation-signals.dox --- a/doc/conversation-signals.dox Fri Dec 23 05:00:47 2005 +0000 +++ b/doc/conversation-signals.dox Fri Dec 23 05:13:52 2005 +0000 @@ -3,22 +3,16 @@ @signals @signal writing-im-msg @signal wrote-im-msg - @signal displaying-im-msg - @signal displayed-im-msg @signal sending-im-msg @signal sent-im-msg @signal receiving-im-msg @signal received-im-msg @signal writing-chat-msg @signal wrote-chat-msg - @signal displaying-chat-msg - @signal displayed-chat-msg @signal sending-chat-msg @signal sent-chat-msg @signal receiving-chat-msg @signal received-chat-msg - @signal conversation-switching - @signal conversation-switched @signal conversation-created @signal conversation-updated @signal deleting-conversation @@ -61,36 +55,7 @@ @signaldesc Emitted after a message is entered by the user, but before it is sent and displyed. When sending an IM, the order that the im-msg callbacks will be called is: - writing-im-msg, wrote-im-msg, displaying-im-msg, displayed-im-msg, sending-im-msg, - and finally sent-im-msg. - @param account The account the message was displayed on. - @param conv The conversation the message was displayed on. - @param message The message that was displayed. - @endsignaldef - - @signaldef displaying-im-msg - @signalproto -gboolean (*displaying_im_msg)(GaimAccount *account, GaimConversation *conv, char **message); - @endsignalproto - @signaldesc - Emitted just before a message is displayed in an IM conversation. - @a message is a pointer to a string, so the plugin can replace the - message that will be displayed. This can also be used to cancel displaying - a message by returning @c TRUE. - @note - Make sure to free @a *message before you replace it! - @param account The account the message is being displayed on. - @param conv The conversation the message is being displayed on. - @param message A pointer to the message that will be displayed. - @return @c TRUE if the message should be canceled, or @c FALSE otherwise. - @endsignaldef - - @signaldef displayed-im-msg - @signalproto -void (*displayed_im_msg)(GaimAccount *account, GaimConversation *conv, const char *message); - @endsignalproto - @signaldesc - Emitted after a message is displayed in an IM conversation. + writing-im-msg, wrote-im-msg, sending-im-msg, and finally sent-im-msg. @param account The account the message was displayed on. @param conv The conversation the message was displayed on. @param message The message that was displayed. @@ -182,36 +147,8 @@ @signaldesc Emitted after a message is entered by the user, but before it is sent and displyed. When sending an IM, the order that the im-msg callbacks will be called is: - writing-im-msg, wrote-im-msg, displaying-im-msg, displayed-im-msg, sending-im-msg, - and finally sent-im-msg. - @param account The account the message was displayed on. - @param conv The conversation the message was displayed on. - @param message The message that was displayed. - @endsignaldef - - @signaldef displaying-chat-msg - @signalproto -gboolean (*displaying_chat_msg)(GaimAccount *account, GaimConversation *conv, char **message); - @endsignalproto - @signaldesc - Emitted just before a message is displayed in a chat. - @a message is a pointer to a string, so the plugin can replace the - message that will be displayed. This can also be used to cancel displaying - a message by returning @c TRUE. - @note - Make sure to free @a *message before you replace it! - @param account The account the message is being displayed on. - @param conv The conversation the message is being displayed on. - @param message A pointer to the message that will be displayed. - @return @c TRUE if the message should be canceled, or @c FALSE otherwise. - @endsignaldef - - @signaldef displayed-chat-msg - @signalproto -void (*displayed_chat_msg)(GaimAccount *account, GaimConversation *conv, const char *message); - @endsignalproto - @signaldesc - Emitted after a message is displayed in a chat conversation. + writing-chat-msg, wrote-chat-msg, sending-chat-msg, and finally + sent-chat-msg. @param account The account the message was displayed on. @param conv The conversation the message was displayed on. @param message The message that was displayed. @@ -276,29 +213,6 @@ @param flags The chat message flags. @endsignaldef - @signaldef conversation-switching - @signalproto -void (*conversation_switching)(GaimConversation *old_conv, - GaimConversation *new_conv); - @endsignalproto - @signaldesc - Emitted when a window is about to switch from one conversation to - another. - @param old_conv The old active conversation. - @param new_conv The soon-to-be active conversation - @endsignaldef - - @signaldef conversation-switched - @signalproto -void (*conversation_switched)(GaimConversation *old_conv, - GaimConversation *new_conv); - @endsignalproto - @signaldesc - Emitted when a window switched from one conversation to another. - @param old_conv The old active conversation. - @param new_conv The now active conversation. - @endsignaldef - @signaldef conversation-created @signalproto void (*conversation_created)(GaimConversation *conv); diff -r 7a2a2ca48703 -r 366326fa9cb4 doc/gtkconv-signals.dox --- a/doc/gtkconv-signals.dox Fri Dec 23 05:00:47 2005 +0000 +++ b/doc/gtkconv-signals.dox Fri Dec 23 05:13:52 2005 +0000 @@ -2,6 +2,11 @@ @signals @signal conversation-dragging + @signal displaying-im-msg + @signal displayed-im-msg + @signal displaying-chat-msg + @signal displayed-chat-msg + @signal conversation-switched @endsignals
@@ -15,5 +20,79 @@ @param source The window where the conversation is. @param destination The window where the conversation will be moved to. @endsignaldef + + @signaldef displaying-im-msg + @signalproto +gboolean (*displaying_im_msg)(GaimAccount *account, GaimConversation *conv, + char **message, GaimMessageFlags flags); + @endsignalproto + @signaldesc + Emitted just before a message is displayed in an IM conversation. + @a message is a pointer to a string, so the plugin can replace the + message that will be displayed. This can also be used to cancel displaying + a message by returning @c TRUE. + @note + Make sure to free @a *message before you replace it! + @param account The account the message is being displayed on. + @param conv The conversation the message is being displayed on. + @param message A pointer to the message that will be displayed. + @param flags The message flags. + @return @c TRUE if the message should be canceled, or @c FALSE otherwise. + @endsignaldef + + @signaldef displayed-im-msg + @signalproto +void (*displayed_im_msg)(GaimAccount *account, GaimConversation *conv, + const char *message, GaimMessageFlags flags); + @endsignalproto + @signaldesc + Emitted after a message is displayed in an IM conversation. + @param account The account the message was displayed on. + @param conv The conversation the message was displayed on. + @param message The message that was displayed. + @param flags The message flags. + @endsignaldef + + @signaldef displaying-chat-msg + @signalproto +gboolean (*displaying_chat_msg)(GaimAccount *account, GaimConversation *conv, + char **message, GaimMessageFlags flags); + @endsignalproto + @signaldesc + Emitted just before a message is displayed in a chat. + @a message is a pointer to a string, so the plugin can replace the + message that will be displayed. This can also be used to cancel displaying + a message by returning @c TRUE. + @note + Make sure to free @a *message before you replace it! + @param account The account the message is being displayed on. + @param conv The conversation the message is being displayed on. + @param message A pointer to the message that will be displayed. + @param flags The message flags. + @return @c TRUE if the message should be canceled, or @c FALSE otherwise. + @endsignaldef + + @signaldef displayed-chat-msg + @signalproto +void (*displayed_chat_msg)(GaimAccount *account, GaimConversation *conv, + const char *message, GaimMessageFlags flags); + @endsignalproto + @signaldesc + Emitted after a message is displayed in a chat conversation. + @param account The account the message was displayed on. + @param conv The conversation the message was displayed on. + @param message The message that was displayed. + @param flags The message flags. + @endsignaldef + + @signaldef conversation-switched + @signalproto +void (*conversation_switched)(GaimConversation *conv); + @endsignalproto + @signaldesc + Emitted when a window switched from one conversation to another. + @param new_conv The now active conversation. + @endsignaldef + */ // vim: syntax=c tw=75 et diff -r 7a2a2ca48703 -r 366326fa9cb4 plugins/ChangeLog.API --- a/plugins/ChangeLog.API Fri Dec 23 05:00:47 2005 +0000 +++ b/plugins/ChangeLog.API Fri Dec 23 05:13:52 2005 +0000 @@ -78,6 +78,9 @@ messages etc.), and the signals now have gaim_gtk_conversations_get_handle() for their handle. * GAIM_NOTIFY_BUTTON_ADD_BUDDY to GAIM_NOTIFY_BUTTON_ADD + * conversation-switched: This signal has been moved from conversation to + the UI and the signal-handlers only receive the + conversation that has been switched to. Removed: * gaim_gtk_sound_{get,set}_mute() (replaced by the /gaim/gtk/sound/mute @@ -123,6 +126,7 @@ * GaimConvImFlags and GaimConvChatFlags; use GaimMessageFlags instead * cb and user_data from the ops in GaimNotifyUiOps: This is now handled by the notify API in the core. + * conversation-switching signal has been removed. Added: * gaim_prefs_disconnect_by_handle() diff -r 7a2a2ca48703 -r 366326fa9cb4 plugins/gtk-signals-test.c --- a/plugins/gtk-signals-test.c Fri Dec 23 05:00:47 2005 +0000 +++ b/plugins/gtk-signals-test.c Fri Dec 23 05:13:52 2005 +0000 @@ -94,6 +94,13 @@ gaim_conversation_get_name(conv), buffer); } +static void +conversation_switched_cb(GaimConversation *conv, void *data) +{ + gaim_debug_misc("gtk-signals test", "conversation-switched (%s)\n", + gaim_conversation_get_name(conv)); +} + /************************************************************************** * Plugin stuff **************************************************************************/ @@ -125,6 +132,8 @@ plugin, GAIM_CALLBACK(displaying_chat_msg_cb), NULL); gaim_signal_connect(conv_handle, "displayed-chat-msg", plugin, GAIM_CALLBACK(displayed_chat_msg_cb), NULL); + gaim_signal_connect(conv_handle, "conversation-switched", + plugin, GAIM_CALLBACK(conversation_switched_cb), NULL); return TRUE; } diff -r 7a2a2ca48703 -r 366326fa9cb4 plugins/signals-test.c --- a/plugins/signals-test.c Fri Dec 23 05:00:47 2005 +0000 +++ b/plugins/signals-test.c Fri Dec 23 05:13:52 2005 +0000 @@ -307,24 +307,6 @@ } static void -conversation_switching_cb(GaimConversation *old_conv, - GaimConversation *new_conv, void *data) -{ - gaim_debug_misc("signals test", "conversation-switching (%s, %s)\n", - gaim_conversation_get_name(old_conv), - gaim_conversation_get_name(new_conv)); -} - -static void -conversation_switched_cb(GaimConversation *old_conv, - GaimConversation *new_conv, void *data) -{ - gaim_debug_misc("signals test", "conversation-switched (%s, %s)\n", - gaim_conversation_get_name(old_conv), - gaim_conversation_get_name(new_conv)); -} - -static void conversation_created_cb(GaimConversation *conv, void *data) { gaim_debug_misc("signals test", "conversation-created (%s)\n", @@ -605,10 +587,6 @@ plugin, GAIM_CALLBACK(receiving_chat_msg_cb), NULL); gaim_signal_connect(conv_handle, "received-chat-msg", plugin, GAIM_CALLBACK(received_chat_msg_cb), NULL); - gaim_signal_connect(conv_handle, "conversation-switching", - plugin, GAIM_CALLBACK(conversation_switching_cb), NULL); - gaim_signal_connect(conv_handle, "conversation-switched", - plugin, GAIM_CALLBACK(conversation_switched_cb), NULL); gaim_signal_connect(conv_handle, "conversation-created", plugin, GAIM_CALLBACK(conversation_created_cb), NULL); gaim_signal_connect(conv_handle, "deleting-conversation", diff -r 7a2a2ca48703 -r 366326fa9cb4 src/conversation.c --- a/src/conversation.c Fri Dec 23 05:00:47 2005 +0000 +++ b/src/conversation.c Fri Dec 23 05:13:52 2005 +0000 @@ -2105,20 +2105,6 @@ GAIM_SUBTYPE_CONVERSATION), gaim_value_new(GAIM_TYPE_UINT)); - gaim_signal_register(handle, "conversation-switching", - gaim_marshal_VOID__POINTER_POINTER, NULL, 2, - gaim_value_new(GAIM_TYPE_SUBTYPE, - GAIM_SUBTYPE_CONVERSATION), - gaim_value_new(GAIM_TYPE_SUBTYPE, - GAIM_SUBTYPE_CONVERSATION)); - - gaim_signal_register(handle, "conversation-switched", - gaim_marshal_VOID__POINTER_POINTER, NULL, 2, - gaim_value_new(GAIM_TYPE_SUBTYPE, - GAIM_SUBTYPE_CONVERSATION), - gaim_value_new(GAIM_TYPE_SUBTYPE, - GAIM_SUBTYPE_CONVERSATION)); - gaim_signal_register(handle, "conversation-created", gaim_marshal_VOID__POINTER, NULL, 1, gaim_value_new(GAIM_TYPE_SUBTYPE, diff -r 7a2a2ca48703 -r 366326fa9cb4 src/gtkconv.c --- a/src/gtkconv.c Fri Dec 23 05:00:47 2005 +0000 +++ b/src/gtkconv.c Fri Dec 23 05:13:52 2005 +0000 @@ -1985,6 +1985,8 @@ gaim_conversation_set_logging(conv, gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(gtkconv->win->menu.logging))); + + gaim_signal_emit(gaim_gtk_conversations_get_handle(), "conversation-switched", conv); } void @@ -2990,7 +2992,7 @@ for (node = node->child; node != NULL; node = node->next) { - GaimBuddy *buddy = node; + GaimBuddy *buddy = (GaimBuddy *)node; GaimAccount *account; if (!GAIM_BLIST_NODE_IS_BUDDY(node)) @@ -6178,6 +6180,11 @@ gaim_value_new(GAIM_TYPE_STRING), gaim_value_new(G_TYPE_INT)); + gaim_signal_register(handle, "conversation-switched", + gaim_marshal_VOID__POINTER_POINTER, NULL, 1, + gaim_value_new(GAIM_TYPE_SUBTYPE, + GAIM_SUBTYPE_CONVERSATION)); + /********************************************************************** * Register commands **********************************************************************/ @@ -6969,6 +6976,8 @@ if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && (gtkconv->u.im->animate)) start_anim(NULL, gtkconv); + + gaim_signal_emit(gaim_gtk_conversations_get_handle(), "conversation-switched", conv); } /**************************************************************************