diff options
author | Marvin W <git@larma.de> | 2017-03-11 22:48:35 +0100 |
---|---|---|
committer | Marvin W <git@larma.de> | 2017-03-11 22:50:28 +0100 |
commit | 0ea4ac7e20674e3e6a8d1b3d4b53702dace72907 (patch) | |
tree | 09a4f713b66d45a1ecdb9a826611899fad35105a /libdino/src/plugin | |
parent | 47ab19b3a06b6f96965482e4a33d443c2276c1d8 (diff) | |
download | dino-0ea4ac7e20674e3e6a8d1b3d4b53702dace72907.tar.gz dino-0ea4ac7e20674e3e6a8d1b3d4b53702dace72907.zip |
Plug-In API: allow adding custom entries to account settings
Also make OpenPGP code use this API
Diffstat (limited to 'libdino/src/plugin')
-rw-r--r-- | libdino/src/plugin/interfaces.vala | 27 | ||||
-rw-r--r-- | libdino/src/plugin/registry.vala | 13 |
2 files changed, 40 insertions, 0 deletions
diff --git a/libdino/src/plugin/interfaces.vala b/libdino/src/plugin/interfaces.vala index 19873003..35c93786 100644 --- a/libdino/src/plugin/interfaces.vala +++ b/libdino/src/plugin/interfaces.vala @@ -1,5 +1,15 @@ +using Gtk; + namespace Dino.Plugins { +public enum Priority { + LOWEST, + LOWER, + DEFAULT, + HIGHER, + HIGHEST +} + public interface RootInterface : Object { public abstract void registered(Dino.Application app); @@ -13,4 +23,21 @@ public interface EncryptionListEntry : Object { public abstract bool can_encrypt(Entities.Conversation conversation); } +public abstract class AccountSettingsEntry : Object { + public abstract string id { get; } + public virtual Priority priority { get { return Priority.DEFAULT; } } + public abstract string name { get; } + public virtual int16 label_top_padding { get { return -1; } } + + public abstract AccountSettingsWidget get_widget(); +} + +public interface AccountSettingsWidget : Gtk.Widget { + public abstract void set_account(Entities.Account account); + + public abstract signal void activated(); + + public abstract void deactivate(); +} + }
\ No newline at end of file diff --git a/libdino/src/plugin/registry.vala b/libdino/src/plugin/registry.vala index 8c75784e..27cac6f3 100644 --- a/libdino/src/plugin/registry.vala +++ b/libdino/src/plugin/registry.vala @@ -4,6 +4,7 @@ namespace Dino.Plugins { public class Registry { internal ArrayList<EncryptionListEntry> encryption_list_entries = new ArrayList<EncryptionListEntry>(); + internal ArrayList<AccountSettingsEntry> account_settings_entries = new ArrayList<AccountSettingsEntry>(); public bool register_encryption_list_entry(EncryptionListEntry entry) { lock(encryption_list_entries) { @@ -15,6 +16,18 @@ public class Registry { return true; } } + + public bool register_account_settings_entry(AccountSettingsEntry entry) { + lock(account_settings_entries) { + foreach(var e in account_settings_entries) { + if (e.id == entry.id) return false; + } + account_settings_entries.add(entry); + // TODO: Order by priority + account_settings_entries.sort((a,b) => b.name.collate(a.name)); + return true; + } + } } }
\ No newline at end of file |