SF.net SVN: geany: [2771] branches/editor-struct

ntrel at users.sourceforge.net ntrel at xxxxx
Fri Jul 11 17:09:02 UTC 2008


Revision: 2771
          http://geany.svn.sourceforge.net/geany/?rev=2771&view=rev
Author:   ntrel
Date:     2008-07-11 10:09:01 -0700 (Fri, 11 Jul 2008)

Log Message:
-----------
Make editor_set_font() take a pango-style font string, and use a
GeanyEditor pointer.

Modified Paths:
--------------
    branches/editor-struct/ChangeLog
    branches/editor-struct/src/document.c
    branches/editor-struct/src/editor.c
    branches/editor-struct/src/editor.h
    branches/editor-struct/src/ui_utils.c

Modified: branches/editor-struct/ChangeLog
===================================================================
--- branches/editor-struct/ChangeLog	2008-07-11 14:49:09 UTC (rev 2770)
+++ branches/editor-struct/ChangeLog	2008-07-11 17:09:01 UTC (rev 2771)
@@ -10,6 +10,9 @@
  * src/build.c, src/plugindata.h, src/msgwindow.c, src/callbacks.c,
    src/editor.c, src/editor.h:
    Change plugin API EditorFuncs to use GeanyEditor pointers.
+ * src/document.c, src/editor.c, src/editor.h, src/ui_utils.c:
+   Make editor_set_font() take a pango-style font string, and use a
+   GeanyEditor pointer.
 
 
 2008-07-08  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>

Modified: branches/editor-struct/src/document.c
===================================================================
--- branches/editor-struct/src/document.c	2008-07-11 14:49:09 UTC (rev 2770)
+++ branches/editor-struct/src/document.c	2008-07-11 17:09:01 UTC (rev 2771)
@@ -384,8 +384,6 @@
  * @return The index of the created document */
 static GeanyDocument *document_create(const gchar *utf8_filename)
 {
-	PangoFontDescription *pfd;
-	gchar *fname;
 	GeanyDocument *this;
 	gint new_idx;
 	gint cur_pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook));
@@ -416,12 +414,6 @@
 
 	document_apply_update_prefs(this);
 
-	pfd = pango_font_description_from_string(interface_prefs.editor_font);
-	fname = g_strdup_printf("!%s", pango_font_description_get_family(pfd));
-	editor_set_font(this, fname, pango_font_description_get_size(pfd) / PANGO_SCALE);
-	pango_font_description_free(pfd);
-	g_free(fname);
-
 	treeviews_openfiles_add(this);	/* sets this->iter */
 
 	notebook_new_tab(this);

Modified: branches/editor-struct/src/editor.c
===================================================================
--- branches/editor-struct/src/editor.c	2008-07-11 14:49:09 UTC (rev 2770)
+++ branches/editor-struct/src/editor.c	2008-07-11 17:09:01 UTC (rev 2771)
@@ -3414,18 +3414,30 @@
 }
 
 
-void editor_set_font(GeanyDocument *doc, const gchar *font_name, gint size)
+void editor_set_font(GeanyEditor *editor, const gchar *font)
 {
-	gint style;
+	gint style, size;
+	gchar *font_name;
+	PangoFontDescription *pfd;
 
+	g_return_if_fail(editor);
+
+	pfd = pango_font_description_from_string(font);
+	size = pango_font_description_get_size(pfd) / PANGO_SCALE;
+	font_name = g_strdup_printf("!%s", pango_font_description_get_family(pfd));
+	pango_font_description_free(pfd);
+
 	for (style = 0; style <= 127; style++)
-		sci_set_font(doc->editor->scintilla, style, font_name, size);
+		sci_set_font(editor->scintilla, style, font_name, size);
+
 	/* line number and braces */
-	sci_set_font(doc->editor->scintilla, STYLE_LINENUMBER, font_name, size);
-	sci_set_font(doc->editor->scintilla, STYLE_BRACELIGHT, font_name, size);
-	sci_set_font(doc->editor->scintilla, STYLE_BRACEBAD, font_name, size);
+	sci_set_font(editor->scintilla, STYLE_LINENUMBER, font_name, size);
+	sci_set_font(editor->scintilla, STYLE_BRACELIGHT, font_name, size);
+	sci_set_font(editor->scintilla, STYLE_BRACEBAD, font_name, size);
+	g_free(font_name);
+
 	/* zoom to 100% to prevent confusion */
-	sci_zoom_off(doc->editor->scintilla);
+	sci_zoom_off(editor->scintilla);
 }
 
 
@@ -3609,6 +3621,7 @@
 	editor->line_breaking = FALSE;
 
 	editor->scintilla = create_new_sci(doc);
+	editor_set_font(editor, interface_prefs.editor_font);
 	return editor;
 }
 

Modified: branches/editor-struct/src/editor.h
===================================================================
--- branches/editor-struct/src/editor.h	2008-07-11 14:49:09 UTC (rev 2770)
+++ branches/editor-struct/src/editor.h	2008-07-11 17:09:01 UTC (rev 2771)
@@ -192,7 +192,7 @@
 
 void editor_clear_indicators(GeanyEditor *editor);
 
-void editor_set_font(GeanyDocument *doc, const gchar *font_name, gint size);
+void editor_set_font(GeanyEditor *editor, const gchar *font);
 
 const gchar *editor_get_eol_char_name(GeanyDocument *doc);
 

Modified: branches/editor-struct/src/ui_utils.c
===================================================================
--- branches/editor-struct/src/ui_utils.c	2008-07-11 14:49:09 UTC (rev 2770)
+++ branches/editor-struct/src/ui_utils.c	2008-07-11 17:09:01 UTC (rev 2771)
@@ -250,11 +250,9 @@
 void ui_set_editor_font(const gchar *font_name)
 {
 	guint i;
-	gint size;
-	gchar *fname;
-	PangoFontDescription *font_desc;
 
 	g_return_if_fail(font_name != NULL);
+
 	/* do nothing if font has not changed */
 	if (interface_prefs.editor_font != NULL)
 		if (strcmp(font_name, interface_prefs.editor_font) == 0) return;
@@ -262,23 +260,16 @@
 	g_free(interface_prefs.editor_font);
 	interface_prefs.editor_font = g_strdup(font_name);
 
-	font_desc = pango_font_description_from_string(interface_prefs.editor_font);
-
-	fname = g_strdup_printf("!%s", pango_font_description_get_family(font_desc));
-	size = pango_font_description_get_size(font_desc) / PANGO_SCALE;
-
 	/* We copy the current style, and update the font in all open tabs. */
-	for(i = 0; i < documents_array->len; i++)
+	for (i = 0; i < documents_array->len; i++)
 	{
 		if (documents[i]->editor)
 		{
-			editor_set_font(documents[i], fname, size);
+			editor_set_font(documents[i]->editor, interface_prefs.editor_font);
 		}
 	}
-	pango_font_description_free(font_desc);
 
 	ui_set_statusbar(TRUE, _("Font updated (%s)."), interface_prefs.editor_font);
-	g_free(fname);
 }
 
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list