void LauncherApplication::setDesktopFile(const QString& desktop_file) { QString oldDesktopFile = this->desktop_file(); QByteArray byte_array = desktop_file.toUtf8(); gchar *file = byte_array.data(); if(desktop_file.startsWith("/")) { /* It looks like a full path to a desktop file */ m_appInfo.reset((GAppInfo*)g_desktop_app_info_new_from_filename(file)); } else { /* It might just be a desktop file name; let GIO look for the actual desktop file for us */ /* The docs for g_desktop_app_info_new() says it respects "-" to "/" substitution as per XDG Menu Spec, but it only seems to work for exactly 1 substitution where as Wine programs often require many. Bottom line: We must do some manual trial and error to find desktop files in deeply nested directories. Same workaround is implemented in Unity: plugins/unityshell/src/PlacesView.cpp:731 References: https://bugzilla.gnome.org/show_bug.cgi?id=654566 https://bugs.launchpad.net/unity-2d/+bug/794471 */ int slash_index; do { m_appInfo.reset((GAppInfo*)g_desktop_app_info_new(file)); slash_index = byte_array.indexOf("-"); if (slash_index == -1) { break; } byte_array.replace(slash_index, 1, "/"); file = byte_array.data(); } while (m_appInfo.isNull()); } /* setDesktopFile(…) may be called with the same desktop file, when e.g. the contents of the file have changed. Some properties may have changed. */ QString newDesktopFile = this->desktop_file(); if (newDesktopFile != oldDesktopFile) { Q_EMIT desktopFileChanged(newDesktopFile); } /* Emit the Changed signal on all properties that can depend on m_appInfo m_application's properties take precedence over m_appInfo's */ if (m_appInfo != NULL) { if (m_application == NULL) { Q_EMIT nameChanged(name()); Q_EMIT iconChanged(icon()); } Q_EMIT executableChanged(executable()); } /* Update the list of static shortcuts (quicklist entries defined in the desktop file). */ m_staticShortcuts.reset(indicator_desktop_shortcuts_new(newDesktopFile.toUtf8().constData(), "Unity")); monitorDesktopFile(newDesktopFile); }
void Updater::run() { connect(ai, SIGNAL(startUpdate(QList<FileUpdate>)), this, SLOT(startUpdate(QList<FileUpdate>))); connect(dm, SIGNAL(downloadsFinished(QList<FileUpdate>)), this, SLOT(downloadFinished(QList<FileUpdate>))); connect(ai, SIGNAL(applicationClosed(bool)), this, SLOT(startExchange(bool))); connect(ai, SIGNAL(executableChanged(QString)), this, SLOT(setExecutable(QString))); connect(fh, SIGNAL(exchangingFinished(bool)), this, SLOT(exchangeFinished(bool))); connect(dm, SIGNAL(error(QString)), ai, SLOT(sendError(QString))); connect(fh, SIGNAL(error(QString)), ai, SLOT(sendError(QString))); connect(ai, SIGNAL(close()), this, SLOT(closeRequested())); }
void LauncherApplication::setSnStartupSequence(SnStartupSequence* sequence) { if (sequence != NULL) { if (!sn_startup_sequence_get_completed(sequence)) { /* 'launching' property becomes true for a few seconds */ m_launching_timer.start(); } else { m_launching_timer.stop(); } sn_startup_sequence_ref(sequence); } m_snStartupSequence.reset(sequence); nameChanged(name()); iconChanged(icon()); executableChanged(executable()); launchingChanged(launching()); }