diff options
-rw-r--r-- | meson.build | 17 | ||||
-rw-r--r-- | meson_options.txt | 4 | ||||
-rw-r--r-- | src/meson.build | 2 | ||||
-rw-r--r-- | src/text.c | 21 |
4 files changed, 20 insertions, 24 deletions
diff --git a/meson.build b/meson.build index 97d0284..222d264 100644 --- a/meson.build +++ b/meson.build @@ -65,15 +65,14 @@ opt_missing_str = ''' Requested optional @0@ support but library not found. Please ensure you have any required development libraries installed.''' -# TODO -#webkitgtk = dependency('webkit2gtk-4.0', version: '>= 2.8.1', required: false) -#if get_option('webkitgtk') -# if webkitgtk.found() -# zenity_conf.set('HAVE_WEBKITGTK', true) -# else -# error(opt_missing_str.format('webkitgtk')) -# endif -#endif +webkitgtk_dep = dependency('webkit2gtk-5.0', required: false) +if get_option('webkitgtk') + if webkitgtk_dep.found() + zenity_conf.set('HAVE_WEBKITGTK', true) + else + error(opt_missing_str.format('webkitgtk')) + endif +endif configure_file( output: 'config.h', diff --git a/meson_options.txt b/meson_options.txt index deeaf4b..8509973 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,3 +1 @@ -#TODO -#option('webkitgtk', type : 'boolean', value : true, -# description : 'enable webkitgtk support') +option('webkitgtk', type: 'boolean', value: false, description : 'enable webkitgtk support') diff --git a/src/meson.build b/src/meson.build index 0c03b31..2ee1889 100644 --- a/src/meson.build +++ b/src/meson.build @@ -46,6 +46,6 @@ zenity = executable( zenity_sources + zenity_enums + zenity_res, include_directories: zenity_root_dir, c_args: zenity_c_args, - dependencies: adw_dep, + dependencies: [adw_dep, webkitgtk_dep], install: true ) @@ -41,7 +41,6 @@ static ZenityTextData *zen_text_data; static void zenity_text_dialog_response (GtkWidget *widget, char *rstr, gpointer data); static void zenity_text_toggle_button (GtkCheckButton *button, AdwMessageDialog *dialog); -// TODO - I don't think gtk4 support for webkit is fully "there" yet. #ifdef HAVE_WEBKITGTK static void zenity_configure_webkit (WebKitWebView *web_view) { @@ -77,7 +76,6 @@ zenity_configure_webkit (WebKitWebView *web_view) { NULL); g_object_set (G_OBJECT (settings), "enable-page-cache", FALSE, NULL); g_object_set (G_OBJECT (settings), "enable-plugins", FALSE, NULL); - g_object_set (G_OBJECT (settings), "enable-private-browsing", TRUE, NULL); /* Stick to defaults "enforce-96-dpi" gboolean : Read / Write / @@ -356,10 +354,13 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) if (data->modal) gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); -/* TODO once gtk4 support fully lands in webkitgtk. */ #ifdef HAVE_WEBKITGTK - if (text_data->html) { - web_kit = webkit_web_view_new (); + if (text_data->html) + { + /* "ephemeral" == private browsing */ + g_autoptr(WebKitWebContext) wk_context = webkit_web_context_new_ephemeral (); + + web_kit = webkit_web_view_new_with_context (wk_context); scrolled_window = GTK_WIDGET ( gtk_builder_get_object (builder, "zenity_text_scrolled_window")); @@ -373,9 +374,9 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) webkit_web_view_load_uri ( WEBKIT_WEB_VIEW (web_kit), text_data->url); } else { - g_autoptr char *cwd = NULL; - g_autoptr char *dirname = NULL; - g_autoptr char *dirname_uri = NULL; + g_autofree char *cwd = NULL; + g_autofree char *dirname = NULL; + g_autofree char *dirname_uri = NULL; dirname = text_data->uri ? g_path_get_dirname (text_data->uri) : g_strdup ("/"); cwd = g_get_current_dir (); @@ -396,9 +397,7 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) G_CALLBACK (zenity_text_webview_load_changed), NULL); - gtk_widget_destroy (GTK_WIDGET (text_view)); - gtk_container_add (GTK_CONTAINER (scrolled_window), web_kit); - gtk_widget_show (GTK_WIDGET (web_kit)); + gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW(scrolled_window), web_kit); } #endif /* HAVE_WEBKITGTK */ |