Allow user to interact with --text-info --html WebView
This commit changes the default --text-view behavior (when --html is also in effect) so that the clicked links are opened in the default browser (closes #732626). Additionally, a new option is introduced, --prevent-interaction, which disables above behavior.
This commit is contained in:
parent
b5460887fb
commit
5b0553e9ef
12
src/option.c
12
src/option.c
@ -113,6 +113,7 @@ static gboolean zenity_text_auto_scroll;
|
||||
|
||||
#ifdef HAVE_WEBKITGTK
|
||||
static gboolean zenity_text_enable_html;
|
||||
static gboolean zenity_text_no_interaction;
|
||||
static gchar *zenity_text_url;
|
||||
#endif
|
||||
|
||||
@ -915,6 +916,15 @@ static GOptionEntry text_options[] = {
|
||||
N_("Enable html support"),
|
||||
NULL
|
||||
},
|
||||
{
|
||||
"no-interaction",
|
||||
'\0',
|
||||
G_OPTION_FLAG_NOALIAS,
|
||||
G_OPTION_ARG_NONE,
|
||||
&zenity_text_no_interaction,
|
||||
N_("Do not enable user interaction with the WebView. Only works if you use --html option"),
|
||||
NULL
|
||||
},
|
||||
{
|
||||
"url",
|
||||
'\0',
|
||||
@ -1600,6 +1610,7 @@ zenity_text_pre_callback (GOptionContext *context,
|
||||
zenity_text_auto_scroll = FALSE;
|
||||
#ifdef HAVE_WEBKITGTK
|
||||
zenity_text_enable_html = FALSE;
|
||||
zenity_text_no_interaction = FALSE;
|
||||
zenity_text_url = NULL;
|
||||
#endif
|
||||
return TRUE;
|
||||
@ -2028,6 +2039,7 @@ zenity_text_post_callback (GOptionContext *context,
|
||||
results->text_data->auto_scroll = zenity_text_auto_scroll;
|
||||
#ifdef HAVE_WEBKITGTK
|
||||
results->text_data->html = zenity_text_enable_html;
|
||||
results->text_data->no_interaction = zenity_text_no_interaction;
|
||||
results->text_data->url = zenity_text_url;
|
||||
#endif
|
||||
} else {
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gio/gio.h>
|
||||
#include "zenity.h"
|
||||
#include "util.h"
|
||||
|
||||
@ -114,6 +115,11 @@ zenity_text_webview_decision_request (WebKitWebView *webkitwebview,
|
||||
gpointer user_data)
|
||||
{
|
||||
webkit_web_policy_decision_ignore (policy_decision);
|
||||
if (!zen_text_data->no_interaction &&
|
||||
webkit_web_navigation_action_get_reason (navigation_action) == WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED) {
|
||||
g_app_info_launch_default_for_uri (webkit_web_navigation_action_get_original_uri(navigation_action),
|
||||
NULL, NULL);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -333,7 +339,7 @@ zenity_text (ZenityData *data, ZenityTextData *text_data)
|
||||
}
|
||||
|
||||
// We don't want user to click on links and navigate to another page.
|
||||
// So, when page finish load, we block requests.
|
||||
// So, when the page finishes loading, we take handle of the requests.
|
||||
|
||||
g_signal_connect (G_OBJECT (web_kit), "document-load-finished",
|
||||
G_CALLBACK (zenity_text_webview_load_finished), NULL);
|
||||
|
@ -118,6 +118,7 @@ typedef struct {
|
||||
gchar *checkbox;
|
||||
#ifdef HAVE_WEBKITGTK
|
||||
gboolean html;
|
||||
gboolean no_interaction;
|
||||
gchar *url;
|
||||
#endif
|
||||
} ZenityTextData;
|
||||
|
Reference in New Issue
Block a user