aboutsummaryrefslogtreecommitdiffstats
path: root/embed/ephy-embed-shell.c
diff options
context:
space:
mode:
authorXan Lopez <xan@igalia.com>2012-12-12 00:29:19 +0800
committerXan Lopez <xan@igalia.com>2012-12-12 19:22:33 +0800
commit6ede0c3ebcbc129ea1112ee9f43427231ab50e07 (patch)
treea7914732e5ce2b86eeaf7d44956371c610d341e4 /embed/ephy-embed-shell.c
parent7f6211d2901f70d571f18106bf97ff636712a712 (diff)
downloadgsoc2013-epiphany-6ede0c3ebcbc129ea1112ee9f43427231ab50e07.tar
gsoc2013-epiphany-6ede0c3ebcbc129ea1112ee9f43427231ab50e07.tar.gz
gsoc2013-epiphany-6ede0c3ebcbc129ea1112ee9f43427231ab50e07.tar.bz2
gsoc2013-epiphany-6ede0c3ebcbc129ea1112ee9f43427231ab50e07.tar.lz
gsoc2013-epiphany-6ede0c3ebcbc129ea1112ee9f43427231ab50e07.tar.xz
gsoc2013-epiphany-6ede0c3ebcbc129ea1112ee9f43427231ab50e07.tar.zst
gsoc2013-epiphany-6ede0c3ebcbc129ea1112ee9f43427231ab50e07.zip
Handle a bit more gracefully the self-launch detection
Check whether the app that will launch a given download is actually the browser itself, and do nothing *before* going ahead. Seems better than actually launching and then aborting on startup through UUID hacks.
Diffstat (limited to 'embed/ephy-embed-shell.c')
-rw-r--r--embed/ephy-embed-shell.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/embed/ephy-embed-shell.c b/embed/ephy-embed-shell.c
index c050d9764..9821d4f11 100644
--- a/embed/ephy-embed-shell.c
+++ b/embed/ephy-embed-shell.c
@@ -608,3 +608,47 @@ ephy_embed_shell_get_mode (EphyEmbedShell *shell)
return shell->priv->mode;
}
+
+/**
+ * ephy_embed_shell_launch_application:
+ * @shell: an #EphyEmbedShell
+ * @file: a #GFile to open
+ * @mime_type: the mime type of @file or %NULL
+ * @user_time: user time to prevent focus stealing
+ *
+ * Tries to open @file with the right application, making sure we will
+ * not call ourselves in the process. This is needed to avoid
+ * potential infinite loops when opening unknown file types.
+ *
+ * Returns: %TRUE on success
+ **/
+gboolean
+ephy_embed_shell_launch_handler (EphyEmbedShell *shell,
+ GFile *file,
+ const char *mime_type,
+ guint32 user_time)
+{
+ GAppInfo *app;
+ GList *list = NULL;
+ gboolean ret = FALSE;
+
+ g_return_val_if_fail (EPHY_IS_EMBED_SHELL (shell), FALSE);
+ g_return_val_if_fail (file || mime_type, FALSE);
+
+ app = ephy_file_launcher_get_app_info_for_file (file, mime_type);
+
+ /* Do not allow recursive calls into the browser, they can lead to
+ * infinite loops and they should never happen anyway. */
+
+ /* FIXME: eventually there should be a nice and safe way of getting
+ * the app ID from the GApplication itself, but for now let's
+ * hardcode the .desktop file name and use it here. */
+ if (!app || g_strcmp0 (g_app_info_get_id (app), "epiphany.desktop") == 0)
+ return ret;
+
+ list = g_list_append (list, file);
+ ret = ephy_file_launch_application (app, list, user_time, NULL);
+ g_list_free (list);
+
+ return ret;
+}