Default key display patch
Andy Ruddock
andy.ruddock at minnesund.net
Sun Nov 23 11:48:04 CET 2003
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
I've attached a small patch I wrote for gpa, which displays the users
current default key in the keylist with a red/blue key icon to
distinguish it from other secret keys that the user may have on their
keyring.
I also added a "Set As Default _Key" option to both the menubar and the
context menu for the keylist.
Details are in the changelog.
The patch is against the 0.7.0 source.
- --
Andy Ruddock
- ------------
Senior Software Developer (andy.ruddock at minnesund.net)
PGP Key IDs : RSA(legacy)=0x87A2EE71 RSA=0x9B1B9423 DH/DSS=0xAFAB32A7
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQE/wJBTRVHR7k5QlSARAiQCAJ0X22Pj83/Jswu+13EsUDPvnfm4jgCgjPs2
97xJbOflFH8eFDMNGnUsNn8=
=nDvH
-----END PGP SIGNATURE-----
-------------- next part --------------
diff -Naur gpa-0.7.0/ChangeLog gpa-0.7.0-apr/ChangeLog
--- gpa-0.7.0/ChangeLog 2003-10-22 13:37:20.000000000 +0200
+++ gpa-0.7.0-apr/ChangeLog 2003-11-23 11:37:12.000000000 +0100
@@ -1,3 +1,15 @@
+2003-11-23 Andy Ruddock <andy.ruddock at minnesund.net>
+ * red_blue_key.xpm: New file for users default key
+ * gpa_red_key.xpm: New file for consistency
+ * icons.c: Added blue_red_key
+ * keylist.c: Added secret_default_pixbuf for default key image
+ Added check for secret key being users default key
+ * keyring.c: Added keyring_editor_can_default, returns true
+ if selected key could be a default key.
+ Added "/Keys/Set As Default _Key" to menu.
+ Added "/Set As Default _Key" to keylist context menu.
+ Added handler for setting default key and updating the keylist.
+
2003-10-22 Miguel Coca <mcoca at gnu.org>
* configure.ac: Release 0.7.0.
diff -Naur gpa-0.7.0/pixmaps/blue_red_key.xpm gpa-0.7.0-apr/pixmaps/blue_red_key.xpm
--- gpa-0.7.0/pixmaps/blue_red_key.xpm 1970-01-01 01:00:00.000000000 +0100
+++ gpa-0.7.0-apr/pixmaps/blue_red_key.xpm 2003-03-22 00:29:11.000000000 +0100
@@ -0,0 +1,56 @@
+/* XPM */
+static char * blue_red_key_xpm[] = {
+"22 14 39 1",
+" c None",
+". c #AAAAAA",
+"+ c #555129",
+"@ c #000000",
+"# c #554E12",
+"$ c #FF0000",
+"% c #7F007F",
+"& c #514C24",
+"* c #555555",
+"= c #AAA67E",
+"- c #7F0000",
+"; c #8E8E8E",
+"> c #7F7F7F",
+", c #393939",
+"' c #2B2B2B",
+") c #9C9C9C",
+"! c #707070",
+"~ c #47421A",
+"{ c #737575",
+"] c #6E7171",
+"^ c #868E8E",
+"/ c #9EAAAA",
+"( c #DAFFFF",
+"_ c #BCD5D5",
+": c #5C5F5F",
+"< c #716C45",
+"[ c #8C9C9C",
+"} c #3B3F3F",
+"| c #92AAAA",
+"1 c #495555",
+"2 c #404949",
+"3 c #353939",
+"4 c #3F4747",
+"5 c #697171",
+"6 c #545959",
+"7 c #828484",
+"8 c #303030",
+"9 c #B9B9B9",
+"0 c #D5D5D5",
+" .+@@+ ",
+" .#$$$%&. ",
+" .********@%$$$$$& ",
+" =%$$$$$$$$$$$$#@--; ",
+" @$$$$$$$$$$$$$@>--, ",
+" %#-#@--#--%$$$%#%-' ",
+" )**>>!>*!!~$$$$$$~{. ",
+" ]^/((_/((:~%$$$#<[} ",
+" }|||1||(11*~@@~*{|2 ",
+" )344'354*>67>>>/(18 ",
+" )>;);9>0 >1((((|4) ",
+" 341114>0 ",
+" )>''*>0 ",
+" ... "};
diff -Naur gpa-0.7.0/pixmaps/gpa_red_key.xpm gpa-0.7.0-apr/pixmaps/gpa_red_key.xpm
--- gpa-0.7.0/pixmaps/gpa_red_key.xpm 1970-01-01 01:00:00.000000000 +0100
+++ gpa-0.7.0-apr/pixmaps/gpa_red_key.xpm 2003-11-07 11:58:58.000000000 +0100
@@ -0,0 +1,18 @@
+/* XPM */
+static char * gpa_red_key_xpm[] = {
+"22 11 4 1",
+" c None",
+". c #000000",
+"+ c #FF0000",
+"@ c #72706F",
+" . ",
+" .+. ",
+" ..+++.. ",
+" ............++++++. ",
+" .++++++++++++++++.++.",
+".++++++++++++++++. at .+.",
+"@.+.+...+...++++++.+.@",
+" @. at .@. at .@@@..+++++.@@",
+" @@@ @ @@ @.+++++.@ ",
+" @.+++.@@ ",
+" @...@@@ "};
diff -Naur gpa-0.7.0/src/icons.c gpa-0.7.0-apr/src/icons.c
--- gpa-0.7.0/src/icons.c 2003-06-21 11:29:49.000000000 +0200
+++ gpa-0.7.0-apr/src/icons.c 2003-11-07 14:04:30.000000000 +0100
@@ -27,6 +27,7 @@
#include "icons.h"
#include "verify.xpm"
#include "blue_key.xpm"
+#include "blue_red_key.xpm"
#include "blue_yellow_key.xpm"
#include "brief.xpm"
#include "decrypt.xpm"
@@ -61,6 +62,7 @@
{"gpa_blue_key", gpa_blue_key_xpm},
{"gpa_yellow_key", gpa_yellow_key_xpm},
{"blue_key", blue_key_xpm},
+ {"blue_red_key", blue_red_key_xpm},
{"blue_yellow_key", blue_yellow_key_xpm},
{"export", export_xpm},
{"import", import_xpm},
diff -Naur gpa-0.7.0/src/keylist.c gpa-0.7.0-apr/src/keylist.c
--- gpa-0.7.0/src/keylist.c 2003-10-12 13:10:53.000000000 +0200
+++ gpa-0.7.0-apr/src/keylist.c 2003-11-07 14:48:25.000000000 +0100
@@ -460,11 +460,13 @@
{
static gboolean pixmaps_created = FALSE;
static GdkPixbuf *secret_pixbuf = NULL;
+ static GdkPixbuf *secret_default_pixbuf = NULL;
static GdkPixbuf *public_pixbuf = NULL;
if (!pixmaps_created)
{
secret_pixbuf = gpa_create_icon_pixbuf ("blue_yellow_key");
+ secret_default_pixbuf = gpa_create_icon_pixbuf ("blue_red_key");
public_pixbuf = gpa_create_icon_pixbuf ("blue_key");
pixmaps_created = TRUE;
}
@@ -473,7 +475,15 @@
(gpa_keytable_get_secret_instance(),
key->subkeys->fpr) != NULL)
{
- return secret_pixbuf;
+ /* Determine if this secret key is the default key */
+ if (g_str_equal (key->subkeys->fpr,gpa_options_get_default_key(gpa_options_get_instance())->subkeys->fpr))
+ {
+ return secret_default_pixbuf;
+ }
+ else
+ {
+ return secret_pixbuf;
+ }
}
else
{
diff -Naur gpa-0.7.0/src/keyring.c gpa-0.7.0-apr/src/keyring.c
--- gpa-0.7.0/src/keyring.c 2003-10-22 13:19:10.000000000 +0200
+++ gpa-0.7.0-apr/src/keyring.c 2003-11-23 11:37:48.000000000 +0100
@@ -463,6 +463,41 @@
}
}
+
+/* Return TRUE if selected key can be set as default */
+static gboolean
+keyring_editor_can_default (gpointer param)
+{
+ gboolean result = FALSE;
+
+ result = keyring_editor_has_private_selected (param);
+ //TODO: Check if selected key is currently default & grey menuitem if it is
+
+ return result;
+} /* keyring_editor_can_default */
+
+
+/* Set selected key as default */
+static void
+keyring_editor_default (gpointer param)
+{
+ GPAKeyringEditor * editor = param;
+ gpgme_key_t key = keyring_editor_current_key (editor);
+
+ if (!keyring_editor_has_private_selected (param))
+ {
+ /* this shouldn't happen because the button should be grayed out
+ * in this case
+ */
+ gpa_window_error (_("Unable to make key default."), editor->window);
+ return;
+ }
+ else
+ {
+ gpa_options_set_default_key (gpa_options_get_instance (), key);
+ }
+}
+
static void
keyring_editor_trust (gpointer param)
{
@@ -840,6 +875,7 @@
{_("/Keys/sep1"), NULL, NULL, 0, "<Separator>"},
{_("/Keys/_Sign Keys..."), NULL, keyring_editor_sign, 0, NULL},
{_("/Keys/Set _Owner Trust..."), NULL, keyring_editor_trust, 0, NULL},
+ {_("/Keys/Set As Default _Key..."), NULL, keyring_editor_default, 0, NULL},
{_("/Keys/_Edit Private Key..."), NULL, keyring_editor_edit, 0, NULL},
{_("/Keys/sep2"), NULL, NULL, 0, "<Separator>"},
{_("/Keys/_Import Keys..."), NULL, keyring_editor_import, 0, NULL},
@@ -927,6 +963,14 @@
add_selection_sensitive_widget (editor, item,
keyring_editor_can_sign);
}
+ /* If the key can be made the default key */
+ item = gtk_item_factory_get_widget (GTK_ITEM_FACTORY(factory),
+ _("/Keys/Set As Default Key..."));
+ if (item)
+ {
+ add_selection_sensitive_widget (editor, item,
+ keyring_editor_can_default);
+ }
/* If the selected key has a private key */
item = gtk_item_factory_get_widget (GTK_ITEM_FACTORY(factory),
_("/Keys/Edit Private Key..."));
@@ -962,6 +1006,7 @@
{"/sep1", NULL, NULL, 0, "<Separator>"},
{_("/_Sign Keys..."), NULL, keyring_editor_sign, 0, NULL},
{_("/Set _Owner Trust..."), NULL, keyring_editor_trust, 0, NULL},
+ {_("/Set As Default _Key..."), NULL, keyring_editor_default, 0, NULL},
{_("/_Edit Private Key..."), NULL, keyring_editor_edit, 0, NULL},
{"/sep2", NULL, NULL, 0, "<Separator>"},
{_("/E_xport Keys..."), NULL, keyring_editor_export, 0, NULL},
@@ -991,6 +1036,14 @@
add_selection_sensitive_widget (editor, item,
keyring_editor_can_sign);
}
+ /* If the key can be made the default key */
+ item = gtk_item_factory_get_widget (GTK_ITEM_FACTORY(factory),
+ _("/Set As Default Key..."));
+ if (item)
+ {
+ add_selection_sensitive_widget (editor, item,
+ keyring_editor_can_default);
+ }
/* If the selected key has a private key */
item = gtk_item_factory_get_widget (GTK_ITEM_FACTORY(factory),
_("/Edit Private Key..."));
@@ -1711,7 +1764,10 @@
GPAKeyringEditor * editor = param;
keyring_update_status_bar (editor);
- update_selection_sensitive_widgets (editor);
+ update_selection_sensitive_widgets (editor);
+
+ gpa_keylist_start_reload(editor->keylist);
+
}
/* signal handler for the "changed_ui_mode" signal. Disable the subkeys
@@ -1856,4 +1912,3 @@
return window;
} /* keyring_editor_new */
-
More information about the Gpa-dev
mailing list