diff options
Diffstat (limited to 'plugins/openpgp/src/contact_details_provider.vala')
-rw-r--r-- | plugins/openpgp/src/contact_details_provider.vala | 49 |
1 files changed, 33 insertions, 16 deletions
diff --git a/plugins/openpgp/src/contact_details_provider.vala b/plugins/openpgp/src/contact_details_provider.vala index 9ec84c21..f2fa8f06 100644 --- a/plugins/openpgp/src/contact_details_provider.vala +++ b/plugins/openpgp/src/contact_details_provider.vala @@ -6,6 +6,7 @@ namespace Dino.Plugins.OpenPgp { public class ContactDetailsProvider : Plugins.ContactDetailsProvider, Object { public string id { get { return "pgp_info"; } } + public string tab { get { return "encryption"; } } private StreamInteractor stream_interactor; @@ -13,23 +14,39 @@ public class ContactDetailsProvider : Plugins.ContactDetailsProvider, Object { this.stream_interactor = stream_interactor; } - public void populate(Conversation conversation, Plugins.ContactDetails contact_details, WidgetType type) { - if (conversation.type_ == Conversation.Type.CHAT && type == WidgetType.GTK4) { - string? key_id = stream_interactor.get_module(Manager.IDENTITY).get_key_id(conversation.account, conversation.counterpart); - if (key_id != null) { - Label label = new Label("") { use_markup=true, justify=Justification.RIGHT, selectable=true }; - Gee.List<GPG.Key>? keys = null; - try { - keys = GPGHelper.get_keylist(key_id); - } catch (Error e) { } - if (keys != null && keys.size > 0) { - label.label = markup_colorize_id(keys[0].fpr, true); - } else { - label.label = _("Key not in keychain") + "\n" + markup_colorize_id(key_id, false); - } - contact_details.add(_("Encryption"), "OpenPGP", "", label); - } + public void populate(Conversation conversation, Plugins.ContactDetails contact_details, WidgetType type) { } + + public Object? get_widget(Conversation conversation) { + var preferences_group = new Adw.PreferencesGroup() { title="OpenPGP" }; + + if (conversation.type_ != Conversation.Type.CHAT) return null; + + string? key_id = stream_interactor.get_module(Manager.IDENTITY).get_key_id(conversation.account, conversation.counterpart); + if (key_id == null) return null; + + Gee.List<GPG.Key>? keys = null; + try { + keys = GPGHelper.get_keylist(key_id); + } catch (Error e) { } + + var str = ""; + if (keys != null && keys.size > 0) { + str = markup_id(keys[0].fpr, true); + } else { + str = _("Key not in keychain") + "\n" + markup_id(key_id, false); } + + var view = new Adw.ActionRow() { + title = "Fingerprint", + subtitle = str, +#if Adw_1_3 + subtitle_selectable = true, +#endif + }; + + preferences_group.add(view); + + return preferences_group; } } |