SF.net SVN: geany:[3219] trunk
eht16 at users.sourceforge.net
eht16 at xxxxx
Thu Nov 13 14:37:47 UTC 2008
Revision: 3219
http://geany.svn.sourceforge.net/geany/?rev=3219&view=rev
Author: eht16
Date: 2008-11-13 14:37:47 +0000 (Thu, 13 Nov 2008)
Log Message:
-----------
Follow XDG Base Directory specification and use $XDG_CONFIG_HOME/geany (most often this is ~/.config/geany) as default configuration directory (closes #2166229).
The previous configuration will be moved to the new location if the new directory doesn't exist yet.
Move utils_make_settings_dir() into main.c.
Remove win32_get_appdata_folder() because g_get_user_config_dir() does the same.
Modified Paths:
--------------
trunk/ChangeLog
trunk/HACKING
trunk/doc/geany.1.in
trunk/doc/geany.html
trunk/doc/geany.txt
trunk/plugins/demoplugin.c
trunk/src/geany.h
trunk/src/main.c
trunk/src/plugins.c
trunk/src/socket.c
trunk/src/utils.c
trunk/src/utils.h
trunk/src/win32.c
trunk/src/win32.h
trunk/tagmanager/options.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2008-11-13 13:18:02 UTC (rev 3218)
+++ trunk/ChangeLog 2008-11-13 14:37:47 UTC (rev 3219)
@@ -1,3 +1,19 @@
+2008-11-13 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
+
+ * HACKING, doc/geany.1.in, doc/geany.html, doc/geany.txt,
+ plugins/demoplugin.c, src/geany.h, src/main.c, src/plugins.c,
+ src/socket.c, src/utils.c, src/utils.h, src/win32.c, src/win32.h,
+ tagmanager/options.c:
+ Follow XDG Base Directory specification and use
+ $XDG_CONFIG_HOME/geany (most often this is ~/.config/geany) as
+ default configuration directory (closes #2166229).
+ The previous configuration will be moved to the new location if
+ the new directory doesn't exist yet.
+ Move utils_make_settings_dir() into main.c.
+ Remove win32_get_appdata_folder() because g_get_user_config_dir()
+ does the same.
+
+
2008-11-13 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* src/editor.c:
Modified: trunk/HACKING
===================================================================
--- trunk/HACKING 2008-11-13 13:18:02 UTC (rev 3218)
+++ trunk/HACKING 2008-11-13 14:37:47 UTC (rev 3219)
@@ -295,7 +295,7 @@
Loading a plugin from GDB
-------------------------
This is useful so you can load plugins without installing them first.
-Alternatively you can use a symlink in ~/.geany/plugins or
+Alternatively you can use a symlink in ~/.config/geany/plugins or
$prefix/lib/geany (where $prefix is /usr/local by default).
The gdb session below was run from the toplevel Geany source directory.
Modified: trunk/doc/geany.1.in
===================================================================
--- trunk/doc/geany.1.in 2008-11-13 13:18:02 UTC (rev 3218)
+++ trunk/doc/geany.1.in 2008-11-13 14:37:47 UTC (rev 3219)
@@ -30,7 +30,7 @@
Set initial column number for the first opened file (useful in conjunction with \-\-line).
.IP "\fB-c\fP, \fB\-\-config\fP " 10
Use an alternate configuration directory. Default configuration directory is
-~/.geany/ and there resides geany.conf and some template files.
+~/.config/geany/ and there resides geany.conf and some template files.
.IP "\fB-d\fP, \fB\-\-debug\fP " 10
Run Geany in debug mode, which means being verbose and printing lots of information.
.IP "\fB\fP, \fB\-\-ft\-names\fP " 10
Modified: trunk/doc/geany.html
===================================================================
--- trunk/doc/geany.html 2008-11-13 13:18:02 UTC (rev 3218)
+++ trunk/doc/geany.html 2008-11-13 14:37:47 UTC (rev 3219)
@@ -554,8 +554,8 @@
<tr><td>-c dir_name</td>
<td>--config=directory_name</td>
<td>Use an alternate configuration directory. Default
-configuration directory is <tt class="docutils literal"><span class="pre">~/.geany/</span></tt> and there resides
-<tt class="docutils literal"><span class="pre">geany.conf</span></tt> and other configuration files.</td>
+configuration directory is <tt class="docutils literal"><span class="pre">~/.config/geany/</span></tt> and there
+resides <tt class="docutils literal"><span class="pre">geany.conf</span></tt> and other configuration files.</td>
</tr>
<tr><td>-d</td>
<td>--debug</td>
@@ -1084,15 +1084,15 @@
installed (commonly <tt class="docutils literal"><span class="pre">/usr/local</span></tt>). It is not recommended to edit the
system-wide file, because it will be overridden when Geany is updated.</p>
<p>To change the settings, copy the file from <tt class="docutils literal"><span class="pre">$prefix/share/geany</span></tt>
-in your configuration directory (usually <tt class="docutils literal"><span class="pre">~/.geany/</span></tt>).</p>
+in your configuration directory (usually <tt class="docutils literal"><span class="pre">~/.config/geany/</span></tt>).</p>
<p>For example:</p>
<pre class="literal-block">
-% cp /usr/local/share/geany/snippets.conf /home/username/.geany/
+% cp /usr/local/share/geany/snippets.conf /home/username/.config/geany/
</pre>
<p>Then you can edit the file and the changes are also available
after an update of Geany because the file resides in your
configuration directory. Alternatively, you can create a file
-<tt class="docutils literal"><span class="pre">~/.geany/snippets.conf</span></tt> and add only these settings you want
+<tt class="docutils literal"><span class="pre">~/.config/geany/snippets.conf</span></tt> and add only these settings you want
to change. All missing settings will be read from the global snippets
file in <tt class="docutils literal"><span class="pre">$prefix/share/geany</span></tt>.</p>
<p>The file <tt class="docutils literal"><span class="pre">snippets.conf</span></tt> may contain several sections for each
@@ -1410,7 +1410,7 @@
<p>Geany has built-in functionality for generating tag information (aka
"workspace tags") for supported filetypes when you open a file. You
can also have Geany automatically load external tag files (aka "global
-tags files") from its <tt class="docutils literal"><span class="pre">~/.geany/tags</span></tt> directory upon startup, or
+tags files") from its <tt class="docutils literal"><span class="pre">~/.config/geany/tags</span></tt> directory upon startup, or
manually using <em>Tools --> Load Tags</em>.</p>
<p>Geany uses its own tag file format, similar to what <tt class="docutils literal"><span class="pre">ctags</span></tt> uses
(but is incompatible with ctags). You use Geany to generate global
@@ -1433,7 +1433,7 @@
<p>You can load a custom global tags file in two ways:</p>
<ul class="simple">
<li>Using the <em>Load Tags</em> command in the Tools menu.</li>
-<li>By creating a directory <tt class="docutils literal"><span class="pre">~/.geany/tags</span></tt>, and moving or symlinking
+<li>By creating a directory <tt class="docutils literal"><span class="pre">~/.config/geany/tags</span></tt>, and moving or symlinking
the tags files there before starting Geany.</li>
</ul>
<p>You can either download these files or generate your own. They have
@@ -1508,7 +1508,7 @@
<h3><a class="toc-backref" href="#id68">Ignore tags</a></h3>
<p>You can also ignore certain tags if they would lead to wrong parsing of
the code. Simply create a file called "ignore.tags" in your Geany
-configuration directory (usually <tt class="docutils literal"><span class="pre">~/.geany/</span></tt>). Then list all tags
+configuration directory (usually <tt class="docutils literal"><span class="pre">~/.config/geany/</span></tt>). Then list all tags
you want to ignore in this file, separated by spaces and/or newlines.</p>
<p>More detailed information about the usage from the Exuberant Ctags
manual page:</p>
@@ -2388,7 +2388,7 @@
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">$prefix/lib/geany</span></tt> (<tt class="docutils literal"><span class="pre">$prefix</span></tt> is usually <tt class="docutils literal"><span class="pre">/usr/local</span></tt> or
<tt class="docutils literal"><span class="pre">/usr</span></tt>)</li>
-<li><tt class="docutils literal"><span class="pre">~/.geany/plugins</span></tt></li>
+<li><tt class="docutils literal"><span class="pre">~/.config/geany/plugins</span></tt></li>
</ul>
<p>Most plugins add menu items to the <em>Tools</em> menu when they are loaded.</p>
<p>Since Geany 0.13, there is a Plugin Manager to let you choose which plugins
@@ -3068,15 +3068,15 @@
Geany is updated.</p>
<p>To change the settings, copy a file from <tt class="docutils literal"><span class="pre">$prefix/share/geany</span></tt> to
the subdirectory filedefs in your configuration directory (usually
-<tt class="docutils literal"><span class="pre">~/.geany/</span></tt>).</p>
+<tt class="docutils literal"><span class="pre">~/.config/geany/</span></tt>).</p>
<p>For example:</p>
<pre class="literal-block">
-% cp /usr/local/share/geany/filetypes.c /home/username/.geany/filedefs/
+% cp /usr/local/share/geany/filetypes.c /home/username/.config/geany/filedefs/
</pre>
<p>Then you can edit the file and the changes are also
available after an update of Geany because they reside in your
configuration directory. Alternatively, you can create a file
-<tt class="docutils literal"><span class="pre">~/.geany/filedefs/filetypes.X</span></tt> and add only these settings you want
+<tt class="docutils literal"><span class="pre">~/.config/geany/filedefs/filetypes.X</span></tt> and add only these settings you want
to change. All missing settings will be read from the corresponding
global definition file in <tt class="docutils literal"><span class="pre">$prefix/share/geany</span></tt>.</p>
<div class="section" id="format">
@@ -3386,18 +3386,18 @@
filetype using the <tt class="docutils literal"><span class="pre">filetype_extensions.conf</span></tt> file.</p>
<p>To override the system-wide configuration file, copy it from
<tt class="docutils literal"><span class="pre">$prefix/share/geany</span></tt> to your configuration directory, usually
-<tt class="docutils literal"><span class="pre">~/.geany/</span></tt>. <tt class="docutils literal"><span class="pre">$prefix</span></tt> is the path where Geany is installed
+<tt class="docutils literal"><span class="pre">~/.config/geany/</span></tt>. <tt class="docutils literal"><span class="pre">$prefix</span></tt> is the path where Geany is installed
(commonly <tt class="docutils literal"><span class="pre">/usr/local</span></tt>).</p>
<p>For example:</p>
<pre class="literal-block">
-% cp /usr/local/share/geany/filetype_extensions.conf /home/username/.geany/
+% cp /usr/local/share/geany/filetype_extensions.conf /home/username/.config/geany/
</pre>
<p>Then edit it and remove all the lines for filetype extensions that
you do not want to override. The remaining lines can be edited after
the <tt class="docutils literal"><span class="pre">=</span></tt> sign, using a semi-colon separated list of patterns which
should be matched for that filetype.</p>
<p>For example, to set the filetype extensions for Make, the
-<tt class="docutils literal"><span class="pre">/home/username/.geany/filetype_extensions.conf</span></tt> file should
+<tt class="docutils literal"><span class="pre">/home/username/.config/geany/filetype_extensions.conf</span></tt> file should
look like:</p>
<pre class="literal-block">
[Extensions]
@@ -3451,18 +3451,18 @@
followed by a blank line.</p>
<div class="section" id="custom-file-templates">
<h4><a class="toc-backref" href="#id143">Custom file templates</a></h4>
-<p>These are read from the <tt class="docutils literal"><span class="pre">~/.geany/templates/files</span></tt> directory (created
-the first time Geany is started). The filetype to use is detected from
-the template file's extension, if any. For example, creating a file
-<tt class="docutils literal"><span class="pre">main.c</span></tt> would add a menu item which created a new document with the
-filetype set to 'C'.</p>
+<p>These are read from the <tt class="docutils literal"><span class="pre">~/.config/geany/templates/files</span></tt> directory
+(created the first time Geany is started). The filetype to use is
+detected from the template file's extension, if any. For example, creating
+a file <tt class="docutils literal"><span class="pre">main.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 restart Geany after editing a custom file
template.</p>
</div>
<div class="section" id="filetype-templates">
<h4><a class="toc-backref" href="#id144">Filetype templates</a></h4>
-<p>Filetype template files are read from the <tt class="docutils literal"><span class="pre">~/.geany/templates</span></tt>
+<p>Filetype template files are read from the <tt class="docutils literal"><span class="pre">~/.config/geany/templates</span></tt>
directory, and are named "filetype." followed by the filetype
name, e.g. "filetype.python", "filetype.sh", etc. If you are
unsure about the filetype name extensions, they are the same as
@@ -3475,7 +3475,7 @@
<div class="section" id="customizing-templates">
<h3><a class="toc-backref" href="#id145">Customizing templates</a></h3>
<p>Each template can be customized to your needs. The templates are
-stored in the <tt class="docutils literal"><span class="pre">~/.geany/templates/</span></tt> directory (see the section called
+stored in the <tt class="docutils literal"><span class="pre">~/.config/geany/templates/</span></tt> directory (see the section called
<a class="reference internal" href="#command-line-options">Command line options</a> for further information about the configuration
directory). Just open the desired template with an editor (ideally,
Geany ;-) ) and edit the template to your needs. There are some
@@ -3784,7 +3784,7 @@
<div class="section" id="hidden-preferences">
<h1><a class="toc-backref" href="#id158">Hidden preferences</a></h1>
<p>There are some uncommon preferences that are not shown in the Preferences
-dialog. These can be set by editing <tt class="docutils literal"><span class="pre">~/.geany/geany.conf</span></tt>, then
+dialog. These can be set by editing <tt class="docutils literal"><span class="pre">~/.config/geany/geany.conf</span></tt>, then
restarting Geany. Search for the key name, then edit the value. Example:</p>
<blockquote>
<tt class="docutils literal"><span class="pre">brace_match_ltgt=true</span></tt></blockquote>
@@ -4412,7 +4412,7 @@
<div class="footer">
<hr class="footer" />
<a class="reference external" href="geany.txt">View document source</a>.
-Generated on: 2008-11-10 18:20 UTC.
+Generated on: 2008-11-13 14:09 UTC.
Generated by <a class="reference external" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
</div>
Modified: trunk/doc/geany.txt
===================================================================
--- trunk/doc/geany.txt 2008-11-13 13:18:02 UTC (rev 3218)
+++ trunk/doc/geany.txt 2008-11-13 14:37:47 UTC (rev 3219)
@@ -201,8 +201,8 @@
*none* --column Set initial column number for the first opened file.
-c dir_name --config=directory_name Use an alternate configuration directory. Default
- configuration directory is ``~/.geany/`` and there resides
- ``geany.conf`` and other configuration files.
+ configuration directory is ``~/.config/geany/`` and there
+ resides ``geany.conf`` and other configuration files.
-d --debug Run Geany in debug mode, which means being verbose
and printing lots of information.
@@ -763,16 +763,16 @@
system-wide file, because it will be overridden when Geany is updated.
To change the settings, copy the file from ``$prefix/share/geany``
-in your configuration directory (usually ``~/.geany/``).
+in your configuration directory (usually ``~/.config/geany/``).
For example::
- % cp /usr/local/share/geany/snippets.conf /home/username/.geany/
+ % cp /usr/local/share/geany/snippets.conf /home/username/.config/geany/
Then you can edit the file and the changes are also available
after an update of Geany because the file resides in your
configuration directory. Alternatively, you can create a file
-``~/.geany/snippets.conf`` and add only these settings you want
+``~/.config/geany/snippets.conf`` and add only these settings you want
to change. All missing settings will be read from the global snippets
file in ``$prefix/share/geany``.
@@ -1116,7 +1116,7 @@
Geany has built-in functionality for generating tag information (aka
"workspace tags") for supported filetypes when you open a file. You
can also have Geany automatically load external tag files (aka "global
-tags files") from its ``~/.geany/tags`` directory upon startup, or
+tags files") from its ``~/.config/geany/tags`` directory upon startup, or
manually using *Tools --> Load Tags*.
Geany uses its own tag file format, similar to what ``ctags`` uses
@@ -1147,7 +1147,7 @@
You can load a custom global tags file in two ways:
* Using the *Load Tags* command in the Tools menu.
-* By creating a directory ``~/.geany/tags``, and moving or symlinking
+* By creating a directory ``~/.config/geany/tags``, and moving or symlinking
the tags files there before starting Geany.
You can either download these files or generate your own. They have
@@ -1235,7 +1235,7 @@
You can also ignore certain tags if they would lead to wrong parsing of
the code. Simply create a file called "ignore.tags" in your Geany
-configuration directory (usually ``~/.geany/``). Then list all tags
+configuration directory (usually ``~/.config/geany/``). Then list all tags
you want to ignore in this file, separated by spaces and/or newlines.
More detailed information about the usage from the Exuberant Ctags
@@ -2258,7 +2258,7 @@
* ``$prefix/lib/geany`` (``$prefix`` is usually ``/usr/local`` or
``/usr``)
-* ``~/.geany/plugins``
+* ``~/.config/geany/plugins``
Most plugins add menu items to the *Tools* menu when they are loaded.
@@ -2687,16 +2687,16 @@
To change the settings, copy a file from ``$prefix/share/geany`` to
the subdirectory filedefs in your configuration directory (usually
-``~/.geany/``).
+``~/.config/geany/``).
For example::
- % cp /usr/local/share/geany/filetypes.c /home/username/.geany/filedefs/
+ % cp /usr/local/share/geany/filetypes.c /home/username/.config/geany/filedefs/
Then you can edit the file and the changes are also
available after an update of Geany because they reside in your
configuration directory. Alternatively, you can create a file
-``~/.geany/filedefs/filetypes.X`` and add only these settings you want
+``~/.config/geany/filedefs/filetypes.X`` and add only these settings you want
to change. All missing settings will be read from the corresponding
global definition file in ``$prefix/share/geany``.
@@ -3057,12 +3057,12 @@
To override the system-wide configuration file, copy it from
``$prefix/share/geany`` to your configuration directory, usually
-``~/.geany/``. ``$prefix`` is the path where Geany is installed
+``~/.config/geany/``. ``$prefix`` is the path where Geany is installed
(commonly ``/usr/local``).
For example::
- % cp /usr/local/share/geany/filetype_extensions.conf /home/username/.geany/
+ % cp /usr/local/share/geany/filetype_extensions.conf /home/username/.config/geany/
Then edit it and remove all the lines for filetype extensions that
you do not want to override. The remaining lines can be edited after
@@ -3070,7 +3070,7 @@
should be matched for that filetype.
For example, to set the filetype extensions for Make, the
-``/home/username/.geany/filetype_extensions.conf`` file should
+``/home/username/.config/geany/filetype_extensions.conf`` file should
look like::
[Extensions]
@@ -3138,11 +3138,11 @@
Custom file templates
`````````````````````
-These are read from the ``~/.geany/templates/files`` directory (created
-the first time Geany is started). The filetype to use is detected from
-the template file's extension, if any. For example, creating a file
-``main.c`` would add a menu item which created a new document with the
-filetype set to 'C'.
+These are read from the ``~/.config/geany/templates/files`` directory
+(created the first time Geany is started). The filetype to use is
+detected from the template file's extension, if any. For example, creating
+a file ``main.c`` would add a menu item 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 restart Geany after editing a custom file
@@ -3151,7 +3151,7 @@
Filetype templates
``````````````````
-Filetype template files are read from the ``~/.geany/templates``
+Filetype template files are read from the ``~/.config/geany/templates``
directory, and are named "filetype." followed by the filetype
name, e.g. "filetype.python", "filetype.sh", etc. If you are
unsure about the filetype name extensions, they are the same as
@@ -3166,7 +3166,7 @@
^^^^^^^^^^^^^^^^^^^^^
Each template can be customized to your needs. The templates are
-stored in the ``~/.geany/templates/`` directory (see the section called
+stored in the ``~/.config/geany/templates/`` directory (see the section called
`Command line options`_ for further information about the configuration
directory). Just open the desired template with an editor (ideally,
Geany ;-) ) and edit the template to your needs. There are some
@@ -3397,7 +3397,7 @@
==================
There are some uncommon preferences that are not shown in the Preferences
-dialog. These can be set by editing ``~/.geany/geany.conf``, then
+dialog. These can be set by editing ``~/.config/geany/geany.conf``, then
restarting Geany. Search for the key name, then edit the value. Example:
``brace_match_ltgt=true``
Modified: trunk/plugins/demoplugin.c
===================================================================
--- trunk/plugins/demoplugin.c 2008-11-13 13:18:02 UTC (rev 3218)
+++ trunk/plugins/demoplugin.c 2008-11-13 14:37:47 UTC (rev 3219)
@@ -30,7 +30,7 @@
* cd plugins
* make demoplugin.so
*
- * Then copy or symlink the plugins/demoplugin.so file to ~/.geany/plugins
+ * Then copy or symlink the plugins/demoplugin.so file to ~/.config/geany/plugins
* - it will be loaded at next startup.
*/
@@ -119,7 +119,7 @@
* (e.g. using GLib's GKeyFile API)
* all plugin specific files should be created in:
* geany->app->configdir G_DIR_SEPARATOR_S plugins G_DIR_SEPARATOR_S pluginname G_DIR_SEPARATOR_S
- * e.g. this could be: ~/.geany/plugins/Demo/, please use geany->app->configdir */
+ * e.g. this could be: ~/.config/geany/plugins/Demo/, please use geany->app->configdir */
}
}
Modified: trunk/src/geany.h
===================================================================
--- trunk/src/geany.h 2008-11-13 13:18:02 UTC (rev 3218)
+++ trunk/src/geany.h 2008-11-13 14:37:47 UTC (rev 3219)
@@ -63,7 +63,7 @@
typedef struct GeanyApp
{
gboolean debug_mode; /**< @c TRUE if debug messages should be printed. */
- /** User configuration directory, usually @c ~/.geany.
+ /** User configuration directory, usually @c ~/.config/geany.
* @note Plugin configuration files should be saved as:
* @code g_build_path(G_DIR_SEPARATOR_S, geany->app->configdir, "plugins", "pluginname",
* "file.conf"); @endcode */
Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c 2008-11-13 13:18:02 UTC (rev 3218)
+++ trunk/src/main.c 2008-11-13 14:37:47 UTC (rev 3219)
@@ -36,6 +36,7 @@
#include <stdlib.h>
#include "geany.h"
+#include <glib/gstdio.h>
#ifdef HAVE_LOCALE_H
# include <locale.h>
@@ -540,22 +541,7 @@
}
else
{
-#ifdef G_OS_WIN32
- gchar *appdata;
-
- appdata = win32_get_appdata_folder();
- if (appdata != NULL)
- {
- app->configdir = g_strconcat(appdata, G_DIR_SEPARATOR_S, "Geany", NULL);
- g_free(appdata);
- }
- else
- {
- app->configdir = g_strconcat(g_get_home_dir(), G_DIR_SEPARATOR_S, "Geany", NULL);
- }
-#else
- app->configdir = g_strconcat(g_get_home_dir(), G_DIR_SEPARATOR_S, ".geany", NULL);
-#endif
+ app->configdir = g_build_filename(g_get_user_config_dir(), "geany", NULL);
}
#ifdef GEANY_DEBUG
@@ -598,6 +584,111 @@
}
+#ifdef G_OS_WIN32
+# define DIR_SEP "\\" /* on Windows we need an additional dir separator */
+#else
+# define DIR_SEP ""
+#endif
+
+static gint create_config_dir(void)
+{
+ gint saved_errno = 0;
+ gchar *conf_file = g_build_filename(app->configdir, "geany.conf", NULL);
+ gchar *filedefs_dir = g_build_filename(app->configdir, GEANY_FILEDEFS_SUBDIR, NULL);
+
+ gchar *templates_dir = g_build_filename(app->configdir, GEANY_TEMPLATES_SUBDIR, NULL);
+
+ if (! g_file_test(app->configdir, G_FILE_TEST_EXISTS))
+ {
+ /* if we are *not* using an alternate config directory, we check whether the old one
+ * in ~/.geany still exists and try to move it */
+ if (alternate_config == NULL)
+ {
+ gchar *old_dir = g_build_filename(g_get_home_dir(), ".geany", NULL);
+ /* move the old config dir if it exists */
+ if (g_file_test(old_dir, G_FILE_TEST_EXISTS))
+ {
+ if (g_rename(old_dir, app->configdir) == 0)
+ {
+ dialogs_show_msgbox(GTK_MESSAGE_INFO,
+ _("Your configuration directory has been successfully moved from \"%s\" to \"%s\"."),
+ old_dir, app->configdir);
+ g_free(old_dir);
+ return 0;
+ }
+ else
+ {
+ dialogs_show_msgbox(GTK_MESSAGE_WARNING,
+ /* for translators: the third %s in brackets is the error message which
+ * describes why moving the dir didn't work */
+ _("Your old configuration directory \"%s\" could not be moved to \"%s\" (%s). "
+ "Please move manually the directory to the new location."),
+ old_dir, app->configdir, g_strerror(errno));
+ }
+ }
+ g_free(old_dir);
+ }
+ geany_debug("creating config directory %s", app->configdir);
+ saved_errno = utils_mkdir(app->configdir, FALSE);
+ }
+
+ if (saved_errno == 0 && ! g_file_test(conf_file, G_FILE_TEST_EXISTS))
+ { /* check whether geany.conf can be written */
+ saved_errno = utils_is_file_writeable(app->configdir);
+ }
+
+ /* make subdir for filetype definitions */
+ if (saved_errno == 0)
+ {
+ gchar *filedefs_readme = g_build_filename(app->configdir,
+ GEANY_FILEDEFS_SUBDIR, "filetypes.README", NULL);
+
+ if (! g_file_test(filedefs_dir, G_FILE_TEST_EXISTS))
+ {
+ saved_errno = utils_mkdir(filedefs_dir, FALSE);
+ }
+ if (saved_errno == 0 && ! g_file_test(filedefs_readme, G_FILE_TEST_EXISTS))
+ {
+ gchar *text = g_strconcat(
+"Copy files from ", app->datadir, " to this directory to overwrite "
+"them. To use the defaults, just delete the file in this directory.\nFor more information read "
+"the documentation (in ", app->docdir, DIR_SEP "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 (saved_errno == 0)
+ {
+ gchar *templates_readme = g_build_filename(app->configdir, GEANY_TEMPLATES_SUBDIR,
+ "templates.README", NULL);
+
+ if (! g_file_test(templates_dir, G_FILE_TEST_EXISTS))
+ {
+ saved_errno = utils_mkdir(templates_dir, FALSE);
+ }
+ if (saved_errno == 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 ", app->docdir, DIR_SEP "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(templates_dir);
+ g_free(conf_file);
+
+ return saved_errno;
+}
+
+
/* Returns 0 if config dir is OK. */
static gint setup_config_dir(void)
{
@@ -608,7 +699,7 @@
app->configdir = utils_get_locale_from_utf8(app->configdir);
g_free(tmp);
- mkdir_result = utils_make_settings_dir();
+ mkdir_result = create_config_dir();
if (mkdir_result != 0)
{
if (! dialogs_show_question(
Modified: trunk/src/plugins.c
===================================================================
--- trunk/src/plugins.c 2008-11-13 13:18:02 UTC (rev 3218)
+++ trunk/src/plugins.c 2008-11-13 14:37:47 UTC (rev 3219)
@@ -778,7 +778,7 @@
gchar *path;
path = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "plugins", NULL);
- /* first load plugins in ~/.geany/plugins/, then in $prefix/lib/geany */
+ /* first load plugins in ~/.config/geany/plugins/, then in $prefix/lib/geany */
load_plugins_from_path(path);
g_free(path);
#ifdef G_OS_WIN32
Modified: trunk/src/socket.c
===================================================================
--- trunk/src/socket.c 2008-11-13 13:18:02 UTC (rev 3218)
+++ trunk/src/socket.c 2008-11-13 14:37:47 UTC (rev 3219)
@@ -342,12 +342,12 @@
g_get_tmp_dir(), G_DIR_SEPARATOR, g_random_int());
if (utils_is_file_writeable(real_path) != 0)
- { /* if real_path is not writable for us, fall back to ~/.geany/geany_socket_*_* */
+ { /* if real_path is not writable for us, fall back to ~/.config/geany/geany_socket_*_* */
/* instead of creating a symlink and print a warning */
g_warning("Socket %s could not be written, using %s as fallback.", real_path, path);
setptr(real_path, g_strdup(path));
}
- /* create a symlink in e.g. ~/.geany/geany_socket_hostname__0 to /tmp/geany_socket.499602d2 */
+ /* create a symlink in e.g. ~/.config/geany/geany_socket_hostname__0 to /tmp/geany_socket.499602d2 */
else if (symlink(real_path, path) != 0)
{
perror("symlink");
Modified: trunk/src/utils.c
===================================================================
--- trunk/src/utils.c 2008-11-13 13:18:02 UTC (rev 3218)
+++ trunk/src/utils.c 2008-11-13 14:37:47 UTC (rev 3219)
@@ -496,85 +496,6 @@
}
-#ifdef G_OS_WIN32
-# define DIR_SEP "\\" /* on Windows we need an additional dir separator */
-#else
-# define DIR_SEP ""
-#endif
-
-gint utils_make_settings_dir(void)
-{
- gint saved_errno = 0;
- gchar *conf_file = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "geany.conf", NULL);
- gchar *filedefs_dir = g_strconcat(app->configdir, G_DIR_SEPARATOR_S,
- GEANY_FILEDEFS_SUBDIR, G_DIR_SEPARATOR_S, NULL);
-
- gchar *templates_dir = g_strconcat(app->configdir, G_DIR_SEPARATOR_S,
- GEANY_TEMPLATES_SUBDIR, G_DIR_SEPARATOR_S, NULL);
-
- if (! g_file_test(app->configdir, G_FILE_TEST_EXISTS))
- {
- geany_debug("creating config directory %s", app->configdir);
- saved_errno = utils_mkdir(app->configdir, FALSE);
- }
-
- if (saved_errno == 0 && ! g_file_test(conf_file, G_FILE_TEST_EXISTS))
- { /* check whether geany.conf can be written */
- saved_errno = utils_is_file_writeable(app->configdir);
- }
-
- /* make subdir for filetype definitions */
- if (saved_errno == 0)
- {
- gchar *filedefs_readme = g_strconcat(app->configdir, G_DIR_SEPARATOR_S,
- GEANY_FILEDEFS_SUBDIR, G_DIR_SEPARATOR_S, "filetypes.README", NULL);
-
- if (! g_file_test(filedefs_dir, G_FILE_TEST_EXISTS))
- {
- saved_errno = utils_mkdir(filedefs_dir, FALSE);
- }
- if (saved_errno == 0 && ! g_file_test(filedefs_readme, G_FILE_TEST_EXISTS))
- {
- gchar *text = g_strconcat(
-"Copy files from ", app->datadir, " to this directory to overwrite "
-"them. To use the defaults, just delete the file in this directory.\nFor more information read "
-"the documentation (in ", app->docdir, DIR_SEP "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 (saved_errno == 0)
- {
- gchar *templates_readme = g_strconcat(app->configdir, G_DIR_SEPARATOR_S,
- GEANY_TEMPLATES_SUBDIR, G_DIR_SEPARATOR_S, "templates.README", NULL);
-
- if (! g_file_test(templates_dir, G_FILE_TEST_EXISTS))
- {
- saved_errno = utils_mkdir(templates_dir, FALSE);
- }
- if (saved_errno == 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 ", app->docdir, DIR_SEP "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(templates_dir);
- g_free(conf_file);
-
- return saved_errno;
-}
-
-
/* Replaces all occurrences of needle in haystack with replacement.
* New code should use utils_string_replace_all() instead.
* All strings have to be NULL-terminated and needle and replacement have to be different,
Modified: trunk/src/utils.h
===================================================================
--- trunk/src/utils.h 2008-11-13 13:18:02 UTC (rev 3218)
+++ trunk/src/utils.h 2008-11-13 14:37:47 UTC (rev 3219)
@@ -74,8 +74,6 @@
gchar *utils_get_hostname(void);
-gint utils_make_settings_dir(void);
-
gboolean utils_string_replace_all(GString *str, const gchar *needle, const gchar *replace);
gchar *utils_str_replace(gchar *haystack, const gchar *needle, const gchar *replacement);
Modified: trunk/src/win32.c
===================================================================
--- trunk/src/win32.c 2008-11-13 13:18:02 UTC (rev 3218)
+++ trunk/src/win32.c 2008-11-13 14:37:47 UTC (rev 3219)
@@ -716,33 +716,6 @@
}
-/* Used to get special Windows folder paths like %appdata%,
- * Code taken from Sylpheed, thanks */
-gchar *win32_get_appdata_folder()
-{
- gchar *folder = NULL;
- gint nfolder = CSIDL_APPDATA;
- HRESULT hr;
-
- if (G_WIN32_HAVE_WIDECHAR_API())
- {
- wchar_t path[MAX_PATH + 1];
- hr = SHGetFolderPathW(NULL, nfolder, NULL, 0, path);
- if (hr == S_OK)
- folder = g_utf16_to_utf8(path, -1, NULL, NULL, NULL);
- }
- else
- {
- gchar path[MAX_PATH + 1];
- hr = SHGetFolderPathA(NULL, nfolder, NULL, 0, path);
- if (hr == S_OK)
- folder = g_locale_to_utf8(path, -1, NULL, NULL, NULL);
- }
-
- return folder;
-}
-
-
gchar *win32_get_hostname()
{
gchar hostname[100];
Modified: trunk/src/win32.h
===================================================================
--- trunk/src/win32.h 2008-11-13 13:18:02 UTC (rev 3218)
+++ trunk/src/win32.h 2008-11-13 14:37:47 UTC (rev 3219)
@@ -50,8 +50,6 @@
void win32_init_debug_code();
-gchar *win32_get_appdata_folder();
-
gchar *win32_get_hostname();
gboolean win32_get_exit_status(GPid child_pid);
Modified: trunk/tagmanager/options.c
===================================================================
--- trunk/tagmanager/options.c 2008-11-13 13:18:02 UTC (rev 3218)
+++ trunk/tagmanager/options.c 2008-11-13 14:37:47 UTC (rev 3219)
@@ -151,7 +151,7 @@
return FALSE;
}
-/* tags_ignore is a NULL-terminated array of strings, read from ~/.geany/ignore.tags.
+/* tags_ignore is a NULL-terminated array of strings, read from ~/.config/geany/ignore.tags.
* This file contains a space or newline separated list of symbols which should be ignored
* by the C/C++ parser, see -I command line option of ctags for details. */
gchar **c_tags_ignore = 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