Skip to content

Commit

Permalink
Move code to namespace fcitx::rime and use FCITX_ADDON_FACTORY_V2
Browse files Browse the repository at this point in the history
  • Loading branch information
wengxt committed Nov 19, 2024
1 parent 8f80c36 commit 88d3e39
Show file tree
Hide file tree
Showing 16 changed files with 38 additions and 36 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/rime-addon.conf.in.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ OnDemand=True
Configurable=True

[Addon/Dependencies]
0=core:5.1.0
0=core:@REQUIRED_FCITX_VERSION@

[Addon/OptionalDependencies]
0=notifications
Expand Down
4 changes: 2 additions & 2 deletions src/rimeaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <utility>
#include <vector>

namespace fcitx {
namespace fcitx::rime {

namespace {

Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions src/rimeaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <string_view>
#include <vector>

namespace fcitx {
namespace fcitx::rime {

class RimeEngine;

Expand Down Expand Up @@ -82,6 +82,6 @@ class SelectAction : public RimeOptionAction {
Menu menu_;
};

} // namespace fcitx
} // namespace fcitx::rime

#endif // _FCITX_RIMEENGINE_H_
4 changes: 2 additions & 2 deletions src/rimecandidate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <rime_api.h>
#include <stdexcept>

namespace fcitx {
namespace fcitx::rime {

RimeCandidateWord::RimeCandidateWord(RimeEngine *engine,
const RimeCandidate &candidate, KeySym sym,
Expand Down Expand Up @@ -205,4 +205,4 @@ void RimeCandidateList::setGlobalCursorIndex(int index) {
api->highlight_candidate(session, index);
}
#endif
} // namespace fcitx
} // namespace fcitx::rime
4 changes: 2 additions & 2 deletions src/rimecandidate.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <memory>
#include <vector>

namespace fcitx {
namespace fcitx::rime {

class RimeCandidateWord : public CandidateWord {
public:
Expand Down Expand Up @@ -129,6 +129,6 @@ class RimeCandidateList final : public CandidateList,
mutable std::vector<std::unique_ptr<RimeGlobalCandidateWord>>
globalCandidateWords_;
};
} // namespace fcitx
} // namespace fcitx::rime

#endif // _FCITX_RIMECANDIDATE_H_
8 changes: 4 additions & 4 deletions src/rimeengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
#include <utility>
#include <vector>

FCITX_DEFINE_LOG_CATEGORY(rime, "rime");
FCITX_DEFINE_LOG_CATEGORY(rime_log, "rime");

namespace fcitx {
namespace fcitx::rime {

namespace {

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -792,4 +792,4 @@ PropertyPropagatePolicy RimeEngine::getSharedStatePolicy() {
}
}

} // namespace fcitx
} // namespace fcitx::rime
10 changes: 5 additions & 5 deletions src/rimeengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#include "rimeservice.h"
#endif

namespace fcitx {
namespace fcitx::rime {

class RimeState;
class RimeOptionAction;
Expand Down Expand Up @@ -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_
6 changes: 3 additions & 3 deletions src/rimefactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
#include "rimeengine.h"
#include <fcitx-utils/i18n.h>

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)
4 changes: 2 additions & 2 deletions src/rimefactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

#include <fcitx/addonfactory.h>

namespace fcitx {
namespace fcitx::rime {

class RimeEngineFactory : public AddonFactory {
public:
AddonInstance *create(AddonManager *manager) override;
};

} // namespace fcitx
} // namespace fcitx::rime

#endif
4 changes: 2 additions & 2 deletions src/rimeservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -84,4 +84,4 @@ std::vector<std::string> RimeService::listAllSchemas() {
return schemas;
}

} // namespace fcitx
} // namespace fcitx::rime
4 changes: 2 additions & 2 deletions src/rimeservice.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <fcitx-utils/dbus/message.h>
#include <fcitx-utils/dbus/objectvtable.h>

namespace fcitx {
namespace fcitx::rime {

class RimeEngine;
class RimeState;
Expand All @@ -36,6 +36,6 @@ class RimeService : public dbus::ObjectVTable<RimeService> {
RimeEngine *engine_;
};

} // namespace fcitx
} // namespace fcitx::rime

#endif // _FCITX5_RIME_RIMESERVICE_H_
4 changes: 2 additions & 2 deletions src/rimesession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <tuple>
#include <utility>

namespace fcitx {
namespace fcitx::rime {

RimeSessionHolder::RimeSessionHolder(RimeSessionPool *pool,
const std::string &program)
Expand Down Expand Up @@ -148,4 +148,4 @@ void RimeSessionPool::unregisterSession(const std::string &key) {
assert(count > 0);
}

} // namespace fcitx
} // namespace fcitx::rime
4 changes: 2 additions & 2 deletions src/rimesession.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <tuple>
#include <unordered_map>

namespace fcitx {
namespace fcitx::rime {

class RimeEngine;
class RimeSessionPool;
Expand Down Expand Up @@ -66,6 +66,6 @@ class RimeSessionPool {
std::unordered_map<std::string, std::weak_ptr<RimeSessionHolder>> sessions_;
};

} // namespace fcitx
} // namespace fcitx::rime

#endif
4 changes: 2 additions & 2 deletions src/rimestate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include <utility>
#include <vector>

namespace fcitx {
namespace fcitx::rime {

namespace {

Expand Down Expand Up @@ -620,4 +620,4 @@ void RimeState::showChangedOptions() {
engine_->instance()->showCustomInputMethodInformation(&ic_, labels);
}
}
} // namespace fcitx
} // namespace fcitx::rime
4 changes: 2 additions & 2 deletions src/rimestate.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#define RIME_ASCII_MODE "ascii_mode"

namespace fcitx {
namespace fcitx::rime {

class RimeEngine;

Expand Down Expand Up @@ -72,6 +72,6 @@ class RimeState : public InputContextProperty {
std::vector<std::string> savedOptions_;
std::vector<std::string> changedOptions_;
};
} // namespace fcitx
} // namespace fcitx::rime

#endif // _FCITX_RIMESTATE_H_

0 comments on commit 88d3e39

Please sign in to comment.