diff --git a/.appveyor/install.bat b/.appveyor/install.bat index ed1f9c6f1..bb90f1bd9 100644 --- a/.appveyor/install.bat +++ b/.appveyor/install.bat @@ -82,6 +82,10 @@ GOTO:EOF set TDESKTOP_BUILD_DEFINES=%TDESKTOP_BUILD_DEFINES%,TDESKTOP_DISABLE_UNITY_INTEGRATION ) + echo %BUILD_VERSION% | findstr /C:"disable_gtk_integration">nul && ( + set TDESKTOP_BUILD_DEFINES=%TDESKTOP_BUILD_DEFINES%,TDESKTOP_DISABLE_GTK_INTEGRATION + ) + if not "%TDESKTOP_BUILD_DEFINES%" == "" ( set "TDESKTOP_BUILD_DEFINES=%TDESKTOP_BUILD_DEFINES:~1%" ) diff --git a/.travis.yml b/.travis.yml index a7148c314..03710c3da 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,7 @@ env: - BUILD_VERSION="disable_network_proxy" - BUILD_VERSION="disable_desktop_file_generation" - BUILD_VERSION="disable_unity_integration" + - BUILD_VERSION="disable_gtk_integration" matrix: fast_finish: true diff --git a/.travis/build.sh b/.travis/build.sh index 749c4e12f..506f8d4bb 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -118,6 +118,10 @@ build() { GYP_DEFINES+=",TDESKTOP_DISABLE_UNITY_INTEGRATION" fi + if [[ $BUILD_VERSION == *"disable_gtk_integration"* ]]; then + GYP_DEFINES+=",TDESKTOP_DISABLE_GTK_INTEGRATION" + fi + info_msg "Build defines: ${GYP_DEFINES}" buildTelegram diff --git a/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp b/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp index 99f32dc66..f847f3141 100644 --- a/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp @@ -95,6 +95,7 @@ void UnsafeShowInFolder(const QString &filepath) { namespace FileDialog { namespace { +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION // GTK file chooser image preview: thanks to Chromium @@ -105,9 +106,11 @@ namespace { // be preserved. constexpr auto kPreviewWidth = 256; constexpr auto kPreviewHeight = 512; +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION using Type = ::FileDialog::internal::Type; +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION bool NativeSupported() { return Platform::internal::GdkHelperLoaded() && (Libs::gtk_widget_hide_on_delete != nullptr) @@ -191,16 +194,20 @@ bool GetNative(QStringList &files, QByteArray &remoteContent, const QString &cap remoteContent = QByteArray(); return false; } +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION } // namespace bool Get(QStringList &files, QByteArray &remoteContent, const QString &caption, const QString &filter, Type type, QString startFile) { +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION if (NativeSupported()) { return GetNative(files, remoteContent, caption, filter, type, startFile); } +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION return ::FileDialog::internal::GetDefault(files, remoteContent, caption, filter, type, startFile); } +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION namespace internal { QGtkDialog::QGtkDialog(GtkWidget *gtkWidget) : gtkWidget(gtkWidget) { @@ -302,6 +309,7 @@ void QGtkDialog::onParentWindowDestroyed() { // The Gtk*DialogHelper classes own this object. Make sure the parent doesn't delete it. setParent(nullptr); } +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION namespace { @@ -321,6 +329,7 @@ QStringList cleanFilterList(const QString &filter) { } // namespace +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION GtkFileDialog::GtkFileDialog(QWidget *parent, const QString &caption, const QString &directory, const QString &filter) : QDialog(parent) , _windowTitle(caption) , _initialDirectory(directory) { @@ -624,5 +633,6 @@ void GtkFileDialog::setNameFilters(const QStringList &filters) { } } // namespace internal +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION } // namespace FileDialog } // namespace Platform diff --git a/Telegram/SourceFiles/platform/linux/file_utilities_linux.h b/Telegram/SourceFiles/platform/linux/file_utilities_linux.h index 422c40cb9..16ca45a3e 100644 --- a/Telegram/SourceFiles/platform/linux/file_utilities_linux.h +++ b/Telegram/SourceFiles/platform/linux/file_utilities_linux.h @@ -24,8 +24,10 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org extern "C" { #undef signals +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION #include #include +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION #define signals public } // extern "C" @@ -69,6 +71,7 @@ inline void InitLastPath() { } namespace internal { +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION // This is a patched copy of qgtk2 theme plugin. // We need to use our own gtk file dialog instead of @@ -173,6 +176,7 @@ private: QHash _filterNames; QScopedPointer d; }; +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION } // namespace internal } // namespace FileDialog diff --git a/Telegram/SourceFiles/platform/linux/linux_gdk_helper.cpp b/Telegram/SourceFiles/platform/linux/linux_gdk_helper.cpp index 596764439..82232fb76 100644 --- a/Telegram/SourceFiles/platform/linux/linux_gdk_helper.cpp +++ b/Telegram/SourceFiles/platform/linux/linux_gdk_helper.cpp @@ -18,6 +18,7 @@ to link the code of portions of this program with the OpenSSL library. Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org */ +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION #include "platform/linux/linux_gdk_helper.h" #include "platform/linux/linux_libs.h" @@ -111,3 +112,4 @@ void XSetTransientForHint(GdkWindow *window, quintptr winId) { } // namespace internal } // namespace Platform +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION diff --git a/Telegram/SourceFiles/platform/linux/linux_gdk_helper.h b/Telegram/SourceFiles/platform/linux/linux_gdk_helper.h index d7ad478d6..3fcb72940 100644 --- a/Telegram/SourceFiles/platform/linux/linux_gdk_helper.h +++ b/Telegram/SourceFiles/platform/linux/linux_gdk_helper.h @@ -22,6 +22,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION extern "C" { #undef signals #include @@ -38,3 +39,4 @@ void XSetTransientForHint(GdkWindow *window, quintptr winId); } // namespace internal } // namespace Platform +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION diff --git a/Telegram/SourceFiles/platform/linux/linux_libnotify.cpp b/Telegram/SourceFiles/platform/linux/linux_libnotify.cpp index 7d884d1e2..4f969d918 100644 --- a/Telegram/SourceFiles/platform/linux/linux_libnotify.cpp +++ b/Telegram/SourceFiles/platform/linux/linux_libnotify.cpp @@ -44,6 +44,7 @@ bool loadLibrary(QLibrary &lib, const char *name, int version) { } // namespace +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION f_notify_init notify_init = nullptr; f_notify_uninit notify_uninit = nullptr; f_notify_is_initted notify_is_initted = nullptr; @@ -116,6 +117,7 @@ void startLibNotify() { load(lib_notify, "notify_notification_close", notify_notification_close); load(lib_notify, "notify_notification_get_closed_reason", notify_notification_get_closed_reason); } +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION } // namespace Libs } // namespace Platform diff --git a/Telegram/SourceFiles/platform/linux/linux_libnotify.h b/Telegram/SourceFiles/platform/linux/linux_libnotify.h index 1d4253612..c23f32432 100644 --- a/Telegram/SourceFiles/platform/linux/linux_libnotify.h +++ b/Telegram/SourceFiles/platform/linux/linux_libnotify.h @@ -20,6 +20,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org */ #pragma once +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION extern "C" { #undef signals #include @@ -129,3 +130,4 @@ extern f_notify_notification_get_closed_reason notify_notification_get_closed_re } // namespace Libs } // namespace Platform +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION diff --git a/Telegram/SourceFiles/platform/linux/linux_libs.cpp b/Telegram/SourceFiles/platform/linux/linux_libs.cpp index b6d18ae90..ae4b16376 100644 --- a/Telegram/SourceFiles/platform/linux/linux_libs.cpp +++ b/Telegram/SourceFiles/platform/linux/linux_libs.cpp @@ -44,6 +44,7 @@ bool loadLibrary(QLibrary &lib, const char *name, int version) { return false; } +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION bool setupGtkBase(QLibrary &lib_gtk) { if (!load(lib_gtk, "gtk_init_check", gtk_init_check)) return false; if (!load(lib_gtk, "gtk_menu_new", gtk_menu_new)) return false; @@ -142,9 +143,11 @@ bool setupAppIndicator(QLibrary &lib_indicator) { DEBUG_LOG(("Library appindicator functions loaded!")); return true; } +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION } // namespace +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION f_gtk_init_check gtk_init_check = nullptr; f_gtk_menu_new gtk_menu_new = nullptr; f_gtk_menu_get_type gtk_menu_get_type = nullptr; @@ -235,9 +238,11 @@ f_unity_launcher_entry_set_count unity_launcher_entry_set_count = nullptr; f_unity_launcher_entry_set_count_visible unity_launcher_entry_set_count_visible = nullptr; f_unity_launcher_entry_get_for_desktop_id unity_launcher_entry_get_for_desktop_id = nullptr; #endif // !TDESKTOP_DISABLE_UNITY_INTEGRATION +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION void start() { DEBUG_LOG(("Loading libraries")); +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION bool gtkLoaded = false; bool indicatorLoaded = false; @@ -310,6 +315,7 @@ void start() { if (gtkLoaded) { startLibNotify(); } +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION } } // namespace Libs diff --git a/Telegram/SourceFiles/platform/linux/linux_libs.h b/Telegram/SourceFiles/platform/linux/linux_libs.h index a8bf969cd..e9e349be9 100644 --- a/Telegram/SourceFiles/platform/linux/linux_libs.h +++ b/Telegram/SourceFiles/platform/linux/linux_libs.h @@ -20,6 +20,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org */ #pragma once +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION extern "C" { #undef signals #include @@ -31,6 +32,7 @@ extern "C" { #ifndef TDESKTOP_DISABLE_UNITY_INTEGRATION #include #endif // !TDESKTOP_DISABLE_UNITY_INTEGRATION +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION namespace Platform { namespace Libs { @@ -52,6 +54,7 @@ bool load(QLibrary &lib, const char *name, Function &func) { return false; } +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION typedef gboolean (*f_gtk_init_check)(int *argc, char ***argv); extern f_gtk_init_check gtk_init_check; @@ -381,6 +384,7 @@ extern f_unity_launcher_entry_set_count_visible unity_launcher_entry_set_count_v typedef UnityLauncherEntry* (*f_unity_launcher_entry_get_for_desktop_id)(const gchar* desktop_id); extern f_unity_launcher_entry_get_for_desktop_id unity_launcher_entry_get_for_desktop_id; #endif // !TDESKTOP_DISABLE_UNITY_INTEGRATION +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION } // namespace Libs } // namespace Platform diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp index d3e3816f1..e7c40a699 100644 --- a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp @@ -36,18 +36,21 @@ namespace { bool noQtTrayIcon = false, tryAppIndicator = false; bool useGtkBase = false, useAppIndicator = false, useStatusIcon = false, trayIconChecked = false, useUnityCount = false; +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION AppIndicator *_trayIndicator = 0; GtkStatusIcon *_trayIcon = 0; GtkWidget *_trayMenu = 0; GdkPixbuf *_trayPixbuf = 0; QByteArray _trayPixbufData; QList > _trayItems; +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION int32 _trayIconSize = 22; bool _trayIconMuted = true; int32 _trayIconCount = 0; QImage _trayIconImageBack, _trayIconImage; +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION void _trayIconPopup(GtkStatusIcon *status_icon, guint button, guint32 activate_time, gpointer popup_menu) { Libs::gtk_menu_popup(Libs::gtk_menu_cast(popup_menu), NULL, NULL, Libs::gtk_status_icon_position_menu, status_icon, button, activate_time); } @@ -65,16 +68,19 @@ gboolean _trayIconResized(GtkStatusIcon *status_icon, gint size, gpointer popup_ if (Global::started()) Notify::unreadCounterUpdated(); return FALSE; } +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION #define QT_RED 0 #define QT_GREEN 1 #define QT_BLUE 2 #define QT_ALPHA 3 +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION #define GTK_RED 2 #define GTK_GREEN 1 #define GTK_BLUE 0 #define GTK_ALPHA 3 +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION QImage _trayIconImageGen() { int32 counter = App::histories().unreadBadge(), counterSlice = (counter >= 1000) ? (1000 + (counter % 100)) : counter; @@ -133,6 +139,7 @@ QString _trayIconImageFile() { return QString(); } +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION void loadPixbuf(QImage image) { int w = image.width(), h = image.height(), perline = image.bytesPerLine(), s = image.byteCount(); @@ -180,6 +187,7 @@ static gboolean _trayIconCheck(gpointer/* pIn*/) { #ifndef TDESKTOP_DISABLE_UNITY_INTEGRATION UnityLauncherEntry *_psUnityLauncherEntry = nullptr; #endif // !TDESKTOP_DISABLE_UNITY_INTEGRATION +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION } // namespace @@ -192,11 +200,17 @@ MainWindow::MainWindow() { } bool MainWindow::hasTrayIcon() const { +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION return trayIcon || ((useAppIndicator || (useStatusIcon && trayIconChecked)) && (Global::WorkMode().value() != dbiwmWindowOnly)); +#else + return trayIcon; +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION } void MainWindow::psStatusIconCheck() { +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION _trayIconCheck(0); +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION if (cSupportTray() || !--_psCheckStatusIconLeft) { _psCheckStatusIconTimer.stop(); return; @@ -207,6 +221,7 @@ void MainWindow::psShowTrayMenu() { } void MainWindow::psTrayMenuUpdated() { +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION if (noQtTrayIcon && (useAppIndicator || useStatusIcon)) { const QList &actions = trayIconMenu->actions(); if (_trayItems.isEmpty()) { @@ -230,6 +245,7 @@ void MainWindow::psTrayMenuUpdated() { } } } +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION } void MainWindow::psSetupTrayIcon() { @@ -273,11 +289,13 @@ void MainWindow::workmodeUpdated(DBIWorkMode mode) { if (mode == dbiwmWindowOnly) { if (noQtTrayIcon) { +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION if (useAppIndicator) { Libs::app_indicator_set_status(_trayIndicator, APP_INDICATOR_STATUS_PASSIVE); } else if (useStatusIcon) { Libs::gtk_status_icon_set_visible(_trayIcon, false); } +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION } else { if (trayIcon) { trayIcon->setContextMenu(0); @@ -287,11 +305,13 @@ void MainWindow::workmodeUpdated(DBIWorkMode mode) { } } else { if (noQtTrayIcon) { +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION if (useAppIndicator) { Libs::app_indicator_set_status(_trayIndicator, APP_INDICATOR_STATUS_ACTIVE); } else if (useStatusIcon) { Libs::gtk_status_icon_set_visible(_trayIcon, true); } +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION } else { psSetupTrayIcon(); } @@ -299,6 +319,7 @@ void MainWindow::workmodeUpdated(DBIWorkMode mode) { } void MainWindow::psUpdateIndicator() { +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION _psUpdateIndicatorTimer.stop(); _psLastIndicatorUpdate = getms(); QFileInfo iconFile(_trayIconImageFile()); @@ -309,6 +330,7 @@ void MainWindow::psUpdateIndicator() { } else { useAppIndicator = false; } +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION } void MainWindow::unreadCounterChangedHook() { @@ -321,7 +343,7 @@ void MainWindow::updateIconCounters() { auto counter = App::histories().unreadBadge(); -#ifndef TDESKTOP_DISABLE_UNITY_INTEGRATION +#if !defined(TDESKTOP_DISABLE_GTK_INTEGRATION) && !defined(TDESKTOP_DISABLE_UNITY_INTEGRATION) if (_psUnityLauncherEntry) { if (counter > 0) { Libs::unity_launcher_entry_set_count(_psUnityLauncherEntry, (counter > 9999) ? 9999 : counter); @@ -330,9 +352,10 @@ void MainWindow::updateIconCounters() { Libs::unity_launcher_entry_set_count_visible(_psUnityLauncherEntry, FALSE); } } -#endif // !TDESKTOP_DISABLE_UNITY_INTEGRATION +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION && !TDESKTOP_DISABLE_UNITY_INTEGRATION if (noQtTrayIcon) { +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION if (useAppIndicator) { if (getms() > _psLastIndicatorUpdate + 1000) { psUpdateIndicator(); @@ -349,6 +372,7 @@ void MainWindow::updateIconCounters() { Libs::gtk_status_icon_set_from_pixbuf(_trayIcon, _trayPixbuf); } } +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION } else if (trayIcon) { QIcon icon; QFileInfo iconFile(_trayIconImageFile()); @@ -370,12 +394,15 @@ void MainWindow::updateIconCounters() { void MainWindow::LibsLoaded() { noQtTrayIcon = !DesktopEnvironment::TryQtTrayIcon(); +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION tryAppIndicator = DesktopEnvironment::PreferAppIndicatorTrayIcon(); +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION LOG(("Tray Icon: Try Qt = %1, Prefer appindicator = %2").arg(Logs::b(!noQtTrayIcon)).arg(Logs::b(tryAppIndicator))); if (noQtTrayIcon) cSetSupportTray(false); +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION useGtkBase = (Libs::gtk_init_check != nullptr) && (Libs::gtk_menu_new != nullptr) && (Libs::gtk_menu_get_type != nullptr) @@ -430,6 +457,7 @@ void MainWindow::LibsLoaded() { DEBUG_LOG(("Unity count api loaded!")); } #endif // !TDESKTOP_DISABLE_UNITY_INTEGRATION +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION } void MainWindow::psCreateTrayIcon() { @@ -439,6 +467,7 @@ void MainWindow::psCreateTrayIcon() { return; } +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION if (useAppIndicator) { DEBUG_LOG(("Trying to create AppIndicator")); _trayMenu = Libs::gtk_menu_new(); @@ -516,12 +545,13 @@ void MainWindow::psCreateTrayIcon() { } else { workmodeUpdated(Global::WorkMode().value()); } +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION } void MainWindow::psFirstShow() { psCreateTrayIcon(); -#ifndef TDESKTOP_DISABLE_UNITY_INTEGRATION +#if !defined(TDESKTOP_DISABLE_GTK_INTEGRATION) && !defined(TDESKTOP_DISABLE_UNITY_INTEGRATION) if (useUnityCount) { _psUnityLauncherEntry = Libs::unity_launcher_entry_get_for_desktop_id("telegramdesktop.desktop"); if (_psUnityLauncherEntry) { @@ -537,7 +567,7 @@ void MainWindow::psFirstShow() { } else { LOG(("Not using Unity Launcher count.")); } -#endif // !TDESKTOP_DISABLE_UNITY_INTEGRATION +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION && !TDESKTOP_DISABLE_GTK_INTEGRATION psUpdateMargins(); @@ -572,6 +602,7 @@ void MainWindow::psUpdateMargins() { } MainWindow::~MainWindow() { +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION if (_trayIcon) { Libs::g_object_unref(_trayIcon); _trayIcon = nullptr; @@ -594,7 +625,8 @@ MainWindow::~MainWindow() { Libs::g_object_unref(_psUnityLauncherEntry); _psUnityLauncherEntry = nullptr; } -#endif +#endif // ! TDESKTOP_DISABLE_UNITY_INTEGRATION +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION } } // namespace Platform diff --git a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp index 8c6af06b3..1bc0a146c 100644 --- a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp @@ -28,6 +28,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org namespace Platform { namespace Notifications { +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION namespace { bool LibNotifyLoaded() { @@ -269,8 +270,10 @@ QString GetServerName() { auto LibNotifyServerName = QString(); } // namespace +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION bool Supported() { +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION static auto Checked = false; if (!Checked) { Checked = true; @@ -278,23 +281,31 @@ bool Supported() { } return !LibNotifyServerName.isEmpty(); +#else + return false; +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION } std::unique_ptr Create(Window::Notifications::System *system) { +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION if (Global::NativeNotifications() && Supported()) { return std::make_unique(system); } +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION return nullptr; } void Finish() { +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION if (Libs::notify_is_initted && Libs::notify_uninit) { if (Libs::notify_is_initted()) { Libs::notify_uninit(); } } +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION } +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION class Manager::Private { public: using Type = Window::Notifications::CachedUserpics::Type; @@ -347,7 +358,9 @@ private: std::shared_ptr _guarded; }; +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION +#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION void Manager::Private::init(Manager *manager) { _guarded = std::make_shared(manager); @@ -543,6 +556,7 @@ void Manager::doClearAllFast() { void Manager::doClearFromHistory(History *history) { _private->clearFromHistory(history); } +#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION } // namespace Notifications } // namespace Platform diff --git a/Telegram/gyp/telegram_linux.gypi b/Telegram/gyp/telegram_linux.gypi index 2c464928f..721d4f6cd 100644 --- a/Telegram/gyp/telegram_linux.gypi +++ b/Telegram/gyp/telegram_linux.gypi @@ -20,6 +20,7 @@ { 'conditions': [[ 'build_linux', { 'variables': { + 'not_need_gtk%': ' /dev/null --libs <@(pkgconfig_libs))', ], - 'cflags_cc': [ - ' /dev/null --cflags appindicator-0.1)', - ' /dev/null --cflags gtk+-2.0)', - ' /dev/null --cflags glib-2.0)', - ' /dev/null --cflags dee-1.0)', - ], + 'conditions': [['not_need_gtk!="True"', { + 'cflags_cc': [ + ' /dev/null --cflags appindicator-0.1)', + ' /dev/null --cflags gtk+-2.0)', + ' /dev/null --cflags glib-2.0)', + ' /dev/null --cflags dee-1.0)', + ], + }]], 'configurations': { 'Release': { 'cflags': [