Commit 8b58843d authored by Kalev Lember's avatar Kalev Lember
Browse files

Support opening appstream URLs

Add support for appstream URLs so that web pages could link to their
favourite apps with e.g. <a href="appstream:0ad.desktop">Install 0ad</a>

https://bugzilla.gnome.org/show_bug.cgi?id=736053
parent 6f4d5f4a
......@@ -29,6 +29,7 @@
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <gio/gdesktopappinfo.h>
#include <libsoup/soup.h>
#include <packagekit-glib2/packagekit.h>
#ifdef GDK_WINDOWING_X11
......@@ -693,6 +694,37 @@ gs_application_handle_local_options (GApplication *app, GVariantDict *options)
return -1;
}
static void
gs_application_open (GApplication *application,
GFile **files,
gint n_files,
const gchar *hint)
{
GsApplication *app = GS_APPLICATION (application);
gint i;
for (i = 0; i < n_files; i++) {
g_autofree gchar *str = g_file_get_uri (files[i]);
g_autoptr(SoupURI) uri = NULL;
uri = soup_uri_new (str);
if (!SOUP_URI_IS_VALID (uri))
continue;
if (g_strcmp0 (soup_uri_get_scheme (uri), "appstream") == 0) {
const gchar *path = soup_uri_get_path (uri);
/* trim any leading slashes */
while (*path == '/')
path++;
g_action_group_activate_action (G_ACTION_GROUP (app),
"details",
g_variant_new ("(ss)", path, ""));
}
}
}
static void
gs_application_class_init (GsApplicationClass *class)
{
......@@ -700,6 +732,7 @@ gs_application_class_init (GsApplicationClass *class)
G_APPLICATION_CLASS (class)->startup = gs_application_startup;
G_APPLICATION_CLASS (class)->activate = gs_application_activate;
G_APPLICATION_CLASS (class)->handle_local_options = gs_application_handle_local_options;
G_APPLICATION_CLASS (class)->open = gs_application_open;
G_APPLICATION_CLASS (class)->dbus_register = gs_application_dbus_register;
G_APPLICATION_CLASS (class)->dbus_unregister = gs_application_dbus_unregister;
}
......@@ -710,6 +743,7 @@ gs_application_new (void)
g_set_prgname("org.gnome.Software");
return g_object_new (GS_APPLICATION_TYPE,
"application-id", "org.gnome.Software",
"flags", G_APPLICATION_HANDLES_OPEN,
"inactivity-timeout", 12000,
NULL);
}
......
......@@ -2,12 +2,13 @@
_Name=Software
_Comment=Add, remove or update software on this computer
Icon=gnome-software
Exec=gnome-software
Exec=gnome-software %U
Terminal=false
Type=Application
Categories=GNOME;GTK;System;PackageManager;
_Keywords=Updates;Upgrade;Sources;Repositories;Preferences;Install;Uninstall;Program;Software;App;Store;
StartupNotify=true
MimeType=x-scheme-handler/appstream;
X-GNOME-Bugzilla-Bugzilla=GNOME
X-GNOME-Bugzilla-Product=gnome-software
X-GNOME-Bugzilla-Component=gnome-software
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment