Skip to content

Commit

Permalink
New define: TDESKTOP_DISABLE_UNITY_INTEGRATION
Browse files Browse the repository at this point in the history
Signed-off-by: Egor Y. Egorov <[email protected]> (github: eegorov)
  • Loading branch information
eegorov committed Jun 29, 2016
1 parent 15eef5f commit bd8bb42
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions .travis/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"'
Expand Down
4 changes: 4 additions & 0 deletions Telegram/SourceFiles/platform/linux/linux_libs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions Telegram/SourceFiles/platform/linux/linux_libs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;

Expand All @@ -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
8 changes: 8 additions & 0 deletions Telegram/SourceFiles/platform/linux/main_window_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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);
Expand All @@ -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) {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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) {
Expand All @@ -613,6 +620,7 @@ void MainWindow::psFirstShow() {
} else {
LOG(("Not using Unity Launcher count."));
}
#endif // TDESKTOP_DISABLE_UNITY_INTEGRATION

psUpdateMargins();

Expand Down

0 comments on commit bd8bb42

Please sign in to comment.