aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/crystfel_gui.c10
-rw-r--r--src/crystfelimageview.c37
-rw-r--r--src/crystfelimageview.h14
3 files changed, 61 insertions, 0 deletions
diff --git a/src/crystfel_gui.c b/src/crystfel_gui.c
index fbb8d0e2..c57a0a9f 100644
--- a/src/crystfel_gui.c
+++ b/src/crystfel_gui.c
@@ -39,6 +39,8 @@
#include <gdk/gdkkeysyms-compat.h>
#include <assert.h>
+#include <datatemplate.h>
+
#include "crystfelimageview.h"
@@ -197,6 +199,7 @@ int main(int argc, char *argv[])
GtkWidget *hpaned;
GtkWidget *scroll;
GtkWidget *frame;
+ DataTemplate *dtempl;
/* Long options */
const struct option longopts[] = {
@@ -252,6 +255,8 @@ int main(int argc, char *argv[])
gtk_paned_pack1(GTK_PANED(vpaned), hpaned, TRUE, TRUE);
proj.imageview = crystfel_image_view_new();
+
+ /* CrystFELImage into main area */
frame = gtk_frame_new(NULL);
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
scroll = gtk_scrolled_window_new(NULL, NULL);
@@ -261,18 +266,23 @@ int main(int argc, char *argv[])
gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(scroll));
gtk_paned_pack2(GTK_PANED(hpaned), GTK_WIDGET(frame), TRUE, TRUE);
+ /* Icon region at left */
proj.icons = gtk_drawing_area_new();
frame = gtk_frame_new(NULL);
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(proj.icons));
gtk_paned_pack1(GTK_PANED(hpaned), GTK_WIDGET(frame), FALSE, FALSE);
+ /* Report (text) region at bottom */
proj.report = gtk_text_view_new();
frame = gtk_frame_new(NULL);
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(proj.report));
gtk_paned_pack2(GTK_PANED(vpaned), GTK_WIDGET(frame), FALSE, FALSE);
+ gtk_window_set_default_size(GTK_WINDOW(proj.window), 1024, 768);
+ gtk_paned_set_position(GTK_PANED(hpaned), 172);
+ gtk_paned_set_position(GTK_PANED(vpaned), 600);
gtk_widget_show_all(proj.window);
gtk_main();
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);
+}
diff --git a/src/crystfelimageview.h b/src/crystfelimageview.h
index 9dd69d0d..829909df 100644
--- a/src/crystfelimageview.h
+++ b/src/crystfelimageview.h
@@ -33,6 +33,9 @@
#include <config.h>
#endif
+#include <image.h>
+#include <datatemplate.h>
+
#define CRYSTFEL_TYPE_IMAGE_VIEW (crystfel_image_view_get_type())
#define CRYSTFEL_IMAGE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \
@@ -67,6 +70,11 @@ struct _crystfelimageview
GtkAdjustment *vadj;
double x_scroll_pos;
double y_scroll_pos;
+
+ DataTemplate *dtempl;
+ char *filename;
+ char *event;
+ struct image *image;
};
struct _crystfelimageviewclass
@@ -80,5 +88,11 @@ typedef struct _crystfelimageviewclass CrystFELImageViewClass;
extern GType crystfel_image_view_get_type(void);
extern GtkWidget *crystfel_image_view_new(void);
+extern int crystfel_image_view_set_datatemplate(CrystFELImageView *iv,
+ DataTemplate *dtempl);
+
+extern int crystfel_image_view_set_image(CrystFELImageView *iv,
+ const char *filename,
+ const char *event);
#endif /* CRYSTFELIMAGEVIEW_H */