mirror of https://github.com/procxx/kepka.git
				
				
				
			fixed libappindicator load:q
This commit is contained in:
		
							parent
							
								
									9e43f1b5de
								
							
						
					
					
						commit
						2f9b64fdd7
					
				| 
						 | 
					@ -330,9 +330,13 @@ namespace {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        void setupGTK() {
 | 
					        void setupGTK() {
 | 
				
			||||||
            QLibrary lib_gtk(QLatin1String("gtk-x11-2.0"), 0, 0), lib_indicator(QLatin1String("appindicator"), 1, 0);
 | 
					            QLibrary lib_gtk(QLatin1String("gtk-x11-2.0"), 0, 0), lib_indicator(QLatin1String("appindicator"), 1, 0);
 | 
				
			||||||
            if (!lib_gtk.load()) {
 | 
					            if (lib_gtk.load()) {
 | 
				
			||||||
 | 
					                _initErrors.push_back(QString("Loaded 'gtk-x11-2.0' version 0 library"));
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
                lib_gtk.setFileNameAndVersion(QLatin1String("gtk-x11-2.0"), QString());
 | 
					                lib_gtk.setFileNameAndVersion(QLatin1String("gtk-x11-2.0"), QString());
 | 
				
			||||||
                if (!lib_gtk.load()) {
 | 
					                if (lib_gtk.load()) {
 | 
				
			||||||
 | 
					                    _initErrors.push_back(QString("Loaded 'gtk-x11-2.0' withou version library"));
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
                    _initErrors.push_back(QString("Failed to load 'gtk-x11-2.0' library!"));
 | 
					                    _initErrors.push_back(QString("Failed to load 'gtk-x11-2.0' library!"));
 | 
				
			||||||
                    return;
 | 
					                    return;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
| 
						 | 
					@ -355,16 +359,30 @@ namespace {
 | 
				
			||||||
            if (!loadFunction(lib_gtk, "g_signal_connect_data", ps_g_signal_connect_data)) return;
 | 
					            if (!loadFunction(lib_gtk, "g_signal_connect_data", ps_g_signal_connect_data)) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (lib_indicator.load()) {
 | 
					            if (lib_indicator.load()) {
 | 
				
			||||||
 | 
					                _initErrors.push_back(QString("Loaded 'appindicator' version 1 library"));
 | 
				
			||||||
                setupAppIndicator(lib_indicator);
 | 
					                setupAppIndicator(lib_indicator);
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                lib_indicator.setFileNameAndVersion(QLatin1String("appindicator"), QString());
 | 
					                lib_indicator.setFileNameAndVersion(QLatin1String("appindicator"), QString());
 | 
				
			||||||
                if (lib_indicator.load()) {
 | 
					                if (lib_indicator.load()) {
 | 
				
			||||||
 | 
					                    _initErrors.push_back(QString("Loaded 'appindicator' without version library"));
 | 
				
			||||||
 | 
					                    setupAppIndicator(lib_indicator);
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                    lib_indicator.setFileNameAndVersion(QLatin1String("appindicator3"), 1);
 | 
				
			||||||
 | 
					                    if (lib_indicator.load()) {
 | 
				
			||||||
 | 
					                        _initErrors.push_back(QString("Loaded 'appindicator3' version 1 library"));
 | 
				
			||||||
 | 
					                        setupAppIndicator(lib_indicator);
 | 
				
			||||||
 | 
					                    } else {
 | 
				
			||||||
 | 
					                        lib_indicator.setFileNameAndVersion(QLatin1String("appindicator3"), QString());
 | 
				
			||||||
 | 
					                        if (lib_indicator.load()) {
 | 
				
			||||||
 | 
					                            _initErrors.push_back(QString("Loaded 'appindicator3' without version library"));
 | 
				
			||||||
                            setupAppIndicator(lib_indicator);
 | 
					                            setupAppIndicator(lib_indicator);
 | 
				
			||||||
                        } else {
 | 
					                        } else {
 | 
				
			||||||
                            _initErrors.push_back(QString("Failed to load 'appindicator' library!"));
 | 
					                            _initErrors.push_back(QString("Failed to load 'appindicator' library!"));
 | 
				
			||||||
                            return;
 | 
					                            return;
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (!loadFunction(lib_gtk, "gdk_init_check", ps_gdk_init_check)) return;
 | 
					            if (!loadFunction(lib_gtk, "gdk_init_check", ps_gdk_init_check)) return;
 | 
				
			||||||
            if (!loadFunction(lib_gtk, "gdk_pixbuf_new_from_data", ps_gdk_pixbuf_new_from_data)) return;
 | 
					            if (!loadFunction(lib_gtk, "gdk_pixbuf_new_from_data", ps_gdk_pixbuf_new_from_data)) return;
 | 
				
			||||||
| 
						 | 
					@ -392,9 +410,13 @@ namespace {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        void setupUnity() {
 | 
					        void setupUnity() {
 | 
				
			||||||
            QLibrary lib_unity(QLatin1String("unity"), 9, 0);
 | 
					            QLibrary lib_unity(QLatin1String("unity"), 9, 0);
 | 
				
			||||||
            if (!lib_unity.load()) {
 | 
					            if (lib_unity.load()) {
 | 
				
			||||||
 | 
					                _initErrors.push_back(QString("Loaded 'unity' version 9 library"));
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
                lib_unity.setFileNameAndVersion(QLatin1String("unity"), QString());
 | 
					                lib_unity.setFileNameAndVersion(QLatin1String("unity"), QString());
 | 
				
			||||||
                if (!lib_unity.load()) {
 | 
					                if (lib_unity.load()) {
 | 
				
			||||||
 | 
					                    _initErrors.push_back(QString("Loaded 'unity' without version library"));
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
                    _initErrors.push_back(QString("Failed to load 'unity' library!"));
 | 
					                    _initErrors.push_back(QString("Failed to load 'unity' library!"));
 | 
				
			||||||
                    return;
 | 
					                    return;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
| 
						 | 
					@ -422,7 +444,7 @@ namespace {
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
    _PsEventFilter *_psEventFilter = 0;
 | 
					    _PsEventFilter *_psEventFilter = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    UnityLauncherEntry *_psUnityLauncherEntryOld = 0, *_psUnityLauncherEntry = 0;
 | 
					    UnityLauncherEntry *_psUnityLauncherEntry = 0;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
PsMainWindow::PsMainWindow(QWidget *parent) : QMainWindow(parent),
 | 
					PsMainWindow::PsMainWindow(QWidget *parent) : QMainWindow(parent),
 | 
				
			||||||
| 
						 | 
					@ -509,6 +531,7 @@ void PsMainWindow::psTrayMenuUpdated() {
 | 
				
			||||||
    if (useAppIndicator || useStatusIcon) {
 | 
					    if (useAppIndicator || useStatusIcon) {
 | 
				
			||||||
        const QList<QAction*> &actions = trayIconMenu->actions();
 | 
					        const QList<QAction*> &actions = trayIconMenu->actions();
 | 
				
			||||||
        if (_trayItems.isEmpty()) {
 | 
					        if (_trayItems.isEmpty()) {
 | 
				
			||||||
 | 
					            DEBUG_LOG(("Creating tray menu!"));
 | 
				
			||||||
            for (int32 i = 0, l = actions.size(); i != l; ++i) {
 | 
					            for (int32 i = 0, l = actions.size(); i != l; ++i) {
 | 
				
			||||||
                GtkWidget *item = ps_gtk_menu_item_new_with_label(actions.at(i)->text().toUtf8());
 | 
					                GtkWidget *item = ps_gtk_menu_item_new_with_label(actions.at(i)->text().toUtf8());
 | 
				
			||||||
                ps_gtk_menu_shell_append(PS_GTK_MENU_SHELL(_trayMenu), item);
 | 
					                ps_gtk_menu_shell_append(PS_GTK_MENU_SHELL(_trayMenu), item);
 | 
				
			||||||
| 
						 | 
					@ -519,6 +542,7 @@ void PsMainWindow::psTrayMenuUpdated() {
 | 
				
			||||||
                _trayItems.push_back(qMakePair(item, actions.at(i)));
 | 
					                _trayItems.push_back(qMakePair(item, actions.at(i)));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
 | 
					            DEBUG_LOG(("Updating tray menu!"));
 | 
				
			||||||
            for (int32 i = 0, l = actions.size(); i != l; ++i) {
 | 
					            for (int32 i = 0, l = actions.size(); i != l; ++i) {
 | 
				
			||||||
                if (i < _trayItems.size()) {
 | 
					                if (i < _trayItems.size()) {
 | 
				
			||||||
                    ps_gtk_menu_item_set_label(reinterpret_cast<GtkMenuItem*>(_trayItems.at(i).first), actions.at(i)->text().toUtf8());
 | 
					                    ps_gtk_menu_item_set_label(reinterpret_cast<GtkMenuItem*>(_trayItems.at(i).first), actions.at(i)->text().toUtf8());
 | 
				
			||||||
| 
						 | 
					@ -572,14 +596,6 @@ void PsMainWindow::psUpdateCounter() {
 | 
				
			||||||
	int32 counter = App::histories().unreadFull;
 | 
						int32 counter = App::histories().unreadFull;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    setWindowTitle((counter > 0) ? qsl("Telegram (%1)").arg(counter) : qsl("Telegram"));
 | 
					    setWindowTitle((counter > 0) ? qsl("Telegram (%1)").arg(counter) : qsl("Telegram"));
 | 
				
			||||||
    if (_psUnityLauncherEntryOld) {
 | 
					 | 
				
			||||||
        if (counter > 0) {
 | 
					 | 
				
			||||||
            ps_unity_launcher_entry_set_count(_psUnityLauncherEntryOld, (counter > 9999) ? 9999 : counter);
 | 
					 | 
				
			||||||
            ps_unity_launcher_entry_set_count_visible(_psUnityLauncherEntryOld, TRUE);
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            ps_unity_launcher_entry_set_count_visible(_psUnityLauncherEntryOld, FALSE);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    if (_psUnityLauncherEntry) {
 | 
					    if (_psUnityLauncherEntry) {
 | 
				
			||||||
        if (counter > 0) {
 | 
					        if (counter > 0) {
 | 
				
			||||||
            ps_unity_launcher_entry_set_count(_psUnityLauncherEntry, (counter > 9999) ? 9999 : counter);
 | 
					            ps_unity_launcher_entry_set_count(_psUnityLauncherEntry, (counter > 9999) ? 9999 : counter);
 | 
				
			||||||
| 
						 | 
					@ -706,13 +722,17 @@ void PsMainWindow::psCreateTrayIcon() {
 | 
				
			||||||
    if (useAppIndicator) {
 | 
					    if (useAppIndicator) {
 | 
				
			||||||
        DEBUG_LOG(("Trying to create AppIndicator"));
 | 
					        DEBUG_LOG(("Trying to create AppIndicator"));
 | 
				
			||||||
        if (ps_gtk_init_check(0, 0)) {
 | 
					        if (ps_gtk_init_check(0, 0)) {
 | 
				
			||||||
 | 
					            DEBUG_LOG(("Checked gtk with gtk_init_check!"));
 | 
				
			||||||
            _trayMenu = ps_gtk_menu_new();
 | 
					            _trayMenu = ps_gtk_menu_new();
 | 
				
			||||||
            if (_trayMenu) {
 | 
					            if (_trayMenu) {
 | 
				
			||||||
 | 
					                DEBUG_LOG(("Created gtk menu for appindicator!"));
 | 
				
			||||||
                QFileInfo f(_trayIconImageFile());
 | 
					                QFileInfo f(_trayIconImageFile());
 | 
				
			||||||
                if (f.exists()) {
 | 
					                if (f.exists()) {
 | 
				
			||||||
                    QByteArray path = QFile::encodeName(f.absoluteFilePath());
 | 
					                    QByteArray path = QFile::encodeName(f.absoluteFilePath());
 | 
				
			||||||
                   _trayIndicator = ps_app_indicator_new("Telegram Desktop", path.constData(), APP_INDICATOR_CATEGORY_APPLICATION_STATUS);
 | 
					                   _trayIndicator = ps_app_indicator_new("Telegram Desktop", path.constData(), APP_INDICATOR_CATEGORY_APPLICATION_STATUS);
 | 
				
			||||||
                   if (!_trayIndicator) {
 | 
					                   if (_trayIndicator) {
 | 
				
			||||||
 | 
					                       DEBUG_LOG(("Created appindicator!"));
 | 
				
			||||||
 | 
					                   } else {
 | 
				
			||||||
                       DEBUG_LOG(("Failed to app_indicator_new()!"));
 | 
					                       DEBUG_LOG(("Failed to app_indicator_new()!"));
 | 
				
			||||||
                   }
 | 
					                   }
 | 
				
			||||||
                } else {
 | 
					                } else {
 | 
				
			||||||
| 
						 | 
					@ -781,13 +801,14 @@ void PsMainWindow::psFirstShow() {
 | 
				
			||||||
        _psUnityLauncherEntry = ps_unity_launcher_entry_get_for_desktop_id("telegramdesktop.desktop");
 | 
					        _psUnityLauncherEntry = ps_unity_launcher_entry_get_for_desktop_id("telegramdesktop.desktop");
 | 
				
			||||||
        if (_psUnityLauncherEntry) {
 | 
					        if (_psUnityLauncherEntry) {
 | 
				
			||||||
            LOG(("Found Unity Launcher entry telegramdesktop.desktop!"));
 | 
					            LOG(("Found Unity Launcher entry telegramdesktop.desktop!"));
 | 
				
			||||||
        }
 | 
					        } else {
 | 
				
			||||||
        _psUnityLauncherEntryOld = ps_unity_launcher_entry_get_for_desktop_id("Telegram.desktop");
 | 
					            _psUnityLauncherEntry = ps_unity_launcher_entry_get_for_desktop_id("Telegram.desktop");
 | 
				
			||||||
        if (_psUnityLauncherEntryOld) {
 | 
					            if (_psUnityLauncherEntry) {
 | 
				
			||||||
                LOG(("Found Unity Launcher entry Telegram.desktop!"));
 | 
					                LOG(("Found Unity Launcher entry Telegram.desktop!"));
 | 
				
			||||||
        } else if (_psUnityLauncherEntry) {
 | 
					            } else {
 | 
				
			||||||
                LOG(("Could not get Unity Launcher entry!"));
 | 
					                LOG(("Could not get Unity Launcher entry!"));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        LOG(("Not using Unity Launcher count."));
 | 
					        LOG(("Not using Unity Launcher count."));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue