From 76dd77e2f40b6e2de50716117c3abd2c49e528a4 Mon Sep 17 00:00:00 2001 From: Xan Lopez Date: Mon, 30 Jun 2008 21:27:12 +0000 Subject: embed: remove ge-zoom-changed and zoom property. Use zoom-level property in WebKit directly. svn path=/trunk/; revision=8326 --- doc/reference/tmpl/ephy-embed.sgml | 9 ------ embed/ephy-base-embed.c | 58 ++------------------------------------ embed/ephy-embed.c | 21 -------------- embed/ephy-embed.h | 2 -- embed/webkit/webkit-embed.c | 45 ++++++++++++++++++++++++++++- src/ephy-window.c | 36 +++++++++++++++-------- 6 files changed, 72 insertions(+), 99 deletions(-) diff --git a/doc/reference/tmpl/ephy-embed.sgml b/doc/reference/tmpl/ephy-embed.sgml index fe2a47c55..5fb26aed8 100644 --- a/doc/reference/tmpl/ephy-embed.sgml +++ b/doc/reference/tmpl/ephy-embed.sgml @@ -174,14 +174,6 @@ be done by casting). @arg2: @arg3: - - - - - -@ephyembed: the object which received the signal. -@arg1: - @@ -327,7 +319,6 @@ be done by casting). @get_is_blank: @get_loading_title: @get_visibility: -@go_to_history_item: diff --git a/embed/ephy-base-embed.c b/embed/ephy-base-embed.c index 68bae0683..689cf80de 100644 --- a/embed/ephy-base-embed.c +++ b/embed/ephy-base-embed.c @@ -55,7 +55,6 @@ struct _EphyBaseEmbedPrivate { /* guint security_level : 3; ? */ EphyEmbedDocumentType document_type; EphyEmbedNavigationFlags nav_flags; - float zoom; /* Flags */ guint is_blank : 1; @@ -108,7 +107,6 @@ enum { PROP_TITLE, PROP_VISIBLE, PROP_TYPED_ADDRESS, - PROP_ZOOM }; #define EPHY_BASE_EMBED_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_BASE_EMBED, EphyBaseEmbedPrivate)) @@ -480,7 +478,6 @@ ephy_base_embed_set_property (GObject *object, case PROP_SECURITY: case PROP_STATUS_MESSAGE: case PROP_VISIBLE: - case PROP_ZOOM: /* read only */ break; default: @@ -584,9 +581,6 @@ ephy_base_embed_get_property (GObject *object, case PROP_VISIBLE: g_value_set_boolean (value, priv->visibility); break; - case PROP_ZOOM: - g_value_set_float (value, priv->zoom); - break; default: break; } @@ -623,15 +617,7 @@ ephy_base_embed_class_init (EphyBaseEmbedClass *klass) EPHY_TYPE_EMBED_DOCUMENT_TYPE, EPHY_EMBED_DOCUMENT_HTML, G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); - g_object_class_install_property (gobject_class, - PROP_ZOOM, - g_param_spec_float ("zoom", - "Zoom", - "The embed's zoom", - ZOOM_MINIMAL, - ZOOM_MAXIMAL, - 1.0, - G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); + g_object_class_install_property (gobject_class, PROP_LOAD_PROGRESS, g_param_spec_int ("load-progress", @@ -765,41 +751,6 @@ ge_document_type_cb (EphyEmbed *embed, } } -static void -ge_zoom_change_cb (EphyEmbed *embed, - float zoom, - EphyBaseEmbed *bembed) -{ - char *address; - - if (bembed->priv->zoom != zoom) { - if (bembed->priv->is_setting_zoom) { - return; - } - - address = ephy_embed_get_location (embed, TRUE); - if (ephy_embed_utils_address_has_web_scheme (address)) { - EphyHistory *history; - EphyNode *host; - history = EPHY_HISTORY - (ephy_embed_shell_get_global_history (embed_shell)); - host = ephy_history_get_host (history, address); - - if (host != NULL) { - ephy_node_set_property_float (host, - EPHY_NODE_HOST_PROP_ZOOM, - zoom); - } - } - - g_free (address); - - bembed->priv->zoom = zoom; - - g_object_notify (G_OBJECT (embed), "zoom"); - } -} - static void ge_favicon_cb (EphyEmbed *membed, const char *address, @@ -894,10 +845,6 @@ ephy_base_embed_init (EphyBaseEmbed *self) G_CALLBACK (ge_document_type_cb), self, (GConnectFlags)0); - g_signal_connect_object (self, "ge_zoom_change", - G_CALLBACK (ge_zoom_change_cb), - self, (GConnectFlags)0); - g_signal_connect_object (self, "ge_favicon", G_CALLBACK (ge_favicon_cb), self, (GConnectFlags)0); @@ -918,7 +865,6 @@ ephy_base_embed_init (EphyBaseEmbed *self) priv->document_type = EPHY_EMBED_DOCUMENT_HTML; priv->security_level = EPHY_EMBED_STATE_IS_UNKNOWN; - priv->zoom = 1.0; priv->address_expire = EPHY_EMBED_ADDRESS_EXPIRE_NOW; priv->is_blank = TRUE; priv->title = g_strdup (EMPTY_PAGE); @@ -1546,6 +1492,7 @@ ephy_base_embed_set_security_level (EphyBaseEmbed *embed, } } +#if 0 void ephy_base_embed_restore_zoom_level (EphyBaseEmbed *membed, const char *address) @@ -1577,6 +1524,7 @@ ephy_base_embed_restore_zoom_level (EphyBaseEmbed *membed, } } } +#endif void ephy_base_embed_set_visibility (EphyBaseEmbed *embed, diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c index 5fff25366..2260b112d 100644 --- a/embed/ephy-embed.c +++ b/embed/ephy-embed.c @@ -207,27 +207,6 @@ ephy_embed_base_init (gpointer g_class) G_TYPE_BOOLEAN, 1, G_TYPE_OBJECT); -/** - * EphyEmbed::ge-zoom-change: - * @embed: - * @zoom: @embed's new zoom level - * - * The ::ge_zoom_change signal is emitted when @embed's zoom changes. This can - * be manual (the user modified the zoom level) or automatic (@embed's zoom is - * automatically changed when browsing to a new site for which the user - * previously specified a zoom level). - * - * A @zoom value of 1.0 indicates 100% (normal zoom). - **/ - g_signal_new ("ge_zoom_change", - EPHY_TYPE_EMBED, - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EphyEmbedIface, zoom_change), - NULL, NULL, - g_cclosure_marshal_VOID__FLOAT, - G_TYPE_NONE, - 1, - G_TYPE_FLOAT); /** * EphyEmbed::ge-modal-alert: * @embed: diff --git a/embed/ephy-embed.h b/embed/ephy-embed.h index 6df34e8d1..8a03b501b 100644 --- a/embed/ephy-embed.h +++ b/embed/ephy-embed.h @@ -145,8 +145,6 @@ struct _EphyEmbedIface const char *address, const char *target, const char *features); - void (* zoom_change) (EphyEmbed *embed, - float new_zoom); void (* content_blocked) (EphyEmbed *embed, const char *uri); gboolean (* modal_alert) (EphyEmbed *embed); diff --git a/embed/webkit/webkit-embed.c b/embed/webkit/webkit-embed.c index c59d0b493..4d483844a 100644 --- a/embed/webkit/webkit-embed.c +++ b/embed/webkit/webkit-embed.c @@ -28,6 +28,7 @@ #include "ephy-embed-single.h" #include "ephy-string.h" #include "ephy-embed-event.h" +#include "ephy-embed-utils.h" #include #include @@ -213,6 +214,46 @@ webkit_embed_hovering_over_link_cb (WebKitWebView *web_view, ephy_base_embed_set_link_message (EPHY_BASE_EMBED (embed), location); } +static void +webkit_web_view_zoom_change_cb (WebKitWebView *web_view, + GParamSpec *pspec, + EphyEmbed *embed) +{ + char *address; + float zoom; + + g_object_get (G_OBJECT (web_view), + "zoom-level", &zoom, + NULL); + + /* TODO: need to move the is_setting_zoom flag + * somewhere else. It's set by restoring_zoom + * in base_embed, which is unused right now. Should + * be called each time we load a page in a web_view + + if (bembed->priv->is_setting_zoom) { + return; + } + */ + + address = ephy_embed_get_location (embed, TRUE); + if (ephy_embed_utils_address_has_web_scheme (address)) { + EphyHistory *history; + EphyNode *host; + history = EPHY_HISTORY + (ephy_embed_shell_get_global_history (embed_shell)); + host = ephy_history_get_host (history, address); + + if (host != NULL) { + ephy_node_set_property_float (host, + EPHY_NODE_HOST_PROP_ZOOM, + zoom); + } + } + + g_free (address); +} + static void webkit_embed_finalize (GObject *object) { @@ -263,6 +304,9 @@ webkit_embed_init (WebKitEmbed *embed) "signal::hovering-over-link", G_CALLBACK (webkit_embed_hovering_over_link_cb), embed, NULL); + g_signal_connect (G_OBJECT (web_view), + "notify::zoom-level", G_CALLBACK (webkit_web_view_zoom_change_cb), embed); + webkit_embed_prefs_add_embed (embed); embed->priv->history = EPHY_HISTORY (ephy_embed_shell_get_global_history (ephy_embed_shell_get_default ())); @@ -354,7 +398,6 @@ impl_set_zoom (EphyEmbed *embed, g_return_if_fail (zoom > 0.0); g_object_set (WEBKIT_EMBED (embed)->priv->web_view, "zoom-level", zoom, NULL); - g_signal_emit_by_name (embed, "ge_zoom_change", zoom); } static void diff --git a/src/ephy-window.c b/src/ephy-window.c index 51b9f6895..52c19603c 100644 --- a/src/ephy-window.c +++ b/src/ephy-window.c @@ -102,7 +102,7 @@ static void sync_tab_load_status (EphyEmbed *embed, static void sync_tab_security (EphyEmbed *embed, GParamSpec *pspec, EphyWindow *window); -static void sync_tab_zoom (EphyEmbed *embed, +static void sync_tab_zoom (WebKitWebView *web_view, GParamSpec *pspec, EphyWindow *window); @@ -1544,7 +1544,7 @@ sync_tab_document_type (EphyEmbed *embed, if (priv->closing) return; /* update zoom actions */ - sync_tab_zoom (embed, NULL, window); + sync_tab_zoom (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed), NULL, window); type = ephy_embed_get_document_type (embed); can_find = (type != EPHY_EMBED_DOCUMENT_IMAGE); @@ -1854,17 +1854,21 @@ sync_tab_title (EphyEmbed *embed, } static void -sync_tab_zoom (EphyEmbed *embed, GParamSpec *pspec, EphyWindow *window) +sync_tab_zoom (WebKitWebView *web_view, GParamSpec *pspec, EphyWindow *window) { GtkActionGroup *action_group; GtkAction *action; EphyEmbedDocumentType type; gboolean can_zoom_in = TRUE, can_zoom_out = TRUE, can_zoom_normal = FALSE, can_zoom; float zoom; + EphyEmbed *embed = window->priv->active_embed; if (window->priv->closing) return; - zoom = ephy_embed_get_zoom (embed); + g_object_get (G_OBJECT (web_view), + "zoom-level", &zoom, + NULL); + type = ephy_embed_get_document_type (embed); can_zoom = (type != EPHY_EMBED_DOCUMENT_IMAGE); @@ -2401,7 +2405,14 @@ ephy_window_set_active_tab (EphyWindow *window, EphyEmbed *new_embed) if (old_embed != NULL) { + WebKitWebView *web_view; + embed = old_embed; + web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed); + + g_signal_handlers_disconnect_by_func (web_view, + G_CALLBACK (sync_tab_zoom), + window); g_signal_handlers_disconnect_by_func (embed, G_CALLBACK (sync_tab_popup_windows), @@ -2415,9 +2426,6 @@ ephy_window_set_active_tab (EphyWindow *window, EphyEmbed *new_embed) g_signal_handlers_disconnect_by_func (embed, G_CALLBACK (sync_tab_document_type), window); - g_signal_handlers_disconnect_by_func (embed, - G_CALLBACK (sync_tab_zoom), - window); g_signal_handlers_disconnect_by_func (embed, G_CALLBACK (sync_tab_load_progress), window); @@ -2454,11 +2462,12 @@ ephy_window_set_active_tab (EphyWindow *window, EphyEmbed *new_embed) if (new_embed != NULL) { + WebKitWebView *web_view; + embed = new_embed; sync_tab_security (embed, NULL, window); sync_tab_document_type (embed, NULL, window); - sync_tab_zoom (embed, NULL, window); sync_tab_load_progress (embed, NULL, window); sync_tab_load_status (embed, NULL, window); sync_tab_navigation (embed, NULL, window); @@ -2469,6 +2478,14 @@ ephy_window_set_active_tab (EphyWindow *window, EphyEmbed *new_embed) sync_tab_popup_windows (embed, NULL, window); sync_tab_popups_allowed (embed, NULL, window); + web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed); + + sync_tab_zoom (web_view, NULL, window); + + g_signal_connect_object (web_view, "notify::zoom-level", + G_CALLBACK (sync_tab_zoom), + window, 0); + g_signal_connect_object (embed, "notify::hidden-popup-count", G_CALLBACK (sync_tab_popup_windows), window, 0); @@ -2493,9 +2510,6 @@ ephy_window_set_active_tab (EphyWindow *window, EphyEmbed *new_embed) g_signal_connect_object (embed, "notify::document-type", G_CALLBACK (sync_tab_document_type), window, 0); - g_signal_connect_object (embed, "notify::zoom", - G_CALLBACK (sync_tab_zoom), - window, 0); g_signal_connect_object (embed, "notify::load-status", G_CALLBACK (sync_tab_load_status), window, 0); -- cgit v1.2.3