Plugin.FolderPluginContext: Support registering special use folders
Add `register_folder_used_as` and `unregister_folder_used_as`, implement both `Application.FolderContextPlugin`.
This commit is contained in:
parent
9345323c84
commit
1dfd5a1855
2 changed files with 50 additions and 0 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue