kee

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

commit 31d7e0fb51baf658999cb7b5a2e82a26eb9b4654
parent 4e187f7e6c3c012bfe74f57f349dbdeea55ff49b
Author: lash <dev@holbrook.no>
Date:   Sun, 26 May 2024 20:35:07 +0100

WIP New menu impl builds

Diffstat:
Msrc/Makefile | 2+-
Msrc/aux/beamenu/gen.c | 72++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------
Msrc/gtk/kee-menu.c | 2--
Msrc/gtk/nav.h | 4++--
Msrc/gtk/ui.c | 7++++---
Dsrc/gtk/view.c | 34----------------------------------
Dsrc/gtk/view.h | 18------------------
7 files changed, 67 insertions(+), 72 deletions(-)

diff --git a/src/Makefile b/src/Makefile @@ -6,7 +6,7 @@ LDFLAGS += $(LIBS) #all: aux resource $(OBJS) # $(CC) $(CFLAGS) main.c -o a.out $(OBJS) $(LDFLAGS) aux/varint/varint.o -all: aux $(OBJS) +all: asn aux $(OBJS) asn: make -C asn1 compile diff --git a/src/aux/beamenu/gen.c b/src/aux/beamenu/gen.c @@ -230,10 +230,8 @@ int write_data() { int write_defs() { char *p; - char *pr; struct beamenu_node *o; char buf[1024]; - char buf_r[1024]; char k[KEYMAXLEN + 1]; int c; int f; @@ -241,11 +239,6 @@ int write_defs() { int r; int i; - p = "\nchar *beamenu_dst_r[] = {\n"; - strcpy(buf_r, p); - l = strlen(p); - pr = buf_r + l; - f = open("beamenu_defs.h", O_WRONLY | O_CREAT, S_IRWXU); r = 0; @@ -262,8 +255,6 @@ int write_defs() { for (i = 0; i < BEAMENU_N_DST; i++) { o = beamenu_get(i); strcpy(k, o->cn); - c = sprintf(pr, "\t\"%s\",\n", k); - pr += c; r = uc(k); sprintf(buf, "#define BEAMENU_DST_%s %d\n", k, i); l = strlen(buf); @@ -274,9 +265,9 @@ int write_defs() { } r += c; } - sprintf(pr, "};\n"); - l = strlen(buf_r); - c = write(f, buf_r, l); + sprintf(buf, "\nextern char *beamenu_dst_r[];\n"); + l = strlen(buf); + c = write(f, buf, l); if (c != l) { close(f); return 0; @@ -298,6 +289,58 @@ int write_defs() { } +int write_impl() { + char *p; + struct beamenu_node *o; + char buf[1024]; + char k[KEYMAXLEN + 1]; + int r; + int c; + int i; + int l; + int f; + + f = open("beamenu_defs.c", O_WRONLY | O_CREAT, S_IRWXU); + + r = 0; + p = "char *beamenu_dst_r[] = {\n"; + strcpy(buf, p); + l = strlen(p); + c = write(f, buf, l); + if (c != l) { + close(f); + return 0; + } + r += c; + p += c; + + for (i = 0; i < BEAMENU_N_DST; i++) { + o = beamenu_get(i); + strcpy(k, o->cn); + sprintf(buf, "\t\"%s\",\n", k); + l = strlen(buf); + c = write(f, buf, l); + if (c != l) { + close(f); + return 0; + } + r += c; + } + + p = "};\n"; + strcpy(buf, p); + l = strlen(p); + c = write(f, buf, l); + if (c != l) { + close(f); + return 0; + } + r += c; + + close(f); + return r; +} + int main(int argc, char **argv) { int i; int r; @@ -381,5 +424,10 @@ int main(int argc, char **argv) { return 1; } + r = write_impl(); + if (!r) { + return 1; + } + return 0; } diff --git a/src/gtk/kee-menu.c b/src/gtk/kee-menu.c @@ -247,12 +247,10 @@ int kee_menu_set(KeeMenu *o, GtkWidget *widget) { int kee_menu_prev(KeeMenu *o) { GtkWidget *widget; - const char *label; widget = kee_nav_back(); gtk_stack_set_visible_child(o->stack, widget); - //label = gtk_stack_get_visible_child_name(o->stack); kee_menu_header_update(o, KEE_NAV_LABEL); return ERR_OK; diff --git a/src/gtk/nav.h b/src/gtk/nav.h @@ -6,7 +6,7 @@ #include <beamenu_defs.h> #define KEE_NAV_NOW kee_nav_get() -#define KEE_NAV_LABEL kee_nav_label() +#define KEE_NAV_LABEL kee_nav_get_label() #ifndef KEE_NAV_N_DST #define KEE_NAV_N_DST BEAMENU_N_DST + 1 @@ -19,7 +19,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(); -char* kee_nav_label(); +char* kee_nav_get_label(); GtkWidget* kee_nav_back(); // returns new current widget #endif // _KEE_NAV_H diff --git a/src/gtk/ui.c b/src/gtk/ui.c @@ -9,7 +9,7 @@ #include "settings.h" #include "context.h" #include "state.h" -#include "view.h" +//#include "view.h" #include "menu.h" #include "kee-import.h" #include "kee-entry-list.h" @@ -88,8 +88,9 @@ void ui_build(GtkApplication *gapp, struct kee_context *ctx) { widget = kee_entry_list_new(G_LIST_MODEL(ctx->entry_store), win); kee_menu_add(win, "view", widget); - kee_menu_next(win, "view"); - kee_menu_next(win, "unlock"); + //kee_menu_next(win, "view"); + kee_menu_next(win, BEAMENU_DST_LIST); + kee_menu_next(win, BEAMENU_DST_KEY); import = kee_import_new(win); kee_menu_add(win, "import", GTK_WIDGET(import)); diff --git a/src/gtk/view.c b/src/gtk/view.c @@ -1,34 +0,0 @@ -#include <gtk/gtk.h> - -#include "debug.h" -#include "view.h" -#include "nav.h" - -static struct KeeView view; - -void kee_view_init(GtkStack *stack) { - if (view.stack != NULL) { - return; - } - view.stack = stack; -} - -int kee_view_add(GtkWidget *widget, const char *label) { - gtk_stack_add_named(view.stack, widget, label); - return ERR_OK; -} - -int kee_view_next(const char *label) { - GtkWidget *widget; - - widget = gtk_stack_get_child_by_name(view.stack, label); - kee_nav_push(&view.nav, widget); - gtk_stack_set_visible_child(view.stack, widget); - return ERR_OK; -} - -int kee_view_prev() { - kee_nav_pop(&view.nav); - gtk_stack_set_visible_child(view.stack, view.nav.now); - return ERR_OK; -} diff --git a/src/gtk/view.h b/src/gtk/view.h @@ -1,18 +0,0 @@ -#ifndef _KEE_VIEW_H -#define _KEE_VIEW_H - -#include <gtk/gtk.h> - -#include "nav.h" - -struct KeeView { - GtkStack *stack; - struct KeeNav nav; -}; - -void kee_view_init(GtkStack *stack); -int kee_view_add(GtkWidget *widget, const char *label); -int kee_view_next(const char *label); -int kee_view_prev(); - -#endif // _KEE_VIEW_H