From bcf80f7ddb66ee213dc493904e1b743e99d90082 Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Thu, 18 Oct 2012 16:07:13 +0200 Subject: Launch download dialog to ease waiting --- tools/gui/control.c | 34 ++++++++++++++++++++-- tools/gui/control.glade | 77 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+), 3 deletions(-) (limited to 'tools/gui') diff --git a/tools/gui/control.c b/tools/gui/control.c index 07b7937..0b59837 100644 --- a/tools/gui/control.c +++ b/tools/gui/control.c @@ -44,6 +44,11 @@ typedef struct { GtkWidget *download_button; GtkComboBox *zoom_box; + GtkDialog *download_dialog; + GtkProgressBar *download_progressbar; + GtkWidget *download_close_button; + GtkAdjustment *download_adjustment; + GtkWidget *histogram_view; GtkToggleButton *histogram_button; GtkAdjustment *frame_slider; @@ -290,17 +295,21 @@ on_record_button_clicked (GtkWidget *widget, ThreadData *data) } } -static void -on_download_button_clicked (GtkWidget *widget, ThreadData *data) +static gpointer +download_frames (ThreadData *data) { gpointer buffer; + guint n_frames; GError *error = NULL; + g_object_get (data->camera, "recorded-frames", &n_frames, NULL); + g_print ("recorded %i frames\n", n_frames); + uca_camera_start_readout (data->camera, &error); if (error != NULL) { g_printerr ("Failed to start read out of camera memory: %s\n", error->message); - return; + return NULL; } ring_buffer_reset (data->buffer); @@ -327,6 +336,22 @@ on_download_button_clicked (GtkWidget *widget, ThreadData *data) if (error != NULL) g_printerr ("Failed to stop reading out of camera memory: %s\n", error->message); + + return NULL; +} + +static void +on_download_button_clicked (GtkWidget *widget, ThreadData *data) +{ + GError *error = NULL; + + if (!g_thread_create ((GThreadFunc) download_frames, data, FALSE, &error)) { + g_printerr ("Failed to create thread: %s\n", error->message); + } + + gtk_window_set_modal (GTK_WINDOW (data->download_dialog), TRUE); + gtk_dialog_run (data->download_dialog); + gtk_window_set_modal (GTK_WINDOW (data->download_dialog), FALSE); } static void @@ -408,6 +433,9 @@ create_main_window (GtkBuilder *builder, const gchar* camera_name) td.histogram_button = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "histogram-checkbutton")); td.frame_slider = GTK_ADJUSTMENT (gtk_builder_get_object (builder, "frames-adjustment")); + td.download_dialog = GTK_DIALOG (gtk_builder_get_object (builder, "download-dialog")); + td.download_adjustment = GTK_ADJUSTMENT (gtk_builder_get_object (builder, "download-adjustment")); + /* Set initial data */ pixel_size = bits_per_sample > 8 ? 2 : 1; image_size = pixel_size * width * height; diff --git a/tools/gui/control.glade b/tools/gui/control.glade index 2d2aaac..eec9dde 100644 --- a/tools/gui/control.glade +++ b/tools/gui/control.glade @@ -555,4 +555,81 @@ 1 10 + + 5 + normal + + + True + 2 + + + True + 10 + 6 + + + True + 0 + Downloading Frames … + + + False + False + 0 + + + + + True + download-adjustment + + + False + 1 + + + + + 1 + + + + + True + end + + + gtk-close + True + True + True + True + + + False + False + 0 + + + + + False + False + end + 0 + + + + + + download-close-button + + + + 100 + 1 + 10 + 10 + -- cgit v1.2.3