[gnome-software] Fix launching various KDE4 applications
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Fix launching various KDE4 applications
- Date: Wed, 27 Apr 2016 09:39:23 +0000 (UTC)
commit 27448ec728b69b8120a186a013ee55c02304cf0f
Author: Richard Hughes <richard hughsie com>
Date: Wed Apr 27 10:31:47 2016 +0100
Fix launching various KDE4 applications
Based on a patch by Iain Lane <iain orangesquash org uk>, many thanks.
src/gs-application.c | 2 +-
src/gs-dbus-helper.c | 3 ++-
src/gs-plugin.c | 3 ++-
src/gs-utils.c | 24 ++++++++++++++++++++++++
src/gs-utils.h | 3 +++
5 files changed, 32 insertions(+), 3 deletions(-)
---
diff --git a/src/gs-application.c b/src/gs-application.c
index 51af5d9..81e290d 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -641,7 +641,7 @@ launch_activated (GSimpleAction *action,
desktop_id = g_variant_get_string (parameter, NULL);
display = gdk_display_get_default ();
- appinfo = G_APP_INFO (g_desktop_app_info_new (desktop_id));
+ appinfo = G_APP_INFO (gs_utils_get_desktop_app_info (desktop_id));
if (appinfo == NULL) {
g_warning ("no such desktop file: %s", desktop_id);
return;
diff --git a/src/gs-dbus-helper.c b/src/gs-dbus-helper.c
index e657f2a..59a2c4f 100644
--- a/src/gs-dbus-helper.c
+++ b/src/gs-dbus-helper.c
@@ -32,6 +32,7 @@
#include "gs-packagekit-modify2-generated.h"
#include "gs-resources.h"
#include "gs-shell-extras.h"
+#include "gs-utils.h"
struct _GsDbusHelper {
GObject parent;
@@ -297,7 +298,7 @@ notify_search_resources (GsShellExtrasMode mode,
g_autoptr(GNotification) n = NULL;
if (desktop_id != NULL) {
- app_info = g_desktop_app_info_new (desktop_id);
+ app_info = gs_utils_get_desktop_app_info (desktop_id);
if (app_info != NULL)
app_name = g_app_info_get_name (G_APP_INFO (app_info));
}
diff --git a/src/gs-plugin.c b/src/gs-plugin.c
index 6f97ca3..75e9da0 100644
--- a/src/gs-plugin.c
+++ b/src/gs-plugin.c
@@ -45,6 +45,7 @@
#include "gs-os-release.h"
#include "gs-plugin-private.h"
#include "gs-plugin.h"
+#include "gs-utils.h"
typedef struct
{
@@ -568,7 +569,7 @@ gs_plugin_app_launch (GsPlugin *plugin, GsApp *app, GError **error)
desktop_id);
return FALSE;
}
- appinfo = G_APP_INFO (g_desktop_app_info_new (desktop_id));
+ appinfo = G_APP_INFO (gs_utils_get_desktop_app_info (desktop_id));
if (appinfo == NULL) {
g_set_error (error,
GS_PLUGIN_ERROR,
diff --git a/src/gs-utils.c b/src/gs-utils.c
index ff69ad1..2f7d050 100644
--- a/src/gs-utils.c
+++ b/src/gs-utils.c
@@ -915,4 +915,28 @@ gs_utils_strv_fnmatch (gchar **strv, const gchar *str)
return FALSE;
}
+/**
+ * gs_utils_get_desktop_app_info:
+ */
+GDesktopAppInfo *
+gs_utils_get_desktop_app_info (const gchar *id)
+{
+ GDesktopAppInfo *app_info;
+
+ /* try to get the standard app-id */
+ app_info = g_desktop_app_info_new (id);
+
+ /* KDE is a special project because it believes /usr/share/applications
+ * isn't KDE enough. For this reason we support falling back to the
+ * "kde4-" prefixed ID to avoid educating various self-righteous
+ * upstreams about the correct ID to use in the AppData file. */
+ if (app_info == NULL) {
+ g_autofree gchar *kde_id = NULL;
+ kde_id = g_strdup_printf ("%s-%s", "kde4", id);
+ app_info = g_desktop_app_info_new (kde_id);
+ }
+
+ return app_info;
+}
+
/* vim: set noexpandtab: */
diff --git a/src/gs-utils.h b/src/gs-utils.h
index 27a4b3e..2524d44 100644
--- a/src/gs-utils.h
+++ b/src/gs-utils.h
@@ -22,6 +22,7 @@
#ifndef __GS_UTILS_H
#define __GS_UTILS_H
+#include <gio/gdesktopappinfo.h>
#include <gtk/gtk.h>
#include "gs-app.h"
@@ -75,6 +76,8 @@ void gs_utils_widget_set_custom_css (GsApp *app,
gboolean gs_utils_strv_fnmatch (gchar **strv,
const gchar *str);
+GDesktopAppInfo *gs_utils_get_desktop_app_info (const gchar *id);
+
G_END_DECLS
#endif /* __GS_UTILS_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]