pub struct CtxEntry {
pub path: Vec<String>,
pub entry_type: ActivationType,
}Fields§
§path: Vec<String>The path to the entry as a list of entry names
entry_type: ActivationTypeImplementations§
Source§impl CtxEntry
impl CtxEntry
Sourcepub fn get<N: AsRef<str>>(
name_path: &[N],
entry_type: &ActivationType,
) -> Option<CtxEntry>
pub fn get<N: AsRef<str>>( name_path: &[N], entry_type: &ActivationType, ) -> Option<CtxEntry>
Gets an existing entry at the given name path. The last name corresponds to the returned entry.
§Examples
let name_path = &["Root entry", "Sub entry", "Sub sub entry"];
let entry = CtxEntry::get(name_path, &ActivationType::Folder)?;Sourcepub fn new(name: &str, entry_type: &ActivationType) -> Result<CtxEntry>
pub fn new(name: &str, entry_type: &ActivationType) -> Result<CtxEntry>
Creates a new top-level entry under the given entry_type.
The resulting entry will appear in the context menu but will do
nothing until modified.
§Examples
let mut entry = CtxEntry::new("Basic entry", ActivationType::Background)?;Sourcepub fn new_with_options(
name: &str,
entry_type: &ActivationType,
opts: &EntryOptions,
) -> Result<CtxEntry>
pub fn new_with_options( name: &str, entry_type: &ActivationType, opts: &EntryOptions, ) -> Result<CtxEntry>
Creates a new top-level entry under the given entry_type.
§Examples
let entry = CtxEntry::new(
"Open in terminal",
&ActivationType::Folder,
&EntryOptions {
// This command opens the target directory in cmd.
command: Some("cmd /s /k pushd \"%V\""),
icon: Some("C:\\Windows\\System32\\cmd.exe"),
position: None,
extended: false,
}
)?;Sourcepub fn delete(self) -> Result<()>
pub fn delete(self) -> Result<()>
Deletes the entry and any children.
§Examples
let entry = CtxEntry::new("Basic entry", ActivationType::Background)?;
entry.delete()?;Sourcepub fn name(&self) -> Result<String>
pub fn name(&self) -> Result<String>
Gets the entry’s current name.
§Examples
let entry = CtxEntry::new("Basic entry", ActivationType::Background)?;
let name = entry.name()?;Sourcepub fn rename(&mut self, new_name: &str) -> Result<()>
pub fn rename(&mut self, new_name: &str) -> Result<()>
Renames the entry.
§Examples
let mut entry = CtxEntry::new("Basic entry", ActivationType::Background)?;
entry.rename("Renamed entry")?;Sourcepub fn command(&self) -> Result<Option<String>>
pub fn command(&self) -> Result<Option<String>>
Gets the entry’s command, if any.
§Examples
let entry = CtxEntry::new("Basic entry", ActivationType::Background)?;
let command = entry.command()?;Sourcepub fn set_command(&mut self, command: Option<&str>) -> Result<()>
pub fn set_command(&mut self, command: Option<&str>) -> Result<()>
Sets the entry’s command.
§Examples
let mut entry = CtxEntry::new("Basic entry", ActivationType::Folder)?;
// This command opens the target directory in Powershell.
entry.set_command(Some("powershell.exe -noexit -command Set-Location -literalPath '%V'"))?;Sourcepub fn icon(&self) -> Result<Option<String>>
pub fn icon(&self) -> Result<Option<String>>
Gets the entry’s icon, if any.
§Examples
let entry = CtxEntry::new("Basic entry", ActivationType::Background)?;
let icon = entry.icon()?;Sourcepub fn set_icon(&mut self, icon: Option<&str>) -> Result<()>
pub fn set_icon(&mut self, icon: Option<&str>) -> Result<()>
Sets the entry’s icon.
§Examples
let mut entry = CtxEntry::new("Basic entry", ActivationType::Background)?;
entry.set_icon(Some("C:\\Windows\\System32\\control.exe"))?;Sourcepub fn position(&self) -> Result<Option<MenuPosition>>
pub fn position(&self) -> Result<Option<MenuPosition>>
Gets the entry’s position, if any.
§Examples
let entry = CtxEntry::new("Basic entry", ActivationType::Background)?;
let position = entry.position()?;Sourcepub fn set_position(&mut self, position: Option<MenuPosition>) -> Result<()>
pub fn set_position(&mut self, position: Option<MenuPosition>) -> Result<()>
Sets the entry’s menu position. By default, new root entries are positioned at the top. Does not affect child entries.
§Examples
let mut entry = CtxEntry::new("Basic entry", ActivationType::Background)?;
entry.set_position(Some(MenuPosition::Bottom))?;Sourcepub fn extended(&self) -> Result<bool>
pub fn extended(&self) -> Result<bool>
Gets whether the entry appears with Shift+RClick.
§Examples
let entry = CtxEntry::new("Basic entry", ActivationType::Background)?;
let is_extended = entry.extended()?;Sourcepub fn set_extended(&mut self, extended: bool) -> Result<()>
pub fn set_extended(&mut self, extended: bool) -> Result<()>
Sets whether the entry should only appear with Shift+RClick.
§Examples
let mut entry = CtxEntry::new("Basic entry", ActivationType::Background)?;
entry.set_extended(true)?;Sourcepub fn separator(&self) -> Result<Option<Separator>>
pub fn separator(&self) -> Result<Option<Separator>>
Gets the entry’s separator(s), if any.
§Examples
let entry = CtxEntry::new("Basic entry", ActivationType::Background)?;
let separator = entry.separator()?;Sourcepub fn set_separator(&mut self, separator: Option<Separator>) -> Result<()>
pub fn set_separator(&mut self, separator: Option<Separator>) -> Result<()>
Sets the entry’s separator(s).
§Examples
let mut entry = CtxEntry::new("Basic entry", ActivationType::Background)?;
entry.set_separator(Some(Separator::After))?;Sourcepub fn parent(&self) -> Option<CtxEntry>
pub fn parent(&self) -> Option<CtxEntry>
Gets the entry’s parent, if any.
§Examples
let entry = CtxEntry::new("Basic entry", ActivationType::Background)?;
let child = entry.new_child("Basic child entry")?;
let parent = child.parent()?;
assert_eq!(entry.name().unwrap(), parent.name().unwrap());Sourcepub fn child(&self, name: &str) -> Result<Option<CtxEntry>>
pub fn child(&self, name: &str) -> Result<Option<CtxEntry>>
Gets one of the entry’s children, if any.
§Examples
let entry = CtxEntry::new("Basic entry", ActivationType::Background)?;
let created_child = entry.new_child("Basic child entry")?;
let retrieved_child = entry.child("Basic child entry")?;
assert_eq!(created_child.name().unwrap(), retrieved_child.name().unwrap());Sourcepub fn children(&self) -> Result<Vec<CtxEntry>>
pub fn children(&self) -> Result<Vec<CtxEntry>>
Gets the entry’s children, if any.
§Examples
let entry = CtxEntry::new("Basic entry", ActivationType::Background)?;
let child_1 = entry.new_child("Child 1")?;
let child_2 = entry.new_child("Child 2")?;
let children = entry.children()?;Sourcepub fn new_child(&self, name: &str) -> Result<CtxEntry>
pub fn new_child(&self, name: &str) -> Result<CtxEntry>
Creates a new child entry under the entry. The resulting entry will appear in the context menu but will do nothing until modified.
§Examples
let entry = CtxEntry::new("Basic entry", ActivationType::Background)?;
let child = entry.new_child("Basic child entry")?;Sourcepub fn new_child_with_options(
&self,
name: &str,
opts: &EntryOptions,
) -> Result<CtxEntry>
pub fn new_child_with_options( &self, name: &str, opts: &EntryOptions, ) -> Result<CtxEntry>
Creates a new child entry under the entry.
§Examples
let entry = CtxEntry::new("Basic entry", ActivationType::Background)?;
let child = entry.new_child_with_options(
"Basic child entry",
&EntryOptions {
// This command opens the target directory in cmd.
command: Some("cmd /s /k pushd \"%V\""),
icon: Some("C:\\Windows\\System32\\cmd.exe"),
position: None,
extended: false,
}
)?;