From 8b727979d0176d6f35ab43d65797f79a18dc58b8 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 15 Jan 2015 21:56:09 +0300 Subject: [PATCH 1/3] moving tray icon images to /tmp/ --- Telegram/SourceFiles/pspecific_linux.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/pspecific_linux.cpp b/Telegram/SourceFiles/pspecific_linux.cpp index 0c17b8551e..297ae85f20 100644 --- a/Telegram/SourceFiles/pspecific_linux.cpp +++ b/Telegram/SourceFiles/pspecific_linux.cpp @@ -259,7 +259,7 @@ namespace { int32 counter = App::histories().unreadFull, counterSlice = (counter >= 1000) ? (1000 + (counter % 100)) : counter; bool muted = (App::histories().unreadMuted >= counter); - QString name = cWorkingDir() + qsl("tdata/ticons/ico%1_%2_%3.png").arg(muted ? "mute" : "").arg(_trayIconSize).arg(counterSlice); + QString name = qsl("/tmp/tdesktop-icons/ico%1_%2_%3.png").arg(muted ? "mute" : "").arg(_trayIconSize).arg(counterSlice); QFileInfo info(name); if (info.exists()) return name; From c4ace88643b4f48014933bec822928de938dd46d Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 16 Jan 2015 13:02:44 +0300 Subject: [PATCH 2/3] fixed appindicator for ubuntu - glib now is linked not statically --- Telegram/FixMake.sh | 1 - Telegram/FixMake32.sh | 1 - Telegram/SourceFiles/pspecific_linux.cpp | 34 ++++++++++++++---------- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/Telegram/FixMake.sh b/Telegram/FixMake.sh index 1f88c1c561..693d69c163 100755 --- a/Telegram/FixMake.sh +++ b/Telegram/FixMake.sh @@ -13,7 +13,6 @@ sed -i 's/\-lz/\/usr\/lib\/x86_64\-linux\-gnu\/libz\.a/g' Makefile sed -i 's/\-lssl/\/usr\/lib\/x86_64\-linux\-gnu\/libssl\.a/g' Makefile sed -i 's/\-lcrypto/\/usr\/lib\/x86_64\-linux\-gnu\/libcrypto\.a/g' Makefile sed -i 's/\-lexif/\/usr\/lib\/x86_64\-linux\-gnu\/libexif\.a/g' Makefile -sed -i 's/\-lglib\-2\.0/\/usr\/lib\/x86_64\-linux\-gnu\/libglib\-2\.0\.a/g' Makefile sed -i 's/\-lopusfile/\/usr\/local\/lib\/libopusfile\.a/g' Makefile sed -i 's/\-lopus/\/usr\/local\/lib\/libopus\.a/g' Makefile sed -i 's/\-lopenal/\/usr\/local\/lib\/libopenal\.a/g' Makefile diff --git a/Telegram/FixMake32.sh b/Telegram/FixMake32.sh index f575a00371..10492cc067 100755 --- a/Telegram/FixMake32.sh +++ b/Telegram/FixMake32.sh @@ -13,7 +13,6 @@ sed -i 's/\-lz/\/usr\/lib\/i386\-linux\-gnu\/libz\.a/g' Makefile sed -i 's/\-lssl/\/usr\/lib\/i386\-linux\-gnu\/libssl\.a/g' Makefile sed -i 's/\-lcrypto/\/usr\/lib\/i386\-linux\-gnu\/libcrypto\.a/g' Makefile sed -i 's/\-lexif/\/usr\/lib\/i386\-linux\-gnu\/libexif\.a/g' Makefile -sed -i 's/\-lglib\-2\.0/\/usr\/lib\/i386\-linux\-gnu\/libglib\-2\.0\.a/g' Makefile sed -i 's/\-lopusfile/\/usr\/local\/lib\/libopusfile\.a/g' Makefile sed -i 's/\-lopus/\/usr\/local\/lib\/libopus\.a/g' Makefile sed -i 's/\-lopenal/\/usr\/local\/lib\/libopenal\.a/g' Makefile diff --git a/Telegram/SourceFiles/pspecific_linux.cpp b/Telegram/SourceFiles/pspecific_linux.cpp index 297ae85f20..a3bc02e719 100644 --- a/Telegram/SourceFiles/pspecific_linux.cpp +++ b/Telegram/SourceFiles/pspecific_linux.cpp @@ -114,8 +114,11 @@ namespace { typedef void (*f_app_indicator_set_menu)(AppIndicator *self, GtkMenu *menu); f_app_indicator_set_menu ps_app_indicator_set_menu = 0; - typedef void (*f_app_indicator_set_icon)(AppIndicator *self, const gchar *icon_name); - f_app_indicator_set_icon ps_app_indicator_set_icon = 0; + typedef void (*f_app_indicator_set_icon_full)(AppIndicator *self, const gchar *icon_name, const gchar *icon_desc); + f_app_indicator_set_icon_full ps_app_indicator_set_icon_full = 0; + + typedef void (*f_app_indicator_set_icon_theme_path)(AppIndicator *self, const gchar *icon_theme_path); + f_app_indicator_set_icon_theme_path ps_app_indicator_set_icon_theme_path = 0; typedef gboolean (*f_gdk_init_check)(gint *argc, gchar ***argv); f_gdk_init_check ps_gdk_init_check = 0; @@ -259,7 +262,7 @@ namespace { int32 counter = App::histories().unreadFull, counterSlice = (counter >= 1000) ? (1000 + (counter % 100)) : counter; bool muted = (App::histories().unreadMuted >= counter); - QString name = qsl("/tmp/tdesktop-icons/ico%1_%2_%3.png").arg(muted ? "mute" : "").arg(_trayIconSize).arg(counterSlice); + QString name = cWorkingDir() + qsl("tdata/ticons/ico%1_%2_%3.png").arg(muted ? "mute" : "").arg(_trayIconSize).arg(counterSlice); QFileInfo info(name); if (info.exists()) return name; @@ -365,7 +368,8 @@ namespace { if (!loadFunction(lib_indicator, "app_indicator_new", ps_app_indicator_new)) return; if (!loadFunction(lib_indicator, "app_indicator_set_status", ps_app_indicator_set_status)) return; if (!loadFunction(lib_indicator, "app_indicator_set_menu", ps_app_indicator_set_menu)) return; - if (!loadFunction(lib_indicator, "app_indicator_set_icon", ps_app_indicator_set_icon)) return; + if (!loadFunction(lib_indicator, "app_indicator_set_icon_full", ps_app_indicator_set_icon_full)) return; + if (!loadFunction(lib_indicator, "app_indicator_set_icon_theme_path", ps_app_indicator_set_icon_theme_path)) return; useAppIndicator = true; } void setupUnity() { @@ -528,9 +532,13 @@ void PsMainWindow::psUpdateWorkmode() { void PsMainWindow::psUpdateIndicator() { _psUpdateIndicatorTimer.stop(); _psLastIndicatorUpdate = getms(); - QByteArray f = _trayIconImageFile().toUtf8(); - if (!f.isEmpty()) { - ps_app_indicator_set_icon(_trayIndicator, f.constData()); + QFileInfo f(_trayIconImageFile()); + if (f.exists()) { + QByteArray path = f.absoluteFilePath().toUtf8(), name = f.fileName().toUtf8(); + name = name.mid(0, name.size() - 4); + ps_app_indicator_set_icon_full(_trayIndicator, path.constData(), name); + } else { + useAppIndicator = false; } } @@ -659,9 +667,6 @@ void PsMainWindow::psUpdatedPosition() { void PsMainWindow::psStateChanged(Qt::WindowState state) { psUpdateSysMenu(state); psUpdateMargins(); -// if (state == Qt::WindowMinimized && GetWindowLong(ps_hWnd, GWL_HWNDPARENT)) { -// App::wnd()->minimizeToTray(); -// } psSavePosition(state); } @@ -670,11 +675,12 @@ void PsMainWindow::psCreateTrayIcon() { if (ps_gtk_init_check(0, 0)) { _trayMenu = ps_gtk_menu_new(); if (_trayMenu) { - QByteArray f = _trayIconImageFile().toUtf8(); - if (f.isEmpty()) { - useAppIndicator = false; + QFileInfo f(_trayIconImageFile()); + if (f.exists()) { + QByteArray path = f.absoluteFilePath().toUtf8(); + _trayIndicator = ps_app_indicator_new("Telegram Desktop", path.constData(), APP_INDICATOR_CATEGORY_APPLICATION_STATUS); } else { - _trayIndicator = ps_app_indicator_new("Telegram Desktop", f.constData(), APP_INDICATOR_CATEGORY_COMMUNICATIONS); + useAppIndicator = false; } } } From dfd6936d64eab917548d78d24714463eca76ec31 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 16 Jan 2015 13:26:20 +0300 Subject: [PATCH 3/3] fixing cyclic resize --- Telegram/SourceFiles/pspecific_linux.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Telegram/SourceFiles/pspecific_linux.cpp b/Telegram/SourceFiles/pspecific_linux.cpp index a3bc02e719..e6866b777e 100644 --- a/Telegram/SourceFiles/pspecific_linux.cpp +++ b/Telegram/SourceFiles/pspecific_linux.cpp @@ -117,9 +117,6 @@ namespace { typedef void (*f_app_indicator_set_icon_full)(AppIndicator *self, const gchar *icon_name, const gchar *icon_desc); f_app_indicator_set_icon_full ps_app_indicator_set_icon_full = 0; - typedef void (*f_app_indicator_set_icon_theme_path)(AppIndicator *self, const gchar *icon_theme_path); - f_app_indicator_set_icon_theme_path ps_app_indicator_set_icon_theme_path = 0; - typedef gboolean (*f_gdk_init_check)(gint *argc, gchar ***argv); f_gdk_init_check ps_gdk_init_check = 0; @@ -195,10 +192,9 @@ namespace { } gboolean _trayIconResized(GtkStatusIcon *status_icon, gint size, gpointer popup_menu) { - std::cerr << "New tray icon size: " << size << "\n"; - _trayIconSize = size - 2; + _trayIconSize = size; if (App::wnd()) App::wnd()->psUpdateCounter(); - return TRUE; + return FALSE; } #if Q_BYTE_ORDER == Q_BIG_ENDIAN @@ -252,7 +248,7 @@ namespace { layerSize = -20; } QImage layer = App::wnd()->iconWithCounter(layerSize, counter, (muted ? st::counterMuteBG : st::counterBG), false); - p.drawImage(_trayIconImage.width() - layer.width(), _trayIconImage.height() - layer.height(), layer); + p.drawImage(_trayIconImage.width() - layer.width() - 1, _trayIconImage.height() - layer.height() - 1, layer); } } return _trayIconImage; @@ -369,7 +365,6 @@ namespace { if (!loadFunction(lib_indicator, "app_indicator_set_status", ps_app_indicator_set_status)) return; if (!loadFunction(lib_indicator, "app_indicator_set_menu", ps_app_indicator_set_menu)) return; if (!loadFunction(lib_indicator, "app_indicator_set_icon_full", ps_app_indicator_set_icon_full)) return; - if (!loadFunction(lib_indicator, "app_indicator_set_icon_theme_path", ps_app_indicator_set_icon_theme_path)) return; useAppIndicator = true; } void setupUnity() {