changeset 22666:47731d2e9fe4

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.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Mon, 14 Apr 2008 05:30:18 +0000
parents 864c82371181
children 6827600df4fc 3378d2701c2b
files pidgin/plugins/markerline.c
diffstat 1 files changed, 28 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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;
 }