Revision: 4273 http://geany.svn.sourceforge.net/geany/?rev=4273&view=rev Author: ntrel Date: 2009-09-30 17:40:10 +0000 (Wed, 30 Sep 2009)
Log Message: ----------- Move filetype template defaults into custom file template files.
Modified Paths: -------------- trunk/ChangeLog trunk/Makefile.am trunk/src/templates.c trunk/wscript
Added Paths: ----------- trunk/data/templates/ trunk/data/templates/files/ trunk/data/templates/files/file.html trunk/data/templates/files/file.php trunk/data/templates/files/file.rb trunk/data/templates/files/file.tex trunk/data/templates/files/main.c trunk/data/templates/files/main.cxx trunk/data/templates/files/main.d trunk/data/templates/files/main.java trunk/data/templates/files/main.py trunk/data/templates/files/program.pas
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-09-30 14:55:25 UTC (rev 4272) +++ trunk/ChangeLog 2009-09-30 17:40:10 UTC (rev 4273) @@ -5,6 +5,14 @@ * src/templates.c, doc/geany.txt, doc/geany.html: Read custom file templates from $prefix/share/geany/templates/files as well as user dir. + * src/templates.c, data/templates, data/templates/files, + data/templates/files/file.rb, data/templates/files/file.html, + data/templates/files/main.java, data/templates/files/main.c, + data/templates/files/main.cxx, data/templates/files/file.php, + data/templates/files/main.d, data/templates/files/program.pas, + data/templates/files/main.py, data/templates/files/file.tex, + wscript, Makefile.am: + Move filetype template defaults into custom file template files.
2009-09-29 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/Makefile.am =================================================================== --- trunk/Makefile.am 2009-09-30 14:55:25 UTC (rev 4272) +++ trunk/Makefile.am 2009-09-30 17:40:10 UTC (rev 4273) @@ -22,7 +22,8 @@ $(srcdir)/data/filetypes.* \ data/filetype_extensions.conf \ data/snippets.conf \ - data/ui_toolbar.xml + data/ui_toolbar.xml \ + $(srcdir)/data/templates/files/*
EXTRA_DIST = \ autogen.sh \ @@ -68,6 +69,13 @@ $(INSTALL_DATA) $$file $(DESTDIR)$(pkgdatadir)/; \ fi \ done + $(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/templates; + $(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/templates/files; + for file in $(srcdir)/data/templates/files/*; do \ + if test -f $$file; then \ + $(INSTALL_DATA) $$file $(DESTDIR)$(pkgdatadir)/templates/files/; \ + fi \ + done
BZIP2_ENV =--best
Added: trunk/data/templates/files/file.html =================================================================== --- trunk/data/templates/files/file.html (rev 0) +++ trunk/data/templates/files/file.html 2009-09-30 17:40:10 UTC (rev 4273) @@ -0,0 +1,16 @@ +{fileheader} +<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" + \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"> +<html xmlns="http://www.w3.org/1999/xhtml%5C" xml:lang="en" lang="en"> + +<head> + <title>{untitled}</title> + <meta http-equiv="content-type" content="text/html;charset=utf-8" /> + <meta name="generator" content="{geanyversion}" /> +</head> + +<body> + +</body> +</html> +
Added: trunk/data/templates/files/file.php =================================================================== --- trunk/data/templates/files/file.php (rev 0) +++ trunk/data/templates/files/file.php 2009-09-30 17:40:10 UTC (rev 4273) @@ -0,0 +1,20 @@ + +<?php +{fileheader} +?> + +<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" + \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"> +<html xmlns="http://www.w3.org/1999/xhtml%5C" xml:lang="en" lang="en"> + +<head> + <title>{untitled}</title> + <meta http-equiv="content-type" content="text/html;charset=utf-8" /> + <meta name="generator" content="{geanyversion}" /> +</head> + +<body> + +</body> +</html> +
Added: trunk/data/templates/files/file.rb =================================================================== --- trunk/data/templates/files/file.rb (rev 0) +++ trunk/data/templates/files/file.rb 2009-09-30 17:40:10 UTC (rev 4273) @@ -0,0 +1,10 @@ +{fileheader} + +class StdClass + def initialize + + end +end + +x = StdClass.new +
Added: trunk/data/templates/files/file.tex =================================================================== --- trunk/data/templates/files/file.tex (rev 0) +++ trunk/data/templates/files/file.tex 2009-09-30 17:40:10 UTC (rev 4273) @@ -0,0 +1,10 @@ + +\documentclass[a4paper]{article} +\usepackage[T1]{fontenc} +\usepackage[utf8]{inputenc} +\usepackage{lmodern} +\usepackage{babel} +\begin{document} + +\end{document} +
Added: trunk/data/templates/files/main.c =================================================================== --- trunk/data/templates/files/main.c (rev 0) +++ trunk/data/templates/files/main.c 2009-09-30 17:40:10 UTC (rev 4273) @@ -0,0 +1,10 @@ +{fileheader} + +#include <stdio.h> + +int main(int argc, char **argv) +{ + + return 0; +} +
Added: trunk/data/templates/files/main.cxx =================================================================== --- trunk/data/templates/files/main.cxx (rev 0) +++ trunk/data/templates/files/main.cxx 2009-09-30 17:40:10 UTC (rev 4273) @@ -0,0 +1,10 @@ +{fileheader} + +#include <iostream> + +int main(int argc, char **argv) +{ + + return 0; +} +
Added: trunk/data/templates/files/main.d =================================================================== --- trunk/data/templates/files/main.d (rev 0) +++ trunk/data/templates/files/main.d 2009-09-30 17:40:10 UTC (rev 4273) @@ -0,0 +1,10 @@ +{fileheader} + +import std.stdio; + +int main(char[][] args) +{ + + return 0; +} +
Added: trunk/data/templates/files/main.java =================================================================== --- trunk/data/templates/files/main.java (rev 0) +++ trunk/data/templates/files/main.java 2009-09-30 17:40:10 UTC (rev 4273) @@ -0,0 +1,10 @@ +{fileheader} + +public class {untitled} { + + public static void main (String args[]) { + + + } +} +
Added: trunk/data/templates/files/main.py =================================================================== --- trunk/data/templates/files/main.py (rev 0) +++ trunk/data/templates/files/main.py 2009-09-30 17:40:10 UTC (rev 4273) @@ -0,0 +1,13 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +{fileheader} + + +def main(): + + return 0 + +if __name__ == '__main__': + main() +
Added: trunk/data/templates/files/program.pas =================================================================== --- trunk/data/templates/files/program.pas (rev 0) +++ trunk/data/templates/files/program.pas 2009-09-30 17:40:10 UTC (rev 4273) @@ -0,0 +1,12 @@ +{fileheader} + +program {untitled}; + +uses crt; +var i : byte; + +BEGIN + + +END. +
Modified: trunk/src/templates.c =================================================================== --- trunk/src/templates.c 2009-09-30 14:55:25 UTC (rev 4272) +++ trunk/src/templates.c 2009-09-30 17:40:10 UTC (rev 4273) @@ -47,6 +47,8 @@ static GtkWidget *toolbar_new_file_menu = NULL;
+/* TODO: implement custom insertion templates, put these into files in data/templates */ + /* default templates, only for initial tempate file creation on first start of Geany */ static const gchar templates_gpl_notice[] = "\ This program is free software; you can redistribute it and/or modify\n\ @@ -118,133 +120,13 @@ \n\ * \n\n\n";
+/* Used when starting a new file normally */ static const gchar templates_filetype_none[] = "";
-static const gchar templates_filetype_c[] = "{fileheader}\n\n\ -#include <stdio.h>\n\ -\n\ -int main(int argc, char** argv)\n\ -{\n\ - \n\ - return 0;\n\ -}\n\ -"; - -static const gchar templates_filetype_cpp[] = "{fileheader}\n\n\ -#include <iostream>\n\ -\n\ -int main(int argc, char** argv)\n\ -{\n\ - \n\ - return 0;\n\ -}\n\ -"; - -static const gchar templates_filetype_d[] = "{fileheader}\n\n\ -import std.stdio;\n\ -\n\ -int main(char[][] args)\n\ -{\n\ - \n\ - return 0;\n\ -}\n\ -"; - -static const gchar templates_filetype_php[] = "\ -<?php\n\ -{fileheader}\ -?>\n\n\ -<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n\ - \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n\ -<html xmlns="http://www.w3.org/1999/xhtml%5C" xml:lang="en" lang="en">\n\ -\n\ -<head>\n\ - <title>{untitled}</title>\n\ - <meta http-equiv="content-type" content="text/html;charset=utf-8" />\n\ - <meta name="generator" content="{geanyversion}" />\n\ -</head>\n\ -\n\ -<body>\n\ - \n\ -</body>\n\ -</html>\n\ -"; - -static const gchar templates_filetype_html[] = "{fileheader}\n\ -<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n\ - \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n\ -<html xmlns="http://www.w3.org/1999/xhtml%5C" xml:lang="en" lang="en">\n\ -\n\ -<head>\n\ - <title>{untitled}</title>\n\ - <meta http-equiv="content-type" content="text/html;charset=utf-8" />\n\ - <meta name="generator" content="{geanyversion}" />\n\ -</head>\n\ -\n\ -<body>\n\ - \n\ -</body>\n\ -</html>\n\ -"; - -static const gchar templates_filetype_pascal[] = "{fileheader}\n\n\ -program {untitled};\n\ -\n\ -uses crt;\n\ -var i : byte;\n\ -\n\ -BEGIN\n\ - \n\ - \n\ -END.\n\ -"; - -static const gchar templates_filetype_java[] = "{fileheader}\n\n\ -public class {untitled} {\n\ -\n\ - public static void main (String args[]) {\ - \n\ - \n\ - }\n\ -}\n\ -"; - -static const gchar templates_filetype_ruby[] = "{fileheader}\n\n\ -class StdClass\n\ - def initialize\n\ - \n\ - end\n\ -end\n\ -\n\ -x = StdClass.new\n\ -"; - -static const gchar templates_filetype_python[] = "#!/usr/bin/env python\n\ -# -*- coding: utf-8 -*-\n#\n\ -{fileheader}\n\n\ -\n\ -def main():\n\ - \n\ - return 0\n\ -\n\ -if __name__ == '__main__':\n\ - main()\n\ -"; - -static const gchar templates_filetype_latex[] = "\ -\documentclass[a4paper]{article}\n\ -\usepackage[T1]{fontenc}\n\ -\usepackage[utf8]{inputenc}\n\ -\usepackage{lmodern}\n\ -\usepackage{babel}\n\ -\begin{document}\n\ -\n\ -\end{document}\n\ -"; - static gchar *templates[GEANY_MAX_TEMPLATES];
-/* TODO: remove filetype templates, use custom file templates instead. */ +/* We should probably remove filetype templates support soon - users can use custom + * file templates instead. */ static gchar *ft_templates[GEANY_MAX_BUILT_IN_FILETYPES] = {NULL};
@@ -335,6 +217,7 @@ }
+/* Users should use custom filetypes instead, except for filetype none template */ static void init_ft_templates(const gchar *year, const gchar *date, const gchar *datetime) { filetype_id ft_id; @@ -350,37 +233,8 @@ case GEANY_FILETYPES_NONE: create_template_file_if_necessary(fname, templates_filetype_none); break; - case GEANY_FILETYPES_C: - create_template_file_if_necessary(fname, templates_filetype_c); + default: break; - case GEANY_FILETYPES_CPP: - create_template_file_if_necessary(fname, templates_filetype_cpp); - break; - case GEANY_FILETYPES_D: - create_template_file_if_necessary(fname, templates_filetype_d); - break; - case GEANY_FILETYPES_JAVA: - create_template_file_if_necessary(fname, templates_filetype_java); - break; - case GEANY_FILETYPES_PASCAL: - create_template_file_if_necessary(fname, templates_filetype_pascal); - break; - case GEANY_FILETYPES_PHP: - create_template_file_if_necessary(fname, templates_filetype_php); - break; - case GEANY_FILETYPES_HTML: - create_template_file_if_necessary(fname, templates_filetype_html); - break; - case GEANY_FILETYPES_RUBY: - create_template_file_if_necessary(fname, templates_filetype_ruby); - break; - case GEANY_FILETYPES_PYTHON: - create_template_file_if_necessary(fname, templates_filetype_python); - break; - case GEANY_FILETYPES_LATEX: - create_template_file_if_necessary(fname, templates_filetype_latex); - break; - default: break; } TEMPLATES_READ_FILE(fname, &ft_templates[ft_id]); ft_templates[ft_id] = replace_all(ft_templates[ft_id], year, date, datetime);
Modified: trunk/wscript =================================================================== --- trunk/wscript 2009-09-30 14:55:25 UTC (rev 4272) +++ trunk/wscript 2009-09-30 17:40:10 UTC (rev 4273) @@ -503,6 +503,7 @@ bld.install_files('${DATADIR}/%s' % dir, 'data/*.tags') bld.install_files('${DATADIR}/%s' % dir, 'data/snippets.conf') bld.install_files('${DATADIR}/%s' % dir, 'data/ui_toolbar.xml') + bld.install_files('${DATADIR}/%s/templates/files' % dir, 'data/templates/files/*.*') bld.install_as('${DATADIR}/%s/GPL-2' % dir, 'COPYING') # Icons bld.install_files('${PREFIX}/share/icons'
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.