mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Update to the new cppgir API
This commit is contained in:
parent
5a47ed268c
commit
931c17418d
5 changed files with 27 additions and 34 deletions
|
@ -55,17 +55,17 @@ public:
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void open_(GFile **files, int n_files, const char*) noexcept override {
|
void open_(
|
||||||
Core::Sandbox::Instance().customEnterFromEventLoop([&] {
|
gi::Collection<gi::DSpan, ::GFile*, gi::transfer_none_t> files,
|
||||||
for (int i = 0; i < n_files; ++i) {
|
const gi::cstring_v hint) noexcept override {
|
||||||
QFileOpenEvent e(
|
for (auto file : files) {
|
||||||
QUrl(QString::fromUtf8(g_file_get_uri(files[i]))));
|
QFileOpenEvent e(QUrl(QString::fromStdString(file.get_uri())));
|
||||||
QGuiApplication::sendEvent(qApp, &e);
|
QGuiApplication::sendEvent(qApp, &e);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_platform_data_(GLib::VariantBuilder builder) noexcept override {
|
void add_platform_data_(
|
||||||
|
GLib::VariantBuilder_Ref builder) noexcept override {
|
||||||
if (Platform::IsWayland()) {
|
if (Platform::IsWayland()) {
|
||||||
const auto token = qgetenv("XDG_ACTIVATION_TOKEN");
|
const auto token = qgetenv("XDG_ACTIVATION_TOKEN");
|
||||||
if (!token.isEmpty()) {
|
if (!token.isEmpty()) {
|
||||||
|
@ -113,8 +113,7 @@ Application::Application()
|
||||||
Glib::create_variant(
|
Glib::create_variant(
|
||||||
NotificationId().toTuple()
|
NotificationId().toTuple()
|
||||||
).get_type().gobj_copy(),
|
).get_type().gobj_copy(),
|
||||||
gi::transfer_full,
|
gi::transfer_full
|
||||||
gi::direction_out
|
|
||||||
);
|
);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
return GLib::VariantType();
|
return GLib::VariantType();
|
||||||
|
@ -239,11 +238,7 @@ void LinuxIntegration::initInhibit() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto uniqueName = _inhibitProxy
|
std::string uniqueName = _inhibitProxy.get_connection().get_unique_name();
|
||||||
.get_connection()
|
|
||||||
.get_unique_name()
|
|
||||||
.value_or("");
|
|
||||||
|
|
||||||
uniqueName.erase(0, 1);
|
uniqueName.erase(0, 1);
|
||||||
uniqueName.replace(uniqueName.find('.'), 1, 1, '_');
|
uniqueName.replace(uniqueName.find('.'), 1, 1, '_');
|
||||||
|
|
||||||
|
@ -277,20 +272,18 @@ void LinuxIntegration::initInhibit() {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
const auto options = std::array{
|
|
||||||
GLib::Variant::new_dict_entry(
|
|
||||||
GLib::Variant::new_string("handle_token"),
|
|
||||||
GLib::Variant::new_variant(
|
|
||||||
GLib::Variant::new_string(handleToken))),
|
|
||||||
GLib::Variant::new_dict_entry(
|
|
||||||
GLib::Variant::new_string("session_handle_token"),
|
|
||||||
GLib::Variant::new_variant(
|
|
||||||
GLib::Variant::new_string(sessionHandleToken))),
|
|
||||||
};
|
|
||||||
|
|
||||||
inhibit().call_create_monitor(
|
inhibit().call_create_monitor(
|
||||||
{},
|
"",
|
||||||
GLib::Variant::new_array(options.data(), options.size()),
|
GLib::Variant::new_array({
|
||||||
|
GLib::Variant::new_dict_entry(
|
||||||
|
GLib::Variant::new_string("handle_token"),
|
||||||
|
GLib::Variant::new_variant(
|
||||||
|
GLib::Variant::new_string(handleToken))),
|
||||||
|
GLib::Variant::new_dict_entry(
|
||||||
|
GLib::Variant::new_string("session_handle_token"),
|
||||||
|
GLib::Variant::new_variant(
|
||||||
|
GLib::Variant::new_string(sessionHandleToken))),
|
||||||
|
}),
|
||||||
nullptr);
|
nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,14 +111,14 @@ bool Launcher::launchUpdater(UpdaterLaunch action) {
|
||||||
return GLib::spawn_async(
|
return GLib::spawn_async(
|
||||||
initialWorkingDir().toStdString(),
|
initialWorkingDir().toStdString(),
|
||||||
argumentsList,
|
argumentsList,
|
||||||
std::nullopt,
|
{},
|
||||||
GLib::SpawnFlags::FILE_AND_ARGV_ZERO_,
|
GLib::SpawnFlags::FILE_AND_ARGV_ZERO_,
|
||||||
nullptr,
|
nullptr,
|
||||||
nullptr,
|
nullptr,
|
||||||
nullptr);
|
nullptr);
|
||||||
} else if (!GLib::spawn_sync(
|
} else if (!GLib::spawn_sync(
|
||||||
argumentsList,
|
argumentsList,
|
||||||
std::nullopt,
|
{},
|
||||||
// if the spawn is sync, working directory is not set
|
// if the spawn is sync, working directory is not set
|
||||||
// and GLib::SpawnFlags::LEAVE_DESCRIPTORS_OPEN_ is set,
|
// and GLib::SpawnFlags::LEAVE_DESCRIPTORS_OPEN_ is set,
|
||||||
// it goes through an optimized code path
|
// it goes through an optimized code path
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 73b0e8fcca59d754b60c22d5cd28c3995bf902ea
|
Subproject commit 5660073495c4cc40d45b393be16e285f485ed33b
|
|
@ -1 +1 @@
|
||||||
Subproject commit c83478cd5ce2eb6fb343d9c96cec31688fe6d5f6
|
Subproject commit af30968bfd3558391183eaa2ca1f4b359e6a02b7
|
2
cmake
2
cmake
|
@ -1 +1 @@
|
||||||
Subproject commit 92f27add11ae4280939079249d0f9da933ece6ad
|
Subproject commit fb4386adc3689dd5337175cbd8eb1c5b6b4ce221
|
Loading…
Add table
Reference in a new issue