kee

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

commit f61610b133207fabc4dee4336caa5723fb56f74f
parent 6fcd3d062e2a80fee5e2f7ce4f2952655df1f5c5
Author: lash <dev@holbrook.no>
Date:   Tue, 11 Jun 2024 20:09:40 +0100

Add nav stack lookback for continue buttton

Diffstat:
Msrc/gtk/kee-menu.c | 4++++
Msrc/gtk/kee-menu.h | 1+
Msrc/gtk/kee-transport.c | 20+++++++++++++++-----
Msrc/gtk/nav.c | 4++++
Msrc/gtk/nav.h | 1+
5 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/src/gtk/kee-menu.c b/src/gtk/kee-menu.c @@ -296,3 +296,7 @@ int kee_menu_prev(KeeMenu *o, int force) { return ERR_OK; } + +int kee_menu_peek(int ridx) { + return kee_nav_get_stack_idx(ridx+1); +} diff --git a/src/gtk/kee-menu.h b/src/gtk/kee-menu.h @@ -29,6 +29,7 @@ int kee_menu_add(KeeMenu *o, const char *k, GtkWidget *v); GtkWidget* kee_menu_next(KeeMenu *o, int menu_id); int kee_menu_prev(KeeMenu *o, int force); int kee_menu_set(KeeMenu *o, GtkWidget *widget); +int kee_menu_peek(int reverse_idx); G_END_DECLS diff --git a/src/gtk/kee-transport.c b/src/gtk/kee-transport.c @@ -42,12 +42,22 @@ static void kee_transport_init(KeeTransport *o) { o->image_data = malloc(QR_IMAGE_SIZE); } -static void kee_transport_handle_continue(GAction *Act, GVariant *v, void *o) { +static void kee_transport_handle_continue(GAction *act, GVariant *v, KeeMenu *o) { + int menu_id; debug_log(DEBUG_DEBUG, "continue"); + + menu_id = kee_menu_peek(1); + switch(menu_id) { + case BEAMENU_DST_NEW: + kee_menu_next(o, BEAMENU_DST_IMPORT); + break; + default: + debug_log(DEBUG_CRITICAL, "you should check in to see what condition my condition is in"); + } } /// \todo find a way to modify underlying bytes and keep the stack from pixbuf to widget -static void kee_transport_render(KeeTransport *o) { +static void kee_transport_render(KeeTransport *o, const gchar *mode) { KeeMenu *menu; GtkWidget *widget; GdkTexture *texture; @@ -81,14 +91,14 @@ static void kee_transport_render(KeeTransport *o) { act = g_simple_action_new("transport_continue", NULL); gtk_actionable_set_action_name(GTK_ACTIONABLE(widget), "win.transport_continue"); g_action_map_add_action(G_ACTION_MAP(menu), G_ACTION(act)); - g_signal_connect(act, "activate", G_CALLBACK(kee_transport_handle_continue), NULL); + g_signal_connect(act, "activate", G_CALLBACK(kee_transport_handle_continue), menu); g_simple_action_set_enabled(act, true); kee_menu_next(menu, BEAMENU_DST_TRANSPORT); } /// \todo share buffer with image data? -void kee_transport_handle_qr(GAction *Act, GVariant *v, KeeTransport *o) { +void kee_transport_handle_qr(GAction *act, GVariant *v, KeeTransport *o) { char *p; char *pp; int i; @@ -133,5 +143,5 @@ void kee_transport_handle_qr(GAction *Act, GVariant *v, KeeTransport *o) { } } o->image_size = width_pixels * width_pixels; - kee_transport_render(o); + kee_transport_render(o, g_action_get_name(act)); } diff --git a/src/gtk/nav.c b/src/gtk/nav.c @@ -108,6 +108,10 @@ int kee_nav_get_idx() { return o->i; } +int kee_nav_get_stack_idx(int idx) { + return stack[stack_crsr-idx]; +} + int kee_nav_get_exit(int exit_id) { struct beamenu_node *o; o = beamenu_get(-1); diff --git a/src/gtk/nav.h b/src/gtk/nav.h @@ -23,6 +23,7 @@ int kee_nav_init(const char *path); int kee_nav_set(GtkWidget *, int idx); int kee_nav_unset(int idx); GtkWidget* kee_nav_get(); +int kee_nav_get_stack_idx(int idx); int kee_nav_get_idx(); char* kee_nav_get_label(); GtkWidget* kee_nav_back(); // returns new current widget