diff options
Diffstat (limited to 'plugins/openpgp')
-rw-r--r-- | plugins/openpgp/data/account_settings_item.ui | 1 | ||||
-rw-r--r-- | plugins/openpgp/src/account_settings_widget.vala | 32 |
2 files changed, 18 insertions, 15 deletions
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 @@ <child> <object class="GtkButton" id="button"> <property name="relief">none</property> + <property name="sensitive">False</property> <property name="visible">True</property> <child> <object class="GtkLabel" id="label"> 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\n<span font='9'>Select key</span>", 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))\n<span font='9'>0x$(Markup.escape_text(keys[i].fpr[0:16]))</span>"); + 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<void*> (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...\n<span font='9'>Querying GnuPG</span>"); - 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\n<span font='9'>Error in GnuPG</span>", 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<span font='9'>$(Markup.escape_text(secondary))</span>"; + } } }
\ No newline at end of file |