diff options
author | Matthias Vogelgesang <matthias.vogelgesang@kit.edu> | 2013-07-16 12:31:24 +0200 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@kit.edu> | 2013-07-16 12:31:24 +0200 |
commit | c7d87b9c4a2b220886aea7a6eb025685c57e950a (patch) | |
tree | dd84b03d18cccb072b1a5fcb383d02aede6d2a2f | |
parent | d5079e4bb5a947b66760066d4376963799307c74 (diff) | |
download | uca-c7d87b9c4a2b220886aea7a6eb025685c57e950a.tar.gz uca-c7d87b9c4a2b220886aea7a6eb025685c57e950a.tar.bz2 uca-c7d87b9c4a2b220886aea7a6eb025685c57e950a.tar.xz uca-c7d87b9c4a2b220886aea7a6eb025685c57e950a.zip |
Save acquired data as binary blob
-rw-r--r-- | bin/gui/control.c | 46 | ||||
-rw-r--r-- | bin/gui/control.glade | 10 |
2 files changed, 47 insertions, 9 deletions
diff --git a/bin/gui/control.c b/bin/gui/control.c index 76b1345..ea150f3 100644 --- a/bin/gui/control.c +++ b/bin/gui/control.c @@ -332,6 +332,50 @@ on_frame_slider_changed (GtkAdjustment *adjustment, ThreadData *data) update_current_frame (data); } +static gboolean +write_raw_file (const gchar *filename, RingBuffer *buffer) +{ + FILE *fp; + guint n_blocks; + gsize size; + + fp = fopen (filename, "wb"); + + if (fp == NULL) + return FALSE; + + n_blocks = ring_buffer_get_num_blocks (buffer); + size = ring_buffer_get_block_size (buffer); + + for (guint i = 0; i < n_blocks; i++) + fwrite (ring_buffer_get_pointer (buffer, i), size , 1, fp); + + fclose (fp); + return TRUE; +} + +static void +on_save (GtkMenuItem *item, ThreadData *data) +{ + GtkWidget *dialog; + + dialog = gtk_file_chooser_dialog_new ("Save Frames", NULL, + GTK_FILE_CHOOSER_ACTION_SAVE, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, + NULL); + + if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) { + gchar *filename; + + filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); + write_raw_file (filename, data->buffer); + g_free (filename); + } + + gtk_widget_destroy (dialog); +} + static void on_start_button_clicked (GtkWidget *widget, ThreadData *data) { @@ -612,6 +656,8 @@ create_main_window (GtkBuilder *builder, const gchar* camera_name) gtk_builder_get_object (builder, "exposure-adjustment"), "value", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); + g_signal_connect (gtk_builder_get_object (builder, "save-item"), "activate", G_CALLBACK (on_save), &td); + g_signal_connect (td.frame_slider, "value-changed", G_CALLBACK (on_frame_slider_changed), &td); g_signal_connect (td.start_button, "clicked", G_CALLBACK (on_start_button_clicked), &td); g_signal_connect (td.stop_button, "clicked", G_CALLBACK (on_stop_button_clicked), &td); diff --git a/bin/gui/control.glade b/bin/gui/control.glade index 179eb2c..2b87806 100644 --- a/bin/gui/control.glade +++ b/bin/gui/control.glade @@ -54,7 +54,7 @@ </object> </child> <child> - <object class="GtkImageMenuItem" id="imagemenuitem3"> + <object class="GtkImageMenuItem" id="save-item"> <property name="label">gtk-save</property> <property name="visible">True</property> <property name="use_underline">True</property> @@ -62,14 +62,6 @@ </object> </child> <child> - <object class="GtkImageMenuItem" id="imagemenuitem4"> - <property name="label">gtk-save-as</property> - <property name="visible">True</property> - <property name="use_underline">True</property> - <property name="use_stock">True</property> - </object> - </child> - <child> <object class="GtkSeparatorMenuItem" id="separatormenuitem1"> <property name="visible">True</property> </object> |