diff options
author | Carlos Garcia Campos <cgarcia@igalia.com> | 2012-05-06 22:47:19 +0800 |
---|---|---|
committer | Carlos Garcia Campos <carlosgc@gnome.org> | 2012-06-21 19:54:16 +0800 |
commit | 97c91b2fc2059b1e358bb19896203afaa44bfd33 (patch) | |
tree | 6aa01250a99fa884d177ce3202d8ff41e8e96d74 /embed | |
parent | a8767266443074689200fff9ca43531d88d65aed (diff) | |
download | gsoc2013-epiphany-97c91b2fc2059b1e358bb19896203afaa44bfd33.tar gsoc2013-epiphany-97c91b2fc2059b1e358bb19896203afaa44bfd33.tar.gz gsoc2013-epiphany-97c91b2fc2059b1e358bb19896203afaa44bfd33.tar.bz2 gsoc2013-epiphany-97c91b2fc2059b1e358bb19896203afaa44bfd33.tar.lz gsoc2013-epiphany-97c91b2fc2059b1e358bb19896203afaa44bfd33.tar.xz gsoc2013-epiphany-97c91b2fc2059b1e358bb19896203afaa44bfd33.tar.zst gsoc2013-epiphany-97c91b2fc2059b1e358bb19896203afaa44bfd33.zip |
Initial WebKit2 port
It builds and basic functionality works.
Diffstat (limited to 'embed')
-rw-r--r-- | embed/Makefile.am | 4 | ||||
-rw-r--r-- | embed/ephy-download.c | 34 | ||||
-rw-r--r-- | embed/ephy-download.h | 4 | ||||
-rw-r--r-- | embed/ephy-embed-event.h | 4 | ||||
-rw-r--r-- | embed/ephy-embed-prefs.c | 64 | ||||
-rw-r--r-- | embed/ephy-embed-single.c | 9 | ||||
-rw-r--r-- | embed/ephy-embed-utils.h | 5 | ||||
-rw-r--r-- | embed/ephy-embed.c | 74 | ||||
-rw-r--r-- | embed/ephy-request-about.c | 8 | ||||
-rw-r--r-- | embed/ephy-web-view.c | 167 | ||||
-rw-r--r-- | embed/ephy-web-view.h | 8 |
11 files changed, 369 insertions, 12 deletions
diff --git a/embed/Makefile.am b/embed/Makefile.am index bf05190a2..ea7f3c28d 100644 --- a/embed/Makefile.am +++ b/embed/Makefile.am @@ -62,6 +62,10 @@ libephyembed_la_CPPFLAGS = \ -I$(top_srcdir)/lib/widgets \ $(AM_CPPFLAGS) +if WITH_WEBKIT2 +libephyembed_la_CPPFLAGS += -DHAVE_WEBKIT2 +endif + libephyembed_la_CFLAGS = \ -DSHARE_DIR=\"$(pkgdatadir)\" \ $(DEPENDENCIES_CFLAGS) \ diff --git a/embed/ephy-download.c b/embed/ephy-download.c index 85c03b231..a1821f208 100644 --- a/embed/ephy-download.c +++ b/embed/ephy-download.c @@ -36,7 +36,6 @@ #include <errno.h> #include <glib/gi18n.h> #include <string.h> -#include <webkit/webkit.h> G_DEFINE_TYPE (EphyDownload, ephy_download, G_TYPE_OBJECT) @@ -153,6 +152,10 @@ ephy_download_set_property (GObject *object, char * ephy_download_get_content_type (EphyDownload *download) { +#ifdef HAVE_WEBKIT2 + /* TODO: Downloads */ + return NULL; +#else WebKitNetworkResponse *response; SoupMessage *message; char *content_type = NULL; @@ -192,6 +195,7 @@ ephy_download_get_content_type (EphyDownload *download) LOG ("ephy_download_get_content_type: %s", content_type); return content_type; +#endif } @@ -285,7 +289,12 @@ define_destination_uri (EphyDownload *download) char *destination_uri; const char *suggested_filename; +#ifdef HAVE_WEBKIT2 + /* TODO: Downloads */ + suggested_filename = NULL; +#else suggested_filename = webkit_download_get_suggested_filename (download->priv->download); +#endif dest_dir = ephy_file_get_downloads_dir (); /* Make sure the download directory exists */ @@ -369,7 +378,11 @@ ephy_download_set_destination_uri (EphyDownload *download, priv->destination = g_strdup (destination); +#ifdef HAVE_WEBKIT2 + /* TODO: Downloads */ +#else webkit_download_set_destination_uri (priv->download, priv->destination); +#endif g_object_notify (G_OBJECT (download), "destination"); } @@ -595,8 +608,11 @@ ephy_download_start (EphyDownload *download) if (priv->destination == NULL) ephy_download_set_auto_destination (download); - +#ifdef HAVE_WEBKIT2 + /* TODO: Downloads */ +#else webkit_download_start (priv->download); +#endif } /** @@ -633,7 +649,9 @@ ephy_download_do_download_action (EphyDownload *download, const char *destination_uri; EphyDownloadPrivate *priv; gboolean ret = FALSE; - +#ifdef HAVE_WEBKIT2 + /* TODO: Downloads */ +#else priv = download->priv; destination_uri = webkit_download_get_destination_uri (priv->download); @@ -662,7 +680,7 @@ ephy_download_do_download_action (EphyDownload *download, break; } g_object_unref (destination); - +#endif return ret; } @@ -880,6 +898,9 @@ ephy_download_init (EphyDownload *download) download->priv->widget = NULL; } +#ifdef HAVE_WEBKIT2 +/* TODO: Downloads */ +#else static void download_status_changed_cb (GObject *object, GParamSpec *pspec, @@ -927,6 +948,7 @@ download_error_cb (WebKitDownload *download, return ret; } +#endif /** * ephy_download_new: @@ -949,6 +971,9 @@ _ephy_download_new (WebKitDownload *webkit_download, const char *uri) EphyDownload *ephy_download; ephy_download = ephy_download_new (); +#ifdef HAVE_WEBKIT2 + /* TODO: Downloads */ +#else if (webkit_download == NULL) { WebKitNetworkRequest *request; @@ -968,6 +993,7 @@ _ephy_download_new (WebKitDownload *webkit_download, const char *uri) ephy_download->priv->download = g_object_ref (webkit_download); ephy_download->priv->source = g_strdup (webkit_download_get_uri (webkit_download)); +#endif return ephy_download; } diff --git a/embed/ephy-download.h b/embed/ephy-download.h index 466da4006..34cbbca83 100644 --- a/embed/ephy-download.h +++ b/embed/ephy-download.h @@ -30,7 +30,11 @@ #define _EPHY_DOWNLOAD_H #include <glib-object.h> +#ifdef HAVE_WEBKIT2 +#include <webkit2/webkit2.h> +#else #include <webkit/webkit.h> +#endif #include "ephy-embed.h" diff --git a/embed/ephy-embed-event.h b/embed/ephy-embed-event.h index 633104c07..128c74aab 100644 --- a/embed/ephy-embed-event.h +++ b/embed/ephy-embed-event.h @@ -29,7 +29,11 @@ #include <glib-object.h> #include <glib.h> +#ifdef HAVE_WEBKIT2 +#include <webkit2/webkit2.h> +#else #include <webkit/webkit.h> +#endif G_BEGIN_DECLS diff --git a/embed/ephy-embed-prefs.c b/embed/ephy-embed-prefs.c index e16c06602..066619783 100644 --- a/embed/ephy-embed-prefs.c +++ b/embed/ephy-embed-prefs.c @@ -29,7 +29,11 @@ #include "ephy-settings.h" #include <glib.h> +#ifdef HAVE_WEBKIT2 +#include <webkit2/webkit2.h> +#else #include <webkit/webkit.h> +#endif typedef struct { @@ -39,7 +43,11 @@ typedef struct void (*callback) (GSettings *settings, char *key, gpointer data); } PrefData; +#ifdef HAVE_WEBKIT2 +/* TODO: WebKitSettings */ +#else static WebKitWebSettings *webkit_settings = NULL; +#endif static void webkit_pref_callback_user_stylesheet (GSettings *settings, @@ -60,8 +68,11 @@ webkit_pref_callback_user_stylesheet (GSettings *settings, G_DIR_SEPARATOR_S, USER_STYLESHEET_FILENAME, NULL); - +#ifdef HAVE_WEBKIT2 + /* TODO: WebKitSettings */ +#else g_object_set (webkit_settings, webkit_pref, uri, NULL); +#endif g_free (uri); } @@ -106,6 +117,10 @@ webkit_pref_get_internal_user_agent (void) g_key_file_free (branding_keyfile); +#ifdef HAVE_WEBKIT2 + /* TODO: User agent */ + return g_strup (""); +#else g_object_get (webkit_settings, "user-agent", &webkit_user_agent, NULL); user_agent = g_strconcat (webkit_user_agent, " ", @@ -118,6 +133,7 @@ webkit_pref_get_internal_user_agent (void) g_free (webkit_user_agent); return user_agent; +#endif } static void @@ -125,6 +141,9 @@ webkit_pref_callback_user_agent (GSettings *settings, char *key, gpointer data) { +#ifdef HAVE_WEBKIT2 + /* TODO: User agent */ +#else char *value = NULL; static char *internal_user_agent = NULL; char *webkit_pref = data; @@ -140,6 +159,7 @@ webkit_pref_callback_user_agent (GSettings *settings, g_object_set (webkit_settings, webkit_pref, value, NULL); g_free (value); +#endif } static void @@ -175,8 +195,11 @@ webkit_pref_callback_font_size (GSettings *settings, size /= PANGO_SCALE; pango_font_description_free (desc); } - +#ifdef HAVE_WEBKIT2 + /* TODO: WebKitSettings */ +#else g_object_set (webkit_settings, webkit_pref, size, NULL); +#endif g_free (value); } @@ -209,7 +232,11 @@ webkit_pref_callback_font_family (GSettings *settings, desc = pango_font_description_from_string (value); family = pango_font_description_get_family (desc); +#ifdef HAVE_WEBKIT2 + /* TODO: WEbKitSettings */ +#else g_object_set (webkit_settings, webkit_pref, family, NULL); +#endif pango_font_description_free (desc); } @@ -266,6 +293,9 @@ webkit_pref_callback_accept_languages (GSettings *settings, char *key, gpointer data) { +#ifdef HAVE_WEBKIT2 + /* TODO: Languages */ +#else SoupSession *session; GArray *array; char **languages; @@ -299,6 +329,7 @@ webkit_pref_callback_accept_languages (GSettings *settings, g_strfreev (languages); g_free (langs_str); g_array_free (array, TRUE); +#endif } void @@ -329,6 +360,9 @@ webkit_pref_callback_cookie_accept_policy (GSettings *settings, char *key, gpointer data) { +#ifdef HAVE_WEBKIT2 + /* TODO: Cookies */ +#else SoupSession *session; char *value = NULL; @@ -348,6 +382,7 @@ webkit_pref_callback_cookie_accept_policy (GSettings *settings, } g_free (value); +#endif } static void @@ -355,6 +390,9 @@ webkit_pref_callback_gnome_fonts (GSettings *ephy_settings, char *key, gpointer data) { +#ifdef HAVE_WEBKIT2 + /* TODO: WebKitSettings */ +#else GSettings *settings; if (g_settings_get_boolean (ephy_settings, key)) { @@ -383,6 +421,7 @@ webkit_pref_callback_gnome_fonts (GSettings *ephy_settings, webkit_pref_callback_font_family (settings, EPHY_PREFS_WEB_SERIF_FONT, "serif-font-family"); } +#endif } static void @@ -422,8 +461,12 @@ webkit_pref_callback_enable_spell_checking (GSettings *settings, g_strfreev (languages); } +#ifdef HAVE_WEBKIT2 + /* TODO: WebKitSettings */ +#else g_object_set (webkit_settings, "enable-spell-checking", value, NULL); g_object_set (webkit_settings, "spell-checking-languages", langs, NULL); +#endif g_free (langs); } @@ -484,18 +527,24 @@ static const PrefData webkit_pref_entries[] = webkit_pref_callback_cookie_accept_policy }, }; +#ifdef HAVE_WEBKIT2 +/* TODO: WebKitSettings */ +#else static void ephy_embed_prefs_apply (EphyEmbed *embed, WebKitWebSettings *settings) { webkit_web_view_set_settings (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed), settings); } +#endif void ephy_embed_prefs_init (void) { int i; - +#ifdef HAVE_WEBKIT2 + /* TODO: WebKitSettings */ +#else webkit_settings = webkit_web_settings_new (); /* Hardcoded settings */ @@ -552,17 +601,26 @@ ephy_embed_prefs_init (void) EPHY_PREFS_WEB_ENABLE_WEBGL, webkit_settings, "enable-webgl", G_SETTINGS_BIND_GET); +#endif } void ephy_embed_prefs_shutdown (void) { +#ifdef HAVE_WEBKIT2 + /* TODO: WebKitSettings */ +#else g_object_unref (webkit_settings); +#endif } void ephy_embed_prefs_add_embed (EphyEmbed *embed) { +#ifdef HAVE_WEBKIT2 + /* TODO: WebKitSettings */ +#else ephy_embed_prefs_apply (embed, webkit_settings); +#endif } diff --git a/embed/ephy-embed-single.c b/embed/ephy-embed-single.c index 8eb52daab..e2280bea4 100644 --- a/embed/ephy-embed-single.c +++ b/embed/ephy-embed-single.c @@ -37,7 +37,11 @@ #include "ephy-settings.h" #include "ephy-request-about.h" +#ifdef HAVE_WEBKIT2 +#include <webkit2/webkit2.h> +#else #include <webkit/webkit.h> +#endif #include <glib/gi18n.h> #include <libsoup/soup-gnome.h> #include <libsoup/soup-cache.h> @@ -343,6 +347,9 @@ cache_size_cb (GSettings *settings, gboolean ephy_embed_single_initialize (EphyEmbedSingle *single) { +#ifdef HAVE_WEBKIT2 + /* TODO: Network features */ +#else SoupSession *session; SoupCookieJar *jar; char *filename; @@ -413,7 +420,7 @@ ephy_embed_single_initialize (EphyEmbedSingle *single) favicon_db_path = g_build_filename (g_get_user_data_dir (), g_get_prgname (), NULL); webkit_favicon_database_set_path (webkit_get_favicon_database (), favicon_db_path); g_free (favicon_db_path); - +#endif return TRUE; } diff --git a/embed/ephy-embed-utils.h b/embed/ephy-embed-utils.h index ded63a5d8..5f7cd95ce 100644 --- a/embed/ephy-embed-utils.h +++ b/embed/ephy-embed-utils.h @@ -34,7 +34,12 @@ G_BEGIN_DECLS #define EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED(embed) (WEBKIT_WEB_VIEW (ephy_embed_get_web_view (embed))) +#ifdef HAVE_WEBKIT2 +/* There's no scrolled window widget in WebKit2 */ +#define EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW(view) (EPHY_EMBED (gtk_widget_get_parent (gtk_widget_get_parent (gtk_widget_get_parent ((GTK_WIDGET (view))))))) +#else #define EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW(view) (EPHY_EMBED (gtk_widget_get_parent (gtk_widget_get_parent (gtk_widget_get_parent (gtk_widget_get_parent ((GTK_WIDGET (view)))))))) +#endif #define EPHY_WEBKIT_BACK_FORWARD_LIMIT 100 diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c index 46366b4bf..a458f17dd 100644 --- a/embed/ephy-embed.c +++ b/embed/ephy-embed.c @@ -37,13 +37,21 @@ #include "nautilus-floating-bar.h" #include <glib/gi18n.h> +#ifdef HAVE_WEBKIT2 +#include <webkit2/webkit2.h> +#else #include <webkit/webkit.h> +#endif static void ephy_embed_constructed (GObject *object); +#ifdef HAVE_WEBKIT2 +/* TODO: Inspector */ +#else static gboolean ephy_embed_inspect_show_cb (WebKitWebInspector *inspector, EphyEmbed *embed); static gboolean ephy_embed_inspect_close_cb (WebKitWebInspector *inspector, EphyEmbed *embed); +#endif #define EPHY_EMBED_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_EMBED, EphyEmbedPrivate)) @@ -58,7 +66,9 @@ typedef struct { struct _EphyEmbedPrivate { GtkBox *top_widgets_vbox; +#ifndef HAVE_WEBKIT2 GtkScrolledWindow *scrolled_window; +#endif GtkPaned *paned; WebKitWebView *web_view; GtkWidget *inspector_window; @@ -220,6 +230,9 @@ ephy_embed_statusbar_pop (EphyEmbed *embed, guint context_id) ephy_embed_statusbar_update (embed, msg ? msg->text : NULL); } +#ifdef HAVE_WEBKIT2 +/* TODO: WebKitWebResource::send-request */ +#else static void resource_request_starting_cb (WebKitWebView *web_view, WebKitWebFrame *web_frame, @@ -242,6 +255,7 @@ resource_request_starting_cb (WebKitWebView *web_view, webkit_network_request_set_uri (request, "about:blank"); } } +#endif static void ephy_embed_destroy_top_widgets (EphyEmbed *embed) @@ -262,6 +276,9 @@ remove_from_destroy_list_cb (GtkWidget *widget, EphyEmbed *embed) embed->priv->destroy_on_transition_list = list; } +#ifdef HAVE_WEBKIT2 +/* TODO: Loader */ +#else static void load_status_changed_cb (WebKitWebView *web_view, GParamSpec *spec, @@ -272,6 +289,7 @@ load_status_changed_cb (WebKitWebView *web_view, if (status == WEBKIT_LOAD_COMMITTED) ephy_embed_destroy_top_widgets (embed); } +#endif static void ephy_embed_grab_focus (GtkWidget *widget) @@ -323,6 +341,9 @@ ephy_embed_dispose (GObject *object) EphyEmbedPrivate *priv = embed->priv; if (priv->inspector_window) { +#ifdef HAVE_WEBKIT2 + /* TODO: Inspector */ +#else WebKitWebInspector *inspector; inspector = webkit_web_view_get_inspector (priv->web_view); @@ -334,6 +355,7 @@ ephy_embed_dispose (GObject *object) g_signal_handlers_disconnect_by_func (inspector, ephy_embed_inspect_close_cb, priv->inspector_window); +#endif gtk_widget_destroy (GTK_WIDGET (priv->inspector_window)); priv->inspector_window = NULL; @@ -419,6 +441,9 @@ ephy_embed_class_init (EphyEmbedClass *klass) g_type_class_add_private (G_OBJECT_CLASS (klass), sizeof(EphyEmbedPrivate)); } +#ifdef HAVE_WEBKIT2 +/* TODO: Inspector */ +#else static WebKitWebView * ephy_embed_inspect_web_view_cb (WebKitWebInspector *inspector, WebKitWebView *web_view, @@ -507,6 +532,7 @@ ephy_embed_inspect_close_cb (WebKitWebInspector *inspector, return TRUE; } +#endif void ephy_embed_auto_download_url (EphyEmbed *embed, const char *url) @@ -518,6 +544,9 @@ ephy_embed_auto_download_url (EphyEmbed *embed, const char *url) ephy_download_set_action (download, EPHY_DOWNLOAD_ACTION_OPEN); } +#ifdef HAVE_WEBKIT2 +/* TODO: Downloads */ +#else static gboolean download_requested_cb (WebKitWebView *web_view, WebKitDownload *download, @@ -539,6 +568,7 @@ download_requested_cb (WebKitWebView *web_view, return TRUE; } +#endif static void ephy_embed_set_fullscreen_message (EphyEmbed *embed, @@ -610,6 +640,9 @@ status_message_notify_cb (EphyWebView *view, GParamSpec *pspec, EphyEmbed *embed } } +#ifdef HAVE_WEBKIT2 +/* TODO: WebKitWindowProperties */ +#else static void window_resize_requested (WebKitWebWindowFeatures *features, GParamSpec *pspec, EphyEmbed *embed) { @@ -638,6 +671,7 @@ window_resize_requested (WebKitWebWindowFeatures *features, GParamSpec *pspec, E g_object_get (features, "width", &width, "height", &height, NULL); gtk_window_resize (GTK_WINDOW (window), width, height); } +#endif static gboolean clear_progress_cb (EphyEmbed *embed) @@ -648,6 +682,9 @@ clear_progress_cb (EphyEmbed *embed) return FALSE; } +#ifdef HAVE_WEBKIT2 +/* TODO: Load progress */ +#else static void progress_update (EphyWebView *view, GParamSpec *pspec, EphyEmbed *embed) { @@ -679,22 +716,29 @@ progress_update (EphyWebView *view, GParamSpec *pspec, EphyEmbed *embed) gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (priv->progress), (loading || progress == 1.0) ? progress : 0.0); } +#endif static void ephy_embed_constructed (GObject *object) { EphyEmbed *embed = (EphyEmbed*)object; EphyEmbedPrivate *priv = embed->priv; +#ifndef HAVE_WEBKIT2 GtkWidget *scrolled_window; +#endif GtkWidget *paned; WebKitWebView *web_view; +#ifndef HAVE_WEBKIT2 WebKitWebWindowFeatures *window_features; WebKitWebInspector *inspector; +#endif GtkWidget *overlay; /* Skeleton */ web_view = WEBKIT_WEB_VIEW (ephy_web_view_new ()); +#ifndef HAVE_WEBKIT2 scrolled_window = GTK_WIDGET (priv->scrolled_window); +#endif overlay = gtk_overlay_new (); gtk_style_context_add_class (gtk_widget_get_style_context (overlay), GTK_STYLE_CLASS_OSD); @@ -702,7 +746,11 @@ ephy_embed_constructed (GObject *object) gtk_widget_add_events (overlay, GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); +#ifdef HAVE_WEBKIT2 + gtk_container_add (GTK_CONTAINER (overlay), GTK_WIDGET (web_view)); +#else gtk_container_add (GTK_CONTAINER (overlay), scrolled_window); +#endif /* Floating message popup for fullscreen mode. */ priv->fullscreen_message_label = gtk_label_new (NULL); @@ -729,11 +777,17 @@ ephy_embed_constructed (GObject *object) paned = GTK_WIDGET (priv->paned); priv->web_view = web_view; +#ifdef HAVE_WEBKIT2 + /* TODO: Load progress */ +#else priv->progress_update_handler_id = g_signal_connect (web_view, "notify::progress", G_CALLBACK (progress_update), object); +#endif +#ifndef HAVE_WEBKIT2 gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (web_view)); +#endif gtk_paned_pack1 (GTK_PANED (paned), GTK_WIDGET (overlay), TRUE, FALSE); @@ -746,6 +800,9 @@ ephy_embed_constructed (GObject *object) gtk_widget_show (GTK_WIDGET (web_view)); gtk_widget_show_all (paned); +#ifdef HAVE_WEBKIT2 + /* TODO: Loader, WebKitWebResource::send-request, Downloads */ +#else g_object_connect (web_view, "signal::notify::load-status", G_CALLBACK (load_status_changed_cb), embed, "signal::resource-request-starting", G_CALLBACK (resource_request_starting_cb), embed, @@ -753,11 +810,19 @@ ephy_embed_constructed (GObject *object) "signal::entering-fullscreen", G_CALLBACK (entering_fullscreen_cb), embed, "signal::leaving-fullscreen", G_CALLBACK (leaving_fullscreen_cb), embed, NULL); +#endif +#ifdef HAVE_WEBKIT2 + /* TODO: status message? */ +#else priv->status_handler_id = g_signal_connect (web_view, "notify::status-message", G_CALLBACK (status_message_notify_cb), embed); +#endif +#ifdef HAVE_WEBKIT2 + /* TODO: WebKitWindowProperties */ +#else /* Window features */ window_features = webkit_web_view_get_window_features (web_view); g_object_connect (window_features, @@ -766,9 +831,13 @@ ephy_embed_constructed (GObject *object) "signal::notify::width", G_CALLBACK (window_resize_requested), embed, "signal::notify::height", G_CALLBACK (window_resize_requested), embed, NULL); +#endif /* The inspector */ priv->inspector_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); +#ifdef HAVE_WEBKIT2 + /* TODO: Inspector */ +#else inspector = webkit_web_view_get_inspector (web_view); priv->inspector_scrolled_window = gtk_scrolled_window_new (NULL, NULL); @@ -798,6 +867,7 @@ ephy_embed_constructed (GObject *object) "signal::detach-window", G_CALLBACK (ephy_embed_detach_inspector_cb), embed, NULL); +#endif ephy_embed_prefs_add_embed (embed); } @@ -810,15 +880,19 @@ ephy_embed_init (EphyEmbed *embed) gtk_orientable_set_orientation (GTK_ORIENTABLE (embed), GTK_ORIENTATION_VERTICAL); +#ifndef HAVE_WEBKIT2 embed->priv->scrolled_window = GTK_SCROLLED_WINDOW (gtk_scrolled_window_new (NULL, NULL)); +#endif embed->priv->paned = GTK_PANED (gtk_paned_new (GTK_ORIENTATION_VERTICAL)); embed->priv->top_widgets_vbox = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 0)); embed->priv->seq_context_id = 1; embed->priv->seq_message_id = 1; embed->priv->tab_message_id = ephy_embed_statusbar_get_context_id (embed, EPHY_EMBED_STATUSBAR_TAB_MESSAGE_CONTEXT_DESCRIPTION); +#ifndef HAVE_WEBKIT2 gtk_scrolled_window_set_policy (embed->priv->scrolled_window, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); +#endif } /** diff --git a/embed/ephy-request-about.c b/embed/ephy-request-about.c index bfff22f95..cddb9d135 100644 --- a/embed/ephy-request-about.c +++ b/embed/ephy-request-about.c @@ -30,7 +30,11 @@ #include <gio/gio.h> #include <glib/gi18n.h> #include <libsoup/soup-uri.h> +#ifdef HAVE_WEBKIT2 +#include <webkit2/webkit2.h> +#else #include <webkit/webkit.h> +#endif G_DEFINE_TYPE (EphyRequestAbout, ephy_request_about, SOUP_TYPE_REQUEST) @@ -93,6 +97,9 @@ ephy_request_about_send (SoupRequest *request, read_css_style (about); if (!g_strcmp0 (uri->path, "plugins")) { +#ifdef HAVE_WEBKIT2 + /* TODO: SoupRequest and Plugins */ +#else WebKitWebPluginDatabase* database = webkit_get_web_plugin_database (); GSList *plugin_list, *p; @@ -136,6 +143,7 @@ ephy_request_about_send (SoupRequest *request, } webkit_web_plugin_database_plugins_list_free (plugin_list); +#endif g_string_append (data_str, "</body>"); } else if (!g_strcmp0 (uri->path, "memory")) { char *memory = ephy_smaps_to_html (EPHY_REQUEST_ABOUT (request)->priv->smaps); diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c index 5aa5bff25..c0350a3ca 100644 --- a/embed/ephy-web-view.c +++ b/embed/ephy-web-view.c @@ -72,7 +72,11 @@ struct _EphyWebViewPrivate { EphyWebViewSecurityLevel security_level; EphyWebViewDocumentType document_type; EphyWebViewNavigationFlags nav_flags; +#ifdef HAVE_WEBKIT2 + /* TODO: Loader */ +#else WebKitLoadStatus load_status; +#endif /* Flags */ guint is_blank : 1; @@ -560,6 +564,9 @@ ephy_web_view_dispose (GObject *object) G_OBJECT_CLASS (ephy_web_view_parent_class)->dispose (object); } +#ifdef HAVE_WEBKIT2 +/* TODO: DOM bindings */ +#else typedef struct { WebKitDOMNode *username_node; WebKitDOMNode *password_node; @@ -665,6 +672,7 @@ find_username_and_password_elements (WebKitDOMNode *form_node, g_object_unref(elements); } +#endif typedef struct { EphyEmbed *embed; @@ -835,6 +843,9 @@ should_store_cb (GnomeKeyringResult retval, request_decision_on_storing (store_data); } +#ifdef HAVE_WEBKIT2 +/* TODO: DOM bindings */ +#else static gboolean form_submitted_cb (WebKitDOMHTMLFormElement *dom_form, WebKitDOMEvent *dom_event, @@ -1040,6 +1051,7 @@ _ephy_web_view_hook_into_links (EphyWebView *web_view) g_object_unref(links); } +#endif static void update_navigation_flags (EphyWebView *view) @@ -1064,6 +1076,9 @@ update_navigation_flags (EphyWebView *view) static void ephy_web_view_clear_history (EphyWebView *view) { +#ifdef HAVE_WEBKIT2 + /* TODO: History */ +#else WebKitWebBackForwardList *history_list; g_return_if_fail (EPHY_IS_WEB_VIEW (view)); @@ -1083,6 +1098,7 @@ ephy_web_view_clear_history (EphyWebView *view) update_navigation_flags (view); } +#endif } static void @@ -1141,11 +1157,15 @@ title_changed_cb (WebKitWebView *web_view, { const char *uri; char *title; - WebKitWebFrame *frame; EphyHistoryService *history = EPHY_WEB_VIEW (web_view)->priv->history_service; +#ifndef HAVE_WEBKIT2 + WebKitWebFrame *frame; frame = webkit_web_view_get_main_frame (web_view); uri = webkit_web_frame_get_uri (frame); +#else + uri = webkit_web_view_get_uri (web_view); +#endif g_object_get (web_view, "title", &title, NULL); @@ -1181,6 +1201,9 @@ uri_changed_cb (WebKitWebView *web_view, g_free (uri); } +#ifdef HAVE_WEBKIT2 +/* TODO: Mouse target changed */ +#else static void hovering_over_link_cb (EphyWebView *web_view, char *title, @@ -1189,6 +1212,7 @@ hovering_over_link_cb (EphyWebView *web_view, { ephy_web_view_set_link_message (web_view, location); } +#endif static void ephy_web_view_constructed (GObject *object) @@ -1201,7 +1225,10 @@ ephy_web_view_constructed (GObject *object) * different keys for text and full content zooming. AFAIK you can * have both enabled at the same time in WebKit now (although our * API does not reflect this atm). See r67274 in WebKit. */ +#ifndef HAVE_WEBKIT2 + /* This is the default behaviour in WebKit2 */ webkit_web_view_set_full_content_zoom (WEBKIT_WEB_VIEW (object), TRUE); +#endif } static void @@ -1589,6 +1616,9 @@ ephy_web_view_class_init (EphyWebViewClass *klass) g_type_class_add_private (gobject_class, sizeof (EphyWebViewPrivate)); } +#ifdef HAVE_WEBKIT2 +/* TODO: Favicons */ +#else static void _ephy_web_view_load_icon (EphyWebView *view) { @@ -1630,6 +1660,7 @@ favicon_cb (EphyWebView *view, { _ephy_web_view_set_icon_address (view, address); } +#endif static void new_window_cb (EphyWebView *view, @@ -1656,6 +1687,9 @@ ge_popup_blocked_cb (EphyWebView *view, popups_manager_add (view, url, name, features); } +#ifdef HAVE_WEBKIT2 +/* TODO: Policy Client */ +#else static gboolean mime_type_policy_decision_requested_cb (WebKitWebView *web_view, WebKitWebFrame *frame, @@ -1740,7 +1774,11 @@ mime_type_policy_decision_requested_cb (WebKitWebView *web_view, return FALSE; } +#endif +#ifdef HAVE_WEBKIT2 +/* TODO: Geolocation */ +#else static void decide_on_geolocation_policy_request (GtkWidget *info_bar, int response, @@ -1822,7 +1860,11 @@ geolocation_policy_decision_requested_cb (WebKitWebView *web_view, return TRUE; } +#endif +#ifdef HAVE_WEBKIT2 +/* TODO: DOM Bindings */ +#else static gboolean delete_web_app_cb (WebKitDOMHTMLElement *button, WebKitDOMEvent *dom_event, @@ -1838,6 +1880,7 @@ delete_web_app_cb (WebKitDOMHTMLElement *button, return FALSE; } +#endif static void get_host_for_url_cb (gpointer service, @@ -1876,6 +1919,9 @@ restore_zoom_level (EphyWebView *view, (EphyHistoryJobCallback)get_host_for_url_cb, view); } +#ifdef HAVE_WEBKIT2 +/* TODO: Loader */ +#else static void load_status_cb (WebKitWebView *web_view, GParamSpec *pspec, @@ -2046,6 +2092,7 @@ load_status_cb (WebKitWebView *web_view, g_object_thaw_notify (object); } +#endif /** * ephy_web_view_load_error_page: @@ -2144,7 +2191,11 @@ ephy_web_view_load_error_page (EphyWebView *view, g_file_get_contents (html_file, &template, NULL, NULL); ephy_web_view_set_title (view, page_title); +#ifdef HAVE_WEBKIT2 + /* TODO: Favicons */ +#else _ephy_web_view_set_icon_address (view, NULL); +#endif g_string_printf (html, template, lang, lang, @@ -2162,11 +2213,18 @@ ephy_web_view_load_error_page (EphyWebView *view, g_free (button_label); g_free (image_data); +#ifdef HAVE_WEBKIT2 + webkit_web_view_load_html (WEBKIT_WEB_VIEW (view), html->str, uri); +#else webkit_web_view_load_string (WEBKIT_WEB_VIEW (view), html->str, "text/html", "utf8", uri); +#endif g_string_free (html, TRUE); } +#ifdef HAVE_WEBKIT2 +/* TODO: Load error */ +#else static gboolean load_error_cb (WebKitWebView *web_view, WebKitWebFrame *frame, @@ -2228,7 +2286,11 @@ load_error_cb (WebKitWebView *web_view, return FALSE; } +#endif +#ifdef HAVE_WEBKIT2 +/* TODO: WebKitWebView::close */ +#else static gboolean close_web_view_cb (WebKitWebView *web_view, gpointer user_data) @@ -2245,6 +2307,7 @@ close_web_view_cb (WebKitWebView *web_view, return TRUE; } +#endif static void zoom_changed_cb (WebKitWebView *web_view, @@ -2270,6 +2333,9 @@ zoom_changed_cb (WebKitWebView *web_view, g_free (address); } +#ifdef HAVE_WEBKIT2 +/* TODO: WebKitWebResource::send-request */ +#else static void add_do_not_track_header_cb (WebKitWebView *view, WebKitWebFrame *frame, WebKitWebResource *resource, WebKitNetworkRequest *request, @@ -2306,6 +2372,7 @@ do_not_track_setting_changed_cb (GSettings *settings, priv->do_not_track_handler = 0; } } +#endif static void ephy_web_view_init (EphyWebView *web_view) @@ -2316,7 +2383,9 @@ ephy_web_view_init (EphyWebView *web_view) priv->expire_address_now = TRUE; priv->is_blank = TRUE; +#ifndef HAVE_WEBKIT2 priv->load_status = WEBKIT_LOAD_PROVISIONAL; +#endif priv->title = g_strdup (EMPTY_PAGE); priv->document_type = EPHY_WEB_VIEW_DOCUMENT_HTML; priv->security_level = EPHY_WEB_VIEW_STATE_IS_UNKNOWN; @@ -2332,25 +2401,45 @@ ephy_web_view_init (EphyWebView *web_view) "cleared", G_CALLBACK (ephy_web_view_history_cleared_cb), web_view); +#ifdef HAVE_WEBKIT2 + /* TODO: Policy Client */ +#else g_signal_connect (web_view, "mime-type-policy-decision-requested", G_CALLBACK (mime_type_policy_decision_requested_cb), NULL); +#endif +#ifdef HAVE_WEBKIT2 + /* TODO: Geolocation */ +#else g_signal_connect (web_view, "geolocation-policy-decision-requested", G_CALLBACK (geolocation_policy_decision_requested_cb), NULL); +#endif +#ifdef HAVE_WEBKIT2 + /* TODO: Loader */ +#else g_signal_connect (web_view, "notify::load-status", G_CALLBACK (load_status_cb), NULL); +#endif +#ifdef HAVE_WEBKIT2 + /* TODO: WebKitWebView::close */ +#else g_signal_connect (web_view, "close-web-view", G_CALLBACK (close_web_view_cb), NULL); +#endif +#ifdef HAVE_WEBKIT2 + /* TODO: Load errors */ +#else g_signal_connect (web_view, "load-error", G_CALLBACK (load_error_cb), NULL); +#endif g_signal_connect (web_view, "notify::zoom-level", G_CALLBACK (zoom_changed_cb), @@ -2364,13 +2453,21 @@ ephy_web_view_init (EphyWebView *web_view) G_CALLBACK (uri_changed_cb), NULL); +#ifdef HAVE_WEBKIT2 + /* TODO: Mouse target changed */ +#else g_signal_connect (web_view, "hovering-over-link", G_CALLBACK (hovering_over_link_cb), NULL); +#endif +#ifdef HAVE_WEBKIT2 + /* TODO: Favicons */ +#else g_signal_connect (web_view, "icon-loaded", G_CALLBACK (favicon_cb), NULL); +#endif g_signal_connect (web_view, "new-window", G_CALLBACK (new_window_cb), @@ -2379,7 +2476,9 @@ ephy_web_view_init (EphyWebView *web_view) g_signal_connect (web_view, "ge_popup_blocked", G_CALLBACK (ge_popup_blocked_cb), NULL); - +#ifdef HAVE_WEBKIT2 + /* TODO: WebKitWebResource::send-request */ +#else if (g_settings_get_boolean (EPHY_SETTINGS_WEB, EPHY_PREFS_WEB_DO_NOT_TRACK)) priv->do_not_track_handler = g_signal_connect (web_view, "resource-request-starting", G_CALLBACK (add_do_not_track_header_cb), NULL); @@ -2387,6 +2486,7 @@ ephy_web_view_init (EphyWebView *web_view) g_signal_connect (EPHY_SETTINGS_WEB, "changed::" EPHY_PREFS_WEB_DO_NOT_TRACK, G_CALLBACK (do_not_track_setting_changed_cb), web_view); +#endif } /** @@ -2456,15 +2556,33 @@ normalize_or_autosearch_url (EphyWebView *view, const char *url) * * Loads the given #WebKitNetworkRequest in the given #EphyWebView. **/ +#ifdef HAVE_WEBKIT2 +void +ephy_web_view_load_request (EphyWebView *view, + WebKitURIRequest *request) +#else void ephy_web_view_load_request (EphyWebView *view, WebKitNetworkRequest *request) +#endif { +#ifndef HAVE_WEBKIT2 WebKitWebFrame *main_frame; +#endif const char *url; char *effective_url; g_return_if_fail (EPHY_IS_WEB_VIEW(view)); +#ifdef HAVE_WEBKIT2 + g_return_if_fail (WEBKIT_IS_URI_REQUEST(request)); + + url = webkit_uri_request_get_uri (request); + effective_url = normalize_or_autosearch_url (view, url); + + // TODO: webkit_uri_request_set_uri? + webkit_web_view_load_uri (WEBKIT_WEB_VIEW(view), effective_url); + g_free (effective_url); +#else g_return_if_fail (WEBKIT_IS_NETWORK_REQUEST(request)); url = webkit_network_request_get_uri (request); @@ -2474,6 +2592,7 @@ ephy_web_view_load_request (EphyWebView *view, main_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW(view)); webkit_web_frame_load_request(main_frame, request); +#endif } typedef struct { @@ -2544,6 +2663,9 @@ ephy_web_view_load_url (EphyWebView *view, * typed in the location entry, which uses this method to do the * load. */ if (!ephy_embed_utils_address_has_web_scheme (effective_url)) { +#ifdef HAVE_WEBKIT2 + /* TODO: Network features */ +#else SoupMessage *message; SoupSession *session; char *temp_url; @@ -2569,12 +2691,17 @@ ephy_web_view_load_url (EphyWebView *view, } g_free (temp_url); +#endif } else if (g_str_has_prefix (effective_url, "javascript:")) { +#ifdef HAVE_WEBKIT2 + /* TODO: Run JavaScript */ +#else char *decoded_url; decoded_url = soup_uri_decode (effective_url); webkit_web_view_execute_script (WEBKIT_WEB_VIEW (view), decoded_url); g_free (decoded_url); +#endif } else webkit_web_view_load_uri (WEBKIT_WEB_VIEW (view), effective_url); @@ -2596,6 +2723,9 @@ void ephy_web_view_copy_back_history (EphyWebView *source, EphyWebView *dest) { +#ifdef HAVE_WEBKIT2 + /* TODO: BackForwardList */ +#else WebKitWebView *source_view, *dest_view; WebKitWebBackForwardList* source_bflist, *dest_bflist; WebKitWebHistoryItem *item; @@ -2626,6 +2756,7 @@ ephy_web_view_copy_back_history (EphyWebView *source, item = webkit_web_back_forward_list_get_current_item (source_bflist); if (item) webkit_web_back_forward_list_add_item (dest_bflist, item); +#endif } static void @@ -2976,7 +3107,12 @@ ephy_web_view_location_changed (EphyWebView *view, } ephy_web_view_set_link_message (view, NULL); +#ifdef HAVE_WEBKIT2 + /* TODO: Favicons */ +#else _ephy_web_view_set_icon_address (view, NULL); +#endif + update_navigation_flags (view); g_object_notify (object, "embed-title"); @@ -2998,6 +3134,10 @@ ephy_web_view_location_changed (EphyWebView *view, gboolean ephy_web_view_is_loading (EphyWebView *view) { +#ifdef HAVE_WEBKIT2 + /* Loader */ + return FALSE; +#else WebKitLoadStatus status; status = webkit_web_view_get_load_status (WEBKIT_WEB_VIEW (view)); @@ -3016,6 +3156,7 @@ ephy_web_view_is_loading (EphyWebView *view) view->priv->load_status = status; return status != WEBKIT_LOAD_FINISHED && status != WEBKIT_LOAD_FAILED; +#endif } /** @@ -3258,6 +3399,9 @@ ephy_web_view_set_typed_address (EphyWebView *view, gboolean ephy_web_view_has_modified_forms (EphyWebView *view) { +#ifdef HAVE_WEBKIT2 + /* TODO: DOM Bindings */ +#else WebKitDOMHTMLCollection *forms = NULL; WebKitDOMDocument *document = NULL; gulong forms_n; @@ -3309,7 +3453,7 @@ ephy_web_view_has_modified_forms (EphyWebView *view) } } } - +#endif return FALSE; } @@ -3332,8 +3476,12 @@ ephy_web_view_get_location (EphyWebView *view, gboolean toplevel) { /* FIXME: follow the toplevel parameter */ +#ifdef HAVE_WEBKIT2 + return g_strdup (webkit_web_view_get_uri (WEBKIT_WEB_VIEW (view))); +#else WebKitWebFrame *web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view)); return g_strdup (webkit_web_frame_get_uri (web_frame)); +#endif } /** @@ -3363,6 +3511,9 @@ ephy_web_view_get_security_level (EphyWebView *view, static void ephy_web_view_run_print_action (EphyWebView *view, GtkPrintOperationAction action) { +#ifdef HAVE_WEBKIT2 + /* TODO: Printing */ +#else WebKitWebFrame *main_frame; GtkPrintOperation *operation; GError *error; @@ -3400,6 +3551,7 @@ ephy_web_view_run_print_action (EphyWebView *view, GtkPrintOperationAction actio ephy_embed_shell_set_page_setup (shell, gtk_print_operation_get_default_page_setup (operation)); g_object_unref (operation); +#endif } /** @@ -3451,6 +3603,9 @@ ephy_web_view_get_title_composite (EphyWebView *view) return title != NULL ? title : ""; } +#ifdef HAVE_WEBKIT2 +/* TODO: webkit_web_view_save() */ +#else static void ephy_web_view_save_sub_resource_start (GList *subresources, char *destination_uri); @@ -3671,7 +3826,7 @@ ephy_web_view_save_sub_resources (EphyWebView *view, const char *uri, GList *sub /* Now, let's start saving sub resources */ ephy_web_view_save_sub_resource_start (subresources, destination_uri); } - +#endif /** * ephy_web_view_save: * @view: an #EphyWebView @@ -3682,6 +3837,9 @@ ephy_web_view_save_sub_resources (EphyWebView *view, const char *uri, GList *sub void ephy_web_view_save (EphyWebView *view, const char *uri) { +#ifdef HAVE_WEBKIT2 + /* TODO: webkit_web_view_save() */ +#else WebKitWebFrame *frame; WebKitWebDataSource *data_source; GList *subresources; @@ -3708,6 +3866,7 @@ ephy_web_view_save (EphyWebView *view, const char *uri) return; ephy_web_view_save_sub_resources (view, uri, subresources); +#endif } /** diff --git a/embed/ephy-web-view.h b/embed/ephy-web-view.h index dd8235a03..28203b274 100644 --- a/embed/ephy-web-view.h +++ b/embed/ephy-web-view.h @@ -28,7 +28,11 @@ #define EPHY_WEB_VIEW_H #include <gtk/gtk.h> +#ifdef HAVE_WEBKIT2 +#include <webkit2/webkit2.h> +#else #include <webkit/webkit.h> +#endif G_BEGIN_DECLS @@ -123,7 +127,11 @@ GType ephy_web_view_chrome_get_type (void); GType ephy_web_view_security_level_get_type (void); GtkWidget * ephy_web_view_new (void); void ephy_web_view_load_request (EphyWebView *view, +#ifdef HAVE_WEBKIT2 + WebKitURIRequest *request); +#else WebKitNetworkRequest *request); +#endif void ephy_web_view_load_url (EphyWebView *view, const char *url); void ephy_web_view_copy_back_history (EphyWebView *source, |