changeset 17406:747e5fd970e6

Reluctantly, I've added a preference for overriding the GTK+ default theme in GtkIMHtml widgets. There is support for this feature in the GNOME HIG and in other GTK+ (including GNOME) applications. This fixes #494. This is a GTK+ 2.4-only feature. I don't update the fonts in existing gtkimhtml's yet, only in new ones. Someone else may want to take care of that
author Sean Egan <seanegan@gmail.com>
date Thu, 31 May 2007 03:00:35 +0000
parents 45178b7e580d
children 0dbb403c9016
files pidgin/gtkconv.c pidgin/gtkprefs.c pidgin/gtkutils.c
diffstat 3 files changed, 49 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkconv.c	Thu May 31 00:57:53 2007 +0000
+++ b/pidgin/gtkconv.c	Thu May 31 03:00:35 2007 +0000
@@ -6951,6 +6951,9 @@
 	purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/tab_side", GTK_POS_TOP);
 	purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/scrollback_lines", 4000);
 
+	purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/use_theme_font", TRUE);
+	purple_prefs_add_string(PIDGIN_PREFS_ROOT "/conversations/custom_font", "Sans 28");
+
 	/* Conversations -> Chat */
 	purple_prefs_add_none(PIDGIN_PREFS_ROOT "/conversations/chat");
 	purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/chat/default_width", 410);
--- a/pidgin/gtkprefs.c	Thu May 31 00:57:53 2007 +0000
+++ b/pidgin/gtkprefs.c	Thu May 31 03:00:35 2007 +0000
@@ -881,6 +881,15 @@
 	return ret;
 }
 
+#if GTK_CHECK_VERSION(2,4,0)
+static void
+pidgin_custom_font_set(GtkFontButton *font_button, gpointer nul)
+{
+	purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/custom_font",
+				gtk_font_button_get_font_name(font_button));
+}
+#endif
+
 static GtkWidget *
 conv_page()
 {
@@ -889,9 +898,16 @@
 	GtkWidget *toolbar;
 	GtkWidget *iconpref1;
 	GtkWidget *iconpref2;
+	GtkWidget *fontpref;
 	GtkWidget *imhtml;
 	GtkWidget *frame;
 
+#if GTK_CHECK_VERSION(2,4,0)
+	GtkWidget *hbox;
+	GtkWidget *label;
+	GtkWidget *font_button;
+#endif
+
 	ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE);
 	gtk_container_set_border_width(GTK_CONTAINER(ret), PIDGIN_HIG_BORDER);
 
@@ -922,6 +938,25 @@
 	pidgin_prefs_checkbox(_("F_lash window when IMs are received"), PIDGIN_PREFS_ROOT "/win32/blink_im", vbox);
 #endif
 
+#if GTK_CHECK_VERSION(2,4,0)
+	vbox = pidgin_make_frame(ret, _("Font"));
+	if (purple_running_gnome())
+		fontpref = pidgin_prefs_checkbox(_("Use document font from _theme"), PIDGIN_PREFS_ROOT "/conversations/use_theme_font", vbox);
+	else
+		fontpref = pidgin_prefs_checkbox(_("Use font from _theme"), PIDGIN_PREFS_ROOT "/conversations/use_theme_font", vbox);
+	hbox = gtk_hbox_new(FALSE, 3);
+	label = gtk_label_new_with_mnemonic(_("Conversation _font:"));
+	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+	font_button = gtk_font_button_new_with_font(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/custom_font"));
+	gtk_font_button_set_show_style(GTK_FONT_BUTTON(font_button), TRUE);
+	gtk_box_pack_start(GTK_BOX(hbox), font_button, FALSE, FALSE, 0);
+	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
+	if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/use_theme_font"))
+		gtk_widget_set_sensitive(hbox, FALSE);
+	g_signal_connect(G_OBJECT(fontpref), "clicked", G_CALLBACK(pidgin_toggle_sensitive), hbox);
+	g_signal_connect(G_OBJECT(font_button), "font-set", G_CALLBACK(pidgin_custom_font_set), NULL);
+#endif
+
 	vbox = pidgin_make_frame(ret, _("Default Formatting"));
 
 	frame = pidgin_create_imhtml(TRUE, &imhtml, &toolbar, NULL);
--- a/pidgin/gtkutils.c	Thu May 31 00:57:53 2007 +0000
+++ b/pidgin/gtkutils.c	Thu May 31 03:00:35 2007 +0000
@@ -94,6 +94,7 @@
 void
 pidgin_setup_imhtml(GtkWidget *imhtml)
 {
+	PangoFontDescription *desc = NULL;
 	g_return_if_fail(imhtml != NULL);
 	g_return_if_fail(GTK_IS_IMHTML(imhtml));
 
@@ -104,10 +105,12 @@
 
 	gtk_imhtml_set_funcs(GTK_IMHTML(imhtml), &gtkimhtml_cbs);
 
-	/* Use the GNOME "document" font, if applicable */
-	if (purple_running_gnome()) {
+	if (!purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/use_theme_font")) {
+		const char *font = purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/custom_font");
+		desc = pango_font_description_from_string(font);
+	} else if (purple_running_gnome()) {
+		/* Use the GNOME "document" font, if applicable */
 		char *path, *font;
-		PangoFontDescription *desc = NULL;
 
 		if ((path = g_find_program_in_path("gconftool-2"))) {
 			g_free(path);
@@ -118,11 +121,11 @@
 		}
 		desc = pango_font_description_from_string(font);
 		g_free(font);
-
-		if (desc) {
-			gtk_widget_modify_font(imhtml, desc);
-			pango_font_description_free(desc);
-		}
+	}
+	
+	if (desc) {
+		gtk_widget_modify_font(imhtml, desc);
+		pango_font_description_free(desc);
 	}
 }