diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3da7815..d258a85 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -81,7 +81,10 @@ jobs: ./scripts/code-sign.sh # after tar to avoid local signature in tarball - name: Test - run: ctest --test-dir build/${{ matrix.arch }} --output-on-failure + run: | + ICON_DIR=~/Library/fcitx5/share/icons/hicolor/48x48/apps + mkdir -p $ICON_DIR && touch $ICON_DIR/fcitx_rime_deploy.png + ctest --test-dir build/${{ matrix.arch }} --output-on-failure - name: Upload artifact uses: actions/upload-artifact@v5 diff --git a/macosnotifications/macosnotifications.cpp b/macosnotifications/macosnotifications.cpp index a65d383..3b1ca65 100644 --- a/macosnotifications/macosnotifications.cpp +++ b/macosnotifications/macosnotifications.cpp @@ -50,23 +50,22 @@ uint32_t Notifications::sendNotification( // Record a notification item to store callbacks. auto internalId = ++internalId_; - std::string externalId = appName + "-" + std::to_string(internalId_); + auto externalId = std::format("{}-{}", appName, internalId_); NotificationItem item{externalId, internalId, actionCallback, closedCallback}; itemTable_.insert(item); // Find appIcon file. - static const std::vector iconExtensions{".png"}; - auto iconPath = iconTheme_->findIconPath(appIcon, 48, 1, iconExtensions); + auto iconPath = iconTheme_->findIconPath(appIcon, 48, 1, {".png"}); // Send the notification. - std::vector cActionStrings; + auto actionsArray = swift::Array::init(); for (const auto &action : actions) { - cActionStrings.push_back(action.c_str()); + actionsArray.append(action); } - SwiftNotify::sendNotificationProxy( - externalId.c_str(), iconPath.c_str(), summary.c_str(), body.c_str(), - cActionStrings.data(), cActionStrings.size(), timeout); + SwiftNotify::sendNotification(externalId.c_str(), iconPath.c_str(), + summary.c_str(), body.c_str(), actionsArray, + timeout); return internalId_; } @@ -79,7 +78,8 @@ void Notifications::showTip(const std::string &tipId, if (hiddenNotifications_.count(tipId)) { return; } - std::vector actions = {"dont-show", "Do not show again"}; + std::vector actions = { + "dont-show", translateDomain("fcitx5", "Do not show again")}; lastTipId_ = sendNotification( appName, lastTipId_, appIcon, summary, body, actions, timeout, [this, tipId](const std::string &action) { diff --git a/macosnotifications/notify.swift b/macosnotifications/notify.swift index da69f26..30df6ff 100644 --- a/macosnotifications/notify.swift +++ b/macosnotifications/notify.swift @@ -41,32 +41,6 @@ public class NotificationDelegate: NSObject, UNUserNotificationCenterDelegate { } } -@_cdecl("sendNotificationProxy") -public func sendNotificationProxy( - _ identifier: UnsafePointer, - _ iconPath: UnsafePointer, - _ title: UnsafePointer, - _ body: UnsafePointer, - _ cActionStrings: UnsafePointer>?, - _ cActionStringCount: Int, - _ timeout: Double -) { - var actionStrings: [String] = [] - if let cActionStrings = cActionStrings { - for i in 0..("hicolor"); + auto path = iconTheme->findIconPath("fcitx_rime_deploy", 48, 1, {".png"}); + FCITX_ASSERT(!path.empty()); +} + +int main() { + Fcitx::shared(); + test_find_icon(); + return 0; +}