From 931c17418d14ee57c56149b501345c27c51da6ca Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Mon, 18 Dec 2023 20:48:49 +0400 Subject: [PATCH] Update to the new cppgir API --- .../platform/linux/integration_linux.cpp | 51 ++++++++----------- .../platform/linux/launcher_linux.cpp | 4 +- Telegram/lib_base | 2 +- Telegram/lib_webview | 2 +- cmake | 2 +- 5 files changed, 27 insertions(+), 34 deletions(-) diff --git a/Telegram/SourceFiles/platform/linux/integration_linux.cpp b/Telegram/SourceFiles/platform/linux/integration_linux.cpp index 6c461ec732..1087e09fbe 100644 --- a/Telegram/SourceFiles/platform/linux/integration_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/integration_linux.cpp @@ -55,17 +55,17 @@ public: }); } - void open_(GFile **files, int n_files, const char*) noexcept override { - Core::Sandbox::Instance().customEnterFromEventLoop([&] { - for (int i = 0; i < n_files; ++i) { - QFileOpenEvent e( - QUrl(QString::fromUtf8(g_file_get_uri(files[i])))); - QGuiApplication::sendEvent(qApp, &e); - } - }); + void open_( + gi::Collection files, + const gi::cstring_v hint) noexcept override { + for (auto file : files) { + QFileOpenEvent e(QUrl(QString::fromStdString(file.get_uri()))); + 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()) { const auto token = qgetenv("XDG_ACTIVATION_TOKEN"); if (!token.isEmpty()) { @@ -113,8 +113,7 @@ Application::Application() Glib::create_variant( NotificationId().toTuple() ).get_type().gobj_copy(), - gi::transfer_full, - gi::direction_out + gi::transfer_full ); } catch (...) { return GLib::VariantType(); @@ -239,11 +238,7 @@ void LinuxIntegration::initInhibit() { return; } - auto uniqueName = _inhibitProxy - .get_connection() - .get_unique_name() - .value_or(""); - + std::string uniqueName = _inhibitProxy.get_connection().get_unique_name(); uniqueName.erase(0, 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( - {}, - 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); } diff --git a/Telegram/SourceFiles/platform/linux/launcher_linux.cpp b/Telegram/SourceFiles/platform/linux/launcher_linux.cpp index d7a6fe9425..9afde3b19c 100644 --- a/Telegram/SourceFiles/platform/linux/launcher_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/launcher_linux.cpp @@ -111,14 +111,14 @@ bool Launcher::launchUpdater(UpdaterLaunch action) { return GLib::spawn_async( initialWorkingDir().toStdString(), argumentsList, - std::nullopt, + {}, GLib::SpawnFlags::FILE_AND_ARGV_ZERO_, nullptr, nullptr, nullptr); } else if (!GLib::spawn_sync( argumentsList, - std::nullopt, + {}, // if the spawn is sync, working directory is not set // and GLib::SpawnFlags::LEAVE_DESCRIPTORS_OPEN_ is set, // it goes through an optimized code path diff --git a/Telegram/lib_base b/Telegram/lib_base index 73b0e8fcca..5660073495 160000 --- a/Telegram/lib_base +++ b/Telegram/lib_base @@ -1 +1 @@ -Subproject commit 73b0e8fcca59d754b60c22d5cd28c3995bf902ea +Subproject commit 5660073495c4cc40d45b393be16e285f485ed33b diff --git a/Telegram/lib_webview b/Telegram/lib_webview index c83478cd5c..af30968bfd 160000 --- a/Telegram/lib_webview +++ b/Telegram/lib_webview @@ -1 +1 @@ -Subproject commit c83478cd5ce2eb6fb343d9c96cec31688fe6d5f6 +Subproject commit af30968bfd3558391183eaa2ca1f4b359e6a02b7 diff --git a/cmake b/cmake index 92f27add11..fb4386adc3 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit 92f27add11ae4280939079249d0f9da933ece6ad +Subproject commit fb4386adc3689dd5337175cbd8eb1c5b6b4ce221