Skip to content

Commit

Permalink
Fix icon name mapping in flatpak (#1049)
Browse files Browse the repository at this point in the history
Now we have a much of icons that uses "fcitx_" as the name, including
mozc, skk, kkc, rime, to avoid xdg icon spec based fallback.

But we missed the flatpak naming mapping for those icons. Update the
condition here, and also handle the special name "fcitx" (I don't think
we do have code that uses "fcitx" as icon, but well.. )

fcitx/mozc#53 (comment)
  • Loading branch information
wengxt authored May 11, 2024
1 parent cae526a commit fb91429
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/lib/fcitx/icontheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,13 @@ std::string IconTheme::defaultIconThemeName() {

/// Rename fcitx-* icon to org.fcitx.Fcitx5.fcitx-* if in flatpak
std::string IconTheme::iconName(const std::string &icon, bool inFlatpak) {
if (inFlatpak && stringutils::startsWith(icon, "fcitx-")) {
constexpr std::string_view fcitxIconPrefix = "fcitx";
if (inFlatpak && stringutils::startsWith(icon, fcitxIconPrefix)) {
// Map "fcitx" to org.fcitx.Fcitx5
// And map fcitx* to org.fcitx.Fcitx5.fcitx*
if (icon.size() == fcitxIconPrefix.size()) {
return "org.fcitx.Fcitx5";
}
return stringutils::concat("org.fcitx.Fcitx5.", icon);
}
return icon;
Expand Down
3 changes: 3 additions & 0 deletions test/testicontheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ int main() {
FCITX_ASSERT(IconTheme::iconName("fcitx-pinyin", false) == "fcitx-pinyin");
FCITX_ASSERT(IconTheme::iconName("fcitx-pinyin", true) ==
"org.fcitx.Fcitx5.fcitx-pinyin");
FCITX_ASSERT(IconTheme::iconName("fcitx_mozc", true) ==
"org.fcitx.Fcitx5.fcitx_mozc");
FCITX_ASSERT(IconTheme::iconName("fcitx", true) == "org.fcitx.Fcitx5");

for (const auto &inheritTheme : theme.inherits()) {
FCITX_INFO() << inheritTheme.name().match();
Expand Down

0 comments on commit fb91429

Please sign in to comment.