diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ephy-file-helpers.c | 52 | ||||
-rw-r--r-- | lib/ephy-file-helpers.h | 82 |
2 files changed, 74 insertions, 60 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; } diff --git a/lib/ephy-file-helpers.h b/lib/ephy-file-helpers.h index fc50c638d..a80f45084 100644 --- a/lib/ephy-file-helpers.h +++ b/lib/ephy-file-helpers.h @@ -52,46 +52,48 @@ typedef enum #define EPHY_UUID_ENVVAR "EPHY_UNIQUE" -gboolean ephy_file_helpers_init (const char *profile_dir, - EphyFileHelpersFlags flags, - GError **error); -const char * ephy_file (const char *filename); -const char * ephy_dot_dir (void); -gboolean ephy_dot_dir_is_default (void); -void ephy_file_helpers_shutdown (void); -char * ephy_file_get_downloads_dir (void); -char * ephy_file_desktop_dir (void); -const char * ephy_file_tmp_dir (void); -char * ephy_file_tmp_filename (const char *base, - const char *extension); -gboolean ephy_ensure_dir_exists (const char *dir, - GError **); -GSList * ephy_file_find (const char *path, - const char *fname, - gint maxdepth); -gboolean ephy_file_switch_temp_file (GFile *file_dest, - GFile *file_temp); -void ephy_file_delete_on_exit (GFile *file); -EphyMimePermission ephy_file_check_mime (const char *mime_type); -gboolean ephy_file_launch_desktop_file (const char *filename, - const char *parameter, - guint32 user_time, - GtkWidget *widget); -gboolean ephy_file_launch_application (GAppInfo *app, - GList *files, - guint32 user_time, - GtkWidget *widget); -gboolean ephy_file_launch_handler (const char *mime_type, - GFile *file, - guint32 user_time); -gboolean ephy_file_browse_to (GFile *file, - guint32 user_time); -gboolean ephy_file_delete_dir_recursively (GFile *file, - GError **error); -void ephy_file_delete_uri (const char *uri); -char * ephy_file_create_data_uri_for_filename (const char *filename, - const char *mime_type); -char * ephy_sanitize_filename (char *filename); +gboolean ephy_file_helpers_init (const char *profile_dir, + EphyFileHelpersFlags flags, + GError **error); +const char * ephy_file (const char *filename); +const char * ephy_dot_dir (void); +gboolean ephy_dot_dir_is_default (void); +void ephy_file_helpers_shutdown (void); +char * ephy_file_get_downloads_dir (void); +char * ephy_file_desktop_dir (void); +const char * ephy_file_tmp_dir (void); +char * ephy_file_tmp_filename (const char *base, + const char *extension); +gboolean ephy_ensure_dir_exists (const char *dir, + GError **); +GSList * ephy_file_find (const char *path, + const char *fname, + gint maxdepth); +gboolean ephy_file_switch_temp_file (GFile *file_dest, + GFile *file_temp); +void ephy_file_delete_on_exit (GFile *file); +EphyMimePermission ephy_file_check_mime (const char *mime_type); +gboolean ephy_file_launch_desktop_file (const char *filename, + const char *parameter, + guint32 user_time, + GtkWidget *widget); +gboolean ephy_file_launch_application (GAppInfo *app, + GList *files, + guint32 user_time, + GtkWidget *widget); +gboolean ephy_file_launch_handler (const char *mime_type, + GFile *file, + guint32 user_time); +gboolean ephy_file_browse_to (GFile *file, + guint32 user_time); +gboolean ephy_file_delete_dir_recursively (GFile *file, + GError **error); +void ephy_file_delete_uri (const char *uri); +char * ephy_file_create_data_uri_for_filename (const char *filename, + const char *mime_type); +char * ephy_sanitize_filename (char *filename); +GAppInfo * ephy_file_launcher_get_app_info_for_file (GFile *file, + const char *mime_type); G_END_DECLS |