kee

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

commit 1743dc6b54511a28ab9d0d6392ef0973a368f7e4
parent 99a66135a4e7f00c4181e9b86313fbd41d7b1e74
Author: lash <dev@holbrook.no>
Date:   Mon, 22 Apr 2024 22:04:49 +0100

Remove duplicates in entry display view

Diffstat:
Msrc/content.c | 4+++-
Msrc/gtk/kee-entry-item.c | 3++-
Msrc/gtk/kee-entry-list.c | 11++++++-----
Msrc/gtk/kee-entry.c | 14+++++++++-----
Msrc/gtk/kee-entry.h | 3+--
Msrc/ledger.c | 1+
6 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/src/content.c b/src/content.c @@ -34,9 +34,11 @@ int kee_content_resolve(struct kee_content_t *content, Cadiz *cadiz) { size_t c; content->flags = 0; - c = content->mem_size; + c = content->mem_size - 1; r = cadiz_resolve(cadiz, content->key, content->body, &c); if (!r) { + *(content->body+c) = 0; + c -= 1; content->mem_size -= c; content->flags |= KEE_CONTENT_RESOLVED_DATA; msg = cmime_message_new(); diff --git a/src/gtk/kee-entry-item.c b/src/gtk/kee-entry-item.c @@ -92,7 +92,8 @@ void kee_entry_item_apply_list_item_widget(KeeEntryItem *o) { //sprintf(o->header, "%s [%s]\n%s (%s)", o->ledger.content.subject, o->ledger.uoa, o->bob_dn.cn, o->bob_dn.uid); kee_content_resolve(&o->item->content, o->resolver); - widget = gtk_label_new(o->item->content.subject); + //widget = gtk_label_new(o->item->content.subject); + widget = gtk_label_new("foo"); gtk_box_append(GTK_BOX(o), widget); return; } diff --git a/src/gtk/kee-entry-list.c b/src/gtk/kee-entry-list.c @@ -29,12 +29,13 @@ static void kee_entry_list_handle_select(GtkListView *view, guint i, KeeMenu *me g_object_take_ref(G_OBJECT(o)); container = kee_menu_next(menu, "entry"); - widget = gtk_widget_get_first_child(container); - if (widget) { - gtk_box_remove(GTK_BOX(container), widget); + if (!kee_entry_apply_display_widget(o)) { + widget = gtk_widget_get_first_child(container); + if (widget) { + gtk_box_remove(GTK_BOX(container), widget); + } + gtk_box_append(GTK_BOX(container), GTK_WIDGET(o)); } - kee_entry_apply_display_widget(o); - gtk_box_append(GTK_BOX(container), GTK_WIDGET(o)); g_log(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "list item selected %d", i); } diff --git a/src/gtk/kee-entry.c b/src/gtk/kee-entry.c @@ -46,6 +46,7 @@ struct _KeeEntry { int bob_credit_balance; int alice_collateral_balance; int bob_collateral_balance; + int is_displaying; struct db_ctx *db; }; @@ -117,6 +118,7 @@ static void kee_entry_class_init(KeeEntryClass *kls) { static void kee_entry_init(KeeEntry *o) { o->state = 2; o->resolver = NULL; + o->is_displaying = 0; } KeeEntry* kee_entry_new(struct db_ctx *db) { @@ -197,19 +199,21 @@ void kee_entry_apply_list_item_widget(KeeEntry *o) { sprintf(o->header, "%s [%s]\n%s (%s)", o->ledger.content.subject, o->ledger.uoa, o->bob_dn.cn, o->bob_dn.uid); widget = gtk_label_new(o->header); gtk_box_append(GTK_BOX(o), widget); + o->is_displaying = 0; return; } -void kee_entry_apply_display_widget(KeeEntry *o) { +int kee_entry_apply_display_widget(KeeEntry *o) { GtkWidget *widget; GtkSingleSelection *sel; GtkListItemFactory *factory; KeeEntryItemStore *model; - widget = gtk_label_new(o->ledger.content.subject); - gtk_box_append(GTK_BOX(o), widget); + if (o->is_displaying) { + return 1; + } + o->is_displaying = 1; - return; factory = gtk_signal_list_item_factory_new(); g_signal_connect(factory, "setup", G_CALLBACK(kee_entry_handle_item_setup), NULL); g_signal_connect(factory, "bind", G_CALLBACK(kee_entry_handle_item_bind), NULL); @@ -218,5 +222,5 @@ void kee_entry_apply_display_widget(KeeEntry *o) { sel = gtk_single_selection_new(G_LIST_MODEL(model)); widget = gtk_list_view_new(GTK_SELECTION_MODEL(sel), GTK_LIST_ITEM_FACTORY(factory)); gtk_box_append(GTK_BOX(o), widget); - return; + return 0; } diff --git a/src/gtk/kee-entry.h b/src/gtk/kee-entry.h @@ -28,10 +28,9 @@ int kee_entry_load(KeeEntry *o, struct db_ctx *db, const char *id); //int kee_entry_deserialize(KeeEntry *o, const char *key, size_t key_len, const char *data, size_t data_len); int kee_entry_deserialize(KeeEntry *o, const char *data, size_t data_len); void kee_entry_apply_list_item_widget(KeeEntry *o); -void kee_entry_apply_display_widget(KeeEntry *o); +int kee_entry_apply_display_widget(KeeEntry *o); KeeEntry* kee_entry_new(struct db_ctx *db); void kee_entry_set_resolver(KeeEntry *o, struct Cadiz *resolver); -void kee_entry_apply_entry(KeeEntry *target, KeeEntry *orig); G_END_DECLS diff --git a/src/ledger.c b/src/ledger.c @@ -287,6 +287,7 @@ struct kee_ledger_item_t *kee_ledger_parse_item(struct kee_ledger_t *ledger, con if (r != ASN1_SUCCESS) { return NULL; } + r = kee_content_init(&(cur->content), tmp, 0); if (r) { return NULL;