summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/uca.c50
-rw-r--r--src/uca.h6
-rw-r--r--test/control.c42
-rw-r--r--test/control.glade2
4 files changed, 69 insertions, 31 deletions
diff --git a/src/uca.c b/src/uca.c
index 84de8b6..ea91f59 100644
--- a/src/uca.c
+++ b/src/uca.c
@@ -38,31 +38,31 @@ const char *uca_unit_map[] = {
};
static struct uca_property_t property_map[UCA_PROP_LAST+1] = {
- { "general.name", uca_na, uca_string },
- { "image.width", uca_pixel, uca_uint32t },
- { "image.width.min", uca_pixel, uca_uint32t },
- { "image.width.max", uca_pixel, uca_uint32t },
- { "image.height", uca_pixel, uca_uint32t },
- { "image.height.min", uca_pixel, uca_uint32t },
- { "image.height.max", uca_pixel, uca_uint32t },
- { "image.offset.x", uca_pixel, uca_uint32t },
- { "image.offset.y", uca_pixel, uca_uint32t },
- { "image.bitdepth", uca_bits, uca_uint8t },
- { "time.exposure", uca_us, uca_uint32t },
- { "time.exposure.min", uca_ns, uca_uint32t },
- { "time.exposure.max", uca_ms, uca_uint32t },
- { "time.delay", uca_us, uca_uint32t },
- { "time.delay.min", uca_ns, uca_uint32t },
- { "time.delay.max", uca_ms, uca_uint32t },
- { "time.framerate", uca_fps, uca_uint32t },
- { "mode.trigger", uca_na, uca_uint32t },
- { "mode.timestamp", uca_na, uca_uint32t },
- { "mode.scan", uca_na, uca_uint32t },
- { "ipe.interlace.samplerate", uca_na, uca_uint32t },
- { "ipe.interlace.threshold.pixel", uca_na, uca_uint32t },
- { "ipe.interlace.threshold.row", uca_na, uca_uint32t },
- { "mode.correction", uca_na, uca_uint32t },
- { NULL, 0, 0 }
+ { "general.name", uca_na, uca_string, uca_read },
+ { "image.width", uca_pixel, uca_uint32t, uca_readwrite },
+ { "image.width.min", uca_pixel, uca_uint32t, uca_read },
+ { "image.width.max", uca_pixel, uca_uint32t, uca_read },
+ { "image.height", uca_pixel, uca_uint32t, uca_readwrite },
+ { "image.height.min", uca_pixel, uca_uint32t, uca_read },
+ { "image.height.max", uca_pixel, uca_uint32t, uca_read },
+ { "image.offset.x", uca_pixel, uca_uint32t, uca_readwrite },
+ { "image.offset.y", uca_pixel, uca_uint32t, uca_readwrite },
+ { "image.bitdepth", uca_bits, uca_uint8t, uca_read},
+ { "time.exposure", uca_us, uca_uint32t, uca_readwrite },
+ { "time.exposure.min", uca_ns, uca_uint32t, uca_read },
+ { "time.exposure.max", uca_ms, uca_uint32t, uca_read },
+ { "time.delay", uca_us, uca_uint32t, uca_readwrite },
+ { "time.delay.min", uca_ns, uca_uint32t, uca_read },
+ { "time.delay.max", uca_ms, uca_uint32t, uca_read },
+ { "time.framerate", uca_fps, uca_uint32t, uca_read },
+ { "mode.trigger", uca_na, uca_uint32t, uca_readwrite },
+ { "mode.timestamp", uca_na, uca_uint32t, uca_readwrite },
+ { "mode.scan", uca_na, uca_uint32t, uca_readwrite },
+ { "ipe.interlace.samplerate", uca_na, uca_uint32t, uca_readwrite },
+ { "ipe.interlace.threshold.pixel", uca_na, uca_uint32t, uca_readwrite },
+ { "ipe.interlace.threshold.row", uca_na, uca_uint32t, uca_readwrite },
+ { "mode.correction", uca_na, uca_uint32t, uca_readwrite },
+ { NULL, 0, 0, 0 }
};
struct uca_t *uca_init(void)
diff --git a/src/uca.h b/src/uca.h
index 5fa8c39..0c554c6 100644
--- a/src/uca.h
+++ b/src/uca.h
@@ -117,6 +117,12 @@ struct uca_property_t {
uca_uint8t,
uca_string
} type;
+
+ enum uca_access_rights {
+ uca_read = 0x01,
+ uca_write = 0x02,
+ uca_readwrite = 0x01 | 0x02
+ } access;
};
extern const char *uca_unit_map[]; /**< maps unit numbers to corresponding strings */
diff --git a/test/control.c b/test/control.c
index 2c08308..baf6ee2 100644
--- a/test/control.c
+++ b/test/control.c
@@ -15,12 +15,19 @@ struct ThreadData {
struct uca_camera_t *cam;
};
+enum {
+ COLUMN_NAME = 0,
+ COLUMN_VALUE,
+ COLUMN_UNIT,
+ COLUMN_UCA_ID,
+ NUM_COLUMNS
+};
+
static gboolean delete_event(GtkWidget *widget, GdkEvent *event, gpointer data)
{
return FALSE;
}
-/* Another callback */
static void destroy(GtkWidget *widget, gpointer data)
{
struct uca_t *uca = (struct uca_t *) data;
@@ -123,8 +130,7 @@ void find_recursively(GtkTreeStore *store, GtkTreeIter *root, GtkTreeIter *resul
g_free(str);
gtk_tree_store_append(store, &iter, root);
- gtk_tree_store_set(store, &iter, 0, current_token, -1);
- //*result = iter;
+ gtk_tree_store_set(store, &iter, COLUMN_NAME, current_token, -1);
find_recursively(store, &iter, result, tokens, depth+1);
}
@@ -163,9 +169,10 @@ void fill_tree_store(GtkTreeStore *tree_store, struct uca_camera_t *cam)
while (tokens[count++] != NULL);
gtk_tree_store_set(tree_store, &child,
- 0, tokens[count-2],
- 1, value_string,
- 2, uca_unit_map[property->unit],
+ COLUMN_NAME, tokens[count-2],
+ COLUMN_VALUE, value_string,
+ COLUMN_UNIT, uca_unit_map[property->unit],
+ COLUMN_UCA_ID, prop_id,
-1);
g_strfreev(tokens);
@@ -174,6 +181,24 @@ void fill_tree_store(GtkTreeStore *tree_store, struct uca_camera_t *cam)
g_free(value_string);
}
+void value_cell_data_func(GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
+{
+ uint32_t prop_id;
+
+ gtk_tree_model_get(model, iter, COLUMN_UCA_ID, &prop_id, -1);
+ struct uca_property_t *property = uca_get_full_property(prop_id);
+ if (property->access & uca_write) {
+ g_object_set(cell, "mode", GTK_CELL_RENDERER_MODE_EDITABLE, NULL);
+ g_object_set(GTK_CELL_RENDERER_TEXT(cell), "editable", TRUE, NULL);
+ g_object_set(GTK_CELL_RENDERER_TEXT(cell), "style", PANGO_STYLE_NORMAL, NULL);
+ }
+ else {
+ g_object_set(cell, "mode", GTK_CELL_RENDERER_MODE_INERT, NULL);
+ g_object_set(GTK_CELL_RENDERER_TEXT(cell), "editable", FALSE, NULL);
+ g_object_set(GTK_CELL_RENDERER_TEXT(cell), "style", PANGO_STYLE_ITALIC, NULL);
+ }
+}
+
int main(int argc, char *argv[])
{
struct uca_t *uca = uca_init();
@@ -203,9 +228,14 @@ int main(int argc, char *argv[])
GtkWidget *window = GTK_WIDGET(gtk_builder_get_object(builder, "window"));
GtkWidget *image = GTK_WIDGET(gtk_builder_get_object(builder, "image"));
+
GtkTreeStore *tree_store = GTK_TREE_STORE(gtk_builder_get_object(builder, "cameraproperties"));
+ GtkTreeViewColumn *value_column = GTK_TREE_VIEW_COLUMN(gtk_builder_get_object(builder, "valuecolumn"));
+ GtkCellRendererText *value_renderer = GTK_CELL_RENDERER_TEXT(gtk_builder_get_object(builder, "valuecell"));
fill_tree_store(tree_store, cam);
+ gtk_tree_view_column_set_cell_data_func(value_column, GTK_CELL_RENDERER(value_renderer), value_cell_data_func, NULL, NULL);
+
g_signal_connect (window, "delete-event",
G_CALLBACK (delete_event), NULL);
diff --git a/test/control.glade b/test/control.glade
index dd9b829..4847767 100644
--- a/test/control.glade
+++ b/test/control.glade
@@ -10,6 +10,8 @@
<column type="gchararray"/>
<!-- column-name PropertyUnit -->
<column type="gchararray"/>
+ <!-- column-name PropertyUCA -->
+ <column type="guint"/>
</columns>
</object>
<object class="GtkWindow" id="window">