[epiphany] Allow to build epiphany with WebKit from current git master



commit 2bf254cb1791bf922fc8ff6e833d490135f2c925
Author: Carlos Garcia Campos <cgarcia igalia com>
Date:   Fri Jul 11 14:08:16 2014 +0200

    Allow to build epiphany with WebKit from current git master
    
    Update to the latest API changes

 embed/ephy-embed-prefs.c |   15 +++++++++++++++
 embed/ephy-embed-shell.c |   19 +++++++++++++++++++
 embed/ephy-embed-shell.h |    1 +
 embed/ephy-web-view.c    |    3 +++
 4 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/embed/ephy-embed-prefs.c b/embed/ephy-embed-prefs.c
index 3d77d42..db926e6 100644
--- a/embed/ephy-embed-prefs.c
+++ b/embed/ephy-embed-prefs.c
@@ -54,9 +54,20 @@ user_style_sheet_output_stream_splice_cb (GOutputStream *output_stream,
 
   bytes = g_output_stream_splice_finish (output_stream, result, NULL);
   if (bytes > 0) {
+#if WEBKIT_CHECK_VERSION(2, 5, 0)
+    WebKitUserStyleSheet *style_sheet;
+
+    style_sheet = webkit_user_style_sheet_new (g_memory_output_stream_get_data (G_MEMORY_OUTPUT_STREAM 
(output_stream)),
+                                               WEBKIT_USER_CONTENT_INJECT_ALL_FRAMES, 
WEBKIT_USER_STYLE_LEVEL_USER,
+                                               NULL, NULL);
+    webkit_user_content_manager_add_style_sheet (ephy_embed_shell_get_user_content_manager 
(ephy_embed_shell_get_default ()),
+                                                 style_sheet);
+    webkit_user_style_sheet_unref (style_sheet);
+#else
     webkit_web_view_group_add_user_style_sheet (web_view_group,
                                                 g_memory_output_stream_get_data (G_MEMORY_OUTPUT_STREAM 
(output_stream)),
                                                 NULL, NULL, NULL, WEBKIT_INJECTED_CONTENT_FRAMES_ALL);
+#endif
   }
 }
 
@@ -94,7 +105,11 @@ webkit_pref_callback_user_stylesheet (GSettings *settings,
   value = g_settings_get_boolean (settings, key);
 
   if (!value)
+#if WEBKIT_CHECK_VERSION(2, 5, 0)
+    webkit_user_content_manager_remove_all_style_sheets (ephy_embed_shell_get_user_content_manager 
(ephy_embed_shell_get_default ()));
+#else
     webkit_web_view_group_remove_all_user_style_sheets (web_view_group);
+#endif
   else {
     GFile *file;
     char *filename;
diff --git a/embed/ephy-embed-shell.c b/embed/ephy-embed-shell.c
index a9de0a5..9cf764f 100644
--- a/embed/ephy-embed-shell.c
+++ b/embed/ephy-embed-shell.c
@@ -54,6 +54,9 @@ struct _EphyEmbedShellPrivate
   GtkPageSetup *page_setup;
   GtkPrintSettings *print_settings;
   EphyEmbedShellMode mode;
+#if WEBKIT_CHECK_VERSION(2, 5, 0)
+  WebKitUserContentManager *user_content;
+#endif
   EphyAboutHandler *about_handler;
   guint update_overview_timeout_id;
   guint hiding_overview_item;
@@ -104,6 +107,9 @@ ephy_embed_shell_dispose (GObject *object)
   g_clear_object (&priv->print_settings);
   g_clear_object (&priv->global_history_service);
   g_clear_object (&priv->about_handler);
+#if WEBKIT_CHECK_VERSION(2, 5, 0)
+  g_clear_object (&priv->user_content);
+#endif
 
   G_OBJECT_CLASS (ephy_embed_shell_parent_class)->dispose (object);
 }
@@ -998,3 +1004,16 @@ ephy_embed_shell_clear_cache (EphyEmbedShell *shell)
 {
   webkit_web_context_clear_cache (webkit_web_context_get_default ());
 }
+
+GObject *
+ephy_embed_shell_get_user_content_manager (EphyEmbedShell *shell)
+{
+#if WEBKIT_CHECK_VERSION(2, 5, 0)
+  if (!shell->priv->user_content)
+    shell->priv->user_content = webkit_user_content_manager_new ();
+
+  return G_OBJECT (shell->priv->user_content);
+#else
+  return NULL;
+#endif
+}
diff --git a/embed/ephy-embed-shell.h b/embed/ephy-embed-shell.h
index aa96de5..64653e1 100644
--- a/embed/ephy-embed-shell.h
+++ b/embed/ephy-embed-shell.h
@@ -93,6 +93,7 @@ void               ephy_embed_shell_set_thumbanil_path         (EphyEmbedShell
                                                                 const char       *url,
                                                                 time_t            mtime,
                                                                 const char       *path);
+GObject *ephy_embed_shell_get_user_content_manager (EphyEmbedShell *shell);
 
 G_END_DECLS
 
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index de2e36f..d3b7f05 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -1990,6 +1990,9 @@ GtkWidget *
 ephy_web_view_new (void)
 {
   return g_object_new (EPHY_TYPE_WEB_VIEW,
+#if WEBKIT_CHECK_VERSION(2, 5, 0)
+                       "user-content-manager", ephy_embed_shell_get_user_content_manager 
(ephy_embed_shell_get_default ()),
+#endif
                        "group", ephy_embed_prefs_get_web_view_group (),
                        NULL);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]