aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2021-02-25 16:47:17 +0100
committerThomas White <taw@physics.org>2021-02-25 16:47:17 +0100
commita885bcbb659b361ac305d706410e3ed415566f22 (patch)
treeec38ad310ca96b02f23beead9b986c341b9df7e5
parent32fa3814ff7f70acddf0d9de2e1184bd10affaec (diff)
GUI: Improve image info bar
(...and work through horrific circular logic during creation)
-rw-r--r--src/crystfel_gui.c53
-rw-r--r--src/gui_project.c1
2 files changed, 32 insertions, 22 deletions
diff --git a/src/crystfel_gui.c b/src/crystfel_gui.c
index d50d9942..615d13ad 100644
--- a/src/crystfel_gui.c
+++ b/src/crystfel_gui.c
@@ -191,13 +191,39 @@ void update_imageview(struct crystfelproject *proj)
struct image *image;
const gchar *results_name;
- if ( proj->n_frames == 0 ) return;
+ if ( proj->image_info == NULL ) return;
+
+ if ( (proj->dtempl == NULL)
+ || (proj->filenames == NULL)
+ || (proj->events == NULL)
+ || (proj->n_frames == 0) )
+ {
+ gtk_label_set_text(GTK_LABEL(proj->image_info),
+ "Ready to load images");
+ return;
+ }
image = image_read(proj->dtempl,
proj->filenames[proj->cur_frame],
proj->events[proj->cur_frame],
0, 0);
+ if ( proj->events[proj->cur_frame] != NULL ) {
+ ev_str = proj->events[proj->cur_frame];
+ ev_sep = " ";
+ } else {
+ ev_str = "";
+ ev_sep = "";
+ }
+ snprintf(tmp, 1023, "%s%s%s (frame %i of %i%s)",
+ proj->filenames[proj->cur_frame],
+ ev_sep,
+ ev_str,
+ proj->cur_frame+1,
+ proj->n_frames,
+ (image==NULL)?", load error":"");
+ gtk_label_set_text(GTK_LABEL(proj->image_info), tmp);
+
if ( image == NULL ) {
ERROR("Failed to load image\n");
return;
@@ -209,21 +235,6 @@ void update_imageview(struct crystfelproject *proj)
image_free(proj->cur_image);
proj->cur_image = image;
- if ( proj->cur_image->ev != NULL ) {
- ev_str = proj->cur_image->ev;
- ev_sep = " ";
- } else {
- ev_str = "";
- ev_sep = "";
- }
- snprintf(tmp, 1023, "%s%s%s (frame %i of %i)",
- proj->cur_image->filename,
- ev_sep,
- ev_str,
- proj->cur_frame+1,
- proj->n_frames);
- gtk_label_set_text(GTK_LABEL(proj->image_info), tmp);
-
/* Look up results, if applicable */
results_name = gtk_combo_box_get_active_id(GTK_COMBO_BOX(proj->results_combo));
if ( strcmp(results_name, "crystfel-gui-internal") == 0 ) {
@@ -670,6 +681,8 @@ int main(int argc, char *argv[])
default_project(&proj);
+ proj.image_info = NULL;
+
proj.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(proj.window), "CrystFEL");
gtk_window_set_default_icon_name("crystfel");
@@ -687,12 +700,6 @@ int main(int argc, char *argv[])
hpaned = gtk_paned_new(GTK_ORIENTATION_HORIZONTAL);
gtk_paned_pack1(GTK_PANED(vpaned), hpaned, TRUE, TRUE);
- proj.imageview = crystfel_image_view_new();
-
- proj.cur_frame = 0;
- update_imageview(&proj);
- crystfel_image_view_reset_zoom(CRYSTFEL_IMAGE_VIEW(proj.imageview));
-
toolbar = gtk_hbox_new(FALSE, 0.0);
/* First */
@@ -761,6 +768,8 @@ int main(int argc, char *argv[])
FALSE, FALSE, 2.0);
/* Main area stuff (toolbar and imageview) at right */
+ proj.imageview = crystfel_image_view_new();
+ proj.cur_frame = 0;
frame = gtk_frame_new(NULL);
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
scroll = gtk_scrolled_window_new(NULL, NULL);
diff --git a/src/gui_project.c b/src/gui_project.c
index 3c4a5c52..12377d83 100644
--- a/src/gui_project.c
+++ b/src/gui_project.c
@@ -563,6 +563,7 @@ void clear_project_files(struct crystfelproject *proj)
proj->max_frames = 0;
proj->filenames = NULL;
proj->events = NULL;
+ proj->cur_frame = 0;
}