Clearing GTK integration leftovers
This commit is contained in:
parent
4313414048
commit
c9dc0bf115
9 changed files with 1 additions and 145 deletions
|
|
@ -63,7 +63,6 @@
|
||||||
"ktg_net_speed_boost_big": "Big",
|
"ktg_net_speed_boost_big": "Big",
|
||||||
"ktg_settings_system": "System",
|
"ktg_settings_system": "System",
|
||||||
"ktg_settings_qt_scale": "Qt scaling engine",
|
"ktg_settings_qt_scale": "Qt scaling engine",
|
||||||
"ktg_settings_gtk_integration": "GTK integration",
|
|
||||||
"ktg_settings_file_dialog_type": "File chooser dialog",
|
"ktg_settings_file_dialog_type": "File chooser dialog",
|
||||||
"ktg_file_dialog_type_default": "Default",
|
"ktg_file_dialog_type_default": "Default",
|
||||||
"ktg_file_dialog_disabled_on_build": "Disabled on build time",
|
"ktg_file_dialog_disabled_on_build": "Disabled on build time",
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,4 @@ void BaseIntegration::logAssertionViolation(const QString &info) {
|
||||||
CrashReports::SetAnnotation("Assertion", info);
|
CrashReports::SetAnnotation("Assertion", info);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BaseIntegration::gtkIntegrationEnabled() const {
|
|
||||||
return cGtkIntegration();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ public:
|
||||||
void logMessageDebug(const QString &message) override;
|
void logMessageDebug(const QString &message) override;
|
||||||
void logMessage(const QString &message) override;
|
void logMessage(const QString &message) override;
|
||||||
void logAssertionViolation(const QString &info) override;
|
void logAssertionViolation(const QString &info) override;
|
||||||
[[nodiscard]] bool gtkIntegrationEnabled() const override;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -380,7 +380,6 @@ QByteArray GenerateSettingsJson(bool areDefault = false) {
|
||||||
settings.insert(qsl("userpic_corner_type"), cUserpicCornersType());
|
settings.insert(qsl("userpic_corner_type"), cUserpicCornersType());
|
||||||
settings.insert(qsl("always_show_top_userpic"), cShowTopBarUserpic());
|
settings.insert(qsl("always_show_top_userpic"), cShowTopBarUserpic());
|
||||||
settings.insert(qsl("qt_scale"), cQtScale());
|
settings.insert(qsl("qt_scale"), cQtScale());
|
||||||
settings.insert(qsl("gtk_integration"), cGtkIntegration());
|
|
||||||
settings.insert(qsl("file_dialog_type"), int(FileDialogType()));
|
settings.insert(qsl("file_dialog_type"), int(FileDialogType()));
|
||||||
settings.insert(qsl("disable_tray_counter"), cDisableTrayCounter());
|
settings.insert(qsl("disable_tray_counter"), cDisableTrayCounter());
|
||||||
settings.insert(qsl("use_telegram_panel_icon"), cUseTelegramPanelIcon());
|
settings.insert(qsl("use_telegram_panel_icon"), cUseTelegramPanelIcon());
|
||||||
|
|
@ -651,10 +650,6 @@ bool Manager::readCustomFile() {
|
||||||
cSetQtScale(v);
|
cSetQtScale(v);
|
||||||
});
|
});
|
||||||
|
|
||||||
ReadBoolOption(settings, "gtk_integration", [&](auto v) {
|
|
||||||
cSetGtkIntegration(v);
|
|
||||||
});
|
|
||||||
|
|
||||||
ReadIntOption(settings, "file_dialog_type", [&](auto v) {
|
ReadIntOption(settings, "file_dialog_type", [&](auto v) {
|
||||||
using Platform::FileDialog::ImplementationType;
|
using Platform::FileDialog::ImplementationType;
|
||||||
if (v >= int(ImplementationType::Default)
|
if (v >= int(ImplementationType::Default)
|
||||||
|
|
|
||||||
|
|
@ -166,7 +166,6 @@ int gUserpicCornersType = 3;
|
||||||
bool gShowTopBarUserpic = false;
|
bool gShowTopBarUserpic = false;
|
||||||
|
|
||||||
bool gQtScale = false;
|
bool gQtScale = false;
|
||||||
bool gGtkIntegration = false;
|
|
||||||
|
|
||||||
rpl::variable<Platform::FileDialog::ImplementationType> gFileDialogType = Platform::FileDialog::ImplementationType::Default;
|
rpl::variable<Platform::FileDialog::ImplementationType> gFileDialogType = Platform::FileDialog::ImplementationType::Default;
|
||||||
void SetFileDialogType(Platform::FileDialog::ImplementationType t) {
|
void SetFileDialogType(Platform::FileDialog::ImplementationType t) {
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,6 @@ DeclareSetting(int, UserpicCornersType);
|
||||||
DeclareSetting(bool, ShowTopBarUserpic);
|
DeclareSetting(bool, ShowTopBarUserpic);
|
||||||
|
|
||||||
DeclareSetting(bool, QtScale);
|
DeclareSetting(bool, QtScale);
|
||||||
DeclareSetting(bool, GtkIntegration);
|
|
||||||
|
|
||||||
void SetFileDialogType(Platform::FileDialog::ImplementationType t);
|
void SetFileDialogType(Platform::FileDialog::ImplementationType t);
|
||||||
[[nodiscard]] Platform::FileDialog::ImplementationType FileDialogType();
|
[[nodiscard]] Platform::FileDialog::ImplementationType FileDialogType();
|
||||||
|
|
|
||||||
|
|
@ -595,37 +595,6 @@ void SetupKotatoSystem(
|
||||||
cancelled));
|
cancelled));
|
||||||
}, container->lifetime());
|
}, container->lifetime());
|
||||||
|
|
||||||
#ifndef DESKTOP_APP_DISABLE_GTK_INTEGRATION
|
|
||||||
if (Platform::IsLinux()) {
|
|
||||||
const auto gtkIntegrationToggled = Ui::CreateChild<rpl::event_stream<bool>>(
|
|
||||||
container.get());
|
|
||||||
AddButton(
|
|
||||||
container,
|
|
||||||
rktr("ktg_settings_gtk_integration"),
|
|
||||||
st::settingsButton
|
|
||||||
)->toggleOn(
|
|
||||||
gtkIntegrationToggled->events_starting_with_copy(cGtkIntegration())
|
|
||||||
)->toggledValue(
|
|
||||||
) | rpl::filter([](bool enabled) {
|
|
||||||
return (enabled != cGtkIntegration());
|
|
||||||
}) | rpl::start_with_next([=](bool enabled) {
|
|
||||||
const auto confirmed = [=] {
|
|
||||||
cSetGtkIntegration(enabled);
|
|
||||||
::Kotato::JsonSettings::Write();
|
|
||||||
App::restart();
|
|
||||||
};
|
|
||||||
const auto cancelled = [=] {
|
|
||||||
gtkIntegrationToggled->fire(cGtkIntegration() == true);
|
|
||||||
};
|
|
||||||
Ui::show(Box<ConfirmBox>(
|
|
||||||
tr::lng_settings_need_restart(tr::now),
|
|
||||||
tr::lng_settings_restart_now(tr::now),
|
|
||||||
confirmed,
|
|
||||||
cancelled));
|
|
||||||
}, container->lifetime());
|
|
||||||
}
|
|
||||||
#endif // !DESKTOP_APP_DISABLE_GTK_INTEGRATION
|
|
||||||
|
|
||||||
if (Platform::IsLinux()) {
|
if (Platform::IsLinux()) {
|
||||||
auto fileDialogTypeText = rpl::single(
|
auto fileDialogTypeText = rpl::single(
|
||||||
FileDialogType()
|
FileDialogType()
|
||||||
|
|
|
||||||
|
|
@ -1,100 +0,0 @@
|
||||||
/*
|
|
||||||
This file is part of Telegram Desktop,
|
|
||||||
the official desktop application for the Telegram messaging service.
|
|
||||||
|
|
||||||
For license and copyright information please follow this link:
|
|
||||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
||||||
*/
|
|
||||||
#include "platform/linux/linux_gtk_integration.h"
|
|
||||||
|
|
||||||
#ifdef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
|
||||||
#error "GTK integration depends on D-Bus integration."
|
|
||||||
#endif // DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
|
||||||
|
|
||||||
#include "base/platform/linux/base_linux_gtk_integration.h"
|
|
||||||
#include "base/platform/linux/base_linux_dbus_utilities.h"
|
|
||||||
#include "base/platform/base_platform_info.h"
|
|
||||||
|
|
||||||
#include <QtCore/QProcess>
|
|
||||||
|
|
||||||
#include <glibmm.h>
|
|
||||||
|
|
||||||
namespace Platform {
|
|
||||||
namespace internal {
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
constexpr auto kBaseService = "io.github.kotatogram.BaseGtkIntegration-%1"_cs;
|
|
||||||
|
|
||||||
using BaseGtkIntegration = base::Platform::GtkIntegration;
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
QString GtkIntegration::AllowedBackends() {
|
|
||||||
return Platform::IsWayland()
|
|
||||||
? qsl("wayland,x11")
|
|
||||||
: Platform::IsX11()
|
|
||||||
? qsl("x11,wayland")
|
|
||||||
: QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GtkIntegration::Start(Type type) {
|
|
||||||
if (type != Type::Base) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto d = QFile::encodeName(QDir(cWorkingDir()).absolutePath());
|
|
||||||
char h[33] = { 0 };
|
|
||||||
hashMd5Hex(d.constData(), d.size(), h);
|
|
||||||
|
|
||||||
BaseGtkIntegration::SetServiceName(kBaseService.utf16().arg(h));
|
|
||||||
|
|
||||||
const auto dbusName = [] {
|
|
||||||
try {
|
|
||||||
static const auto connection = Gio::DBus::Connection::get_sync(
|
|
||||||
Gio::DBus::BusType::BUS_TYPE_SESSION);
|
|
||||||
|
|
||||||
return QString::fromStdString(connection->get_unique_name());
|
|
||||||
} catch (...) {
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}();
|
|
||||||
|
|
||||||
if (dbusName.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QProcess::startDetached(cExeDir() + cExeName(), {
|
|
||||||
qsl("-basegtkintegration"),
|
|
||||||
dbusName,
|
|
||||||
kBaseService.utf16().arg(h),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void GtkIntegration::Autorestart(Type type) {
|
|
||||||
if (type != Type::Base) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
static const auto connection = Gio::DBus::Connection::get_sync(
|
|
||||||
Gio::DBus::BusType::BUS_TYPE_SESSION);
|
|
||||||
|
|
||||||
base::Platform::DBus::RegisterServiceWatcher(
|
|
||||||
connection,
|
|
||||||
Glib::ustring(BaseGtkIntegration::ServiceName().toStdString()),
|
|
||||||
[=](
|
|
||||||
const Glib::ustring &service,
|
|
||||||
const Glib::ustring &oldOwner,
|
|
||||||
const Glib::ustring &newOwner) {
|
|
||||||
if (newOwner.empty()) {
|
|
||||||
Start(type);
|
|
||||||
} else if (const auto integration = BaseGtkIntegration::Instance()) {
|
|
||||||
integration->load(AllowedBackends());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (...) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace internal
|
|
||||||
} // namespace Platform
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 27dfac9006bd863c3ad5dc3799d96c49ea9bf7eb
|
Subproject commit 5ccf8c9a1eafbdd3cae98e53885a92cfb8b01431
|
||||||
Loading…
Add table
Reference in a new issue