Kaydet (Commit) 7b114697 authored tarafından Enrico Tröger's avatar Enrico Tröger

Save template files in a subdirectory "templates" inside Geany's configuration directory.


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1163 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 1151c48c
......@@ -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@btinternet.com>
......
......@@ -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@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@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
......
/*
* geany.h - this file is part of Geany, a fast and lightweight IDE
*
* Copyright 2006 Enrico Troeger <enrico.troeger@uvena.de>
* Copyright 2005-2007 Enrico Troeger <enrico.troeger@uvena.de>
* Copyright 2006-2007 Nick Treleaven <nick.treleaven@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
......
......@@ -204,7 +204,8 @@ static gchar *templates[GEANY_MAX_TEMPLATES];
// 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 @@ static gchar *templates_replace_all(gchar *source, gchar *year, gchar *date);
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);
......
/*
* utils.c - this file is part of Geany, a fast and lightweight IDE
*
* Copyright 2006 Enrico Troeger <enrico.troeger@uvena.de>
* Copyright 2005-2007 Enrico Troeger <enrico.troeger@uvena.de>
* Copyright 2006-2007 Nick Treleaven <nick.treleaven@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,12 +770,12 @@ gchar *utils_get_hostname()
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))
{
......@@ -786,17 +787,11 @@ gint utils_make_settings_dir(const gchar *dir, const gchar *data_dir, const gcha
#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 @@ For more information read the documentation (in ", doc_dir, "index.html or visit
// 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 @@ For more information read the documentation (in ", doc_dir, "index.html or visit
"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);
}
}
// 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(filetypes_readme);
g_free(filedefs_dir);
g_free(filedefs_readme);
g_free(templates_dir);
g_free(conf_file);
return error_nr;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment