diff options
author | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2012-10-12 16:47:51 +0200 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2012-10-12 16:47:51 +0200 |
commit | 6d4826f326f981a207ed6d64d5c481d0b1bddd00 (patch) | |
tree | 83b8a6aee91107d8763bc6f76eb36ca589654a0f /tools | |
parent | be1bfae1ecef5032e667174da4b4ad016d47887b (diff) | |
download | libuca-6d4826f326f981a207ed6d64d5c481d0b1bddd00.tar.gz libuca-6d4826f326f981a207ed6d64d5c481d0b1bddd00.tar.bz2 libuca-6d4826f326f981a207ed6d64d5c481d0b1bddd00.tar.xz libuca-6d4826f326f981a207ed6d64d5c481d0b1bddd00.zip |
Fix button states
Diffstat (limited to 'tools')
-rw-r--r-- | tools/gui/control.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/tools/gui/control.c b/tools/gui/control.c index 5e8860f..e01bc7d 100644 --- a/tools/gui/control.c +++ b/tools/gui/control.c @@ -191,7 +191,7 @@ on_frame_slider_changed (GtkAdjustment *adjustment, gpointer user_data) if (data->state == IDLE) { gpointer buffer; gint index; - + index = (gint) gtk_adjustment_get_value (adjustment); buffer = ring_buffer_get_pointer (data->buffer, index); convert_grayscale_to_rgb (data, buffer); @@ -205,7 +205,6 @@ on_start_button_clicked (GtkWidget *widget, gpointer args) ThreadData *data = (ThreadData *) args; GError *error = NULL; - set_tool_button_state (data); uca_camera_start_recording (data->camera, &error); if (error != NULL) { @@ -213,12 +212,14 @@ on_start_button_clicked (GtkWidget *widget, gpointer args) return; } + data->state = RUNNING; + set_tool_button_state (data); + if (!g_thread_create (preview_frames, data, FALSE, &error)) { g_printerr ("Failed to create thread: %s\n", error->message); - return; + data->state = IDLE; + set_tool_button_state (data); } - - data->state = RUNNING; } static void @@ -242,14 +243,21 @@ on_record_button_clicked (GtkWidget *widget, gpointer args) ThreadData *data = (ThreadData *) args; GError *error = NULL; + uca_camera_start_recording (data->camera, &error); + + if (error != NULL) { + g_printerr ("Failed to start recording: %s\n", error->message); + } + data->timestamp = (int) time (0); data->state = RECORDING; - set_tool_button_state (data); - uca_camera_start_recording (data->camera, &error); - if (!g_thread_create (record_frames, data, FALSE, &error)) + if (!g_thread_create (record_frames, data, FALSE, &error)) { g_printerr ("Failed to create thread: %s\n", error->message); + data->state = IDLE; + set_tool_button_state (data); + } } static void @@ -434,7 +442,7 @@ main (int argc, char *argv[]) g_option_context_add_main_entries (context, entries, NULL); g_option_context_add_group (context, gtk_get_option_group (TRUE)); if (!g_option_context_parse (context, &argc, &argv, &error)) { - g_print ("Option parsing failed: %s\n", error->message); + g_print ("Option parsing failed: %s\n", error->message); return 1; } |