aboutsummaryrefslogtreecommitdiff
path: root/src/gui_import.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2021-04-30 16:19:59 +0200
committerThomas White <taw@physics.org>2021-04-30 16:19:59 +0200
commit5ae8201dbefdbd69741a2009704443655f98045a (patch)
tree7073bff0dc0786f1200fa6b174b1363d89c50522 /src/gui_import.c
parent7d4eff3ab922d7f4929a244b373f77e0a795745b (diff)
GUI: Take optional stream on command line
Closes: https://gitlab.desy.de/thomas.white/crystfel/-/issues/12
Diffstat (limited to 'src/gui_import.c')
-rw-r--r--src/gui_import.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/gui_import.c b/src/gui_import.c
index 11d5f7f2..4328cacf 100644
--- a/src/gui_import.c
+++ b/src/gui_import.c
@@ -243,32 +243,28 @@ static void import_via_search(struct finddata_ctx *ctx)
}
-static void import_stream(struct finddata_ctx *ctx)
+/* stream_filename will be adopted */
+int load_stream(struct crystfelproject *proj, char *stream_filename)
{
- struct crystfelproject *proj = ctx->proj;
Stream *st;
- char *stream_filename;
DataTemplate *dtempl;
const char *geom_str;
char **streams;
- stream_filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(ctx->stream_chooser));
- if ( stream_filename == NULL ) return;
-
st = stream_open_for_read(stream_filename);
- if ( st == NULL ) return;
+ if ( st == NULL ) return 1;
geom_str = stream_geometry_file(st);
if ( geom_str == NULL ) {
ERROR("No geometry file\n");
stream_close(st);
- return;
+ return 1;
}
dtempl = data_template_new_from_string(geom_str);
if ( dtempl == NULL ) {
stream_close(st);
- return;
+ return 1;
}
/* If we do not yet have a DataTemplate, the one from the file
@@ -291,6 +287,19 @@ static void import_stream(struct finddata_ctx *ctx)
add_indexing_result(proj, result_name, streams, 1);
select_result(proj, result_name);
}
+
+ return 0;
+}
+
+
+static void import_stream(struct finddata_ctx *ctx)
+{
+ char *stream_filename;
+
+ stream_filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(ctx->stream_chooser));
+ if ( stream_filename == NULL ) return;
+
+ load_stream(ctx->proj, stream_filename);
}