aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
authorXan Lopez <xan@igalia.com>2012-03-14 19:44:18 +0800
committerXan Lopez <xan@igalia.com>2012-03-14 19:45:07 +0800
commit6f220733c22c7c2f04ba8894a470ba7b7c64d8bd (patch)
tree4be84968816abc67f60523add72153eb3e4f0d00 /embed
parent9d0c171675a92fb30e8bc45f73a513e5dc86912e (diff)
downloadgsoc2013-epiphany-6f220733c22c7c2f04ba8894a470ba7b7c64d8bd.tar
gsoc2013-epiphany-6f220733c22c7c2f04ba8894a470ba7b7c64d8bd.tar.gz
gsoc2013-epiphany-6f220733c22c7c2f04ba8894a470ba7b7c64d8bd.tar.bz2
gsoc2013-epiphany-6f220733c22c7c2f04ba8894a470ba7b7c64d8bd.tar.lz
gsoc2013-epiphany-6f220733c22c7c2f04ba8894a470ba7b7c64d8bd.tar.xz
gsoc2013-epiphany-6f220733c22c7c2f04ba8894a470ba7b7c64d8bd.tar.zst
gsoc2013-epiphany-6f220733c22c7c2f04ba8894a470ba7b7c64d8bd.zip
ephy-web-view: move zoom handling to EphyWebView
Again, this only interacts with the view, so it does not need to be in EphyEmbed.
Diffstat (limited to 'embed')
-rw-r--r--embed/ephy-embed.c81
-rw-r--r--embed/ephy-web-view.c82
2 files changed, 82 insertions, 81 deletions
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c
index e78b14fbd..44a84666c 100644
--- a/embed/ephy-embed.c
+++ b/embed/ephy-embed.c
@@ -73,12 +73,10 @@ struct _EphyEmbedPrivate
GtkPaned *paned;
WebKitWebView *web_view;
EphyHistoryService *history_service;
- GCancellable *history_service_cancellable;
GtkWidget *inspector_window;
GtkWidget *inspector_web_view;
GtkWidget *inspector_scrolled_window;
gboolean inspector_attached;
- guint is_setting_zoom : 1;
GSList *destroy_on_transition_list;
GtkWidget *floating_bar;
GtkWidget *progress;
@@ -231,50 +229,6 @@ ephy_embed_statusbar_pop (EphyEmbed *embed, guint context_id)
}
static void
-get_host_for_url_cb (gpointer service,
- gboolean success,
- gpointer result_data,
- gpointer user_data)
-{
- EphyHistoryHost *host;
- EphyEmbed *embed;
- WebKitWebView *web_view;
- double current_zoom;
-
- if (success == FALSE)
- return;
-
- embed = EPHY_EMBED (user_data);
- host = (EphyHistoryHost *)result_data;
-
- web_view = embed->priv->web_view;
-
- g_object_get (web_view,
- "zoom-level", &current_zoom,
- NULL);
-
- if (host->zoom_level != current_zoom) {
- embed->priv->is_setting_zoom = TRUE;
- g_object_set (web_view, "zoom-level", host->zoom_level, NULL);
- embed->priv->is_setting_zoom = FALSE;
- }
-
- ephy_history_host_free (host);
-}
-
-static void
-restore_zoom_level (EphyEmbed *embed,
- const char *address)
-{
- /* restore zoom level */
- if (ephy_embed_utils_address_has_web_scheme (address)) {
- ephy_history_service_get_host_for_url (embed->priv->history_service,
- address, embed->priv->history_service_cancellable,
- (EphyHistoryJobCallback)get_host_for_url_cb, embed);
- }
-}
-
-static void
resource_request_starting_cb (WebKitWebView *web_view,
WebKitWebFrame *web_frame,
WebKitWebResource *web_resource,
@@ -333,8 +287,6 @@ load_status_changed_cb (WebKitWebView *web_view,
ephy_embed_destroy_top_widgets (embed);
- restore_zoom_level (embed, uri);
-
if (ephy_web_view_is_loading_homepage (view))
return;
@@ -355,32 +307,6 @@ load_status_changed_cb (WebKitWebView *web_view,
}
static void
-zoom_changed_cb (WebKitWebView *web_view,
- GParamSpec *pspec,
- EphyEmbed *embed)
-{
- char *address;
- float zoom;
-
- g_object_get (web_view,
- "zoom-level", &zoom,
- NULL);
-
- if (EPHY_EMBED (embed)->priv->is_setting_zoom) {
- return;
- }
-
- address = ephy_web_view_get_location (EPHY_WEB_VIEW (web_view), TRUE);
- if (ephy_embed_utils_address_has_web_scheme (address)) {
- ephy_history_service_set_url_zoom_level (embed->priv->history_service,
- address, zoom,
- NULL, NULL, NULL);
- }
-
- g_free (address);
-}
-
-static void
ephy_embed_grab_focus (GtkWidget *widget)
{
GtkWidget *child;
@@ -436,11 +362,6 @@ ephy_embed_dispose (GObject *object)
priv->progress_update_handler_id = 0;
}
- if (priv->history_service_cancellable) {
- g_cancellable_cancel (priv->history_service_cancellable);
- g_clear_object (&priv->history_service_cancellable);
- }
-
G_OBJECT_CLASS (ephy_embed_parent_class)->dispose (object);
}
@@ -779,7 +700,6 @@ ephy_embed_constructed (GObject *object)
"signal::notify::load-status", G_CALLBACK (load_status_changed_cb), embed,
"signal::resource-request-starting", G_CALLBACK (resource_request_starting_cb), embed,
"signal::download-requested", G_CALLBACK (download_requested_cb), embed,
- "signal::notify::zoom-level", G_CALLBACK (zoom_changed_cb), embed,
NULL);
priv->status_handler_id = g_signal_connect (web_view, "notify::status-message",
@@ -830,7 +750,6 @@ ephy_embed_constructed (GObject *object)
ephy_embed_prefs_add_embed (embed);
priv->history_service = EPHY_HISTORY_SERVICE (ephy_embed_shell_get_global_history_service (ephy_embed_shell_get_default ()));
- priv->history_service_cancellable = g_cancellable_new ();
}
static void
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 5759eabbc..55aa51d44 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -81,6 +81,7 @@ struct _EphyWebViewPrivate {
guint is_blank : 1;
guint visibility : 1;
guint loading_homepage : 1;
+ guint is_setting_zoom : 1;
char *address;
char *typed_address;
@@ -106,6 +107,8 @@ struct _EphyWebViewPrivate {
GtkWidget *password_info_bar;
EphyHistoryService *history_service;
+ GCancellable *history_service_cancellable;
+
EphyHistoryPageVisitType visit_type;
};
@@ -548,8 +551,15 @@ ephy_web_view_button_press_event (GtkWidget *widget, GdkEventButton *event)
static void
ephy_web_view_dispose (GObject *object)
{
+ EphyWebViewPrivate *priv = EPHY_WEB_VIEW (object)->priv;
+
ephy_web_view_file_monitor_cancel (EPHY_WEB_VIEW (object));
+ if (priv->history_service_cancellable) {
+ g_cancellable_cancel (priv->history_service_cancellable);
+ g_clear_object (&priv->history_service_cancellable);
+ }
+
G_OBJECT_CLASS (ephy_web_view_parent_class)->dispose (object);
}
@@ -1837,6 +1847,45 @@ delete_web_app_cb (WebKitDOMHTMLElement *button,
}
static void
+get_host_for_url_cb (gpointer service,
+ gboolean success,
+ gpointer result_data,
+ gpointer user_data)
+{
+ EphyHistoryHost *host;
+ EphyWebView *view;
+ double current_zoom;
+
+ if (success == FALSE)
+ return;
+
+ view = EPHY_WEB_VIEW (user_data);
+ host = (EphyHistoryHost *)result_data;
+
+ g_object_get (view,
+ "zoom-level", &current_zoom,
+ NULL);
+
+ if (host->zoom_level != current_zoom) {
+ view->priv->is_setting_zoom = TRUE;
+ g_object_set (view, "zoom-level", host->zoom_level, NULL);
+ view->priv->is_setting_zoom = FALSE;
+ }
+
+ ephy_history_host_free (host);
+}
+
+static void
+restore_zoom_level (EphyWebView *view,
+ const char *address)
+{
+ if (ephy_embed_utils_address_has_web_scheme (address))
+ ephy_history_service_get_host_for_url (view->priv->history_service,
+ address, view->priv->history_service_cancellable,
+ (EphyHistoryJobCallback)get_host_for_url_cb, view);
+}
+
+static void
load_status_cb (WebKitWebView *web_view,
GParamSpec *pspec,
gpointer user_data)
@@ -1913,6 +1962,8 @@ load_status_cb (WebKitWebView *web_view,
security_level = EPHY_WEB_VIEW_STATE_IS_UNKNOWN;
ephy_web_view_set_security_level (EPHY_WEB_VIEW (web_view), security_level);
+
+ restore_zoom_level (view, uri);
}
break;
case WEBKIT_LOAD_FINISHED: {
@@ -2216,6 +2267,32 @@ close_web_view_cb (WebKitWebView *web_view,
}
static void
+zoom_changed_cb (WebKitWebView *web_view,
+ GParamSpec *pspec,
+ gpointer user_data)
+{
+ char *address;
+ float zoom;
+ EphyWebViewPrivate *priv = EPHY_WEB_VIEW (web_view)->priv;
+
+ g_object_get (web_view,
+ "zoom-level", &zoom,
+ NULL);
+
+ if (priv->is_setting_zoom)
+ return;
+
+ address = ephy_web_view_get_location (EPHY_WEB_VIEW (web_view), TRUE);
+ if (ephy_embed_utils_address_has_web_scheme (address)) {
+ ephy_history_service_set_url_zoom_level (priv->history_service,
+ address, zoom,
+ NULL, NULL, NULL);
+ }
+
+ g_free (address);
+}
+
+static void
ephy_web_view_init (EphyWebView *web_view)
{
EphyWebViewPrivate *priv;
@@ -2235,6 +2312,7 @@ ephy_web_view_init (EphyWebView *web_view)
G_REGEX_OPTIMIZE, G_REGEX_MATCH_NOTEMPTY, NULL);
priv->history_service = EPHY_HISTORY_SERVICE (ephy_embed_shell_get_global_history_service (embed_shell));
+ priv->history_service_cancellable = g_cancellable_new ();
g_signal_connect (priv->history_service,
"cleared", G_CALLBACK (ephy_web_view_history_cleared_cb),
@@ -2260,6 +2338,10 @@ ephy_web_view_init (EphyWebView *web_view)
G_CALLBACK (load_error_cb),
NULL);
+ g_signal_connect (web_view, "notify::zoom-level",
+ G_CALLBACK (zoom_changed_cb),
+ NULL);
+
g_signal_connect_object (web_view, "icon-loaded",
G_CALLBACK (favicon_cb),
web_view, (GConnectFlags)0);