pidgin: e0c898b6: Allow replacing smileys with texts in co...

sadrul at pidgin.im sadrul at pidgin.im
Fri May 2 23:05:38 EDT 2008


-----------------------------------------------------------------
Revision: e0c898b6c75ee358dd659b7fde7551c304f48413
Ancestor: de954c20849206de750b57c34fb04dd7b8a8833a
Author: sadrul at pidgin.im
Date: 2008-05-03T02:49:53
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/e0c898b6c75ee358dd659b7fde7551c304f48413

Modified files:
        ChangeLog pidgin/gtkimhtml.c

ChangeLog: 

Allow replacing smileys with texts in conversations/logs. This should be
helpful for all those users who paste code in conversations.

-------------- next part --------------
============================================================
--- ChangeLog	2972081c8978ed55247a6d6c78011bf0c2f4f672
+++ ChangeLog	6ddb67149048c10fc63ecef7a63ffba2a2f605b9
@@ -24,6 +24,9 @@ version 2.x.x:
 	  workspaces the "Present" option should.
 	* Add a preference to set Escape as the keyboard shortcut for closing
 	  the conversation window.
+	* Add an option in the context menu to disable smileys in the selected
+	  text in the conversation history/log viewer. This should help people who
+	  regularly paste code in conversations.
 
 	General:
 	* The configure script now dies on more absent dependencies.  The
============================================================
--- pidgin/gtkimhtml.c	ef7bbc3ce686b2a465ef6a0d1605492eeb951a2e
+++ pidgin/gtkimhtml.c	cfd8f23ab7ba5b67bafb67fe23ea7fdd514c25aa
@@ -814,9 +814,30 @@ static void clear_formatting_cb(GtkMenuI
 	gtk_imhtml_clear_formatting(imhtml);
 }
 
+static void disable_smiley_selected(GtkMenuItem *item, GtkIMHtml *imhtml)
+{
+	GtkTextIter start, end;
+	GtkTextMark *mark;
+	char *text;
+
+	if (!gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end))
+		return;
+
+	text = gtk_imhtml_get_markup_range(imhtml, &start, &end);
+
+	mark = gtk_text_buffer_get_selection_bound(imhtml->text_buffer);
+	gtk_text_buffer_delete_selection(imhtml->text_buffer, FALSE, FALSE);
+
+	gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &start, mark);
+	gtk_imhtml_insert_html_at_iter(imhtml, text, GTK_IMHTML_NO_NEWLINE | GTK_IMHTML_NO_SMILEY, &start);
+
+	g_free(text);
+}
+
 static void hijack_menu_cb(GtkIMHtml *imhtml, GtkMenu *menu, gpointer data)
 {
 	GtkWidget *menuitem;
+	GtkTextIter start, end;
 
 	menuitem = gtk_menu_item_new_with_mnemonic(_("Paste as Plain _Text"));
 	gtk_widget_show(menuitem);
@@ -842,6 +863,15 @@ static void hijack_menu_cb(GtkIMHtml *im
 	gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 5);
 
 	g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(clear_formatting_cb), imhtml);
+
+	menuitem = gtk_menu_item_new_with_mnemonic(_("Disable _smileys in selected text"));
+	gtk_widget_show(menuitem);
+	if (gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) {
+		g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(disable_smiley_selected), imhtml);
+	} else {
+		gtk_widget_set_sensitive(menuitem, FALSE);
+	}
+	gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 6);
 }
 
 static char *
@@ -1458,10 +1488,8 @@ static void gtk_imhtml_init (GtkIMHtml *
 
 static void gtk_imhtml_init (GtkIMHtml *imhtml)
 {
-	GtkTextIter iter;
 	imhtml->text_buffer = gtk_text_buffer_new(NULL);
 	imhtml->undo_manager = gtk_source_undo_manager_new(imhtml->text_buffer);
-	gtk_text_buffer_get_end_iter (imhtml->text_buffer, &iter);
 	gtk_text_view_set_buffer(GTK_TEXT_VIEW(imhtml), imhtml->text_buffer);
 	gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(imhtml), GTK_WRAP_WORD_CHAR);
 	gtk_text_view_set_pixels_above_lines(GTK_TEXT_VIEW(imhtml), 2);


More information about the Commits mailing list