fix: fix the behavior of highlevel fetching string and icon
This commit is contained in:
@@ -687,18 +687,25 @@ impl Program {
|
|||||||
// Now try fetch its diaplay name in modern way first.
|
// Now try fetch its diaplay name in modern way first.
|
||||||
// If there is no modern way, use legacy way instead.
|
// If there is no modern way, use legacy way instead.
|
||||||
// If there is still no display name, use ProgId self instead as display name.
|
// If there is still no display name, use ProgId self instead as display name.
|
||||||
let name = match progid_key.get_friendly_type_name(view)? {
|
let mut name: Option<String> = None;
|
||||||
Some(name) => name.extract()?,
|
if let None = name {
|
||||||
None => match progid_key.get_default(view)? {
|
name = progid_key
|
||||||
Some(name) => name.extract()?,
|
.get_friendly_type_name(view)?
|
||||||
None => progid_key.inner().to_string(),
|
.map(|name| name.extract().ok())
|
||||||
},
|
.flatten();
|
||||||
};
|
}
|
||||||
|
if let None = name {
|
||||||
|
name = progid_key
|
||||||
|
.get_default(view)?
|
||||||
|
.map(|name| name.extract().ok())
|
||||||
|
.flatten();
|
||||||
|
}
|
||||||
|
let name = name.unwrap_or(progid_key.inner().to_string());
|
||||||
// Now try to fetch icon.
|
// Now try to fetch icon.
|
||||||
let icon = progid_key
|
let icon = progid_key
|
||||||
.get_default_icon(view)?
|
.get_default_icon(view)?
|
||||||
.map(|ico| ico.extract(concept::IconSizeKind::Small))
|
.map(|ico| ico.extract(concept::IconSizeKind::Small).ok())
|
||||||
.transpose()?;
|
.flatten();
|
||||||
|
|
||||||
// Okey, return it.
|
// Okey, return it.
|
||||||
Ok(Some(ProgramExtStatus::new(name, icon)))
|
Ok(Some(ProgramExtStatus::new(name, icon)))
|
||||||
|
|||||||
@@ -160,10 +160,7 @@ pub enum IconResVariant {
|
|||||||
impl IconResVariant {
|
impl IconResVariant {
|
||||||
pub fn extract(&self, kind: concept::IconSizeKind) -> Result<concept::IconRc> {
|
pub fn extract(&self, kind: concept::IconSizeKind) -> Result<concept::IconRc> {
|
||||||
let rc = match self {
|
let rc = match self {
|
||||||
IconResVariant::Plain(v) => {
|
IconResVariant::Plain(v) => concept::IconRc::with_ico_file(v.as_str(), kind)?,
|
||||||
eprintln!("plain: {v}");
|
|
||||||
concept::IconRc::with_ico_file(v.as_str(), kind)?
|
|
||||||
},
|
|
||||||
IconResVariant::RefStr(v) => {
|
IconResVariant::RefStr(v) => {
|
||||||
// Try expand path part if possible
|
// Try expand path part if possible
|
||||||
let path_part = strip_quote(v.get_path());
|
let path_part = strip_quote(v.get_path());
|
||||||
@@ -171,13 +168,11 @@ impl IconResVariant {
|
|||||||
Ok(expand_string) => expand_string.expand()?,
|
Ok(expand_string) => expand_string.expand()?,
|
||||||
Err(_) => path_part.to_string(),
|
Err(_) => path_part.to_string(),
|
||||||
};
|
};
|
||||||
eprintln!("refstr: {path_part}");
|
|
||||||
// Get index part.
|
// Get index part.
|
||||||
let index_part = v.get_index();
|
let index_part = v.get_index();
|
||||||
eprintln!("refstr: {index_part}");
|
|
||||||
// Resolve icon resource
|
// Resolve icon resource
|
||||||
concept::IconRc::new(&path_part, index_part, kind)?
|
concept::IconRc::new(&path_part, index_part, kind)?
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
Ok(rc)
|
Ok(rc)
|
||||||
}
|
}
|
||||||
@@ -238,10 +233,8 @@ impl StrResVariant {
|
|||||||
Ok(expand_string) => expand_string.expand()?,
|
Ok(expand_string) => expand_string.expand()?,
|
||||||
Err(_) => path_part.to_string(),
|
Err(_) => path_part.to_string(),
|
||||||
};
|
};
|
||||||
eprintln!("{path_part}");
|
|
||||||
// Get index part
|
// Get index part
|
||||||
let index_part = v.get_index();
|
let index_part = v.get_index();
|
||||||
eprintln!("{index_part}");
|
|
||||||
// Resolve string resource
|
// Resolve string resource
|
||||||
let rc = concept::StrRc::new(&path_part, index_part)?;
|
let rc = concept::StrRc::new(&path_part, index_part)?;
|
||||||
rc.into_string()
|
rc.into_string()
|
||||||
@@ -419,7 +412,7 @@ fn check_privilege(territory: OpenKeyTerritory, purpose: OpenKeyPurpose) -> Resu
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Remove quote pair if possible.
|
/// Remove quote pair if possible.
|
||||||
///
|
///
|
||||||
/// In some cases, the path part of [concept::IconRefStr] or [concept::StrRefStr] is quoted by quote.
|
/// In some cases, the path part of [concept::IconRefStr] or [concept::StrRefStr] is quoted by quote.
|
||||||
/// This can no be recognized by Win32 functions.
|
/// This can no be recognized by Win32 functions.
|
||||||
/// So in this case, we should remove this quote pair.
|
/// So in this case, we should remove this quote pair.
|
||||||
|
|||||||
Reference in New Issue
Block a user