### Eclipse Workspace Patch 1.0
#P Drivel
Index: src/journal.c
===================================================================
RCS file: /cvs/gnome/drivel/src/journal.c,v
retrieving revision 1.128
diff -u -r1.128 journal.c
--- src/journal.c	8 Aug 2006 12:45:14 -0000	1.128
+++ src/journal.c	12 Oct 2006 10:07:29 -0000
@@ -1919,6 +1919,96 @@
 }
 
 static void
+editor_set_font (GtkWidget   *journal_text, 
+		     gboolean     def, 
+		     const gchar *font_name)
+{
+
+	if (!def)
+	{
+		PangoFontDescription *font_desc = NULL;
+		g_return_if_fail (font_name != NULL);
+		
+		font_desc = pango_font_description_from_string (font_name);
+		g_return_if_fail (font_desc != NULL);
+		gtk_widget_modify_font (GTK_WIDGET (journal_text), font_desc);
+		
+		pango_font_description_free (font_desc);		
+	}
+	else
+	{
+		GtkRcStyle *rc_style;
+		rc_style = gtk_widget_get_modifier_style (GTK_WIDGET (journal_text));
+
+		if (rc_style->font_desc)
+			pango_font_description_free (rc_style->font_desc);
+
+		rc_style->font_desc = NULL;
+		gtk_widget_modify_style (GTK_WIDGET (journal_text), rc_style);
+	}
+}
+
+static void
+editor_update_font(DrivelClient   *dc) 
+{
+	
+	GConfValue *value;
+	gboolean state;
+	gchar *editor_font;
+	
+	/* if the journal hasn't been built yet, skip this */
+	if (!dc->journal_window)
+		return;
+		
+	value = gconf_client_get(dc->client, dc->gconf->use_default_font, NULL);
+	if (value)
+		state = gconf_value_get_bool(value);
+	else
+		state = TRUE;
+		
+	editor_font = gconf_client_get_string(dc->client, dc->gconf->editor_font, NULL);
+	
+	editor_set_font( GTK_WIDGET(dc->journal_text), state,
+			(editor_font == NULL || *editor_font=='\0') ? NULL : editor_font);
+	
+	g_free (editor_font);
+
+	return;	
+}
+
+static void
+editor_font_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer user_data)
+{
+	DrivelClient *dc = (DrivelClient *) user_data;
+	editor_update_font(dc);
+	
+	return;
+}
+
+static void
+use_default_font_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer user_data)
+{
+	GConfValue *value;
+	gboolean state;
+	DrivelClient *dc = (DrivelClient *) user_data;
+	
+	/* set sensitivity of GtkFontButton */
+	if (dc->pref_font_hbox) {
+		
+		value = gconf_entry_get_value (entry);
+		state = gconf_value_get_bool (value);
+		
+		gtk_widget_set_sensitive(dc->pref_font_hbox, !state);
+		
+	}
+	
+	editor_update_font(dc);
+	
+	return;
+}
+
+
+static void
 mood_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
 {
 	GConfValue *value;
@@ -2493,7 +2583,10 @@
 			dc, NULL, NULL);
 	dc->id.spell_language_id = gconf_client_notify_add (dc->client, dc->gconf->spell_language, spell_language_changed_cb,
 			dc, NULL, NULL);
-			
+	dc->id.use_default_font_id = gconf_client_notify_add (dc->client, dc->gconf->use_default_font, use_default_font_changed_cb,
+			dc, NULL, NULL);
+	dc->id.editor_font_id = gconf_client_notify_add (dc->client, dc->gconf->editor_font, editor_font_changed_cb,
+			dc, NULL, NULL);
 	return;
 }
 
@@ -2516,7 +2609,9 @@
 	gconf_client_notify_remove (client, id->highlight_syntax_id);
 	gconf_client_notify_remove (client, id->spellcheck_id);
 	gconf_client_notify_remove (client, id->spell_language_id);
-	
+	gconf_client_notify_remove (client, id->use_default_font_id);	
+	gconf_client_notify_remove (client, id->editor_font_id);
+		
 	return;
 }
 
@@ -3518,7 +3613,7 @@
 	EggRecentModel *recent_model;
 	EggRecentViewUIManager *recent_view;
 	GtkSizeGroup *col1, *row1, *row2;
-	gchar *filename, *last_journal_path;
+	gchar *filename, *last_journal_path, *editor_font;
 	gint last_active_journal;
 	
 	debug ("journal_window_build()");
@@ -3587,7 +3682,17 @@
 				     NULL);
 	}
 #endif /* HAVE_GTKSPELL */
-	
+	value = gconf_client_get(dc->client, dc->gconf->use_default_font, NULL);
+	if (value)
+		state = gconf_value_get_bool(value);
+	else
+		state = TRUE;
+	editor_font = gconf_client_get_string(dc->client, dc->gconf->editor_font, NULL);
+	if (!state && editor_font) {
+		editor_set_font(GTK_WIDGET(text_area), state, editor_font);
+	}
+	g_free(editor_font);
+		
 	/* the mood entry */
 	widget = glade_xml_get_widget (xml, "mood_label");
 	gtk_size_group_add_widget (col1, widget);
Index: src/dialogs.c
===================================================================
RCS file: /cvs/gnome/drivel/src/dialogs.c,v
retrieving revision 1.61
diff -u -r1.61 dialogs.c
--- src/dialogs.c	8 Aug 2006 12:45:13 -0000	1.61
+++ src/dialogs.c	12 Oct 2006 10:07:06 -0000
@@ -595,6 +595,38 @@
 #endif /* HAVE_GTKSPELL */
 
 static void
+use_default_font_cb (GtkWidget *button, gpointer data)
+{
+	gboolean state;
+	DrivelClient *dc = (DrivelClient *) data;
+
+	state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
+	
+	gconf_client_set_bool(dc->client, dc->gconf->use_default_font, state, NULL);
+	
+	return;
+}
+
+static void
+editor_font_cb(GtkWidget *button, gpointer data)
+{
+	const gchar *font_name;
+	DrivelClient *dc = (DrivelClient *) data;
+
+	font_name = gtk_font_button_get_font_name (GTK_FONT_BUTTON (button));
+	if (!font_name)
+	{
+		g_warning ("Could not get font name");
+		return;
+	}
+
+	gconf_client_set_string(dc->client, dc->gconf->editor_font, font_name, NULL);
+	
+	return;
+}
+
+
+static void
 picture_cb (GtkWidget *menu, gpointer data)
 {
 	gint number;
@@ -1972,6 +2004,31 @@
 	g_signal_connect (G_OBJECT (dialog), "destroy",
 			  G_CALLBACK (nullify_pointer), &(dc->pref_dictionary));
 	
+	/* use system font */
+	widget = glade_xml_get_widget (xml, "pref_general_use_default_font");
+	value = gconf_client_get (dc->client, dc->gconf->use_default_font, NULL);
+	if (value)
+		state = gconf_value_get_bool (value);
+	else
+		state = TRUE;
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), state);
+	g_signal_connect (G_OBJECT (widget), "toggled",
+			G_CALLBACK (use_default_font_cb), dc);
+		
+	/* editor font */
+	widget = glade_xml_get_widget (xml, "pref_general_editor_font");
+	dc->pref_font_hbox = glade_xml_get_widget (xml, "pref_general_font_hbox");
+	value = gconf_client_get (dc->client, dc->gconf->editor_font, NULL);
+	if (state)
+		gtk_widget_set_sensitive(dc->pref_font_hbox, FALSE);
+	if (value)
+		gtk_font_button_set_font_name(GTK_FONT_BUTTON(widget), gconf_value_get_string(value));
+	g_signal_connect (G_OBJECT (widget), "font-set",
+			G_CALLBACK (editor_font_cb), dc);	
+	g_signal_connect (G_OBJECT (dialog), "destroy",
+		 	G_CALLBACK (nullify_pointer), &(dc->pref_font_hbox));
+	
+			
 	/* picture */
 	picture_store = gtk_list_store_new (2, G_TYPE_STRING, GDK_TYPE_PIXBUF);
 	fill_picture_menu (dc, picture_store);
Index: src/drivel.h
===================================================================
RCS file: /cvs/gnome/drivel/src/drivel.h,v
retrieving revision 1.57
diff -u -r1.57 drivel.h
--- src/drivel.h	8 Aug 2006 12:45:13 -0000	1.57
+++ src/drivel.h	12 Oct 2006 10:07:21 -0000
@@ -113,6 +113,8 @@
 	guint spell_language_id;
 	guint last_journal_id;
 	guint technorati_id;
+	guint editor_font_id;
+	guint use_default_font_id;
 	
 	/* loop ids */
 	guint loop_checkfriends_id;
@@ -149,6 +151,10 @@
 	gchar *entry_max;
 	gchar *min_start;
 	gchar *min_post;
+	
+	/* font preferences */
+	gchar *editor_font;
+	gchar *use_default_font;
 };
 
 struct _DrivelJournalEntry
@@ -295,6 +301,7 @@
 	/* preferences widgets */
 	GtkWidget *pref_dictionary;
 	GtkWidget *pref_dictionary_box;
+	GtkWidget *pref_font_hbox;
 	
 	GConfClient *client;
 	DrivelGConfData *gconf;
Index: src/drivel.glade
===================================================================
RCS file: /cvs/gnome/drivel/src/drivel.glade,v
retrieving revision 1.56
diff -u -r1.56 drivel.glade
--- src/drivel.glade	8 Aug 2006 12:45:13 -0000	1.56
+++ src/drivel.glade	12 Oct 2006 10:07:21 -0000
@@ -2130,6 +2130,137 @@
 		    </widget>
 		    <packing>
 		      <property name="padding">0</property>
+		      <property name="expand">False</property>
+		      <property name="fill">True</property>
+		    </packing>
+		  </child>
+
+		  <child>
+		    <widget class="GtkVBox" id="pref_general_font_box">
+		      <property name="visible">True</property>
+		      <property name="homogeneous">False</property>
+		      <property name="spacing">0</property>
+
+		      <child>
+			<widget class="GtkLabel" id="label38">
+			  <property name="visible">True</property>
+			  <property name="label" translatable="yes">&lt;b&gt;Fonts&lt;/b&gt;</property>
+			  <property name="use_underline">False</property>
+			  <property name="use_markup">True</property>
+			  <property name="justify">GTK_JUSTIFY_LEFT</property>
+			  <property name="wrap">False</property>
+			  <property name="selectable">False</property>
+			  <property name="xalign">0</property>
+			  <property name="yalign">0.5</property>
+			  <property name="xpad">0</property>
+			  <property name="ypad">0</property>
+			</widget>
+			<packing>
+			  <property name="padding">0</property>
+			  <property name="expand">False</property>
+			  <property name="fill">False</property>
+			</packing>
+		      </child>
+
+		      <child>
+			<widget class="GtkAlignment" id="alignment7">
+			  <property name="visible">True</property>
+			  <property name="xalign">0.5</property>
+			  <property name="yalign">0.5</property>
+			  <property name="xscale">1</property>
+			  <property name="yscale">1</property>
+			  <property name="top_padding">0</property>
+			  <property name="bottom_padding">0</property>
+			  <property name="left_padding">18</property>
+			  <property name="right_padding">0</property>
+
+			  <child>
+			    <widget class="GtkVBox" id="vbox2">
+			      <property name="visible">True</property>
+			      <property name="homogeneous">False</property>
+			      <property name="spacing">0</property>
+
+			      <child>
+				<widget class="GtkCheckButton" id="pref_general_use_default_font">
+				  <property name="visible">True</property>
+				  <property name="can_focus">True</property>
+				  <property name="label" translatable="yes">Use default _theme font</property>
+				  <property name="use_underline">True</property>
+				  <property name="relief">GTK_RELIEF_NORMAL</property>
+				  <property name="focus_on_click">True</property>
+				  <property name="active">False</property>
+				  <property name="inconsistent">False</property>
+				  <property name="draw_indicator">True</property>
+				</widget>
+				<packing>
+				  <property name="padding">0</property>
+				  <property name="expand">False</property>
+				  <property name="fill">False</property>
+				</packing>
+			      </child>
+
+			      <child>
+				<widget class="GtkHBox" id="pref_general_font_hbox">
+				  <property name="visible">True</property>
+				  <property name="homogeneous">False</property>
+				  <property name="spacing">12</property>
+
+				  <child>
+				    <widget class="GtkLabel" id="label39">
+				      <property name="visible">True</property>
+				      <property name="label" translatable="yes">Editor font:</property>
+				      <property name="use_underline">False</property>
+				      <property name="use_markup">False</property>
+				      <property name="justify">GTK_JUSTIFY_LEFT</property>
+				      <property name="wrap">False</property>
+				      <property name="selectable">False</property>
+				      <property name="xalign">0.5</property>
+				      <property name="yalign">0.5</property>
+				      <property name="xpad">0</property>
+				      <property name="ypad">0</property>
+				    </widget>
+				    <packing>
+				      <property name="padding">0</property>
+				      <property name="expand">False</property>
+				      <property name="fill">False</property>
+				    </packing>
+				  </child>
+
+				  <child>
+				    <widget class="GtkFontButton" id="pref_general_editor_font">
+				      <property name="visible">True</property>
+				      <property name="can_focus">True</property>
+				      <property name="show_style">True</property>
+				      <property name="show_size">True</property>
+				      <property name="use_font">False</property>
+				      <property name="use_size">False</property>
+				      <property name="focus_on_click">True</property>
+				    </widget>
+				    <packing>
+				      <property name="padding">0</property>
+				      <property name="expand">True</property>
+				      <property name="fill">True</property>
+				    </packing>
+				  </child>
+				</widget>
+				<packing>
+				  <property name="padding">0</property>
+				  <property name="expand">True</property>
+				  <property name="fill">True</property>
+				</packing>
+			      </child>
+			    </widget>
+			  </child>
+			</widget>
+			<packing>
+			  <property name="padding">0</property>
+			  <property name="expand">False</property>
+			  <property name="fill">False</property>
+			</packing>
+		      </child>
+		    </widget>
+		    <packing>
+		      <property name="padding">0</property>
 		      <property name="expand">True</property>
 		      <property name="fill">True</property>
 		    </packing>
Index: src/main.c
===================================================================
RCS file: /cvs/gnome/drivel/src/main.c,v
retrieving revision 1.62
diff -u -r1.62 main.c
--- src/main.c	13 Aug 2006 23:40:34 -0000	1.62
+++ src/main.c	12 Oct 2006 10:07:30 -0000
@@ -540,6 +540,9 @@
 	
 	data->expander_open = g_strdup_printf ("%s/expander_open", base);
 	
+	data->use_default_font = g_strdup_printf("%s/use_default_font", base);
+	data->editor_font = g_strdup_printf("%s/editor_font", base);
+	
 	gconf_client_add_dir (client, base, GCONF_CLIENT_PRELOAD_NONE, NULL);
 
 	add_gconf_notifies (dc);
