kee

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

commit be26f8da0c2f5109d8b28084b9dfc046ef300515
parent 636fbb23b385b09f1680f60453b0a0beecbd117e
Author: lash <dev@holbrook.no>
Date:   Thu, 21 Mar 2024 09:59:51 +0000

Complete refactor with import object

Diffstat:
MMakefile | 2--
Msrc/Makefile | 2++
Msrc/camera.c | 1+
Msrc/err.h | 5+++++
Msrc/gtk/Makefile | 4+++-
Asrc/gtk/kee-import.c | 166+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/gtk/kee-import.h | 23+++++++++++++++++++++++
Msrc/gtk/kee-uicontext.c | 3---
Msrc/gtk/main.c | 11+++++++++++
Msrc/gtk/menu.c | 11+----------
Msrc/gtk/scan.c | 4+++-
Msrc/gtk/tests/Makefile | 3+++
Msrc/gtk/ui.c | 170++++++++-----------------------------------------------------------------------
Msrc/gtk/ui.h | 4+++-
14 files changed, 237 insertions(+), 172 deletions(-)

diff --git a/Makefile b/Makefile @@ -13,8 +13,6 @@ glade: clean: make -C src clean - make -C src/gtk clean - make -C src/aux clean run: gtk all G_MESSAGES_DEBUG=all ./src/gtk/a.out diff --git a/src/Makefile b/src/Makefile @@ -16,6 +16,8 @@ aux: clean: rm -vf *.o + make -C gtk clean + make -C aux clean dev: $(CC) $(CFLAGS) -c settings.c -o settings.o $(LDFLAGS) diff --git a/src/camera.c b/src/camera.c @@ -28,6 +28,7 @@ int kee_camera_scan(struct kee_camera_devices *devices) { sprintf(p->path, "/dev/video%d", devnum); fd = open(p->path, O_RDONLY); if (fd < 0) { + p->path[0] = 0; break; } r = ioctl(fd, VIDIOC_QUERYCAP, &video_cap); diff --git a/src/err.h b/src/err.h @@ -1,3 +1,6 @@ +#ifndef _KEE_ERR_H +#define _KEE_ERR_H + /** * * Error codes within context of the kee application and backend. @@ -20,3 +23,5 @@ enum keeError { ERR_INPUT_PROTECT, }; + +#endif // _KEE_ERR_H diff --git a/src/gtk/Makefile b/src/gtk/Makefile @@ -18,6 +18,7 @@ clean: rm -vf a.out rm -vf a_dev.out rm -vf resources.c + make -C tests clean resource: glib-compile-resources kee.gresource.xml --target=resources.c --generate-source @@ -30,4 +31,5 @@ dev: $(CC) $(CFLAGS) -c ui.c -o ui.o $(CC) $(CFLAGS) -c menu.c -o menu.o $(CC) $(CFLAGS) -c kee-uicontext.c -o kee-uicontext.o - $(CC) $(CFLAGS) main.c -o a_dev.out ../settings.o ../camera.o ../context.o ../state.o ./kee-uicontext.o ./debug.o ./menu.o ./scan.o ./ui.o ./view.o ./nav.o $(LDFLAGS) + $(CC) $(CFLAGS) -c kee-import.c -o kee-import.o + $(CC) $(CFLAGS) main.c -o a_dev.out ../settings.o ../camera.o ../context.o ../state.o ./kee-uicontext.o ./kee-import.o ./debug.o ./menu.o ./scan.o ./ui.o ./view.o ./nav.o $(LDFLAGS) diff --git a/src/gtk/kee-import.c b/src/gtk/kee-import.c @@ -0,0 +1,166 @@ +#include <glib-object.h> +#include <gtk/gtk.h> +#include <gst/gst.h> + +#include "kee-import.h" +#include "camera.h" +#include "scan.h" +#include "err.h" + +typedef struct { +} KeeImportPrivate; + +struct _KeeImportClass { + GtkWidget parent_class; +}; + +struct _KeeImport { + GtkWidget parent; + GListModel *camera_list; + struct kee_camera_devices camera_device; + struct kee_scanner scan; +}; + +G_DEFINE_TYPE(KeeImport, kee_import, GTK_TYPE_BOX); + +static guint kee_sigs[KEE_N_IMPORT_SIGS] = {0,}; + +static void kee_import_class_init(KeeImportClass *kls) { + GObjectClass *o = G_OBJECT_CLASS(kls); + + kee_sigs[KEE_S_IMPORT_SCAN_CHANGE] = g_signal_newv("scan", + G_TYPE_FROM_CLASS(o), + G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, + NULL, + NULL, + NULL, + NULL, + G_TYPE_NONE, + 0, + NULL + ); +} + +static void kee_import_init(KeeImport *o) { + o->camera_list = G_LIST_MODEL(g_list_store_new(GTK_TYPE_LABEL)); + kee_import_refresh(o); + memset(&o->scan, 0, sizeof(struct kee_scanner)); +} + +static void kee_import_scanadd(KeeImport *o, GtkLabel *label) { + g_list_store_append(G_LIST_STORE(o->camera_list), label); +} + +int kee_import_refresh(KeeImport *o) { + int r; + GtkWidget *label; + struct kee_camera_devices *p; + + p = &o->camera_device; + r = kee_camera_scan(p); + if (r) { + return ERR_FAIL; + } + + while(strcmp(p->path, "")) { + label = gtk_label_new(p->label); + g_object_set_data(G_OBJECT(label), "devpath", p->path); + kee_import_scanadd(o, GTK_LABEL(label)); + if (p->next == NULL) { + break; + } + p = p->next; + } + + return ERR_OK; +} + +static void kee_import_apply_viewfinder(KeeImport *o) { + GtkWidget *p; + GtkWidget *label; + + p = gtk_widget_get_first_child(GTK_WIDGET(o)); + if (p) { + gtk_box_remove(GTK_BOX(o), p); + } + + p = GTK_WIDGET(o->scan.video_view); + gtk_box_append(GTK_BOX(o), p); + gtk_widget_set_visible(GTK_WIDGET(o), true); +} + +static gboolean kee_import_scan_code_handler(GstBus *bus, GstMessage *msg, gpointer user_data) { + GError *err; + gchar *debug_info; + GstState oldstate; + GstState newstate; + GstState pendingstate; + const gchar *src; + const gchar *code; + const GstStructure *strctr; + //struct _gst_data *data; + //GstStateChangeReturn rsc; + + //data = (struct _gst_data*)user_data; + + g_log(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "scan msg got"); + + switch (GST_MESSAGE_TYPE (msg)) { + case GST_MESSAGE_ERROR: + gst_message_parse_error(msg, &err, &debug_info); + g_log(G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "logg %s: %s", GST_OBJECT_NAME(msg->src), err->message); + g_log(G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "debug %s", debug_info ? debug_info : "none"); + g_clear_error(&err); + g_free(debug_info); + break; + case GST_MESSAGE_EOS: + g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "eos"); + break; + case GST_MESSAGE_STATE_CHANGED: + gst_message_parse_state_changed(msg, &oldstate, &newstate, &pendingstate); + g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "state change: %s -> %s", gst_element_state_get_name(oldstate), gst_element_state_get_name(newstate)); + break; + case GST_MESSAGE_ELEMENT: + src = gst_object_get_name(msg->src); + if (strcmp(src, "zbar")) { + break; + } + strctr = gst_message_get_structure(msg); + code = gst_structure_get_string(strctr, "symbol"); + g_log(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "message %s: %d (%s) - decoded: %s", src, msg->type, gst_message_type_get_name(msg->type), code); + break; + default: + g_log(G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "unknown message (ext %d): %s", GST_MESSAGE_TYPE_IS_EXTENDED(msg), GST_MESSAGE_TYPE_NAME(msg)); + break; + } + + return true; +} + +int kee_import_scanchange(KeeImport *o, const char *device) { + if (!(strcmp(device, ""))) { + return ERR_FAIL; + } + + if (o->scan.pipeline) { + scan_free(&o->scan); + } + scan_init(&o->scan, device); + scan_begin(&o->scan); + + kee_import_apply_viewfinder(o); + + o->scan.bus = gst_element_get_bus(o->scan.pipeline); + gst_bus_add_watch(o->scan.bus, kee_import_scan_code_handler, o); + //scan_set_handler(&o->scan, kee_import_scan_code_handler); + return ERR_OK; +} + +GListModel* kee_import_get_camera_list(KeeImport *o) { + return o->camera_list; +} + +void kee_import_free(KeeImport *o) { + kee_camera_free(&o->camera_device); + scan_free(&o->scan); +} diff --git a/src/gtk/kee-import.h b/src/gtk/kee-import.h @@ -0,0 +1,23 @@ +#ifndef _GTK_KEE_IMPORT_H +#define _GTK_KEE_IMPORT_H + +#include <glib-object.h> + +G_BEGIN_DECLS + +#define KEE_TYPE_IMPORT kee_import_get_type() +G_DECLARE_FINAL_TYPE(KeeImport, kee_import, KEE, IMPORT, GtkBox) + +enum KEE_IMPORT_SIGS { + KEE_S_IMPORT_SCAN_CHANGE, + KEE_N_IMPORT_SIGS, +}; + +KeeImport* kee_import_new(void); +int kee_import_refresh(KeeImport *im); +GListModel* kee_import_get_camera_list(KeeImport *o); +int kee_import_scanchange(KeeImport *o, const char *device); + +G_END_DECLS + +#endif //_GTK_KEE_IMPORT_H diff --git a/src/gtk/kee-uicontext.c b/src/gtk/kee-uicontext.c @@ -11,9 +11,6 @@ typedef struct { } KeeUicontextPrivate; -/** - * \todo parent can be gapplication object? - */ struct _KeeUicontext { GObject parent; //struct ui_container *ui; diff --git a/src/gtk/main.c b/src/gtk/main.c @@ -1,8 +1,10 @@ #include <string.h> #include <gtk/gtk.h> #include <glib-object.h> +#include <gst/gst.h> #include "kee-uicontext.h" +#include "kee-import.h" #include "ui.h" //#include "context.h" #include "menu.h" @@ -21,6 +23,9 @@ static void startup(GtkApplication *app, KeeUicontext *uctx) { static void activate(GtkApplication *app, KeeUicontext *uctx) { ui_build(app, uctx); } +static void activate_scan(GtkApplication *app, KeeImport *import) { + ui_build_scan(app, import); +} static void deactivate(GtkApplication *app, gpointer user_data) { g_object_unref(user_data); @@ -32,6 +37,10 @@ int main(int argc, char **argv) { struct kee_settings settings; struct kee_context ctx; GtkApplication *gapp; + KeeImport *import; + + gtk_init(); + gst_init(0, NULL); gapp = gtk_application_new ("org.defalsify.Kee", G_APPLICATION_DEFAULT_FLAGS); @@ -39,10 +48,12 @@ int main(int argc, char **argv) { settings_init(&settings); uctx = g_object_new(KEE_TYPE_UICONTEXT, "gtk_application", gapp, "core_context", &ctx, NULL); + import = g_object_new(KEE_TYPE_IMPORT, "orientation", GTK_ORIENTATION_VERTICAL, NULL); //db_connect(&ctx.db, "./testdata_mdb"); g_signal_connect (gapp, "startup", G_CALLBACK (startup), uctx); g_signal_connect (gapp, "activate", G_CALLBACK (activate), uctx); + g_signal_connect (gapp, "activate", G_CALLBACK (activate_scan), import); g_signal_connect (gapp, "shutdown", G_CALLBACK (deactivate), uctx); g_signal_connect (uctx, "scan", G_CALLBACK( ui_handle_scan) , uctx); g_signal_connect (uctx, "unlock", G_CALLBACK(ui_handle_unlock), uctx); diff --git a/src/gtk/menu.c b/src/gtk/menu.c @@ -14,16 +14,6 @@ static void act_quit(GAction *act, GVariant *param, GApplication *gapp) { static void menu_handle_state(KeeUicontext *uctx, char state_hint, kee_state_t *new_state, kee_state_t *old_state, GObject *head) { - GtkWidget *widget; - - if (!(state_hint & KEE_ST_HINT_UI_MENU)) { - return; - } - - if (new_state->ui_menu & KEE_ST_UI_HEAD_ADD) { - widget = g_object_get_data(head, KEE_W_UI_MENU_QUICK_ADD); - gtk_actionable_set_action_name(GTK_ACTIONABLE(widget), "win.import"); - } } @@ -75,6 +65,7 @@ GtkWidget* header_setup(GtkApplication *gapp, KeeUicontext *uctx) { g_object_set_data(G_OBJECT(uctx), KEE_W_HEADER, GTK_HEADER_BAR(head)); + g_signal_connect (uctx, "state", G_CALLBACK(menu_handle_state), head); return head; } diff --git a/src/gtk/scan.c b/src/gtk/scan.c @@ -122,7 +122,9 @@ void scan_act(GSimpleAction *act, GVariant *param, KeeUicontext *uctx) { } void scan_free(struct kee_scanner *scan) { - gst_object_unref(scan->bus); + if (scan->bus) { + gst_object_unref(scan->bus); + } gst_element_set_state(scan->pipeline, GST_STATE_NULL); gst_object_unref(scan->pipeline); free(scan->device); diff --git a/src/gtk/tests/Makefile b/src/gtk/tests/Makefile @@ -14,3 +14,6 @@ test_run: $(wildcard test_*) ./$< test: all test_run + +clean: + rm -vf test_* diff --git a/src/gtk/ui.c b/src/gtk/ui.c @@ -10,6 +10,7 @@ #include "state.h" #include "view.h" #include "menu.h" +#include "kee-import.h" static void new_item(GtkListItemFactory *factory, GtkListItem *item, gpointer user_data) { @@ -29,9 +30,6 @@ static void win_handle_state(KeeUicontext *uctx, char state_hint, kee_state_t *n } -static void scan_menu_handle_state(KeeUicontext *uctx, char state_hint, kee_state_t *new_state, kee_state_t *old_state, GObject *head) { -} - static void act_import(GAction *act, GVariant *param, GtkStack *stack) { g_log(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "act impot"); gtk_stack_set_visible_child_name(stack, "import"); @@ -57,14 +55,10 @@ void ui_handle_unlock(KeeUicontext *uctx, gpointer user_data) { } -//static void ui_handle_unlock_click(GtkWidget *button, gpointer user_data) { static void ui_handle_unlock_click(GtkWidget *button, KeeUicontext *uctx) { GtkEntryBuffer *buf; const char *passphrase; - //ui = (struct ui_container*)user_data; - //gtk_stack_set_visible_child(ui->stack, GTK_WIDGET(ui->front_view)); - buf = g_object_get_data(G_OBJECT(uctx), "passphrase"); passphrase = gtk_entry_buffer_get_text(buf); g_log(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "click"); @@ -74,22 +68,16 @@ static void ui_handle_unlock_click(GtkWidget *button, KeeUicontext *uctx) { gtk_entry_buffer_delete_text(buf, 0, gtk_entry_buffer_get_length(buf)); } -//static void ui_handle_camera_change(GtkDropDown *chooser, GParamSpec *spec, struct kee_context *ctx) { -static void ui_handle_camera_change(GtkDropDown *chooser, GParamSpec *spec, KeeUicontext *uctx) { +static void ui_handle_camera_change(GtkDropDown *chooser, GParamSpec *spec, KeeImport *import) { GtkLabel *label; char *s; - //struct ui_container *ui; - - //ui = (struct ui_container*)ctx->front; label = gtk_drop_down_get_selected_item(chooser); s = g_object_get_data(G_OBJECT(label), "devpath"); g_log(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "dropdown changed: %s -> %s", spec->name, s); - kee_uicontext_scanchange(uctx, s); + kee_import_scanchange(import, s); - //ui_handle_scan(ui->gapp, ctx); - ui_handle_scan(uctx); } @@ -115,28 +103,23 @@ GtkWidget* ui_build_unlock(KeeUicontext *uctx) { return GTK_WIDGET(box); } -//static GtkWidget* ui_build_scan_videochooser(struct kee_context *ctx) { -static GtkWidget* ui_build_scan_videochooser(KeeUicontext *uctx) { + +static GtkWidget* ui_build_scan_videochooser(KeeImport *import) { GtkWidget *chooser; GtkExpression *exp_label; GListModel *camera_list; - //GtkExpression *exp_item; - //GClosure *gclosure; - - //ui = (struct ui_container*)ctx->front; exp_label = gtk_property_expression_new(GTK_TYPE_LABEL, NULL, "label"); - //exp_item = gtk_closure_expression_new(G_TYPE_STRING, gclosure, 1, &exp_label); - g_object_get(uctx, "camera_list", &camera_list, NULL); + camera_list = kee_import_get_camera_list(import); //, "camera_list", &camera_list, NULL); chooser = gtk_drop_down_new(camera_list, exp_label); - - g_signal_connect(chooser, "notify::selected-item", G_CALLBACK (ui_handle_camera_change), uctx); + g_signal_connect(chooser, "notify::selected-item", G_CALLBACK (ui_handle_camera_change), import); return chooser; } -static GtkWidget* ui_build_scan_footer(KeeUicontext *uctx) { + +static GtkWidget* ui_build_scan_footer(KeeImport *import) { GtkWidget *foot; GtkWidget *butt; GtkToggleButton *butt_prev; @@ -179,47 +162,34 @@ static GtkWidget* ui_build_scan_footer(KeeUicontext *uctx) { g_signal_connect(ag, "action-state-changed", G_CALLBACK(act_scan_select), ag); - g_object_set_data(G_OBJECT(uctx), KEE_W_FOOTER, GTK_ACTION_BAR(foot)); - gtk_widget_insert_action_group(foot, "import", ag); - g_signal_connect (uctx, "state", G_CALLBACK(scan_menu_handle_state), foot); return foot; } -//static GtkWidget* ui_build_scan(struct ui_container *ui) { -//static GtkWidget* ui_build_scan(struct kee_context *ctx) { -static GtkWidget* ui_build_scan(KeeUicontext *uctx) { +void ui_build_scan(GtkApplication *app, KeeImport *import) { GtkWidget *chooser; GtkWidget *box; GtkWidget *widget; GtkWidget *stack; - //struct ui_container *ui; stack = gtk_stack_new(); - //ui = (struct ui_container*)ctx->front; box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10); - chooser = ui_build_scan_videochooser(uctx); + chooser = ui_build_scan_videochooser(import); gtk_box_append(GTK_BOX(box), chooser); - widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); - g_object_set_data(G_OBJECT(uctx), KEE_W_CAMERA_VIEWFINDER, widget); + gtk_box_append(GTK_BOX(box), GTK_WIDGET(import)); - //widget = g_object_get_data(G_OBJECT(uctx), KEE_W_FOOTER); - widget = ui_build_scan_footer(uctx); + widget = ui_build_scan_footer(import); gtk_box_append(GTK_BOX(box), widget); gtk_stack_add_child(GTK_STACK(stack), box); - //g_object_set(uctx, "camera_view", box, NULL); - g_object_set_data(G_OBJECT(uctx), KEE_W_CAMERA_SCAN, box); // replace with state listen - - return GTK_WIDGET(stack); + kee_view_add(stack, "import"); } -//static GtkWidget* ui_build_view(struct ui_container *ui) { static GtkWidget* ui_build_view(KeeUicontext *uctx) { GtkListItemFactory *factory; GtkSelectionModel *sel; @@ -262,8 +232,8 @@ void ui_build(GtkApplication *app, KeeUicontext *uctx) { widget = ui_build_view(uctx); kee_view_add(widget, "view"); - widget = ui_build_scan(uctx); - kee_view_add(widget, "import"); + //widget = ui_build_scan(uctx); + //kee_view_add(widget, "import"); kee_view_next("view"); kee_view_next("unlock"); @@ -303,111 +273,3 @@ void ui_build(GtkApplication *app, KeeUicontext *uctx) { // // gtk_window_present(GTK_WINDOW (ui->win)); //} -// - - -//gboolean ui_scan_code_handler(GstBus *bus, GstMessage *msg, gpointer user_data) { -// GError *err; -// gchar *debug_info; -// GstState oldstate; -// GstState newstate; -// GstState pendingstate; -// const gchar *src; -// const gchar *code; -// const GstStructure *strctr; -// //struct _gst_data *data; -// //GstStateChangeReturn rsc; -// -// //data = (struct _gst_data*)user_data; -// -// g_log(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "scan msg got"); -// -// switch (GST_MESSAGE_TYPE (msg)) { -// case GST_MESSAGE_ERROR: -// gst_message_parse_error(msg, &err, &debug_info); -// g_log(G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "logg %s: %s", GST_OBJECT_NAME(msg->src), err->message); -// g_log(G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "debug %s", debug_info ? debug_info : "none"); -// g_clear_error(&err); -// g_free(debug_info); -// break; -// case GST_MESSAGE_EOS: -// g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "eos"); -// break; -// case GST_MESSAGE_STATE_CHANGED: -// gst_message_parse_state_changed(msg, &oldstate, &newstate, &pendingstate); -// g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "state change: %s -> %s", gst_element_state_get_name(oldstate), gst_element_state_get_name(newstate)); -// break; -// case GST_MESSAGE_ELEMENT: -// src = gst_object_get_name(msg->src); -// if (strcmp(src, "zbar")) { -// break; -// } -// strctr = gst_message_get_structure(msg); -// code = gst_structure_get_string(strctr, "symbol"); -// g_log(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "message %s: %d (%s) - decoded: %s", src, msg->type, gst_message_type_get_name(msg->type), code); -// break; -// default: -// g_log(G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "unknown message (ext %d): %s", GST_MESSAGE_TYPE_IS_EXTENDED(msg), GST_MESSAGE_TYPE_NAME(msg)); -// break; -// } -// -// return true; -//} -// -////GtkWidget* ui_build_scan_attach(GtkWidget *front_scan, const char *device) { -//// int r; -//// struct kee_scanner scan; -//// GtkWidget *view; -//// -//// //scan = &ui->scan; -//// scan_init(&scan, device); -//// r = scan_begin(&scan); -//// if (r) { -//// g_log(G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, "fail scan setup"); -//// return NULL; -//// } -//// view = GTK_WIDGET(scan.video_view); -//// gtk_box_append(GTK_BOX(front_scan), view); -//// scan_set_handler(&scan, ui_scan_code_handler); -//// return view; -////} -// -////void ui_handle_scan(GtkApplication *app, struct kee_context *ctx) { -//void ui_handle_scan(GtkApplication *app, KeeUicontext *uctx) { -void ui_handle_scan(KeeUicontext *uctx) { -// int r; -// GtkWidget *front_scan; -// struct kee_scanner scan; -// char *device; -// GtkWidget *view; -// //struct kee_scanner *scan; -// -// //ui = (struct ui_container*)ctx->front; -// //s = settings_get(ctx->settings, SETTINGS_VIDEO); -// //scan = &ui->scan; -// -// g_object_get(uctx, "camera_device", &device, NULL); -// //g_object_get(uctx, "camera_scan", &scan, NULL); -// g_object_get(uctx, "camera_view", &front_scan, NULL); -// -// //if (ui->state & KEE_ST_SCAN_INIT) { -//// if (scan.video_view) { -//// gtk_box_remove(GTK_BOX(front_scan), GTK_WIDGET(scan.video_view)); -//// scan_free(&scan); -//// } -// -// scan_init(&scan, device); -// r = scan_begin(&scan); -// if (r) { -// g_log(G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, "fail scan setup"); -// return; -// } -// view = GTK_WIDGET(scan.video_view); -// gtk_box_append(GTK_BOX(front_scan), view); -// scan_set_handler(&scan, ui_scan_code_handler); -// -//// ui_build_scan_attach(uctx, (const char*)s); -// //ui_state_change(ui, KEE_ST_SCAN_INIT, 0); -// //gtk_stack_set_visible_child(GTK_STACK(ui->stack), GTK_WIDGET(front_scan)); -// g_object_set(uctx, "ui_push", GTK_BOX(front_scan), NULL); -} diff --git a/src/gtk/ui.h b/src/gtk/ui.h @@ -2,6 +2,8 @@ #define _UI_H #include <gtk/gtk.h> +#include "kee-uicontext.h" +#include "kee-import.h" enum KeeActScan { KEE_ACT_SCAN_QR = 1, @@ -9,9 +11,9 @@ enum KeeActScan { KEE_ACT_SCAN_TEXT }; -#include "kee-uicontext.h" void ui_build(GtkApplication *app, KeeUicontext *uctx); +void ui_build_scan(GtkApplication *app, KeeImport *imp); void ui_handle_scan(KeeUicontext *uctx); void ui_handle_unlock(KeeUicontext *uctx, gpointer user_data);