diff --git a/plugins/openpgp/data/account_settings_item.ui b/plugins/openpgp/data/account_settings_item.ui index 0c10b84b..f9757c2b 100644 --- a/plugins/openpgp/data/account_settings_item.ui +++ b/plugins/openpgp/data/account_settings_item.ui @@ -5,6 +5,7 @@ none + False True diff --git a/plugins/openpgp/src/account_settings_widget.vala b/plugins/openpgp/src/account_settings_widget.vala index 5340db30..1ebf5c58 100644 --- a/plugins/openpgp/src/account_settings_widget.vala +++ b/plugins/openpgp/src/account_settings_widget.vala @@ -66,44 +66,42 @@ private class AccountSettingsWidget : Stack, Plugins.AccountSettingsWidget { } private void populate_list_store() { + if (keys.size == 0) { + label.set_markup(build_markup_string("Key publishing disabled", "No keys available. Generate one!")); + return; + } + TreeIter iter; list_store.append(out iter); - list_store.set(iter, 0, "Disabled\nSelect key", 1, null); - set_label_active(iter, 0); + list_store.set(iter, 0, build_markup_string("Key publishing disabled", "Select key"), 1, ""); for (int i = 0; i < keys.size; i++) { list_store.append(out iter); - list_store.set(iter, 0, @"$(Markup.escape_text(keys[i].uids[0].uid))\n0x$(Markup.escape_text(keys[i].fpr[0:16]))"); + list_store.set(iter, 0, build_markup_string(keys[i].uids[0].uid, keys[i].fpr[0:16])); list_store.set(iter, 1, keys[i].fpr); if (keys[i].fpr == plugin.db.get_account_key(current_account)) { set_label_active(iter, i + 1); } } activate_current_account(); + button.sensitive = true; } private void fetch_keys() { + TreeIter iter; + list_store.clear(); + list_store.append(out iter); + label.set_markup(build_markup_string("Loading...", "Querying GnuPG")); new Thread (null, () => { // Querying GnuPG might take some while - Idle.add(() => { - TreeIter iter; - list_store.clear(); - list_store.append(out iter); - button.sensitive = false; - label.set_markup("Loading...\nQuerying GnuPG"); - return false; - }); try { keys = GPGHelper.get_keylist(null, true); Idle.add(() => { list_store.clear(); populate_list_store(); - button.sensitive = true; return false; }); } catch (Error e) { Idle.add(() => { - TreeIter iter; - list_store.append(out iter); - list_store.set(iter, 0, @"Disabled\nError in GnuPG", 1, null); + label.set_markup(build_markup_string("Key publishing disabled", "Error in GnuPG")); return false; }); } @@ -135,6 +133,10 @@ private class AccountSettingsWidget : Stack, Plugins.AccountSettingsWidget { deactivate(); } } + + private string build_markup_string(string primary, string secondary) { + return @"$(Markup.escape_text(primary))\n$(Markup.escape_text(secondary))"; + } } } \ No newline at end of file