mirror of
https://github.com/vale981/tdesktop
synced 2025-03-04 17:21:40 -05:00
Generalize Unity Integration to not depend on libunity
This commit is contained in:
parent
c66b2b2291
commit
add2356c8a
8 changed files with 41 additions and 77 deletions
|
@ -72,10 +72,6 @@ GOTO:EOF
|
|||
set TDESKTOP_BUILD_DEFINES=%TDESKTOP_BUILD_DEFINES%,TDESKTOP_DISABLE_DESKTOP_FILE_GENERATION
|
||||
)
|
||||
|
||||
echo %BUILD_VERSION% | findstr /C:"disable_unity_integration">nul && (
|
||||
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
|
||||
)
|
||||
|
|
|
@ -14,7 +14,6 @@ env:
|
|||
- BUILD_VERSION="disable_crash_reports"
|
||||
- BUILD_VERSION="disable_network_proxy"
|
||||
- BUILD_VERSION="disable_desktop_file_generation"
|
||||
- BUILD_VERSION="disable_unity_integration"
|
||||
- BUILD_VERSION="disable_gtk_integration"
|
||||
|
||||
matrix:
|
||||
|
@ -45,7 +44,7 @@ addons:
|
|||
- libopus-dev
|
||||
- libpulse-dev
|
||||
- libssl-dev
|
||||
- libunity-dev
|
||||
- libdee-dev
|
||||
- libva-dev
|
||||
- libvdpau-dev
|
||||
- libxcb-xkb-dev
|
||||
|
|
|
@ -116,10 +116,6 @@ build() {
|
|||
GYP_DEFINES+=",TDESKTOP_DISABLE_DESKTOP_FILE_GENERATION"
|
||||
fi
|
||||
|
||||
if [[ $BUILD_VERSION == *"disable_unity_integration"* ]]; then
|
||||
GYP_DEFINES+=",TDESKTOP_DISABLE_UNITY_INTEGRATION"
|
||||
fi
|
||||
|
||||
if [[ $BUILD_VERSION == *"disable_gtk_integration"* ]]; then
|
||||
GYP_DEFINES+=",TDESKTOP_DISABLE_GTK_INTEGRATION"
|
||||
fi
|
||||
|
|
|
@ -220,11 +220,6 @@ f_g_list_free g_list_free = nullptr;
|
|||
f_g_list_free_full g_list_free_full = nullptr;
|
||||
f_g_error_free g_error_free = nullptr;
|
||||
f_g_slist_free g_slist_free = nullptr;
|
||||
#ifndef TDESKTOP_DISABLE_UNITY_INTEGRATION
|
||||
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() {
|
||||
|
@ -288,17 +283,6 @@ void start() {
|
|||
LOG(("Could not load gtk-x11-2.0!"));
|
||||
}
|
||||
|
||||
#ifndef TDESKTOP_DISABLE_UNITY_INTEGRATION
|
||||
if (DesktopEnvironment::TryUnityCounter()) {
|
||||
QLibrary lib_unity(qstr("unity"), 9, 0);
|
||||
loadLibrary(lib_unity, "unity", 9);
|
||||
|
||||
load(lib_unity, "unity_launcher_entry_get_for_desktop_id", unity_launcher_entry_get_for_desktop_id);
|
||||
load(lib_unity, "unity_launcher_entry_set_count", unity_launcher_entry_set_count);
|
||||
load(lib_unity, "unity_launcher_entry_set_count_visible", unity_launcher_entry_set_count_visible);
|
||||
}
|
||||
#endif // !TDESKTOP_DISABLE_UNITY_INTEGRATION
|
||||
|
||||
if (gtkLoaded) {
|
||||
startLibNotify();
|
||||
}
|
||||
|
|
|
@ -20,9 +20,6 @@ extern "C" {
|
|||
#define signals public
|
||||
} // extern "C"
|
||||
|
||||
#ifndef TDESKTOP_DISABLE_UNITY_INTEGRATION
|
||||
#include <unity/unity/unity.h>
|
||||
#endif // !TDESKTOP_DISABLE_UNITY_INTEGRATION
|
||||
#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||
|
||||
namespace Platform {
|
||||
|
@ -364,17 +361,6 @@ extern f_g_error_free g_error_free;
|
|||
|
||||
typedef void (*f_g_slist_free)(GSList *list);
|
||||
extern f_g_slist_free g_slist_free;
|
||||
|
||||
#ifndef TDESKTOP_DISABLE_UNITY_INTEGRATION
|
||||
typedef void (*f_unity_launcher_entry_set_count)(UnityLauncherEntry* self, gint64 value);
|
||||
extern f_unity_launcher_entry_set_count unity_launcher_entry_set_count;
|
||||
|
||||
typedef void (*f_unity_launcher_entry_set_count_visible)(UnityLauncherEntry* self, gboolean value);
|
||||
extern f_unity_launcher_entry_set_count_visible unity_launcher_entry_set_count_visible;
|
||||
|
||||
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
|
||||
|
|
|
@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "core/application.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "storage/localstorage.h"
|
||||
#include <QtDBus>
|
||||
|
||||
namespace Platform {
|
||||
namespace {
|
||||
|
@ -36,6 +37,8 @@ int32 _trayIconSize = 22;
|
|||
bool _trayIconMuted = true;
|
||||
int32 _trayIconCount = 0;
|
||||
QImage _trayIconImageBack, _trayIconImage;
|
||||
QString _desktopFile;
|
||||
QString _dbusPath = "/";
|
||||
|
||||
#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||
void _trayIconPopup(GtkStatusIcon *status_icon, guint button, guint32 activate_time, gpointer popup_menu) {
|
||||
|
@ -177,11 +180,17 @@ static gboolean _trayIconCheck(gpointer/* pIn*/) {
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
#ifndef TDESKTOP_DISABLE_UNITY_INTEGRATION
|
||||
UnityLauncherEntry *_psUnityLauncherEntry = nullptr;
|
||||
#endif // !TDESKTOP_DISABLE_UNITY_INTEGRATION
|
||||
#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||
|
||||
quint32 djbStringHash(QString string) {
|
||||
quint32 hash = 5381;
|
||||
QByteArray chars = string.toLatin1();
|
||||
for(int i = 0; i < chars.length(); i++){
|
||||
hash = (hash << 5) + hash + chars[i];
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
MainWindow::MainWindow() {
|
||||
|
@ -336,16 +345,20 @@ void MainWindow::updateIconCounters() {
|
|||
|
||||
const auto counter = Core::App().unreadBadge();
|
||||
|
||||
#if !defined(TDESKTOP_DISABLE_GTK_INTEGRATION) && !defined(TDESKTOP_DISABLE_UNITY_INTEGRATION)
|
||||
if (_psUnityLauncherEntry) {
|
||||
if (useUnityCount) {
|
||||
QVariantMap dbusUnityProperties;
|
||||
if (counter > 0) {
|
||||
Libs::unity_launcher_entry_set_count(_psUnityLauncherEntry, (counter > 9999) ? 9999 : counter);
|
||||
Libs::unity_launcher_entry_set_count_visible(_psUnityLauncherEntry, TRUE);
|
||||
// Gnome requires that count is a 64bit integer
|
||||
dbusUnityProperties.insert("count", (qint64) ((counter > 9999) ? 9999 : (counter)));
|
||||
dbusUnityProperties.insert("count-visible", true);
|
||||
} else {
|
||||
Libs::unity_launcher_entry_set_count_visible(_psUnityLauncherEntry, FALSE);
|
||||
dbusUnityProperties.insert("count-visible", false);
|
||||
}
|
||||
QDBusMessage signal = QDBusMessage::createSignal(_dbusPath, "com.canonical.Unity.LauncherEntry", "Update");
|
||||
signal << "application://" + _desktopFile;
|
||||
signal << dbusUnityProperties;
|
||||
QDBusConnection::sessionBus().send(signal);
|
||||
}
|
||||
#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION && !TDESKTOP_DISABLE_UNITY_INTEGRATION
|
||||
|
||||
if (noQtTrayIcon) {
|
||||
#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||
|
@ -441,15 +454,6 @@ void MainWindow::LibsLoaded() {
|
|||
if (useStatusIcon) {
|
||||
DEBUG_LOG(("Status icon api loaded!"));
|
||||
}
|
||||
|
||||
#ifndef TDESKTOP_DISABLE_UNITY_INTEGRATION
|
||||
useUnityCount = (Libs::unity_launcher_entry_get_for_desktop_id != nullptr)
|
||||
&& (Libs::unity_launcher_entry_set_count != nullptr)
|
||||
&& (Libs::unity_launcher_entry_set_count_visible != nullptr);
|
||||
if (useUnityCount) {
|
||||
DEBUG_LOG(("Unity count api loaded!"));
|
||||
}
|
||||
#endif // !TDESKTOP_DISABLE_UNITY_INTEGRATION
|
||||
#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||
}
|
||||
|
||||
|
@ -544,23 +548,29 @@ void MainWindow::psCreateTrayIcon() {
|
|||
void MainWindow::psFirstShow() {
|
||||
psCreateTrayIcon();
|
||||
|
||||
#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) {
|
||||
LOG(("Found Unity Launcher entry telegramdesktop.desktop!"));
|
||||
} else {
|
||||
_psUnityLauncherEntry = Libs::unity_launcher_entry_get_for_desktop_id("Telegram.desktop");
|
||||
if (_psUnityLauncherEntry) {
|
||||
LOG(("Found Unity Launcher entry Telegram.desktop!"));
|
||||
if (QDBusInterface("com.canonical.Unity", "/").isValid()) {
|
||||
auto snapName = QString::fromLatin1(qgetenv("SNAP_NAME"));
|
||||
if(snapName.isEmpty()) {
|
||||
if(!QStandardPaths::locate(QStandardPaths::ApplicationsLocation, "telegramdesktop.desktop").isEmpty()) {
|
||||
_desktopFile = "telegramdesktop.desktop";
|
||||
LOG(("Found Unity Launcher entry telegramdesktop.desktop!"));
|
||||
useUnityCount=true;
|
||||
} else if(!QStandardPaths::locate(QStandardPaths::ApplicationsLocation, "Telegram.desktop").isEmpty()) {
|
||||
_desktopFile = "telegramdesktop.desktop";
|
||||
LOG(("Found Unity Launcher entry telegramdesktop.desktop!"));
|
||||
useUnityCount=true;
|
||||
} else {
|
||||
LOG(("Could not get Unity Launcher entry!"));
|
||||
}
|
||||
} else {
|
||||
LOG(("SNAP Enviroment detected, setting Launcher entry to %1-telegramdesktop.desktop!").arg(snapName));
|
||||
_desktopFile = snapName + "_telegramdesktop.desktop";
|
||||
useUnityCount=true;
|
||||
}
|
||||
_dbusPath = "/com/canonical/unity/launcherentry/" + QString::number(djbStringHash("application://" + _desktopFile));
|
||||
} else {
|
||||
LOG(("Not using Unity Launcher count."));
|
||||
}
|
||||
#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION && !TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||
|
||||
psUpdateMargins();
|
||||
|
||||
|
@ -613,12 +623,6 @@ MainWindow::~MainWindow() {
|
|||
Libs::g_object_unref(_trayIndicator);
|
||||
_trayIndicator = nullptr;
|
||||
}
|
||||
#ifndef TDESKTOP_DISABLE_UNITY_INTEGRATION
|
||||
if (_psUnityLauncherEntry) {
|
||||
Libs::g_object_unref(_psUnityLauncherEntry);
|
||||
_psUnityLauncherEntry = nullptr;
|
||||
}
|
||||
#endif // ! TDESKTOP_DISABLE_UNITY_INTEGRATION
|
||||
#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ You will need GCC 7.2 and CMake 3.2 installed. To install them and all the requi
|
|||
sudo add-apt-repository --remove ppa:ubuntu-toolchain-r/test
|
||||
sudo add-apt-repository --remove ppa:george-edison55/cmake-3.x
|
||||
|
||||
sudo apt-get install git libexif-dev liblzma-dev libz-dev libssl-dev libappindicator-dev libunity-dev libicu-dev libdee-dev libdrm-dev dh-autoreconf autoconf automake build-essential libass-dev libfreetype6-dev libgpac-dev libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-image0-dev libxcb-shm0-dev libxcb-xfixes0-dev libxcb-keysyms1-dev libxcb-icccm4-dev libxcb-render-util0-dev libxcb-util0-dev libxrender-dev libasound-dev libpulse-dev libxcb-sync0-dev libxcb-randr0-dev libx11-xcb-dev libffi-dev libncurses5-dev pkg-config texi2html zlib1g-dev yasm cmake xutils-dev bison python-xcbgen
|
||||
sudo apt-get install git libexif-dev liblzma-dev libz-dev libssl-dev libappindicator-dev libicu-dev libdee-dev libdrm-dev dh-autoreconf autoconf automake build-essential libass-dev libfreetype6-dev libgpac-dev libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-image0-dev libxcb-shm0-dev libxcb-xfixes0-dev libxcb-keysyms1-dev libxcb-icccm4-dev libxcb-render-util0-dev libxcb-util0-dev libxrender-dev libasound-dev libpulse-dev libxcb-sync0-dev libxcb-randr0-dev libx11-xcb-dev libffi-dev libncurses5-dev pkg-config texi2html zlib1g-dev yasm cmake xutils-dev bison python-xcbgen
|
||||
|
||||
You can set the multithreaded make parameter by running
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ parts:
|
|||
- libicu-dev
|
||||
- liblzma-dev
|
||||
- libssl-dev
|
||||
- libunity-dev
|
||||
- libdee-dev
|
||||
- zlib1g-dev
|
||||
gyp-file: Telegram/gyp/Telegram.gyp
|
||||
build-type: 'Release'
|
||||
|
@ -133,7 +133,6 @@ parts:
|
|||
- libappindicator3-1
|
||||
- libnotify4
|
||||
- libpulse0
|
||||
- libunity9
|
||||
after: [desktop-gtk3]
|
||||
stage:
|
||||
- -./usr/share/fonts/**
|
||||
|
|
Loading…
Add table
Reference in a new issue