Browse Source

Enable searching for a user ID.

Allow the user to search through the list of public key for a
given user ID (or a user ID matching the searched string).
master
Damien Goutte-Gattat 2 years ago
parent
commit
1faf98bb64
  1. 15
      src/encrypt.c

15
src/encrypt.c

@ -101,6 +101,19 @@ public_key_toggled(GtkCellRendererToggle *renderer,
update_buttons(yki);
}
static gboolean
public_key_search(GtkTreeModel *model,
gint column,
const gchar *pattern,
GtkTreeIter *iter,
gpointer data)
{
gchar *uid;
gtk_tree_model_get(model, iter, 1, &uid, -1);
return g_strstr_len(uid, -1, pattern) ? FALSE : TRUE;
}
static GtkDialog *
create_encrypt_dialog(yki_encrypt_data_t *yki)
{
@ -120,6 +133,8 @@ create_encrypt_dialog(yki_encrypt_data_t *yki)
widget = gtk_builder_get_object(builder, "trvPublicKeys");
yki->public_keys = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(widget)));
gtk_tree_view_set_search_column(GTK_TREE_VIEW(widget), 1);
gtk_tree_view_set_search_equal_func(GTK_TREE_VIEW(widget), public_key_search, NULL, NULL);
renderer = gtk_cell_renderer_toggle_new();
column = gtk_tree_view_column_new_with_attributes("Selected", renderer, "active", 0, NULL);

Loading…
Cancel
Save