summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test/CMakeLists.txt3
-rw-r--r--test/control.c76
-rw-r--r--test/control.glade91
3 files changed, 44 insertions, 126 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 89351d9..728da6a 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -10,8 +10,7 @@ pkg_check_modules(GTHREAD2 gthread-2.0)
include_directories(${CMAKE_SOURCE_DIR}/src)
-file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/control.glade
- DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/control.glade ${CMAKE_CURRENT_BINARY_DIR})
# --- Build targets -----------------------------------------------------------
add_executable(enum enum.c)
diff --git a/test/control.c b/test/control.c
index 00bda8c..5ff54c6 100644
--- a/test/control.c
+++ b/test/control.c
@@ -36,27 +36,21 @@ enum {
void convert_8bit_to_rgb(guchar *output, guchar *input, int width, int height)
{
- for (int x = 0; x < width; x++) {
- for (int y = 0; y < height; y++) {
- const int off = y*width + x;
- output[off*3] = input[off];
- output[off*3+1] = input[off];
- output[off*3+2] = input[off];
- }
+ for (int i = 0, j = 0; i < width*height; i++) {
+ output[j++] = input[i];
+ output[j++] = input[i];
+ output[j++] = input[i];
}
}
void convert_16bit_to_rgb(guchar *output, guchar *input, int width, int height)
{
uint16_t *in = (uint16_t *) input;
- for (int x = 0; x < width; x++) {
- for (int y = 0; y < height; y++) {
- const int off = y*width + x;
- guchar val = (uint8_t) ((in[off]/65536.0f)*256.0f);
- output[off*3] = val;
- output[off*3+1] = val;
- output[off*3+2] = val;
- }
+ for (int i = 0, j = 0; i < width*height; i++) {
+ guchar val = (uint8_t) ((in[i]/65536.0f)*256.0f);
+ output[j++] = val;
+ output[j++] = val;
+ output[j++] = val;
}
}
@@ -79,19 +73,6 @@ void reallocate_buffers(ThreadData *td, int width, int height)
g_print("Couldn't allocate buffer for 20 frames\n");
}
-static gboolean delete_event(GtkWidget *widget, GdkEvent *event, gpointer data)
-{
- return FALSE;
-}
-
-static void destroy(GtkWidget *widget, gpointer data)
-{
- ThreadData *td = (ThreadData *) data;
- td->running = FALSE;
- uca_destroy(td->u);
- gtk_main_quit();
-}
-
void *grab_thread(void *args)
{
ThreadData *data = (ThreadData *) args;
@@ -114,7 +95,20 @@ void *grab_thread(void *args)
return NULL;
}
-static void on_toolbutton_run_clicked(GtkWidget *widget, gpointer args)
+gboolean on_delete_event(GtkWidget *widget, GdkEvent *event, gpointer data)
+{
+ return FALSE;
+}
+
+void on_destroy(GtkWidget *widget, gpointer data)
+{
+ ThreadData *td = (ThreadData *) data;
+ td->running = FALSE;
+ uca_destroy(td->u);
+ gtk_main_quit();
+}
+
+void on_toolbutton_run_clicked(GtkWidget *widget, gpointer args)
{
ThreadData *data = (ThreadData *) args;
GError *error = NULL;
@@ -126,14 +120,14 @@ static void on_toolbutton_run_clicked(GtkWidget *widget, gpointer args)
}
}
-static void on_toolbutton_stop_clicked(GtkWidget *widget, gpointer args)
+void on_toolbutton_stop_clicked(GtkWidget *widget, gpointer args)
{
ThreadData *data = (ThreadData *) args;
data->running = FALSE;
uca_cam_stop_recording(data->cam);
}
-static void on_valuecell_edited(GtkCellRendererText *renderer, gchar *path, gchar *new_text, gpointer data)
+void on_valuecell_edited(GtkCellRendererText *renderer, gchar *path, gchar *new_text, gpointer data)
{
ValueCellData *value_data = (ValueCellData *) data;
@@ -163,7 +157,7 @@ static void on_valuecell_edited(GtkCellRendererText *renderer, gchar *path, gcha
}
}
-void get_first_level_root(GtkTreeStore *store, GtkTreeIter *iter, gchar *group)
+static void get_first_level_root(GtkTreeStore *store, GtkTreeIter *iter, gchar *group)
{
GtkTreeIter root;
if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &root)) {
@@ -193,7 +187,7 @@ void get_first_level_root(GtkTreeStore *store, GtkTreeIter *iter, gchar *group)
gtk_tree_store_set(store, iter, 0, group, -1);
}
-void find_recursively(GtkTreeStore *store, GtkTreeIter *root, GtkTreeIter *result, gchar **tokens, int depth)
+static void find_recursively(GtkTreeStore *store, GtkTreeIter *root, GtkTreeIter *result, gchar **tokens, int depth)
{
GtkTreeIter iter;
gchar *str;
@@ -232,7 +226,7 @@ void find_recursively(GtkTreeStore *store, GtkTreeIter *root, GtkTreeIter *resul
find_recursively(store, &iter, result, tokens, depth+1);
}
-void fill_tree_store(GtkTreeStore *tree_store, struct uca_camera *cam)
+static void fill_tree_store(GtkTreeStore *tree_store, struct uca_camera *cam)
{
GtkTreeIter iter, child;
struct uca_property *property;
@@ -284,7 +278,7 @@ void fill_tree_store(GtkTreeStore *tree_store, struct uca_camera *cam)
g_free(value_string);
}
-void value_cell_data_func(GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
+static void value_cell_data_func(GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
{
uint32_t prop_id;
@@ -357,17 +351,7 @@ int main(int argc, char *argv[])
td.running = FALSE;
td.pixel_size = pixel_size;
- g_signal_connect(window, "delete-event",
- G_CALLBACK (delete_event), NULL);
-
- g_signal_connect(window, "destroy",
- G_CALLBACK (destroy), &td);
-
- g_signal_connect(GTK_WIDGET(gtk_builder_get_object(builder, "toolbutton_run")), "clicked",
- G_CALLBACK(on_toolbutton_run_clicked), &td);
-
- g_signal_connect(GTK_WIDGET(gtk_builder_get_object(builder, "toolbutton_stop")), "clicked",
- G_CALLBACK(on_toolbutton_stop_clicked), &td);
+ gtk_builder_connect_signals(builder, &td);
ValueCellData value_cell_data;
value_cell_data.thread_data = &td;
diff --git a/test/control.glade b/test/control.glade
index 4847767..e20f9ff 100644
--- a/test/control.glade
+++ b/test/control.glade
@@ -1,4 +1,4 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="2.20"/>
<!-- interface-naming-policy project-wide -->
@@ -18,27 +18,26 @@
<property name="title" translatable="yes">Camera Control</property>
<property name="default_width">800</property>
<property name="default_height">600</property>
+ <signal name="destroy" handler="on_destroy"/>
+ <signal name="delete_event" handler="on_delete_event"/>
<child>
<object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
- <property name="orientation">vertical</property>
<child>
<object class="GtkMenuBar" id="menubar1">
<property name="visible">True</property>
<child>
<object class="GtkMenuItem" id="menuitem1">
<property name="visible">True</property>
- <property name="use_action_appearance">False</property>
<property name="label" translatable="yes">_File</property>
<property name="use_underline">True</property>
<child type="submenu">
- <object class="GtkMenu" id="menu1">
+ <object class="GtkMenu" id="menu_file">
<property name="visible">True</property>
<child>
<object class="GtkImageMenuItem" id="imagemenuitem1">
<property name="label">gtk-new</property>
<property name="visible">True</property>
- <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
@@ -47,7 +46,6 @@
<object class="GtkImageMenuItem" id="imagemenuitem2">
<property name="label">gtk-open</property>
<property name="visible">True</property>
- <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
@@ -56,7 +54,6 @@
<object class="GtkImageMenuItem" id="imagemenuitem3">
<property name="label">gtk-save</property>
<property name="visible">True</property>
- <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
@@ -65,7 +62,6 @@
<object class="GtkImageMenuItem" id="imagemenuitem4">
<property name="label">gtk-save-as</property>
<property name="visible">True</property>
- <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
@@ -73,16 +69,15 @@
<child>
<object class="GtkSeparatorMenuItem" id="separatormenuitem1">
<property name="visible">True</property>
- <property name="use_action_appearance">False</property>
</object>
</child>
<child>
- <object class="GtkImageMenuItem" id="imagemenuitem5">
+ <object class="GtkImageMenuItem" id="imagemenuitem_quit">
<property name="label">gtk-quit</property>
<property name="visible">True</property>
- <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
+ <signal name="activate" handler="gtk_main_quit"/>
</object>
</child>
</object>
@@ -90,76 +85,17 @@
</object>
</child>
<child>
- <object class="GtkMenuItem" id="menuitem2">
- <property name="visible">True</property>
- <property name="use_action_appearance">False</property>
- <property name="label" translatable="yes">_Edit</property>
- <property name="use_underline">True</property>
- <child type="submenu">
- <object class="GtkMenu" id="menu2">
- <property name="visible">True</property>
- <child>
- <object class="GtkImageMenuItem" id="imagemenuitem6">
- <property name="label">gtk-cut</property>
- <property name="visible">True</property>
- <property name="use_action_appearance">False</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem" id="imagemenuitem7">
- <property name="label">gtk-copy</property>
- <property name="visible">True</property>
- <property name="use_action_appearance">False</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem" id="imagemenuitem8">
- <property name="label">gtk-paste</property>
- <property name="visible">True</property>
- <property name="use_action_appearance">False</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- </object>
- </child>
- <child>
- <object class="GtkImageMenuItem" id="imagemenuitem9">
- <property name="label">gtk-delete</property>
- <property name="visible">True</property>
- <property name="use_action_appearance">False</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkMenuItem" id="menuitem3">
- <property name="visible">True</property>
- <property name="use_action_appearance">False</property>
- <property name="label" translatable="yes">_View</property>
- <property name="use_underline">True</property>
- </object>
- </child>
- <child>
<object class="GtkMenuItem" id="menuitem4">
<property name="visible">True</property>
- <property name="use_action_appearance">False</property>
<property name="label" translatable="yes">_Help</property>
<property name="use_underline">True</property>
<child type="submenu">
- <object class="GtkMenu" id="menu3">
+ <object class="GtkMenu" id="menu_help">
<property name="visible">True</property>
<child>
- <object class="GtkImageMenuItem" id="imagemenuitem10">
+ <object class="GtkImageMenuItem" id="imagemenuitem_about">
<property name="label">gtk-about</property>
<property name="visible">True</property>
- <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
</object>
@@ -180,10 +116,10 @@
<child>
<object class="GtkToolButton" id="toolbutton_run">
<property name="visible">True</property>
- <property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Run</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-media-play</property>
+ <signal name="clicked" handler="on_toolbutton_run_clicked"/>
</object>
<packing>
<property name="expand">False</property>
@@ -193,7 +129,6 @@
<child>
<object class="GtkToolButton" id="toolbutton_record">
<property name="visible">True</property>
- <property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Record</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-media-record</property>
@@ -206,10 +141,10 @@
<child>
<object class="GtkToolButton" id="toolbutton_stop">
<property name="visible">True</property>
- <property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Stop</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-media-stop</property>
+ <signal name="clicked" handler="on_toolbutton_stop_clicked"/>
</object>
<packing>
<property name="expand">False</property>
@@ -257,7 +192,7 @@
<property name="model">cameraproperties</property>
<child>
<object class="GtkTreeViewColumn" id="namecolumn">
- <property name="title" translatable="yes">Name</property>
+ <property name="title">Name</property>
<child>
<object class="GtkCellRendererText" id="namecell"/>
<attributes>
@@ -268,7 +203,7 @@
</child>
<child>
<object class="GtkTreeViewColumn" id="valuecolumn">
- <property name="title" translatable="yes">Value</property>
+ <property name="title">Value</property>
<child>
<object class="GtkCellRendererText" id="valuecell"/>
<attributes>
@@ -279,7 +214,7 @@
</child>
<child>
<object class="GtkTreeViewColumn" id="unitcolumn">
- <property name="title" translatable="yes">Unit</property>
+ <property name="title">Unit</property>
<child>
<object class="GtkCellRendererText" id="unitcell"/>
<attributes>