From: "Alex Xu (Hello71)" <alex_y...@yahoo.ca> gtk_show_uri uses gappinfo, not gvfs. see https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/2359
this fixes Desktop.browse for systems without gvfs installed. this doesn't accurately reflect systems which use libgnome gnome_url_show, but gtk_show_uri should be used on all modern GNOME systems anyways. --- .../native/libawt_xawt/awt/gtk2_interface.c | 36 ++++-------------- .../native/libawt_xawt/awt/gtk3_interface.c | 38 ++++--------------- 2 files changed, 14 insertions(+), 60 deletions(-) diff --git a/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.c b/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.c index 4995044dc..3705a8839 100644 --- a/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.c +++ b/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.c @@ -362,8 +362,7 @@ do { \ static void update_supported_actions(JNIEnv *env) { - GVfs * (*fp_g_vfs_get_default) (void); - const gchar * const * (*fp_g_vfs_get_supported_uri_schemes) (GVfs * vfs); + GAppInfo * (*fp_g_app_info_get_default_for_uri_scheme) (const char *); const gchar * const * schemes = NULL; jclass cls_action = (*env)->FindClass(env, "java/awt/Desktop$Action"); @@ -385,38 +384,17 @@ static void update_supported_actions(JNIEnv *env) { ADD_SUPPORTED_ACTION("OPEN"); - /** - * gtk_show_uri() documentation says: - * - * > you need to install gvfs to get support for uri schemes such as http:// - * > or ftp://, as only local files are handled by GIO itself. - * - * So OPEN action was safely added here. - * However, it looks like Solaris 11 have gvfs support only for 32-bit - * applications only by default. - */ - - fp_g_vfs_get_default = dl_symbol("g_vfs_get_default"); - fp_g_vfs_get_supported_uri_schemes = dl_symbol("g_vfs_get_supported_uri_schemes"); + fp_g_app_info_get_default_for_uri_scheme = dl_symbol("g_app_info_get_default_for_uri_scheme"); dlerror(); - if (fp_g_vfs_get_default && fp_g_vfs_get_supported_uri_schemes) { - GVfs * vfs = fp_g_vfs_get_default(); - schemes = vfs ? fp_g_vfs_get_supported_uri_schemes(vfs) : NULL; - if (schemes) { - int i = 0; - while (schemes[i]) { - if (strcmp(schemes[i], "http") == 0) { - ADD_SUPPORTED_ACTION("BROWSE"); - ADD_SUPPORTED_ACTION("MAIL"); - break; - } - i++; - } + if (fp_g_app_info_get_default_for_uri_scheme) { + if (fp_g_app_info_get_default_for_uri_scheme("http")) { + ADD_SUPPORTED_ACTION("BROWSE"); + ADD_SUPPORTED_ACTION("MAIL"); } } else { #ifdef DEBUG - fprintf(stderr, "Cannot load g_vfs_get_supported_uri_schemes\n"); + fprintf(stderr, "Cannot load g_app_info_get_default_for_uri_scheme\n"); #endif /* DEBUG */ } diff --git a/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c b/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c index 886437e2a..bd5afbcbf 100644 --- a/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c +++ b/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c @@ -135,9 +135,7 @@ do { \ static void update_supported_actions(JNIEnv *env) { - GVfs * (*fp_g_vfs_get_default) (void); - const gchar * const * (*fp_g_vfs_get_supported_uri_schemes) (GVfs * vfs); - const gchar * const * schemes = NULL; + GAppInfo * (*fp_g_app_info_get_default_for_uri_scheme) (const gchar *); jclass cls_action = (*env)->FindClass(env, "java/awt/Desktop$Action"); CHECK_NULL(cls_action); @@ -163,39 +161,17 @@ static void update_supported_actions(JNIEnv *env) { ADD_SUPPORTED_ACTION("OPEN"); - /** - * gtk_show_uri() documentation says: - * - * > you need to install gvfs to get support for uri schemes such as http:// - * > or ftp://, as only local files are handled by GIO itself. - * - * So OPEN action was safely added here. - * However, it looks like Solaris 11 have gvfs support only for 32-bit - * applications only by default. - */ - - fp_g_vfs_get_default = dl_symbol("g_vfs_get_default"); - fp_g_vfs_get_supported_uri_schemes = - dl_symbol("g_vfs_get_supported_uri_schemes"); + fp_g_app_info_get_default_for_uri_scheme = dl_symbol("g_app_info_get_default_for_uri_scheme"); dlerror(); - if (fp_g_vfs_get_default && fp_g_vfs_get_supported_uri_schemes) { - GVfs * vfs = fp_g_vfs_get_default(); - schemes = vfs ? fp_g_vfs_get_supported_uri_schemes(vfs) : NULL; - if (schemes) { - int i = 0; - while (schemes[i]) { - if (strcmp(schemes[i], "http") == 0) { - ADD_SUPPORTED_ACTION("BROWSE"); - ADD_SUPPORTED_ACTION("MAIL"); - break; - } - i++; - } + if (fp_g_app_info_get_default_for_uri_scheme) { + if (fp_g_app_info_get_default_for_uri_scheme("http")) { + ADD_SUPPORTED_ACTION("BROWSE"); + ADD_SUPPORTED_ACTION("MAIL"); } } else { #ifdef DEBUG - fprintf(stderr, "Cannot load g_vfs_get_supported_uri_schemes\n"); + fprintf(stderr, "Cannot load g_app_info_get_default_for_uri_scheme\n"); #endif /* DEBUG */ } -- 2.28.0