diff options
author | Xan Lopez <xan@igalia.com> | 2012-12-12 00:29:19 +0800 |
---|---|---|
committer | Xan Lopez <xan@igalia.com> | 2012-12-12 19:22:33 +0800 |
commit | 6ede0c3ebcbc129ea1112ee9f43427231ab50e07 (patch) | |
tree | a7914732e5ce2b86eeaf7d44956371c610d341e4 /lib/ephy-file-helpers.c | |
parent | 7f6211d2901f70d571f18106bf97ff636712a712 (diff) | |
download | gsoc2013-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 'lib/ephy-file-helpers.c')
-rw-r--r-- | lib/ephy-file-helpers.c | 52 |
1 files changed, 32 insertions, 20 deletions
diff --git a/lib/ephy-file-helpers.c b/lib/ephy-file-helpers.c index 680f2b5ed..8b61085b4 100644 --- a/lib/ephy-file-helpers.c +++ b/lib/ephy-file-helpers.c @@ -825,26 +825,13 @@ ephy_file_launch_desktop_file (const char *filename, return ret; } -/** - * ephy_file_launch_handler: - * @mime_type: the mime type of @file or %NULL - * @file: a #GFile to pass as argument - * @user_time: user time to prevent focus stealing - * - * Launches @file with its default handler application, if @mime_type is %NULL - * then @file will be queried for its type. - * - * Returns: %TRUE on success - **/ -gboolean -ephy_file_launch_handler (const char *mime_type, - GFile *file, - guint32 user_time) +GAppInfo * +ephy_file_launcher_get_app_info_for_file (GFile *file, + const char *mime_type) { GAppInfo *app = NULL; - gboolean ret = FALSE; - g_return_val_if_fail (file != NULL, FALSE); + g_return_val_if_fail (file || mime_type, FALSE); if (mime_type != NULL) { @@ -860,7 +847,8 @@ ephy_file_launch_handler (const char *mime_type, file_info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, 0, NULL, NULL); - if (file_info == NULL) { + if (file_info == NULL) + { return FALSE; } type = g_strdup (g_file_info_get_content_type (file_info)); @@ -876,6 +864,32 @@ ephy_file_launch_handler (const char *mime_type, g_free (type); } + return app; +} + +/** + * ephy_file_launch_handler: + * @mime_type: the mime type of @file or %NULL + * @file: a #GFile to pass as argument + * @user_time: user time to prevent focus stealing + * + * Launches @file with its default handler application, if @mime_type is %NULL + * then @file will be queried for its type. + * + * Returns: %TRUE on success + **/ +gboolean +ephy_file_launch_handler (const char *mime_type, + GFile *file, + guint32 user_time) +{ + GAppInfo *app = NULL; + gboolean ret = FALSE; + + g_return_val_if_fail (file != NULL, FALSE); + + app = ephy_file_launcher_get_app_info_for_file (file, mime_type); + if (app != NULL) { GList *list = NULL; @@ -884,8 +898,6 @@ ephy_file_launch_handler (const char *mime_type, ret = ephy_file_launch_application (app, list, user_time, NULL); g_list_free (list); } - else - ret = FALSE; return ret; } |