Mercurial > pidgin.yaz
changeset 31920:32a00b76ce49
Patch from kawaii.neko that adds chat-nick-clicked and chat-nick-autocomplete
signals to do interesting stuff like allowing a plugin to override tab
completion or do stuff when a nick in a chat userlist is clocked. Still need
a name to credit kawaii.neko properly. Fixes #12599.
author | John Bailey <rekkanoryo@rekkanoryo.org> |
---|---|
date | Sat, 16 Apr 2011 18:56:17 +0000 |
parents | 283cee80741e |
children | 0e7c5fe661e5 |
files | pidgin/gtkconv.c |
diffstat | 1 files changed, 55 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/pidgin/gtkconv.c Sat Apr 16 15:49:39 2011 +0000 +++ b/pidgin/gtkconv.c Sat Apr 16 18:56:17 2011 +0000 @@ -1792,6 +1792,15 @@ gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, path); gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &who, -1); + /* emit chat-nick-clicked signal */ + if (event->type == GDK_BUTTON_PRESS) { + gint plugin_return = GPOINTER_TO_INT(purple_signal_emit_return_1( + pidgin_conversations_get_handle(), "chat-nick-clicked", + conv, who, event->button)); + if (plugin_return) + goto handled; + } + if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) { chat_do_im(gtkconv, who); } else if (event->button == 2 && event->type == GDK_BUTTON_PRESS) { @@ -1806,6 +1815,7 @@ event->button, event->time); } +handled: g_free(who); gtk_tree_path_free(path); @@ -2122,7 +2132,13 @@ case GDK_ISO_Left_Tab: if (gtkconv->entry != entry) break; - return tab_complete(conv); + { + gint plugin_return; + plugin_return = GPOINTER_TO_INT(purple_signal_emit_return_1( + pidgin_conversations_get_handle(), "chat-nick-autocomplete", + conv, event->state & GDK_SHIFT_MASK)); + return plugin_return ? TRUE : tab_complete(conv); + } break; case GDK_Page_Up: @@ -5586,6 +5602,15 @@ buddyname = (tag->name) + 6; + /* emit chat-nick-clicked signal */ + if (event->type == GDK_BUTTON_PRESS) { + gint plugin_return = GPOINTER_TO_INT(purple_signal_emit_return_1( + pidgin_conversations_get_handle(), "chat-nick-clicked", + data, buddyname, btn_event->button)); + if (plugin_return) + return TRUE; + } + if (btn_event->button == 1 && event->type == GDK_2BUTTON_PRESS) { chat_do_im(PIDGIN_CONVERSATION(conv), buddyname); @@ -7817,6 +7842,20 @@ return &handle; } +static void +pidgin_marshal_BOOLEAN__POINTER_BOOLEAN(PurpleCallback cb, va_list args, + void *data, void **return_val) +{ + gboolean ret_val; + void *arg1 = va_arg(args, void *); + gboolean arg2 = va_arg(args, gboolean); + + ret_val = ((gboolean (*)(void *, gboolean, void *))cb)(arg1, arg2, data); + + if (return_val != NULL) + *return_val = GINT_TO_POINTER(ret_val); +} + void pidgin_conversations_init(void) { @@ -8003,6 +8042,21 @@ purple_value_new(PURPLE_TYPE_BOXED, "PidginConversation *")); + purple_signal_register(handle, "chat-nick-autocomplete", + pidgin_marshal_BOOLEAN__POINTER_BOOLEAN, + purple_value_new(PURPLE_TYPE_BOOLEAN), 1, + purple_value_new(PURPLE_TYPE_SUBTYPE, + PURPLE_SUBTYPE_CONVERSATION)); + + purple_signal_register(handle, "chat-nick-clicked", + purple_marshal_BOOLEAN__POINTER_POINTER_UINT, + purple_value_new(PURPLE_TYPE_BOOLEAN), 3, + purple_value_new(PURPLE_TYPE_SUBTYPE, + PURPLE_SUBTYPE_CONVERSATION), + purple_value_new(PURPLE_TYPE_STRING), + purple_value_new(PURPLE_TYPE_UINT)); + + /********************************************************************** * Register commands **********************************************************************/