mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-30 22:25:12 +00:00
New build option: without GTK and appindicator
Signed-off-by: Egor Y. Egorov <egor.y.egorov@gmail.com> (github: eegorov)
This commit is contained in:
@@ -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
|
||||
|
@@ -24,8 +24,10 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||
|
||||
extern "C" {
|
||||
#undef signals
|
||||
#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdk.h>
|
||||
#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<GtkFileFilter*, QString> _filterNames;
|
||||
QScopedPointer<QGtkDialog> d;
|
||||
};
|
||||
#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||
|
||||
} // namespace internal
|
||||
} // namespace FileDialog
|
||||
|
@@ -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
|
||||
|
@@ -22,6 +22,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||
extern "C" {
|
||||
#undef signals
|
||||
#include <gtk/gtk.h>
|
||||
@@ -38,3 +39,4 @@ void XSetTransientForHint(GdkWindow *window, quintptr winId);
|
||||
|
||||
} // namespace internal
|
||||
} // namespace Platform
|
||||
#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||
|
@@ -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
|
||||
|
@@ -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 <gtk/gtk.h>
|
||||
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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 <libappindicator/app-indicator.h>
|
||||
@@ -31,6 +32,7 @@ extern "C" {
|
||||
#ifndef TDESKTOP_DISABLE_UNITY_INTEGRATION
|
||||
#include <unity/unity/unity.h>
|
||||
#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
|
||||
|
@@ -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<QPair<GtkWidget*, QObject*> > _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<QAction*> &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
|
||||
|
@@ -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<Window::Notifications::Manager> Create(Window::Notifications::System *system) {
|
||||
#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||
if (Global::NativeNotifications() && Supported()) {
|
||||
return std::make_unique<Manager>(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<Manager*> _guarded;
|
||||
|
||||
};
|
||||
#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||
|
||||
#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||
void Manager::Private::init(Manager *manager) {
|
||||
_guarded = std::make_shared<Manager*>(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
|
||||
|
Reference in New Issue
Block a user