diff options
author | Thomas White <taw@physics.org> | 2020-02-21 17:05:56 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2020-07-29 18:39:50 +0200 |
commit | ca3b3162f037506ae224e0f8bb7c6f669a43d1b1 (patch) | |
tree | f34a9c5e9d80541c396ff2ae224989e8e0b5eef5 /src/crystfelimageview.c | |
parent | e7d338d5e697526df8843f45c8044533212bbb38 (diff) |
GUI image loading stuff
Diffstat (limited to 'src/crystfelimageview.c')
-rw-r--r-- | src/crystfelimageview.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/crystfelimageview.c b/src/crystfelimageview.c index 9d3589d0..d675e7bb 100644 --- a/src/crystfelimageview.c +++ b/src/crystfelimageview.c @@ -37,6 +37,8 @@ #include <gtk/gtk.h> #include <glib-object.h> +#include <utils.h> + #include "crystfelimageview.h" @@ -266,6 +268,8 @@ GtkWidget *crystfel_image_view_new() iv->h = 100; iv->x_scroll_pos = 0; iv->y_scroll_pos = 0; + iv->filename = NULL; + iv->event = NULL; gtk_widget_set_size_request(GTK_WIDGET(iv), iv->w, iv->h); @@ -296,3 +300,36 @@ GtkWidget *crystfel_image_view_new() return GTK_WIDGET(iv); } + + +static int reload_image(CrystFELImageView *iv) +{ + if ( iv->dtempl == NULL ) return 0; + if ( iv->filename == NULL ) return 0; + image_free(iv->image); + iv->image = image_read(iv->dtempl, iv->filename, iv->event); + printf("loaded %p\n", iv->image); + return 0; +} + + +int crystfel_image_view_set_datatemplate(CrystFELImageView *iv, + DataTemplate *dtempl) +{ + iv->dtempl = dtempl; + printf("have %p\n", dtempl); + return reload_image(iv); +} + + +int crystfel_image_view_set_image(CrystFELImageView *iv, + const char *filename, + const char *event) +{ + free(iv->filename); + free(iv->event); + iv->filename = safe_strdup(filename); + iv->event = safe_strdup(event); + printf("have '%s'\n", iv->filename); + return reload_image(iv); +} |