SF.net SVN: geany:[4878] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Thu May 6 12:45:19 UTC 2010
Revision: 4878
http://geany.svn.sourceforge.net/geany/?rev=4878&view=rev
Author: ntrel
Date: 2010-05-06 12:45:19 +0000 (Thu, 06 May 2010)
Log Message:
-----------
Reload templates if saving a document in the templates config dir.
Modified Paths:
--------------
trunk/ChangeLog
trunk/doc/geany.html
trunk/doc/geany.txt
trunk/src/templates.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-05-06 12:03:11 UTC (rev 4877)
+++ trunk/ChangeLog 2010-05-06 12:45:19 UTC (rev 4878)
@@ -3,6 +3,8 @@
* src/build.c:
Fix marking some strings as translatable (cannot be done in the
ASSIGNIF macro).
+ * src/templates.c:
+ Reload templates if saving a document in the templates config dir.
2010-05-05 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/doc/geany.html
===================================================================
--- trunk/doc/geany.html 2010-05-06 12:03:11 UTC (rev 4877)
+++ trunk/doc/geany.html 2010-05-06 12:45:19 UTC (rev 4878)
@@ -2473,8 +2473,8 @@
you want to use in your template files.</p>
<div class="note">
<p class="first admonition-title">Note</p>
-<p class="last">For changes made here to take effect, either selecting
-<em>Tools->Reload Configuration</em> or restarting Geany is required.</p>
+<p class="last">For changes made here to take effect, you must either select
+<em>Tools->Reload Configuration</em> or restart Geany.</p>
</div>
<img alt="./images/pref_dialog_templ.png" src="./images/pref_dialog_templ.png" />
<div class="section">
@@ -4816,6 +4816,12 @@
of a function or the function name cannot be determined, the inserted
function description won't contain the correct function name but "unknown"
instead.</p>
+<div class="note">
+<p class="first admonition-title">Note</p>
+<p class="last">Geany automatically reloads template information when it notices you
+save a file in the user's template configuration directory. You can
+also force this by selecting <em>Tools->Reload Configuration</em>.</p>
+</div>
<div class="section">
<h3><a class="toc-backref" href="#id192" id="template-meta-data" name="template-meta-data">Template meta data</a></h3>
<p>Meta data can be used with all templates, but by default user set
@@ -4850,8 +4856,7 @@
any. For example, creating a file <tt class="docutils literal"><span class="pre">module.c</span></tt> would add a menu item
which created a new document with the filetype set to 'C'.</p>
<p>The template file is read from disk when the corresponding menu item is
-clicked, so you don't need to select <em>Tools->Reload Configuration</em> or restart
-Geany after editing a custom file template.</p>
+clicked.</p>
</div>
<div class="section">
<h4><a class="toc-backref" href="#id195" id="filetype-templates" name="filetype-templates">Filetype templates</a></h4>
@@ -6080,7 +6085,7 @@
<div class="footer">
<hr class="footer" />
<a class="reference" href="geany.txt">View document source</a>.
-Generated on: 2010-05-05 15:03 UTC.
+Generated on: 2010-05-06 12:44 UTC.
Generated by <a class="reference" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
</div>
Modified: trunk/doc/geany.txt
===================================================================
--- trunk/doc/geany.txt 2010-05-06 12:03:11 UTC (rev 4877)
+++ trunk/doc/geany.txt 2010-05-06 12:45:19 UTC (rev 4878)
@@ -2182,8 +2182,8 @@
you want to use in your template files.
.. note::
- For changes made here to take effect, either selecting
- *Tools->Reload Configuration* or restarting Geany is required.
+ For changes made here to take effect, you must either select
+ *Tools->Reload Configuration* or restart Geany.
.. image:: ./images/pref_dialog_templ.png
@@ -4153,7 +4153,12 @@
function description won't contain the correct function name but "unknown"
instead.
+.. note::
+ Geany automatically reloads template information when it notices you
+ save a file in the user's template configuration directory. You can
+ also force this by selecting *Tools->Reload Configuration*.
+
Template meta data
^^^^^^^^^^^^^^^^^^
@@ -4197,8 +4202,7 @@
which created a new document with the filetype set to 'C'.
The template file is read from disk when the corresponding menu item is
-clicked, so you don't need to select *Tools->Reload Configuration* or restart
-Geany after editing a custom file template.
+clicked.
Filetype templates
``````````````````
Modified: trunk/src/templates.c
===================================================================
--- trunk/src/templates.c 2010-05-06 12:03:11 UTC (rev 4877)
+++ trunk/src/templates.c 2010-05-06 12:45:19 UTC (rev 4878)
@@ -465,6 +465,22 @@
}
+/* reload templates if any file in the templates path is saved */
+static void on_document_save(G_GNUC_UNUSED GObject *object, GeanyDocument *doc)
+{
+ const gchar *path = utils_build_path(app->configdir, GEANY_TEMPLATES_SUBDIR, NULL);
+
+ g_return_if_fail(NZV(doc->real_path));
+
+ if (strncmp(doc->real_path, path, strlen(path)) == 0)
+ {
+ /* reload templates */
+ templates_free_templates();
+ templates_init();
+ }
+}
+
+
void templates_init(void)
{
gchar *year = utils_get_date_time(template_prefs.year_format, NULL);
@@ -488,6 +504,8 @@
item = gtk_menu_item_get_submenu(GTK_MENU_ITEM(item));
g_signal_connect(item, "show", G_CALLBACK(on_file_menu_show), NULL);
g_signal_connect(item, "hide", G_CALLBACK(on_file_menu_hide), NULL);
+
+ g_signal_connect(geany_object, "document-save", G_CALLBACK(on_document_save), NULL);
}
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