From 5c48244e8d8dfb781aceecfdb52157af55d42225 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Mon, 26 Oct 2020 11:05:02 +0000 Subject: [PATCH] Fix report page focus Currently the setting of keyboard focus is to the scroll window but should be to the Webkit webview so correct this. --- gnucash/gnome/gnc-plugin-page-report.c | 5 +--- gnucash/html/gnc-html.c | 33 ++++++++++++++++++++++++++ gnucash/html/gnc-html.h | 9 +++++++ 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/gnucash/gnome/gnc-plugin-page-report.c b/gnucash/gnome/gnc-plugin-page-report.c index d77aa5e9d4..ece19892ce 100644 --- a/gnucash/gnome/gnc-plugin-page-report.c +++ b/gnucash/gnome/gnc-plugin-page-report.c @@ -253,7 +253,7 @@ gnc_plugin_page_report_focus_widget (GncPluginPage *report_plugin_page) if (window && !gnc_main_window_is_restoring_pages (GNC_MAIN_WINDOW(window))) { - GtkWidget * widget = gnc_html_get_widget (priv->html); + GtkWidget *widget = gnc_html_get_webview (priv->html); gnc_plugin_page_report_load_uri (report_plugin_page); @@ -752,15 +752,12 @@ static void gnc_plugin_page_report_destroy_widget(GncPluginPage *plugin_page) { GncPluginPageReportPrivate *priv; - GtkWidget *widget; // FIXME: cleanup other resources. PINFO("destroy widget"); priv = GNC_PLUGIN_PAGE_REPORT_GET_PRIVATE(plugin_page); - widget = gnc_html_get_widget(priv->html); - // Remove the page_changed signal callback gnc_plugin_page_disconnect_page_changed (GNC_PLUGIN_PAGE(plugin_page)); diff --git a/gnucash/html/gnc-html.c b/gnucash/html/gnc-html.c index 3b97ec22d2..4565bdaad2 100644 --- a/gnucash/html/gnc-html.c +++ b/gnucash/html/gnc-html.c @@ -574,6 +574,39 @@ gnc_html_get_widget( GncHtml* self ) return GNC_HTML_GET_PRIVATE(self)->container; } + +GtkWidget * +gnc_html_get_webview( GncHtml* self ) +{ + GncHtmlPrivate* priv; + GList *sw_list = NULL; + GtkWidget *webview = NULL; + + g_return_val_if_fail (self != NULL, NULL); + g_return_val_if_fail (GNC_IS_HTML(self), NULL); + + priv = GNC_HTML_GET_PRIVATE(self); + sw_list = gtk_container_get_children (GTK_CONTAINER(priv->container)); + + if (sw_list) // the scroll window has only one child + { +#ifdef WEBKIT1 + webview = sw_list->data; +#else + GList *vp_list = gtk_container_get_children (GTK_CONTAINER(sw_list->data)); + + if (vp_list) // the viewport has only one child + { + webview = vp_list->data; + g_list_free (vp_list); + } +#endif + } + g_list_free (sw_list); + return webview; +} + + void gnc_html_set_parent( GncHtml* self, GtkWindow* parent ) { diff --git a/gnucash/html/gnc-html.h b/gnucash/html/gnc-html.h index 67eaf73734..70b4352c9a 100644 --- a/gnucash/html/gnc-html.h +++ b/gnucash/html/gnc-html.h @@ -256,6 +256,15 @@ gnc_html_history* gnc_html_get_history( GncHtml* html ); */ GtkWidget* gnc_html_get_widget( GncHtml* html ); +/** + * Returns the webview widget for this html engine + * + * @param html GncHtml object + * @return webview widget + */ +GtkWidget* gnc_html_get_webview( GncHtml* html ); + + /** * Sets the parent window for this html engine. The engine will be embedded in this parent. *