aboutsummaryrefslogtreecommitdiff
path: root/clients/ui.c
diff options
context:
space:
mode:
authorAnders Betts <anders.betts@gmail.com>2026-09-21 14:03:36 +0200
committerAnders Betts <anders.betts@gmail.com>2026-09-21 14:03:44 +0200
commit776dbdf6f6f12289c874fd9d1eada379f1b02a0b (patch)
tree8bdf34d311c5a2f02956b1bb94dc2b502eb738fa /clients/ui.c
parentb0189d7d6b58a4761daebe761afeaf4a68a9296c (diff)
downloadbokf-776dbdf6f6f12289c874fd9d1eada379f1b02a0b.tar.gz
bokf-776dbdf6f6f12289c874fd9d1eada379f1b02a0b.zip
tui: flat menu, System hub, remembered attachment directoryv0.1.57
Diffstat (limited to 'clients/ui.c')
-rw-r--r--clients/ui.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/clients/ui.c b/clients/ui.c
index a95ce44..ca6906f 100644
--- a/clients/ui.c
+++ b/clients/ui.c
@@ -217,17 +217,12 @@ void app_refresh_context(struct app *a)
free(resp);
snprintf(a->default_series, sizeof a->default_series, "%s", "A");
- a->attachment_dir[0] = '\0';
resp = client_rpc(&a->conn, "settings.get", a->session, a->org, "{}");
if (resp && client_ok(resp)) {
char *ser = jstr_dup(resp, "result.default_series");
if (ser && *ser)
snprintf(a->default_series, sizeof a->default_series, "%s", ser);
free(ser);
- char *dir = jstr_dup(resp, "result.attachment_dir");
- if (dir && *dir)
- snprintf(a->attachment_dir, sizeof a->attachment_dir, "%s", dir);
- free(dir);
}
free(resp);
@@ -332,14 +327,18 @@ static void expand_path(const char *in, char *out, size_t n)
Returns a malloc'd path, or NULL on cancel. */
char *file_browser(struct app *a, const char *start_dir)
{
- (void)a;
if (g_quit)
return NULL;
char dir[1024];
- const char *start = (start_dir && *start_dir) ? start_dir : getenv("HOME");
+ const char *home = getenv("HOME");
+ const char *start = (start_dir && *start_dir) ? start_dir : home;
expand_path(start, dir, sizeof dir);
- if (!dir[0])
- snprintf(dir, sizeof dir, ".");
+ struct stat sb;
+ if (!dir[0] || stat(dir, &sb) != 0 || !S_ISDIR(sb.st_mode)) {
+ expand_path(home && *home ? home : ".", dir, sizeof dir);
+ if (!dir[0])
+ snprintf(dir, sizeof dir, ".");
+ }
for (;;) {
DIR *d = opendir(dir);
if (!d) {
@@ -408,6 +407,8 @@ char *file_browser(struct app *a, const char *start_dir)
continue;
}
free(ents);
+ snprintf(a->attachment_dir, sizeof a->attachment_dir, "%.255s", dir);
+ config_save(a);
return xstrdup(full);
}
}