commit eb6067ef85c20a0ac968ea6db2ac3415e88cca9f
parent 4b102d21fc7a3afd1f0366ffacadbb589a433076
Author: lash <dev@holbrook.no>
Date: Thu, 4 Apr 2024 14:30:25 +0100
Deactivate back button on view, remove compile warnings
Diffstat:
7 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/src/cadir.c b/src/cadir.c
@@ -16,7 +16,6 @@ int cadiz_resolve(Cadiz *cadiz, const char *key, char *out, size_t *out_len) {
char path[1024];
size_t l;
const char *locator = cadiz->locator;
- enum CadizKeyType key_type = cadiz->key_type;
strcpy(path, locator);
c = strlen(locator) - 1;
diff --git a/src/db.c b/src/db.c
@@ -198,6 +198,7 @@ int db_next(struct db_ctx *ctx, enum DbKey pfx, char **key, size_t *key_len, cha
}
+/// \todo find better name
void db_rewind(struct db_ctx *ctx) {
ctx->browsing = 0;
}
diff --git a/src/gtk/kee-entry-list.c b/src/gtk/kee-entry-list.c
@@ -36,7 +36,7 @@ static void kee_entry_list_handle_select(GtkListView *view, guint i, KeeMenu *me
gtk_box_remove(GTK_BOX(container), widget);
}
kee_entry_apply_display_widget(showentry);
- gtk_box_append(GTK_BOX(container), showentry);
+ gtk_box_append(GTK_BOX(container), GTK_WIDGET(showentry));
g_log(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "list item selected %d", i);
}
@@ -49,7 +49,7 @@ static void kee_entry_list_handle_setup(GtkListItemFactory* o, GtkListItem *item
static void kee_entry_list_handle_bind(GtkListItemFactory *o, GtkListItem *item) {
KeeEntry *go;
- GtkGesture *ctrl;
+ //GtkGesture *ctrl;
g_log(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "entry list bind");
go = gtk_list_item_get_item(item);
diff --git a/src/gtk/kee-entry.c b/src/gtk/kee-entry.c
@@ -5,6 +5,7 @@
#include <gtk/gtk.h>
#include "cmime.h"
+#include "varint.h"
#include "kee-entry.h"
#include "db.h"
@@ -56,7 +57,7 @@ static void kee_entry_handle_item_bind(GtkListItemFactory *o, GtkListItem *item
label = gtk_list_item_get_child(item);
s = gtk_list_item_get_item(item);
- gtk_label_set_label(label, gtk_string_object_get_string(s));
+ gtk_label_set_label(GTK_LABEL(label), gtk_string_object_get_string(s));
}
/// \todo free reference to self from parent box necessary..?
@@ -101,7 +102,6 @@ void kee_entry_set_resolver(KeeEntry *o, struct Cadiz *resolver) {
/// \todo replace with struct
static int kee_entry_deserialize_item(KeeEntry *o, const char *data, size_t data_len, char *out, size_t *out_len) {
- GtkWidget *item;
int remaining;
int r;
uint64_t alice_u;
@@ -201,7 +201,7 @@ static int kee_entry_deserialize_item(KeeEntry *o, const char *data, size_t data
// return ERR_FAIL;
// }
- sprintf(out, "alice %i bob %i", alice, bob);
+ sprintf(out, "alice %lli bob %lli", alice, bob);
*out_len = strlen(out);
//item = gtk_label_new(s);
@@ -306,7 +306,6 @@ void kee_entry_apply_list_item_widget(KeeEntry *o) {
}
static int kee_entry_load_items(KeeEntry *o, GtkStringList *list) {
- GtkWidget *widget;
int r;
size_t key_len;
char *mem = malloc(4096);
@@ -336,13 +335,15 @@ static int kee_entry_load_items(KeeEntry *o, GtkStringList *list) {
gtk_string_list_append(list, out);
}
}
+ db_rewind(o->db);
free(mem);
+ return ERR_OK;
}
void kee_entry_apply_display_widget(KeeEntry *o) {
GtkWidget *widget;
GtkNoSelection *sel;
- GtkSignalListItemFactory *factory;
+ GtkListItemFactory *factory;
GtkStringList *list;
list = gtk_string_list_new(NULL);
@@ -355,17 +356,15 @@ void kee_entry_apply_display_widget(KeeEntry *o) {
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);
- sel = gtk_no_selection_new(list);
+ sel = gtk_no_selection_new(G_LIST_MODEL(list));
- widget = gtk_list_view_new(sel, factory);
+ widget = gtk_list_view_new(GTK_SELECTION_MODEL(sel), GTK_LIST_ITEM_FACTORY(factory));
gtk_box_append(GTK_BOX(o), widget);
return;
}
void kee_entry_apply_entry(KeeEntry *target, KeeEntry *orig) {
- KeeEntry *o;
-
target->db = orig->db;
target->current_id = orig->current_id;
target->resolver = orig->resolver;
@@ -373,6 +372,6 @@ void kee_entry_apply_entry(KeeEntry *target, KeeEntry *orig) {
target->unit_of_account = orig->unit_of_account;
target->alice = orig->alice;
target->bob = orig->bob;
- return target;
+ return;
}
diff --git a/src/gtk/kee-entry.h b/src/gtk/kee-entry.h
@@ -30,6 +30,7 @@ void kee_entry_apply_list_item_widget(KeeEntry *o);
void 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/gtk/kee-menu.c b/src/gtk/kee-menu.c
@@ -98,6 +98,8 @@ static void kee_menu_header_update(KeeMenu *o, const char *label) {
} else if (!(strcmp(label, "view"))) {
act = g_action_map_lookup_action(G_ACTION_MAP(o), "import");
g_simple_action_set_enabled(G_SIMPLE_ACTION(act), true);
+ act = g_action_map_lookup_action(G_ACTION_MAP(o), "back");
+ g_simple_action_set_enabled(G_SIMPLE_ACTION(act), false);
} else if (!(strcmp(label, "entry"))) {
act = g_action_map_lookup_action(G_ACTION_MAP(o), "back");
g_simple_action_set_enabled(G_SIMPLE_ACTION(act), true);
diff --git a/src/gtk/nav.c b/src/gtk/nav.c
@@ -22,17 +22,17 @@ int kee_nav_push(struct KeeNav *nav, GtkWidget *page) {
nav->widgets[nav->c] = page;
nav->now = nav->widgets[nav->c];
// kee_nav_log(nav);
+ return 0;
}
GtkWidget* kee_nav_pop(struct KeeNav *nav) {
- GtkWidget *r;
-
if (nav->c == 0) {
return NULL;
}
- r = nav->widgets[nav->c];
+ //r = nav->widgets[nav->c];
nav->c--;
nav->now = nav->widgets[nav->c];
+ return nav->now;
// kee_nav_log(nav);
}