[geary/mjog/email-templates: 11/17] Plugin.FolderPluginContext: Support registering special use folders
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/email-templates: 11/17] Plugin.FolderPluginContext: Support registering special use folders
- Date: Wed, 8 Apr 2020 09:23:23 +0000 (UTC)
commit bbbafadbce6360c4cc3d2f8f72171edafd6836ec
Author: Michael Gratton <mike vee net>
Date: Mon Apr 6 14:09:55 2020 +1000
Plugin.FolderPluginContext: Support registering special use folders
Add `register_folder_used_as` and `unregister_folder_used_as`, implement
both `Application.FolderContextPlugin`.
.../application-folder-plugin-context.vala | 31 ++++++++++++++++++++++
src/client/plugin/plugin-folder-extension.vala | 19 +++++++++++++
2 files changed, 50 insertions(+)
---
diff --git a/src/client/application/application-folder-plugin-context.vala
b/src/client/application/application-folder-plugin-context.vala
index 1031e958..c4994693 100644
--- a/src/client/application/application-folder-plugin-context.vala
+++ b/src/client/application/application-folder-plugin-context.vala
@@ -64,6 +64,37 @@ internal class Application.FolderPluginContext :
}
}
+ public void register_folder_used_as(Plugin.Folder target,
+ string name,
+ string icon_name) throws Plugin.Error {
+ var context = this.folders_factory.get_folder_context(target);
+ if (context != null) {
+ try {
+ context.folder.set_used_as_custom(true);
+ } catch (Geary.EngineError err) {
+ throw new Plugin.Error.NOT_SUPPORTED(
+ "Failed to register folder use: %s", err.message
+ );
+ }
+ context.display_name = name;
+ context.icon_name = icon_name;
+ }
+ }
+
+ public void unregister_folder_used_as(Plugin.Folder target)
+ throws Plugin.Error {
+ var context = this.folders_factory.get_folder_context(target);
+ if (context != null) {
+ try {
+ context.folder.set_used_as_custom(false);
+ } catch (Geary.EngineError err) {
+ throw new Plugin.Error.NOT_SUPPORTED(
+ "Failed to unregister folder use: %s", err.message
+ );
+ }
+ }
+ }
+
internal void destroy() {
this.folders_factory.destroy_folder_store(this.folders);
}
diff --git a/src/client/plugin/plugin-folder-extension.vala b/src/client/plugin/plugin-folder-extension.vala
index c90f0283..66b66df5 100644
--- a/src/client/plugin/plugin-folder-extension.vala
+++ b/src/client/plugin/plugin-folder-extension.vala
@@ -75,4 +75,23 @@ public interface Plugin.FolderContext : Geary.BaseObject {
public abstract void remove_folder_info_bar(Folder selected,
InfoBar infobar);
+ /**
+ * Registers a folder for a well-known use.
+ *
+ * This promotes a folder from a label to a special-use folder,
+ * causing it to appear with other special-use folders with the
+ * given name and icon.
+ */
+ public abstract void register_folder_used_as(Folder target,
+ string name,
+ string icon_name) throws Error;
+
+ /**
+ * Unregisters a folder for a well-known use.
+ *
+ * This demotes the folder from a special-use to an ordinary
+ * label.
+ */
+ public abstract void unregister_folder_used_as(Folder target) throws Error;
+
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]