kee

Offline IOU signer with QR as transport
git clone https://holbrook.no/src/kee
Info | Log | Files | Refs | README | LICENSE

commit a74ee2055db49534b9b1d63c76d0a8bfc27919b4
parent 4d8235cb1d51c51af8a3b99512c73a277a7b5dd6
Author: lash <dev@holbrook.no>
Date:   Mon, 11 Mar 2024 13:35:07 +0000

Populate video device chooser

Diffstat:
M.gitignore | 1+
Msrc/gtk/ui.c | 45+++++++++++++++++++++++++++++++++++++--------
Msrc/gtk/ui.h | 1+
3 files changed, 39 insertions(+), 8 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,3 +1,4 @@ src/gtk/*.ui +**/*.o testdata_mdb *\~ diff --git a/src/gtk/ui.c b/src/gtk/ui.c @@ -49,17 +49,45 @@ GtkWidget* ui_build_unlock(struct ui_container *ui) { return GTK_WIDGET(box); } -//static GtkWidget* ui_build_scan_videochooser(struct ui_container *ui) { -// return NULL; -//} - -static GtkWidget* ui_build_scan(struct ui_container *ui) { +static GtkWidget* ui_build_scan_videochooser(struct kee_context *ctx) { + GtkWidget *chooser; GtkWidget *label; + GtkExpression *exp_label; + //GtkExpression *exp_item; + //GClosure *gclosure; + struct kee_camera_devices *camera_device; + struct ui_container *ui; + + ui = (struct ui_container*)ctx->front; + ui->camera_list = G_LIST_MODEL(g_list_store_new(GTK_TYPE_LABEL)); + + exp_label = gtk_property_expression_new(GTK_TYPE_LABEL, NULL, "label"); + //exp_item = gtk_closure_expression_new(G_TYPE_STRING, gclosure, 1, &exp_label); + + chooser = gtk_drop_down_new(G_LIST_MODEL(ui->camera_list), exp_label); + camera_device = &ctx->camera_devices; + while(1) { + label = gtk_label_new(camera_device->label); + g_object_set_data(G_OBJECT(label), "devpath", camera_device->path); + g_list_store_append(G_LIST_STORE(ui->camera_list), GTK_LABEL(label)); + if (camera_device->next == NULL) { + break; + } + camera_device = camera_device->next; + } + return chooser; +} + +//static GtkWidget* ui_build_scan(struct ui_container *ui) { +static GtkWidget* ui_build_scan(struct kee_context *ctx) { + GtkWidget *chooser; + struct ui_container *ui; + ui = (struct ui_container*)ctx->front; ui->front_scan = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 10)); - label = gtk_label_new("please scan qr code"); - gtk_box_append(GTK_BOX(ui->front_scan), label); + chooser = ui_build_scan_videochooser(ctx); + gtk_box_append(GTK_BOX(ui->front_scan), chooser); return GTK_WIDGET(ui->front_scan); } @@ -78,6 +106,7 @@ static GtkWidget* ui_build_view(struct ui_container *ui) { return GTK_WIDGET(ui->front_view); } + void ui_build(GtkApplication *app, struct kee_context *ctx) { GtkWidget *widget; struct ui_container *ui; @@ -98,7 +127,7 @@ void ui_build(GtkApplication *app, struct kee_context *ctx) { gtk_stack_set_visible_child(GTK_STACK(ui->stack), widget); widget = ui_build_view(ui); gtk_stack_add_child(ui->stack, widget); - widget = ui_build_scan(ui); + widget = ui_build_scan(ctx); gtk_stack_add_child(ui->stack, widget); //gtk_stack_set_visible_child(GTK_STACK(ui->stack), view); diff --git a/src/gtk/ui.h b/src/gtk/ui.h @@ -20,6 +20,7 @@ struct ui_container { GtkApplicationWindow *win; GtkStack *stack; GListModel *front_list; + GListModel *camera_list; GtkListView *front_view; GtkBox *front_scan; struct kee_scanner scan;