summaryrefslogtreecommitdiff
path: root/frontends
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2020-05-08 20:42:49 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2020-05-08 20:42:49 +0100
commit524688098a39a6b23a5a9cdff8faffafae1f5f11 (patch)
treeb94ec73f9abd8e73421d58d7d3281b02444d5888 /frontends
parentb42662325858d98d66e81a92f5730915f3263b65 (diff)
downloadnetsurf-524688098a39a6b23a5a9cdff8faffafae1f5f11.tar.gz
netsurf-524688098a39a6b23a5a9cdff8faffafae1f5f11.tar.bz2
GTK: Make page info transient properly, handle events, etc.
This makes the page info properly transient and causes it to handle activity in the corewindow and outside itself properly. This includes ensuring that actions outside the window will close it, etc. Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'frontends')
-rw-r--r--frontends/gtk/page_info.c48
1 files changed, 44 insertions, 4 deletions
diff --git a/frontends/gtk/page_info.c b/frontends/gtk/page_info.c
index b7ed7ed1b..a3e2747b7 100644
--- a/frontends/gtk/page_info.c
+++ b/frontends/gtk/page_info.c
@@ -29,8 +29,10 @@
#include "utils/messages.h"
#include "netsurf/keypress.h"
#include "netsurf/plotters.h"
+#include "netsurf/misc.h"
#include "netsurf/browser_window.h"
#include "desktop/page-info.h"
+#include "desktop/gui_internal.h"
#include "gtk/plotters.h"
#include "gtk/scaffolding.h"
@@ -74,6 +76,15 @@ nsgtk_pi_delete_event(GtkWidget *w, GdkEvent *event, gpointer data)
}
/**
+ * Called to cause the page-info window to close cleanly
+ */
+static void
+nsgtk_pi_close_callback(void *pw)
+{
+ nsgtk_pi_delete_event(NULL, NULL, pw);
+}
+
+/**
* callback for mouse action for certificate verify on core window
*
* \param nsgtk_cw The nsgtk core window structure.
@@ -88,10 +99,16 @@ nsgtk_pi_mouse(struct nsgtk_corewindow *nsgtk_cw,
int x, int y)
{
struct nsgtk_pi_window *pi_win;
+ bool did_something = false;
/* technically degenerate container of */
pi_win = (struct nsgtk_pi_window *)nsgtk_cw;
- page_info_mouse_action(pi_win->pi, mouse_state, x, y);
+ if (page_info_mouse_action(pi_win->pi, mouse_state, x, y, &did_something) == NSERROR_OK) {
+ if (did_something == true) {
+ /* Something happened so we need to close ourselves */
+ guit->misc->schedule(0, nsgtk_pi_close_callback, pi_win);
+ }
+ }
return NSERROR_OK;
}
@@ -147,6 +164,7 @@ nserror nsgtk_page_info(struct browser_window *bw)
{
struct nsgtk_pi_window *ncwin;
nserror res;
+ GtkWindow *scaffwin = nsgtk_scaffolding_window(nsgtk_current_scaffolding());
ncwin = calloc(1, sizeof(struct nsgtk_pi_window));
if (ncwin == NULL) {
@@ -165,9 +183,19 @@ nserror nsgtk_page_info(struct browser_window *bw)
ncwin->dlg = GTK_WINDOW(gtk_builder_get_object(ncwin->builder,
"PGIWindow"));
- /* set parent for transient dialog */
- gtk_window_set_transient_for(GTK_WINDOW(ncwin->dlg),
- nsgtk_scaffolding_window(nsgtk_current_scaffolding()));
+ /* Configure for transient behaviour */
+ gtk_window_set_type_hint(GTK_WINDOW(ncwin->dlg),
+ GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU);
+
+ gtk_window_set_modal(GTK_WINDOW(ncwin->dlg), TRUE);
+
+ gtk_window_group_add_window(gtk_window_get_group(scaffwin),
+ GTK_WINDOW(ncwin->dlg));
+
+ gtk_window_set_transient_for(GTK_WINDOW(ncwin->dlg), scaffwin);
+
+ gtk_window_set_screen(GTK_WINDOW(ncwin->dlg),
+ gtk_widget_get_screen(GTK_WIDGET(scaffwin)));
ncwin->core.drawing_area = GTK_DRAWING_AREA(
gtk_builder_get_object(ncwin->builder, "PGIDrawingArea"));
@@ -177,6 +205,16 @@ nserror nsgtk_page_info(struct browser_window *bw)
"delete_event",
G_CALLBACK(nsgtk_pi_delete_event),
ncwin);
+ /* Ditto if we lose the grab */
+ g_signal_connect(G_OBJECT(ncwin->dlg),
+ "grab-broken-event",
+ G_CALLBACK(nsgtk_pi_delete_event),
+ ncwin);
+ /* Handle button press events */
+ g_signal_connect(G_OBJECT(ncwin->dlg),
+ "button-press-event",
+ G_CALLBACK(nsgtk_pi_delete_event),
+ ncwin);
/* initialise GTK core window */
ncwin->core.draw = nsgtk_pi_draw;
@@ -201,5 +239,7 @@ nserror nsgtk_page_info(struct browser_window *bw)
gtk_widget_show(GTK_WIDGET(ncwin->dlg));
+ gtk_widget_grab_focus(GTK_WIDGET(ncwin->dlg));
+
return NSERROR_OK;
}