New define: TDESKTOP_DISABLE_UNITY_INTEGRATION

Signed-off-by: Egor Y. Egorov <egor.y.egorov@gmail.com> (github: eegorov)
This commit is contained in:
eegorov 2016-06-29 08:38:42 +06:00
parent 15eef5f7b9
commit bd8bb426be
5 changed files with 21 additions and 0 deletions

View File

@ -9,6 +9,7 @@ env:
- BUILD_VERSION="disable_crash_reports"
- BUILD_VERSION="disable_network_proxy"
- BUILD_VERSION="disable_desktop_file_generation"
- BUILD_VERSION="disable_unity_integration"
arch:
packages:

View File

@ -83,6 +83,10 @@ prepare() {
options+="\nDEFINES += TDESKTOP_DISABLE_DESKTOP_FILE_GENERATION"
fi
if [[ $BUILD_VERSION == *"disable_unity_integration"* ]]; then
options+="\nDEFINES += TDESKTOP_DISABLE_UNITY_INTEGRATION"
fi
options+='\nINCLUDEPATH += "/usr/lib/glib-2.0/include"'
options+='\nINCLUDEPATH += "/usr/lib/gtk-2.0/include"'
options+='\nINCLUDEPATH += "/usr/include/opus"'

View File

@ -118,9 +118,11 @@ f_gtk_get_current_event_time gtk_get_current_event_time = nullptr;
f_g_object_ref_sink g_object_ref_sink = nullptr;
f_g_object_unref g_object_unref = nullptr;
f_g_idle_add g_idle_add = 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
void start() {
DEBUG_LOG(("Loading libraries"));
@ -174,6 +176,7 @@ void start() {
LOG(("Could not load gtk-x11-2.0!"));
}
#ifndef TDESKTOP_DISABLE_UNITY_INTEGRATION
if (QString(getenv("XDG_CURRENT_DESKTOP")).toLower() == qstr("unity")) {
QLibrary lib_unity(qstr("unity"), 9, 0);
loadLibrary(lib_unity, "unity", 9);
@ -182,6 +185,7 @@ void start() {
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
}
} // namespace Libs

View File

@ -27,7 +27,9 @@ extern "C" {
#define signals public
} // extern "C"
#ifndef TDESKTOP_DISABLE_UNITY_INTEGRATION
#include <unity/unity/unity.h>
#endif // TDESKTOP_DISABLE_UNITY_INTEGRATION
namespace Platform {
namespace Libs {
@ -167,6 +169,7 @@ extern f_g_object_unref g_object_unref;
typedef guint (*f_g_idle_add)(GSourceFunc function, gpointer data);
extern f_g_idle_add g_idle_add;
#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;
@ -175,6 +178,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
} // namespace Libs
} // namespace Platform

View File

@ -181,7 +181,9 @@ static gboolean _trayIconCheck(gpointer/* pIn*/) {
return FALSE;
}
#ifndef TDESKTOP_DISABLE_UNITY_INTEGRATION
UnityLauncherEntry *_psUnityLauncherEntry = nullptr;
#endif // TDESKTOP_DISABLE_UNITY_INTEGRATION
} // namespace
@ -319,6 +321,7 @@ void MainWindow::psUpdateCounter() {
int32 counter = App::histories().unreadBadge();
setWindowTitle((counter > 0) ? qsl("Telegram (%1)").arg(counter) : qsl("Telegram"));
#ifndef TDESKTOP_DISABLE_UNITY_INTEGRATION
if (_psUnityLauncherEntry) {
if (counter > 0) {
Libs::unity_launcher_entry_set_count(_psUnityLauncherEntry, (counter > 9999) ? 9999 : counter);
@ -327,6 +330,7 @@ void MainWindow::psUpdateCounter() {
Libs::unity_launcher_entry_set_count_visible(_psUnityLauncherEntry, FALSE);
}
}
#endif // TDESKTOP_DISABLE_UNITY_INTEGRATION
if (noQtTrayIcon) {
if (useAppIndicator) {
@ -416,12 +420,14 @@ void MainWindow::LibsLoaded() {
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
}
void MainWindow::psUpdateDelegate() {
@ -598,6 +604,7 @@ void MainWindow::psCreateTrayIcon() {
void MainWindow::psFirstShow() {
psCreateTrayIcon();
#ifndef TDESKTOP_DISABLE_UNITY_INTEGRATION
if (useUnityCount) {
_psUnityLauncherEntry = Libs::unity_launcher_entry_get_for_desktop_id("telegramdesktop.desktop");
if (_psUnityLauncherEntry) {
@ -613,6 +620,7 @@ void MainWindow::psFirstShow() {
} else {
LOG(("Not using Unity Launcher count."));
}
#endif // TDESKTOP_DISABLE_UNITY_INTEGRATION
psUpdateMargins();