changeset 7717:db3bdae1761e

[gaim-migrate @ 8362] And font face. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Wed, 03 Dec 2003 05:12:24 +0000
parents 911f03121652
children da04da151ec6
files src/gtkconv.c src/gtkimhtml.c src/gtkimhtml.h src/gtkutils.c
diffstat 4 files changed, 36 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkconv.c	Wed Dec 03 04:30:56 2003 +0000
+++ b/src/gtkconv.c	Wed Dec 03 05:12:24 2003 +0000
@@ -2242,12 +2242,7 @@
 
 	gtkconv = GAIM_GTK_CONVERSATION(conv);
 
-	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(font)))
-		show_font_dialog(conv, font);
-	else if (gtkconv->dialogs.font != NULL)
-		cancel_font(font, conv);
-	else
-		gaim_gtk_advance_past(gtkconv, "<FONT FACE>", "</FONT>");
+	show_font_dialog(conv, font);
 }
 
 static void
--- a/src/gtkimhtml.c	Wed Dec 03 04:30:56 2003 +0000
+++ b/src/gtkimhtml.c	Wed Dec 03 05:12:24 2003 +0000
@@ -522,6 +522,7 @@
 	imhtml->edit.underline = NULL;
 	imhtml->edit.forecolor = NULL;
 	imhtml->edit.backcolor = NULL;
+	imhtml->edit.fontface = NULL;
 
 	imhtml->format_spans = NULL;
 	
@@ -1636,6 +1637,7 @@
 	imhtml->edit.bold = NULL;
 	imhtml->edit.italic = NULL;
 	imhtml->edit.underline = NULL;
+	imhtml->edit.fontface = NULL;
 }
 
 void gtk_imhtml_page_up (GtkIMHtml *imhtml)
@@ -1960,6 +1962,7 @@
 static void insert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml)
 {
 	GtkIMHtmlFormatSpan *span = NULL;
+	gtk_text_iter_forward_chars(iter, len);
 
 	if (!imhtml->editable)
 		return;
@@ -1974,24 +1977,26 @@
 	if ((span = imhtml->edit.italic)) {
 		GtkTextIter italic;
 		gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &italic, span->start);
-		gtk_text_iter_forward_chars(iter, len);
 		gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "ITALICS", &italic, iter);
 	}
 	
 	if ((span = imhtml->edit.forecolor)) {
 		GtkTextIter fore;
 		gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &fore, span->start);
-		gtk_text_iter_forward_chars(iter, len);
 		gtk_text_buffer_apply_tag(imhtml->text_buffer, span->tag, &fore, iter);
 	}
 	
 	if ((span = imhtml->edit.backcolor)) {
 		GtkTextIter back;
 		gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &back, span->start);
-		gtk_text_iter_forward_chars(iter, len);
 		gtk_text_buffer_apply_tag(imhtml->text_buffer, span->tag, &back, iter);
 	}
 	
+	if ((span = imhtml->edit.fontface)) {
+		GtkTextIter face;
+		gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &face, span->start);
+		gtk_text_buffer_apply_tag(imhtml->text_buffer, span->tag, &face, iter);
+	}
 }
 
 void gtk_imhtml_set_editable(GtkIMHtml *imhtml, gboolean editable) 
@@ -2126,6 +2131,30 @@
 	return imhtml->edit.backcolor != NULL;
 }
 
+gboolean gtk_imhtml_toggle_fontface(GtkIMHtml *imhtml, const char *face)
+{
+	GtkIMHtmlFormatSpan *span;
+	GtkTextMark *ins = gtk_text_buffer_get_insert(imhtml->text_buffer);
+	GtkTextIter iter;
+	gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, ins);
+	if (!imhtml->edit.fontface) {
+		span = g_malloc(sizeof(GtkIMHtmlFormatSpan));
+		span->start = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, TRUE);
+		span->start_tag = g_strdup_printf("<font face='%s'>", face);
+		span->end = NULL;
+		span->end_tag = g_strdup("</font>");
+		span->buffer = imhtml->text_buffer;
+		span->tag = gtk_text_buffer_create_tag(imhtml->text_buffer, NULL, "family", face, NULL);
+		imhtml->edit.fontface = span;
+		imhtml->format_spans = g_list_append(imhtml->format_spans, span);
+	} else {
+		span = imhtml->edit.fontface;
+		span->end = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, &iter, TRUE);
+		imhtml->edit.fontface = NULL;
+	}
+	return imhtml->edit.fontface != NULL;
+}
+
 void gtk_imhtml_insert_link(GtkIMHtml *imhtml, const char *url, const char *text)
 {
 	GtkIMHtmlFormatSpan *span = g_malloc(sizeof(GtkIMHtmlFormatSpan));
--- a/src/gtkimhtml.h	Wed Dec 03 04:30:56 2003 +0000
+++ b/src/gtkimhtml.h	Wed Dec 03 05:12:24 2003 +0000
@@ -91,6 +91,7 @@
 		GtkIMHtmlFormatSpan *underline;
 		GtkIMHtmlFormatSpan *forecolor;
 		GtkIMHtmlFormatSpan *backcolor;
+		GtkIMHtmlFormatSpan *fontface;
 	} edit;
 	GList *format_spans;
 };
@@ -211,7 +212,7 @@
 gboolean gtk_imhtml_toggle_underline(GtkIMHtml *imhtml);
 gboolean gtk_imhtml_toggle_forecolor(GtkIMHtml *imhtml, const char *color);
 gboolean gtk_imhtml_toggle_backcolor(GtkIMHtml *imhtml, const char *color);
-
+gboolean gtk_imhtml_toggle_fontface(GtkIMHtml *imhtml, const char *face);
 void gtk_imhtml_insert_link(GtkIMHtml *imhtml, const char *url, const char *text);
 
 char *gtk_imhtml_get_markup(GtkIMHtml *imhtml);
--- a/src/gtkutils.c	Wed Dec 03 04:30:56 2003 +0000
+++ b/src/gtkutils.c	Wed Dec 03 05:12:24 2003 +0000
@@ -243,13 +243,10 @@
 
 	gtkconv->has_font = TRUE;
 
-	pre_fontface = g_strconcat("<FONT FACE=\"",
-							   gtkconv->fontface, "\">", NULL);
-	gaim_gtk_surround(gtkconv, pre_fontface, "</FONT>");
+	gtk_imhtml_toggle_fontface(GTK_IMHTML(gtkconv->entry), gtkconv->fontface);
 
 	gtk_widget_grab_focus(gtkconv->entry);
 
-	g_free(pre_fontface);
 }
 
 static int