Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new glibmm 2.78 API #26419

Merged
merged 1 commit into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions Telegram/SourceFiles/platform/linux/integration_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ For license and copyright information please follow this link:

#include "platform/platform_integration.h"
#include "base/platform/base_platform_info.h"
#include "base/platform/linux/base_linux_glibmm_helper.h"
#include "base/platform/linux/base_linux_xdp_utilities.h"
#include "core/sandbox.h"
#include "core/application.h"
Expand Down Expand Up @@ -125,7 +124,7 @@ LinuxIntegration::LinuxIntegration()
if (group == "org.freedesktop.appearance"
&& key == "color-scheme") {
try {
const auto ivalue = base::Platform::GlibVariantCast<uint>(value);
const auto ivalue = value.get_dynamic<uint>();

crl::on_main([=] {
Core::App().settings().setSystemDarkMode(ivalue == 1);
Expand Down Expand Up @@ -266,8 +265,9 @@ void LinuxIntegration::LaunchNativeApplication() {

const auto notificationIdVariantType = [] {
try {
return base::Platform::MakeGlibVariant(
NotificationId().toTuple()).get_type();
return Glib::create_variant(
NotificationId().toTuple()
).get_type();
} catch (...) {
return Glib::VariantType();
}
Expand All @@ -282,9 +282,9 @@ void LinuxIntegration::LaunchNativeApplication() {
const auto &app = Core::App();
app.notifications().manager().notificationActivated(
NotificationId::FromTuple(
base::Platform::GlibVariantCast<
NotificationIdTuple
>(parameter)));
parameter.get_dynamic<NotificationIdTuple>()
)
);
} catch (...) {
}
});
Expand All @@ -299,10 +299,10 @@ void LinuxIntegration::LaunchNativeApplication() {
const auto &app = Core::App();
app.notifications().manager().notificationReplied(
NotificationId::FromTuple(
base::Platform::GlibVariantCast<
NotificationIdTuple
>(parameter)),
{});
parameter.get_dynamic<NotificationIdTuple>()
),
{}
);
} catch (...) {
}
});
Expand Down
33 changes: 13 additions & 20 deletions Telegram/SourceFiles/platform/linux/linux_xdp_open_with_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ For license and copyright information please follow this link:
#include "platform/linux/linux_xdp_open_with_dialog.h"

#include "base/platform/base_platform_info.h"
#include "base/platform/linux/base_linux_glibmm_helper.h"
#include "base/platform/linux/base_linux_xdp_utilities.h"
#include "base/platform/linux/base_linux_wayland_integration.h"
#include "core/application.h"
Expand All @@ -34,20 +33,17 @@ bool ShowXDPOpenWithDialog(const QString &filepath) {
const auto connection = Gio::DBus::Connection::get_sync(
Gio::DBus::BusType::SESSION);

auto reply = connection->call_sync(
const auto version = connection->call_sync(
std::string(base::Platform::XDP::kObjectPath),
std::string(kPropertiesInterface),
"Get",
base::Platform::MakeGlibVariant(std::tuple{
Glib::create_variant(std::tuple{
Glib::ustring(
std::string(kXDPOpenURIInterface)),
Glib::ustring("version"),
}),
std::string(base::Platform::XDP::kService));

const auto version = base::Platform::GlibVariantCast<uint>(
base::Platform::GlibVariantCast<Glib::VariantBase>(
reply.get_child(0)));
std::string(base::Platform::XDP::kService)
).get_child(0).get_dynamic<Glib::Variant<uint>>().get();

if (version < 3) {
return false;
Expand Down Expand Up @@ -112,7 +108,7 @@ bool ShowXDPOpenWithDialog(const QString &filepath) {
loop->quit();
},
std::string(base::Platform::XDP::kService),
"org.freedesktop.portal.Request",
std::string(base::Platform::XDP::kRequestInterface),
"Response",
requestPath);

Expand All @@ -128,26 +124,23 @@ bool ShowXDPOpenWithDialog(const QString &filepath) {
std::string(base::Platform::XDP::kObjectPath),
std::string(kXDPOpenURIInterface),
"OpenFile",
Glib::VariantContainerBase::create_tuple({
Glib::Variant<Glib::ustring>::create(parentWindowId),
Glib::Variant<int>::create_handle(0),
Glib::Variant<std::map<
Glib::ustring,
Glib::VariantBase
>>::create({
Glib::create_variant(std::tuple{
parentWindowId,
Glib::DBusHandle(),
std::map<Glib::ustring, Glib::VariantBase>{
{
"handle_token",
Glib::Variant<Glib::ustring>::create(handleToken)
Glib::create_variant(handleToken)
},
{
"activation_token",
Glib::Variant<Glib::ustring>::create(activationToken)
Glib::create_variant(activationToken)
},
{
"ask",
Glib::Variant<bool>::create(true)
Glib::create_variant(true)
},
}),
},
}),
Gio::UnixFDList::create(std::vector<int>{ fd }),
outFdList,
Expand Down
13 changes: 5 additions & 8 deletions Telegram/SourceFiles/platform/linux/main_window_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ For license and copyright information please follow this link:
#include "window/window_controller.h"
#include "window/window_session_controller.h"
#include "base/platform/base_platform_info.h"
#include "base/platform/linux/base_linux_glibmm_helper.h"
#include "base/event_filter.h"
#include "ui/widgets/popup_menu.h"
#include "ui/widgets/input_fields.h"
Expand Down Expand Up @@ -251,13 +250,11 @@ void MainWindow::updateUnityCounter() {
// According to the spec, it should be of 'x' D-Bus signature,
// which corresponds to signed 64-bit integer
// https://wiki.ubuntu.com/Unity/LauncherAPI#Low_level_DBus_API:_com.canonical.Unity.LauncherEntry
dbusUnityProperties["count"] = Glib::Variant<int64>::create(
counterSlice);
dbusUnityProperties["count-visible"] =
Glib::Variant<bool>::create(true);
dbusUnityProperties["count"] = Glib::create_variant(
int64(counterSlice));
dbusUnityProperties["count-visible"] = Glib::create_variant(true);
} else {
dbusUnityProperties["count-visible"] =
Glib::Variant<bool>::create(false);
dbusUnityProperties["count-visible"] = Glib::create_variant(false);
}

try {
Expand All @@ -270,7 +267,7 @@ void MainWindow::updateUnityCounter() {
"com.canonical.Unity.LauncherEntry",
"Update",
{},
base::Platform::MakeGlibVariant(std::tuple{
Glib::create_variant(std::tuple{
launcherUrl,
dbusUnityProperties,
}));
Expand Down
Loading
Loading