diff options
author | Xan Lopez <xan@src.gnome.org> | 2007-11-06 03:55:13 +0800 |
---|---|---|
committer | Xan Lopez <xan@src.gnome.org> | 2007-11-06 03:55:13 +0800 |
commit | 54deead24517e888803185d6cbdfb2108aa86802 (patch) | |
tree | 72d5722ca5ce8af0aa3a1e54e796244d5e6024a7 | |
parent | bb54d7c84793003d90685a7210fb9614adedb77f (diff) | |
download | gsoc2013-epiphany-54deead24517e888803185d6cbdfb2108aa86802.tar gsoc2013-epiphany-54deead24517e888803185d6cbdfb2108aa86802.tar.gz gsoc2013-epiphany-54deead24517e888803185d6cbdfb2108aa86802.tar.bz2 gsoc2013-epiphany-54deead24517e888803185d6cbdfb2108aa86802.tar.lz gsoc2013-epiphany-54deead24517e888803185d6cbdfb2108aa86802.tar.xz gsoc2013-epiphany-54deead24517e888803185d6cbdfb2108aa86802.tar.zst gsoc2013-epiphany-54deead24517e888803185d6cbdfb2108aa86802.zip |
Update the WebKit backend to use EphyBaseEmbed.
The way both backends track progress seem to be very different,
so I've exported the set_load_percent to get this going for now.
svn path=/trunk/; revision=7630
-rw-r--r-- | embed/ephy-base-embed.c | 2 | ||||
-rw-r--r-- | embed/ephy-base-embed.h | 2 | ||||
-rw-r--r-- | embed/webkit/webkit-embed.cpp | 459 |
3 files changed, 32 insertions, 431 deletions
diff --git a/embed/ephy-base-embed.c b/embed/ephy-base-embed.c index 5c6167aa8..add2b6604 100644 --- a/embed/ephy-base-embed.c +++ b/embed/ephy-base-embed.c @@ -894,7 +894,7 @@ build_load_percent (int requests_done, int requests_total) return percent; } -static void +void ephy_base_embed_set_load_percent (EphyBaseEmbed *embed, int percent) { EphyBaseEmbedPrivate *priv = embed->priv; diff --git a/embed/ephy-base-embed.h b/embed/ephy-base-embed.h index 520dc8520..a429a8c11 100644 --- a/embed/ephy-base-embed.h +++ b/embed/ephy-base-embed.h @@ -51,6 +51,8 @@ void ephy_base_embed_restore_zoom_level (EphyBaseEmbed *membed, void ephy_base_embed_update_from_net_state (EphyBaseEmbed *embed, const char *uri, EphyEmbedNetState state); +void ephy_base_embed_set_load_percent (EphyBaseEmbed *embed, int percent); + G_END_DECLS #endif /* __EPHY_BASE_EMBED_H__ */ diff --git a/embed/webkit/webkit-embed.cpp b/embed/webkit/webkit-embed.cpp index 2560f4705..b60c94d04 100644 --- a/embed/webkit/webkit-embed.cpp +++ b/embed/webkit/webkit-embed.cpp @@ -36,6 +36,7 @@ #include "webkit-embed.h" #include "ephy-embed.h" +#include "ephy-base-embed.h" static void webkit_embed_class_init (WebKitEmbedClass *klass); static void webkit_embed_init (WebKitEmbed *gs); @@ -43,10 +44,6 @@ static void webkit_embed_destroy (GtkObject *object); static void webkit_embed_finalize (GObject *object); static void ephy_embed_iface_init (EphyEmbedIface *iface); -static void impl_set_typed_address (EphyEmbed *embed, - const char *address, - EphyEmbedAddressExpire expire); - #define WEBKIT_EMBED_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), WEBKIT_TYPE_EMBED, WebKitEmbedPrivate)) typedef enum @@ -62,56 +59,6 @@ struct WebKitEmbedPrivate WebKitPage *page; WebKitEmbedLoadState load_state; char *loading_uri; - - EphyEmbedAddressExpire address_expire; - /* guint address_expire : 2; ? */ - EphyEmbedSecurityLevel security_level; - /* guint security_level : 3; ? */ - EphyEmbedDocumentType document_type; - EphyEmbedNavigationFlags nav_flags; - float zoom; - - /* Flags */ - guint is_blank : 1; - guint is_loading : 1; - guint is_setting_zoom : 1; - - gint8 load_percent; - char *address; - char *typed_address; - char *title; - char *loading_title; - int cur_requests; - int total_requests; - char *status_message; - char *link_message; - char *icon_address; - GdkPixbuf *icon; - - /* File watch */ - GnomeVFSMonitorHandle *monitor; - guint reload_scheduled_id; - guint reload_delay_ticks; -}; - -enum -{ - PROP_0, - PROP_ADDRESS, - PROP_DOCUMENT_TYPE, - PROP_HIDDEN_POPUP_COUNT, - PROP_ICON, - PROP_ICON_ADDRESS, - PROP_LINK_MESSAGE, - PROP_LOAD_PROGRESS, - PROP_LOAD_STATUS, - PROP_NAVIGATION, - PROP_POPUPS_ALLOWED, - PROP_SECURITY, - PROP_STATUS_MESSAGE, - PROP_TITLE, - PROP_TYPED_ADDRESS, - PROP_ZOOM }; static void @@ -134,7 +81,7 @@ ephy_command_manager_iface_init (EphyCommandManagerIface *iface) iface->can_do_command = impl_manager_can_do_command; } -G_DEFINE_TYPE_WITH_CODE (WebKitEmbed, webkit_embed, GTK_TYPE_SCROLLED_WINDOW, +G_DEFINE_TYPE_WITH_CODE (WebKitEmbed, webkit_embed, EPHY_TYPE_BASE_EMBED, G_IMPLEMENT_INTERFACE (EPHY_TYPE_EMBED, ephy_embed_iface_init) G_IMPLEMENT_INTERFACE (EPHY_TYPE_COMMAND_MANAGER, @@ -156,17 +103,10 @@ webkit_embed_title_changed_cb (WebKitFrame *frame, gchar *location, EphyEmbed *embed) { - WebKitEmbedPrivate *priv = WEBKIT_EMBED (embed)->priv; - g_free (priv->title); - priv->title = g_strdup (title); - g_object_notify (G_OBJECT (embed), "title"); - - /* FIXME: We emit ge-location signal here, but it should really belong - * to a "location_changed" signal by WebKit, as we can change title - * without changing location or change location without changing title - */ - - g_signal_emit_by_name (embed, "ge-location", location); + ephy_base_embed_set_title (EPHY_BASE_EMBED (embed), + g_strdup (title)); + ephy_base_embed_location_changed (EPHY_BASE_EMBED (embed), + location); } static void @@ -193,6 +133,10 @@ update_load_state (WebKitEmbed *embed, WebKitPage *page) EPHY_EMBED_STATE_IS_DOCUMENT | EPHY_EMBED_STATE_IS_NETWORK); + ephy_base_embed_update_from_net_state (EPHY_BASE_EMBED (embed), + embed->priv->loading_uri, + (EphyEmbedNetState)estate); + g_signal_emit_by_name (EPHY_EMBED (embed), "ge_net_state", embed->priv->loading_uri, estate); } @@ -209,19 +153,6 @@ webkit_embed_load_started_cb (WebKitPage *page, } static void -webkit_embed_set_load_percent (WebKitEmbed *embed, - int progress) -{ - WebKitEmbedPrivate *wpriv = embed->priv; - if (progress != wpriv->load_percent) - { - wpriv->load_percent = progress; - - g_object_notify (G_OBJECT (embed), "load-progress"); - } -} - -static void webkit_embed_load_progress_changed_cb (WebKitPage *page, int progress, EphyEmbed *embed) @@ -231,9 +162,7 @@ webkit_embed_load_progress_changed_cb (WebKitPage *page, if (wembed->priv->load_state == WEBKIT_EMBED_LOAD_STARTED) wembed->priv->load_state = WEBKIT_EMBED_LOAD_LOADING; - webkit_embed_set_load_percent (wembed, progress); - - update_load_state (wembed, page); + ephy_base_embed_set_load_percent (EPHY_BASE_EMBED (embed), progress); } static void @@ -248,106 +177,6 @@ webkit_embed_load_finished_cb (WebKitPage *page, } static void -webkit_embed_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - WebKitEmbed *embed = WEBKIT_EMBED (object); - WebKitEmbedPrivate *priv = embed->priv; - - switch (prop_id) - { - case PROP_ADDRESS: - g_value_set_string (value, priv->address); - break; - case PROP_DOCUMENT_TYPE: - g_value_set_enum (value, priv->document_type); - break; - case PROP_HIDDEN_POPUP_COUNT: - g_value_set_int (value, 0); - break; - case PROP_ICON: - g_value_set_object (value, priv->icon); - break; - case PROP_ICON_ADDRESS: - g_value_set_string (value, priv->icon_address); - break; - case PROP_LINK_MESSAGE: - g_value_set_string (value, priv->link_message); - break; - case PROP_LOAD_PROGRESS: - g_value_set_int (value, priv->load_percent); - break; - case PROP_LOAD_STATUS: - g_value_set_boolean (value, priv->is_loading); - break; - case PROP_NAVIGATION: - g_value_set_flags (value, priv->nav_flags); - break; - case PROP_POPUPS_ALLOWED: - g_value_set_boolean (value, FALSE); - break; - case PROP_SECURITY: - g_value_set_enum (value, priv->security_level); - break; - case PROP_STATUS_MESSAGE: - g_value_set_string (value, priv->status_message); - break; - case PROP_TITLE: - g_value_set_string (value, priv->title); - break; - case PROP_TYPED_ADDRESS: - g_value_set_string (value, priv->typed_address); - break; - case PROP_ZOOM: - g_value_set_float (value, priv->zoom); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -webkit_embed_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - switch (prop_id) - { - case PROP_ICON_ADDRESS: -#if 0 - webkit_embed_set_icon_address (WEBKIT_EMBED (object), g_value_get_string (value)); -#endif - break; - case PROP_TYPED_ADDRESS: - impl_set_typed_address (EPHY_EMBED (object), g_value_get_string (value), - EPHY_EMBED_ADDRESS_EXPIRE_NOW); - break; - case PROP_POPUPS_ALLOWED: - break; - case PROP_ADDRESS: - case PROP_DOCUMENT_TYPE: - case PROP_HIDDEN_POPUP_COUNT: - case PROP_ICON: - case PROP_LOAD_PROGRESS: - case PROP_LOAD_STATUS: - case PROP_LINK_MESSAGE: - case PROP_NAVIGATION: - case PROP_SECURITY: - case PROP_STATUS_MESSAGE: - case PROP_ZOOM: - /* read only */ - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void webkit_embed_class_init (WebKitEmbedClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); @@ -356,29 +185,10 @@ webkit_embed_class_init (WebKitEmbedClass *klass) object_class->finalize = webkit_embed_finalize; - object_class->get_property = webkit_embed_get_property; - object_class->set_property = webkit_embed_set_property; - gtk_object_class->destroy = webkit_embed_destroy; widget_class->grab_focus = webkit_embed_grab_focus; - g_object_class_override_property (object_class, PROP_LOAD_PROGRESS, "load-progress"); - g_object_class_override_property (object_class, PROP_LOAD_STATUS, "load-status"); - g_object_class_override_property (object_class, PROP_DOCUMENT_TYPE, "document-type"); - g_object_class_override_property (object_class, PROP_SECURITY, "security-level"); - g_object_class_override_property (object_class, PROP_ZOOM, "zoom"); - g_object_class_override_property (object_class, PROP_NAVIGATION, "navigation"); - g_object_class_override_property (object_class, PROP_ADDRESS, "address"); - g_object_class_override_property (object_class, PROP_TYPED_ADDRESS, "typed-address"); - g_object_class_override_property (object_class, PROP_TITLE, "title"); - g_object_class_override_property (object_class, PROP_STATUS_MESSAGE, "status-message"); - g_object_class_override_property (object_class, PROP_LINK_MESSAGE, "link-message"); - g_object_class_override_property (object_class, PROP_ICON, "icon"); - g_object_class_override_property (object_class, PROP_ICON_ADDRESS, "icon-address"); - g_object_class_override_property (object_class, PROP_POPUPS_ALLOWED, "popups-allowed"); - g_object_class_override_property (object_class, PROP_HIDDEN_POPUP_COUNT, "hidden-popup-count"); - g_type_class_add_private (object_class, sizeof(WebKitEmbedPrivate)); } @@ -386,21 +196,24 @@ static void webkit_embed_init (WebKitEmbed *embed) { WebKitPage *page; + GtkWidget *sw; embed->priv = WEBKIT_EMBED_GET_PRIVATE (embed); embed->priv->loading_uri = NULL; - gtk_scrolled_window_set_vadjustment (GTK_SCROLLED_WINDOW (embed), NULL); - gtk_scrolled_window_set_hadjustment (GTK_SCROLLED_WINDOW (embed), NULL); - - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (embed), + sw = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + webkit_init (); page = WEBKIT_PAGE (webkit_page_new ()); embed->priv->page = page; - gtk_container_add (GTK_CONTAINER (embed), GTK_WIDGET (page)); + gtk_container_add (GTK_CONTAINER (sw), GTK_WIDGET (page)); + gtk_widget_show (sw); gtk_widget_show (GTK_WIDGET (page)); + gtk_container_add (GTK_CONTAINER (embed), sw); + g_signal_connect (G_OBJECT (page), "load-started", G_CALLBACK (webkit_embed_load_started_cb), embed); g_signal_connect (G_OBJECT (page), "load_finished", @@ -409,13 +222,6 @@ webkit_embed_init (WebKitEmbed *embed) G_CALLBACK (webkit_embed_title_changed_cb), embed); g_signal_connect (G_OBJECT (page), "load-progress-changed", G_CALLBACK (webkit_embed_load_progress_changed_cb), embed); - - embed->priv->document_type = EPHY_EMBED_DOCUMENT_HTML; - embed->priv->security_level = EPHY_EMBED_STATE_IS_UNKNOWN; - embed->priv->zoom = 1.0; - embed->priv->is_setting_zoom = FALSE; - embed->priv->load_percent = 0; - embed->priv->is_loading = FALSE; } static void @@ -430,13 +236,6 @@ webkit_embed_finalize (GObject *object) WebKitEmbed *wembed = WEBKIT_EMBED (object); g_free (wembed->priv->loading_uri); - g_free (wembed->priv->icon_address); - g_free (wembed->priv->address); - g_free (wembed->priv->typed_address); - g_free (wembed->priv->title); - g_free (wembed->priv->loading_title); - g_free (wembed->priv->status_message); - g_free (wembed->priv->link_message); G_OBJECT_CLASS (webkit_embed_parent_class)->finalize (object); } @@ -527,12 +326,6 @@ impl_go_up (EphyEmbed *embed) { } -static const char * -impl_get_title (EphyEmbed *embed) -{ - return WEBKIT_EMBED (embed)->priv->title; -} - static char * impl_get_js_status (EphyEmbed *embed) { @@ -554,18 +347,16 @@ impl_reload (EphyEmbed *embed, webkit_page_reload (WEBKIT_EMBED (embed)->priv->page); } -static void -impl_set_zoom (EphyEmbed *embed, - float zoom) -{ -} - static float impl_get_zoom (EphyEmbed *embed) { - WebKitEmbedPrivate *wpriv = WEBKIT_EMBED (embed)->priv; + return 1.0; +} - return wpriv->zoom; +static void +impl_set_zoom (EphyEmbed *embed, + float zoom) +{ } static void @@ -685,200 +476,20 @@ impl_has_modified_forms (EphyEmbed *embed) return FALSE; } -static int -impl_get_load_percent (EphyEmbed *embed) -{ - WebKitEmbedPrivate *wpriv = WEBKIT_EMBED(embed)->priv; - - return wpriv->load_percent; -} - -static void -impl_set_load_percent (EphyEmbed *embed, int percent) -{ - webkit_embed_set_load_percent (WEBKIT_EMBED (embed), percent); -} - -static gboolean -impl_get_load_status (EphyEmbed *embed) -{ - WebKitEmbedPrivate *wpriv = WEBKIT_EMBED (embed)->priv; - - return wpriv->is_loading; -} - -static void -impl_set_load_status (EphyEmbed *embed, gboolean status) -{ - WebKitEmbedPrivate *wpriv = WEBKIT_EMBED (embed)->priv; - guint is_loading; - - is_loading = status != FALSE; - - if (is_loading != wpriv->is_loading) - { - wpriv->is_loading = is_loading; - - g_object_notify (G_OBJECT (embed), "load-status"); - } -} - -static EphyEmbedDocumentType -impl_get_document_type (EphyEmbed *embed) -{ - WebKitEmbedPrivate *wpriv = WEBKIT_EMBED (embed)->priv; - - return wpriv->document_type; -} - -static EphyEmbedNavigationFlags -impl_get_navigation_flags (EphyEmbed *embed) -{ - WebKitEmbedPrivate *wpriv = WEBKIT_EMBED (embed)->priv; - return wpriv->nav_flags; -} - -static void -impl_update_navigation_flags (EphyEmbed *embed) -{ - WebKitEmbedPrivate *priv = WEBKIT_EMBED (embed)->priv; - guint flags = 0; - - if (ephy_embed_can_go_up (embed)) - { - flags |= EPHY_EMBED_NAV_UP; - } - - if (ephy_embed_can_go_back (embed)) - { - flags |= EPHY_EMBED_NAV_BACK; - } - - if (ephy_embed_can_go_forward (embed)) - { - flags |= EPHY_EMBED_NAV_FORWARD; - } - - if (priv->nav_flags != (EphyEmbedNavigationFlags)flags) - { - priv->nav_flags = (EphyEmbedNavigationFlags)flags; - - g_object_notify (G_OBJECT (embed), "navigation"); - } -} - -static const char* -impl_get_typed_address (EphyEmbed *embed) -{ - return WEBKIT_EMBED (embed)->priv->typed_address; -} - -static void -impl_set_typed_address (EphyEmbed *embed, - const char *address, - EphyEmbedAddressExpire expire) -{ - WebKitEmbedPrivate *priv = WEBKIT_EMBED (embed)->priv; - - g_free (priv->typed_address); - priv->typed_address = g_strdup (address); - - if (expire == EPHY_EMBED_ADDRESS_EXPIRE_CURRENT && - !priv->is_loading) - { - priv->address_expire = EPHY_EMBED_ADDRESS_EXPIRE_NOW; - } - else - { - priv->address_expire = expire; - } - - g_object_notify (G_OBJECT (embed), "typed-address"); -} - -static const char* -impl_get_address (EphyEmbed *embed) -{ - WebKitEmbedPrivate *priv = WEBKIT_EMBED (embed)->priv; - - return priv->address ? priv->address : "about:blank"; -} - -static const char* -impl_get_status_message (EphyEmbed *embed) -{ - WebKitEmbedPrivate *priv = WEBKIT_EMBED (embed)->priv; - - if (priv->link_message && priv->link_message[0] != '\0') - { - return priv->link_message; - } - else if (priv->status_message) - { - return priv->status_message; - } - else - { - return NULL; - } -} - -static const char* -impl_get_link_message (EphyEmbed *embed) -{ - WebKitEmbedPrivate *priv = WEBKIT_EMBED (embed)->priv; - - return priv->link_message; -} - -static gboolean -impl_get_is_blank (EphyEmbed *embed) -{ - WebKitEmbedPrivate *priv = WEBKIT_EMBED (embed)->priv; - - return priv->is_blank; -} - -static const char* -impl_get_loading_title (EphyEmbed *embed) -{ - WebKitEmbedPrivate *priv = WEBKIT_EMBED (embed)->priv; - - return priv->loading_title; -} - -static const char* -impl_get_icon_address (EphyEmbed *embed) -{ - WebKitEmbedPrivate *priv = WEBKIT_EMBED (embed)->priv; - - return priv->icon_address; -} - -static GdkPixbuf* -impl_get_icon (EphyEmbed *embed) -{ - WebKitEmbedPrivate *priv = WEBKIT_EMBED (embed)->priv; - - return priv->icon; -} - static void ephy_embed_iface_init (EphyEmbedIface *iface) { - iface->load_url = impl_load_url; - iface->load = impl_load; + iface->load_url = impl_load_url; + iface->load = impl_load; iface->stop_load = impl_stop_load; iface->can_go_back = impl_can_go_back; - iface->can_go_forward = impl_can_go_forward; + iface->can_go_forward =impl_can_go_forward; iface->can_go_up = impl_can_go_up; iface->get_go_up_list = impl_get_go_up_list; iface->go_back = impl_go_back; iface->go_forward = impl_go_forward; iface->go_up = impl_go_up; - iface->get_title = impl_get_title; iface->get_location = impl_get_location; - iface->get_link_message = impl_get_link_message; iface->get_js_status = impl_get_js_status; iface->reload = impl_reload; iface->set_zoom = impl_set_zoom; @@ -891,7 +502,6 @@ ephy_embed_iface_init (EphyEmbedIface *iface) iface->shistory_get_pos = impl_shistory_get_pos; iface->shistory_go_nth = impl_shistory_go_nth; iface->shistory_copy = impl_shistory_copy; - iface->get_security_level = impl_get_security_level; iface->show_page_certificate = impl_show_page_certificate; iface->close = impl_close; iface->set_encoding = impl_set_encoding; @@ -902,16 +512,5 @@ ephy_embed_iface_init (EphyEmbedIface *iface) iface->print_preview_n_pages = impl_print_preview_n_pages; iface->print_preview_navigate = impl_print_preview_navigate; iface->has_modified_forms = impl_has_modified_forms; - iface->get_load_percent = impl_get_load_percent; - iface->get_load_status = impl_get_load_status; - iface->get_document_type = impl_get_document_type; - iface->get_navigation_flags = impl_get_navigation_flags; - iface->get_typed_address = impl_get_typed_address; - iface->set_typed_address = impl_set_typed_address; - iface->get_address = impl_get_address; - iface->get_status_message = impl_get_status_message; - iface->get_is_blank = impl_get_is_blank; - iface->get_loading_title = impl_get_loading_title; - iface->get_icon = impl_get_icon; - iface->get_icon_address = impl_get_icon_address; + iface->get_security_level = impl_get_security_level; } |