diff options
| author | Simon Tatham <anakin@pobox.com> | 2023-04-23 10:58:53 +0100 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2023-04-23 13:26:36 +0100 |
| commit | 6c66e2b2de63b6a8159835516ee229bda3253bc2 (patch) | |
| tree | 54983273fbc6f0bbc72f790e4d5f97c73c108562 /misc.c | |
| parent | 4752c7a2d9bd83d41d418b31b931a9bb9af219fa (diff) | |
| download | puzzles-6c66e2b2de63b6a8159835516ee229bda3253bc2.zip puzzles-6c66e2b2de63b6a8159835516ee229bda3253bc2.tar.gz puzzles-6c66e2b2de63b6a8159835516ee229bda3253bc2.tar.bz2 puzzles-6c66e2b2de63b6a8159835516ee229bda3253bc2.tar.xz | |
Support preferences in the GTK frontend.
Finally, some user-visible behaviour changes as a payoff for all that
preparation work! In this commit, the GTK puzzles get a 'Preferences'
option in the menu, which presents a dialog box to configure the
preference settings.
On closing that dialog box, the puzzle preferences are enacted
immediately, and also saved to a configuration file where the next run
of the same puzzle will reload them.
The default file location is ~/.config/sgt-puzzles/<puzzlename>.conf,
although you can override the .config dir via $XDG_CONFIG_HOME or
override the Puzzles-specific subdir with $SGT_PUZZLES_DIR.
This is the first commit that actually exposes all the new preferences
work to the user, and therefore, I've also added documentation of all
the current preference options.
Diffstat (limited to 'misc.c')
| -rw-r--r-- | misc.c | 31 |
1 files changed, 31 insertions, 0 deletions
@@ -3,6 +3,7 @@ */ #include <assert.h> +#include <ctype.h> #ifdef NO_TGMATH_H # include <math.h> #else @@ -500,4 +501,34 @@ char *button2label(int button) return NULL; } +char *make_prefs_path(const char *dir, const char *sep, + const game *game, const char *suffix) +{ + size_t dirlen = strlen(dir); + size_t seplen = strlen(sep); + size_t gamelen = strlen(game->name); + size_t suffixlen = strlen(suffix); + char *path, *p; + const char *q; + + path = snewn(dirlen + seplen + gamelen + suffixlen + 1, char); + p = path; + + memcpy(p, dir, dirlen); + p += dirlen; + + memcpy(p, sep, seplen); + p += seplen; + + for (q = game->name; *q; q++) + if (*q != ' ') + *p++ = tolower((unsigned char)*q); + + memcpy(p, suffix, suffixlen); + p += suffixlen; + + *p = '\0'; + return path; +} + /* vim: set shiftwidth=4 tabstop=8: */ |