# HG changeset patch # User Sadrul Habib Chowdhury # Date 1208151018 0 # Node ID 47731d2e9fe40bdf86dfebdbfe3a497ee25d0cc3 # Parent 864c82371181216d0624fa4487d401a824d9ee23 Add a 'Jump to markerline' option in the conversation window menu to jump to the markerline. The menuitem can be assigned a hotkey using the usual 'press key while hovering' GTK+ method. Closes #5355. diff -r 864c82371181 -r 47731d2e9fe4 pidgin/plugins/markerline.c --- a/pidgin/plugins/markerline.c Sun Apr 13 17:47:25 2008 +0000 +++ b/pidgin/plugins/markerline.c Mon Apr 14 05:30:18 2008 +0000 @@ -216,6 +216,32 @@ attach_to_pidgin_window(win, NULL); } +static void +jump_to_markerline(PurpleConversation *conv, gpointer null) +{ + PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); + int offset; + GtkTextIter iter; + + if (!gtkconv) + return; + + offset = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(gtkconv->imhtml), "markerline")); + gtk_text_buffer_get_iter_at_offset(GTK_IMHTML(gtkconv->imhtml)->text_buffer, &iter, offset); + gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(gtkconv->imhtml), &iter, 0, TRUE, 0, 0); +} + +static void +conv_menu_cb(PurpleConversation *conv, GList **list) +{ + PurpleConversationType type = purple_conversation_get_type(conv); + gboolean enabled = ((type == PURPLE_CONV_TYPE_IM && purple_prefs_get_bool(PREF_IMS)) || + (type == PURPLE_CONV_TYPE_CHAT && purple_prefs_get_bool(PREF_CHATS))); + PurpleMenuAction *action = purple_menu_action_new(_("Jump to markerline"), + enabled ? PURPLE_CALLBACK(jump_to_markerline) : NULL, NULL, NULL); + *list = g_list_append(*list, action); +} + static gboolean plugin_load(PurplePlugin *plugin) { @@ -224,6 +250,8 @@ purple_signal_connect(purple_conversations_get_handle(), "conversation-created", plugin, PURPLE_CALLBACK(conv_created), NULL); + purple_signal_connect(purple_conversations_get_handle(), "conversation-extended-menu", + plugin, PURPLE_CALLBACK(conv_menu_cb), NULL); return TRUE; }