Commit f199d6c8 authored by Stefan Walter's avatar Stefan Walter

DBUS work. Bring libcryptui key chooser on par with libseahorse key

    * libcryptui/cryptui-key-chooser.c:
    * libcryptui/cryptui-key-list.c:
    * libcryptui/cryptui-test-ui.c: DBUS work. Bring libcryptui key chooser
    on par with libseahorse key chooser.
parent 8811c69b
2006-04-11 Nate Nielsen <nielsen@memberwebs.com>
* libcryptui/cryptui-key-chooser.c:
* libcryptui/cryptui-key-list.c:
* libcryptui/cryptui-test-ui.c: DBUS work. Bring libcryptui key chooser
on par with libseahorse key chooser.
2006-04-11 Nate Nielsen <nielsen@memberwebs.com>
* libseahorse/seahorse-pgp-key-op.c:
......
......@@ -21,6 +21,7 @@
#include "config.h"
#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
#include "cryptui-key-list.h"
#include "cryptui-key-combo.h"
......@@ -34,8 +35,12 @@ enum {
struct _CryptUIKeyChooserPriv {
gboolean initialized;
CryptUIKeyset *ckset;
CryptUIKeyStore *ckstore;
GtkTreeView *keylist;
GtkComboBox *keycombo;
GtkComboBox *filtermode;
GtkEntry *filtertext;
};
G_DEFINE_TYPE (CryptUIKeyChooser, cryptui_key_chooser, GTK_TYPE_VBOX);
......@@ -58,45 +63,126 @@ signer_filter (CryptUIKeyset *ckset, const gchar *key, gpointer user_data)
return flags & CRYPTUI_FLAG_CAN_SIGN;
}
static void
filtertext_changed (GtkWidget *widget, CryptUIKeyChooser *chooser)
{
const gchar *text = gtk_entry_get_text (chooser->priv->filtertext);
g_object_set (chooser->priv->ckstore, "search", text, NULL);
}
static void
filtertext_activate (GtkEntry *entry, CryptUIKeyChooser *chooser)
{
gtk_widget_grab_focus (GTK_WIDGET (chooser->priv->keylist));
}
static void
filtermode_changed (GtkWidget *widget, CryptUIKeyChooser *chooser)
{
gint active = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
if (active >= 0)
g_object_set (chooser->priv->ckstore, "mode", active, NULL);
}
static void
construct_recipients (CryptUIKeyChooser *chooser, GtkBox *box)
{
CryptUIKeyStore *ckstore;
GtkWidget *scroll;
GtkWidget *label;
GtkWidget *hbox;
/* Top filter box */
hbox = gtk_hbox_new (FALSE, 12);
/* TODO: The key search widgets need to be implemented */
/* TODO: Labels need to be added where appropriate */
/* TODO: HIG and beautification */
/* Filter Combo */
chooser->priv->filtermode = GTK_COMBO_BOX (gtk_combo_box_new_text ());
gtk_combo_box_append_text (chooser->priv->filtermode, _("All Keys"));
gtk_combo_box_append_text (chooser->priv->filtermode, _("Selected Recipients"));
gtk_combo_box_append_text (chooser->priv->filtermode, _("Search Results"));
gtk_combo_box_set_active (chooser->priv->filtermode, 0);
g_signal_connect (chooser->priv->filtermode, "changed",
G_CALLBACK (filtermode_changed), chooser);
gtk_widget_set_size_request (GTK_WIDGET (chooser->priv->filtermode), 140, -1);
gtk_container_add (GTK_CONTAINER (hbox), GTK_WIDGET (chooser->priv->filtermode));
gtk_box_set_child_packing (GTK_BOX (hbox), GTK_WIDGET (chooser->priv->filtermode),
FALSE, TRUE, 0, GTK_PACK_START);
ckstore = cryptui_key_store_new (chooser->priv->ckset, TRUE, NULL);
cryptui_key_store_set_filter (ckstore, recipients_filter, NULL);
chooser->priv->keylist = cryptui_key_list_new (ckstore, CRYPTUI_KEY_LIST_CHECKS);
g_object_unref (ckstore);
/* Filter Label */
label = gtk_label_new (_("Search _for:"));
gtk_label_set_use_underline (GTK_LABEL (label), TRUE);
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_container_add (GTK_CONTAINER (hbox), label);
gtk_box_set_child_packing (GTK_BOX (hbox), label,
TRUE, TRUE, 0, GTK_PACK_START);
/* Filter Entry */
chooser->priv->filtertext = GTK_ENTRY (gtk_entry_new ());
gtk_entry_set_max_length (chooser->priv->filtertext, 256);
gtk_widget_set_size_request (GTK_WIDGET (chooser->priv->filtertext), 140, -1);
g_signal_connect (chooser->priv->filtertext, "changed",
G_CALLBACK (filtertext_changed), chooser);
g_signal_connect (chooser->priv->filtertext, "activate",
G_CALLBACK (filtertext_activate), chooser);
gtk_container_add (GTK_CONTAINER (hbox), GTK_WIDGET (chooser->priv->filtertext));
gtk_box_set_child_packing (GTK_BOX (hbox), GTK_WIDGET (chooser->priv->filtertext),
FALSE, TRUE, 0, GTK_PACK_START);
/* Add Filter box */
gtk_container_add (GTK_CONTAINER (box), hbox);
gtk_box_set_child_packing (GTK_BOX (box), hbox,
FALSE, TRUE, 0, GTK_PACK_START);
gtk_container_add (GTK_CONTAINER (box), GTK_WIDGET (chooser->priv->keylist));
gtk_box_set_child_packing (box, GTK_WIDGET (chooser->priv->keylist), TRUE,
TRUE, 0, GTK_PACK_START);
chooser->priv->ckstore = cryptui_key_store_new (chooser->priv->ckset, TRUE, NULL);
cryptui_key_store_set_filter (chooser->priv->ckstore, recipients_filter, NULL);
/* Main Key list */
chooser->priv->keylist = cryptui_key_list_new (chooser->priv->ckstore,
CRYPTUI_KEY_LIST_CHECKS);
gtk_tree_view_set_enable_search (GTK_TREE_VIEW (chooser->priv->keylist), FALSE);
scroll = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), GTK_SHADOW_IN);
gtk_container_add (GTK_CONTAINER (scroll), GTK_WIDGET (chooser->priv->keylist));
gtk_container_add (GTK_CONTAINER (box), scroll);
gtk_box_set_child_packing (box, scroll, TRUE, TRUE, 0, GTK_PACK_START);
}
static void
construct_signer (CryptUIKeyChooser *chooser, GtkBox *box)
{
CryptUIKeyStore *ckstore;
GtkWidget *hbox;
GtkWidget *label;
/* Top filter box */
hbox = gtk_hbox_new (FALSE, 12);
/* Sign Label */
label = gtk_label_new (_("_Sign message as:"));
gtk_label_set_use_underline (GTK_LABEL (label), TRUE);
gtk_container_add (GTK_CONTAINER (hbox), label);
gtk_box_set_child_packing (GTK_BOX (hbox), label,
FALSE, TRUE, 0, GTK_PACK_START);
/* TODO: Label needs to be added */
/* TODO: HIG and beautification */
/* TODO: When only one key is present this should be a checkbox
ie: 'Sign this Message (as 'key name') */
/* TODO: i18n */
ckstore = cryptui_key_store_new (chooser->priv->ckset, TRUE, "None (Don't Sign)");
/* The Sign combo */
ckstore = cryptui_key_store_new (chooser->priv->ckset, TRUE, _("None (Don't Sign)"));
cryptui_key_store_set_filter (ckstore, signer_filter, NULL);
chooser->priv->keycombo = cryptui_key_combo_new (ckstore);
g_object_unref (ckstore);
gtk_container_add (GTK_CONTAINER (box), GTK_WIDGET (chooser->priv->keycombo));
gtk_box_set_child_packing (box, GTK_WIDGET (chooser->priv->keycombo), FALSE,
TRUE, 0, GTK_PACK_START);
gtk_container_add (GTK_CONTAINER (hbox), GTK_WIDGET (chooser->priv->keycombo));
gtk_box_set_child_packing (GTK_BOX (hbox), GTK_WIDGET (chooser->priv->keycombo),
TRUE, TRUE, 0, GTK_PACK_START);
/* Add it in */
gtk_container_add (GTK_CONTAINER (box), hbox);
gtk_box_set_child_packing (box, hbox, FALSE, TRUE, 0, GTK_PACK_START);
}
/* -----------------------------------------------------------------------------
......@@ -136,10 +222,13 @@ cryptui_key_chooser_dispose (GObject *gobject)
{
CryptUIKeyChooser *chooser = CRYPTUI_KEY_CHOOSER (gobject);
if (chooser->priv->ckset) {
if (chooser->priv->ckset)
g_object_unref (chooser->priv->ckset);
chooser->priv->ckset = NULL;
}
chooser->priv->ckset = NULL;
if (chooser->priv->ckstore)
g_object_unref (chooser->priv->ckstore);
chooser->priv->ckstore = NULL;
G_OBJECT_CLASS (cryptui_key_chooser_parent_class)->dispose (gobject);
}
......
......@@ -118,6 +118,9 @@ cryptui_key_list_setup (GtkTreeView *view, CryptUIKeyStore *ckstore,
col = append_text_column (view, "Name", CRYPTUI_KEY_STORE_NAME);
append_text_column (view, "Key ID", CRYPTUI_KEY_STORE_KEYID);
gtk_tree_view_column_set_sort_column_id (col, CRYPTUI_KEY_STORE_NAME);
gtk_tree_view_set_rules_hint (view, TRUE);
gtk_widget_set_size_request (GTK_WIDGET (view), 500, 250);
}
GList*
......
......@@ -66,6 +66,8 @@ show_chooser_dialog (CryptUIKeyset *keyset)
{
CryptUIKeyChooser *chooser;
GtkWidget *dialog;
GList *recipients, *l;
const gchar *signer;
dialog = gtk_dialog_new_with_buttons ("CryptUI Test", NULL, GTK_DIALOG_MODAL,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);
......@@ -75,6 +77,16 @@ show_chooser_dialog (CryptUIKeyset *keyset)
gtk_widget_show_all (dialog);
gtk_dialog_run (GTK_DIALOG (dialog));
recipients = cryptui_key_chooser_get_recipients (chooser);
for (l = recipients; l; l = g_list_next (l))
g_print ("RECIPIENT: %s\n", (char*)(l->data));
g_list_free (recipients);
signer = cryptui_key_chooser_get_signer (chooser);
g_print ("SIGNER: %s\n", signer);
gtk_widget_destroy (dialog);
}
int
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment