Gitweb links:
...log
http://git.netsurf-browser.org/netsurf.git/shortlog/4b8ed9b7775aec686a46b1b2be01a4efa1214e55
...commit
http://git.netsurf-browser.org/netsurf.git/commit/4b8ed9b7775aec686a46b1b2be01a4efa1214e55
...tree
http://git.netsurf-browser.org/netsurf.git/tree/4b8ed9b7775aec686a46b1b2be01a4efa1214e55
The branch, master has been updated
via 4b8ed9b7775aec686a46b1b2be01a4efa1214e55 (commit)
via 14e506f89f971ddbe204576092c6ffec59e85248 (commit)
via 524688098a39a6b23a5a9cdff8faffafae1f5f11 (commit)
via b42662325858d98d66e81a92f5730915f3263b65 (commit)
from b39db1dac4873fc56d6f7dbe191ec571c383a321 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=4b8ed9b7775aec686a46b1b2be01a4efa1214e55
commit 4b8ed9b7775aec686a46b1b2be01a4efa1214e55
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
GTK: Cause the page-info popup to appear in the right place
To position the page-info window we have to tunnel all the
way from the current scaffolding, via its top-level gui window,
through to the toolbar. In the toolbar we look up the URL bar
and then determine the screen coordinates of the scaffolding
via the top level widget GTK semantics.
Finally we place the page-info window 4 pixels down and right of
the bottom-left of the entry box, which should look nice.
Signed-off-by: Daniel Silverstone <[email protected]>
diff --git a/frontends/gtk/page_info.c b/frontends/gtk/page_info.c
index a3e2747..0d76a2f 100644
--- a/frontends/gtk/page_info.c
+++ b/frontends/gtk/page_info.c
@@ -197,6 +197,10 @@ nserror nsgtk_page_info(struct browser_window *bw)
gtk_window_set_screen(GTK_WINDOW(ncwin->dlg),
gtk_widget_get_screen(GTK_WIDGET(scaffwin)));
+ /* Attempt to place the window in the right place */
+ nsgtk_scaffolding_position_page_info(nsgtk_current_scaffolding(),
+ ncwin);
+
ncwin->core.drawing_area = GTK_DRAWING_AREA(
gtk_builder_get_object(ncwin->builder, "PGIDrawingArea"));
@@ -243,3 +247,12 @@ nserror nsgtk_page_info(struct browser_window *bw)
return NSERROR_OK;
}
+
+/* exported interface documented in gtk/page_info.h */
+void
+nsgtk_page_info_set_position(struct nsgtk_pi_window *win, int x, int y)
+{
+ NSLOG(netsurf, INFO, "win=%p x=%d y=%d", win, x, y);
+
+ gtk_window_move(GTK_WINDOW(win->dlg), x, y);
+}
diff --git a/frontends/gtk/page_info.h b/frontends/gtk/page_info.h
index ad443fc..23e1e34 100644
--- a/frontends/gtk/page_info.h
+++ b/frontends/gtk/page_info.h
@@ -27,4 +27,14 @@
*/
nserror nsgtk_page_info(struct browser_window *bw);
+/**
+ * Position the given page information window at the given
+ * coordinates.
+ *
+ * \param pi the page info window to position
+ * \param x the X coordinate for the top left of the window
+ * \param y the Y coordinate for the top left of the window
+ */
+void nsgtk_page_info_set_position(struct nsgtk_pi_window *pi, int x, int y);
+
#endif
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index 030c6d4..0c8fd33 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -1574,3 +1574,10 @@ struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct
gui_window *toplevel)
return gs;
}
+
+/* exported interface documented in gtk/scaffolding.h */
+nserror nsgtk_scaffolding_position_page_info(struct nsgtk_scaffolding *gs,
+ struct nsgtk_pi_window *win)
+{
+ return nsgtk_window_position_page_info(gs->top_level, win);
+}
diff --git a/frontends/gtk/scaffolding.h b/frontends/gtk/scaffolding.h
index 1fae003..95cd51a 100644
--- a/frontends/gtk/scaffolding.h
+++ b/frontends/gtk/scaffolding.h
@@ -27,6 +27,7 @@ struct hlcache_handle;
struct gui_window;
struct gui_search_web_table;
struct nsurl;
+struct nsgtk_pi_window;
/**
@@ -56,6 +57,15 @@ nserror nsgtk_scaffolding_throbber(struct gui_window* gw,
bool active);
nserror nsgtk_scaffolding_toolbar_context_menu(struct nsgtk_scaffolding *gs);
/**
+ * Position the page-info popup in the right place
+ *
+ * \param gs The scaffolding to position relative to
+ * \param win The page-info window to position
+ */
+nserror nsgtk_scaffolding_position_page_info(struct nsgtk_scaffolding *gs,
+ struct nsgtk_pi_window *win);
+
+/**
* open the burger menu
*/
nserror nsgtk_scaffolding_burger_menu(struct nsgtk_scaffolding *gs);
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index f2b1d05..c6028c9 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -3799,3 +3799,27 @@ nserror nsgtk_toolbar_update(struct nsgtk_toolbar *tb)
return res;
}
+
+/* exported interface documented in toolbar.h */
+nserror nsgtk_toolbar_position_page_info(struct nsgtk_toolbar *tb,
+ struct nsgtk_pi_window *win)
+{
+ struct nsgtk_toolbar_item *item = &tb->items[URL_BAR_ITEM];
+ GtkWidget *widget =
GTK_WIDGET(gtk_bin_get_child(GTK_BIN(item->button)));
+ gint rootx, rooty, x, y;
+
+ if (gtk_widget_translate_coordinates(widget,
+ gtk_widget_get_toplevel(widget),
+ 0,
+
gtk_widget_get_allocated_height(widget) - 1,
+ &x, &y) != TRUE) {
+ return NSERROR_UNKNOWN;
+ }
+
+ gtk_window_get_position(GTK_WINDOW(gtk_widget_get_toplevel(widget)),
+ &rootx, &rooty);
+
+ nsgtk_page_info_set_position(win, rootx + x + 4, rooty + y + 4);
+
+ return NSERROR_OK;
+}
diff --git a/frontends/gtk/toolbar.h b/frontends/gtk/toolbar.h
index 77c3bcd..15740b5 100644
--- a/frontends/gtk/toolbar.h
+++ b/frontends/gtk/toolbar.h
@@ -117,6 +117,15 @@ nserror nsgtk_toolbar_item_activate(struct nsgtk_toolbar
*tb, nsgtk_toolbar_butt
*/
nserror nsgtk_toolbar_show(struct nsgtk_toolbar *tb, bool show);
+/**
+ * position the page info window appropriately
+ *
+ * \param tb The toolbar to position relative to
+ * \param win The page-info window to position
+ */
+nserror nsgtk_toolbar_position_page_info(struct nsgtk_toolbar *tb,
+ struct nsgtk_pi_window *win);
+
/**
* Initialise customization of toolbar entries
diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c
index df1e58d..601177d 100644
--- a/frontends/gtk/window.c
+++ b/frontends/gtk/window.c
@@ -1677,3 +1677,10 @@ nserror nsgtk_window_toolbar_update(void)
}
return NSERROR_OK;
}
+
+/* exported interface documented in window.h */
+nserror nsgtk_window_position_page_info(struct gui_window *gw,
+ struct nsgtk_pi_window *win)
+{
+ return nsgtk_toolbar_position_page_info(gw->toolbar, win);
+}
diff --git a/frontends/gtk/window.h b/frontends/gtk/window.h
index b126a95..36166d8 100644
--- a/frontends/gtk/window.h
+++ b/frontends/gtk/window.h
@@ -19,6 +19,8 @@
#ifndef NETSURF_GTK_WINDOW_H
#define NETSURF_GTK_WINDOW_H 1
+struct nsgtk_pi_window;
+
extern struct gui_window_table *nsgtk_window_table;
extern struct gui_search_web_table *nsgtk_search_web_table;
@@ -95,5 +97,13 @@ GtkLayout *nsgtk_window_get_layout(struct gui_window *gw);
*/
nserror nsgtk_window_item_activate(struct gui_window *gw, nsgtk_toolbar_button
itemid);
+/**
+ * position page_info appropriately
+ *
+ * \param gw The gui window handle to position relative to
+ * \param win The page-info window to position
+ */
+nserror nsgtk_window_position_page_info(struct gui_window *gw,
+ struct nsgtk_pi_window *win);
#endif /* NETSURF_GTK_WINDOW_H */
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=14e506f89f971ddbe204576092c6ffec59e85248
commit 14e506f89f971ddbe204576092c6ffec59e85248
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
GTK RES: Make page info windows popup type
In order for GTK windows to be styled properly, in the context
we use them, the page-info windows need to be marked as popup
windows (typically used for transient popups such a menus, so
ideal for us).
Signed-off-by: Daniel Silverstone <[email protected]>
diff --git a/frontends/gtk/res/pageinfo.gtk2.ui
b/frontends/gtk/res/pageinfo.gtk2.ui
index b690d9c..3d541d6 100644
--- a/frontends/gtk/res/pageinfo.gtk2.ui
+++ b/frontends/gtk/res/pageinfo.gtk2.ui
@@ -3,6 +3,7 @@
<requires lib="gtk+" version="2.24"/>
<!-- interface-naming-policy project-wide -->
<object class="GtkWindow" id="PGIWindow">
+ <property name="type">GTK_WINDOW_POPUP</property>
<property name="can_focus">False</property>
<child>
<object class="GtkDrawingArea" id="PGIDrawingArea">
diff --git a/frontends/gtk/res/pageinfo.gtk3.ui
b/frontends/gtk/res/pageinfo.gtk3.ui
index 6ea876e..fdee5ac 100644
--- a/frontends/gtk/res/pageinfo.gtk3.ui
+++ b/frontends/gtk/res/pageinfo.gtk3.ui
@@ -3,6 +3,7 @@
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkWindow" id="PGIWindow">
+ <property name="type">GTK_WINDOW_POPUP</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_BUTTON_MOTION_MASK |
GDK_STRUCTURE_MASK</property>
<property name="resizable">False</property>
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=524688098a39a6b23a5a9cdff8faffafae1f5f11
commit 524688098a39a6b23a5a9cdff8faffafae1f5f11
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
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 <[email protected]>
diff --git a/frontends/gtk/page_info.c b/frontends/gtk/page_info.c
index b7ed7ed..a3e2747 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;
}
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=b42662325858d98d66e81a92f5730915f3263b65
commit b42662325858d98d66e81a92f5730915f3263b65
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
page-info: Provide support to indicate if action did something
Some mouse actions perform a positive action (such as opening
the SSL certificate viewer). As such, provide an out param
which will be set to true if the action did something. This
parameter is not touched in the case of nothing happening in
case it is used in alternating logic in the caller.
Signed-off-by: Daniel Silverstone <[email protected]>
diff --git a/desktop/page-info.c b/desktop/page-info.c
index db14b69..79701d2f 100644
--- a/desktop/page-info.c
+++ b/desktop/page-info.c
@@ -664,12 +664,14 @@ cleanup:
* \param[in] pi The page info window handle.
* \param[in] mouse The current mouse state.
* \param[in] clicked The page info window entry to consider clicks on.
+ * \param[out] did_something Set to true if this click did something
* \return NSERROR_OK on success, appropriate error code otherwise.
*/
static nserror page_info__handle_item_click(
struct page_info *pi,
enum browser_mouse_state mouse,
- enum pi_entry clicked)
+ enum pi_entry clicked,
+ bool *did_something)
{
nserror err;
@@ -680,9 +682,11 @@ static nserror page_info__handle_item_click(
switch (clicked) {
case PI_ENTRY_CERT:
err = browser_window_show_certificates(pi->bw);
+ *did_something = true;
break;
case PI_ENTRY_COOKIES:
err = browser_window_show_cookies(pi->bw);
+ *did_something = true;
break;
default:
err = NSERROR_OK;
@@ -697,7 +701,8 @@ nserror page_info_mouse_action(
struct page_info *pi,
enum browser_mouse_state mouse,
int x,
- int y)
+ int y,
+ bool *did_something)
{
int cur_y = 0;
nserror err;
@@ -722,7 +727,7 @@ nserror page_info_mouse_action(
if (y >= cur_y && y < cur_y + height) {
hovering = true;
err = page_info__handle_item_click(
- pi, mouse, i);
+ pi, mouse, i, did_something);
if (err != NSERROR_OK) {
return err;
}
diff --git a/desktop/page-info.h b/desktop/page-info.h
index d4437fd..4504e57 100644
--- a/desktop/page-info.h
+++ b/desktop/page-info.h
@@ -106,13 +106,15 @@ nserror page_info_redraw(
* \param[in] mouse The current mouse state
* \param[in] x The current mouse X coordinate
* \param[in] y The current mouse Y coordinate
+ * \param[out] did_something Set to true if this resulted in some action
* \return NSERROR_OK on success, appropriate error code otherwise.
*/
nserror page_info_mouse_action(
struct page_info *pi,
enum browser_mouse_state mouse,
int x,
- int y);
+ int y,
+ bool *did_something);
/**
* Key press handling.
-----------------------------------------------------------------------
Summary of changes:
desktop/page-info.c | 11 +++++--
desktop/page-info.h | 4 ++-
frontends/gtk/page_info.c | 61 +++++++++++++++++++++++++++++++++---
frontends/gtk/page_info.h | 10 ++++++
frontends/gtk/res/pageinfo.gtk2.ui | 1 +
frontends/gtk/res/pageinfo.gtk3.ui | 1 +
frontends/gtk/scaffolding.c | 7 +++++
frontends/gtk/scaffolding.h | 10 ++++++
frontends/gtk/toolbar.c | 24 ++++++++++++++
frontends/gtk/toolbar.h | 9 ++++++
frontends/gtk/window.c | 7 +++++
frontends/gtk/window.h | 10 ++++++
12 files changed, 147 insertions(+), 8 deletions(-)
diff --git a/desktop/page-info.c b/desktop/page-info.c
index db14b69..79701d2f 100644
--- a/desktop/page-info.c
+++ b/desktop/page-info.c
@@ -664,12 +664,14 @@ cleanup:
* \param[in] pi The page info window handle.
* \param[in] mouse The current mouse state.
* \param[in] clicked The page info window entry to consider clicks on.
+ * \param[out] did_something Set to true if this click did something
* \return NSERROR_OK on success, appropriate error code otherwise.
*/
static nserror page_info__handle_item_click(
struct page_info *pi,
enum browser_mouse_state mouse,
- enum pi_entry clicked)
+ enum pi_entry clicked,
+ bool *did_something)
{
nserror err;
@@ -680,9 +682,11 @@ static nserror page_info__handle_item_click(
switch (clicked) {
case PI_ENTRY_CERT:
err = browser_window_show_certificates(pi->bw);
+ *did_something = true;
break;
case PI_ENTRY_COOKIES:
err = browser_window_show_cookies(pi->bw);
+ *did_something = true;
break;
default:
err = NSERROR_OK;
@@ -697,7 +701,8 @@ nserror page_info_mouse_action(
struct page_info *pi,
enum browser_mouse_state mouse,
int x,
- int y)
+ int y,
+ bool *did_something)
{
int cur_y = 0;
nserror err;
@@ -722,7 +727,7 @@ nserror page_info_mouse_action(
if (y >= cur_y && y < cur_y + height) {
hovering = true;
err = page_info__handle_item_click(
- pi, mouse, i);
+ pi, mouse, i, did_something);
if (err != NSERROR_OK) {
return err;
}
diff --git a/desktop/page-info.h b/desktop/page-info.h
index d4437fd..4504e57 100644
--- a/desktop/page-info.h
+++ b/desktop/page-info.h
@@ -106,13 +106,15 @@ nserror page_info_redraw(
* \param[in] mouse The current mouse state
* \param[in] x The current mouse X coordinate
* \param[in] y The current mouse Y coordinate
+ * \param[out] did_something Set to true if this resulted in some action
* \return NSERROR_OK on success, appropriate error code otherwise.
*/
nserror page_info_mouse_action(
struct page_info *pi,
enum browser_mouse_state mouse,
int x,
- int y);
+ int y,
+ bool *did_something);
/**
* Key press handling.
diff --git a/frontends/gtk/page_info.c b/frontends/gtk/page_info.c
index b7ed7ed..0d76a2f 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,23 @@ 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)));
+
+ /* Attempt to place the window in the right place */
+ nsgtk_scaffolding_position_page_info(nsgtk_current_scaffolding(),
+ ncwin);
ncwin->core.drawing_area = GTK_DRAWING_AREA(
gtk_builder_get_object(ncwin->builder, "PGIDrawingArea"));
@@ -177,6 +209,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 +243,16 @@ 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;
}
+
+/* exported interface documented in gtk/page_info.h */
+void
+nsgtk_page_info_set_position(struct nsgtk_pi_window *win, int x, int y)
+{
+ NSLOG(netsurf, INFO, "win=%p x=%d y=%d", win, x, y);
+
+ gtk_window_move(GTK_WINDOW(win->dlg), x, y);
+}
diff --git a/frontends/gtk/page_info.h b/frontends/gtk/page_info.h
index ad443fc..23e1e34 100644
--- a/frontends/gtk/page_info.h
+++ b/frontends/gtk/page_info.h
@@ -27,4 +27,14 @@
*/
nserror nsgtk_page_info(struct browser_window *bw);
+/**
+ * Position the given page information window at the given
+ * coordinates.
+ *
+ * \param pi the page info window to position
+ * \param x the X coordinate for the top left of the window
+ * \param y the Y coordinate for the top left of the window
+ */
+void nsgtk_page_info_set_position(struct nsgtk_pi_window *pi, int x, int y);
+
#endif
diff --git a/frontends/gtk/res/pageinfo.gtk2.ui
b/frontends/gtk/res/pageinfo.gtk2.ui
index b690d9c..3d541d6 100644
--- a/frontends/gtk/res/pageinfo.gtk2.ui
+++ b/frontends/gtk/res/pageinfo.gtk2.ui
@@ -3,6 +3,7 @@
<requires lib="gtk+" version="2.24"/>
<!-- interface-naming-policy project-wide -->
<object class="GtkWindow" id="PGIWindow">
+ <property name="type">GTK_WINDOW_POPUP</property>
<property name="can_focus">False</property>
<child>
<object class="GtkDrawingArea" id="PGIDrawingArea">
diff --git a/frontends/gtk/res/pageinfo.gtk3.ui
b/frontends/gtk/res/pageinfo.gtk3.ui
index 6ea876e..fdee5ac 100644
--- a/frontends/gtk/res/pageinfo.gtk3.ui
+++ b/frontends/gtk/res/pageinfo.gtk3.ui
@@ -3,6 +3,7 @@
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkWindow" id="PGIWindow">
+ <property name="type">GTK_WINDOW_POPUP</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_BUTTON_MOTION_MASK |
GDK_STRUCTURE_MASK</property>
<property name="resizable">False</property>
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index 030c6d4..0c8fd33 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -1574,3 +1574,10 @@ struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct
gui_window *toplevel)
return gs;
}
+
+/* exported interface documented in gtk/scaffolding.h */
+nserror nsgtk_scaffolding_position_page_info(struct nsgtk_scaffolding *gs,
+ struct nsgtk_pi_window *win)
+{
+ return nsgtk_window_position_page_info(gs->top_level, win);
+}
diff --git a/frontends/gtk/scaffolding.h b/frontends/gtk/scaffolding.h
index 1fae003..95cd51a 100644
--- a/frontends/gtk/scaffolding.h
+++ b/frontends/gtk/scaffolding.h
@@ -27,6 +27,7 @@ struct hlcache_handle;
struct gui_window;
struct gui_search_web_table;
struct nsurl;
+struct nsgtk_pi_window;
/**
@@ -56,6 +57,15 @@ nserror nsgtk_scaffolding_throbber(struct gui_window* gw,
bool active);
nserror nsgtk_scaffolding_toolbar_context_menu(struct nsgtk_scaffolding *gs);
/**
+ * Position the page-info popup in the right place
+ *
+ * \param gs The scaffolding to position relative to
+ * \param win The page-info window to position
+ */
+nserror nsgtk_scaffolding_position_page_info(struct nsgtk_scaffolding *gs,
+ struct nsgtk_pi_window *win);
+
+/**
* open the burger menu
*/
nserror nsgtk_scaffolding_burger_menu(struct nsgtk_scaffolding *gs);
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index f2b1d05..c6028c9 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -3799,3 +3799,27 @@ nserror nsgtk_toolbar_update(struct nsgtk_toolbar *tb)
return res;
}
+
+/* exported interface documented in toolbar.h */
+nserror nsgtk_toolbar_position_page_info(struct nsgtk_toolbar *tb,
+ struct nsgtk_pi_window *win)
+{
+ struct nsgtk_toolbar_item *item = &tb->items[URL_BAR_ITEM];
+ GtkWidget *widget =
GTK_WIDGET(gtk_bin_get_child(GTK_BIN(item->button)));
+ gint rootx, rooty, x, y;
+
+ if (gtk_widget_translate_coordinates(widget,
+ gtk_widget_get_toplevel(widget),
+ 0,
+
gtk_widget_get_allocated_height(widget) - 1,
+ &x, &y) != TRUE) {
+ return NSERROR_UNKNOWN;
+ }
+
+ gtk_window_get_position(GTK_WINDOW(gtk_widget_get_toplevel(widget)),
+ &rootx, &rooty);
+
+ nsgtk_page_info_set_position(win, rootx + x + 4, rooty + y + 4);
+
+ return NSERROR_OK;
+}
diff --git a/frontends/gtk/toolbar.h b/frontends/gtk/toolbar.h
index 77c3bcd..15740b5 100644
--- a/frontends/gtk/toolbar.h
+++ b/frontends/gtk/toolbar.h
@@ -117,6 +117,15 @@ nserror nsgtk_toolbar_item_activate(struct nsgtk_toolbar
*tb, nsgtk_toolbar_butt
*/
nserror nsgtk_toolbar_show(struct nsgtk_toolbar *tb, bool show);
+/**
+ * position the page info window appropriately
+ *
+ * \param tb The toolbar to position relative to
+ * \param win The page-info window to position
+ */
+nserror nsgtk_toolbar_position_page_info(struct nsgtk_toolbar *tb,
+ struct nsgtk_pi_window *win);
+
/**
* Initialise customization of toolbar entries
diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c
index df1e58d..601177d 100644
--- a/frontends/gtk/window.c
+++ b/frontends/gtk/window.c
@@ -1677,3 +1677,10 @@ nserror nsgtk_window_toolbar_update(void)
}
return NSERROR_OK;
}
+
+/* exported interface documented in window.h */
+nserror nsgtk_window_position_page_info(struct gui_window *gw,
+ struct nsgtk_pi_window *win)
+{
+ return nsgtk_toolbar_position_page_info(gw->toolbar, win);
+}
diff --git a/frontends/gtk/window.h b/frontends/gtk/window.h
index b126a95..36166d8 100644
--- a/frontends/gtk/window.h
+++ b/frontends/gtk/window.h
@@ -19,6 +19,8 @@
#ifndef NETSURF_GTK_WINDOW_H
#define NETSURF_GTK_WINDOW_H 1
+struct nsgtk_pi_window;
+
extern struct gui_window_table *nsgtk_window_table;
extern struct gui_search_web_table *nsgtk_search_web_table;
@@ -95,5 +97,13 @@ GtkLayout *nsgtk_window_get_layout(struct gui_window *gw);
*/
nserror nsgtk_window_item_activate(struct gui_window *gw, nsgtk_toolbar_button
itemid);
+/**
+ * position page_info appropriately
+ *
+ * \param gw The gui window handle to position relative to
+ * \param win The page-info window to position
+ */
+nserror nsgtk_window_position_page_info(struct gui_window *gw,
+ struct nsgtk_pi_window *win);
#endif /* NETSURF_GTK_WINDOW_H */
--
NetSurf Browser
_______________________________________________
netsurf-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]