SF.net SVN: geany: [1163] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Sat Jan 6 18:00:34 UTC 2007


Revision: 1163
          http://svn.sourceforge.net/geany/?rev=1163&view=rev
Author:   eht16
Date:     2007-01-06 10:00:34 -0800 (Sat, 06 Jan 2007)

Log Message:
-----------
Save template files in a subdirectory "templates" inside Geany's configuration directory.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/doc/geany.docbook
    trunk/src/geany.h
    trunk/src/templates.c
    trunk/src/utils.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-01-06 17:16:43 UTC (rev 1162)
+++ trunk/ChangeLog	2007-01-06 18:00:34 UTC (rev 1163)
@@ -12,6 +12,9 @@
    src/interface.c, src/templates.c, src/templates.h:
    Added template for BSD licence.
  * src/document.c: Fixed missing colouring of tab menu label.
+ * doc/geany.docbook, src/geany.h, src/utils.c, src/templates.c:
+   Save template files in a subdirectory "templates" inside Geany's
+   configuration directory.
 
 
 2007-01-06  Nick Treleaven  <nick.treleaven at btinternet.com>

Modified: trunk/doc/geany.docbook
===================================================================
--- trunk/doc/geany.docbook	2007-01-06 17:16:43 UTC (rev 1162)
+++ trunk/doc/geany.docbook	2007-01-06 18:00:34 UTC (rev 1163)
@@ -2,10 +2,10 @@
 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
         "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
 <!ENTITY app_small "geany">
-<!ENTITY appversion "0.10">
+<!ENTITY appversion "0.11">
 <!ENTITY appurl "http://geany.uvena.de">
 <!ENTITY author_mail "enrico.troeger at uvena.de">
-<!ENTITY date "December 21, 2006">
+<!ENTITY date "January 06, 2007">
 <!ENTITY legal SYSTEM "geany_gpl.docbook">
 <!ENTITY scikeybinding SYSTEM "scikeybinding.docbook">
 ]>
@@ -28,7 +28,7 @@
 			<address><email>frank at frank.uvena.de</email></address>
 		</author>
 		<copyright>
-			<year>2005-2006</year>
+			<year>2005-2007</year>
 		</copyright>
 		<legalnotice>
 			<para>
@@ -1800,7 +1800,7 @@
 			</para>
 			<para>
 				Each template can be customized to your needs. The templates are in the configuration
-				directory, which is in <filename>~/.&app_small;/</filename> (see <xref linkend="clo"/>
+				directory, which is in <filename>~/.geany/templates/</filename> (see <xref linkend="clo"/>
 				for further information about the configuration directory). Just open the desired
 				template with an editor (ideally <application>Geany</application> ;-) ) and edit
 				the template as your needs.	There are some wildcards which will be automatically

Modified: trunk/src/geany.h
===================================================================
--- trunk/src/geany.h	2007-01-06 17:16:43 UTC (rev 1162)
+++ trunk/src/geany.h	2007-01-06 18:00:34 UTC (rev 1163)
@@ -1,7 +1,8 @@
 /*
  *      geany.h - this file is part of Geany, a fast and lightweight IDE
  *
- *      Copyright 2006 Enrico Troeger <enrico.troeger at uvena.de>
+ *      Copyright 2005-2007 Enrico Troeger <enrico.troeger at uvena.de>
+ *      Copyright 2006-2007 Nick Treleaven <nick.treleaven at btinternet.com>
  *
  *      This program is free software; you can redistribute it and/or modify
  *      it under the terms of the GNU General Public License as published by
@@ -36,6 +37,7 @@
 // listed in the documentation should not be changed ;-)
 #define GEANY_HOME_DIR					g_get_home_dir()
 #define GEANY_FILEDEFS_SUBDIR			"filedefs"
+#define GEANY_TEMPLATES_SUBDIR			"templates"
 #define GEANY_CODENAME					"Bandor"
 #define GEANY_HOMEPAGE					"http://geany.uvena.de/"
 #define GEANY_USE_WIN32_DIALOG			0

Modified: trunk/src/templates.c
===================================================================
--- trunk/src/templates.c	2007-01-06 17:16:43 UTC (rev 1162)
+++ trunk/src/templates.c	2007-01-06 18:00:34 UTC (rev 1163)
@@ -204,7 +204,8 @@
 
 
 // some simple macros to reduce code size and make the code readable
-#define TEMPLATES_GET_FILENAME(x) g_strconcat(app->configdir, G_DIR_SEPARATOR_S, x, NULL)
+#define TEMPLATES_GET_FILENAME(x) g_strconcat(app->configdir, \
+				G_DIR_SEPARATOR_S GEANY_TEMPLATES_SUBDIR G_DIR_SEPARATOR_S, x, NULL)
 #define TEMPLATES_CREATE_FILE(x, y)	if (! g_file_test(x, G_FILE_TEST_EXISTS)) utils_write_file(x, y)
 #define TEMPLATES_READ_FILE(x, y) g_file_get_contents(x, y, NULL, NULL);
 
@@ -215,20 +216,20 @@
 
 void templates_init(void)
 {
-	gchar *template_filename_fileheader = TEMPLATES_GET_FILENAME("template.fileheader");
-	gchar *template_filename_gpl = TEMPLATES_GET_FILENAME("template.gpl");
-	gchar *template_filename_bsd = TEMPLATES_GET_FILENAME("template.bsd");
-	gchar *template_filename_function = TEMPLATES_GET_FILENAME("template.function");
-	gchar *template_filename_changelog = TEMPLATES_GET_FILENAME("template.changelog");
-	gchar *template_filename_filetype_none = TEMPLATES_GET_FILENAME("template.filetype.none");
-	gchar *template_filename_filetype_c = TEMPLATES_GET_FILENAME("template.filetype.c");
-	gchar *template_filename_filetype_cpp = TEMPLATES_GET_FILENAME("template.filetype.cpp");
-	gchar *template_filename_filetype_d = TEMPLATES_GET_FILENAME("template.filetype.d");
-	gchar *template_filename_filetype_java = TEMPLATES_GET_FILENAME("template.filetype.java");
-	gchar *template_filename_filetype_pascal = TEMPLATES_GET_FILENAME("template.filetype.pascal");
-	gchar *template_filename_filetype_php = TEMPLATES_GET_FILENAME("template.filetype.php");
-	gchar *template_filename_filetype_html = TEMPLATES_GET_FILENAME("template.filetype.html");
-	gchar *template_filename_filetype_ruby = TEMPLATES_GET_FILENAME("template.filetype.ruby");
+	gchar *template_filename_fileheader = TEMPLATES_GET_FILENAME("fileheader");
+	gchar *template_filename_gpl = TEMPLATES_GET_FILENAME("gpl");
+	gchar *template_filename_bsd = TEMPLATES_GET_FILENAME("bsd");
+	gchar *template_filename_function = TEMPLATES_GET_FILENAME("function");
+	gchar *template_filename_changelog = TEMPLATES_GET_FILENAME("changelog");
+	gchar *template_filename_filetype_none = TEMPLATES_GET_FILENAME("filetype.none");
+	gchar *template_filename_filetype_c = TEMPLATES_GET_FILENAME("filetype.c");
+	gchar *template_filename_filetype_cpp = TEMPLATES_GET_FILENAME("filetype.cpp");
+	gchar *template_filename_filetype_d = TEMPLATES_GET_FILENAME("filetype.d");
+	gchar *template_filename_filetype_java = TEMPLATES_GET_FILENAME("filetype.java");
+	gchar *template_filename_filetype_pascal = TEMPLATES_GET_FILENAME("filetype.pascal");
+	gchar *template_filename_filetype_php = TEMPLATES_GET_FILENAME("filetype.php");
+	gchar *template_filename_filetype_html = TEMPLATES_GET_FILENAME("filetype.html");
+	gchar *template_filename_filetype_ruby = TEMPLATES_GET_FILENAME("filetype.ruby");
 
 	time_t tp = time(NULL);
 	const struct tm *tm = localtime(&tp);

Modified: trunk/src/utils.c
===================================================================
--- trunk/src/utils.c	2007-01-06 17:16:43 UTC (rev 1162)
+++ trunk/src/utils.c	2007-01-06 18:00:34 UTC (rev 1163)
@@ -1,7 +1,8 @@
 /*
  *      utils.c - this file is part of Geany, a fast and lightweight IDE
  *
- *      Copyright 2006 Enrico Troeger <enrico.troeger at uvena.de>
+ *      Copyright 2005-2007 Enrico Troeger <enrico.troeger at uvena.de>
+ *      Copyright 2006-2007 Nick Treleaven <nick.treleaven at btinternet.com>
  *
  *      This program is free software; you can redistribute it and/or modify
  *      it under the terms of the GNU General Public License as published by
@@ -769,13 +770,13 @@
 gint utils_make_settings_dir(const gchar *dir, const gchar *data_dir, const gchar *doc_dir)
 {
 	gint error_nr = 0;
-	gchar *filetypes_readme = g_strconcat(
-					dir, G_DIR_SEPARATOR_S, "template.README", NULL);
+	gchar *conf_file = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "geany.conf", NULL);
 	gchar *filedefs_dir = g_strconcat(dir, G_DIR_SEPARATOR_S,
 					GEANY_FILEDEFS_SUBDIR, G_DIR_SEPARATOR_S, NULL);
-	gchar *filedefs_readme = g_strconcat(dir, G_DIR_SEPARATOR_S, GEANY_FILEDEFS_SUBDIR,
-					G_DIR_SEPARATOR_S, "filetypes.README", NULL);
 
+	gchar *templates_dir = g_strconcat(dir, G_DIR_SEPARATOR_S,
+					GEANY_TEMPLATES_SUBDIR, G_DIR_SEPARATOR_S, NULL);
+
 	if (! g_file_test(dir, G_FILE_TEST_EXISTS))
 	{
 		geany_debug("creating config directory %s", dir);
@@ -786,17 +787,11 @@
 #endif
 	}
 
-	if (error_nr == 0 && ! g_file_test(filetypes_readme, G_FILE_TEST_EXISTS))
-	{	// try to write template.README
-		gchar *text;
-		text = g_strconcat(
-"There are several template files in this directory. For these templates you can use wildcards.\n\
-For more information read the documentation (in ", doc_dir, "index.html or visit " GEANY_HOMEPAGE ").",
-					NULL);
-		error_nr = utils_write_file(filetypes_readme, text);
-		g_free(text);
+	if (error_nr == 0 && ! g_file_test(conf_file, G_FILE_TEST_EXISTS))
+	{	// try to write geany.conf
+		error_nr = utils_write_file(conf_file, "");
 
- 		if (error_nr == 0 && ! g_file_test(filetypes_readme, G_FILE_TEST_EXISTS))
+ 		if (error_nr == 0 && ! g_file_test(conf_file, G_FILE_TEST_EXISTS))
 		{ // check whether write test was successful, otherwise directory is not writable
 			geany_debug("The chosen configuration directory is not writable.");
 			errno = EPERM;
@@ -806,6 +801,9 @@
 	// make subdir for filetype definitions
 	if (error_nr == 0)
 	{
+		gchar *filedefs_readme = g_strconcat(dir, G_DIR_SEPARATOR_S, GEANY_FILEDEFS_SUBDIR,
+					G_DIR_SEPARATOR_S, "filetypes.README", NULL);
+
 		if (! g_file_test(filedefs_dir, G_FILE_TEST_EXISTS))
 		{
 #ifdef G_OS_WIN32
@@ -822,12 +820,39 @@
 "the documentation (in ", doc_dir, "index.html or visit " GEANY_HOMEPAGE ").", NULL);
 			utils_write_file(filedefs_readme, text);
 			g_free(text);
+			g_free(filedefs_readme);
 		}
 	}
 
-	g_free(filetypes_readme);
+	// make subdir for template files
+	if (error_nr == 0)
+	{
+		gchar *templates_readme = g_strconcat(dir, G_DIR_SEPARATOR_S, GEANY_TEMPLATES_SUBDIR,
+					G_DIR_SEPARATOR_S, "templates.README", NULL);
+
+		if (! g_file_test(templates_dir, G_FILE_TEST_EXISTS))
+		{
+#ifdef G_OS_WIN32
+			if (mkdir(templates_dir) != 0) error_nr = errno;
+#else
+			if (mkdir(templates_dir, 0700) != 0) error_nr = errno;
+#endif
+		}
+		if (error_nr == 0 && ! g_file_test(templates_readme, G_FILE_TEST_EXISTS))
+		{
+			gchar *text = g_strconcat(
+"There are several template files in this directory. For these templates you can use wildcards.\n\
+For more information read the documentation (in ", doc_dir, "index.html or visit " GEANY_HOMEPAGE ").",
+					NULL);
+			utils_write_file(templates_readme, text);
+			g_free(text);
+			g_free(templates_readme);
+		}
+	}
+
 	g_free(filedefs_dir);
-	g_free(filedefs_readme);
+	g_free(templates_dir);
+	g_free(conf_file);
 
 	return error_nr;
 }


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