From 1bec7772106d04fe1c9e28b1f6e279e7679ba377 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Sat, 23 Apr 2016 20:20:40 -0700 Subject: [PATCH] image-source: Set starting browse path to last used file dir Set the starting browse path to the directory of the current file used for the source. --- plugins/image-source/image-source.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/plugins/image-source/image-source.c b/plugins/image-source/image-source.c index ee901fd31..f47d1dc24 100644 --- a/plugins/image-source/image-source.c +++ b/plugins/image-source/image-source.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #define blog(log_level, format, ...) \ @@ -197,17 +198,29 @@ static const char *image_filter = "JPEG Files (*.jpeg *.jpg);;" "GIF Files (*.gif)"; -static obs_properties_t *image_source_properties(void *unused) +static obs_properties_t *image_source_properties(void *data) { - UNUSED_PARAMETER(unused); + struct image_source *s = data; + struct dstr path = {0}; obs_properties_t *props = obs_properties_create(); + if (s && s->file && *s->file) { + const char *slash; + + dstr_copy(&path, s->file); + dstr_replace(&path, "\\", "/"); + slash = strrchr(path.array, '/'); + if (slash) + dstr_resize(&path, slash - path.array + 1); + } + obs_properties_add_path(props, "file", obs_module_text("File"), - OBS_PATH_FILE, image_filter, NULL); + OBS_PATH_FILE, image_filter, path.array); obs_properties_add_bool(props, "unload", obs_module_text("UnloadWhenNotShowing")); + dstr_free(&path); return props; }