From d7caf0f9c03537f6b31b32dfc5876580a4e37275 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrico=20Tr=C3=B6ger?= Date: Thu, 13 Nov 2008 14:37:47 +0000 Subject: [PATCH] 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. git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@3219 ea778897-0a13-0410-b9d1-a72fbfd435f5 --- ChangeLog | 16 ++++++ HACKING | 2 +- doc/geany.1.in | 2 +- doc/geany.html | 48 ++++++++--------- doc/geany.txt | 46 ++++++++-------- plugins/demoplugin.c | 4 +- src/geany.h | 2 +- src/main.c | 125 +++++++++++++++++++++++++++++++++++++------ src/plugins.c | 2 +- src/socket.c | 4 +- src/utils.c | 79 --------------------------- src/utils.h | 2 - src/win32.c | 27 ---------- src/win32.h | 2 - tagmanager/options.c | 2 +- 15 files changed, 180 insertions(+), 183 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6dddb0e6..bc90c347 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2008-11-13 Enrico Tröger + + * 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 * src/editor.c: diff --git a/HACKING b/HACKING index 9eee81d4..ca4ca9d7 100644 --- a/HACKING +++ b/HACKING @@ -295,7 +295,7 @@ to the s_tag_type_names strings used in foo.c for FooKinds. 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. diff --git a/doc/geany.1.in b/doc/geany.1.in index d6eb05e9..e4a4535d 100644 --- a/doc/geany.1.in +++ b/doc/geany.1.in @@ -30,7 +30,7 @@ place the cursor in line 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 diff --git a/doc/geany.html b/doc/geany.html index 8fd4326f..4e16aac7 100644 --- a/doc/geany.html +++ b/doc/geany.html @@ -554,8 +554,8 @@ file foo.bar and place the cursor in line 7. -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 @@ -1084,15 +1084,15 @@ called snippets.conf installed (commonly /usr/local). It is not recommended to edit the 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.

The file snippets.conf may contain several sections for each @@ -1410,7 +1410,7 @@ matching is not supported by the Find and Replace dialogs.

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 (but is incompatible with ctags). You use Geany to generate global @@ -1433,7 +1433,7 @@ the library.

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 @@ -1508,7 +1508,7 @@ upgrading Geany.

Ignore tags

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 manual page:

@@ -2388,7 +2388,7 @@ the following directories:

  • $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.

Since Geany 0.13, there is a Plugin Manager to let you choose which plugins @@ -3068,15 +3068,15 @@ to edit the system-wide files, because they will be overridden when Geany is updated.

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.

@@ -3386,18 +3386,18 @@ see Filetype def filetype using the filetype_extensions.conf file.

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 the = sign, using a semi-colon separated list of patterns which 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]
@@ -3451,18 +3451,18 @@ be placed anywhere, but is usually on the first line of the file,
 followed by a blank line.

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 template.

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 @@ -3475,7 +3475,7 @@ the New command is used without a filetype. This is empty by default.

Customizing templates

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 @@ -3784,7 +3784,7 @@ position without having to drag it.

Hidden preferences

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
@@ -4412,7 +4412,7 @@ USE OR PERFORMANCE OF THIS SOFTWARE.

diff --git a/doc/geany.txt b/doc/geany.txt index 2e5f85c6..ab81937f 100644 --- a/doc/geany.txt +++ b/doc/geany.txt @@ -201,8 +201,8 @@ Short option Long option Function *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 @@ installed (commonly ``/usr/local``). It is not recommended to edit the 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 @@ Tags 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 @@ the library. 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 @@ Ignore tags 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 @@ the following directories: * ``$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 @@ Geany is updated. 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 @@ filetype using the ``filetype_extensions.conf`` file. 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 @@ the ``=`` sign, using a semi-colon separated list of patterns which 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 @@ followed by a blank line. 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 @@ template. 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 @@ Customizing templates ^^^^^^^^^^^^^^^^^^^^^ 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 @@ Hidden preferences ================== 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`` diff --git a/plugins/demoplugin.c b/plugins/demoplugin.c index c2d5b647..7139ec48 100644 --- a/plugins/demoplugin.c +++ b/plugins/demoplugin.c @@ -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 @@ on_configure_response(GtkDialog *dialog, gint response, gpointer user_data) * (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 */ } } diff --git a/src/geany.h b/src/geany.h index 01cd3506..d3a086fc 100644 --- a/src/geany.h +++ b/src/geany.h @@ -63,7 +63,7 @@ typedef struct GeanyFiletype GeanyFiletype; 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 */ diff --git a/src/main.c b/src/main.c index cbf7e9ca..679b9b50 100644 --- a/src/main.c +++ b/src/main.c @@ -36,6 +36,7 @@ #include #include "geany.h" +#include #ifdef HAVE_LOCALE_H # include @@ -540,22 +541,7 @@ static void parse_command_line_options(gint *argc, gchar ***argv) } 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 @@ static void parse_command_line_options(gint *argc, gchar ***argv) } +#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 @@ static gint setup_config_dir(void) 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( diff --git a/src/plugins.c b/src/plugins.c index f48b769f..b51a3ae6 100644 --- a/src/plugins.c +++ b/src/plugins.c @@ -778,7 +778,7 @@ static void load_all_plugins(void) 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 diff --git a/src/socket.c b/src/socket.c index d7f6a340..7fa7235f 100644 --- a/src/socket.c +++ b/src/socket.c @@ -342,12 +342,12 @@ static gint socket_fd_open_unix(const gchar *path) 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"); diff --git a/src/utils.c b/src/utils.c index d57a64ea..71675ca3 100644 --- a/src/utils.c +++ b/src/utils.c @@ -496,85 +496,6 @@ gint utils_is_file_writeable(const gchar *locale_filename) } -#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, diff --git a/src/utils.h b/src/utils.h index 61036745..d33af164 100644 --- a/src/utils.h +++ b/src/utils.h @@ -74,8 +74,6 @@ gchar utils_brace_opposite(gchar ch); 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); diff --git a/src/win32.c b/src/win32.c index c77190fc..713ffcea 100644 --- a/src/win32.c +++ b/src/win32.c @@ -716,33 +716,6 @@ void win32_init_debug_code() } -/* 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]; diff --git a/src/win32.h b/src/win32.h index a300f4ae..cafff908 100644 --- a/src/win32.h +++ b/src/win32.h @@ -50,8 +50,6 @@ gint win32_check_write_permission(const gchar *dir); void win32_init_debug_code(); -gchar *win32_get_appdata_folder(); - gchar *win32_get_hostname(); gboolean win32_get_exit_status(GPid child_pid); diff --git a/tagmanager/options.c b/tagmanager/options.c index 3d71c7ce..a2ea39c4 100644 --- a/tagmanager/options.c +++ b/tagmanager/options.c @@ -151,7 +151,7 @@ extern boolean isIncludeFile (const char *const fileName) 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;