summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2012-10-18 16:27:45 +0200
committerMatthias Vogelgesang <matthias.vogelgesang@gmail.com>2012-10-18 16:28:39 +0200
commita7a48c55df8dc3e34a2ce50b18b70c0cd101766d (patch)
treecc3179f6c13aa8cb486b7a1bfbad05b5a8abdcca
parentbcf80f7ddb66ee213dc493904e1b743e99d90082 (diff)
downloadlibuca-a7a48c55df8dc3e34a2ce50b18b70c0cd101766d.tar.gz
libuca-a7a48c55df8dc3e34a2ce50b18b70c0cd101766d.tar.bz2
libuca-a7a48c55df8dc3e34a2ce50b18b70c0cd101766d.tar.xz
libuca-a7a48c55df8dc3e34a2ce50b18b70c0cd101766d.zip
Show download progress
-rw-r--r--plugins/pco/uca-pco-camera.c4
-rw-r--r--tools/gui/control.c20
2 files changed, 23 insertions, 1 deletions
diff --git a/plugins/pco/uca-pco-camera.c b/plugins/pco/uca-pco-camera.c
index d34e0f4..5d08acf 100644
--- a/plugins/pco/uca-pco-camera.c
+++ b/plugins/pco/uca-pco-camera.c
@@ -506,7 +506,11 @@ uca_pco_camera_stop_recording(UcaCamera *camera, GError **error)
if (err == FG_INVALID_PARAMETER)
g_warning(" Unable to unblock all\n");
+ err = pco_get_active_segment(priv->pco, &priv->active_segment);
+ HANDLE_PCO_ERROR(err);
+
err = pco_get_num_images(priv->pco, priv->active_segment, &priv->num_recorded_images);
+ g_print ("images: %i\n", priv->num_recorded_images);
HANDLE_PCO_ERROR(err);
}
diff --git a/tools/gui/control.c b/tools/gui/control.c
index 0b59837..877473e 100644
--- a/tools/gui/control.c
+++ b/tools/gui/control.c
@@ -36,6 +36,7 @@ typedef enum {
typedef struct {
UcaCamera *camera;
+ GtkWidget *main_window;
GdkPixbuf *pixbuf;
GtkWidget *image;
GtkWidget *start_button;
@@ -300,10 +301,14 @@ download_frames (ThreadData *data)
{
gpointer buffer;
guint n_frames;
+ guint current_frame = 1;
GError *error = NULL;
g_object_get (data->camera, "recorded-frames", &n_frames, NULL);
- g_print ("recorded %i frames\n", n_frames);
+ gdk_threads_enter ();
+ gtk_widget_set_sensitive (data->download_close_button, FALSE);
+ gtk_adjustment_set_upper (data->download_adjustment, n_frames);
+ gdk_threads_leave ();
uca_camera_start_readout (data->camera, &error);
@@ -318,6 +323,9 @@ download_frames (ThreadData *data)
buffer = ring_buffer_get_current_pointer (data->buffer);
uca_camera_grab (data->camera, &buffer, &error);
ring_buffer_proceed (data->buffer);
+ gdk_threads_enter ();
+ gtk_adjustment_set_value (data->download_adjustment, current_frame++);
+ gdk_threads_leave ();
}
if (error->code == UCA_CAMERA_ERROR_END_OF_STREAM) {
@@ -337,6 +345,10 @@ download_frames (ThreadData *data)
if (error != NULL)
g_printerr ("Failed to stop reading out of camera memory: %s\n", error->message);
+ gdk_threads_enter ();
+ gtk_widget_set_sensitive (data->download_close_button, TRUE);
+ gdk_threads_leave ();
+
return NULL;
}
@@ -349,9 +361,13 @@ on_download_button_clicked (GtkWidget *widget, ThreadData *data)
g_printerr ("Failed to create thread: %s\n", error->message);
}
+ gtk_widget_set_sensitive (data->main_window, FALSE);
gtk_window_set_modal (GTK_WINDOW (data->download_dialog), TRUE);
gtk_dialog_run (data->download_dialog);
+ gtk_widget_hide (GTK_WIDGET (data->download_dialog));
gtk_window_set_modal (GTK_WINDOW (data->download_dialog), FALSE);
+ gtk_widget_set_sensitive (data->main_window, TRUE);
+ gtk_window_set_modal (GTK_WINDOW (data->download_dialog), TRUE);
}
static void
@@ -435,6 +451,7 @@ create_main_window (GtkBuilder *builder, const gchar* camera_name)
td.download_dialog = GTK_DIALOG (gtk_builder_get_object (builder, "download-dialog"));
td.download_adjustment = GTK_ADJUSTMENT (gtk_builder_get_object (builder, "download-adjustment"));
+ td.download_close_button = GTK_WIDGET (gtk_builder_get_object (builder, "download-close-button"));
/* Set initial data */
pixel_size = bits_per_sample > 8 ? 2 : 1;
@@ -465,6 +482,7 @@ create_main_window (GtkBuilder *builder, const gchar* camera_name)
td.zoom_factor = 1.0;
td.histogram_view = histogram_view;
td.data_in_camram = FALSE;
+ td.main_window = window;
update_pixbuf_dimensions (&td);
set_tool_button_state (&td);