diff options
-rw-r--r-- | tools/gui/control.c | 99 | ||||
-rw-r--r-- | tools/gui/control.glade | 20 |
2 files changed, 59 insertions, 60 deletions
diff --git a/tools/gui/control.c b/tools/gui/control.c index 89e932a..f7d3618 100644 --- a/tools/gui/control.c +++ b/tools/gui/control.c @@ -31,21 +31,22 @@ typedef struct { - gboolean running; - gboolean store; - - guchar *buffer, *pixels; - GdkPixbuf *pixbuf; - GtkWidget *image; - UcaCamera *camera; - - GtkStatusbar *statusbar; - guint statusbar_context_id; - - int timestamp; - int width; - int height; - int pixel_size; + UcaCamera *camera; + GdkPixbuf *pixbuf; + GtkWidget *image; + GtkWidget *start_button; + GtkWidget *stop_button; + GtkWidget *record_button; + + guchar *buffer; + guchar *pixels; + gboolean running; + gboolean store; + + int timestamp; + int width; + int height; + int pixel_size; } ThreadData; enum { @@ -145,16 +146,22 @@ on_destroy (GtkWidget *widget, gpointer data) } static void -on_toolbutton_run_clicked (GtkWidget *widget, gpointer args) +set_tool_button_state (ThreadData *data) { - ThreadData *data = (ThreadData *) args; - - if (data->running) - return; + gtk_widget_set_sensitive (data->start_button, !data->running); + gtk_widget_set_sensitive (data->stop_button, data->running); + gtk_widget_set_sensitive (data->record_button, !data->running); +} +static void +on_start_button_clicked (GtkWidget *widget, gpointer args) +{ + ThreadData *data = (ThreadData *) args; GError *error = NULL; + data->running = TRUE; + set_tool_button_state (data); uca_camera_start_recording (data->camera, &error); if (error != NULL) { @@ -169,12 +176,15 @@ on_toolbutton_run_clicked (GtkWidget *widget, gpointer args) } static void -on_toolbutton_stop_clicked (GtkWidget *widget, gpointer args) +on_stop_button_clicked (GtkWidget *widget, gpointer args) { ThreadData *data = (ThreadData *) args; + GError *error = NULL; + data->running = FALSE; data->store = FALSE; - GError *error = NULL; + + set_tool_button_state (data); uca_camera_stop_recording (data->camera, &error); if (error != NULL) @@ -182,22 +192,20 @@ on_toolbutton_stop_clicked (GtkWidget *widget, gpointer args) } static void -on_toolbutton_record_clicked (GtkWidget *widget, gpointer args) +on_record_button_clicked (GtkWidget *widget, gpointer args) { ThreadData *data = (ThreadData *) args; - data->timestamp = (int) time (0); - data->store = TRUE; GError *error = NULL; - gtk_statusbar_push (data->statusbar, data->statusbar_context_id, "Recording..."); + data->timestamp = (int) time (0); + data->store = TRUE; + data->running = TRUE; - if (data->running != TRUE) { - data->running = TRUE; - uca_camera_start_recording (data->camera, &error); + set_tool_button_state (data); + uca_camera_start_recording (data->camera, &error); - if (!g_thread_create (grab_thread, data, FALSE, &error)) - g_printerr ("Failed to create thread: %s\n", error->message); - } + if (!g_thread_create (grab_thread, data, FALSE, &error)) + g_printerr ("Failed to create thread: %s\n", error->message); } static void @@ -215,10 +223,10 @@ create_main_window (GtkBuilder *builder, const gchar* camera_name) guint bits_per_sample; g_object_get (camera, - "roi-width", &td.width, - "roi-height", &td.height, - "sensor-bitdepth", &bits_per_sample, - NULL); + "roi-width", &td.width, + "roi-height", &td.height, + "sensor-bitdepth", &bits_per_sample, + NULL); GtkWidget *window = GTK_WIDGET (gtk_builder_get_object (builder, "window")); GtkWidget *image = GTK_WIDGET (gtk_builder_get_object (builder, "image")); @@ -237,18 +245,19 @@ create_main_window (GtkBuilder *builder, const gchar* camera_name) td.buffer = (guchar *) g_malloc (td.pixel_size * td.width * td.height); td.pixels = gdk_pixbuf_get_pixels (pixbuf); td.running = FALSE; - td.statusbar = GTK_STATUSBAR (gtk_builder_get_object (builder, "statusbar")); - td.statusbar_context_id = gtk_statusbar_get_context_id (td.statusbar, "Recording Information"); td.store = FALSE; td.camera = camera; g_signal_connect (window, "destroy", G_CALLBACK (on_destroy), &td); - g_signal_connect (gtk_builder_get_object (builder, "toolbutton_run"), - "clicked", G_CALLBACK (on_toolbutton_run_clicked), &td); - g_signal_connect (gtk_builder_get_object (builder, "toolbutton_stop"), - "clicked", G_CALLBACK (on_toolbutton_stop_clicked), &td); - g_signal_connect (gtk_builder_get_object (builder, "toolbutton_record"), - "clicked", G_CALLBACK (on_toolbutton_record_clicked), &td); + + td.start_button = GTK_WIDGET (gtk_builder_get_object (builder, "start-button")); + td.stop_button = GTK_WIDGET (gtk_builder_get_object (builder, "stop-button")); + td.record_button = GTK_WIDGET (gtk_builder_get_object (builder, "record-button")); + set_tool_button_state (&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); + g_signal_connect (td.record_button, "clicked", G_CALLBACK (on_record_button_clicked), &td); gtk_widget_show (image); gtk_widget_show (window); @@ -295,7 +304,7 @@ create_choice_window (GtkBuilder *builder) GtkWidget *choice_window = GTK_WIDGET (gtk_builder_get_object (builder, "choice-window")); GtkTreeView *treeview = GTK_TREE_VIEW (gtk_builder_get_object (builder, "treeview-cameras")); GtkListStore *list_store = GTK_LIST_STORE (gtk_builder_get_object (builder, "camera-types")); - GtkButton *proceed_button = GTK_BUTTON (gtk_builder_get_object (builder, "button-proceed")); + GtkButton *proceed_button = GTK_BUTTON (gtk_builder_get_object (builder, "proceed-button")); GtkTreeIter iter; for (GList *it = g_list_first (camera_types); it != NULL; it = g_list_next (it)) { diff --git a/tools/gui/control.glade b/tools/gui/control.glade index ad5a91f..ee888e8 100644 --- a/tools/gui/control.glade +++ b/tools/gui/control.glade @@ -117,7 +117,7 @@ <object class="GtkToolbar" id="toolbar"> <property name="visible">True</property> <child> - <object class="GtkToolButton" id="toolbutton_run"> + <object class="GtkToolButton" id="start-button"> <property name="visible">True</property> <property name="label" translatable="yes">Run</property> <property name="use_underline">True</property> @@ -129,7 +129,7 @@ </packing> </child> <child> - <object class="GtkToolButton" id="toolbutton_record"> + <object class="GtkToolButton" id="record-button"> <property name="visible">True</property> <property name="label" translatable="yes">Record</property> <property name="use_underline">True</property> @@ -141,7 +141,7 @@ </packing> </child> <child> - <object class="GtkToolButton" id="toolbutton_stop"> + <object class="GtkToolButton" id="stop-button"> <property name="visible">True</property> <property name="label" translatable="yes">Stop</property> <property name="use_underline">True</property> @@ -208,16 +208,6 @@ <property name="position">2</property> </packing> </child> - <child> - <object class="GtkStatusbar" id="statusbar"> - <property name="visible">True</property> - <property name="spacing">2</property> - </object> - <packing> - <property name="expand">False</property> - <property name="position">3</property> - </packing> - </child> </object> </child> </object> @@ -271,7 +261,7 @@ <property name="spacing">6</property> <property name="layout_style">end</property> <child> - <object class="GtkButton" id="button-cancel"> + <object class="GtkButton" id="cancel-button"> <property name="label">gtk-quit</property> <property name="visible">True</property> <property name="can_focus">True</property> @@ -286,7 +276,7 @@ </packing> </child> <child> - <object class="GtkButton" id="button-proceed"> + <object class="GtkButton" id="proceed-button"> <property name="label">gtk-ok</property> <property name="visible">True</property> <property name="can_focus">True</property> |