changeset 3473:0073a014e55b

[gaim-migrate @ 3524] Fixed font preferences, and removed the title from alert windows. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Fri, 30 Aug 2002 03:04:12 +0000
parents d33ec392a5e1
children cfbdfe334975
files src/conversation.c src/dialogs.c src/gaimrc.c src/prefs.c src/ui.h
diffstat 5 files changed, 28 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- a/src/conversation.c	Thu Aug 29 21:40:08 2002 +0000
+++ b/src/conversation.c	Fri Aug 30 03:04:12 2002 +0000
@@ -77,7 +77,7 @@
 GtkWidget *convo_notebook = NULL;
 
 char fontface[128] = { 0 };
-char fontxfld[256] = { 0 };
+
 int fontsize = 3;
 extern GdkColor bgcolor;
 extern GdkColor fgcolor;
@@ -627,18 +627,8 @@
 void set_font_face(char *newfont, struct conversation *c)
 {
 	char *pre_fontface;
-	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];
-	}
-	c->fontface[k] = '\0';
+	
+	sprintf(c->fontface, "%s", newfont && *newfont ? newfont : DEFAULT_FONT_FACE);
 	c->hasfont = 1;
 
 	pre_fontface = g_strconcat("<FONT FACE=\"", c->fontface, "\">", NULL);
@@ -2761,7 +2751,6 @@
 	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;
@@ -3333,7 +3322,6 @@
 		if (b->hasfont)
 			continue;
 		sprintf(b->fontface, "%s", fontface);
-		sprintf(b->fontxfld, "%s", fontxfld);
 	}
 }
 
--- a/src/dialogs.c	Thu Aug 29 21:40:08 2002 +0000
+++ b/src/dialogs.c	Fri Aug 30 03:04:12 2002 +0000
@@ -581,7 +581,7 @@
 		img = gtk_image_new_from_file(filename);
 		gtk_misc_set_alignment(GTK_MISC(img), 0, 0);
 	}
-	d = gtk_dialog_new_with_buttons(NULL, NULL, GTK_DIALOG_MODAL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT);
+	d = gtk_dialog_new_with_buttons("", NULL, GTK_DIALOG_MODAL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT);
 	g_signal_connect(d, "response", G_CALLBACK(gtk_widget_destroy), NULL);
 	
 	gtk_container_set_border_width (GTK_CONTAINER(d), 6);
@@ -3206,34 +3206,29 @@
 {
 	/* this could be expanded to include font size, weight, etc.
 	   but for now only works with font face */
-	int i, j = 0, k = 0;
+	int i = 0;
 	char *fontname;
 	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));
-
+		while(fontname[i] && !isdigit(fontname[i])) { 
+			i++;
+		}
+		fontname[i] = 0;
 		set_font_face(fontname, c);
 	} else {
 		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)
-				fontface[k++] = fontname[i];
+		while(fontface[i] && !isdigit(fontname[i]) && i < sizeof(fontface)) { 
+			fontface[i] = fontname[i];
+			i++;
 		}
-		fontface[k] = '\0';
-
-		g_snprintf(fontxfld, sizeof(fontxfld), "%s", fontname);
+		fontface[i] = 0;
 	}
 
 	cancel_font(NULL, c);
 }
 
-static GtkWidget *fontseld;
-
 void destroy_fontsel(GtkWidget *w, gpointer d)
 {
 	gtk_widget_destroy(fontseld);
@@ -3242,17 +3237,18 @@
 
 void show_font_dialog(struct conversation *c, GtkWidget *font)
 {
-
+	char fonttif[128];
 	if (!font) {		/* we came from the prefs dialog */
 		if (fontseld)
 			return;
 		fontseld = gtk_font_selection_dialog_new(_("Select Font"));
-		if (fontxfld[0]) {
+		if (fontface[0]) {
+			g_snprintf(fonttif, sizeof(fonttif), "%s 12", fontface);
 			gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(fontseld),
-								fontxfld);
+								fonttif);
 		} else {
 			gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(fontseld),
-								DEFAULT_FONT_XFLD);
+								DEFAULT_FONT_FACE " 12");
 		}
 
 		gtk_object_set_user_data(GTK_OBJECT(fontseld), NULL);
@@ -3261,7 +3257,7 @@
 		gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(fontseld)->cancel_button),
 				   "clicked", GTK_SIGNAL_FUNC(destroy_fontsel), NULL);
 		gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(fontseld)->ok_button), "clicked",
-				   GTK_SIGNAL_FUNC(apply_font_dlg), NULL);
+				   GTK_SIGNAL_FUNC(apply_font_dlg), fontseld);
 		gtk_widget_realize(fontseld);
 		aol_icon(fontseld->window);
 		gtk_widget_show(fontseld);
@@ -3277,12 +3273,13 @@
 		else
 			gtk_object_set_user_data(GTK_OBJECT(c->font_dialog), NULL);
 
-		if (c->fontxfld[0]) {
+		if (c->fontface[0]) {
+			g_snprintf(fonttif, sizeof(fonttif), "%s 12", c->fontface);
 			gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(c->font_dialog),
-								c->fontxfld);
+							       fonttif);
 		} else {
 			gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(c->font_dialog),
-								DEFAULT_FONT_XFLD);
+								DEFAULT_FONT_FACE);
 		}
 
 		gtk_signal_connect(GTK_OBJECT(c->font_dialog), "delete_event",
--- a/src/gaimrc.c	Thu Aug 29 21:40:08 2002 +0000
+++ b/src/gaimrc.c	Fri Aug 30 03:04:12 2002 +0000
@@ -748,8 +748,6 @@
 		} else if (!strcmp(p->option, "away_options")) {
 			away_options = atoi(p->value[0]);
 			away_resend = atoi(p->value[1]);
-		} else if (!strcmp(p->option, "font_xfld")) {
-			g_snprintf(fontxfld, sizeof(fontxfld), "%s", p->value[0]);
 		} else if (!strcmp(p->option, "font_face")) {
 			g_snprintf(fontface, sizeof(fontface), "%s", p->value[0]);
 		} else if (!strcmp(p->option, "font_size")) {
@@ -851,7 +849,6 @@
 	fprintf(f, "\tsound_options { %u }\n", sound_options);
 	fprintf(f, "\taway_options { %u } { %u }\n", away_options, away_resend);
 
-	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);
--- a/src/prefs.c	Thu Aug 29 21:40:08 2002 +0000
+++ b/src/prefs.c	Fri Aug 30 03:04:12 2002 +0000
@@ -1919,13 +1919,14 @@
 	int i = 0;
 	char *fontname;
 
-	fontname = g_strdup(gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(fontseld)));
+	fontname = g_strdup(gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(f)));
 	destroy_fontsel(0, 0);
 
 	while(fontname[i] && !isdigit(fontname[i]) && i < sizeof(fontface_new)) { 
 		fontface_new[i] = fontname[i];
 		i++;
 	}
-	
+	fontface_new[i] = 0;
+	debug_printf("fontface_new: %s\n", fontface_new);
 	g_free(fontname);
 }
--- a/src/ui.h	Thu Aug 29 21:40:08 2002 +0000
+++ b/src/ui.h	Fri Aug 30 03:04:12 2002 +0000
@@ -36,8 +36,7 @@
 #define gtk_accel_group_attach(x, y) _gtk_accel_group_attach(x, y)
 #define gtk_widget_lock_accelerators(x)
 
-#define DEFAULT_FONT_XFLD "-adobe-helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1"
-#define DEFAULT_FONT_FACE "helvetica"
+#define DEFAULT_FONT_FACE "Helvetica"
 
 #define BROWSER_NETSCAPE              0
 #define BROWSER_KONQ                  1
@@ -125,7 +124,6 @@
 	GtkWidget *log_dialog;
 	int makesound;
 	char fontface[128];
-	char fontxfld[256];
 	int hasfont;
 	GdkColor bgcol;
 	int hasbg;
@@ -296,6 +294,7 @@
 
 /* Globals in prefs.c */
 extern struct debug_window *dw;
+extern GtkWidget *fontseld;
 
 /* Globals in prpl.c */
 extern GtkWidget *protomenu;