changeset 2763:477a035d81e5

[gaim-migrate @ 2776] more font stuff! yay! committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Mon, 19 Nov 2001 12:03:38 +0000
parents 8eb8db9a8449
children b8967c961056
files src/conversation.c src/dialogs.c src/gaimrc.c src/ui.h
diffstat 4 files changed, 44 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/src/conversation.c	Mon Nov 19 11:19:52 2001 +0000
+++ b/src/conversation.c	Mon Nov 19 12:03:38 2001 +0000
@@ -70,7 +70,8 @@
 GtkWidget *all_convos = NULL;
 static GtkWidget *convo_notebook = NULL;
 
-char fontface[64];
+char fontface[128] = { 0 };
+char fontxfld[256] = { 0 };
 int fontsize = 3;
 extern GdkColor bgcolor;
 extern GdkColor fgcolor;
@@ -502,24 +503,24 @@
 void set_font_face(char *newfont, struct conversation *c)
 {
 	char *pre_fontface;
-	int alloc = 1;
-
-	pre_fontface = g_strconcat("<FONT FACE=\"", newfont, "\">", '\0');
-
-	if (!strcmp(pre_fontface, "<FONT FACE=\"\">")) {
-		g_free(pre_fontface);
-		alloc--;
-		pre_fontface = "<FONT FACE=\"" DEFAULT_FONT_FACE "\">";
+	int i, j = 0, k = 0;
+
+
+	sprintf(c->fontxfld, "%s", newfont && *newfont ? newfont : DEFAULT_FONT_XFLD);
+	for (i = 0; i < strlen(c->fontxfld); i++) {
+		if (c->fontxfld[i] == '-') {
+			if (++j > 2)
+				break;
+		} else if (j == 2)
+			c->fontface[k++] = c->fontxfld[i];
 	}
-
-	sprintf(c->fontface, "%s", newfont ?
-		(newfont[0] ? newfont : DEFAULT_FONT_FACE) : DEFAULT_FONT_FACE);
+	c->fontface[k] = '\0';
 	c->hasfont = 1;
+
+	pre_fontface = g_strconcat("<FONT FACE=\"", c->fontface, "\">", NULL);
 	surround(c->entry, pre_fontface, "</FONT>");
 	gtk_widget_grab_focus(c->entry);
-
-	if (alloc)
-		g_free(pre_fontface);
+	g_free(pre_fontface);
 }
 
 static gint delete_all_convo(GtkWidget *w, GdkEventAny *e, gpointer d)
@@ -2150,6 +2151,7 @@
 	c->smiley_dialog = NULL;
 	c->link_dialog = NULL;
 	c->log_dialog = NULL;
+	sprintf(c->fontxfld, "%s", fontxfld);
 	sprintf(c->fontface, "%s", fontface);
 	c->hasfont = 0;
 	c->bgcol = bgcolor;
@@ -2586,6 +2588,7 @@
 		if (b->hasfont)
 			continue;
 		sprintf(b->fontface, "%s", fontface);
+		sprintf(b->fontxfld, "%s", fontxfld);
 	}
 }
 
--- a/src/dialogs.c	Mon Nov 19 11:19:52 2001 +0000
+++ b/src/dialogs.c	Mon Nov 19 12:03:38 2001 +0000
@@ -2653,24 +2653,12 @@
 	   but for now only works with font face */
 	int i, j = 0, k = 0;
 	char *fontname;
-	char font[64];
 	struct conversation *c = gtk_object_get_user_data(GTK_OBJECT(fontsel));
 
 	if (c) {
 		fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(fontsel));
 
-		for (i = 0; i < strlen(fontname); i++) {
-			if (fontname[i] == '-') {
-				if (++j > 2)
-					break;
-			} else if (j == 2)
-				font[k++] = fontname[i];
-		}
-		font[k] = '\0';
-
-		debug_printf("Setting font face %s\n", font);
-
-		set_font_face(font, c);
+		set_font_face(fontname, c);
 	} else {
 		fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(fontsel));
 
@@ -2682,6 +2670,8 @@
 				fontface[k++] = fontname[i];
 		}
 		fontface[k] = '\0';
+
+		g_snprintf(fontxfld, sizeof(fontxfld), "%s", fontname);
 	}
 
 	cancel_font(NULL, c);
@@ -2710,6 +2700,7 @@
 			fontface[k++] = fontname[i];
 	}
 	fontface[k] = '\0';
+	g_snprintf(fontxfld, sizeof(fontxfld), "%s", fontname);
 	update_convo_font();
 }
 
@@ -2720,8 +2711,13 @@
 		if (fontseld)
 			return;
 		fontseld = gtk_font_selection_dialog_new(_("Select Font"));
-		gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(fontseld),
-							DEFAULT_FONT_XFLD);
+		if (fontxfld[0]) {
+			gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(fontseld),
+								fontxfld);
+		} else {
+			gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(fontseld),
+								DEFAULT_FONT_XFLD);
+		}
 
 		gtk_object_set_user_data(GTK_OBJECT(fontseld), NULL);
 		gtk_signal_connect(GTK_OBJECT(fontseld), "delete_event",
@@ -2745,8 +2741,13 @@
 		else
 			gtk_object_set_user_data(GTK_OBJECT(c->font_dialog), NULL);
 
-		gtk_font_selection_dialog_set_font_name((GtkFontSelectionDialog *) c->font_dialog,
-							DEFAULT_FONT_XFLD);
+		if (c->fontxfld[0]) {
+			gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(fontseld),
+								c->fontxfld);
+		} else {
+			gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(fontseld),
+								DEFAULT_FONT_XFLD);
+		}
 
 		gtk_signal_connect(GTK_OBJECT(c->font_dialog), "delete_event",
 				   GTK_SIGNAL_FUNC(delete_event_dialog), c);
@@ -2755,9 +2756,6 @@
 		gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(c->font_dialog)->cancel_button),
 				   "clicked", GTK_SIGNAL_FUNC(cancel_font), c);
 
-		gtk_font_selection_dialog_set_font_name((GtkFontSelectionDialog *) c->font_dialog,
-							DEFAULT_FONT_XFLD);
-
 		gtk_widget_realize(c->font_dialog);
 
 		aol_icon(c->font_dialog->window);
--- a/src/gaimrc.c	Mon Nov 19 11:19:52 2001 +0000
+++ b/src/gaimrc.c	Mon Nov 19 12:03:38 2001 +0000
@@ -731,9 +731,10 @@
 			sound_options = atoi(p->value[0]);
 		} else if (!strcmp(p->option, "away_options")) {
 			away_options = atoi(p->value[0]);
+		} else if (!strcmp(p->option, "font_xfld")) {
+			g_snprintf(fontxfld, sizeof(fontxfld), "%s", p->value[0]);
 		} else if (!strcmp(p->option, "font_face")) {
-			if (p->value[0] != NULL)
-				g_snprintf(fontface, sizeof(fontface), "%s", p->value[0]);
+			g_snprintf(fontface, sizeof(fontface), "%s", p->value[0]);
 		} else if (!strcmp(p->option, "font_size")) {
 			fontsize = atoi(p->value[0]);
 		} else if (!strcmp(p->option, "foreground")) {
@@ -823,8 +824,8 @@
 	fprintf(f, "\tsound_options { %u }\n", sound_options);
 	fprintf(f, "\taway_options { %u }\n", away_options);
 
-	if (fontface)
-		fprintf(f, "\tfont_face { %s }\n", fontface);
+	fprintf(f, "\tfont_xfld { %s }\n", fontxfld);
+	fprintf(f, "\tfont_face { %s }\n", fontface);
 	fprintf(f, "\tfont_size { %d }\n", fontsize);
 	fprintf(f, "\tforeground { %d } { %d } { %d }\n", fgcolor.red, fgcolor.green, fgcolor.blue);
 	fprintf(f, "\tbackground { %d } { %d } { %d }\n", bgcolor.red, bgcolor.green, bgcolor.blue);
--- a/src/ui.h	Mon Nov 19 11:19:52 2001 +0000
+++ b/src/ui.h	Mon Nov 19 12:03:38 2001 +0000
@@ -127,6 +127,7 @@
 	GtkWidget *log_dialog;
 	int makesound;
 	char fontface[128];
+	char fontxfld[256];
 	int hasfont;
 	GdkColor bgcol;
 	int hasbg;
@@ -261,7 +262,8 @@
 extern GtkWidget *joinchat;
 
 /* Globals in dialog.c */
-extern char fontface[64];
+extern char fontface[128];
+extern char fontxfld[256];
 extern int fontsize;
 extern GdkColor bgcolor;
 extern GdkColor fgcolor;