aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-12-07 14:48:07 +0100
committerThomas White <taw@physics.org>2020-12-07 14:48:07 +0100
commit72f857fbd0c29ba4954f5602ecc43574e581776a (patch)
tree6e6f194506e34de3079a39fa559a5be05f2f2658
parent79b8daba1e34e0c16104966314213ce1d0ad7b56 (diff)
GUI: Save and restore the selected result
-rw-r--r--src/crystfel_gui.c10
-rw-r--r--src/crystfel_gui.h3
-rw-r--r--src/gui_project.c21
3 files changed, 32 insertions, 2 deletions
diff --git a/src/crystfel_gui.c b/src/crystfel_gui.c
index 5dd5cedb..ad745d9c 100644
--- a/src/crystfel_gui.c
+++ b/src/crystfel_gui.c
@@ -129,14 +129,20 @@ static void swap_data_arrays(struct image *a, struct image *b)
}
-static void select_result(struct crystfelproject *proj,
- const char *result_name)
+void select_result(struct crystfelproject *proj,
+ const char *result_name)
{
gtk_combo_box_set_active_id(GTK_COMBO_BOX(proj->results_combo),
result_name);
}
+const char *selected_result(struct crystfelproject *proj)
+{
+ return gtk_combo_box_get_active_id(GTK_COMBO_BOX(proj->results_combo));
+}
+
+
/* Bring the image view up to date after changing the selected image */
void update_imageview(struct crystfelproject *proj)
{
diff --git a/src/crystfel_gui.h b/src/crystfel_gui.h
index d942537b..c8492499 100644
--- a/src/crystfel_gui.h
+++ b/src/crystfel_gui.h
@@ -37,6 +37,9 @@ extern void add_running_task(struct crystfelproject *proj,
void *job_priv);
extern void update_imageview(struct crystfelproject *proj);
+extern void select_result(struct crystfelproject *proj,
+ const char *result_name);
+extern const char *selected_result(struct crystfelproject *proj);
extern char *get_crystfel_path_str(void);
diff --git a/src/gui_project.c b/src/gui_project.c
index 638ee065..53874121 100644
--- a/src/gui_project.c
+++ b/src/gui_project.c
@@ -37,6 +37,7 @@
#include <assert.h>
#include "gui_project.h"
+#include "crystfel_gui.h"
#include "gui_backend_local.h"
#include "gui_backend_slurm.h"
@@ -565,6 +566,7 @@ static void read_results(FILE *fh, struct crystfelproject *proj)
char **streams = NULL;
int n_streams = 0;
char *results_name = NULL;
+ int selected = 0;
do {
@@ -576,17 +578,27 @@ static void read_results(FILE *fh, struct crystfelproject *proj)
if ( strncmp(line, "Result ", 7) == 0 ) {
if ( n_streams > 0 ) {
+ /* Add the previously-read result */
add_result(proj,
results_name,
streams,
n_streams);
+
+ if ( selected ) {
+ select_result(proj, results_name);
+ }
}
n_streams = 0;
+ selected = 0;
streams = NULL;
results_name = strdup(line+7);
}
+ if ( strncmp(line, " Selected", 11) == 0 ) {
+ selected = 1;
+ }
+
if ( strncmp(line, " Stream ", 10) == 0 ) {
streams = add_stream(strdup(line+10),
streams,
@@ -600,6 +612,10 @@ static void read_results(FILE *fh, struct crystfelproject *proj)
results_name,
streams,
n_streams);
+
+ if ( selected ) {
+ select_result(proj, results_name);
+ }
}
break;
@@ -836,6 +852,11 @@ int save_project(struct crystfelproject *proj)
fprintf(fh, " Stream %s\n",
proj->results[i].streams[j]);
}
+ if ( strcmp(selected_result(proj),
+ proj->results[i].name) == 0 )
+ {
+ fprintf(fh, " Selected\n");
+ }
}
fprintf(fh, "-----\n");