diff options
30 files changed, 2473 insertions, 2857 deletions
diff --git a/embed/ephy-base-embed.c b/embed/ephy-base-embed.c index c87af20dc..1d11439c9 100644 --- a/embed/ephy-base-embed.c +++ b/embed/ephy-base-embed.c @@ -42,82 +42,7 @@ #include "ephy-string.h" #include "ephy-zoom.h" -#define MAX_HIDDEN_POPUPS 5 -#define MAX_TITLE_LENGTH 512 /* characters */ -#define RELOAD_DELAY 250 /* ms */ -#define RELOAD_DELAY_MAX_TICKS 40 /* RELOAD_DELAY * RELOAD_DELAY_MAX_TICKS = 10 s */ -#define EMPTY_PAGE _("Blank page") /* Title for the empty page */ - -struct _EphyBaseEmbedPrivate { - EphyEmbedAddressExpire address_expire; - /* guint address_expire : 2; ? */ - EphyEmbedSecurityLevel security_level; - /* guint security_level : 3; ? */ - EphyEmbedDocumentType document_type; - EphyEmbedNavigationFlags nav_flags; - - /* Flags */ - guint is_blank : 1; - guint is_loading : 1; - guint visibility : 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 */ - GFileMonitor *monitor; - gboolean monitor_directory; - guint reload_scheduled_id; - guint reload_delay_ticks; - - GSList *hidden_popups; - GSList *shown_popups; -}; - -typedef struct { - char *url; - char *name; - char *features; -} PopupInfo; - -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_VISIBLE, - PROP_TYPED_ADDRESS, -}; - -#define EPHY_BASE_EMBED_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_BASE_EMBED, EphyBaseEmbedPrivate)) - -static void ephy_base_embed_file_monitor_cancel (EphyBaseEmbed *embed); -static void ephy_base_embed_dispose (GObject *object); -static void ephy_base_embed_finalize (GObject *object); -static void ephy_embed_iface_init (EphyEmbedIface *iface); - -G_DEFINE_ABSTRACT_TYPE_WITH_CODE (EphyBaseEmbed, ephy_base_embed, GTK_TYPE_BIN, - G_IMPLEMENT_INTERFACE (EPHY_TYPE_EMBED, - ephy_embed_iface_init)) +G_DEFINE_TYPE (EphyBaseEmbed, ephy_base_embed, GTK_TYPE_BIN) static void ephy_base_embed_size_request (GtkWidget *widget, @@ -161,1341 +86,16 @@ ephy_base_embed_grab_focus (GtkWidget *widget) } static void -impl_set_typed_address (EphyEmbed *embed, - const char *address, - EphyEmbedAddressExpire expire) -{ - EphyBaseEmbedPrivate *priv = EPHY_BASE_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_typed_address (EphyEmbed *embed) -{ - return EPHY_BASE_EMBED (embed)->priv->typed_address; -} - -static const char * -impl_get_loading_title (EphyEmbed *embed) -{ - EphyBaseEmbedPrivate *priv = EPHY_BASE_EMBED (embed)->priv; - - return priv->loading_title; -} - -static gboolean -impl_get_is_blank (EphyEmbed *embed) -{ - EphyBaseEmbedPrivate *priv = EPHY_BASE_EMBED (embed)->priv; - - return priv->is_blank; -} - -static const char * -impl_get_icon_address (EphyEmbed *embed) -{ - return EPHY_BASE_EMBED (embed)->priv->icon_address; -} - -static GdkPixbuf * -impl_get_icon (EphyEmbed *embed) -{ - return EPHY_BASE_EMBED (embed)->priv->icon; -} - -static const char * -impl_get_title (EphyEmbed *embed) -{ - return EPHY_BASE_EMBED (embed)->priv->title; -} - -static EphyEmbedDocumentType -impl_get_document_type (EphyEmbed *embed) -{ - return EPHY_BASE_EMBED (embed)->priv->document_type; -} - -static int -impl_get_load_percent (EphyEmbed *embed) -{ - return EPHY_BASE_EMBED (embed)->priv->load_percent; -} - -static gboolean -impl_get_load_status (EphyEmbed *embed) -{ - return EPHY_BASE_EMBED (embed)->priv->is_loading; -} - -static EphyEmbedNavigationFlags -impl_get_navigation_flags (EphyEmbed *embed) -{ - return EPHY_BASE_EMBED (embed)->priv->nav_flags; -} - -static const char * -impl_get_address (EphyEmbed *embed) -{ - EphyBaseEmbedPrivate *priv = EPHY_BASE_EMBED (embed)->priv; - return priv->address ? priv->address : "about:blank"; -} - -static const char * -impl_get_status_message (EphyEmbed *embed) -{ - EphyBaseEmbedPrivate *priv = EPHY_BASE_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) -{ - return EPHY_BASE_EMBED (embed)->priv->link_message; -} - -static gboolean -impl_get_visibility (EphyEmbed *embed) -{ - return EPHY_BASE_EMBED (embed)->priv->visibility; -} - -static void -popups_manager_free_info (PopupInfo *popup) -{ - g_free (popup->url); - g_free (popup->name); - g_free (popup->features); - g_slice_free (PopupInfo, popup); -} - -static void -popups_manager_show (PopupInfo *popup, - EphyBaseEmbed *embed) -{ - EphyEmbedSingle *single; - - /* Only show popup with non NULL url */ - if (popup->url != NULL) { - single = EPHY_EMBED_SINGLE - (ephy_embed_shell_get_embed_single (embed_shell)); - - ephy_embed_single_open_window (single, EPHY_EMBED (embed), popup->url, - popup->name, popup->features); - } - popups_manager_free_info (popup); -} - -static void -popups_manager_show_all (EphyBaseEmbed *embed) -{ - LOG ("popup_blocker_show_all: embed %p", embed); - - g_slist_foreach (embed->priv->hidden_popups, - (GFunc)popups_manager_show, embed); - g_slist_free (embed->priv->hidden_popups); - embed->priv->hidden_popups = NULL; - - g_object_notify (G_OBJECT (embed), "hidden-popup-count"); -} - -static char * -popups_manager_new_window_info (EphyEmbedContainer *container) -{ - EphyEmbed *embed; - EphyEmbedChrome chrome; - gboolean is_popup; - char *features; - - g_object_get (container, "chrome", &chrome, "is-popup", &is_popup, NULL); - g_return_val_if_fail (is_popup, g_strdup ("")); - - embed = ephy_embed_container_get_active_child (container); - g_return_val_if_fail (embed != NULL, g_strdup ("")); - - features = g_strdup_printf - ("width=%d,height=%d,menubar=%d,status=%d,toolbar=%d", - GTK_WIDGET (embed)->allocation.width, - GTK_WIDGET (embed)->allocation.height, - (chrome & EPHY_EMBED_CHROME_MENUBAR) > 0, - (chrome & EPHY_EMBED_CHROME_STATUSBAR) > 0, - (chrome & EPHY_EMBED_CHROME_TOOLBAR) > 0); - - return features; -} - -static guint -popup_blocker_n_hidden (EphyBaseEmbed *embed) -{ - return g_slist_length (embed->priv->hidden_popups); -} - -static void -popups_manager_add (EphyBaseEmbed *embed, - const char *url, - const char *name, - const char *features) -{ - EphyBaseEmbedPrivate *priv = embed->priv; - PopupInfo *popup; - - LOG ("popups_manager_add: embed %p, url %s, features %s", - embed, url, features); - - popup = g_slice_new (PopupInfo); - - popup->url = g_strdup (url); - popup->name = g_strdup (name); - popup->features = g_strdup (features); - - priv->hidden_popups = g_slist_prepend (priv->hidden_popups, popup); - - if (popup_blocker_n_hidden (embed) > MAX_HIDDEN_POPUPS) {/* bug #160863 */ - /* Remove the oldest popup */ - GSList *l = embed->priv->hidden_popups; - - while (l->next->next != NULL) { - l = l->next; - } - - popup = (PopupInfo *)l->next->data; - popups_manager_free_info (popup); - - l->next = NULL; - } else { - g_object_notify (G_OBJECT (embed), "hidden-popup-count"); - } -} - -static void -popups_manager_hide (EphyEmbedContainer *container, - EphyBaseEmbed *parent_embed) -{ - EphyEmbed *embed; - char *location; - char *features; - - embed = ephy_embed_container_get_active_child (container); - g_return_if_fail (EPHY_IS_EMBED (embed)); - - location = ephy_embed_get_location (embed, TRUE); - if (location == NULL) return; - - features = popups_manager_new_window_info (container); - - popups_manager_add (parent_embed, location, "" /* FIXME? maybe _blank? */, features); - - gtk_widget_destroy (GTK_WIDGET (container)); - - g_free (location); - g_free (features); -} - -static void -popups_manager_hide_all (EphyBaseEmbed *embed) -{ - LOG ("popup_blocker_hide_all: embed %p", embed); - - g_slist_foreach (embed->priv->shown_popups, - (GFunc)popups_manager_hide, embed); - g_slist_free (embed->priv->shown_popups); - embed->priv->shown_popups = NULL; -} - -static void -ephy_base_embed_set_popups_allowed (EphyBaseEmbed *embed, - gboolean allowed) -{ - char *location; - EphyPermissionManager *manager; - EphyPermission permission; - - location = ephy_embed_get_location (EPHY_EMBED (embed), TRUE); - g_return_if_fail (location != NULL); - - manager = EPHY_PERMISSION_MANAGER - (ephy_embed_shell_get_embed_single (embed_shell)); - g_return_if_fail (EPHY_IS_PERMISSION_MANAGER (manager)); - - permission = allowed ? EPHY_PERMISSION_ALLOWED - : EPHY_PERMISSION_DENIED; - - ephy_permission_manager_add_permission (manager, location, EPT_POPUP, permission); - - if (allowed) { - popups_manager_show_all (embed); - } else { - popups_manager_hide_all (embed); - } - - g_free (location); -} - -static void -ephy_base_embed_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - switch (prop_id) { - case PROP_ICON_ADDRESS: - ephy_base_embed_set_icon_address (EPHY_BASE_EMBED (object), g_value_get_string (value)); - 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: - ephy_base_embed_set_popups_allowed (EPHY_BASE_EMBED (object), g_value_get_boolean (value)); - break; - case PROP_ADDRESS: - case PROP_TITLE: - 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_VISIBLE: - /* read only */ - break; - default: - break; - } -} - -static gboolean -ephy_base_embed_get_popups_allowed (EphyBaseEmbed *embed) -{ - EphyPermissionManager *permission_manager; - EphyPermission response; - char *location; - gboolean allow; - - permission_manager = EPHY_PERMISSION_MANAGER - (ephy_embed_shell_get_embed_single (embed_shell)); - g_return_val_if_fail (EPHY_IS_PERMISSION_MANAGER (permission_manager), - FALSE); - - location = ephy_embed_get_location (EPHY_EMBED (embed), TRUE); - if (location == NULL) return FALSE;/* FALSE, TRUE… same thing */ - - response = ephy_permission_manager_test_permission - (permission_manager, location, EPT_POPUP); - - switch (response) { - case EPHY_PERMISSION_ALLOWED: - allow = TRUE; - break; - case EPHY_PERMISSION_DENIED: - allow = FALSE; - break; - case EPHY_PERMISSION_DEFAULT: - default: - allow = eel_gconf_get_boolean - (CONF_SECURITY_ALLOW_POPUPS); - break; - } - - g_free (location); - - LOG ("ephy_base_embed_get_popups_allowed: embed %p, allowed: %d", embed, allow); - - return allow; -} - -static void -ephy_base_embed_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - EphyBaseEmbedPrivate *priv = EPHY_BASE_EMBED (object)->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, popup_blocker_n_hidden - (EPHY_BASE_EMBED (object))); - 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, ephy_base_embed_get_popups_allowed - (EPHY_BASE_EMBED (object))); - 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_VISIBLE: - g_value_set_boolean (value, priv->visibility); - break; - default: - break; - } -} - -static void ephy_base_embed_class_init (EphyBaseEmbedClass *klass) { - GObjectClass *gobject_class = (GObjectClass *)klass; GtkWidgetClass *widget_class = (GtkWidgetClass *)klass; - gobject_class->dispose = ephy_base_embed_dispose; - gobject_class->finalize = ephy_base_embed_finalize; - gobject_class->get_property = ephy_base_embed_get_property; - gobject_class->set_property = ephy_base_embed_set_property; - widget_class->size_request = ephy_base_embed_size_request; widget_class->size_allocate = ephy_base_embed_size_allocate; widget_class->grab_focus = ephy_base_embed_grab_focus; - - g_object_class_install_property (gobject_class, - PROP_SECURITY, - g_param_spec_enum ("security-level", - "Security Level", - "The embed's security level", - EPHY_TYPE_EMBED_SECURITY_LEVEL, - EPHY_EMBED_STATE_IS_UNKNOWN, - G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); - g_object_class_install_property (gobject_class, - PROP_DOCUMENT_TYPE, - g_param_spec_enum ("document-type", - "Document Type", - "The embed's documen type", - 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_LOAD_PROGRESS, - g_param_spec_int ("load-progress", - "Load progress", - "The embed's load progress in percent", - 0, - 100, - 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_STATUS, - g_param_spec_boolean ("load-status", - "Load status", - "The embed's load status", - FALSE, - G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); - g_object_class_install_property (gobject_class, - PROP_NAVIGATION, - g_param_spec_flags ("navigation", - "Navigation flags", - "The embed's navigation flags", - EPHY_TYPE_EMBED_NAVIGATION_FLAGS, - 0, - G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); - g_object_class_install_property (gobject_class, - PROP_ADDRESS, - g_param_spec_string ("address", - "Address", - "The embed's address", - "", - G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); - g_object_class_install_property (gobject_class, - PROP_TYPED_ADDRESS, - g_param_spec_string ("typed-address", - "Typed Address", - "The typed address", - "", - G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); - g_object_class_install_property (gobject_class, - PROP_TITLE, - g_param_spec_string ("title", - "Title", - "The embed's title", - EMPTY_PAGE, - G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); - g_object_class_install_property (gobject_class, - PROP_STATUS_MESSAGE, - g_param_spec_string ("status-message", - "Status Message", - "The embed's statusbar message", - NULL, - G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); - g_object_class_install_property (gobject_class, - PROP_LINK_MESSAGE, - g_param_spec_string ("link-message", - "Link Message", - "The embed's link message", - NULL, - G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); - g_object_class_install_property (gobject_class, - PROP_ICON, - g_param_spec_object ("icon", - "Icon", - "The embed icon's", - GDK_TYPE_PIXBUF, - G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); - - g_object_class_install_property (gobject_class, - PROP_ICON_ADDRESS, - g_param_spec_string ("icon-address", - "Icon address", - "The embed icon's address", - NULL, - (G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB))); - g_object_class_install_property (gobject_class, - PROP_HIDDEN_POPUP_COUNT, - g_param_spec_int ("hidden-popup-count", - "Number of Blocked Popups", - "The embed's number of blocked popup windows", - 0, - G_MAXINT, - 0, - G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); - - g_object_class_install_property (gobject_class, - PROP_POPUPS_ALLOWED, - g_param_spec_boolean ("popups-allowed", - "Popups Allowed", - "Whether popup windows are to be displayed", - FALSE, - G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); - - g_object_class_install_property (gobject_class, - PROP_VISIBLE, - g_param_spec_boolean ("visibility", - "Visibility", - "The embed's visibility", - FALSE, - G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); - - g_type_class_add_private (gobject_class, sizeof (EphyBaseEmbedPrivate)); -} - -static void -icon_cache_changed_cb (EphyFaviconCache *cache, - const char *address, - EphyBaseEmbed *embed) -{ - const char *icon_address; - - g_return_if_fail (address != NULL); - - icon_address = ephy_embed_get_icon_address (EPHY_EMBED (embed)); - - /* is this for us? */ - if (icon_address != NULL && - strcmp (icon_address, address) == 0) { - ephy_base_embed_load_icon (EPHY_BASE_EMBED (embed)); - } -} - -static void -ge_document_type_cb (EphyEmbed *embed, - EphyEmbedDocumentType type, - EphyBaseEmbed *bembed) -{ - if (bembed->priv->document_type != type) { - bembed->priv->document_type = type; - - g_object_notify (G_OBJECT (embed), "document-type"); - } -} - -static void -ge_favicon_cb (EphyEmbed *membed, - const char *address, - EphyBaseEmbed *bembed) -{ - ephy_base_embed_set_icon_address (bembed, address); -} - -static gboolean -popups_manager_remove_window (EphyBaseEmbed *embed, - EphyEmbedContainer *container) -{ - embed->priv->shown_popups = g_slist_remove (embed->priv->shown_popups, - container); - - return FALSE; -} - -static void -popups_manager_add_window (EphyBaseEmbed *embed, - EphyEmbedContainer *container) -{ - LOG ("popups_manager_add_window: embed %p, container %p", embed, container); - - embed->priv->shown_popups = g_slist_prepend - (embed->priv->shown_popups, container); - - g_signal_connect_swapped (container, "destroy", - G_CALLBACK (popups_manager_remove_window), - embed); -} - -static void -ge_new_window_cb (EphyEmbed *embed, - EphyEmbed *new_embed, - EphyBaseEmbed *bembed) -{ - EphyEmbedContainer *container; - - g_return_if_fail (new_embed != NULL); - - container = EPHY_EMBED_CONTAINER (gtk_widget_get_toplevel (GTK_WIDGET (new_embed))); - g_return_if_fail (container != NULL || !GTK_WIDGET_TOPLEVEL (container)); - - popups_manager_add_window (bembed, container); -} - -static void -disconnect_popup (EphyEmbedContainer *container, - EphyBaseEmbed *embed) -{ - g_signal_handlers_disconnect_by_func - (container, G_CALLBACK (popups_manager_remove_window), embed); -} - -void -ephy_base_embed_popups_manager_reset (EphyBaseEmbed *embed) -{ - g_slist_foreach (embed->priv->hidden_popups, - (GFunc)popups_manager_free_info, NULL); - g_slist_free (embed->priv->hidden_popups); - embed->priv->hidden_popups = NULL; - - g_slist_foreach (embed->priv->shown_popups, - (GFunc)disconnect_popup, embed); - g_slist_free (embed->priv->shown_popups); - embed->priv->shown_popups = NULL; - - g_object_notify (G_OBJECT (embed), "hidden-popup-count"); - g_object_notify (G_OBJECT (embed), "popups-allowed"); -} - -static void -ge_popup_blocked_cb (EphyEmbed *embed, - const char *url, - const char *name, - const char *features, - EphyBaseEmbed *bembed) -{ - popups_manager_add (bembed, url, name, features); } static void ephy_base_embed_init (EphyBaseEmbed *self) { - EphyBaseEmbedPrivate *priv; - EphyFaviconCache *cache; - - priv = self->priv = EPHY_BASE_EMBED_GET_PRIVATE (self); - - g_signal_connect_object (self, "ge_document_type", - G_CALLBACK (ge_document_type_cb), - self, (GConnectFlags)0); - - g_signal_connect_object (self, "ge_favicon", - G_CALLBACK (ge_favicon_cb), - self, (GConnectFlags)0); - - g_signal_connect_object (self, "ge_new_window", - G_CALLBACK (ge_new_window_cb), - self, (GConnectFlags)0); - - g_signal_connect_object (self, "ge_popup_blocked", - G_CALLBACK (ge_popup_blocked_cb), - self, (GConnectFlags)0); - - cache = EPHY_FAVICON_CACHE - (ephy_embed_shell_get_favicon_cache (embed_shell)); - g_signal_connect_object (G_OBJECT (cache), "changed", - G_CALLBACK (icon_cache_changed_cb), - self, (GConnectFlags)0); - - priv->document_type = EPHY_EMBED_DOCUMENT_HTML; - priv->security_level = EPHY_EMBED_STATE_IS_UNKNOWN; - priv->address_expire = EPHY_EMBED_ADDRESS_EXPIRE_NOW; - priv->is_blank = TRUE; - priv->title = g_strdup (EMPTY_PAGE); - priv->monitor_directory = FALSE; -} - -static void -ephy_base_embed_dispose (GObject *object) -{ - ephy_base_embed_file_monitor_cancel (EPHY_BASE_EMBED (object)); - - G_OBJECT_CLASS (ephy_base_embed_parent_class)->dispose (object); -} - -static void -ephy_base_embed_finalize (GObject *object) -{ - EphyBaseEmbedPrivate *priv = EPHY_BASE_EMBED (object)->priv; - - if (priv->icon != NULL) { - g_object_unref (priv->icon); - priv->icon = NULL; - } - - ephy_base_embed_popups_manager_reset (EPHY_BASE_EMBED (object)); - - g_free (priv->icon_address); - g_free (priv->status_message); - g_free (priv->link_message); - g_free (priv->address); - g_free (priv->typed_address); - g_free (priv->title); - g_free (priv->loading_title); - - G_OBJECT_CLASS (ephy_base_embed_parent_class)->finalize (object); -} - -static void -ephy_embed_iface_init (EphyEmbedIface *iface) -{ - iface->get_title = impl_get_title; - iface->get_address = impl_get_address; - iface->get_typed_address = impl_get_typed_address; - iface->set_typed_address = impl_set_typed_address; - iface->get_loading_title = impl_get_loading_title; - iface->get_is_blank = impl_get_is_blank; - iface->get_icon = impl_get_icon; - iface->get_icon_address = impl_get_icon_address; - iface->get_document_type = impl_get_document_type; - iface->get_load_status = impl_get_load_status; - iface->get_load_percent = impl_get_load_percent; - iface->get_navigation_flags = impl_get_navigation_flags; - iface->get_link_message = impl_get_link_message; - iface->get_status_message = impl_get_status_message; - iface->get_visibility = impl_get_visibility; -} - -void -ephy_base_embed_set_address (EphyBaseEmbed *embed, - const char *address) -{ - EphyBaseEmbedPrivate *priv = embed->priv; - GObject *object = G_OBJECT (embed); - - g_free (priv->address); - priv->address = g_strdup (address); - - priv->is_blank = address == NULL || - strcmp (address, "about:blank") == 0; - - if (priv->is_loading && - priv->address_expire == EPHY_EMBED_ADDRESS_EXPIRE_NOW && - priv->typed_address != NULL) { - g_free (priv->typed_address); - priv->typed_address = NULL; - - g_object_notify (object, "typed-address"); - } - - g_object_notify (object, "address"); -} - -static char* -get_title_from_address (const char *address) -{ - if (g_str_has_prefix (address, "file://")) - return g_strdup (address + 7); - else - return ephy_string_get_host_name (address); -} - -void -ephy_base_embed_set_title (EphyBaseEmbed *embed, - const char *embed_title) -{ - EphyBaseEmbedPrivate *priv = embed->priv; - char *title = g_strdup (embed_title); - - if (!priv->is_blank && (title == NULL || g_strstrip (title)[0] == '\0')) { - g_free (title); - title = get_title_from_address (priv->address); - - /* Fallback */ - if (title == NULL || title[0] == '\0') { - g_free (title); - title = g_strdup (EMPTY_PAGE); - priv->is_blank = TRUE; - } - } else if (priv->is_blank) { - g_free (title); - title = g_strdup (EMPTY_PAGE); - } - - g_free (priv->title); - priv->title = ephy_string_shorten (title, MAX_TITLE_LENGTH); - - g_object_notify (G_OBJECT (embed), "title"); -} - -static void -ensure_page_info (EphyBaseEmbed *embed, const char *address) -{ - EphyBaseEmbedPrivate *priv = embed->priv; - - if ((priv->address == NULL || priv->address[0] == '\0') && - priv->address_expire == EPHY_EMBED_ADDRESS_EXPIRE_NOW) { - ephy_base_embed_set_address (embed, address); - } - - /* FIXME huh?? */ - if (priv->title == NULL || priv->title[0] == '\0') { - ephy_base_embed_set_title (embed, NULL); - } -} -static void -update_net_state_message (EphyBaseEmbed *embed, const char *uri, EphyEmbedNetState flags) -{ - const char *msg = NULL; - char *host = NULL; - - if (uri != NULL) - host = ephy_string_get_host_name (uri); - - if (host == NULL) goto out; - - /* IS_REQUEST and IS_NETWORK can be both set */ - if (flags & EPHY_EMBED_STATE_IS_REQUEST) { - if (flags & EPHY_EMBED_STATE_REDIRECTING) { - msg = _ ("Redirecting to “%s”…"); - } else if (flags & EPHY_EMBED_STATE_TRANSFERRING) { - msg = _ ("Transferring data from “%s”…"); - } else if (flags & EPHY_EMBED_STATE_NEGOTIATING) { - msg = _ ("Waiting for authorization from “%s”…"); - } - } - - if (flags & EPHY_EMBED_STATE_IS_NETWORK) { - if (flags & EPHY_EMBED_STATE_START) { - msg = _ ("Loading “%s”…"); - } - } - - if ((flags & EPHY_EMBED_STATE_IS_NETWORK) && - (flags & EPHY_EMBED_STATE_STOP)) { - g_free (embed->priv->status_message); - embed->priv->status_message = NULL; - g_object_notify (G_OBJECT (embed), "status-message"); - - } else if (msg != NULL) { - g_free (embed->priv->status_message); - g_free (embed->priv->loading_title); - embed->priv->status_message = g_strdup_printf (msg, host); - embed->priv->loading_title = g_strdup_printf (msg, host); - g_object_notify (G_OBJECT (embed), "status-message"); - g_object_notify (G_OBJECT (embed), "title"); - } - - out: - g_free (host); -} - -static void -update_navigation_flags (EphyBaseEmbed *membed) -{ - EphyBaseEmbedPrivate *priv = membed->priv; - EphyEmbed *embed = EPHY_EMBED (membed); - guint flags = 0; - WebKitWebView *web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed); - - if (ephy_embed_can_go_up (embed)) { - flags |= EPHY_EMBED_NAV_UP; - } - - if (webkit_web_view_can_go_back (web_view)) { - flags |= EPHY_EMBED_NAV_BACK; - } - - if (webkit_web_view_can_go_forward (web_view)) { - flags |= EPHY_EMBED_NAV_FORWARD; - } - - if (priv->nav_flags != (EphyEmbedNavigationFlags)flags) { - priv->nav_flags = (EphyEmbedNavigationFlags)flags; - - g_object_notify (G_OBJECT (embed), "navigation"); - } -} - -static int -build_load_percent (int requests_done, int requests_total) -{ - int percent = 0; - - if (requests_total > 0) { - percent = (requests_done * 100) / requests_total; - percent = CLAMP (percent, 0, 100); - } - - return percent; -} - -void -ephy_base_embed_set_load_percent (EphyBaseEmbed *embed, int percent) -{ - EphyBaseEmbedPrivate *priv = embed->priv; - - if (percent != priv->load_percent) { - priv->load_percent = percent; - - g_object_notify (G_OBJECT (embed), "load-progress"); - } -} - -static void -build_progress_from_requests (EphyBaseEmbed *embed, EphyEmbedNetState state) -{ - int load_percent; - - if (state & EPHY_EMBED_STATE_IS_REQUEST) { - if (state & EPHY_EMBED_STATE_START) { - embed->priv->total_requests++; - } else if (state & EPHY_EMBED_STATE_STOP) { - embed->priv->cur_requests++; - } - - load_percent = build_load_percent (embed->priv->cur_requests, - embed->priv->total_requests); - - ephy_base_embed_set_load_percent (embed, load_percent); - } -} - -static void -ephy_base_embed_set_load_status (EphyBaseEmbed *embed, gboolean status) -{ - EphyBaseEmbedPrivate *priv = embed->priv; - guint is_loading; - - is_loading = status != FALSE; - - if (is_loading != priv->is_loading) { - priv->is_loading = is_loading; - - g_object_notify (G_OBJECT (embed), "load-status"); - } -} - -void -ephy_base_embed_update_from_net_state (EphyBaseEmbed *embed, - const char *uri, - EphyEmbedNetState state) -{ - EphyBaseEmbedPrivate *priv = embed->priv; - - update_net_state_message (embed, uri, state); - - if (state & EPHY_EMBED_STATE_IS_NETWORK) { - if (state & EPHY_EMBED_STATE_START) { - GObject *object = G_OBJECT (embed); - - g_object_freeze_notify (object); - - priv->total_requests = 0; - priv->cur_requests = 0; - - ephy_base_embed_set_load_percent (embed, 0); - ephy_base_embed_set_load_status (embed, TRUE); - - ensure_page_info (embed, uri); - - g_object_notify (object, "title"); - - g_object_thaw_notify (object); - } else if (state & EPHY_EMBED_STATE_STOP) { - GObject *object = G_OBJECT (embed); - - g_object_freeze_notify (object); - - ephy_base_embed_set_load_percent (embed, 100); - ephy_base_embed_set_load_status (embed, FALSE); - - g_free (priv->loading_title); - priv->loading_title = NULL; - - priv->address_expire = EPHY_EMBED_ADDRESS_EXPIRE_NOW; - - g_object_notify (object, "title"); - - g_object_thaw_notify (object); - } - - update_navigation_flags (embed); - } - - build_progress_from_requests (embed, state); -} - -void -ephy_base_embed_set_loading_title (EphyBaseEmbed *embed, - const char *title, - gboolean is_address) -{ - EphyBaseEmbedPrivate *priv = embed->priv; - char *freeme = NULL; - - g_free (priv->loading_title); - priv->loading_title = NULL; - - if (is_address) { - title = freeme = get_title_from_address (title); - } - - if (title != NULL && title[0] != '\0') { - /* translators: %s here is the address of the web page */ - priv->loading_title = g_strdup_printf (_ ("Loading “%s”…"), title); - } else { - priv->loading_title = g_strdup (_ ("Loading…")); - } - - g_free (freeme); -} - -static void -ephy_base_embed_file_monitor_cancel (EphyBaseEmbed *embed) -{ - EphyBaseEmbedPrivate *priv = embed->priv; - - if (priv->monitor != NULL) { - LOG ("Cancelling file monitor"); - - g_file_monitor_cancel (G_FILE_MONITOR (priv->monitor)); - priv->monitor = NULL; - } - - if (priv->reload_scheduled_id != 0) { - LOG ("Cancelling scheduled reload"); - - g_source_remove (priv->reload_scheduled_id); - priv->reload_scheduled_id = 0; - } - - priv->reload_delay_ticks = 0; -} - -static gboolean -ephy_base_embed_file_monitor_reload_cb (EphyBaseEmbed *embed) -{ - EphyBaseEmbedPrivate *priv = embed->priv; - - if (priv->reload_delay_ticks > 0) { - priv->reload_delay_ticks--; - - /* Run again */ - return TRUE; - } - - if (priv->is_loading) { - /* Wait a bit to reload if we're still loading! */ - priv->reload_delay_ticks = RELOAD_DELAY_MAX_TICKS / 2; - - /* Run again */ - return TRUE; - } - - priv->reload_scheduled_id = 0; - - LOG ("Reloading file '%s'", ephy_embed_get_address (EPHY_EMBED (embed))); - webkit_web_view_reload (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed)); - - /* don't run again */ - return FALSE; -} - -static void -ephy_base_embed_file_monitor_cb (GFileMonitor *monitor, - GFile *file, - GFile *other_file, - GFileMonitorEvent event_type, - EphyBaseEmbed *embed) -{ - gboolean should_reload; - EphyBaseEmbedPrivate *priv = embed->priv; - - switch (event_type) { - /* These events will always trigger a reload: */ - case G_FILE_MONITOR_EVENT_CHANGED: - case G_FILE_MONITOR_EVENT_CREATED: - should_reload = TRUE; - break; - - /* These events will only trigger a reload for directories: */ - case G_FILE_MONITOR_EVENT_DELETED: - case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED: - should_reload = priv->monitor_directory; - break; - - /* These events don't trigger a reload: */ - case G_FILE_MONITOR_EVENT_PRE_UNMOUNT: - case G_FILE_MONITOR_EVENT_UNMOUNTED: - case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT: - default: - should_reload = FALSE; - break; - } - - if (should_reload) { - /* We make a lot of assumptions here, but basically we know - * that we just have to reload, by construction. - * Delay the reload a little bit so we don't endlessly - * reload while a file is written. - */ - if (priv->reload_delay_ticks == 0) { - priv->reload_delay_ticks = 1; - } else { - /* Exponential backoff */ - priv->reload_delay_ticks = MIN (priv->reload_delay_ticks * 2, - RELOAD_DELAY_MAX_TICKS); - } - - if (priv->reload_scheduled_id == 0) { - priv->reload_scheduled_id = - g_timeout_add (RELOAD_DELAY, - (GSourceFunc)ephy_base_embed_file_monitor_reload_cb, embed); - } - } -} - -static void -ephy_base_embed_update_file_monitor (EphyBaseEmbed *embed, - const gchar *address) -{ - EphyBaseEmbedPrivate *priv = embed->priv; - gboolean local; - gchar *anchor; - gchar *url; - GFile *file; - GFileType file_type; - GFileInfo *file_info; - GFileMonitor *monitor = NULL; - - if (priv->monitor != NULL && - priv->address != NULL && address != NULL && - strcmp (priv->address, address) == 0) { - /* same address, no change needed */ - return; - } - - ephy_base_embed_file_monitor_cancel (embed); - - local = g_str_has_prefix (address, "file://"); - if (local == FALSE) return; - - /* strip off anchors */ - anchor = strchr (address, '#'); - if (anchor != NULL) { - url = g_strndup (address, anchor - address); - } else { - url = g_strdup (address); - } - - file = g_file_new_for_uri (url); - file_info = g_file_query_info (file, - G_FILE_ATTRIBUTE_STANDARD_TYPE, - 0, NULL, NULL); - if (file_info == NULL) { - g_object_unref (file); - g_free (url); - return; - } - - file_type = g_file_info_get_file_type (file_info); - g_object_unref (file_info); - - if (file_type == G_FILE_TYPE_DIRECTORY) { - monitor = g_file_monitor_directory (file, 0, NULL, NULL); - g_signal_connect (monitor, "changed", - G_CALLBACK (ephy_base_embed_file_monitor_cb), - embed); - priv->monitor_directory = TRUE; - LOG ("Installed monitor for directory '%s'", url); - } - else if (file_type == G_FILE_TYPE_REGULAR) { - monitor = g_file_monitor_file (file, 0, NULL, NULL); - g_signal_connect (monitor, "changed", - G_CALLBACK (ephy_base_embed_file_monitor_cb), - embed); - priv->monitor_directory = FALSE; - LOG ("Installed monitor for file '%s'", url); - } - priv->monitor = monitor; - g_object_unref (file); - g_free (url); -} - -void -ephy_base_embed_location_changed (EphyBaseEmbed *embed, - const char *location) -{ - GObject *object = G_OBJECT (embed); - - g_object_freeze_notify (object); - - /* do this up here so we still have the old address around */ - ephy_base_embed_update_file_monitor (embed, location); - - /* Do not expose about:blank to the user, an empty address - bar will do better */ - if (location == NULL || location[0] == '\0' || - strcmp (location, "about:blank") == 0) { - ephy_base_embed_set_address (embed, NULL); - ephy_base_embed_set_title (embed, EMPTY_PAGE); - } else { - char *embed_address; - - /* we do this to get rid of an eventual password in the URL */ - embed_address = ephy_embed_get_location (EPHY_EMBED (embed), TRUE); - ephy_base_embed_set_address (embed, embed_address); - ephy_base_embed_set_loading_title (embed, embed_address, TRUE); - g_free (embed_address); - } - - ephy_base_embed_set_link_message (embed, NULL); - ephy_base_embed_set_icon_address (embed, NULL); - update_navigation_flags (embed); - - g_object_notify (object, "title"); - - g_object_thaw_notify (object); -} - -void -ephy_base_embed_set_link_message (EphyBaseEmbed *embed, - char *link_message) -{ - EphyBaseEmbedPrivate *priv = embed->priv; - - g_free (priv->link_message); - - priv->link_message = ephy_embed_utils_link_message_parse (link_message); - - g_object_notify (G_OBJECT (embed), "status-message"); - g_object_notify (G_OBJECT (embed), "link-message"); -} - -void -ephy_base_embed_load_icon (EphyBaseEmbed *embed) -{ - EphyBaseEmbedPrivate *priv = embed->priv; - EphyEmbedShell *shell; - EphyFaviconCache *cache; - - if (priv->icon_address == NULL || priv->icon != NULL) return; - - shell = ephy_embed_shell_get_default (); - cache = EPHY_FAVICON_CACHE (ephy_embed_shell_get_favicon_cache (shell)); - - /* ephy_favicon_cache_get returns a reference already */ - priv->icon = ephy_favicon_cache_get (cache, priv->icon_address); - - g_object_notify (G_OBJECT (embed), "icon"); -} - -void -ephy_base_embed_set_icon_address (EphyBaseEmbed *embed, - const char *address) -{ - GObject *object = G_OBJECT (embed); - EphyBaseEmbedPrivate *priv = embed->priv; - EphyHistory *history; - - g_free (priv->icon_address); - priv->icon_address = g_strdup (address); - - if (priv->icon != NULL) { - g_object_unref (priv->icon); - priv->icon = NULL; - - g_object_notify (object, "icon"); - } - - if (priv->icon_address) { - history = EPHY_HISTORY (ephy_embed_shell_get_global_history (embed_shell)); - ephy_history_set_icon (history, priv->address, priv->icon_address); - - ephy_base_embed_load_icon (embed); - } - - g_object_notify (object, "icon-address"); -} - -void -ephy_base_embed_set_security_level (EphyBaseEmbed *embed, - EphyEmbedSecurityLevel level) -{ - EphyBaseEmbedPrivate *priv = embed->priv; - - if (priv->security_level != level) { - priv->security_level = level; - - g_object_notify (G_OBJECT (embed), "security-level"); - } -} - -void -ephy_base_embed_set_visibility (EphyBaseEmbed *embed, - gboolean visibility) -{ - EphyBaseEmbedPrivate *priv = embed->priv; - - if (priv->visibility != visibility) { - priv->visibility = visibility; - - g_object_notify (G_OBJECT (embed), "visibility"); - } } diff --git a/embed/ephy-base-embed.h b/embed/ephy-base-embed.h index d2043a8b9..9e34007e8 100644 --- a/embed/ephy-base-embed.h +++ b/embed/ephy-base-embed.h @@ -53,31 +53,6 @@ struct _EphyBaseEmbed { }; GType ephy_base_embed_get_type (void) G_GNUC_CONST; -void ephy_base_embed_set_title (EphyBaseEmbed *embed, - const char *title); -void ephy_base_embed_set_loading_title (EphyBaseEmbed *embed, - const char *title, - gboolean is_address); -void ephy_base_embed_set_address (EphyBaseEmbed *embed, - const char *address); -void ephy_base_embed_location_changed (EphyBaseEmbed *embed, - const char *location); -void ephy_base_embed_load_icon (EphyBaseEmbed *embed); -void ephy_base_embed_set_icon_address (EphyBaseEmbed *embed, - const char *address); -void ephy_base_embed_set_link_message (EphyBaseEmbed *embed, - char *link_message); -void ephy_base_embed_set_security_level (EphyBaseEmbed *embed, - EphyEmbedSecurityLevel level); -void ephy_base_embed_restore_zoom_level (EphyBaseEmbed *membed, - const char *address); -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); -void ephy_base_embed_popups_manager_reset (EphyBaseEmbed *embed); -void ephy_base_embed_set_visibility (EphyBaseEmbed *embed, - gboolean visibility); G_END_DECLS diff --git a/embed/ephy-embed-container.c b/embed/ephy-embed-container.c index c2a6ad9cd..1a55eb66a 100644 --- a/embed/ephy-embed-container.c +++ b/embed/ephy-embed-container.c @@ -33,8 +33,8 @@ ephy_embed_container_base_init (gpointer g_class) g_object_interface_install_property (g_class, g_param_spec_flags ("chrome", NULL, NULL, - EPHY_TYPE_EMBED_CHROME, - EPHY_EMBED_CHROME_ALL, + EPHY_TYPE_WEB_VIEW_CHROME, + EPHY_WEB_VIEW_CHROME_ALL, G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); @@ -205,12 +205,12 @@ ephy_embed_container_get_is_popup (EphyEmbedContainer *container) * ephy_embed_container_get_chrome: * @container: an #EphyEmbedContainer * - * Returns the #EphyEmbedChrome flags indicating the visibility of several parts + * Returns the #EphyWebViewChrome flags indicating the visibility of several parts * of the UI. * - * Return value: #EphyEmbedChrome flags. + * Return value: #EphyWebViewChrome flags. **/ -EphyEmbedChrome +EphyWebViewChrome ephy_embed_container_get_chrome (EphyEmbedContainer *container) { EphyEmbedContainerIface *iface; diff --git a/embed/ephy-embed-container.h b/embed/ephy-embed-container.h index 8a502fdd0..13c602a18 100644 --- a/embed/ephy-embed-container.h +++ b/embed/ephy-embed-container.h @@ -25,6 +25,7 @@ #define EPHY_EMBED_CONTAINER_H #include "ephy-embed.h" +#include "ephy-web-view.h" #include <glib-object.h> #include <glib.h> @@ -62,7 +63,7 @@ struct _EphyEmbedContainerIface gboolean (* get_is_popup) (EphyEmbedContainer *container); - EphyEmbedChrome (* get_chrome) (EphyEmbedContainer *container); + EphyWebViewChrome (* get_chrome) (EphyEmbedContainer *container); }; GType ephy_embed_container_get_type (void); @@ -84,7 +85,7 @@ GList *ephy_embed_container_get_children (EphyEmbedContainer *container); gboolean ephy_embed_container_get_is_popup (EphyEmbedContainer *container); -EphyEmbedChrome ephy_embed_container_get_chrome (EphyEmbedContainer *container); +EphyWebViewChrome ephy_embed_container_get_chrome (EphyEmbedContainer *container); G_END_DECLS diff --git a/embed/ephy-embed-single.c b/embed/ephy-embed-single.c index f24fef1c6..9b0e8178f 100644 --- a/embed/ephy-embed-single.c +++ b/embed/ephy-embed-single.c @@ -76,7 +76,7 @@ ephy_embed_single_iface_init (gpointer g_iface) GTK_TYPE_WIDGET, 2, GTK_TYPE_WIDGET, - EPHY_TYPE_EMBED_CHROME); + EPHY_TYPE_WEB_VIEW_CHROME); /** * EphyEmbedSingle::handle_content: diff --git a/embed/ephy-embed-single.h b/embed/ephy-embed-single.h index 8ae5d92cb..cbd253ab3 100644 --- a/embed/ephy-embed-single.h +++ b/embed/ephy-embed-single.h @@ -25,6 +25,7 @@ #define EPHY_EMBED_SINGLE_H #include "ephy-embed.h" +#include "ephy-web-view.h" G_BEGIN_DECLS @@ -46,7 +47,7 @@ struct _EphyEmbedSingleIface EphyEmbed * (* new_window) (EphyEmbedSingle *single, EphyEmbed *parent_embed, - EphyEmbedChrome chromemask); + EphyWebViewChrome chromemask); gboolean (* handle_content) (EphyEmbedSingle *shell, char *mime_type, diff --git a/embed/ephy-embed-utils.c b/embed/ephy-embed-utils.c index e00e23528..672c46bc3 100644 --- a/embed/ephy-embed-utils.c +++ b/embed/ephy-embed-utils.c @@ -80,28 +80,28 @@ ephy_embed_utils_link_message_parse (char *message) /** * ephy_embed_utils_get_title_composite: - * @embed: an #EphyEmbed + * @view: an #EphyView * * Returns the title of the web page loaded in @embed. * * This differs from #ephy_embed_utils_get_title in that this function * will return a special title while the page is still loading. * - * Return value: @embed's web page's title. Will never be %NULL. + * Return value: @view's web page's title. Will never be %NULL. **/ const char * -ephy_embed_utils_get_title_composite (EphyEmbed *embed) +ephy_embed_utils_get_title_composite (EphyWebView *view) { const char *title = ""; const char *loading_title; gboolean is_loading, is_blank; - g_return_val_if_fail (EPHY_IS_EMBED (embed), NULL); + g_return_val_if_fail (EPHY_IS_WEB_VIEW (view), NULL); - is_loading = ephy_embed_get_load_status (embed); - is_blank = ephy_embed_get_is_blank (embed); - loading_title = ephy_embed_get_loading_title (embed); - title = ephy_embed_get_title (embed); + is_loading = ephy_web_view_get_load_status (view); + is_blank = ephy_web_view_get_is_blank (view); + loading_title = ephy_web_view_get_loading_title (view); + title = ephy_web_view_get_title (view); if (is_blank) { diff --git a/embed/ephy-embed-utils.h b/embed/ephy-embed-utils.h index e98860ed8..226eff3f7 100644 --- a/embed/ephy-embed-utils.h +++ b/embed/ephy-embed-utils.h @@ -36,10 +36,13 @@ G_BEGIN_DECLS #define EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED(embed) (WEBKIT_WEB_VIEW (gtk_bin_get_child (GTK_BIN (gtk_bin_get_child (GTK_BIN (embed)))))) +#define EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED(embed) (EPHY_WEB_VIEW (gtk_bin_get_child (GTK_BIN (gtk_bin_get_child (GTK_BIN (embed)))))) +#define EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW(view) (EPHY_EMBED (gtk_widget_get_parent (gtk_widget_get_parent (GTK_WIDGET (view))))) + #define EPHY_WEBKIT_BACK_FORWARD_LIMIT 100 char * ephy_embed_utils_link_message_parse (char *message); -const char * ephy_embed_utils_get_title_composite (EphyEmbed *embed); +const char * ephy_embed_utils_get_title_composite (EphyWebView *view); gboolean ephy_embed_utils_address_has_web_scheme (const char *address); G_END_DECLS diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c deleted file mode 100644 index 29ecfed9d..000000000 --- a/embed/ephy-embed.c +++ /dev/null @@ -1,771 +0,0 @@ -/* - * Copyright © 2000-2003 Marco Pesenti Gritti - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "config.h" - -#include <gdk-pixbuf/gdk-pixbuf.h> - -#include "ephy-embed.h" - -#include "ephy-embed-type-builtins.h" -#include "ephy-marshal.h" - -static void ephy_embed_base_init (gpointer g_class); - -GType -ephy_embed_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) - { - const GTypeInfo our_info = - { - sizeof (EphyEmbedIface), - ephy_embed_base_init, - NULL, - }; - - type = g_type_register_static (G_TYPE_INTERFACE, - "EphyEmbed", - &our_info, (GTypeFlags)0); - } - - return type; -} - -static void -ephy_embed_base_init (gpointer g_class) -{ - static gboolean initialized = FALSE; - - if (!initialized) - { -/** - * EphyEmbed::ge-new-window: - * @embed: - * @new_embed: the newly opened #EphyEmbed - * - * The ::ge_new_window signal is emitted after a new window has been opened by - * the embed. For example, when a JavaScript popup window is opened. - **/ - g_signal_new ("ge_new_window", - EPHY_TYPE_EMBED, - G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EphyEmbedIface, new_window), - NULL, NULL, - g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, - 1, - GTK_TYPE_WIDGET); -/** - * EphyEmbed::ge-popup-blocked: - * @embed: - * @address: The requested URL - * @target: The requested window name, e.g. "_blank" - * @features: The requested features: for example, "height=400,width=200" - * - * The ::ge_popup_blocked signal is emitted when the viewed web page requests - * a popup window (with javascript:open()) but popup windows are not allowed. - **/ - g_signal_new ("ge_popup_blocked", - EPHY_TYPE_EMBED, - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EphyEmbedIface, popup_blocked), - NULL, NULL, - ephy_marshal_VOID__STRING_STRING_STRING, - G_TYPE_NONE, - 3, - G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE, - G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE, - G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE); -/** - * EphyEmbed::ge-context-menu: - * @embed: - * @event: the #EphyEmbedEvent which triggered this signal - * - * The ::ge_context_menu signal is emitted when a context menu is to be - * displayed. This will usually happen when the user right-clicks on a part of - * @embed. - **/ - g_signal_new ("ge_context_menu", - EPHY_TYPE_EMBED, - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EphyEmbedIface, context_menu), - g_signal_accumulator_true_handled, NULL, - ephy_marshal_BOOLEAN__OBJECT, - G_TYPE_BOOLEAN, - 1, - G_TYPE_OBJECT); -/** - * EphyEmbed::ge-favicon: - * @embed: - * @address: the URL to @embed's web site's favicon - * - * The ::ge_favicon signal is emitted when @embed discovers that a favourite - * icon (favicon) is available for the site it is visiting. - **/ - g_signal_new ("ge_favicon", - EPHY_TYPE_EMBED, - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EphyEmbedIface, favicon), - NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, - 1, - G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE); -/** - * EphyEmbed::ge-search-link: - * @embed: - * @type: the mime-type of the search description - * @title: the title of the news feed - * @address: the URL to @embed's web site's search description - * - * The ::ge_rss signal is emitted when @embed discovers that a search - * description is available for the site it is visiting. - **/ - g_signal_new ("ge_search_link", - EPHY_TYPE_EMBED, - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EphyEmbedIface, search_link), - NULL, NULL, - ephy_marshal_VOID__STRING_STRING_STRING, - G_TYPE_NONE, - 3, - G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE, - G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE, - G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE); - -/** - * EphyEmbed::ge-feed-link: - * @embed: - * @type: the mime-type of the news feed - * @title: the title of the news feed - * @address: the URL to @embed's web site's news feed - * - * The ::ge_rss signal is emitted when @embed discovers that a news feed - * is available for the site it is visiting. - **/ - g_signal_new ("ge_feed_link", - EPHY_TYPE_EMBED, - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EphyEmbedIface, feed_link), - NULL, NULL, - ephy_marshal_VOID__STRING_STRING_STRING, - G_TYPE_NONE, - 3, - G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE, - G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE, - G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE); -/** - * EphyEmbed::ge-dom-mouse-click: - * @embed: - * @event: the #EphyEmbedEvent which triggered this signal - * - * The ::ge_dom_mouse_click signal is emitted when the user clicks in @embed. - **/ - g_signal_new ("ge_dom_mouse_click", - EPHY_TYPE_EMBED, - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EphyEmbedIface, dom_mouse_click), - g_signal_accumulator_true_handled, NULL, - ephy_marshal_BOOLEAN__OBJECT, - G_TYPE_BOOLEAN, - 1, - G_TYPE_OBJECT); -/** - * EphyEmbed::ge-dom-mouse-down: - * @embed: - * @event: the #EphyEmbedEvent which triggered this signal - * - * The ::ge_dom_mouse_down signal is emitted when the user depresses a mouse - * button. - **/ - g_signal_new ("ge_dom_mouse_down", - EPHY_TYPE_EMBED, - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EphyEmbedIface, dom_mouse_down), - g_signal_accumulator_true_handled, NULL, - ephy_marshal_BOOLEAN__OBJECT, - G_TYPE_BOOLEAN, - 1, - G_TYPE_OBJECT); -/** - * EphyEmbed::ge-modal-alert: - * @embed: - * - * The ::ge-modal-alert signal is emitted when a DOM event will open a - * modal alert. - * - * Return %TRUE to prevent the dialog from being opened. - **/ - g_signal_new ("ge_modal_alert", - EPHY_TYPE_EMBED, - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EphyEmbedIface, modal_alert), - g_signal_accumulator_true_handled, NULL, - ephy_marshal_BOOLEAN__VOID, - G_TYPE_BOOLEAN, - 0); -/** - * EphyEmbed::ge-modal-alert-closed: - * @embed: - * - * The ::ge-modal-alert-closed signal is emitted when a modal alert put up by a - * DOM event was closed. - **/ - g_signal_new ("ge_modal_alert_closed", - EPHY_TYPE_EMBED, - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EphyEmbedIface, modal_alert_closed), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, - 0); - -/** - * EphyEmbed::ge-document-type: - * @embed: - * @type: the new document type - * - * The ::ge-document-type signal is emitted when @embed determines the type of its document. - **/ - g_signal_new ("ge_document_type", - EPHY_TYPE_EMBED, - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EphyEmbedIface, document_type), - NULL, NULL, - g_cclosure_marshal_VOID__ENUM, - G_TYPE_NONE, - 1, - EPHY_TYPE_EMBED_DOCUMENT_TYPE); -/** - * EphyEmbed::dom-content-loaded: - * @embed: - * - * The ::dom-content-loaded signal is emitted when - * the document has been loaded (excluding images and other loads initiated by this document). - * That's true also for frameset and all the frames within it. - **/ - g_signal_new ("dom_content_loaded", - EPHY_TYPE_EMBED, - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EphyEmbedIface, dom_content_loaded), - NULL, NULL, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, - 1, - G_TYPE_POINTER); - -/** - * EphyEmbed::ge-search-key-press: - * @embed: - * @event: the #GdkEventKey which triggered this signal - * - * The ::ge-search-key-press signal is emitted for keypresses which - * should be used for find implementations. - **/ - g_signal_new ("ge-search-key-press", - EPHY_TYPE_EMBED, - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EphyEmbedIface, search_key_press), - g_signal_accumulator_true_handled, NULL, - ephy_marshal_BOOLEAN__BOXED, - G_TYPE_BOOLEAN, - 1, - GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE); - -/** - * EphyEmbed::close-request - * @embed: - * - * The ::close signal is emitted when the embed request closing. - * Return %TRUE to prevent closing. You HAVE to process removal of the embed - * as soon as possible after that. - **/ - g_signal_new ("close-request", - EPHY_TYPE_EMBED, - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EphyEmbedIface, close_request), - g_signal_accumulator_true_handled, NULL, - ephy_marshal_BOOLEAN__VOID, - G_TYPE_BOOLEAN, - 0); -/** - * EphyEmbed::content-blocked: - * @embed: - * @uri: blocked URI - * - * The ::content-blocked signal is emitted when an url has been blocked. - **/ - g_signal_new ("content-blocked", - EPHY_TYPE_EMBED, - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EphyEmbedIface, content_blocked), - NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, - 1, - G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE); -/** - * EphyEmbed::new-document-now: - * @embed: - * @uri: URI of the new content - * - * The ::new-document-now signal is emitted when a new page content - * is being loaded into the browser. It's a good place to do view - * related changes, for example to restore the zoom level of a page - * or to set an user style sheet. - **/ - g_signal_new ("new-document-now", - EPHY_TYPE_EMBED, - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EphyEmbedIface, new_document_now), - NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, - 1, - G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE); - - - initialized = TRUE; - } - -} - -/** - * ephy_embed_can_go_up: - * @embed: an #EphyEmbed - * - * Returns whether @embed can travel to a higher-level directory on the server. - * For example, for http://www.example.com/subdir/index.html, returns %TRUE; for - * http://www.example.com/index.html, returns %FALSE. - * - * Return value: %TRUE if @embed can browse to a higher-level directory - **/ -gboolean -ephy_embed_can_go_up (EphyEmbed *embed) -{ - EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed); - return iface->can_go_up (embed); -} - -/** - * ephy_embed_get_go_up_list: - * @embed: an #EphyEmbed - * - * Returns a list of (%char *) URLs to higher-level directories on the same - * server, in order of deepest to shallowest. For example, given - * "http://www.example.com/dir/subdir/file.html", will return a list containing - * "http://www.example.com/dir/subdir/", "http://www.example.com/dir/" and - * "http://www.example.com/". - * - * Return value: a list of URLs higher up in @embed's web page's directory - * hierarchy - **/ -GSList * -ephy_embed_get_go_up_list (EphyEmbed *embed) -{ - EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed); - return iface->get_go_up_list (embed); -} - -/** - * ephy_embed_go_up: - * @embed: an #EphyEmbed - * - * Moves @embed one level up in its web page's directory hierarchy. - **/ -void -ephy_embed_go_up (EphyEmbed *embed) -{ - EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed); - iface->go_up (embed); -} - -/** - * ephy_embed_get_title: - * @embed: an #EphyEmbed - * - * Return value: the title of the web page displayed in @embed - **/ -const char * -ephy_embed_get_title (EphyEmbed *embed) -{ - EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed); - return iface->get_title (embed); -} - -/** - * ephy_embed_get_location: - * @embed: an #EphyEmbed - * @toplevel: %FALSE to return the location of the focused frame only - * - * Returns the URL of the web page displayed in @embed. - * - * If the web page contains frames, @toplevel will determine which location to - * retrieve. If @toplevel is %TRUE, the return value will be the location of the - * frameset document. If @toplevel is %FALSE, the return value will be the - * location of the currently-focused frame. - * - * Return value: the URL of the web page displayed in @embed - **/ -char * -ephy_embed_get_location (EphyEmbed *embed, - gboolean toplevel) -{ - EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed); - return iface->get_location (embed, toplevel); -} - -/** - * ephy_embed_get_link_message: - * @embed: an #EphyEmbed - * - * When the user is hovering the mouse over a hyperlink, returns the URL of the - * hyperlink. - * - * Return value: the URL of the link over which the mouse is hovering - **/ -const char * -ephy_embed_get_link_message (EphyEmbed *embed) -{ - EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed); - return iface->get_link_message (embed); -} - -/** - * ephy_embed_get_js_status: - * @embed: an #EphyEmbed - * - * Displays the message JavaScript is attempting to display in the statusbar. - * - * Note that Epiphany does not display JavaScript statusbar messages. - * - * Return value: a message from JavaScript meant to be displayed in the - * statusbar - **/ -char * -ephy_embed_get_js_status (EphyEmbed *embed) -{ - EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed); - return iface->get_js_status (embed); -} - -/** - * ephy_embed_get_security_level: - * @embed: an #EphyEmbed - * @level: return value of security level - * @description: return value of the description of the security level - * - * Fetches the #EphyEmbedSecurityLevel and a newly-allocated string description - * of the security state of @embed. - **/ -void -ephy_embed_get_security_level (EphyEmbed *embed, - EphyEmbedSecurityLevel *level, - char **description) -{ - EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed); - iface->get_security_level (embed, level, description); -} -/** - * ephy_embed_show_page_certificate: - * @embed: an #EphyEmbed - * - * Shows a dialogue displaying the certificate of the currently loaded page - * of @embed, if it was loaded over a secure connection; else does nothing. - **/ -void -ephy_embed_show_page_certificate (EphyEmbed *embed) -{ - EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed); - iface->show_page_certificate (embed); -} - -/** - * ephy_embed_set_print_preview_mode: - * @embed: an #EphyEmbed - * @preview_mode: Whether the print preview mode is enabled. - * - * Enable and disable the print preview mode. - **/ -void -ephy_embed_set_print_preview_mode (EphyEmbed *embed, - gboolean preview_mode) -{ - EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed); - iface->set_print_preview_mode (embed, preview_mode); -} - -/** - * ephy_embed_print_preview_n_pages: - * @embed: an #EphyEmbed - * - * Returns the number of pages which would appear in @embed's loaded document - * if it were to be printed. - * - * Return value: the number of pages in @embed's loaded document - **/ -int -ephy_embed_print_preview_n_pages (EphyEmbed *embed) -{ - EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed); - return iface->print_preview_n_pages (embed); -} - -/** - * ephy_embed_print_preview_navigate: - * @embed: an #EphyEmbed - * @type: an #EphyPrintPreviewNavType which determines where to navigate - * @page: if @type is %EPHY_EMBED_PRINTPREVIEW_GOTO_PAGENUM, the desired page number - * - * Navigates @embed's print preview. - **/ -void -ephy_embed_print_preview_navigate (EphyEmbed *embed, - EphyEmbedPrintPreviewNavType type, - int page) -{ - EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed); - iface->print_preview_navigate (embed, type, page); -} - -/** - * ephy_embed_has_modified_forms: - * @embed: an #EphyEmbed - * - * Returns %TRUE if the user has modified <input> or <textarea> - * values in @embed's loaded document. - * - * Return value: %TRUE if @embed has user-modified forms - **/ -gboolean -ephy_embed_has_modified_forms (EphyEmbed *embed) -{ - EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed); - return iface->has_modified_forms (embed); -} - -/** - * ephy_embed_get_document_type: - * @embed: an #EphyEmbed - * - * Returns the type of document loaded in the @embed - * - * Return value: the #EphyEmbedDocumentType - **/ -EphyEmbedDocumentType -ephy_embed_get_document_type (EphyEmbed *embed) -{ - EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed); - return iface->get_document_type (embed); -} - -/** - * ephy_embed_get_load_percent: - * @embed: an #EphyEmbed - * - * Returns the page load percentage (displayed in the progressbar). - * - * Return value: a percentage from 0 to 100. - **/ -int -ephy_embed_get_load_percent (EphyEmbed *embed) -{ - EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed); - return iface->get_load_percent (embed); -} - -/** - * ephy_embed_get_load_status: - * @embed: an #EphyEmbed - * - * Returns whether the web page in @embed has finished loading. A web page is - * only finished loading after all images, styles, and other dependencies have - * been downloaded and rendered. - * - * Return value: %TRUE if the page is still loading, %FALSE if complete - **/ -gboolean -ephy_embed_get_load_status (EphyEmbed *embed) -{ - EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed); - return iface->get_load_status (embed); -} - -/** - * ephy_embed_get_navigation_flags: - * @embed: an #EphyEmbed - * - * Returns @embed's navigation flags. - * - * Return value: @embed's navigation flags - **/ -EphyEmbedNavigationFlags -ephy_embed_get_navigation_flags (EphyEmbed *embed) -{ - EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed); - return iface->get_navigation_flags (embed); -} - -/** - * ephy_embed_get_typed_address: - * @embed: an #EphyEmbed - * - * Returns the text that @embed's #EphyWindow will display in its location toolbar - * entry when @embed is selected. - * - * This is not guaranteed to be the same as @embed's location, - * available through ephy_embed_get_location(). As the user types a new address - * into the location entry, ephy_embed_get_location()'s returned string will - * change. - * - * Return value: @embed's #EphyWindow's location entry when @embed is selected - **/ -const char * -ephy_embed_get_typed_address (EphyEmbed *embed) -{ - EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed); - return iface->get_typed_address (embed); -} - -/** - * ephy_embed_set_typed_address: - * @embed: an #EphyEmbed - * @address: the new typed address, or %NULL to clear it - * @expire: when to expire this address_expire - * - * Sets the text that @embed's #EphyWindow will display in its location toolbar - * entry when @embed is selected. - **/ -void -ephy_embed_set_typed_address (EphyEmbed *embed, - const char *address, - EphyEmbedAddressExpire expire) -{ - EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed); - return iface->set_typed_address (embed, address, expire); -} - -/** - * ephy_embed_get_address: - * @embed: an #EphyEmbed - * - * Returns the address of the currently loaded page. - * - * Return value: @embed's address. Will never be %NULL. - **/ -const char * -ephy_embed_get_address (EphyEmbed *embed) -{ - EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed); - return iface->get_address (embed); -} - -/** - * ephy_embed_get_status_message: - * @embed: an #EphyEmbed - * - * Returns the message displayed in @embed's #EphyWindow's - * #EphyStatusbar. If the user is hovering the mouse over a hyperlink, - * this function will return the same value as - * ephy_embed_get_link_message(). Otherwise, it will return a network - * status message, or NULL. - * - * The message returned has a limited lifetime, and so should be copied with - * g_strdup() if it must be stored. - * - * Return value: The current statusbar message - **/ -const char * -ephy_embed_get_status_message (EphyEmbed *embed) -{ - EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed); - return iface->get_status_message (embed); -} - -/** - * ephy_embed_get_icon: - * @embed: an #EphyEmbed - * - * Returns the embed's site icon as a #GdkPixbuf, - * or %NULL if it is not available. - * - * Return value: a the embed's site icon - **/ -GdkPixbuf * -ephy_embed_get_icon (EphyEmbed *embed) -{ - EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed); - return iface->get_icon (embed); -} - -/** - * ephy_embed_get_icon_address: - * @embed: an #EphyEmbed - * - * Returns a URL which points to @embed's site icon. - * - * Return value: the URL of @embed's site icon - **/ -const char * -ephy_embed_get_icon_address (EphyEmbed *embed) -{ - EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed); - return iface->get_icon_address (embed); -} - -/** - * ephy_embed_get_is_blank: - * @embed: an #EphyEmbed - * - * Returns whether the @embed's address is "blank". - * - * Return value: %TRUE if the @embed's address is "blank" - **/ -gboolean -ephy_embed_get_is_blank (EphyEmbed *embed) -{ - EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed); - return iface->get_is_blank (embed); -} - -const char * -ephy_embed_get_loading_title (EphyEmbed *embed) -{ - EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed); - return iface->get_loading_title (embed); -} - -/** - * ephy_embed_get_visibility: - * @embed: an #EphyEmbed - * - * Returns whether the @embed's toplevel is visible or not. Used - * mostly for popup visibility management. - * - * Return value: %TRUE if @embed's "visibility" property is set - **/ -gboolean -ephy_embed_get_visibility (EphyEmbed *embed) -{ - EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed); - return iface->get_visibility (embed); -} diff --git a/embed/ephy-embed.h b/embed/ephy-embed.h deleted file mode 100644 index 2f48763c4..000000000 --- a/embed/ephy-embed.h +++ /dev/null @@ -1,276 +0,0 @@ -/* - * Copyright © 2000-2003 Marco Pesenti Gritti - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#if !defined (__EPHY_EPIPHANY_H_INSIDE__) && !defined (EPIPHANY_COMPILATION) -#error "Only <epiphany/epiphany.h> can be included directly." -#endif - -#ifndef EPHY_EMBED_H -#define EPHY_EMBED_H - -#include "ephy-embed-event.h" - -#include <glib-object.h> -#include <glib.h> -#include <gtk/gtk.h> - -G_BEGIN_DECLS - -#define EPHY_TYPE_EMBED (ephy_embed_get_type ()) -#define EPHY_EMBED(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EPHY_TYPE_EMBED, EphyEmbed)) -#define EPHY_EMBED_IFACE(k) (G_TYPE_CHECK_CLASS_CAST((k), EPHY_TYPE_EMBED, EphyEmbedIface)) -#define EPHY_IS_EMBED(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EPHY_TYPE_EMBED)) -#define EPHY_IS_EMBED_IFACE(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_EMBED)) -#define EPHY_EMBED_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), EPHY_TYPE_EMBED, EphyEmbedIface)) - -typedef struct _EphyEmbed EphyEmbed; -typedef struct _EphyEmbedIface EphyEmbedIface; - -typedef enum -{ - EPHY_EMBED_STATE_UNKNOWN = 0, - EPHY_EMBED_STATE_START = 1 << 0, - EPHY_EMBED_STATE_REDIRECTING = 1 << 1, - EPHY_EMBED_STATE_TRANSFERRING = 1 << 2, - EPHY_EMBED_STATE_NEGOTIATING = 1 << 3, - EPHY_EMBED_STATE_STOP = 1 << 4, - - EPHY_EMBED_STATE_IS_REQUEST = 1 << 5, - EPHY_EMBED_STATE_IS_DOCUMENT = 1 << 6, - EPHY_EMBED_STATE_IS_NETWORK = 1 << 7, - EPHY_EMBED_STATE_IS_WINDOW = 1 << 8, - EPHY_EMBED_STATE_RESTORING = 1 << 9 -} EphyEmbedNetState; - -typedef enum -{ - EPHY_EMBED_CHROME_MENUBAR = 1 << 0, - EPHY_EMBED_CHROME_TOOLBAR = 1 << 1, - EPHY_EMBED_CHROME_STATUSBAR = 1 << 2, - EPHY_EMBED_CHROME_BOOKMARKSBAR = 1 << 3 -} EphyEmbedChrome; - -#define EPHY_EMBED_CHROME_ALL (EPHY_EMBED_CHROME_MENUBAR | \ - EPHY_EMBED_CHROME_TOOLBAR | \ - EPHY_EMBED_CHROME_STATUSBAR | \ - EPHY_EMBED_CHROME_BOOKMARKSBAR) - -typedef enum -{ - EPHY_EMBED_PRINTPREVIEW_GOTO_PAGENUM = 0, - EPHY_EMBED_PRINTPREVIEW_PREV_PAGE = 1, - EPHY_EMBED_PRINTPREVIEW_NEXT_PAGE = 2, - EPHY_EMBED_PRINTPREVIEW_HOME = 3, - EPHY_EMBED_PRINTPREVIEW_END = 4 -} EphyEmbedPrintPreviewNavType; - -typedef enum -{ - EPHY_EMBED_STATE_IS_UNKNOWN, - EPHY_EMBED_STATE_IS_INSECURE, - EPHY_EMBED_STATE_IS_BROKEN, - EPHY_EMBED_STATE_IS_SECURE_LOW, - EPHY_EMBED_STATE_IS_SECURE_MED, - EPHY_EMBED_STATE_IS_SECURE_HIGH -} EphyEmbedSecurityLevel; - -typedef enum -{ - EPHY_EMBED_DOCUMENT_HTML, - EPHY_EMBED_DOCUMENT_XML, - EPHY_EMBED_DOCUMENT_IMAGE, - EPHY_EMBED_DOCUMENT_OTHER -} EphyEmbedDocumentType; - -typedef enum -{ - EPHY_EMBED_NAV_UP = 1 << 0, - EPHY_EMBED_NAV_BACK = 1 << 1, - EPHY_EMBED_NAV_FORWARD = 1 << 2 -} EphyEmbedNavigationFlags; - -typedef enum -{ - EPHY_EMBED_ADDRESS_EXPIRE_NOW, - EPHY_EMBED_ADDRESS_EXPIRE_NEXT, - EPHY_EMBED_ADDRESS_EXPIRE_CURRENT -} EphyEmbedAddressExpire; - -struct _EphyEmbedIface -{ - GTypeInterface base_iface; - - int (* context_menu) (EphyEmbed *embed, - EphyEmbedEvent *event); - void (* favicon) (EphyEmbed *embed, - const char *location); - void (* feed_link) (EphyEmbed *embed, - const char *type, - const char *title, - const char *address); - void (* search_link) (EphyEmbed *embed, - const char *type, - const char *title, - const char *address); - gboolean (* dom_mouse_click) (EphyEmbed *embed, - EphyEmbedEvent *event); - gboolean (* dom_mouse_down) (EphyEmbed *embed, - EphyEmbedEvent *event); - void (* dom_content_loaded) (EphyEmbed *embed, - gpointer event); - void (* popup_blocked) (EphyEmbed *embed, - const char *address, - const char *target, - const char *features); - void (* content_blocked) (EphyEmbed *embed, - const char *uri); - gboolean (* modal_alert) (EphyEmbed *embed); - void (* modal_alert_closed) (EphyEmbed *embed); - void (* document_type) (EphyEmbed *embed, - EphyEmbedDocumentType type); - void (* new_window) (EphyEmbed *embed, - EphyEmbed *new_embed); - gboolean (* search_key_press) (EphyEmbed *embed, - GdkEventKey *event); - gboolean (* close_request) (EphyEmbed *embed); - - void (* new_document_now) (EphyEmbed *embed, - const char *uri); - - /* Methods */ - gboolean (* can_go_up) (EphyEmbed *embed); - GSList * (* get_go_up_list) (EphyEmbed *embed); - void (* go_up) (EphyEmbed *embed); - const char * (* get_title) (EphyEmbed *embed); - char * (* get_location) (EphyEmbed *embed, - gboolean toplevel); - const char * (* get_link_message) (EphyEmbed *embed); - char * (* get_js_status) (EphyEmbed *embed); - void (* get_security_level) (EphyEmbed *embed, - EphyEmbedSecurityLevel *level, - char **description); - void (* show_page_certificate) (EphyEmbed *embed); - void (* set_print_preview_mode) (EphyEmbed *embed, - gboolean mode); - int (* print_preview_n_pages) (EphyEmbed *embed); - void (* print_preview_navigate) (EphyEmbed *embed, - EphyEmbedPrintPreviewNavType type, - int page); - gboolean (* has_modified_forms) (EphyEmbed *embed); - EphyEmbedDocumentType (* get_document_type) (EphyEmbed *embed); - int (* get_load_percent) (EphyEmbed *embed); - gboolean (* get_load_status) (EphyEmbed *embed); - EphyEmbedNavigationFlags (* get_navigation_flags) (EphyEmbed *embed); - const char * (* get_typed_address) (EphyEmbed *embed); - void (* set_typed_address) (EphyEmbed *embed, - const char *address, - EphyEmbedAddressExpire expire); - const char * (* get_address) (EphyEmbed *embed); - const char * (* get_status_message) (EphyEmbed *embed); - GdkPixbuf * (* get_icon) (EphyEmbed *embed); - const char * (* get_icon_address) (EphyEmbed *embed); - gboolean (* get_is_blank) (EphyEmbed *embed); - const char * (* get_loading_title) (EphyEmbed *embed); - gboolean (* get_visibility) (EphyEmbed *embed); -}; - -GType ephy_embed_net_state_get_type (void); - -GType ephy_embed_chrome_get_type (void); - -GType ephy_embed_security_level_get_type (void); - -GType ephy_embed_document_type_get_type (void); - -GType ephy_embed_get_type (void); - -/* Base */ -const char *ephy_embed_get_title (EphyEmbed *embed); - -char *ephy_embed_get_location (EphyEmbed *embed, - gboolean toplevel); -const char *ephy_embed_get_link_message (EphyEmbed *embed); - -char *ephy_embed_get_js_status (EphyEmbed *embed); - -/* Navigation */ -gboolean ephy_embed_can_go_up (EphyEmbed *embed); - -GSList *ephy_embed_get_go_up_list (EphyEmbed *embed); - -void ephy_embed_go_up (EphyEmbed *embed); - -void ephy_embed_get_security_level (EphyEmbed *embed, - EphyEmbedSecurityLevel *level, - char **description); - -void ephy_embed_show_page_certificate (EphyEmbed *embed); - -/* Document type */ -EphyEmbedDocumentType ephy_embed_get_document_type (EphyEmbed *embed); - -/* Progress */ -int ephy_embed_get_load_percent (EphyEmbed *embed); - -/* Load status */ -gboolean ephy_embed_get_load_status (EphyEmbed *embed); - -/* Navigation flags */ - -EphyEmbedNavigationFlags ephy_embed_get_navigation_flags (EphyEmbed *embed); - -/* Typed address */ -const char *ephy_embed_get_typed_address (EphyEmbed *embed); -void ephy_embed_set_typed_address (EphyEmbed *embed, - const char *address, - EphyEmbedAddressExpire expire); -/* Address */ -const char * ephy_embed_get_address (EphyEmbed *embed); - -/* Status messages */ -const char * ephy_embed_get_status_message (EphyEmbed *embed); - -/* Icon and Icon Address */ - -GdkPixbuf * ephy_embed_get_icon (EphyEmbed *embed); -const char * ephy_embed_get_icon_address (EphyEmbed *embed); - -/* Is blank */ -gboolean ephy_embed_get_is_blank (EphyEmbed *embed); - -const char * ephy_embed_get_loading_title (EphyEmbed *embed); - -gboolean ephy_embed_get_visibility (EphyEmbed *embed); - -/* Print */ -void ephy_embed_set_print_preview_mode (EphyEmbed *embed, - gboolean preview_mode); - -int ephy_embed_print_preview_n_pages (EphyEmbed *embed); - -void ephy_embed_print_preview_navigate (EphyEmbed *embed, - EphyEmbedPrintPreviewNavType type, - int page); - -/* Misc. utility */ -gboolean ephy_embed_has_modified_forms (EphyEmbed *embed); - -G_END_DECLS - -#endif diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c index 10e6d3475..3f1c40179 100644 --- a/embed/ephy-web-view.c +++ b/embed/ephy-web-view.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* * Copyright © 2008 Gustavo Noronha Silva + * Copyright © 2009 Igalia S.L. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,26 +21,1027 @@ #include "config.h" -#include "ephy-web-view.h" -#include "ephy-debug.h" -#include "ephy-embed-utils.h" - +#include <gio/gio.h> +#include <glib/gi18n.h> #include <gtk/gtk.h> +#include <string.h> #include <webkit/webkit.h> +#include "eel-gconf-extensions.h" +#include "ephy-base-embed.h" +#include "ephy-debug.h" +#include "ephy-embed.h" +#include "ephy-embed-container.h" +#include "ephy-embed-prefs.h" +#include "ephy-embed-shell.h" +#include "ephy-embed-single.h" +#include "ephy-embed-type-builtins.h" +#include "ephy-embed-utils.h" +#include "ephy-marshal.h" +#include "ephy-permission-manager.h" +#include "ephy-favicon-cache.h" +#include "ephy-history.h" +#include "ephy-string.h" +#include "ephy-web-view.h" +#include "ephy-zoom.h" + static void ephy_web_view_class_init (EphyWebViewClass *klass); static void ephy_web_view_init (EphyWebView *gs); +#define MAX_HIDDEN_POPUPS 5 +#define MAX_TITLE_LENGTH 512 /* characters */ +#define RELOAD_DELAY 250 /* ms */ +#define RELOAD_DELAY_MAX_TICKS 40 /* RELOAD_DELAY * RELOAD_DELAY_MAX_TICKS = 10 s */ +#define EMPTY_PAGE _("Blank page") /* Title for the empty page */ + +struct _EphyWebViewPrivate { + EphyWebViewAddressExpire address_expire; + EphyWebViewSecurityLevel security_level; + EphyWebViewDocumentType document_type; + EphyWebViewNavigationFlags nav_flags; + + /* Flags */ + guint is_blank : 1; + guint is_loading : 1; + guint visibility : 1; + + char *address; + char *typed_address; + char *title; + int cur_requests; + int total_requests; + gint8 load_percent; + char *loading_title; + char *status_message; + char *link_message; + char *icon_address; + GdkPixbuf *icon; + + /* File watch */ + GFileMonitor *monitor; + gboolean monitor_directory; + guint reload_scheduled_id; + guint reload_delay_ticks; + + GSList *hidden_popups; + GSList *shown_popups; +}; + +typedef struct { + char *url; + char *name; + char *features; +} PopupInfo; + +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_EMBED_TITLE, + PROP_TYPED_ADDRESS, + PROP_VISIBLE, +}; + +#define EPHY_WEB_VIEW_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_WEB_VIEW, EphyWebViewPrivate)) + G_DEFINE_TYPE (EphyWebView, ephy_web_view, WEBKIT_TYPE_WEB_VIEW) +static guint +popup_blocker_n_hidden (EphyWebView *view) +{ + return g_slist_length (view->priv->hidden_popups); +} + +static void +popups_manager_free_info (PopupInfo *popup) +{ + g_free (popup->url); + g_free (popup->name); + g_free (popup->features); + g_slice_free (PopupInfo, popup); +} + +static void +popups_manager_show (PopupInfo *popup, + EphyWebView *view) +{ + EphyEmbedSingle *single; + + /* Only show popup with non NULL url */ + if (popup->url != NULL) { + single = EPHY_EMBED_SINGLE + (ephy_embed_shell_get_embed_single (embed_shell)); + + ephy_embed_single_open_window (single, EPHY_EMBED (view), popup->url, + popup->name, popup->features); + } + popups_manager_free_info (popup); +} + +static void +popups_manager_show_all (EphyWebView *view) +{ + LOG ("popup_blocker_show_all: view %p", view); + + g_slist_foreach (view->priv->hidden_popups, + (GFunc)popups_manager_show, view); + g_slist_free (view->priv->hidden_popups); + view->priv->hidden_popups = NULL; + + g_object_notify (G_OBJECT (view), "hidden-popup-count"); +} + +static char * +popups_manager_new_window_info (EphyEmbedContainer *container) +{ + EphyEmbed *embed; + EphyWebViewChrome chrome; + gboolean is_popup; + char *features; + + g_object_get (container, "chrome", &chrome, "is-popup", &is_popup, NULL); + g_return_val_if_fail (is_popup, g_strdup ("")); + + embed = ephy_embed_container_get_active_child (container); + g_return_val_if_fail (embed != NULL, g_strdup ("")); + + features = g_strdup_printf + ("width=%d,height=%d,menubar=%d,status=%d,toolbar=%d", + GTK_WIDGET (embed)->allocation.width, + GTK_WIDGET (embed)->allocation.height, + (chrome & EPHY_WEB_VIEW_CHROME_MENUBAR) > 0, + (chrome & EPHY_WEB_VIEW_CHROME_STATUSBAR) > 0, + (chrome & EPHY_WEB_VIEW_CHROME_TOOLBAR) > 0); + + return features; +} + +static void +popups_manager_add (EphyWebView *view, + const char *url, + const char *name, + const char *features) +{ + EphyWebViewPrivate *priv = view->priv; + PopupInfo *popup; + + LOG ("popups_manager_add: view %p, url %s, features %s", + view, url, features); + + popup = g_slice_new (PopupInfo); + + popup->url = g_strdup (url); + popup->name = g_strdup (name); + popup->features = g_strdup (features); + + priv->hidden_popups = g_slist_prepend (priv->hidden_popups, popup); + + if (popup_blocker_n_hidden (view) > MAX_HIDDEN_POPUPS) {/* bug #160863 */ + /* Remove the oldest popup */ + GSList *l = view->priv->hidden_popups; + + while (l->next->next != NULL) { + l = l->next; + } + + popup = (PopupInfo *)l->next->data; + popups_manager_free_info (popup); + + l->next = NULL; + } else { + g_object_notify (G_OBJECT (view), "hidden-popup-count"); + } +} + +static void +popups_manager_hide (EphyEmbedContainer *container, + EphyWebView *parent_view) +{ + EphyEmbed *embed; + char *location; + char *features; + + embed = ephy_embed_container_get_active_child (container); + g_return_if_fail (EPHY_IS_EMBED (embed)); + + location = ephy_web_view_get_location (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed), TRUE); + if (location == NULL) return; + + features = popups_manager_new_window_info (container); + + popups_manager_add (parent_view, location, "" /* FIXME? maybe _blank? */, features); + + gtk_widget_destroy (GTK_WIDGET (container)); + + g_free (location); + g_free (features); +} + +static void +popups_manager_hide_all (EphyWebView *view) +{ + LOG ("popup_blocker_hide_all: view %p", view); + + g_slist_foreach (view->priv->shown_popups, + (GFunc)popups_manager_hide, view); + g_slist_free (view->priv->shown_popups); + view->priv->shown_popups = NULL; +} + +static void +ephy_web_view_set_popups_allowed (EphyWebView *view, + gboolean allowed) +{ + char *location; + EphyPermissionManager *manager; + EphyPermission permission; + + location = ephy_web_view_get_location (view, TRUE); + g_return_if_fail (location != NULL); + + manager = EPHY_PERMISSION_MANAGER + (ephy_embed_shell_get_embed_single (embed_shell)); + g_return_if_fail (EPHY_IS_PERMISSION_MANAGER (manager)); + + permission = allowed ? EPHY_PERMISSION_ALLOWED + : EPHY_PERMISSION_DENIED; + + ephy_permission_manager_add_permission (manager, location, EPT_POPUP, permission); + + if (allowed) { + popups_manager_show_all (view); + } else { + popups_manager_hide_all (view); + } + + g_free (location); +} + +static gboolean +ephy_web_view_get_popups_allowed (EphyWebView *view) +{ + EphyPermissionManager *permission_manager; + EphyPermission response; + char *location; + gboolean allow; + + permission_manager = EPHY_PERMISSION_MANAGER + (ephy_embed_shell_get_embed_single (embed_shell)); + g_return_val_if_fail (EPHY_IS_PERMISSION_MANAGER (permission_manager), + FALSE); + + location = ephy_web_view_get_location (view, TRUE); + if (location == NULL) return FALSE;/* FALSE, TRUE… same thing */ + + response = ephy_permission_manager_test_permission + (permission_manager, location, EPT_POPUP); + + switch (response) { + case EPHY_PERMISSION_ALLOWED: + allow = TRUE; + break; + case EPHY_PERMISSION_DENIED: + allow = FALSE; + break; + case EPHY_PERMISSION_DEFAULT: + default: + allow = eel_gconf_get_boolean + (CONF_SECURITY_ALLOW_POPUPS); + break; + } + + g_free (location); + + LOG ("ephy_web_view_get_popups_allowed: view %p, allowed: %d", view, allow); + + return allow; +} + +static gboolean +popups_manager_remove_window (EphyWebView *view, + EphyEmbedContainer *container) +{ + view->priv->shown_popups = g_slist_remove (view->priv->shown_popups, + container); + + return FALSE; +} + +static void +popups_manager_add_window (EphyWebView *view, + EphyEmbedContainer *container) +{ + LOG ("popups_manager_add_window: view %p, container %p", view, container); + + view->priv->shown_popups = g_slist_prepend (view->priv->shown_popups, container); + + g_signal_connect_swapped (container, "destroy", + G_CALLBACK (popups_manager_remove_window), + view); +} + +static void +disconnect_popup (EphyEmbedContainer *container, + EphyWebView *view) +{ + g_signal_handlers_disconnect_by_func + (container, G_CALLBACK (popups_manager_remove_window), view); +} + +void +ephy_web_view_popups_manager_reset (EphyWebView *view) +{ + g_slist_foreach (view->priv->hidden_popups, + (GFunc)popups_manager_free_info, NULL); + g_slist_free (view->priv->hidden_popups); + view->priv->hidden_popups = NULL; + + g_slist_foreach (view->priv->shown_popups, + (GFunc)disconnect_popup, view); + g_slist_free (view->priv->shown_popups); + view->priv->shown_popups = NULL; + + g_object_notify (G_OBJECT (view), "hidden-popup-count"); + g_object_notify (G_OBJECT (view), "popups-allowed"); +} + +static void +ephy_web_view_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + EphyWebViewPrivate *priv = EPHY_WEB_VIEW (object)->priv; + + switch (prop_id) { + case PROP_ADDRESS: + g_value_set_string (value, priv->address); + break; + case PROP_LOAD_STATUS: + g_value_set_boolean (value, priv->is_loading); + break; + case PROP_EMBED_TITLE: + g_value_set_string (value, priv->title); + break; + case PROP_TYPED_ADDRESS: + g_value_set_string (value, priv->typed_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, popup_blocker_n_hidden + (EPHY_WEB_VIEW (object))); + 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_NAVIGATION: + g_value_set_flags (value, priv->nav_flags); + break; + case PROP_POPUPS_ALLOWED: + g_value_set_boolean (value, ephy_web_view_get_popups_allowed + (EPHY_WEB_VIEW (object))); + 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_VISIBLE: + g_value_set_boolean (value, priv->visibility); + break; + default: + break; + } +} + +static void +ephy_web_view_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (prop_id) { + case PROP_ICON_ADDRESS: + ephy_web_view_set_icon_address (EPHY_WEB_VIEW (object), g_value_get_string (value)); + break; + case PROP_POPUPS_ALLOWED: + ephy_web_view_set_popups_allowed (EPHY_WEB_VIEW (object), g_value_get_boolean (value)); + break; + case PROP_TYPED_ADDRESS: + ephy_web_view_set_typed_address (EPHY_WEB_VIEW (object), g_value_get_string (value), + EPHY_WEB_VIEW_ADDRESS_EXPIRE_NOW); + break; + break; + case PROP_ADDRESS: + case PROP_DOCUMENT_TYPE: + case PROP_HIDDEN_POPUP_COUNT: + case PROP_ICON: + case PROP_LINK_MESSAGE: + case PROP_LOAD_PROGRESS: + case PROP_LOAD_STATUS: + case PROP_NAVIGATION: + case PROP_SECURITY: + case PROP_STATUS_MESSAGE: + case PROP_EMBED_TITLE: + case PROP_VISIBLE: + /* read only */ + break; + default: + break; + } +} + +static void +ephy_web_view_file_monitor_cancel (EphyWebView *view) +{ + EphyWebViewPrivate *priv = view->priv; + + if (priv->monitor != NULL) { + LOG ("Cancelling file monitor"); + + g_file_monitor_cancel (G_FILE_MONITOR (priv->monitor)); + priv->monitor = NULL; + } + + if (priv->reload_scheduled_id != 0) { + LOG ("Cancelling scheduled reload"); + + g_source_remove (priv->reload_scheduled_id); + priv->reload_scheduled_id = 0; + } + + priv->reload_delay_ticks = 0; +} + +static void +ephy_web_view_dispose (GObject *object) +{ + ephy_web_view_file_monitor_cancel (EPHY_WEB_VIEW (object)); + + G_OBJECT_CLASS (ephy_web_view_parent_class)->dispose (object); +} + +static void +ephy_web_view_finalize (GObject *object) +{ + EphyWebViewPrivate *priv = EPHY_WEB_VIEW (object)->priv; + + if (priv->icon != NULL) { + g_object_unref (priv->icon); + priv->icon = NULL; + } + + ephy_web_view_popups_manager_reset (EPHY_WEB_VIEW (object)); + + g_free (priv->address); + g_free (priv->typed_address); + g_free (priv->title); + g_free (priv->icon_address); + g_free (priv->status_message); + g_free (priv->link_message); + g_free (priv->loading_title); + + G_OBJECT_CLASS (ephy_web_view_parent_class)->finalize (object); +} + static void ephy_web_view_class_init (EphyWebViewClass *klass) { + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + + gobject_class->dispose = ephy_web_view_dispose; + gobject_class->finalize = ephy_web_view_finalize; + gobject_class->get_property = ephy_web_view_get_property; + gobject_class->set_property = ephy_web_view_set_property; + + g_object_class_install_property (gobject_class, + PROP_ADDRESS, + g_param_spec_string ("address", + "Address", + "The view's address", + "", + G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); + g_object_class_install_property (gobject_class, + PROP_TYPED_ADDRESS, + g_param_spec_string ("typed-address", + "Typed Address", + "The typed address", + "", + G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); + g_object_class_install_property (gobject_class, + PROP_EMBED_TITLE, + g_param_spec_string ("embed-title", + "Title", + "The view's title", + EMPTY_PAGE, + G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); + + g_object_class_install_property (gobject_class, + PROP_SECURITY, + g_param_spec_enum ("security-level", + "Security Level", + "The view's security level", + EPHY_TYPE_WEB_VIEW_SECURITY_LEVEL, + EPHY_WEB_VIEW_STATE_IS_UNKNOWN, + G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); + g_object_class_install_property (gobject_class, + PROP_DOCUMENT_TYPE, + g_param_spec_enum ("document-type", + "Document Type", + "The view's documen type", + EPHY_TYPE_WEB_VIEW_DOCUMENT_TYPE, + EPHY_WEB_VIEW_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_LOAD_PROGRESS, + g_param_spec_int ("load-progress", + "Load progress", + "The view's load progress in percent", + 0, + 100, + 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_STATUS, + g_param_spec_boolean ("load-status", + "Load status", + "The view's load status", + FALSE, + G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); + g_object_class_install_property (gobject_class, + PROP_NAVIGATION, + g_param_spec_flags ("navigation", + "Navigation flags", + "The view's navigation flags", + EPHY_TYPE_WEB_VIEW_NAVIGATION_FLAGS, + 0, + G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); + g_object_class_install_property (gobject_class, + PROP_STATUS_MESSAGE, + g_param_spec_string ("status-message", + "Status Message", + "The view's statusbar message", + NULL, + G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); + g_object_class_install_property (gobject_class, + PROP_LINK_MESSAGE, + g_param_spec_string ("link-message", + "Link Message", + "The view's link message", + NULL, + G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); + g_object_class_install_property (gobject_class, + PROP_ICON, + g_param_spec_object ("icon", + "Icon", + "The view icon's", + GDK_TYPE_PIXBUF, + G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); + + g_object_class_install_property (gobject_class, + PROP_ICON_ADDRESS, + g_param_spec_string ("icon-address", + "Icon address", + "The view icon's address", + NULL, + (G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB))); + g_object_class_install_property (gobject_class, + PROP_HIDDEN_POPUP_COUNT, + g_param_spec_int ("hidden-popup-count", + "Number of Blocked Popups", + "The view's number of blocked popup windows", + 0, + G_MAXINT, + 0, + G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); + + g_object_class_install_property (gobject_class, + PROP_POPUPS_ALLOWED, + g_param_spec_boolean ("popups-allowed", + "Popups Allowed", + "Whether popup windows are to be displayed", + FALSE, + G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); + + g_object_class_install_property (gobject_class, + PROP_VISIBLE, + g_param_spec_boolean ("visibility", + "Visibility", + "The view's visibility", + FALSE, + G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); + +/** + * EphyWebView::ge-new-window: + * @view: + * @new_view: the newly opened #EphyWebView + * + * The ::ge_new_window signal is emitted after a new window has been opened by + * the view. For example, when a JavaScript popup window is opened. + **/ + g_signal_new ("ge_new_window", + EPHY_TYPE_WEB_VIEW, + G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EphyWebViewClass, new_window), + NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, + 1, + GTK_TYPE_WIDGET); +/** + * EphyWebView::ge-popup-blocked: + * @view: + * @address: The requested URL + * @target: The requested window name, e.g. "_blank" + * @features: The requested features: for example, "height=400,width=200" + * + * The ::ge_popup_blocked signal is emitted when the viewed web page requests + * a popup window (with javascript:open()) but popup windows are not allowed. + **/ + g_signal_new ("ge_popup_blocked", + EPHY_TYPE_WEB_VIEW, + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (EphyWebViewClass, popup_blocked), + NULL, NULL, + ephy_marshal_VOID__STRING_STRING_STRING, + G_TYPE_NONE, + 3, + G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE, + G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE, + G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE); +/** + * EphyWebView::ge-context-menu: + * @embed: + * @event: the #EphyEmbedEvent which triggered this signal + * + * The ::ge_context_menu signal is emitted when a context menu is to be + * displayed. This will usually happen when the user right-clicks on a part of + * @embed. + **/ + g_signal_new ("ge_context_menu", + EPHY_TYPE_WEB_VIEW, + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EphyWebViewClass, context_menu), + g_signal_accumulator_true_handled, NULL, + ephy_marshal_BOOLEAN__OBJECT, + G_TYPE_BOOLEAN, + 1, + G_TYPE_OBJECT); +/** + * EphyWebView::ge-favicon: + * @embed: + * @address: the URL to @embed's web site's favicon + * + * The ::ge_favicon signal is emitted when @embed discovers that a favourite + * icon (favicon) is available for the site it is visiting. + **/ + g_signal_new ("ge_favicon", + EPHY_TYPE_WEB_VIEW, + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (EphyWebViewClass, favicon), + NULL, NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, + 1, + G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE); +/** + * EphyWebView::ge-search-link: + * @embed: + * @type: the mime-type of the search description + * @title: the title of the news feed + * @address: the URL to @embed's web site's search description + * + * The ::ge_rss signal is emitted when @embed discovers that a search + * description is available for the site it is visiting. + **/ + g_signal_new ("ge_search_link", + EPHY_TYPE_WEB_VIEW, + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (EphyWebViewClass, search_link), + NULL, NULL, + ephy_marshal_VOID__STRING_STRING_STRING, + G_TYPE_NONE, + 3, + G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE, + G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE, + G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE); + +/** + * EphyWebView::ge-feed-link: + * @embed: + * @type: the mime-type of the news feed + * @title: the title of the news feed + * @address: the URL to @embed's web site's news feed + * + * The ::ge_rss signal is emitted when @embed discovers that a news feed + * is available for the site it is visiting. + **/ + g_signal_new ("ge_feed_link", + EPHY_TYPE_WEB_VIEW, + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (EphyWebViewClass, feed_link), + NULL, NULL, + ephy_marshal_VOID__STRING_STRING_STRING, + G_TYPE_NONE, + 3, + G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE, + G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE, + G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE); +/** + * EphyWebView::ge-dom-mouse-click: + * @embed: + * @event: the #EphyEmbedEvent which triggered this signal + * + * The ::ge_dom_mouse_click signal is emitted when the user clicks in @embed. + **/ + g_signal_new ("ge_dom_mouse_click", + EPHY_TYPE_WEB_VIEW, + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EphyWebViewClass, dom_mouse_click), + g_signal_accumulator_true_handled, NULL, + ephy_marshal_BOOLEAN__OBJECT, + G_TYPE_BOOLEAN, + 1, + G_TYPE_OBJECT); +/** + * EphyWebView::ge-dom-mouse-down: + * @embed: + * @event: the #EphyEmbedEvent which triggered this signal + * + * The ::ge_dom_mouse_down signal is emitted when the user depresses a mouse + * button. + **/ + g_signal_new ("ge_dom_mouse_down", + EPHY_TYPE_WEB_VIEW, + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EphyWebViewClass, dom_mouse_down), + g_signal_accumulator_true_handled, NULL, + ephy_marshal_BOOLEAN__OBJECT, + G_TYPE_BOOLEAN, + 1, + G_TYPE_OBJECT); +/** + * EphyWebView::ge-modal-alert: + * @embed: + * + * The ::ge-modal-alert signal is emitted when a DOM event will open a + * modal alert. + * + * Return %TRUE to prevent the dialog from being opened. + **/ + g_signal_new ("ge_modal_alert", + EPHY_TYPE_WEB_VIEW, + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EphyWebViewClass, modal_alert), + g_signal_accumulator_true_handled, NULL, + ephy_marshal_BOOLEAN__VOID, + G_TYPE_BOOLEAN, + 0); +/** + * EphyWebView::ge-modal-alert-closed: + * @embed: + * + * The ::ge-modal-alert-closed signal is emitted when a modal alert put up by a + * DOM event was closed. + **/ + g_signal_new ("ge_modal_alert_closed", + EPHY_TYPE_WEB_VIEW, + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EphyWebViewClass, modal_alert_closed), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0); + +/** + * EphyWebView::ge-document-type: + * @embed: + * @type: the new document type + * + * The ::ge-document-type signal is emitted when @embed determines the type of its document. + **/ + g_signal_new ("ge_document_type", + EPHY_TYPE_WEB_VIEW, + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (EphyWebViewClass, document_type), + NULL, NULL, + g_cclosure_marshal_VOID__ENUM, + G_TYPE_NONE, + 1, + EPHY_TYPE_WEB_VIEW_DOCUMENT_TYPE); +/** + * EphyWebView::dom-content-loaded: + * @embed: + * + * The ::dom-content-loaded signal is emitted when + * the document has been loaded (excluding images and other loads initiated by this document). + * That's true also for frameset and all the frames within it. + **/ + g_signal_new ("dom_content_loaded", + EPHY_TYPE_WEB_VIEW, + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (EphyWebViewClass, dom_content_loaded), + NULL, NULL, + g_cclosure_marshal_VOID__POINTER, + G_TYPE_NONE, + 1, + G_TYPE_POINTER); + +/** + * EphyWebView::ge-search-key-press: + * @embed: + * @event: the #GdkEventKey which triggered this signal + * + * The ::ge-search-key-press signal is emitted for keypresses which + * should be used for find implementations. + **/ + g_signal_new ("ge-search-key-press", + EPHY_TYPE_WEB_VIEW, + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EphyWebViewClass, search_key_press), + g_signal_accumulator_true_handled, NULL, + ephy_marshal_BOOLEAN__BOXED, + G_TYPE_BOOLEAN, + 1, + GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE); + +/** + * EphyWebView::close-request + * @embed: + * + * The ::close signal is emitted when the embed request closing. + * Return %TRUE to prevent closing. You HAVE to process removal of the embed + * as soon as possible after that. + **/ + g_signal_new ("close-request", + EPHY_TYPE_WEB_VIEW, + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EphyWebViewClass, close_request), + g_signal_accumulator_true_handled, NULL, + ephy_marshal_BOOLEAN__VOID, + G_TYPE_BOOLEAN, + 0); +/** + * EphyWebView::content-blocked: + * @embed: + * @uri: blocked URI + * + * The ::content-blocked signal is emitted when an url has been blocked. + **/ + g_signal_new ("content-blocked", + EPHY_TYPE_WEB_VIEW, + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EphyWebViewClass, content_blocked), + NULL, NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, + 1, + G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE); +/** + * EphyWebView::new-document-now: + * @embed: + * @uri: URI of the new content + * + * The ::new-document-now signal is emitted when a new page content + * is being loaded into the browser. It's a good place to do view + * related changes, for example to restore the zoom level of a page + * or to set an user style sheet. + **/ + g_signal_new ("new-document-now", + EPHY_TYPE_WEB_VIEW, + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (EphyWebViewClass, new_document_now), + NULL, NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, + 1, + G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE); + + g_type_class_add_private (gobject_class, sizeof (EphyWebViewPrivate)); +} + +static void +icon_cache_changed_cb (EphyFaviconCache *cache, + const char *address, + EphyWebView *view) +{ + const char *icon_address; + + g_return_if_fail (address != NULL); + + icon_address = ephy_web_view_get_icon_address (view); + + /* is this for us? */ + if (icon_address != NULL && + strcmp (icon_address, address) == 0) { + ephy_web_view_load_icon (view); + } +} + +static void +ge_document_type_cb (EphyWebView *view, + EphyWebViewDocumentType type, + gpointer user_data) +{ + if (view->priv->document_type != type) { + view->priv->document_type = type; + + g_object_notify (G_OBJECT (view), "document-type"); + } +} + +static void +ge_favicon_cb (EphyWebView *view, + const char *address, + gpointer user_data) +{ + ephy_web_view_set_icon_address (view, address); +} + +static void +ge_new_window_cb (EphyWebView *view, + EphyWebView *new_view, + gpointer user_data) +{ + EphyEmbedContainer *container; + + g_return_if_fail (new_view != NULL); + + container = EPHY_EMBED_CONTAINER (gtk_widget_get_toplevel (GTK_WIDGET (new_view))); + g_return_if_fail (container != NULL || !GTK_WIDGET_TOPLEVEL (container)); + + popups_manager_add_window (view, container); +} + +static void +ge_popup_blocked_cb (EphyWebView *view, + const char *url, + const char *name, + const char *features, + gpointer user_data) +{ + popups_manager_add (view, url, name, features); } static void ephy_web_view_init (EphyWebView *web_view) { + EphyWebViewPrivate *priv; + EphyFaviconCache *cache; + + priv = web_view->priv = EPHY_WEB_VIEW_GET_PRIVATE (web_view); + + priv->address_expire = EPHY_WEB_VIEW_ADDRESS_EXPIRE_NOW; + priv->is_blank = TRUE; + priv->title = g_strdup (EMPTY_PAGE); + priv->document_type = EPHY_WEB_VIEW_DOCUMENT_HTML; + priv->security_level = EPHY_WEB_VIEW_STATE_IS_UNKNOWN; + priv->monitor_directory = FALSE; + + g_signal_connect_object (web_view, "ge_document_type", + G_CALLBACK (ge_document_type_cb), + web_view, (GConnectFlags)0); + + g_signal_connect_object (web_view, "ge_favicon", + G_CALLBACK (ge_favicon_cb), + web_view, (GConnectFlags)0); + + g_signal_connect_object (web_view, "ge_new_window", + G_CALLBACK (ge_new_window_cb), + web_view, (GConnectFlags)0); + + g_signal_connect_object (web_view, "ge_popup_blocked", + G_CALLBACK (ge_popup_blocked_cb), + web_view, (GConnectFlags)0); + + cache = EPHY_FAVICON_CACHE + (ephy_embed_shell_get_favicon_cache (embed_shell)); + g_signal_connect_object (G_OBJECT (cache), "changed", + G_CALLBACK (icon_cache_changed_cb), + web_view, (GConnectFlags)0); } /** @@ -137,3 +1139,986 @@ ephy_web_view_copy_back_history (EphyWebView *source, item = webkit_web_back_forward_list_get_current_item (source_bflist); webkit_web_back_forward_list_add_item (dest_bflist, g_object_ref (item)); } + +void +ephy_web_view_set_address (EphyWebView *embed, + const char *address) +{ + EphyWebViewPrivate *priv = embed->priv; + GObject *object = G_OBJECT (embed); + + g_free (priv->address); + priv->address = g_strdup (address); + + priv->is_blank = address == NULL || + strcmp (address, "about:blank") == 0; + + if (priv->is_loading && + priv->address_expire == EPHY_WEB_VIEW_ADDRESS_EXPIRE_NOW && + priv->typed_address != NULL) { + g_free (priv->typed_address); + priv->typed_address = NULL; + + g_object_notify (object, "typed-address"); + } + + g_object_notify (object, "address"); +} + +static char* +get_title_from_address (const char *address) +{ + if (g_str_has_prefix (address, "file://")) + return g_strdup (address + 7); + else + return ephy_string_get_host_name (address); +} + +void +ephy_web_view_set_title (EphyWebView *view, + const char *view_title) +{ + EphyWebViewPrivate *priv = view->priv; + char *title = g_strdup (view_title); + + if (!priv->is_blank && (title == NULL || g_strstrip (title)[0] == '\0')) { + g_free (title); + title = get_title_from_address (priv->address); + + /* Fallback */ + if (title == NULL || title[0] == '\0') { + g_free (title); + title = g_strdup (EMPTY_PAGE); + priv->is_blank = TRUE; + } + } else if (priv->is_blank) { + g_free (title); + title = g_strdup (EMPTY_PAGE); + } + + g_free (priv->title); + priv->title = ephy_string_shorten (title, MAX_TITLE_LENGTH); + + g_object_notify (G_OBJECT (view), "embed-title"); +} + +/** + * ephy_web_view_get_is_blank: + * @view: an #EphyWebView + * + * Returns whether the @view's address is "blank". + * + * Return value: %TRUE if the @view's address is "blank" + **/ +gboolean +ephy_web_view_get_is_blank (EphyWebView *view) +{ + return view->priv->is_blank; +} + +/** + * ephy_web_view_get_address: + * @view: an #EphyWebView + * + * Returns the address of the currently loaded page. + * + * Return value: @view's address. Will never be %NULL. + **/ +const char * +ephy_web_view_get_address (EphyWebView *view) +{ + EphyWebViewPrivate *priv = view->priv; + return priv->address ? priv->address : "about:blank"; +} + +/** + * ephy_web_view_get_title: + * @view: an #EphyWebView + * + * Return value: the title of the web page displayed in @view + **/ +const char * +ephy_web_view_get_title (EphyWebView *view) +{ + return view->priv->title; +} + +static void +ensure_page_info (EphyWebView *view, const char *address) +{ + EphyWebViewPrivate *priv = view->priv; + + if ((priv->address == NULL || priv->address[0] == '\0') && + priv->address_expire == EPHY_WEB_VIEW_ADDRESS_EXPIRE_NOW) { + ephy_web_view_set_address (view, address); + } + + /* FIXME huh?? */ + if (priv->title == NULL || priv->title[0] == '\0') { + ephy_web_view_set_title (view, NULL); + } +} + +static void +update_net_state_message (EphyWebView *view, const char *uri, EphyWebViewNetState flags) +{ + const char *msg = NULL; + char *host = NULL; + + if (uri != NULL) + host = ephy_string_get_host_name (uri); + + if (host == NULL) goto out; + + /* IS_REQUEST and IS_NETWORK can be both set */ + if (flags & EPHY_WEB_VIEW_STATE_IS_REQUEST) { + if (flags & EPHY_WEB_VIEW_STATE_REDIRECTING) { + msg = _ ("Redirecting to “%s”…"); + } else if (flags & EPHY_WEB_VIEW_STATE_TRANSFERRING) { + msg = _ ("Transferring data from “%s”…"); + } else if (flags & EPHY_WEB_VIEW_STATE_NEGOTIATING) { + msg = _ ("Waiting for authorization from “%s”…"); + } + } + + if (flags & EPHY_WEB_VIEW_STATE_IS_NETWORK) { + if (flags & EPHY_WEB_VIEW_STATE_START) { + msg = _ ("Loading “%s”…"); + } + } + + if ((flags & EPHY_WEB_VIEW_STATE_IS_NETWORK) && + (flags & EPHY_WEB_VIEW_STATE_STOP)) { + g_free (view->priv->status_message); + view->priv->status_message = NULL; + g_object_notify (G_OBJECT (view), "status-message"); + + } else if (msg != NULL) { + g_free (view->priv->status_message); + g_free (view->priv->loading_title); + view->priv->status_message = g_strdup_printf (msg, host); + view->priv->loading_title = g_strdup_printf (msg, host); + g_object_notify (G_OBJECT (view), "status-message"); + g_object_notify (G_OBJECT (view), "embed-title"); + } + + out: + g_free (host); +} + +static void +update_navigation_flags (EphyWebView *view) +{ + EphyWebViewPrivate *priv = view->priv; + guint flags = 0; + WebKitWebView *web_view = WEBKIT_WEB_VIEW (view); + + if (ephy_web_view_can_go_up (view)) { + flags |= EPHY_WEB_VIEW_NAV_UP; + } + + if (webkit_web_view_can_go_back (web_view)) { + flags |= EPHY_WEB_VIEW_NAV_BACK; + } + + if (webkit_web_view_can_go_forward (web_view)) { + flags |= EPHY_WEB_VIEW_NAV_FORWARD; + } + + if (priv->nav_flags != (EphyWebViewNavigationFlags)flags) { + priv->nav_flags = (EphyWebViewNavigationFlags)flags; + + g_object_notify (G_OBJECT (view), "navigation"); + } +} + +static int +build_load_percent (int requests_done, int requests_total) +{ + int percent = 0; + + if (requests_total > 0) { + percent = (requests_done * 100) / requests_total; + percent = CLAMP (percent, 0, 100); + } + + return percent; +} + +void +ephy_web_view_set_load_percent (EphyWebView *view, int percent) +{ + EphyWebViewPrivate *priv = view->priv; + + if (percent != priv->load_percent) { + priv->load_percent = percent; + + g_object_notify (G_OBJECT (view), "load-progress"); + } +} + +static void +build_progress_from_requests (EphyWebView *view, EphyWebViewNetState state) +{ + int load_percent; + + if (state & EPHY_WEB_VIEW_STATE_IS_REQUEST) { + if (state & EPHY_WEB_VIEW_STATE_START) { + view->priv->total_requests++; + } else if (state & EPHY_WEB_VIEW_STATE_STOP) { + view->priv->cur_requests++; + } + + load_percent = build_load_percent (view->priv->cur_requests, + view->priv->total_requests); + + ephy_web_view_set_load_percent (view, load_percent); + } +} + +static void +ephy_web_view_set_load_status (EphyWebView *view, gboolean status) +{ + EphyWebViewPrivate *priv = view->priv; + guint is_loading; + + is_loading = status != FALSE; + + if (is_loading != priv->is_loading) { + priv->is_loading = is_loading; + + g_object_notify (G_OBJECT (view), "load-status"); + } +} + +void +ephy_web_view_update_from_net_state (EphyWebView *view, + const char *uri, + EphyWebViewNetState state) +{ + EphyWebViewPrivate *priv = view->priv; + + update_net_state_message (view, uri, state); + + if (state & EPHY_WEB_VIEW_STATE_IS_NETWORK) { + if (state & EPHY_WEB_VIEW_STATE_START) { + GObject *object = G_OBJECT (view); + + g_object_freeze_notify (object); + + priv->total_requests = 0; + priv->cur_requests = 0; + + ephy_web_view_set_load_percent (view, 0); + ephy_web_view_set_load_status (view, TRUE); + + ensure_page_info (view, uri); + + g_object_notify (object, "embed-title"); + + g_object_thaw_notify (object); + } else if (state & EPHY_WEB_VIEW_STATE_STOP) { + GObject *object = G_OBJECT (view); + + g_object_freeze_notify (object); + + ephy_web_view_set_load_percent (view, 100); + ephy_web_view_set_load_status (view, FALSE); + + g_free (priv->loading_title); + priv->loading_title = NULL; + + priv->address_expire = EPHY_WEB_VIEW_ADDRESS_EXPIRE_NOW; + + g_object_notify (object, "embed-title"); + + g_object_thaw_notify (object); + } + + update_navigation_flags (view); + } + + build_progress_from_requests (view, state); +} + +void +ephy_web_view_set_loading_title (EphyWebView *view, + const char *title, + gboolean is_address) +{ + EphyWebViewPrivate *priv = view->priv; + char *freeme = NULL; + + g_free (priv->loading_title); + priv->loading_title = NULL; + + if (is_address) { + title = freeme = get_title_from_address (title); + } + + if (title != NULL && title[0] != '\0') { + /* translators: %s here is the address of the web page */ + priv->loading_title = g_strdup_printf (_ ("Loading “%s”…"), title); + } else { + priv->loading_title = g_strdup (_ ("Loading…")); + } + + g_free (freeme); +} + +static gboolean +ephy_web_view_file_monitor_reload_cb (EphyWebView *view) +{ + EphyWebViewPrivate *priv = view->priv; + + if (priv->reload_delay_ticks > 0) { + priv->reload_delay_ticks--; + + /* Run again */ + return TRUE; + } + + if (priv->is_loading) { + /* Wait a bit to reload if we're still loading! */ + priv->reload_delay_ticks = RELOAD_DELAY_MAX_TICKS / 2; + + /* Run again */ + return TRUE; + } + + priv->reload_scheduled_id = 0; + + LOG ("Reloading file '%s'", ephy_web_view_get_address (view)); + webkit_web_view_reload (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (view)); + + /* don't run again */ + return FALSE; +} + +static void +ephy_web_view_file_monitor_cb (GFileMonitor *monitor, + GFile *file, + GFile *other_file, + GFileMonitorEvent event_type, + EphyWebView *view) +{ + gboolean should_reload; + EphyWebViewPrivate *priv = view->priv; + + switch (event_type) { + /* These events will always trigger a reload: */ + case G_FILE_MONITOR_EVENT_CHANGED: + case G_FILE_MONITOR_EVENT_CREATED: + should_reload = TRUE; + break; + + /* These events will only trigger a reload for directories: */ + case G_FILE_MONITOR_EVENT_DELETED: + case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED: + should_reload = priv->monitor_directory; + break; + + /* These events don't trigger a reload: */ + case G_FILE_MONITOR_EVENT_PRE_UNMOUNT: + case G_FILE_MONITOR_EVENT_UNMOUNTED: + case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT: + default: + should_reload = FALSE; + break; + } + + if (should_reload) { + /* We make a lot of assumptions here, but basically we know + * that we just have to reload, by construction. + * Delay the reload a little bit so we don't endlessly + * reload while a file is written. + */ + if (priv->reload_delay_ticks == 0) { + priv->reload_delay_ticks = 1; + } else { + /* Exponential backoff */ + priv->reload_delay_ticks = MIN (priv->reload_delay_ticks * 2, + RELOAD_DELAY_MAX_TICKS); + } + + if (priv->reload_scheduled_id == 0) { + priv->reload_scheduled_id = + g_timeout_add (RELOAD_DELAY, + (GSourceFunc)ephy_web_view_file_monitor_reload_cb, view); + } + } +} + +static void +ephy_web_view_update_file_monitor (EphyWebView *view, + const gchar *address) +{ + EphyWebViewPrivate *priv = view->priv; + gboolean local; + gchar *anchor; + gchar *url; + GFile *file; + GFileType file_type; + GFileInfo *file_info; + GFileMonitor *monitor = NULL; + + if (priv->monitor != NULL && + priv->address != NULL && address != NULL && + strcmp (priv->address, address) == 0) { + /* same address, no change needed */ + return; + } + + ephy_web_view_file_monitor_cancel (view); + + local = g_str_has_prefix (address, "file://"); + if (local == FALSE) return; + + /* strip off anchors */ + anchor = strchr (address, '#'); + if (anchor != NULL) { + url = g_strndup (address, anchor - address); + } else { + url = g_strdup (address); + } + + file = g_file_new_for_uri (url); + file_info = g_file_query_info (file, + G_FILE_ATTRIBUTE_STANDARD_TYPE, + 0, NULL, NULL); + if (file_info == NULL) { + g_object_unref (file); + g_free (url); + return; + } + + file_type = g_file_info_get_file_type (file_info); + g_object_unref (file_info); + + if (file_type == G_FILE_TYPE_DIRECTORY) { + monitor = g_file_monitor_directory (file, 0, NULL, NULL); + g_signal_connect (monitor, "changed", + G_CALLBACK (ephy_web_view_file_monitor_cb), + view); + priv->monitor_directory = TRUE; + LOG ("Installed monitor for directory '%s'", url); + } + else if (file_type == G_FILE_TYPE_REGULAR) { + monitor = g_file_monitor_file (file, 0, NULL, NULL); + g_signal_connect (monitor, "changed", + G_CALLBACK (ephy_web_view_file_monitor_cb), + view); + priv->monitor_directory = FALSE; + LOG ("Installed monitor for file '%s'", url); + } + priv->monitor = monitor; + g_object_unref (file); + g_free (url); +} + +void +ephy_web_view_location_changed (EphyWebView *view, + const char *location) +{ + GObject *object = G_OBJECT (view); + + g_object_freeze_notify (object); + + /* do this up here so we still have the old address around */ + ephy_web_view_update_file_monitor (view, location); + + /* Do not expose about:blank to the user, an empty address + bar will do better */ + if (location == NULL || location[0] == '\0' || + strcmp (location, "about:blank") == 0) { + ephy_web_view_set_address (view, NULL); + ephy_web_view_set_title (view, EMPTY_PAGE); + } else { + char *view_address; + + /* we do this to get rid of an eventual password in the URL */ + view_address = ephy_web_view_get_location (view, TRUE); + ephy_web_view_set_address (view, view_address); + ephy_web_view_set_loading_title (view, view_address, TRUE); + g_free (view_address); + } + + ephy_web_view_set_link_message (view, NULL); + ephy_web_view_set_icon_address (view, NULL); + update_navigation_flags (view); + + g_object_notify (object, "embed-title"); + + g_object_thaw_notify (object); +} + +void +ephy_web_view_set_icon_address (EphyWebView *view, + const char *address) +{ + GObject *object = G_OBJECT (view); + EphyWebViewPrivate *priv = view->priv; + EphyHistory *history; + + g_free (priv->icon_address); + priv->icon_address = g_strdup (address); + + if (priv->icon != NULL) { + g_object_unref (priv->icon); + priv->icon = NULL; + + g_object_notify (object, "icon"); + } + + if (priv->icon_address) { + history = EPHY_HISTORY (ephy_embed_shell_get_global_history (embed_shell)); + ephy_history_set_icon (history, priv->address, priv->icon_address); + + ephy_web_view_load_icon (view); + } + + g_object_notify (object, "icon-address"); +} + +/** + * ephy_web_view_can_go_up: + * @view: an #EphyWebView + * + * Returns whether @view can travel to a higher-level directory on the server. + * For example, for http://www.example.com/subdir/index.html, returns %TRUE; for + * http://www.example.com/index.html, returns %FALSE. + * + * Return value: %TRUE if @view can browse to a higher-level directory + **/ +gboolean +ephy_web_view_can_go_up (EphyWebView *view) +{ + return FALSE; +} + +/** + * ephy_web_view_get_load_status: + * @view: an #EphyWebView + * + * Returns whether the web page in @view has finished loading. A web page is + * only finished loading after all images, styles, and other dependencies have + * been downloaded and rendered. + * + * Return value: %TRUE if the page is still loading, %FALSE if complete + **/ +gboolean +ephy_web_view_get_load_status (EphyWebView *view) +{ + return view->priv->is_loading; +} + +const char * +ephy_web_view_get_loading_title (EphyWebView *view) +{ + return view->priv->loading_title; +} + +/** + * ephy_web_view_get_icon_address: + * @view: an #EphyWebView + * + * Returns a URL which points to @view's site icon. + * + * Return value: the URL of @view's site icon + **/ +const char * +ephy_web_view_get_icon_address (EphyWebView *view) +{ + return view->priv->icon_address; +} + +/** + * ephy_wew_view_get_icon: + * @view: an #EphyWebView + * + * Returns the view's site icon as a #GdkPixbuf, + * or %NULL if it is not available. + * + * Return value: a the view's site icon + **/ +GdkPixbuf * +ephy_web_view_get_icon (EphyWebView *view) +{ + return view->priv->icon; +} + +/** + * ephy_web_view_get_document_type: + * @view: an #EphyWebView + * + * Returns the type of document loaded in the @view + * + * Return value: the #EphyWebViewDocumentType + **/ +EphyWebViewDocumentType +ephy_web_view_get_document_type (EphyWebView *view) +{ + return view->priv->document_type; +} + +/** + * ephy_web_view_get_load_percent: + * @view: an #EphyWebView + * + * Returns the page load percentage (displayed in the progressbar). + * + * Return value: a percentage from 0 to 100. + **/ +int +ephy_web_view_get_load_percent (EphyWebView *view) +{ + return view->priv->load_percent; +} + +/** + * ephy_web_view_get_navigation_flags: + * @view: an #EphyWebView + * + * Returns @view's navigation flags. + * + * Return value: @view's navigation flags + **/ +EphyWebViewNavigationFlags +ephy_web_view_get_navigation_flags (EphyWebView *view) +{ + return view->priv->nav_flags; +} + +/** + * ephy_web_view_get_status_message: + * @view: an #EphyWebView + * + * Returns the message displayed in @view's #EphyWindow's + * #EphyStatusbar. If the user is hovering the mouse over a hyperlink, + * this function will return the same value as + * ephy_web_view_get_link_message(). Otherwise, it will return a network + * status message, or NULL. + * + * The message returned has a limited lifetime, and so should be copied with + * g_strdup() if it must be stored. + * + * Return value: The current statusbar message + **/ +const char * +ephy_web_view_get_status_message (EphyWebView *view) +{ + EphyWebViewPrivate *priv = view->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; + } +} + +/** + * ephy_web_view_get_link_message: + * @view: an #EphyWebView + * + * When the user is hovering the mouse over a hyperlink, returns the URL of the + * hyperlink. + * + * Return value: the URL of the link over which the mouse is hovering + **/ +const char * +ephy_web_view_get_link_message (EphyWebView *view) +{ + g_return_val_if_fail (EPHY_IS_WEB_VIEW (view), NULL); + + return view->priv->link_message; +} + +/** + * ephy_web_view_get_visibility: + * @view: an #EphyWebView + * + * Returns whether the @view's toplevel is visible or not. Used + * mostly for popup visibility management. + * + * Return value: %TRUE if @view's "visibility" property is set + **/ +gboolean +ephy_web_view_get_visibility (EphyWebView *view) +{ + return view->priv->visibility; +} + +void +ephy_web_view_set_link_message (EphyWebView *view, + char *link_message) +{ + EphyWebViewPrivate *priv = view->priv; + + g_free (priv->link_message); + + priv->link_message = ephy_embed_utils_link_message_parse (link_message); + + g_object_notify (G_OBJECT (view), "status-message"); + g_object_notify (G_OBJECT (view), "link-message"); +} + +void +ephy_web_view_load_icon (EphyWebView *view) +{ + EphyWebViewPrivate *priv = view->priv; + EphyEmbedShell *shell; + EphyFaviconCache *cache; + + if (priv->icon_address == NULL || priv->icon != NULL) return; + + shell = ephy_embed_shell_get_default (); + cache = EPHY_FAVICON_CACHE (ephy_embed_shell_get_favicon_cache (shell)); + + /* ephy_favicon_cache_get returns a reference already */ + priv->icon = ephy_favicon_cache_get (cache, priv->icon_address); + + g_object_notify (G_OBJECT (view), "icon"); +} + +void +ephy_web_view_set_security_level (EphyWebView *view, + EphyWebViewSecurityLevel level) +{ + EphyWebViewPrivate *priv = view->priv; + + if (priv->security_level != level) { + priv->security_level = level; + + g_object_notify (G_OBJECT (view), "security-level"); + } +} + +void +ephy_web_view_set_visibility (EphyWebView *view, + gboolean visibility) +{ + EphyWebViewPrivate *priv = view->priv; + + if (priv->visibility != visibility) { + priv->visibility = visibility; + + g_object_notify (G_OBJECT (view), "visibility"); + } +} + +/** + * ephy_web_view_get_typed_address: + * @view: an #EphyWebView + * + * Returns the text that @view's #EphyWindow will display in its location toolbar + * entry when @view is selected. + * + * This is not guaranteed to be the same as @view's location, + * available through ephy_web_view_get_location(). As the user types a new address + * into the location entry, ephy_web_view_get_location()'s returned string will + * change. + * + * Return value: @view's #EphyWindow's location entry when @view is selected + **/ +const char * +ephy_web_view_get_typed_address (EphyWebView *view) +{ + return view->priv->typed_address; +} + +/** + * ephy_web_view_set_typed_address: + * @view: an #EphyWebView + * @address: the new typed address, or %NULL to clear it + * @expire: when to expire this address_expire + * + * Sets the text that @view's #EphyWindow will display in its location toolbar + * entry when @view is selected. + **/ +void +ephy_web_view_set_typed_address (EphyWebView *view, + const char *address, + EphyWebViewAddressExpire expire) +{ + EphyWebViewPrivate *priv = EPHY_WEB_VIEW (view)->priv; + + g_free (priv->typed_address); + priv->typed_address = g_strdup (address); + + if (expire == EPHY_WEB_VIEW_ADDRESS_EXPIRE_CURRENT && + !priv->is_loading) { + priv->address_expire = EPHY_WEB_VIEW_ADDRESS_EXPIRE_NOW; + } else { + priv->address_expire = expire; + } + + g_object_notify (G_OBJECT (view), "typed-address"); +} + +/** + * ephy_web_view_has_modified_forms: + * @view: an #EphyWebView + * + * Returns %TRUE if the user has modified <input> or <textarea> + * values in @view's loaded document. + * + * Return value: %TRUE if @view has user-modified forms + **/ +gboolean +ephy_web_view_has_modified_forms (EphyWebView *view) +{ + return FALSE; +} + +/** + * ephy_web_view_get_location: + * @view: an #EphyWebView + * @toplevel: %FALSE to return the location of the focused frame only + * + * Returns the URL of the web page displayed in @view. + * + * If the web page contains frames, @toplevel will determine which location to + * retrieve. If @toplevel is %TRUE, the return value will be the location of the + * frameset document. If @toplevel is %FALSE, the return value will be the + * location of the currently-focused frame. + * + * Return value: the URL of the web page displayed in @view + **/ +char * +ephy_web_view_get_location (EphyWebView *view, + gboolean toplevel) +{ + /* FIXME: follow the toplevel parameter */ + WebKitWebFrame *web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view)); + return g_strdup (webkit_web_frame_get_uri (web_frame)); +} + +/** + * ephy_web_view_go_up: + * @view: an #EphyWebView + * + * Moves @view one level up in its web page's directory hierarchy. + **/ +void +ephy_web_view_go_up (EphyWebView *view) +{ +} + +/** + * ephy_web_view_get_js_status: + * @view: an #EphyWebView + * + * Displays the message JavaScript is attempting to display in the statusbar. + * + * Note that Epiphany does not display JavaScript statusbar messages. + * + * Return value: a message from JavaScript meant to be displayed in the + * statusbar + **/ +char * +ephy_web_view_get_js_status (EphyWebView *view) +{ + return NULL; +} + +/** + * ephy_web_view_get_security_level: + * @view: an #EphyWebView + * @level: return value of security level + * @description: return value of the description of the security level + * + * Fetches the #EphyWebViewSecurityLevel and a newly-allocated string description + * of the security state of @view. + **/ +void +ephy_web_view_get_security_level (EphyWebView *view, + EphyWebViewSecurityLevel *level, + char **description) +{ + if (level) { + const gchar *uri = ephy_web_view_get_address (view); + + /* FIXME: as a temporary workaround, determine security level + based on the existence of a 'https' prefix for the URI */ + if (uri && g_str_has_prefix(uri, "https")) + *level = EPHY_WEB_VIEW_STATE_IS_SECURE_HIGH; + else + *level = EPHY_WEB_VIEW_STATE_IS_UNKNOWN; + } +} + +/** + * ephy_web_view_show_page_certificate: + * @view: an #EphyWebView + * + * Shows a dialogue displaying the certificate of the currently loaded page + * of @view, if it was loaded over a secure connection; else does nothing. + **/ +void +ephy_web_view_show_page_certificate (EphyWebView *view) +{ +} + +/** + * ephy_web_view_set_print_preview_mode: + * @view: an #EphyWebView + * @preview_mode: Whether the print preview mode is enabled. + * + * Enable and disable the print preview mode. + **/ +void +ephy_web_view_set_print_preview_mode (EphyWebView *view, + gboolean preview_mode) +{ +} + +/** + * ephy_web_view_print_preview_n_pages: + * @view: an #EphyWebView + * + * Returns the number of pages which would appear in @view's loaded document + * if it were to be printed. + * + * Return value: the number of pages in @view's loaded document + **/ +int +ephy_web_view_print_preview_n_pages (EphyWebView *view) +{ + return 0; +} + +/** + * ephy_web_view_print_preview_navigate: + * @view: an #EphyWebView + * @type: an #EphyPrintPreviewNavType which determines where to navigate + * @page: if @type is %EPHY_WEB_VIEW_PRINTPREVIEW_GOTO_PAGENUM, the desired page number + * + * Navigates @view's print preview. + **/ +void +ephy_web_view_print_preview_navigate (EphyWebView *view, + EphyWebViewPrintPreviewNavType type, + int page) +{ +} + +/** + * ephy_web_view_get_go_up_list: + * @view: an #EphyWebView + * + * Returns a list of (%char *) URLs to higher-level directories on the same + * server, in order of deepest to shallowest. For example, given + * "http://www.example.com/dir/subdir/file.html", will return a list containing + * "http://www.example.com/dir/subdir/", "http://www.example.com/dir/" and + * "http://www.example.com/". + * + * Return value: a list of URLs higher up in @view's web page's directory + * hierarchy + **/ +GSList * +ephy_web_view_get_go_up_list (EphyWebView *view) +{ + return NULL; +} diff --git a/embed/ephy-web-view.h b/embed/ephy-web-view.h index 898133040..b804670a0 100644 --- a/embed/ephy-web-view.h +++ b/embed/ephy-web-view.h @@ -43,6 +43,76 @@ typedef struct _EphyWebViewClass EphyWebViewClass; typedef struct _EphyWebView EphyWebView; typedef struct _EphyWebViewPrivate EphyWebViewPrivate; +typedef enum +{ + EPHY_WEB_VIEW_NAV_UP = 1 << 0, + EPHY_WEB_VIEW_NAV_BACK = 1 << 1, + EPHY_WEB_VIEW_NAV_FORWARD = 1 << 2 +} EphyWebViewNavigationFlags; + +typedef enum +{ + EPHY_WEB_VIEW_STATE_UNKNOWN = 0, + EPHY_WEB_VIEW_STATE_START = 1 << 0, + EPHY_WEB_VIEW_STATE_REDIRECTING = 1 << 1, + EPHY_WEB_VIEW_STATE_TRANSFERRING = 1 << 2, + EPHY_WEB_VIEW_STATE_NEGOTIATING = 1 << 3, + EPHY_WEB_VIEW_STATE_STOP = 1 << 4, + + EPHY_WEB_VIEW_STATE_IS_REQUEST = 1 << 5, + EPHY_WEB_VIEW_STATE_IS_DOCUMENT = 1 << 6, + EPHY_WEB_VIEW_STATE_IS_NETWORK = 1 << 7, + EPHY_WEB_VIEW_STATE_IS_WINDOW = 1 << 8, + EPHY_WEB_VIEW_STATE_RESTORING = 1 << 9 +} EphyWebViewNetState; + +typedef enum +{ + EPHY_WEB_VIEW_CHROME_MENUBAR = 1 << 0, + EPHY_WEB_VIEW_CHROME_TOOLBAR = 1 << 1, + EPHY_WEB_VIEW_CHROME_STATUSBAR = 1 << 2, + EPHY_WEB_VIEW_CHROME_BOOKMARKSBAR = 1 << 3 +} EphyWebViewChrome; + +#define EPHY_WEB_VIEW_CHROME_ALL (EPHY_WEB_VIEW_CHROME_MENUBAR | \ + EPHY_WEB_VIEW_CHROME_TOOLBAR | \ + EPHY_WEB_VIEW_CHROME_STATUSBAR | \ + EPHY_WEB_VIEW_CHROME_BOOKMARKSBAR) + +typedef enum +{ + EPHY_WEB_VIEW_PRINTPREVIEW_GOTO_PAGENUM = 0, + EPHY_WEB_VIEW_PRINTPREVIEW_PREV_PAGE = 1, + EPHY_WEB_VIEW_PRINTPREVIEW_NEXT_PAGE = 2, + EPHY_WEB_VIEW_PRINTPREVIEW_HOME = 3, + EPHY_WEB_VIEW_PRINTPREVIEW_END = 4 +} EphyWebViewPrintPreviewNavType; + +typedef enum +{ + EPHY_WEB_VIEW_STATE_IS_UNKNOWN, + EPHY_WEB_VIEW_STATE_IS_INSECURE, + EPHY_WEB_VIEW_STATE_IS_BROKEN, + EPHY_WEB_VIEW_STATE_IS_SECURE_LOW, + EPHY_WEB_VIEW_STATE_IS_SECURE_MED, + EPHY_WEB_VIEW_STATE_IS_SECURE_HIGH +} EphyWebViewSecurityLevel; + +typedef enum +{ + EPHY_WEB_VIEW_DOCUMENT_HTML, + EPHY_WEB_VIEW_DOCUMENT_XML, + EPHY_WEB_VIEW_DOCUMENT_IMAGE, + EPHY_WEB_VIEW_DOCUMENT_OTHER +} EphyWebViewDocumentType; + +typedef enum +{ + EPHY_WEB_VIEW_ADDRESS_EXPIRE_NOW, + EPHY_WEB_VIEW_ADDRESS_EXPIRE_NEXT, + EPHY_WEB_VIEW_ADDRESS_EXPIRE_CURRENT +} EphyWebViewAddressExpire; + struct _EphyWebView { WebKitWebView parent; @@ -54,20 +124,120 @@ struct _EphyWebView struct _EphyWebViewClass { WebKitWebViewClass parent_class; -}; -GType ephy_web_view_get_type (void); - -GtkWidget *ephy_web_view_new (void); - -void ephy_web_view_load_request (EphyWebView *web_view, - WebKitNetworkRequest *request); + /* Signals */ + int (* context_menu) (EphyWebView *view, + EphyEmbedEvent *event); + void (* favicon) (EphyWebView *view, + const char *location); + void (* feed_link) (EphyWebView *view, + const char *type, + const char *title, + const char *address); + void (* search_link) (EphyWebView *view, + const char *type, + const char *title, + const char *address); + gboolean (* dom_mouse_click) (EphyWebView *view, + EphyEmbedEvent *event); + gboolean (* dom_mouse_down) (EphyWebView *view, + EphyEmbedEvent *event); + void (* dom_content_loaded) (EphyWebView *view, + gpointer event); + void (* popup_blocked) (EphyWebView *view, + const char *address, + const char *target, + const char *features); + void (* content_blocked) (EphyWebView *view, + const char *uri); + gboolean (* modal_alert) (EphyWebView *view); + void (* modal_alert_closed) (EphyWebView *view); + void (* document_type) (EphyWebView *view, + EphyWebViewDocumentType type); + void (* new_window) (EphyWebView *view, + EphyWebView *new_view); + gboolean (* search_key_press) (EphyWebView *view, + GdkEventKey *event); + gboolean (* close_request) (EphyWebView *view); + + void (* new_document_now) (EphyWebView *view, + const char *uri); +}; -void ephy_web_view_load_url (EphyWebView *web_view, - const char *url); +GType ephy_web_view_get_type (void); +GType ephy_web_view_net_state_get_type (void); +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, + WebKitNetworkRequest *request); +void ephy_web_view_load_url (EphyWebView *view, + const char *url); +void ephy_web_view_copy_back_history (EphyWebView *source, + EphyWebView *dest); +gboolean ephy_web_view_get_load_status (EphyWebView *view); +const char * ephy_web_view_get_loading_title (EphyWebView *view); +GdkPixbuf * ephy_web_view_get_icon (EphyWebView *view); +EphyWebViewDocumentType ephy_web_view_get_document_type (EphyWebView *view); +int ephy_web_view_get_load_percent (EphyWebView *view); +EphyWebViewNavigationFlags ephy_web_view_get_navigation_flags (EphyWebView *view); +const char * ephy_web_view_get_status_message (EphyWebView *view); +const char * ephy_web_view_get_link_message (EphyWebView *view); +gboolean ephy_web_view_get_visibility (EphyWebView *view); +void ephy_web_view_set_link_message (EphyWebView *view, + char *link_message); +void ephy_web_view_load_icon (EphyWebView *view); +void ephy_web_view_load_icon (EphyWebView *view); +void ephy_web_view_set_security_level (EphyWebView *view, + EphyWebViewSecurityLevel level); +void ephy_web_view_set_visibility (EphyWebView *view, + gboolean visibility); +const char * ephy_web_view_get_typed_address (EphyWebView *view); +void ephy_web_view_set_typed_address (EphyWebView *view, + const char *address, + EphyWebViewAddressExpire expire); +gboolean ephy_web_view_get_is_blank (EphyWebView *view); +gboolean ephy_web_view_has_modified_forms (EphyWebView *view); +char * ephy_web_view_get_location (EphyWebView *view, + gboolean toplevel); +void ephy_web_view_go_up (EphyWebView *view); +char * ephy_web_view_get_js_status (EphyWebView *view); +void ephy_web_view_get_security_level (EphyWebView *view, + EphyWebViewSecurityLevel *level, + char **description); +void ephy_web_view_show_page_certificate (EphyWebView *view); +void ephy_web_view_set_print_preview_mode (EphyWebView *view, + gboolean preview_mode); +int ephy_web_view_print_preview_n_pages (EphyWebView *view); +void ephy_web_view_print_preview_navigate (EphyWebView *view, + EphyWebViewPrintPreviewNavType type, + int page); +GSList * ephy_web_view_get_go_up_list (EphyWebView *view); +void ephy_web_view_set_title (EphyWebView *view, + const char *view_title); +const char * ephy_web_view_get_icon_address (EphyWebView *view); +const char * ephy_web_view_get_title (EphyWebView *view); +gboolean ephy_web_view_can_go_up (EphyWebView *view); +const char * ephy_web_view_get_address (EphyWebView *view); + + +/* These should be private */ +void ephy_web_view_set_address (EphyWebView *embed, + const char *address); +void ephy_web_view_set_icon_address (EphyWebView *view, + const char *address); +void ephy_web_view_update_from_net_state (EphyWebView *view, + const char *uri, + EphyWebViewNetState state); +void ephy_web_view_location_changed (EphyWebView *view, + const char *location); +void ephy_web_view_set_load_percent (EphyWebView *view, + int percent); +void ephy_web_view_set_loading_title (EphyWebView *view, + const char *title, + gboolean is_address); +void ephy_web_view_popups_manager_reset (EphyWebView *view); -void ephy_web_view_copy_back_history (EphyWebView *source, - EphyWebView *dest); G_END_DECLS diff --git a/embed/webkit/webkit-embed.c b/embed/webkit/webkit-embed.c index c7e5f9f54..cff761572 100644 --- a/embed/webkit/webkit-embed.c +++ b/embed/webkit/webkit-embed.c @@ -55,7 +55,6 @@ static void webkit_embed_class_init (WebKitEmbedClass *klass); static void webkit_embed_init (WebKitEmbed *gs); -static void ephy_embed_iface_init (EphyEmbedIface *iface); #define WEBKIT_EMBED_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), WEBKIT_TYPE_EMBED, WebKitEmbedPrivate)) @@ -116,6 +115,11 @@ ephy_command_manager_iface_init (EphyCommandManagerIface *iface) iface->can_do_command = impl_manager_can_do_command; } +static void +ephy_embed_iface_init (EphyEmbedIface *iface) +{ +} + G_DEFINE_TYPE_WITH_CODE (WebKitEmbed, webkit_embed, EPHY_TYPE_BASE_EMBED, G_IMPLEMENT_INTERFACE (EPHY_TYPE_EMBED, ephy_embed_iface_init) @@ -133,8 +137,8 @@ title_changed_cb (WebKitWebView *web_view, g_object_get (web_view, "title", &title, NULL); - ephy_base_embed_set_title (EPHY_BASE_EMBED (embed), - title); + ephy_web_view_set_title (EPHY_WEB_VIEW (web_view), + title); frame = webkit_web_view_get_main_frame (web_view); uri = webkit_web_frame_get_uri (frame); @@ -148,35 +152,35 @@ title_changed_cb (WebKitWebView *web_view, static void update_load_state (WebKitEmbed *embed, WebKitWebView *web_view) { - EphyEmbedNetState estate = EPHY_EMBED_STATE_UNKNOWN; - const char *loading_uri = ephy_embed_get_typed_address (embed); + EphyWebViewNetState estate = EPHY_WEB_VIEW_STATE_UNKNOWN; + const char *loading_uri = ephy_web_view_get_typed_address (EPHY_WEB_VIEW (web_view)); if (embed->priv->load_state == WEBKIT_EMBED_LOAD_STARTED) { - estate = (EphyEmbedNetState) (estate | - EPHY_EMBED_STATE_START | - EPHY_EMBED_STATE_NEGOTIATING | - EPHY_EMBED_STATE_IS_REQUEST | - EPHY_EMBED_STATE_IS_NETWORK); + estate = (EphyWebViewNetState) (estate | + EPHY_WEB_VIEW_STATE_START | + EPHY_WEB_VIEW_STATE_NEGOTIATING | + EPHY_WEB_VIEW_STATE_IS_REQUEST | + EPHY_WEB_VIEW_STATE_IS_NETWORK); - g_signal_emit_by_name (embed, "new-document-now", loading_uri); + g_signal_emit_by_name (EPHY_WEB_VIEW (web_view), "new-document-now", loading_uri); } if (embed->priv->load_state == WEBKIT_EMBED_LOAD_LOADING) - estate = (EphyEmbedNetState) (estate | - EPHY_EMBED_STATE_TRANSFERRING | - EPHY_EMBED_STATE_IS_REQUEST | - EPHY_EMBED_STATE_IS_NETWORK); + estate = (EphyWebViewNetState) (estate | + EPHY_WEB_VIEW_STATE_TRANSFERRING | + EPHY_WEB_VIEW_STATE_IS_REQUEST | + EPHY_WEB_VIEW_STATE_IS_NETWORK); if (embed->priv->load_state == WEBKIT_EMBED_LOAD_STOPPED) - estate = (EphyEmbedNetState) (estate | - EPHY_EMBED_STATE_STOP | - EPHY_EMBED_STATE_IS_DOCUMENT | - EPHY_EMBED_STATE_IS_NETWORK); - - ephy_base_embed_update_from_net_state (EPHY_BASE_EMBED (embed), - loading_uri, - (EphyEmbedNetState)estate); + estate = (EphyWebViewNetState) (estate | + EPHY_WEB_VIEW_STATE_STOP | + EPHY_WEB_VIEW_STATE_IS_DOCUMENT | + EPHY_WEB_VIEW_STATE_IS_NETWORK); + + ephy_web_view_update_from_net_state (EPHY_WEB_VIEW (web_view), + loading_uri, + (EphyWebViewNetState)estate); } static void @@ -219,17 +223,17 @@ restore_zoom_level (WebKitEmbed *embed, static void load_committed_cb (WebKitWebView *web_view, WebKitWebFrame *web_frame, - EphyEmbed *embed) + WebKitEmbed *embed) { const gchar* uri; - EphyEmbedSecurityLevel security_level; + EphyWebViewSecurityLevel security_level; uri = webkit_web_frame_get_uri (web_frame); - ephy_base_embed_location_changed (EPHY_BASE_EMBED (embed), - uri); + ephy_web_view_location_changed (EPHY_WEB_VIEW (web_view), + uri); - restore_zoom_level (WEBKIT_EMBED (embed), uri); - ephy_history_add_page (WEBKIT_EMBED (embed)->priv->history, + restore_zoom_level (embed, uri); + ephy_history_add_page (embed->priv->history, uri, FALSE, FALSE); @@ -240,11 +244,11 @@ load_committed_cb (WebKitWebView *web_view, * a 'https' prefix for the URI */ if (uri && g_str_has_prefix (uri, "https")) - security_level = EPHY_EMBED_STATE_IS_SECURE_HIGH; + security_level = EPHY_WEB_VIEW_STATE_IS_SECURE_HIGH; else - security_level = EPHY_EMBED_STATE_IS_UNKNOWN; + security_level = EPHY_WEB_VIEW_STATE_IS_UNKNOWN; - ephy_base_embed_set_security_level (EPHY_BASE_EMBED (embed), security_level); + ephy_web_view_set_security_level (EPHY_WEB_VIEW (web_view), security_level); } static void @@ -268,7 +272,7 @@ load_progress_changed_cb (WebKitWebView *web_view, if (wembed->priv->load_state == WEBKIT_EMBED_LOAD_STARTED) wembed->priv->load_state = WEBKIT_EMBED_LOAD_LOADING; - ephy_base_embed_set_load_percent (EPHY_BASE_EMBED (embed), progress); + ephy_web_view_set_load_percent (EPHY_WEB_VIEW (web_view), progress); } static void @@ -288,7 +292,7 @@ hovering_over_link_cb (WebKitWebView *web_view, char *location, EphyEmbed *embed) { - ephy_base_embed_set_link_message (EPHY_BASE_EMBED (embed), location); + ephy_web_view_set_link_message (EPHY_WEB_VIEW (web_view), location); } static void @@ -307,7 +311,7 @@ zoom_changed_cb (WebKitWebView *web_view, return; } - address = ephy_embed_get_location (embed, TRUE); + address = ephy_web_view_get_location (EPHY_WEB_VIEW (web_view), TRUE); if (ephy_embed_utils_address_has_web_scheme (address)) { EphyHistory *history; EphyNode *host; @@ -371,18 +375,18 @@ mime_type_policy_decision_requested_cb (WebKitWebView *web_view, WebKitWebPolicyDecision *decision, WebKitEmbed *embed) { - EphyEmbedDocumentType type; + EphyWebViewDocumentType type; g_return_val_if_fail (mime_type, FALSE); - type = EPHY_EMBED_DOCUMENT_OTHER; + type = EPHY_WEB_VIEW_DOCUMENT_OTHER; if (!strcmp (mime_type, "text/html")) - type = EPHY_EMBED_DOCUMENT_HTML; + type = EPHY_WEB_VIEW_DOCUMENT_HTML; else if (!strcmp (mime_type, "application/xhtml+xml")) - type = EPHY_EMBED_DOCUMENT_XML; + type = EPHY_WEB_VIEW_DOCUMENT_XML; else if (!strncmp (mime_type, "image/", 6)) - type = EPHY_EMBED_DOCUMENT_IMAGE; + type = EPHY_WEB_VIEW_DOCUMENT_IMAGE; /* FIXME: maybe it makes more sense to have an API to query the mime * type when the load of a page starts than doing this here. @@ -390,7 +394,7 @@ mime_type_policy_decision_requested_cb (WebKitWebView *web_view, /* FIXME: rename ge-document-type (and all ge- signals...) to * something else */ - g_signal_emit_by_name (embed, "ge-document-type", type); + g_signal_emit_by_name (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed), "ge-document-type", type); /* If WebKit can't handle the mime type start the download process */ @@ -766,101 +770,3 @@ webkit_embed_init (WebKitEmbed *embed) embed->priv->history = EPHY_HISTORY (ephy_embed_shell_get_global_history (ephy_embed_shell_get_default ())); } -static void -impl_load_url (EphyEmbed *embed, - const char *url) -{ -} - -static gboolean -impl_can_go_up (EphyEmbed *embed) -{ - return FALSE; -} - -static GSList * -impl_get_go_up_list (EphyEmbed *embed) -{ - return NULL; -} - -static void -impl_go_up (EphyEmbed *embed) -{ -} - -static char * -impl_get_js_status (EphyEmbed *embed) -{ - return NULL; -} - -static char * -impl_get_location (EphyEmbed *embed, - gboolean toplevel) -{ - WebKitWebFrame *web_frame = webkit_web_view_get_main_frame (WEBKIT_EMBED (embed)->priv->web_view); - return g_strdup (webkit_web_frame_get_uri (web_frame)); -} - -static void -impl_get_security_level (EphyEmbed *embed, - EphyEmbedSecurityLevel *level, - char **description) -{ - if (level) { - const gchar *uri = ephy_embed_get_address (embed); - - /* FIXME: as a temporary workaround, determine security level - based on the existence of a 'https' prefix for the URI */ - if (uri && g_str_has_prefix(uri, "https")) - *level = EPHY_EMBED_STATE_IS_SECURE_HIGH; - else - *level = EPHY_EMBED_STATE_IS_UNKNOWN; - } -} - -static void -impl_show_page_certificate (EphyEmbed *embed) -{ -} - -static void -impl_set_print_preview_mode (EphyEmbed *embed, gboolean preview_mode) -{ -} - -static int -impl_print_preview_n_pages (EphyEmbed *embed) -{ - return 0; -} - -static void -impl_print_preview_navigate (EphyEmbed *embed, - EphyEmbedPrintPreviewNavType type, - int page) -{ -} - -static gboolean -impl_has_modified_forms (EphyEmbed *embed) -{ - return FALSE; -} - -static void -ephy_embed_iface_init (EphyEmbedIface *iface) -{ - iface->can_go_up = impl_can_go_up; - iface->get_go_up_list = impl_get_go_up_list; - iface->go_up = impl_go_up; - iface->get_location = impl_get_location; - iface->get_js_status = impl_get_js_status; - iface->show_page_certificate = impl_show_page_certificate; - iface->set_print_preview_mode = impl_set_print_preview_mode; - 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_security_level = impl_get_security_level; -} diff --git a/src/Makefile.am b/src/Makefile.am index eae879efb..73ffa003c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -535,6 +535,7 @@ EPHY_GIR_H_FILES = \ $(top_srcdir)/embed/ephy-history.h \ $(top_srcdir)/embed/ephy-password-manager.h \ $(top_srcdir)/embed/ephy-permission-manager.h \ + $(top_srcdir)/embed/ephy-web-view.h \ $(top_srcdir)/lib/ephy-dialog.h \ $(top_srcdir)/lib/ephy-node-db.h \ $(top_srcdir)/lib/ephy-node.h \ diff --git a/src/ephy-encoding-dialog.c b/src/ephy-encoding-dialog.c index e9283cfb8..8da22cdbe 100644 --- a/src/ephy-encoding-dialog.c +++ b/src/ephy-encoding-dialog.c @@ -135,11 +135,11 @@ sync_encoding_against_embed (EphyEncodingDialog *dialog) static void -embed_net_stop_cb (EphyEmbed *embed, +embed_net_stop_cb (EphyWebView *view, GParamSpec *pspec, EphyEncodingDialog *dialog) { - if (ephy_embed_get_load_status (embed) == FALSE) + if (ephy_web_view_get_load_status (view) == FALSE) sync_encoding_against_embed (dialog); } @@ -156,7 +156,7 @@ sync_embed_cb (EphyEncodingDialog *dialog, GParamSpec *pspec, gpointer dummy) dialog); } - g_signal_connect (G_OBJECT (embed), "notify::load-status", + g_signal_connect (G_OBJECT (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed)), "notify::load-status", G_CALLBACK (embed_net_stop_cb), dialog); dialog->priv->embed = embed; @@ -375,7 +375,7 @@ ephy_encoding_dialog_finalize (GObject *object) if (dialog->priv->embed) { - g_signal_handlers_disconnect_by_func (dialog->priv->embed, + g_signal_handlers_disconnect_by_func (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (dialog->priv->embed), G_CALLBACK (embed_net_stop_cb), dialog); } diff --git a/src/ephy-location-action.c b/src/ephy-location-action.c index f2b8ca2cc..ad10ce7d7 100644 --- a/src/ephy-location-action.c +++ b/src/ephy-location-action.c @@ -22,6 +22,7 @@ #include "config.h" #include "ephy-embed-container.h" +#include "ephy-embed-utils.h" #include "ephy-history.h" #include "ephy-location-action.h" #include "ephy-location-entry.h" @@ -325,7 +326,7 @@ get_location_cb (EphyLocationEntry *entry, embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (priv->window)); - return g_strdup (ephy_embed_get_address (embed)); + return g_strdup (ephy_web_view_get_address (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed))); } static char * @@ -337,7 +338,7 @@ get_title_cb (EphyLocationEntry *entry, embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (action->priv->window)); - return g_strdup (ephy_embed_get_title (embed)); + return g_strdup (ephy_web_view_get_title (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed))); } static void diff --git a/src/ephy-lockdown.c b/src/ephy-lockdown.c index 83a4adf00..98627e722 100644 --- a/src/ephy-lockdown.c +++ b/src/ephy-lockdown.c @@ -22,6 +22,8 @@ #include "config.h" #include "ephy-embed-container.h" +#include "ephy-embed-utils.h" +#include "ephy-web-view.h" #include "ephy-lockdown.h" #include "ephy-extension.h" #include "ephy-action-helper.h" @@ -102,10 +104,10 @@ update_location_editable (EphyWindow *window, /* embed is NULL on startup */ if (embed != NULL) { - address = ephy_embed_get_location (embed, TRUE); + address = ephy_web_view_get_location (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed), TRUE); ephy_toolbar_set_location (EPHY_TOOLBAR (toolbar), address, NULL); - ephy_embed_set_typed_address (embed, NULL, - EPHY_EMBED_ADDRESS_EXPIRE_CURRENT); + ephy_web_view_set_typed_address (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed), NULL, + EPHY_WEB_VIEW_ADDRESS_EXPIRE_CURRENT); g_free (address); } } diff --git a/src/ephy-navigation-action.c b/src/ephy-navigation-action.c index 07f202b56..c25e2bd11 100644 --- a/src/ephy-navigation-action.c +++ b/src/ephy-navigation-action.c @@ -283,7 +283,7 @@ build_up_menu (EphyNavigationAction *action) history = EPHY_HISTORY (ephy_embed_shell_get_global_history (embed_shell)); - list = ephy_embed_get_go_up_list (embed); + list = ephy_web_view_get_go_up_list (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed)); for (l = list; l != NULL; l = l->next) { @@ -410,7 +410,7 @@ ephy_navigation_action_activate (GtkAction *gtk_action) { GSList *up_list; - up_list = ephy_embed_get_go_up_list (embed); + up_list = ephy_web_view_get_go_up_list (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed)); ephy_link_open (EPHY_LINK (action), up_list->data, NULL, diff --git a/src/ephy-notebook.c b/src/ephy-notebook.c index e7c0a6c48..0cb77ece3 100644 --- a/src/ephy-notebook.c +++ b/src/ephy-notebook.c @@ -29,6 +29,7 @@ #include "ephy-file-helpers.h" #include "ephy-dnd.h" #include "ephy-embed.h" +#include "ephy-embed-utils.h" #include "ephy-window.h" #include "ephy-shell.h" #include "ephy-spinner.h" @@ -500,7 +501,7 @@ ephy_notebook_finalize (GObject *object) } static void -sync_load_status (EphyEmbed *embed, GParamSpec *pspec, GtkWidget *proxy) +sync_load_status (EphyWebView *view, GParamSpec *pspec, GtkWidget *proxy) { GtkWidget *spinner, *icon; @@ -508,7 +509,7 @@ sync_load_status (EphyEmbed *embed, GParamSpec *pspec, GtkWidget *proxy) icon = GTK_WIDGET (g_object_get_data (G_OBJECT (proxy), "icon")); g_return_if_fail (spinner != NULL && icon != NULL); - if (ephy_embed_get_load_status (embed)) + if (ephy_web_view_get_load_status (view)) { gtk_widget_hide (icon); gtk_widget_show (spinner); @@ -523,19 +524,19 @@ sync_load_status (EphyEmbed *embed, GParamSpec *pspec, GtkWidget *proxy) } static void -sync_icon (EphyEmbed *embed, +sync_icon (EphyWebView *view, GParamSpec *pspec, GtkImage *icon) { - gtk_image_set_from_pixbuf (icon, ephy_embed_get_icon (embed)); + gtk_image_set_from_pixbuf (icon, ephy_web_view_get_icon (view)); } static void -sync_label (EphyEmbed *embed, GParamSpec *pspec, GtkWidget *label) +sync_label (EphyWebView *view, GParamSpec *pspec, GtkWidget *label) { const char *title; - title = ephy_embed_get_title (embed); + title = ephy_web_view_get_title (view); gtk_label_set_text (GTK_LABEL (label), title); @@ -586,6 +587,7 @@ static GtkWidget * build_tab_label (EphyNotebook *nb, EphyEmbed *embed) { GtkWidget *hbox, *label, *close_button, *image, *spinner, *icon; + EphyWebView *view; /* set hbox spacing and label padding (see below) so that there's an * equal amount of space around the label */ @@ -649,15 +651,16 @@ build_tab_label (EphyNotebook *nb, EphyEmbed *embed) g_object_set_data (G_OBJECT (hbox), "close-button", close_button); /* Hook the label up to the tab properties */ - sync_icon (embed, NULL, GTK_IMAGE (icon)); - sync_label (embed, NULL, label); - sync_load_status (embed, NULL, hbox); + view = EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed); + sync_icon (view, NULL, GTK_IMAGE (icon)); + sync_label (view, NULL, label); + sync_load_status (view, NULL, hbox); - g_signal_connect_object (embed, "notify::icon", + g_signal_connect_object (view, "notify::icon", G_CALLBACK (sync_icon), icon, 0); - g_signal_connect_object (embed, "notify::title", + g_signal_connect_object (view, "notify::title", G_CALLBACK (sync_label), label, 0); - g_signal_connect_object (embed, "notify::load-status", + g_signal_connect_object (view, "notify::load-status", G_CALLBACK (sync_load_status), hbox, 0); return hbox; @@ -786,6 +789,7 @@ ephy_notebook_remove (GtkContainer *container, EphyNotebookPrivate *priv = notebook->priv; GtkWidget *tab_label, *tab_label_label, *tab_label_icon; int position, curr; + EphyWebView *view; g_assert (EPHY_IS_EMBED (tab_widget)); @@ -805,12 +809,14 @@ ephy_notebook_remove (GtkContainer *container, tab_label_icon = g_object_get_data (G_OBJECT (tab_label), "icon"); tab_label_label = g_object_get_data (G_OBJECT (tab_label), "label"); + view = EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (tab_widget); + g_signal_handlers_disconnect_by_func - (tab_widget, G_CALLBACK (sync_icon), tab_label_icon); + (view, G_CALLBACK (sync_icon), tab_label_icon); g_signal_handlers_disconnect_by_func - (tab_widget, G_CALLBACK (sync_label), tab_label_label); + (view, G_CALLBACK (sync_label), tab_label_label); g_signal_handlers_disconnect_by_func - (tab_widget, G_CALLBACK (sync_load_status), tab_label); + (view, G_CALLBACK (sync_load_status), tab_label); GTK_CONTAINER_CLASS (ephy_notebook_parent_class)->remove (container, tab_widget); diff --git a/src/ephy-session.c b/src/ephy-session.c index d4e38b988..e78849429 100644 --- a/src/ephy-session.c +++ b/src/ephy-session.c @@ -23,6 +23,8 @@ #include "ephy-session.h" +#include "ephy-embed.h" +#include "ephy-embed-utils.h" #include "ephy-embed-container.h" #include "ephy-window.h" #include "ephy-shell.h" @@ -375,11 +377,11 @@ session_delete (EphySession *session, } static void -load_status_notify_cb (EphyEmbed *embed, +load_status_notify_cb (EphyWebView *view, GParamSpec *pspec, EphySession *session) { - if (ephy_embed_get_load_status (embed) == FALSE) + if (ephy_web_view_get_load_status (view) == FALSE) ephy_session_save (session, SESSION_CRASHED); } @@ -389,7 +391,7 @@ notebook_page_added_cb (GtkWidget *notebook, guint position, EphySession *session) { - g_signal_connect (embed, "notify::load-status", + g_signal_connect (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed), "notify::load-status", G_CALLBACK (load_status_notify_cb), session); } @@ -402,7 +404,7 @@ notebook_page_removed_cb (GtkWidget *notebook, ephy_session_save (session, SESSION_CRASHED); g_signal_handlers_disconnect_by_func - (embed, G_CALLBACK (load_status_notify_cb), + (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed), G_CALLBACK (load_status_notify_cb), session); } @@ -657,7 +659,7 @@ session_command_open_uris (EphySession *session, NULL /* parent tab */, request, flags | page_flags, - EPHY_EMBED_CHROME_ALL, + EPHY_WEB_VIEW_CHROME_ALL, FALSE /* is popup? */, user_time); g_object_unref (request); @@ -704,7 +706,7 @@ session_command_dispatch (EphySession *session) NULL /* NetworkRequest */, EPHY_NEW_TAB_IN_NEW_WINDOW | EPHY_NEW_TAB_HOME_PAGE, - EPHY_EMBED_CHROME_ALL, + EPHY_WEB_VIEW_CHROME_ALL, FALSE /* is popup? */, cmd->user_time); } @@ -1028,17 +1030,17 @@ write_tab (xmlTextWriterPtr writer, ret = xmlTextWriterStartElement (writer, (xmlChar *) "embed"); if (ret < 0) return ret; - address = ephy_embed_get_address (embed); + address = ephy_web_view_get_address (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed)); ret = xmlTextWriterWriteAttribute (writer, (xmlChar *) "url", (const xmlChar *) address); if (ret < 0) return ret; - title = ephy_embed_get_title (embed); + title = ephy_web_view_get_title (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed)); ret = xmlTextWriterWriteAttribute (writer, (xmlChar *) "title", (const xmlChar *) title); if (ret < 0) return ret; - if (ephy_embed_get_load_status (embed)) + if (ephy_web_view_get_load_status (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed))) { ret = xmlTextWriterWriteAttribute (writer, (const xmlChar *) "loading", diff --git a/src/ephy-shell.c b/src/ephy-shell.c index 6a6926e62..614d88d7f 100644 --- a/src/ephy-shell.c +++ b/src/ephy-shell.c @@ -31,6 +31,7 @@ #include "ephy-embed-container.h" #include "ephy-embed-shell.h" #include "ephy-embed-single.h" +#include "ephy-embed-utils.h" #include "eel-gconf-extensions.h" #include "ephy-prefs.h" #include "ephy-file-helpers.h" @@ -111,7 +112,7 @@ ephy_shell_class_init (EphyShellClass *klass) static EphyEmbed * ephy_shell_new_window_cb (EphyEmbedSingle *single, EphyEmbed *parent_embed, - EphyEmbedChrome chromemask, + EphyWebViewChrome chromemask, EphyShell *shell) { GtkWidget *parent = NULL; @@ -125,7 +126,7 @@ ephy_shell_new_window_cb (EphyEmbedSingle *single, if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_JAVASCRIPT_CHROME)) { - chromemask = EPHY_EMBED_CHROME_ALL; + chromemask = EPHY_WEB_VIEW_CHROME_ALL; } if (parent_embed != NULL) @@ -140,7 +141,7 @@ ephy_shell_new_window_cb (EphyEmbedSingle *single, /* what's a popup ? ATM, any window opened with menubar toggled on * is *not* a popup */ - is_popup = (chromemask & EPHY_EMBED_CHROME_MENUBAR) == 0; + is_popup = (chromemask & EPHY_WEB_VIEW_CHROME_MENUBAR) == 0; return ephy_shell_new_tab_full (shell, @@ -424,7 +425,7 @@ ephy_shell_new_tab_full (EphyShell *shell, EphyEmbed *previous_embed, WebKitNetworkRequest *request, EphyNewTabFlags flags, - EphyEmbedChrome chrome, + EphyWebViewChrome chrome, gboolean is_popup, guint32 user_time) { @@ -474,7 +475,7 @@ ephy_shell_new_tab_full (EphyShell *shell, embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window)); if (embed != NULL) { - if (ephy_embed_get_is_blank (embed)) + if (ephy_web_view_get_is_blank (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed))) { active_is_blank = TRUE; } @@ -510,8 +511,8 @@ ephy_shell_new_tab_full (EphyShell *shell, if (flags & EPHY_NEW_TAB_HOME_PAGE || flags & EPHY_NEW_TAB_NEW_PAGE) { - ephy_embed_set_typed_address (embed, "", - EPHY_EMBED_ADDRESS_EXPIRE_NEXT); + ephy_web_view_set_typed_address (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed), "", + EPHY_WEB_VIEW_ADDRESS_EXPIRE_NEXT); ephy_toolbar_activate_location (toolbar); is_empty = load_homepage (embed); } @@ -575,7 +576,7 @@ ephy_shell_new_tab (EphyShell *shell, embed = ephy_shell_new_tab_full (shell, parent_window, previous_embed, request, flags, - EPHY_EMBED_CHROME_ALL, FALSE, 0); + EPHY_WEB_VIEW_CHROME_ALL, FALSE, 0); if (request) g_object_unref (request); diff --git a/src/ephy-shell.h b/src/ephy-shell.h index 00a1765fa..1ebb39190 100644 --- a/src/ephy-shell.h +++ b/src/ephy-shell.h @@ -103,7 +103,7 @@ EphyEmbed *ephy_shell_new_tab_full (EphyShell *shell, EphyEmbed *previous_embed, WebKitNetworkRequest *request, EphyNewTabFlags flags, - EphyEmbedChrome chrome, + EphyWebViewChrome chrome, gboolean is_popup, guint32 user_time); diff --git a/src/ephy-tabs-menu.c b/src/ephy-tabs-menu.c index d68868eba..6963ef324 100644 --- a/src/ephy-tabs-menu.c +++ b/src/ephy-tabs-menu.c @@ -176,7 +176,7 @@ sync_tab_title (EphyEmbed *embed, { const char *title; - title = ephy_embed_utils_get_title_composite (embed); + title = ephy_embed_utils_get_title_composite (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed)); g_object_set (action, "label", title, NULL); } diff --git a/src/ephy-toolbar.c b/src/ephy-toolbar.c index f9cd554c6..464272f4d 100644 --- a/src/ephy-toolbar.c +++ b/src/ephy-toolbar.c @@ -22,6 +22,7 @@ #include "config.h" #include "ephy-embed-container.h" +#include "ephy-embed-utils.h" #include "ephy-toolbar.h" #include "ephy-link.h" #include "ephy-go-action.h" @@ -173,8 +174,8 @@ sync_user_input_cb (EphyLocationAction *action, address = ephy_location_action_get_address (action); priv->updating_address = TRUE; - ephy_embed_set_typed_address (embed, address, - EPHY_EMBED_ADDRESS_EXPIRE_CURRENT); + ephy_web_view_set_typed_address (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed), address, + EPHY_WEB_VIEW_ADDRESS_EXPIRE_CURRENT); priv->updating_address = FALSE; } diff --git a/src/ephy-window.c b/src/ephy-window.c index 2df66b244..562c3f3a8 100644 --- a/src/ephy-window.c +++ b/src/ephy-window.c @@ -95,10 +95,10 @@ static void ephy_window_view_toolbar_cb (GtkAction *action, EphyWindow *window); static void ephy_window_view_popup_windows_cb (GtkAction *action, EphyWindow *window); -static void sync_tab_load_status (EphyEmbed *embed, +static void sync_tab_load_status (EphyWebView *view, GParamSpec *pspec, EphyWindow *window); -static void sync_tab_security (EphyEmbed *embed, +static void sync_tab_security (EphyWebView *view, GParamSpec *pspec, EphyWindow *window); static void sync_tab_zoom (WebKitWebView *web_view, @@ -441,7 +441,7 @@ struct _EphyWindowPrivate guint num_tabs; guint tab_message_cid; guint help_message_cid; - EphyEmbedChrome chrome; + EphyWebViewChrome chrome; guint idle_resize_handler; GHashTable *tabs_to_remove; EphyEmbedEvent *context_event; @@ -576,9 +576,8 @@ impl_remove_child (EphyEmbedContainer *container, window = EPHY_WINDOW (container); priv = window->priv; - modified = ephy_embed_has_modified_forms (child); - if (ephy_embed_has_modified_forms (child) - && confirm_close_with_modified_forms (window) == FALSE) + modified = ephy_web_view_has_modified_forms (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (child)); + if (modified && confirm_close_with_modified_forms (window) == FALSE) { /* don't close the tab */ return; @@ -609,7 +608,7 @@ impl_get_is_popup (EphyEmbedContainer *container) return EPHY_WINDOW (container)->priv->is_popup; } -static EphyEmbedChrome +static EphyWebViewChrome impl_get_chrome (EphyEmbedContainer *container) { return EPHY_WINDOW (container)->priv->chrome; @@ -740,7 +739,7 @@ exit_fullscreen_clicked_cb (EphyWindow *window) static gboolean get_toolbar_visibility (EphyWindow *window) { - return ((window->priv->chrome & EPHY_EMBED_CHROME_TOOLBAR) != 0) && + return ((window->priv->chrome & EPHY_WEB_VIEW_CHROME_TOOLBAR) != 0) && !window->priv->ppv_mode; } @@ -752,7 +751,7 @@ get_chromes_visibility (EphyWindow *window, gboolean *show_tabsbar) { EphyWindowPrivate *priv = window->priv; - EphyEmbedChrome flags = priv->chrome; + EphyWebViewChrome flags = priv->chrome; if (window->priv->ppv_mode) { @@ -763,15 +762,15 @@ get_chromes_visibility (EphyWindow *window, } else if (window->priv->fullscreen_mode) { - *show_toolbar = (flags & EPHY_EMBED_CHROME_TOOLBAR) != 0; + *show_toolbar = (flags & EPHY_WEB_VIEW_CHROME_TOOLBAR) != 0; *show_menubar = *show_statusbar = FALSE; *show_tabsbar = !priv->is_popup; } else { - *show_menubar = (flags & EPHY_EMBED_CHROME_MENUBAR) != 0; - *show_statusbar = (flags & EPHY_EMBED_CHROME_STATUSBAR) != 0; - *show_toolbar = (flags & EPHY_EMBED_CHROME_TOOLBAR) != 0; + *show_menubar = (flags & EPHY_WEB_VIEW_CHROME_MENUBAR) != 0; + *show_statusbar = (flags & EPHY_WEB_VIEW_CHROME_STATUSBAR) != 0; + *show_toolbar = (flags & EPHY_WEB_VIEW_CHROME_TOOLBAR) != 0; *show_tabsbar = !priv->is_popup; } } @@ -839,8 +838,8 @@ ephy_window_fullscreen (EphyWindow *window) /* sync status */ embed = window->priv->active_embed; - sync_tab_load_status (embed, NULL, window); - sync_tab_security (embed, NULL, window); + sync_tab_load_status (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed), NULL, window); + sync_tab_security (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed), NULL, window); egg_editable_toolbar_set_model (EGG_EDITABLE_TOOLBAR (priv->toolbar), @@ -1069,7 +1068,7 @@ ephy_window_delete_event (GtkWidget *widget, EphyEmbed *embed; embed = window->priv->active_embed; - ephy_embed_set_print_preview_mode (embed, FALSE); + ephy_web_view_set_print_preview_mode (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed), FALSE); _ephy_window_set_print_preview (window, FALSE); @@ -1083,7 +1082,7 @@ ephy_window_delete_event (GtkWidget *widget, g_return_val_if_fail (EPHY_IS_EMBED (embed), FALSE); - if (ephy_embed_has_modified_forms (embed)) + if (ephy_web_view_has_modified_forms (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed))) { modified = TRUE; modified_embed = embed; @@ -1533,7 +1532,7 @@ setup_ui_manager (EphyWindow *window) } static void -sync_tab_address (EphyEmbed *embed, +sync_tab_address (EphyWebView *view, GParamSpec *pspec, EphyWindow *window) { @@ -1542,31 +1541,31 @@ sync_tab_address (EphyEmbed *embed, if (priv->closing) return; ephy_toolbar_set_location (priv->toolbar, - ephy_embed_get_address (embed), - ephy_embed_get_typed_address (embed)); + ephy_web_view_get_address (view), + ephy_web_view_get_typed_address (view)); ephy_find_toolbar_request_close (priv->find_toolbar); } static void -sync_tab_document_type (EphyEmbed *embed, +sync_tab_document_type (EphyWebView *view, GParamSpec *pspec, EphyWindow *window) { EphyWindowPrivate *priv = window->priv; GtkActionGroup *action_group = priv->action_group; GtkAction *action; - EphyEmbedDocumentType type; + EphyWebViewDocumentType type; gboolean can_find, disable, is_image; if (priv->closing) return; /* update zoom actions */ - sync_tab_zoom (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed), NULL, window); + sync_tab_zoom (WEBKIT_WEB_VIEW (view), NULL, window); - type = ephy_embed_get_document_type (embed); - can_find = (type != EPHY_EMBED_DOCUMENT_IMAGE); - is_image = type == EPHY_EMBED_DOCUMENT_IMAGE; - disable = (type != EPHY_EMBED_DOCUMENT_HTML); + type = ephy_web_view_get_document_type (view); + can_find = (type != EPHY_WEB_VIEW_DOCUMENT_IMAGE); + is_image = type == EPHY_WEB_VIEW_DOCUMENT_IMAGE; + disable = (type != EPHY_WEB_VIEW_DOCUMENT_HTML); action = gtk_action_group_get_action (action_group, "ViewEncoding"); ephy_action_change_sensitivity_flags (action, SENS_FLAG_DOCUMENT, disable); @@ -1586,7 +1585,7 @@ sync_tab_document_type (EphyEmbed *embed, } static void -sync_tab_icon (EphyEmbed *embed, +sync_tab_icon (EphyWebView *view, GParamSpec *pspec, EphyWindow *window) { @@ -1595,7 +1594,7 @@ sync_tab_icon (EphyEmbed *embed, if (priv->closing) return; - icon = ephy_embed_get_icon (embed); + icon = ephy_web_view_get_icon (view); ephy_toolbar_set_favicon (priv->toolbar, icon); } @@ -1610,7 +1609,7 @@ clear_progress_cb (EphyWindow *window) } static void -sync_tab_load_progress (EphyEmbed *embed, GParamSpec *pspec, EphyWindow *window) +sync_tab_load_progress (EphyWebView *view, GParamSpec *pspec, EphyWindow *window) { gdouble progress, previous_progress; gboolean loading; @@ -1623,8 +1622,8 @@ sync_tab_load_progress (EphyEmbed *embed, GParamSpec *pspec, EphyWindow *window) window->priv->clear_progress_timeout_id = 0; } - progress = ephy_embed_get_load_percent (embed)/100.0; - loading = ephy_embed_get_load_status (embed); + progress = ephy_web_view_get_load_percent (view)/100.0; + loading = ephy_web_view_get_load_status (view); /* Do not show a 'blink' progress from pages that go from 0 to 100, * for example about:blank. */ @@ -1649,14 +1648,14 @@ sync_tab_load_progress (EphyEmbed *embed, GParamSpec *pspec, EphyWindow *window) } static void -sync_tab_message (EphyEmbed *embed, GParamSpec *pspec, EphyWindow *window) +sync_tab_message (EphyWebView *view, GParamSpec *pspec, EphyWindow *window) { GtkStatusbar *s = GTK_STATUSBAR (window->priv->statusbar); const char *message; if (window->priv->closing) return; - message = ephy_embed_get_status_message (embed); + message = ephy_web_view_get_status_message (view); gtk_statusbar_pop (s, window->priv->tab_message_cid); @@ -1667,11 +1666,11 @@ sync_tab_message (EphyEmbed *embed, GParamSpec *pspec, EphyWindow *window) } static void -sync_tab_navigation (EphyEmbed *embed, +sync_tab_navigation (EphyWebView *view, GParamSpec *pspec, EphyWindow *window) { - EphyEmbedNavigationFlags flags; + EphyWebViewNavigationFlags flags; WebKitWebHistoryItem *item; WebKitWebView *web_view; WebKitWebBackForwardList *web_back_forward_list; @@ -1680,17 +1679,17 @@ sync_tab_navigation (EphyEmbed *embed, if (window->priv->closing) return; - flags = ephy_embed_get_navigation_flags (embed); + flags = ephy_web_view_get_navigation_flags (view); - if (flags & EPHY_EMBED_NAV_UP) + if (flags & EPHY_WEB_VIEW_NAV_UP) { up = TRUE; } - if (flags & EPHY_EMBED_NAV_BACK) + if (flags & EPHY_WEB_VIEW_NAV_BACK) { back = TRUE; } - if (flags & EPHY_EMBED_NAV_FORWARD) + if (flags & EPHY_WEB_VIEW_NAV_FORWARD) { forward = TRUE; } @@ -1698,7 +1697,7 @@ sync_tab_navigation (EphyEmbed *embed, ephy_toolbar_set_navigation_actions (window->priv->toolbar, back, forward, up); - web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed); + web_view = WEBKIT_WEB_VIEW (view); web_back_forward_list = webkit_web_view_get_back_forward_list (web_view); item = webkit_web_back_forward_list_get_back_item (web_back_forward_list); @@ -1721,12 +1720,12 @@ sync_tab_navigation (EphyEmbed *embed, } static void -sync_tab_security (EphyEmbed *embed, +sync_tab_security (EphyWebView *view, GParamSpec *pspec, EphyWindow *window) { EphyWindowPrivate *priv = window->priv; - EphyEmbedSecurityLevel level; + EphyWebViewSecurityLevel level; char *description = NULL; char *state = NULL; char *tooltip; @@ -1736,34 +1735,34 @@ sync_tab_security (EphyEmbed *embed, if (priv->closing) return; - ephy_embed_get_security_level (embed, &level, &description); + ephy_web_view_get_security_level (view, &level, &description); switch (level) { - case EPHY_EMBED_STATE_IS_UNKNOWN: + case EPHY_WEB_VIEW_STATE_IS_UNKNOWN: state = _("Unknown"); break; - case EPHY_EMBED_STATE_IS_INSECURE: + case EPHY_WEB_VIEW_STATE_IS_INSECURE: state = _("Insecure"); g_free (description); description = NULL; break; - case EPHY_EMBED_STATE_IS_BROKEN: + case EPHY_WEB_VIEW_STATE_IS_BROKEN: state = _("Broken"); stock_id = STOCK_LOCK_BROKEN; show_lock = TRUE; g_free (description); description = NULL; break; - case EPHY_EMBED_STATE_IS_SECURE_LOW: - case EPHY_EMBED_STATE_IS_SECURE_MED: + case EPHY_WEB_VIEW_STATE_IS_SECURE_LOW: + case EPHY_WEB_VIEW_STATE_IS_SECURE_MED: state = _("Low"); /* We deliberately don't show the 'secure' icon * for low & medium secure sites; see bug #151709. */ stock_id = STOCK_LOCK_INSECURE; break; - case EPHY_EMBED_STATE_IS_SECURE_HIGH: + case EPHY_WEB_VIEW_STATE_IS_SECURE_HIGH: state = _("High"); stock_id = STOCK_LOCK_SECURE; show_lock = TRUE; @@ -1804,14 +1803,14 @@ sync_tab_security (EphyEmbed *embed, } static void -sync_tab_popup_windows (EphyEmbed *embed, +sync_tab_popup_windows (EphyWebView *view, GParamSpec *pspec, EphyWindow *window) { guint num_popups = 0; char *tooltip = NULL; - g_object_get (embed, + g_object_get (view, "hidden-popup-count", &num_popups, NULL); @@ -1832,21 +1831,21 @@ sync_tab_popup_windows (EphyEmbed *embed, } static void -sync_tab_popups_allowed (EphyEmbed *embed, +sync_tab_popups_allowed (EphyWebView *view, GParamSpec *pspec, EphyWindow *window) { GtkAction *action; gboolean allow; - g_return_if_fail (EPHY_IS_EMBED (embed)); + g_return_if_fail (EPHY_IS_WEB_VIEW (view)); g_return_if_fail (EPHY_IS_WINDOW (window)); action = gtk_action_group_get_action (window->priv->action_group, "ViewPopupWindows"); g_return_if_fail (GTK_IS_ACTION (action)); - g_object_get (embed, "popups-allowed", &allow, NULL); + g_object_get (view, "popups-allowed", &allow, NULL); g_signal_handlers_block_by_func (G_OBJECT (action), @@ -1862,7 +1861,7 @@ sync_tab_popups_allowed (EphyEmbed *embed, } static void -sync_tab_load_status (EphyEmbed *embed, +sync_tab_load_status (EphyWebView *view, GParamSpec *pspec, EphyWindow *window) { @@ -1873,7 +1872,7 @@ sync_tab_load_status (EphyEmbed *embed, if (window->priv->closing) return; - loading = ephy_embed_get_load_status (embed); + loading = ephy_web_view_get_load_status (view); action = gtk_action_group_get_action (action_group, "ViewStop"); gtk_action_set_sensitive (action, loading); @@ -1893,7 +1892,7 @@ sync_tab_load_status (EphyEmbed *embed, } static void -sync_tab_title (EphyEmbed *embed, +sync_tab_title (EphyWebView *view, GParamSpec *pspec, EphyWindow *window) { @@ -1902,7 +1901,7 @@ sync_tab_title (EphyEmbed *embed, if (priv->closing) return; gtk_window_set_title (GTK_WINDOW(window), - ephy_embed_utils_get_title_composite (embed)); + ephy_embed_utils_get_title_composite (view)); } static void @@ -1910,7 +1909,7 @@ sync_tab_zoom (WebKitWebView *web_view, GParamSpec *pspec, EphyWindow *window) { GtkActionGroup *action_group; GtkAction *action; - EphyEmbedDocumentType type; + EphyWebViewDocumentType type; gboolean can_zoom_in = TRUE, can_zoom_out = TRUE, can_zoom_normal = FALSE, can_zoom; float zoom; EphyEmbed *embed = window->priv->active_embed; @@ -1921,8 +1920,8 @@ sync_tab_zoom (WebKitWebView *web_view, GParamSpec *pspec, EphyWindow *window) "zoom-level", &zoom, NULL); - type = ephy_embed_get_document_type (embed); - can_zoom = (type != EPHY_EMBED_DOCUMENT_IMAGE); + type = ephy_web_view_get_document_type (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed)); + can_zoom = (type != EPHY_WEB_VIEW_DOCUMENT_IMAGE); if (zoom >= ZOOM_MAXIMAL) { @@ -2237,11 +2236,14 @@ show_embed_popup (EphyWindow *window, } static gboolean -tab_context_menu_cb (EphyEmbed *embed, +tab_context_menu_cb (EphyWebView *view, EphyEmbedEvent *event, EphyWindow *window) { - g_return_val_if_fail (EPHY_IS_EMBED (embed), FALSE); + EphyEmbed *embed; + + g_return_val_if_fail (EPHY_IS_WEB_VIEW (view), FALSE); + embed = EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (view); g_return_val_if_fail (window->priv->active_embed == embed, FALSE); show_embed_popup (window, embed, event); @@ -2432,7 +2434,7 @@ ephy_window_visibility_cb (EphyEmbed *embed, GParamSpec *pspec, EphyWindow *wind { gboolean visibility; - visibility = ephy_embed_get_visibility (embed); + visibility = ephy_web_view_get_visibility (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed)); if (visibility) gtk_widget_show (GTK_WIDGET (window)); @@ -2457,7 +2459,7 @@ web_view_ready_cb (WebKitWebView *web_view, gboolean toolbar_visible; gboolean statusbar_visible; gboolean menubar_visible; - EphyEmbedChrome chrome_mask; + EphyWebViewChrome chrome_mask; WebKitWebWindowFeatures *features; toolbar_visible = statusbar_visible = menubar_visible = TRUE; @@ -2476,13 +2478,13 @@ web_view_ready_cb (WebKitWebView *web_view, gtk_window_set_default_size (GTK_WINDOW (window), width, height); if (!toolbar_visible) - chrome_mask &= ~EPHY_EMBED_CHROME_TOOLBAR; + chrome_mask &= ~EPHY_WEB_VIEW_CHROME_TOOLBAR; if (!statusbar_visible) - chrome_mask &= ~EPHY_EMBED_CHROME_STATUSBAR; + chrome_mask &= ~EPHY_WEB_VIEW_CHROME_STATUSBAR; if (!menubar_visible) - chrome_mask &= ~EPHY_EMBED_CHROME_MENUBAR; + chrome_mask &= ~EPHY_WEB_VIEW_CHROME_MENUBAR; window->priv->chrome = chrome_mask; @@ -2524,7 +2526,7 @@ create_web_view_cb (WebKitWebView *web_view, parent_window, NULL, NULL, flags, - EPHY_EMBED_CHROME_ALL, + EPHY_WEB_VIEW_CHROME_ALL, FALSE, 0); @@ -2558,7 +2560,6 @@ policy_decision_required_cb (WebKitWebView *web_view, if (reason == WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED && (button == 2 /* middle button */ || (button == 1 && state == GDK_CONTROL_MASK) /* ctrl + left button */)) { - const char *uri; EphyEmbed *embed; embed = ephy_embed_container_get_active_child @@ -2570,7 +2571,7 @@ policy_decision_required_cb (WebKitWebView *web_view, request, EPHY_NEW_TAB_IN_EXISTING_WINDOW | EPHY_NEW_TAB_OPEN_PAGE, - EPHY_EMBED_CHROME_ALL, FALSE, 0); + EPHY_WEB_VIEW_CHROME_ALL, FALSE, 0); return TRUE; } @@ -2605,7 +2606,7 @@ const char *remove_node_string = "if (node) node.parentNode.removeChild(node);"; static void -ephy_window_link_message_cb (EphyEmbed *embed, GParamSpec *spec, EphyWindow *window) +ephy_window_link_message_cb (EphyWebView *web_view, GParamSpec *spec, EphyWindow *window) { gboolean visible; const char *link_message; @@ -2613,8 +2614,8 @@ ephy_window_link_message_cb (EphyEmbed *embed, GParamSpec *spec, EphyWindow *win g_object_get (window->priv->statusbar, "visible", &visible, NULL); - view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed); - link_message = ephy_embed_get_link_message (embed); + view = EPHY_WEB_VIEW (web_view); + link_message = ephy_web_view_get_link_message (web_view); /* If the statusbar is visible remove the test, it might get stuck otherwise */ @@ -2648,7 +2649,7 @@ ephy_window_link_message_cb (EphyEmbed *embed, GParamSpec *spec, EphyWindow *win freeme = g_strconcat (buffer, "...", NULL); } - g_utf8_strncpy (text, pango_layout_get_text (layout), item->num_chars); + g_utf8_strncpy ((gchar *)text, pango_layout_get_text (layout), item->num_chars); bg = widget->style->bg[GTK_WIDGET_STATE(widget)]; fg = widget->style->fg[GTK_WIDGET_STATE(widget)]; @@ -2688,10 +2689,12 @@ ephy_window_set_active_tab (EphyWindow *window, EphyEmbed *new_embed) if (old_embed != NULL) { WebKitWebView *web_view; + EphyWebView *view; guint sid; embed = old_embed; web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed); + view = EPHY_WEB_VIEW (web_view); g_signal_handlers_disconnect_by_func (web_view, G_CALLBACK (sync_tab_zoom), @@ -2721,50 +2724,50 @@ ephy_window_set_active_tab (EphyWindow *window, EphyEmbed *new_embed) G_CALLBACK (policy_decision_required_cb), NULL); - g_signal_handlers_disconnect_by_func (embed, + g_signal_handlers_disconnect_by_func (view, G_CALLBACK (sync_tab_popup_windows), window); - g_signal_handlers_disconnect_by_func (embed, + g_signal_handlers_disconnect_by_func (view, G_CALLBACK (sync_tab_popups_allowed), window); - g_signal_handlers_disconnect_by_func (embed, + g_signal_handlers_disconnect_by_func (view, G_CALLBACK (sync_tab_security), window); - g_signal_handlers_disconnect_by_func (embed, + g_signal_handlers_disconnect_by_func (view, G_CALLBACK (sync_tab_document_type), window); - g_signal_handlers_disconnect_by_func (embed, + g_signal_handlers_disconnect_by_func (view, G_CALLBACK (sync_tab_load_progress), window); - g_signal_handlers_disconnect_by_func (embed, + g_signal_handlers_disconnect_by_func (view, G_CALLBACK (sync_tab_load_status), window); - g_signal_handlers_disconnect_by_func (embed, + g_signal_handlers_disconnect_by_func (view, G_CALLBACK (sync_tab_navigation), window); - g_signal_handlers_disconnect_by_func (embed, + g_signal_handlers_disconnect_by_func (view, G_CALLBACK (sync_tab_title), window); - g_signal_handlers_disconnect_by_func (embed, + g_signal_handlers_disconnect_by_func (view, G_CALLBACK (sync_tab_address), window); - g_signal_handlers_disconnect_by_func (embed, + g_signal_handlers_disconnect_by_func (view, G_CALLBACK (sync_tab_icon), window); - g_signal_handlers_disconnect_by_func (embed, + g_signal_handlers_disconnect_by_func (view, G_CALLBACK (sync_tab_message), window); - g_signal_handlers_disconnect_by_func (embed, + g_signal_handlers_disconnect_by_func (view, G_CALLBACK (ephy_window_visibility_cb), window); - g_signal_handlers_disconnect_by_func (embed, + g_signal_handlers_disconnect_by_func (view, G_CALLBACK (ephy_window_link_message_cb), window); g_signal_handlers_disconnect_by_func - (embed, G_CALLBACK (tab_context_menu_cb), window); + (view, G_CALLBACK (tab_context_menu_cb), window); g_signal_handlers_disconnect_by_func - (embed, G_CALLBACK (ephy_window_dom_mouse_click_cb), window); + (view, G_CALLBACK (ephy_window_dom_mouse_click_cb), window); } @@ -2773,22 +2776,25 @@ ephy_window_set_active_tab (EphyWindow *window, EphyEmbed *new_embed) if (new_embed != NULL) { WebKitWebView *web_view; + EphyWebView *view; embed = new_embed; - - sync_tab_security (embed, NULL, window); - sync_tab_document_type (embed, NULL, window); - sync_tab_load_progress (embed, NULL, window); - sync_tab_load_status (embed, NULL, window); - sync_tab_navigation (embed, NULL, window); - sync_tab_title (embed, NULL, window); - sync_tab_address (embed, NULL, window); - sync_tab_icon (embed, NULL, window); - sync_tab_message (embed, NULL, window); - sync_tab_popup_windows (embed, NULL, window); - sync_tab_popups_allowed (embed, NULL, window); + view = EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed); + + sync_tab_security (view, NULL, window); + sync_tab_document_type (view, NULL, window); + sync_tab_load_progress (view, NULL, window); + sync_tab_load_status (view, NULL, window); + sync_tab_navigation (view, NULL, window); + sync_tab_title (view, NULL, window); + sync_tab_address (view, NULL, window); + sync_tab_icon (view, NULL, window); + sync_tab_message (view, NULL, window); + sync_tab_popup_windows (view, NULL, window); + sync_tab_popups_allowed (view, NULL, window); web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed); + view = EPHY_WEB_VIEW (web_view); sync_tab_zoom (web_view, NULL, window); @@ -2814,49 +2820,49 @@ ephy_window_set_active_tab (EphyWindow *window, EphyEmbed *new_embed) G_CALLBACK (policy_decision_required_cb), window, 0); - g_signal_connect_object (embed, "notify::hidden-popup-count", + g_signal_connect_object (view, "notify::hidden-popup-count", G_CALLBACK (sync_tab_popup_windows), window, 0); - g_signal_connect_object (embed, "notify::popups-allowed", + g_signal_connect_object (view, "notify::popups-allowed", G_CALLBACK (sync_tab_popups_allowed), window, 0); - g_signal_connect_object (embed, "notify::title", + g_signal_connect_object (view, "notify::embed-title", G_CALLBACK (sync_tab_title), window, 0); - g_signal_connect_object (embed, "notify::address", + g_signal_connect_object (view, "notify::address", G_CALLBACK (sync_tab_address), window, 0); - g_signal_connect_object (embed, "notify::icon", + g_signal_connect_object (view, "notify::icon", G_CALLBACK (sync_tab_icon), window, 0); - g_signal_connect_object (embed, "notify::status-message", + g_signal_connect_object (view, "notify::status-message", G_CALLBACK (sync_tab_message), window, 0); - g_signal_connect_object (embed, "notify::security-level", + g_signal_connect_object (view, "notify::security-level", G_CALLBACK (sync_tab_security), window, 0); - g_signal_connect_object (embed, "notify::document-type", + g_signal_connect_object (view, "notify::document-type", G_CALLBACK (sync_tab_document_type), window, 0); - g_signal_connect_object (embed, "notify::load-status", + g_signal_connect_object (view, "notify::load-status", G_CALLBACK (sync_tab_load_status), window, 0); - g_signal_connect_object (embed, "notify::navigation", + g_signal_connect_object (view, "notify::navigation", G_CALLBACK (sync_tab_navigation), window, 0); - g_signal_connect_object (embed, "ge-context-menu", + g_signal_connect_object (view, "ge-context-menu", G_CALLBACK (tab_context_menu_cb), window, G_CONNECT_AFTER); - g_signal_connect_object (embed, "notify::load-progress", + g_signal_connect_object (view, "notify::load-progress", G_CALLBACK (sync_tab_load_progress), window, 0); - g_signal_connect_object (embed, "ge_dom_mouse_click", + g_signal_connect_object (view, "ge_dom_mouse_click", G_CALLBACK (ephy_window_dom_mouse_click_cb), window, 0); - g_signal_connect_object (embed, "notify::visibility", + g_signal_connect_object (view, "notify::visibility", G_CALLBACK (ephy_window_visibility_cb), window, 0); - g_signal_connect_object (embed, "notify::link-message", + g_signal_connect_object (view, "notify::link-message", G_CALLBACK (ephy_window_link_message_cb), window, 0); @@ -2912,7 +2918,7 @@ embed_modal_alert_cb (EphyEmbed *embed, gtk_window_present (GTK_WINDOW (window)); /* make sure the location entry shows the real URL of the tab's page */ - address = ephy_embed_get_address (embed); + address = ephy_web_view_get_address (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed)); ephy_toolbar_set_location (priv->toolbar, address, NULL); /* don't suppress alert */ @@ -3081,10 +3087,10 @@ notebook_page_added_cb (EphyNotebook *notebook, G_CONNECT_SWAPPED); #endif - g_signal_connect_object (embed, "close-request", + g_signal_connect_object (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed), "close-request", G_CALLBACK (embed_close_request_cb), window, 0); - g_signal_connect_object (embed, "ge-modal-alert", + g_signal_connect_object (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed), "ge-modal-alert", G_CALLBACK (embed_modal_alert_cb), window, G_CONNECT_AFTER); /* Let the extensions attach themselves to the tab */ @@ -3131,9 +3137,9 @@ notebook_page_removed_cb (EphyNotebook *notebook, } g_signal_handlers_disconnect_by_func - (embed, G_CALLBACK (embed_modal_alert_cb), window); + (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed), G_CALLBACK (embed_modal_alert_cb), window); g_signal_handlers_disconnect_by_func - (embed, G_CALLBACK (embed_close_request_cb), window); + (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed), G_CALLBACK (embed_close_request_cb), window); } static void @@ -3158,7 +3164,7 @@ notebook_page_close_request_cb (EphyNotebook *notebook, return; } - if (!ephy_embed_has_modified_forms (embed) || + if (!ephy_web_view_has_modified_forms (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed)) || confirm_close_with_modified_forms (window)) { gtk_widget_destroy (GTK_WIDGET (embed)); @@ -3215,28 +3221,28 @@ setup_notebook (EphyWindow *window) } static void -ephy_window_set_chrome (EphyWindow *window, EphyEmbedChrome mask) +ephy_window_set_chrome (EphyWindow *window, EphyWebViewChrome mask) { - EphyEmbedChrome chrome_mask = mask; + EphyWebViewChrome chrome_mask = mask; - if (mask == EPHY_EMBED_CHROME_ALL) + if (mask == EPHY_WEB_VIEW_CHROME_ALL) { window->priv->should_save_chrome = TRUE; } if (!eel_gconf_get_boolean (CONF_WINDOWS_SHOW_TOOLBARS)) { - chrome_mask &= ~EPHY_EMBED_CHROME_TOOLBAR; + chrome_mask &= ~EPHY_WEB_VIEW_CHROME_TOOLBAR; } if (!eel_gconf_get_boolean (CONF_WINDOWS_SHOW_STATUSBAR)) { - chrome_mask &= ~EPHY_EMBED_CHROME_STATUSBAR; + chrome_mask &= ~EPHY_WEB_VIEW_CHROME_STATUSBAR; } if (eel_gconf_get_boolean (CONF_LOCKDOWN_HIDE_MENUBAR)) { - chrome_mask &= ~EPHY_EMBED_CHROME_MENUBAR; + chrome_mask &= ~EPHY_WEB_VIEW_CHROME_MENUBAR; } window->priv->chrome = chrome_mask; @@ -3543,7 +3549,7 @@ allow_popups_notifier (GConfClient *client, embed = EPHY_EMBED (tabs->data); g_return_if_fail (EPHY_IS_EMBED (embed)); - g_object_notify (G_OBJECT (embed), "popups-allowed"); + g_object_notify (G_OBJECT (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed)), "popups-allowed"); } } @@ -3871,7 +3877,7 @@ ephy_window_new (void) /** * ephy_window_new_with_chrome: - * @chrome: an #EphyEmbedChrome + * @chrome: an #EphyWebViewChrome * @is_popup: whether the new window is a popup window * * Identical to ephy_window_new(), but allows you to specify a chrome. @@ -3879,7 +3885,7 @@ ephy_window_new (void) * Return value: a new #EphyWindow **/ EphyWindow * -ephy_window_new_with_chrome (EphyEmbedChrome chrome, +ephy_window_new_with_chrome (EphyWebViewChrome chrome, gboolean is_popup) { return EPHY_WINDOW (g_object_new (EPHY_TYPE_WINDOW, @@ -4115,21 +4121,21 @@ ephy_window_set_zoom (EphyWindow *window, static void sync_prefs_with_chrome (EphyWindow *window) { - EphyEmbedChrome flags = window->priv->chrome; + EphyWebViewChrome flags = window->priv->chrome; if (window->priv->should_save_chrome) { eel_gconf_set_boolean (CONF_WINDOWS_SHOW_TOOLBARS, - flags & EPHY_EMBED_CHROME_TOOLBAR); + flags & EPHY_WEB_VIEW_CHROME_TOOLBAR); eel_gconf_set_boolean (CONF_WINDOWS_SHOW_STATUSBAR, - flags & EPHY_EMBED_CHROME_STATUSBAR); + flags & EPHY_WEB_VIEW_CHROME_STATUSBAR); } } static void sync_chrome_with_view_toggle (GtkAction *action, EphyWindow *window, - EphyEmbedChrome chrome_flag, + EphyWebViewChrome chrome_flag, gboolean invert) { gboolean active; @@ -4148,7 +4154,7 @@ ephy_window_view_statusbar_cb (GtkAction *action, EphyWindow *window) { sync_chrome_with_view_toggle (action, window, - EPHY_EMBED_CHROME_STATUSBAR, FALSE); + EPHY_WEB_VIEW_CHROME_STATUSBAR, FALSE); } static void @@ -4156,7 +4162,7 @@ ephy_window_view_toolbar_cb (GtkAction *action, EphyWindow *window) { sync_chrome_with_view_toggle (action, window, - EPHY_EMBED_CHROME_TOOLBAR, TRUE); + EPHY_WEB_VIEW_CHROME_TOOLBAR, TRUE); } static void @@ -4180,7 +4186,7 @@ ephy_window_view_popup_windows_cb (GtkAction *action, allow = FALSE; } - g_object_set (G_OBJECT (embed), "popups-allowed", allow, NULL); + g_object_set (G_OBJECT (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed)), "popups-allowed", allow, NULL); } /** diff --git a/src/ephy-window.h b/src/ephy-window.h index ecb34a442..de7f21a7c 100644 --- a/src/ephy-window.h +++ b/src/ephy-window.h @@ -60,7 +60,7 @@ GType ephy_window_get_type (void); EphyWindow *ephy_window_new (void); -EphyWindow *ephy_window_new_with_chrome (EphyEmbedChrome chrome, +EphyWindow *ephy_window_new_with_chrome (EphyWebViewChrome chrome, gboolean is_popup); void _ephy_window_set_print_preview (EphyWindow *window, diff --git a/src/popup-commands.c b/src/popup-commands.c index 31203237e..00db15425 100644 --- a/src/popup-commands.c +++ b/src/popup-commands.c @@ -373,7 +373,7 @@ popup_cmd_open_frame (GtkAction *action, (EPHY_EMBED_CONTAINER (window)); g_return_if_fail (embed != NULL); - location = ephy_embed_get_location (embed, FALSE); + location = ephy_web_view_get_location (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed), FALSE); ephy_web_view_load_url (EPHY_WEB_VIEW (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed)), location); g_free (location); diff --git a/src/ppview-toolbar.c b/src/ppview-toolbar.c index a5b89abdc..dbc571980 100644 --- a/src/ppview-toolbar.c +++ b/src/ppview-toolbar.c @@ -22,6 +22,7 @@ #include "ppview-toolbar.h" #include "ephy-embed-container.h" +#include "ephy-embed-utils.h" #include "ephy-window.h" #include <string.h> @@ -177,7 +178,7 @@ toolbar_update_sensitivity (PPViewToolbar *t) (EPHY_EMBED_CONTAINER (window)); g_return_if_fail (embed != NULL); - pages = ephy_embed_print_preview_n_pages (embed); + pages = ephy_web_view_print_preview_n_pages (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed)); c_page = t->priv->current_page; action = gtk_action_group_get_action (action_group, "PPVGoBack"); @@ -272,7 +273,7 @@ toolbar_cmd_ppv_goto_first (GtkUIManager *merge, embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window)); g_return_if_fail (EPHY_IS_EMBED (embed)); - ephy_embed_print_preview_navigate (embed, EPHY_EMBED_PRINTPREVIEW_HOME, 0); + ephy_web_view_print_preview_navigate (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed), EPHY_WEB_VIEW_PRINTPREVIEW_HOME, 0); t->priv->current_page = 1; @@ -289,11 +290,11 @@ toolbar_cmd_ppv_goto_last (GtkUIManager *merge, embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window)); g_return_if_fail (embed != NULL); - ephy_embed_print_preview_navigate (embed, - EPHY_EMBED_PRINTPREVIEW_END, - 0); + ephy_web_view_print_preview_navigate (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed), + EPHY_WEB_VIEW_PRINTPREVIEW_END, + 0); - t->priv->current_page = ephy_embed_print_preview_n_pages (embed); + t->priv->current_page = ephy_web_view_print_preview_n_pages (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed)); toolbar_update_sensitivity (t); } @@ -309,7 +310,7 @@ clamp_page_limits (PPViewToolbar *t, int page) (EPHY_EMBED_CONTAINER (window)); g_return_val_if_fail (embed != NULL, -1); - pages = ephy_embed_print_preview_n_pages (embed); + pages = ephy_web_view_print_preview_n_pages (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed)); return CLAMP (page, 1, pages); } @@ -326,9 +327,9 @@ toolbar_cmd_ppv_go_back (GtkUIManager *merge, t->priv->current_page = clamp_page_limits (t, t->priv->current_page - 1); - ephy_embed_print_preview_navigate (embed, - EPHY_EMBED_PRINTPREVIEW_GOTO_PAGENUM, - t->priv->current_page); + ephy_web_view_print_preview_navigate (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed), + EPHY_WEB_VIEW_PRINTPREVIEW_GOTO_PAGENUM, + t->priv->current_page); toolbar_update_sensitivity (t); } @@ -345,9 +346,9 @@ toolbar_cmd_ppv_go_forward (GtkUIManager *merge, t->priv->current_page = clamp_page_limits (t, t->priv->current_page + 1); - ephy_embed_print_preview_navigate (embed, - EPHY_EMBED_PRINTPREVIEW_GOTO_PAGENUM, - t->priv->current_page); + ephy_web_view_print_preview_navigate (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed), + EPHY_WEB_VIEW_PRINTPREVIEW_GOTO_PAGENUM, + t->priv->current_page); toolbar_update_sensitivity (t); } @@ -370,5 +371,5 @@ toolbar_cmd_ppv_close (GtkUIManager *merge, _ephy_window_set_print_preview (window, FALSE); - ephy_embed_set_print_preview_mode (embed, FALSE); + ephy_web_view_set_print_preview_mode (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed), FALSE); } diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c index ab6d5eb1d..0e409051c 100644 --- a/src/prefs-dialog.c +++ b/src/prefs-dialog.c @@ -26,6 +26,7 @@ #include "ephy-prefs.h" #include "ephy-embed-container.h" #include "ephy-embed-shell.h" +#include "ephy-embed-utils.h" #include "ephy-favicon-cache.h" #include "ephy-session.h" #include "ephy-embed-prefs.h" @@ -1016,7 +1017,7 @@ prefs_homepage_current_button_clicked_cb (GtkWidget *button, (EPHY_EMBED_CONTAINER (window)); g_return_if_fail (embed != NULL); - set_homepage_entry (dialog, ephy_embed_get_address (embed)); + set_homepage_entry (dialog, ephy_web_view_get_address (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed))); } static void diff --git a/src/window-commands.c b/src/window-commands.c index dfd512310..66bf63b55 100644 --- a/src/window-commands.c +++ b/src/window-commands.c @@ -93,7 +93,7 @@ window_cmd_file_print_preview (GtkAction *action, (EPHY_EMBED_CONTAINER (window)); g_return_if_fail (EPHY_IS_EMBED (embed)); - ephy_embed_set_print_preview_mode (embed, TRUE); + ephy_web_view_set_print_preview_mode (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed), TRUE); _ephy_window_set_print_preview (window, TRUE); } @@ -124,8 +124,8 @@ window_cmd_file_send_to (GtkAction *action, (EPHY_EMBED_CONTAINER (window)); g_return_if_fail (embed != NULL); - location = ephy_embed_get_address (embed); - title = ephy_embed_get_title (embed); + location = ephy_web_view_get_address (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed)); + title = ephy_web_view_get_title (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed)); subject = g_uri_escape_string (title, NULL, TRUE); body = g_uri_escape_string (location, NULL, TRUE); @@ -247,8 +247,8 @@ window_cmd_file_bookmark_page (GtkAction *action, g_return_if_fail (embed != NULL); ephy_bookmarks_ui_add_bookmark (GTK_WINDOW (window), - ephy_embed_get_address (embed), - ephy_embed_get_title (embed)); + ephy_web_view_get_address (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed)), + ephy_web_view_get_title (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed))); } static void @@ -665,7 +665,7 @@ window_cmd_view_page_source (GtkAction *action, (EPHY_EMBED_CONTAINER (window)); g_return_if_fail (embed != NULL); - address = ephy_embed_get_address (embed); + address = ephy_web_view_get_address (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed)); user_time = gtk_get_current_event_time (); if (g_str_has_prefix (address, "file://")) @@ -693,7 +693,7 @@ window_cmd_view_page_security_info (GtkAction *action, (EPHY_EMBED_CONTAINER (window)); g_return_if_fail (EPHY_IS_EMBED (embed)); - ephy_embed_show_page_certificate (embed); + ephy_web_view_show_page_certificate (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed)); } void @@ -721,7 +721,7 @@ window_cmd_edit_personal_data (GtkAction *action, (EPHY_EMBED_CONTAINER (window)); if (embed == NULL) return; - address = ephy_embed_get_address (embed); + address = ephy_web_view_get_address (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed)); host = address != NULL ? ephy_string_get_host_name (address) : NULL; |