From 88d3e39655f41660a8abb8fbf1e82c13db1a0cf1 Mon Sep 17 00:00:00 2001 From: Weng Xuetian Date: Mon, 18 Nov 2024 17:23:46 -0800 Subject: [PATCH] Move code to namespace fcitx::rime and use FCITX_ADDON_FACTORY_V2 --- CMakeLists.txt | 4 +++- src/rime-addon.conf.in.in | 2 +- src/rimeaction.cpp | 4 ++-- src/rimeaction.h | 4 ++-- src/rimecandidate.cpp | 4 ++-- src/rimecandidate.h | 4 ++-- src/rimeengine.cpp | 8 ++++---- src/rimeengine.h | 10 +++++----- src/rimefactory.cpp | 6 +++--- src/rimefactory.h | 4 ++-- src/rimeservice.cpp | 4 ++-- src/rimeservice.h | 4 ++-- src/rimesession.cpp | 4 ++-- src/rimesession.h | 4 ++-- src/rimestate.cpp | 4 ++-- src/rimestate.h | 4 ++-- 16 files changed, 38 insertions(+), 36 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a1637a..ffbb0d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.6.0) project(fcitx5-rime VERSION 5.1.9) +set(REQUIRED_FCITX_VERSION 5.1.12) + find_package(ECM 1.0.0 REQUIRED) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) include(FeatureSummary) @@ -10,7 +12,7 @@ include(ECMSetupVersion) include(ECMUninstallTarget) find_package(Gettext REQUIRED) -find_package(Fcitx5Core 5.1.11 REQUIRED) +find_package(Fcitx5Core ${REQUIRED_FCITX_VERSION} REQUIRED) find_package(Fcitx5Module REQUIRED COMPONENTS Notifications) find_package(PkgConfig REQUIRED) find_package(Pthread REQUIRED) diff --git a/src/rime-addon.conf.in.in b/src/rime-addon.conf.in.in index 1d5246a..d1fb52e 100644 --- a/src/rime-addon.conf.in.in +++ b/src/rime-addon.conf.in.in @@ -9,7 +9,7 @@ OnDemand=True Configurable=True [Addon/Dependencies] -0=core:5.1.0 +0=core:@REQUIRED_FCITX_VERSION@ [Addon/OptionalDependencies] 0=notifications diff --git a/src/rimeaction.cpp b/src/rimeaction.cpp index c19b05a..953cfc9 100644 --- a/src/rimeaction.cpp +++ b/src/rimeaction.cpp @@ -18,7 +18,7 @@ #include #include -namespace fcitx { +namespace fcitx::rime { namespace { @@ -161,4 +161,4 @@ bool SelectAction::checkOptionName(std::string_view name) const { std::string SelectAction::optionLabel(InputContext *ic) { return shortText(ic); } -} // namespace fcitx +} // namespace fcitx::rime diff --git a/src/rimeaction.h b/src/rimeaction.h index 05f1024..50f5c33 100644 --- a/src/rimeaction.h +++ b/src/rimeaction.h @@ -15,7 +15,7 @@ #include #include -namespace fcitx { +namespace fcitx::rime { class RimeEngine; @@ -82,6 +82,6 @@ class SelectAction : public RimeOptionAction { Menu menu_; }; -} // namespace fcitx +} // namespace fcitx::rime #endif // _FCITX_RIMEENGINE_H_ diff --git a/src/rimecandidate.cpp b/src/rimecandidate.cpp index 0c756a3..de4e142 100644 --- a/src/rimecandidate.cpp +++ b/src/rimecandidate.cpp @@ -13,7 +13,7 @@ #include #include -namespace fcitx { +namespace fcitx::rime { RimeCandidateWord::RimeCandidateWord(RimeEngine *engine, const RimeCandidate &candidate, KeySym sym, @@ -205,4 +205,4 @@ void RimeCandidateList::setGlobalCursorIndex(int index) { api->highlight_candidate(session, index); } #endif -} // namespace fcitx +} // namespace fcitx::rime diff --git a/src/rimecandidate.h b/src/rimecandidate.h index a52b87a..163a594 100644 --- a/src/rimecandidate.h +++ b/src/rimecandidate.h @@ -14,7 +14,7 @@ #include #include -namespace fcitx { +namespace fcitx::rime { class RimeCandidateWord : public CandidateWord { public: @@ -129,6 +129,6 @@ class RimeCandidateList final : public CandidateList, mutable std::vector> globalCandidateWords_; }; -} // namespace fcitx +} // namespace fcitx::rime #endif // _FCITX_RIMECANDIDATE_H_ diff --git a/src/rimeengine.cpp b/src/rimeengine.cpp index 49fc5b8..b335069 100644 --- a/src/rimeengine.cpp +++ b/src/rimeengine.cpp @@ -47,9 +47,9 @@ #include #include -FCITX_DEFINE_LOG_CATEGORY(rime, "rime"); +FCITX_DEFINE_LOG_CATEGORY(rime_log, "rime"); -namespace fcitx { +namespace fcitx::rime { namespace { @@ -261,7 +261,7 @@ void RimeEngine::rimeStart(bool fullcheck) { // make librime only log to stderr // /~https://github.com/rime/librime/commit/6d1b9b65de4e7784a68a17d10a3e5c900e4fd511 fcitx_rime_traits.log_dir = ""; - switch (rime().logLevel()) { + switch (rime_log().logLevel()) { case NoLog: fcitx_rime_traits.min_log_level = 4; break; @@ -792,4 +792,4 @@ PropertyPropagatePolicy RimeEngine::getSharedStatePolicy() { } } -} // namespace fcitx +} // namespace fcitx::rime diff --git a/src/rimeengine.h b/src/rimeengine.h index 823e7ff..4bf912d 100644 --- a/src/rimeengine.h +++ b/src/rimeengine.h @@ -46,7 +46,7 @@ #include "rimeservice.h" #endif -namespace fcitx { +namespace fcitx::rime { class RimeState; class RimeOptionAction; @@ -233,11 +233,11 @@ class RimeEngine final : public InputMethodEngineV2 { std::thread::id mainThreadId_ = std::this_thread::get_id(); RimeState *currentKeyEventState_ = nullptr; }; -} // namespace fcitx +} // namespace fcitx::rime -FCITX_DECLARE_LOG_CATEGORY(rime); +FCITX_DECLARE_LOG_CATEGORY(rime_log); -#define RIME_DEBUG() FCITX_LOGC(rime, Debug) -#define RIME_ERROR() FCITX_LOGC(rime, Error) +#define RIME_DEBUG() FCITX_LOGC(rime_log, Debug) +#define RIME_ERROR() FCITX_LOGC(rime_log, Error) #endif // _FCITX_RIMEENGINE_H_ diff --git a/src/rimefactory.cpp b/src/rimefactory.cpp index 91a2f37..a66cc1f 100644 --- a/src/rimefactory.cpp +++ b/src/rimefactory.cpp @@ -8,13 +8,13 @@ #include "rimeengine.h" #include -namespace fcitx { +namespace fcitx::rime { AddonInstance *RimeEngineFactory::create(AddonManager *manager) { registerDomain("fcitx5-rime", FCITX_INSTALL_LOCALEDIR); return new RimeEngine(manager->instance()); } -} // namespace fcitx +} // namespace fcitx::rime -FCITX_ADDON_FACTORY(fcitx::RimeEngineFactory) +FCITX_ADDON_FACTORY_V2(rime, fcitx::rime::RimeEngineFactory) diff --git a/src/rimefactory.h b/src/rimefactory.h index 3df3928..5847cd2 100644 --- a/src/rimefactory.h +++ b/src/rimefactory.h @@ -8,13 +8,13 @@ #include -namespace fcitx { +namespace fcitx::rime { class RimeEngineFactory : public AddonFactory { public: AddonInstance *create(AddonManager *manager) override; }; -} // namespace fcitx +} // namespace fcitx::rime #endif diff --git a/src/rimeservice.cpp b/src/rimeservice.cpp index 3215faf..b8186b2 100644 --- a/src/rimeservice.cpp +++ b/src/rimeservice.cpp @@ -9,7 +9,7 @@ #include "rimeengine.h" #include "rimestate.h" -namespace fcitx { +namespace fcitx::rime { RimeService::RimeService(RimeEngine *engine) : engine_(engine) { auto dbus = engine->dbus(); @@ -84,4 +84,4 @@ std::vector RimeService::listAllSchemas() { return schemas; } -} // namespace fcitx +} // namespace fcitx::rime diff --git a/src/rimeservice.h b/src/rimeservice.h index da12d20..a5e8920 100644 --- a/src/rimeservice.h +++ b/src/rimeservice.h @@ -10,7 +10,7 @@ #include #include -namespace fcitx { +namespace fcitx::rime { class RimeEngine; class RimeState; @@ -36,6 +36,6 @@ class RimeService : public dbus::ObjectVTable { RimeEngine *engine_; }; -} // namespace fcitx +} // namespace fcitx::rime #endif // _FCITX5_RIME_RIMESERVICE_H_ diff --git a/src/rimesession.cpp b/src/rimesession.cpp index 1e1c011..5d72942 100644 --- a/src/rimesession.cpp +++ b/src/rimesession.cpp @@ -20,7 +20,7 @@ #include #include -namespace fcitx { +namespace fcitx::rime { RimeSessionHolder::RimeSessionHolder(RimeSessionPool *pool, const std::string &program) @@ -148,4 +148,4 @@ void RimeSessionPool::unregisterSession(const std::string &key) { assert(count > 0); } -} // namespace fcitx +} // namespace fcitx::rime diff --git a/src/rimesession.h b/src/rimesession.h index cb3b98a..cc03be8 100644 --- a/src/rimesession.h +++ b/src/rimesession.h @@ -17,7 +17,7 @@ #include #include -namespace fcitx { +namespace fcitx::rime { class RimeEngine; class RimeSessionPool; @@ -66,6 +66,6 @@ class RimeSessionPool { std::unordered_map> sessions_; }; -} // namespace fcitx +} // namespace fcitx::rime #endif diff --git a/src/rimestate.cpp b/src/rimestate.cpp index f986e50..aaf6983 100644 --- a/src/rimestate.cpp +++ b/src/rimestate.cpp @@ -38,7 +38,7 @@ #include #include -namespace fcitx { +namespace fcitx::rime { namespace { @@ -620,4 +620,4 @@ void RimeState::showChangedOptions() { engine_->instance()->showCustomInputMethodInformation(&ic_, labels); } } -} // namespace fcitx +} // namespace fcitx::rime diff --git a/src/rimestate.h b/src/rimestate.h index 6b2a1dc..a675db8 100644 --- a/src/rimestate.h +++ b/src/rimestate.h @@ -20,7 +20,7 @@ #define RIME_ASCII_MODE "ascii_mode" -namespace fcitx { +namespace fcitx::rime { class RimeEngine; @@ -72,6 +72,6 @@ class RimeState : public InputContextProperty { std::vector savedOptions_; std::vector changedOptions_; }; -} // namespace fcitx +} // namespace fcitx::rime #endif // _FCITX_RIMESTATE_H_