aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarlos Garcia Campos <cgarcia@igalia.com>2012-05-30 19:02:33 +0800
committerCarlos Garcia Campos <carlosgc@gnome.org>2012-06-25 18:19:47 +0800
commitbd89147c9cf4df8fdc1cd2757a86f03f197a1862 (patch)
tree9275247f47d3933d3605dbfd2167dd2072b3e663
parent85a2991c85929be430cc9252adce98185e33c5be (diff)
downloadgsoc2013-epiphany-bd89147c9cf4df8fdc1cd2757a86f03f197a1862.tar.gz
gsoc2013-epiphany-bd89147c9cf4df8fdc1cd2757a86f03f197a1862.tar.zst
gsoc2013-epiphany-bd89147c9cf4df8fdc1cd2757a86f03f197a1862.zip
Add support for new windows in WebKit2
https://bugzilla.gnome.org/show_bug.cgi?id=678593
-rw-r--r--embed/ephy-embed.c35
-rw-r--r--embed/ephy-web-view.c14
-rw-r--r--src/ephy-window.c118
3 files changed, 124 insertions, 43 deletions
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c
index fb27e4710..6cff6c0ee 100644
--- a/embed/ephy-embed.c
+++ b/embed/ephy-embed.c
@@ -648,7 +648,27 @@ status_message_notify_cb (EphyWebView *view, GParamSpec *pspec, EphyEmbed *embed
}
#ifdef HAVE_WEBKIT2
-/* TODO: WebKitWindowProperties */
+static void
+window_geometry_changed (WebKitWindowProperties *properties, GParamSpec *pspec, EphyEmbed *embed)
+{
+ GtkWidget *window;
+ gboolean is_popup;
+ GdkRectangle geometry;
+
+ window = gtk_widget_get_toplevel (GTK_WIDGET (embed));
+ if (!window || !gtk_widget_is_toplevel (window))
+ return;
+
+ g_object_get (window, "is-popup", &is_popup, NULL);
+ if (!is_popup)
+ return;
+
+ webkit_window_properties_get_geometry (properties, &geometry);
+ if (geometry.x >= 0 && geometry.y >= 0)
+ gtk_window_move (GTK_WINDOW (window), geometry.x, geometry.y);
+ if (geometry.width > 0 && geometry.height > 0)
+ gtk_window_resize (GTK_WINDOW (window), geometry.width, geometry.height);
+}
#else
static void
window_resize_requested (WebKitWebWindowFeatures *features, GParamSpec *pspec, EphyEmbed *embed)
@@ -735,8 +755,13 @@ ephy_embed_constructed (GObject *object)
#endif
GtkWidget *paned;
WebKitWebView *web_view;
-#ifndef HAVE_WEBKIT2
+#ifdef HAVE_WEBKIT2
+ WebKitWindowProperties *window_properties;
+#else
WebKitWebWindowFeatures *window_features;
+#endif
+#ifndef HAVE_WEBKIT2
+ /* TODO: Inspector */
WebKitWebInspector *inspector;
#endif
GtkWidget *overlay;
@@ -832,7 +857,11 @@ ephy_embed_constructed (GObject *object)
#endif
#ifdef HAVE_WEBKIT2
- /* TODO: WebKitWindowProperties */
+ /* Window properties */
+ window_properties = webkit_web_view_get_window_properties (web_view);
+ g_signal_connect (window_properties, "notify::geometry",
+ G_CALLBACK (window_geometry_changed),
+ embed);
#else
/* Window features */
window_features = webkit_web_view_get_window_features (web_view);
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 93f79aa90..220bc7052 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -2521,11 +2521,15 @@ load_error_cb (WebKitWebView *web_view,
}
#ifdef HAVE_WEBKIT2
-/* TODO: WebKitWebView::close */
+static void
+close_web_view_cb (WebKitWebView *web_view,
+ gpointer user_data)
+
#else
static gboolean
close_web_view_cb (WebKitWebView *web_view,
gpointer user_data)
+#endif
{
GtkWidget *widget = gtk_widget_get_toplevel (GTK_WIDGET (web_view));
@@ -2537,9 +2541,11 @@ close_web_view_cb (WebKitWebView *web_view,
else
gtk_widget_destroy (widget);
+#ifndef HAVE_WEBKIT2
return TRUE;
-}
#endif
+}
+
static void
zoom_changed_cb (WebKitWebView *web_view,
@@ -2662,7 +2668,9 @@ ephy_web_view_init (EphyWebView *web_view)
#endif
#ifdef HAVE_WEBKIT2
- /* TODO: WebKitWebView::close */
+ g_signal_connect (web_view, "close",
+ G_CALLBACK (close_web_view_cb),
+ NULL);
#else
g_signal_connect (web_view, "close-web-view",
G_CALLBACK (close_web_view_cb),
diff --git a/src/ephy-window.c b/src/ephy-window.c
index e57860748..6af169999 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -2026,8 +2026,71 @@ ephy_window_set_is_popup (EphyWindow *window,
}
#ifdef HAVE_WEBKIT2
-/* TODO: New WebView */
+static void
+ephy_window_configure_for_view (EphyWindow *window,
+ WebKitWebView *web_view)
+{
+ WebKitWindowProperties *properties;
+ EphyWebViewChrome chrome_mask;
+
+ properties = webkit_web_view_get_window_properties (web_view);
+
+ chrome_mask = window->priv->chrome;
+ if (!webkit_window_properties_get_toolbar_visible (properties))
+ chrome_mask &= ~EPHY_WEB_VIEW_CHROME_TOOLBAR;
+
+ /* We will consider windows with different chrome settings popups. */
+ if (chrome_mask != window->priv->chrome) {
+ GdkRectangle geometry;
+
+ webkit_window_properties_get_geometry (properties, &geometry);
+ gtk_window_set_default_size (GTK_WINDOW (window), geometry.width, geometry.height);
+
+ if (!webkit_window_properties_get_resizable (properties))
+ gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
+
+ window->priv->is_popup = TRUE;
+ window->priv->chrome = chrome_mask;
+
+ sync_chromes_visibility (window);
+ }
+}
#else
+static void
+ephy_window_configure_for_view (EphyWindow *window,
+ WebKitWebView *web_view)
+{
+ int width, height;
+ gboolean toolbar_visible;
+ EphyWebViewChrome chrome_mask;
+ WebKitWebWindowFeatures *features;
+
+ toolbar_visible = TRUE;
+ features = webkit_web_view_get_window_features (web_view);
+
+ chrome_mask = window->priv->chrome;
+
+ g_object_get (features,
+ "width", &width,
+ "height", &height,
+ "toolbar-visible", &toolbar_visible,
+ NULL);
+
+ if (!toolbar_visible)
+ chrome_mask &= ~EPHY_WEB_VIEW_CHROME_TOOLBAR;
+
+ /* We will consider windows with different chrome settings popups. */
+ if (chrome_mask != window->priv->chrome) {
+ gtk_window_set_default_size (GTK_WINDOW (window), width, height);
+
+ window->priv->is_popup = TRUE;
+ window->priv->chrome = chrome_mask;
+
+ sync_chromes_visibility (window);
+ }
+}
+#endif
+
static gboolean
web_view_ready_cb (WebKitWebView *web_view,
WebKitWebView *parent_web_view)
@@ -2042,35 +2105,7 @@ web_view_ready_cb (WebKitWebView *web_view,
if (using_new_window)
{
- int width, height;
- gboolean toolbar_visible;
- EphyWebViewChrome chrome_mask;
- WebKitWebWindowFeatures *features;
-
- toolbar_visible = TRUE;
- features = webkit_web_view_get_window_features (web_view);
-
- chrome_mask = window->priv->chrome;
-
- g_object_get (features,
- "width", &width,
- "height", &height,
- "toolbar-visible", &toolbar_visible,
- NULL);
-
- if (!toolbar_visible)
- chrome_mask &= ~EPHY_WEB_VIEW_CHROME_TOOLBAR;
-
- /* We will consider windows with different chrome settings popups. */
- if (chrome_mask != window->priv->chrome) {
- gtk_window_set_default_size (GTK_WINDOW (window), width, height);
-
- window->priv->is_popup = TRUE;
- window->priv->chrome = chrome_mask;
-
- sync_chromes_visibility (window);
- }
-
+ ephy_window_configure_for_view (window, web_view);
g_signal_emit_by_name (parent_web_view, "new-window", web_view);
}
@@ -2079,10 +2114,16 @@ web_view_ready_cb (WebKitWebView *web_view,
return TRUE;
}
-static WebKitWebView*
+#ifdef HAVE_WEBKIT2
+static WebKitWebView *
+create_web_view_cb (WebKitWebView *web_view,
+ EphyWindow *window)
+#else
+static WebKitWebView *
create_web_view_cb (WebKitWebView *web_view,
WebKitWebFrame *frame,
EphyWindow *window)
+#endif
{
EphyEmbed *embed;
WebKitWebView *new_web_view;
@@ -2114,13 +2155,18 @@ create_web_view_cb (WebKitWebView *web_view,
0);
new_web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
+#ifdef HAVE_WEBKIT2
+ g_signal_connect (new_web_view, "ready-to-show",
+ G_CALLBACK (web_view_ready_cb),
+ web_view);
+#else
g_signal_connect (new_web_view, "web-view-ready",
G_CALLBACK (web_view_ready_cb),
web_view);
+#endif
return new_web_view;
}
-#endif
#ifdef HAVE_WEBKIT2
static gboolean
@@ -2442,7 +2488,9 @@ ephy_window_connect_active_embed (EphyWindow *window)
G_CALLBACK (scroll_event_cb),
window, 0);
#ifdef HAVE_WEBKIT2
- /* TODO: New WebView */
+ g_signal_connect_object (web_view, "create",
+ G_CALLBACK (create_web_view_cb),
+ window, 0);
#else
g_signal_connect_object (web_view, "create-web-view",
G_CALLBACK (create_web_view_cb),
@@ -2526,13 +2574,9 @@ ephy_window_disconnect_active_embed (EphyWindow *window)
g_signal_handlers_disconnect_by_func (web_view,
G_CALLBACK (scroll_event_cb),
window);
-#ifdef HAVE_WEBKIT2
- /* TODO: New WebView */
-#else
g_signal_handlers_disconnect_by_func (web_view,
G_CALLBACK (create_web_view_cb),
window);
-#endif
#ifdef HAVE_WEBKIT2
g_signal_handlers_disconnect_by_func (view,
G_CALLBACK (decide_policy_cb),