Kaydet (Commit) 66df9594 authored tarafından Enrico Tröger's avatar Enrico Tröger

Added template for BSD licence.


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1161 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst b53385de
......@@ -8,6 +8,9 @@
"#" as comment char. The comment characters for fileheader and GPL
templates are now added dynamically according to the current
filetype.
* geany.glade, doc/geany.docbook, src/callbacks.c, src/callbacks.h,
src/interface.c, src/templates.c, src/templates.h:
Added template for BSD licence.
2007-01-06 Nick Treleaven <nick.treleaven@btinternet.com>
......
......@@ -1778,11 +1778,11 @@
</literal></literallayout>
</para>
</section>
<section>
<section id="templates">
<title>Templates</title>
<para>
<application>Geany</application> supports several templates for file headers,
multiline comments (frame comments), function descriptions, a typical ChangeLog entry
function descriptions, a typical ChangeLog entry
and a short GPL notice. To use these templates, just open the Edit menu or open the
popup menu by right-clicking in the editor widget, and choose "Insert Comments" and
insert templates as you want.
......@@ -1843,51 +1843,60 @@
<row>
<entry>developer</entry>
<entry>The name of the developer.</entry>
<entry>filetypes, file header, function description, ChangeLog entry</entry>
<entry>filetypes, file header, function description, ChangeLog entry,
bsd, gpl</entry>
</row>
<row>
<entry>initial</entry>
<entry>The developer's initials, e.g. "ET" for
Enrico Tröger or "JFD" for John Foobar Doe.</entry>
<entry>filetypes, file header, function description, ChangeLog entry</entry>
<entry>filetypes, file header, function description, ChangeLog entry,
bsd, gpl</entry>
</row>
<row>
<entry>mail</entry>
<entry>The email address of the developer.</entry>
<entry>file header, function description, ChangeLog entry</entry>
<entry>file header, function description, ChangeLog entry,
bsd, gpl</entry>
</row>
<row>
<entry>company</entry>
<entry>The company the developer is working for.</entry>
<entry>filetypes, file header, function description, ChangeLog entry</entry>
<entry>filetypes, file header, function description, ChangeLog entry,
bsd, gpl</entry>
</row>
<row>
<entry>year</entry>
<entry>The current year in the format: YYYY</entry>
<entry>filetypes, file header, function description, ChangeLog entry</entry>
<entry>filetypes, file header, function description, ChangeLog entry,
bsd, gpl</entry>
</row>
<row>
<entry>version</entry>
<entry>The initial version of a new file.</entry>
<entry>filetypes, file header, function description, ChangeLog entry</entry>
<entry>filetypes, file header, function description, ChangeLog entry,
bsd, gpl</entry>
</row>
<row>
<entry>date</entry>
<entry>The current date in the format: YYYY-MM-DD</entry>
<entry>filetypes, file header, function description, ChangeLog entry</entry>
<entry>filetypes, file header, function description, ChangeLog entry,
bsd, gpl</entry>
</row>
<row>
<entry>untitled</entry>
<entry>The string "untitled" (this will be translated to your locale),
used in filetype templates</entry>
<entry>filetypes, file header, function description, ChangeLog entry</entry>
<entry>filetypes, file header, function description, ChangeLog entry,
bsd, gpl</entry>
</row>
<row>
<entry>geanyversion</entry>
<entry>The actual <application>Geany</application> version,
e.g. "Geany &appversion;"
</entry>
<entry>filetypes, file header, function description, ChangeLog entry</entry>
<entry>filetypes, file header, function description, ChangeLog entry,
bsd, gpl</entry>
</row>
<row>
<entry>datetime</entry>
......@@ -1904,6 +1913,11 @@
<entry>This wildcard inserts a short GPL notice.</entry>
<entry>file header</entry>
</row>
<row>
<entry>bsd</entry>
<entry>This wildcard inserts a short BSD licence notice.</entry>
<entry>file header</entry>
</row>
<row>
<entry>functionname</entry>
<entry>The function name of the function at the cursor position.
......
......@@ -57,7 +57,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image1331">
<widget class="GtkImage" id="image1362">
<property name="visible">True</property>
<property name="stock">gtk-new</property>
<property name="icon_size">1</property>
......@@ -138,7 +138,7 @@
<signal name="activate" handler="on_save_all1_activate" last_modification_time="Thu, 02 Jun 2005 14:15:30 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image1332">
<widget class="GtkImage" id="image1363">
<property name="visible">True</property>
<property name="stock">gtk-save</property>
<property name="icon_size">1</property>
......@@ -159,7 +159,7 @@
<signal name="activate" handler="on_toolbutton23_clicked" last_modification_time="Mon, 24 Jul 2006 19:26:04 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image1333">
<widget class="GtkImage" id="image1364">
<property name="visible">True</property>
<property name="stock">gtk-revert-to-saved</property>
<property name="icon_size">1</property>
......@@ -179,7 +179,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image1334">
<widget class="GtkImage" id="image1365">
<property name="visible">True</property>
<property name="stock">gtk-revert-to-saved</property>
<property name="icon_size">1</property>
......@@ -259,7 +259,7 @@
<signal name="activate" handler="on_close_all1_activate" last_modification_time="Thu, 02 Jun 2005 14:15:30 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image1335">
<widget class="GtkImage" id="image1366">
<property name="visible">True</property>
<property name="stock">gtk-close</property>
<property name="icon_size">1</property>
......@@ -467,7 +467,7 @@
<signal name="activate" handler="on_menu_increase_indent1_activate" last_modification_time="Tue, 01 Aug 2006 10:28:54 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image1336">
<widget class="GtkImage" id="image1367">
<property name="visible">True</property>
<property name="stock">gtk-indent</property>
<property name="icon_size">1</property>
......@@ -488,7 +488,7 @@
<signal name="activate" handler="on_menu_decrease_indent1_activate" last_modification_time="Tue, 01 Aug 2006 10:28:54 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image1337">
<widget class="GtkImage" id="image1368">
<property name="visible">True</property>
<property name="stock">gtk-unindent</property>
<property name="icon_size">1</property>
......@@ -518,7 +518,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image1338">
<widget class="GtkImage" id="image1369">
<property name="visible">True</property>
<property name="stock">gtk-add</property>
<property name="icon_size">1</property>
......@@ -550,7 +550,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image1339">
<widget class="GtkImage" id="image1370">
<property name="visible">True</property>
<property name="stock">gtk-add</property>
<property name="icon_size">1</property>
......@@ -613,6 +613,16 @@
<signal name="activate" handler="on_menu_comments_gpl_activate" last_modification_time="Sun, 17 Dec 2006 19:01:32 GMT"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="insert_bsd_license_notice2">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Inserts a BSD llicence notice (should be done at the beginning of the file)</property>
<property name="label" translatable="yes">Insert BSD license Notice</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_menu_comments_bsd_activate" last_modification_time="Fri, 05 Jan 2007 13:29:27 GMT"/>
</widget>
</child>
</widget>
</child>
</widget>
......@@ -710,7 +720,7 @@
<signal name="activate" handler="on_replace1_activate" last_modification_time="Sun, 23 Oct 2005 13:22:36 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image1340">
<widget class="GtkImage" id="image1371">
<property name="visible">True</property>
<property name="stock">gtk-find-and-replace</property>
<property name="icon_size">1</property>
......@@ -752,7 +762,7 @@
<signal name="activate" handler="on_go_to_line1_activate" last_modification_time="Tue, 23 May 2006 17:10:49 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image1341">
<widget class="GtkImage" id="image1372">
<property name="visible">True</property>
<property name="stock">gtk-jump-to</property>
<property name="icon_size">1</property>
......@@ -787,7 +797,7 @@
<signal name="activate" handler="on_change_font1_activate" last_modification_time="Fri, 22 Apr 2005 18:58:45 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image1342">
<widget class="GtkImage" id="image1373">
<property name="visible">True</property>
<property name="stock">gtk-select-font</property>
<property name="icon_size">1</property>
......@@ -1137,7 +1147,7 @@
<signal name="activate" handler="on_show_color_chooser1_activate" last_modification_time="Wed, 22 Jun 2005 18:10:21 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image1343">
<widget class="GtkImage" id="image1374">
<property name="visible">True</property>
<property name="stock">gtk-select-color</property>
<property name="icon_size">1</property>
......@@ -2405,7 +2415,7 @@
<signal name="activate" handler="on_menu_increase_indent1_activate" last_modification_time="Tue, 01 Aug 2006 10:31:38 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image1289">
<widget class="GtkImage" id="image1375">
<property name="visible">True</property>
<property name="stock">gtk-indent</property>
<property name="icon_size">1</property>
......@@ -2426,7 +2436,7 @@
<signal name="activate" handler="on_menu_decrease_indent1_activate" last_modification_time="Tue, 01 Aug 2006 10:31:38 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image1290">
<widget class="GtkImage" id="image1376">
<property name="visible">True</property>
<property name="stock">gtk-unindent</property>
<property name="icon_size">1</property>
......@@ -2456,7 +2466,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image1291">
<widget class="GtkImage" id="image1377">
<property name="visible">True</property>
<property name="stock">gtk-add</property>
<property name="icon_size">1</property>
......@@ -2488,7 +2498,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image1292">
<widget class="GtkImage" id="image1378">
<property name="visible">True</property>
<property name="stock">gtk-add</property>
<property name="icon_size">1</property>
......@@ -2551,6 +2561,16 @@
<signal name="activate" handler="on_comments_gpl_activate" last_modification_time="Sun, 02 Oct 2005 17:37:31 GMT"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="insert_bsd_license_notice1">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Inserts a BSD llicence notice (should be done at the beginning of the file)</property>
<property name="label" translatable="yes">Insert BSD license Notice</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_comments_bsd_activate" last_modification_time="Fri, 05 Jan 2007 13:32:16 GMT"/>
</widget>
</child>
</widget>
</child>
</widget>
......@@ -2590,7 +2610,7 @@
<signal name="activate" handler="on_find_usage1_activate" last_modification_time="Fri, 27 May 2005 21:55:12 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image1293">
<widget class="GtkImage" id="image1379">
<property name="visible">True</property>
<property name="stock">gtk-find</property>
<property name="icon_size">1</property>
......@@ -2636,7 +2656,7 @@
<signal name="activate" handler="on_go_to_line_activate" last_modification_time="Sat, 16 Jul 2005 11:20:32 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image1294">
<widget class="GtkImage" id="image1380">
<property name="visible">True</property>
<property name="stock">gtk-jump-to</property>
<property name="icon_size">1</property>
......
......@@ -1493,7 +1493,7 @@ on_comments_gpl_activate (GtkMenuItem *menuitem,
gint idx = document_get_cur_idx();
gchar *text;
text = templates_get_template_licence(FILETYPE_ID(doc_list[idx].file_type));
text = templates_get_template_licence(FILETYPE_ID(doc_list[idx].file_type), GEANY_TEMPLATE_GPL);
verify_click_pos(idx); // make sure that the click_pos is valid
......@@ -1506,7 +1506,7 @@ void
on_comments_bsd_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
/*
gint idx = document_get_cur_idx();
gchar *text;
......@@ -1516,7 +1516,7 @@ on_comments_bsd_activate (GtkMenuItem *menuitem,
sci_insert_text(doc_list[idx].sci, editor_info.click_pos, text);
g_free(text);
*/
}
......
/*
* callbacks.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
......@@ -562,3 +563,11 @@ on_menu_insert_include_activate (GtkMenuItem *menuitem,
void
on_menu_insert_date_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_menu_comments_bsd_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_comments_bsd_activate (GtkMenuItem *menuitem,
gpointer user_data);
This diff is collapsed.
......@@ -49,6 +49,34 @@ along with this program; if not, write to the Free Software\n\
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n\
";
static const gchar templates_bsd_notice[] = "\
Redistribution and use in source and binary forms, with or without\n\
modification, are permitted provided that the following conditions are\n\
met:\n\
\n\
* Redistributions of source code must retain the above copyright\n\
notice, this list of conditions and the following disclaimer.\n\
* Redistributions in binary form must reproduce the above\n\
copyright notice, this list of conditions and the following disclaimer\n\
in the documentation and/or other materials provided with the\n\
distribution.\n\
* Neither the name of the {company} nor the names of its\n\
contributors may be used to endorse or promote products derived from\n\
this software without specific prior written permission.\n\
\n\
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\
\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n\
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n\
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n\
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n\
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n\
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n\
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n\
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n\
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n\
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\
";
static const gchar templates_function_description[] = "\
\n\
name: {functionname}\n\
......@@ -189,6 +217,7 @@ 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");
......@@ -210,6 +239,7 @@ void templates_init(void)
// create the template files in the configuration directory, if they don't exist
TEMPLATES_CREATE_FILE(template_filename_fileheader, templates_fileheader);
TEMPLATES_CREATE_FILE(template_filename_gpl, templates_gpl_notice);
TEMPLATES_CREATE_FILE(template_filename_bsd, templates_bsd_notice);
TEMPLATES_CREATE_FILE(template_filename_function, templates_function_description);
TEMPLATES_CREATE_FILE(template_filename_changelog, templates_changelog);
TEMPLATES_CREATE_FILE(template_filename_filetype_none, templates_filetype_none);
......@@ -227,7 +257,10 @@ void templates_init(void)
templates[GEANY_TEMPLATE_FILEHEADER] = templates_replace_all(templates[GEANY_TEMPLATE_FILEHEADER], year, date);
TEMPLATES_READ_FILE(template_filename_gpl, &templates[GEANY_TEMPLATE_GPL]);
//templates[GEANY_TEMPLATE_GPL] = templates_replace_all(templates[GEANY_TEMPLATE_GPL], year, date);
templates[GEANY_TEMPLATE_GPL] = templates_replace_all(templates[GEANY_TEMPLATE_GPL], year, date);
TEMPLATES_READ_FILE(template_filename_bsd, &templates[GEANY_TEMPLATE_BSD]);
templates[GEANY_TEMPLATE_BSD] = templates_replace_all(templates[GEANY_TEMPLATE_BSD], year, date);
TEMPLATES_READ_FILE(template_filename_function, &templates[GEANY_TEMPLATE_FUNCTION]);
templates[GEANY_TEMPLATE_FUNCTION] = templates_replace_all(templates[GEANY_TEMPLATE_FUNCTION], year, date);
......@@ -268,6 +301,7 @@ void templates_init(void)
g_free(year);
g_free(template_filename_fileheader);
g_free(template_filename_gpl);
g_free(template_filename_bsd);
g_free(template_filename_function);
g_free(template_filename_changelog);
g_free(template_filename_filetype_none);
......@@ -414,12 +448,12 @@ static gchar *make_comment_block(const gchar *comment_text, gint filetype_idx, g
}
gchar *templates_get_template_licence(gint filetype_idx)
gchar *templates_get_template_licence(gint filetype_idx, gint licence_type)
{
//if (licence_type != GEANY_TEMPLATE_GPL)
//return NULL;
if (licence_type != GEANY_TEMPLATE_GPL && licence_type != GEANY_TEMPLATE_BSD)
return NULL;
return make_comment_block(templates[GEANY_TEMPLATE_GPL], filetype_idx, 8);
return make_comment_block(templates[licence_type], filetype_idx, 8);
}
......@@ -444,6 +478,8 @@ static gchar *get_file_header(filetype *ft, const gchar *fname)
template = utils_str_replace(template, "{gpl}", templates[GEANY_TEMPLATE_GPL]);
template = utils_str_replace(template, "{bsd}", templates[GEANY_TEMPLATE_BSD]);
template = utils_str_replace(template, "{datetime}", date);
result = make_comment_block(template, FILETYPE_ID(ft), 8);
......
......@@ -38,7 +38,7 @@ gchar *templates_get_template_generic(gint template);
gchar *templates_get_template_function(gint filetype_idx, const gchar *func_name);
gchar *templates_get_template_licence(gint filetype_idx);
gchar *templates_get_template_licence(gint filetype_idx, gint licence_type);
void templates_free_templates(void);
......@@ -46,6 +46,7 @@ void templates_free_templates(void);
enum
{
GEANY_TEMPLATE_GPL = 0,
GEANY_TEMPLATE_BSD,
GEANY_TEMPLATE_FILEHEADER,
GEANY_TEMPLATE_CHANGELOG,
GEANY_TEMPLATE_FUNCTION,
......
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