changeset 7735:edebf99a5ec4

[gaim-migrate @ 8380] WYSIWYGation of the smileys. These will only WYSIWYG when you use the select smiley dialog, although with the smiley tree being so perfect for something like lookup smiley while you search, we could easily auto-replace smileys. But then we would have to worry about stuff like :) and :)) being different. I'm going to leave it this way for now. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Thu, 04 Dec 2003 05:06:59 +0000
parents e11cef6aabba
children 662a33ce4343
files src/dialogs.c src/gtkconv.c src/gtkimhtml.c
diffstat 3 files changed, 42 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/dialogs.c	Thu Dec 04 04:22:44 2003 +0000
+++ b/src/dialogs.c	Thu Dec 04 05:06:59 2003 +0000
@@ -1576,17 +1576,9 @@
 	GtkTextIter select_iter, insert_iter;
 
 	gtkconv = GAIM_GTK_CONVERSATION(c);
-
-	select_mark = gtk_text_buffer_get_selection_bound(gtkconv->entry_buffer);
-	insert_mark = gtk_text_buffer_get_insert(gtkconv->entry_buffer);
-
-	if(insert_mark != select_mark) { /* there is text selected */
-		gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &select_iter, select_mark);
-		gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &insert_iter, insert_mark);
-		gtk_text_buffer_delete(gtkconv->entry_buffer, &select_iter, &insert_iter);
-	}
-
-	gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, smiley_text, -1);
+	
+	gtk_imhtml_insert_smiley(GTK_IMHTML(gtkconv->entry), smiley_text);
+	
 	close_smiley_dialog(NULL, c);
 }
 
--- a/src/gtkconv.c	Thu Dec 04 04:22:44 2003 +0000
+++ b/src/gtkconv.c	Thu Dec 04 05:06:59 2003 +0000
@@ -3581,7 +3581,8 @@
 	gtkconv->entry_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry));
 	g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", conv);
 	gtk_imhtml_set_editable(GTK_IMHTML(gtkconv->entry), TRUE);
-	
+	gaim_setup_imhtml(GTK_IMHTML(gtkconv->entry));
+		
 	gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(gtkconv->entry), GTK_WRAP_WORD_CHAR);
 	gtk_widget_set_size_request(gtkconv->entry, -1,
 			MAX(gaim_prefs_get_int("/gaim/gtk/conversations/chat/entry_height"),
@@ -3679,6 +3680,7 @@
 
 	gtkconv->entry = gtk_imhtml_new(NULL, NULL);
 	gtk_imhtml_set_editable(GTK_IMHTML(gtkconv->entry), TRUE);
+	gaim_setup_imhtml(GTK_IMHTML(gtkconv->entry));
 	gtkconv->entry_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry));
 	g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", conv);
 	gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(gtkconv->entry), GTK_WRAP_WORD_CHAR);
--- a/src/gtkimhtml.c	Thu Dec 04 04:22:44 2003 +0000
+++ b/src/gtkimhtml.c	Thu Dec 04 05:06:59 2003 +0000
@@ -2194,6 +2194,39 @@
 	imhtml->format_spans = g_list_append(imhtml->format_spans, span);
 }
 
+void gtk_imhtml_insert_smiley(GtkIMHtml *imhtml, const char *smiley)
+{
+	GtkTextMark *ins = gtk_text_buffer_get_insert(imhtml->text_buffer);
+	GtkTextIter iter;
+	gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, ins);
+	GdkPixbuf *pixbuf = NULL;
+	GdkPixbufAnimation *annipixbuf = NULL;
+	GtkWidget *icon = NULL;
+
+	GtkTextChildAnchor *anchor = gtk_text_buffer_create_child_anchor(imhtml->text_buffer, &iter);
+	g_object_set_data(G_OBJECT(anchor), "text_tag", smiley);
+	annipixbuf = gtk_smiley_tree_image(imhtml, NULL, smiley);
+	if(annipixbuf) {
+		if(gdk_pixbuf_animation_is_static_image(annipixbuf)) {
+			pixbuf = gdk_pixbuf_animation_get_static_image(annipixbuf);
+			if(pixbuf)
+				icon = gtk_image_new_from_pixbuf(pixbuf);
+		} else {
+			icon = gtk_image_new_from_animation(annipixbuf);
+		}
+	}
+	
+	if (icon) {
+		gtk_widget_show(icon);
+		gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(imhtml), icon, anchor);
+#if GTK_CHECK_VERSION(2,2,0)
+		gtk_imhtml_copyable_new(imhtml, 
+					gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, TRUE), 
+					smiley);
+#endif
+	}
+}
+
 int span_compare_begin(const GtkIMHtmlFormatSpan *a, const GtkIMHtmlFormatSpan *b, GtkTextBuffer *buffer)
 {
 	GtkTextIter ia, ib;
@@ -2239,7 +2272,9 @@
 
 	while ((c = gtk_text_iter_get_char(&iter)) != 0) {
 		if (c == 0xFFFC) {
-			/* This is an image or a smiley */
+			GtkTextChildAnchor* anchor = gtk_text_iter_get_child_anchor(&iter);
+			char *text = g_object_get_data(G_OBJECT(anchor), "text_tag");
+			str = g_string_append(str, text);
 		} else {
 			while (gtk_text_iter_equal(&eiter, &iter)) {
 				/* This is where we shall insert the ending tag of