diff options
author | Xan Lopez <xan@src.gnome.org> | 2007-10-26 03:59:36 +0800 |
---|---|---|
committer | Xan Lopez <xan@src.gnome.org> | 2007-10-26 03:59:36 +0800 |
commit | fdacbe229e0defe6ef64068066a13369cce2ec27 (patch) | |
tree | 5525e0fd8d01f1629b43e619b5e5bd763c42bf08 /embed | |
parent | 461af43a1c1f2e0506fb49d15b01b7a76e43579e (diff) | |
download | gsoc2013-epiphany-fdacbe229e0defe6ef64068066a13369cce2ec27.tar gsoc2013-epiphany-fdacbe229e0defe6ef64068066a13369cce2ec27.tar.gz gsoc2013-epiphany-fdacbe229e0defe6ef64068066a13369cce2ec27.tar.bz2 gsoc2013-epiphany-fdacbe229e0defe6ef64068066a13369cce2ec27.tar.lz gsoc2013-epiphany-fdacbe229e0defe6ef64068066a13369cce2ec27.tar.xz gsoc2013-epiphany-fdacbe229e0defe6ef64068066a13369cce2ec27.tar.zst gsoc2013-epiphany-fdacbe229e0defe6ef64068066a13369cce2ec27.zip |
Move address and typed-address from EphyTab to EphyEmbed
ephy-tab.c is totally broken now, will fix in next patches.
svn path=/trunk/; revision=7557
Diffstat (limited to 'embed')
-rw-r--r-- | embed/ephy-embed.c | 75 | ||||
-rw-r--r-- | embed/ephy-embed.h | 22 | ||||
-rw-r--r-- | embed/mozilla/mozilla-embed.cpp | 110 |
3 files changed, 198 insertions, 9 deletions
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c index 99e194ecb..3f052e413 100644 --- a/embed/ephy-embed.c +++ b/embed/ephy-embed.c @@ -467,7 +467,18 @@ ephy_embed_base_init (gpointer g_class) EPHY_TYPE_EMBED_NAVIGATION_FLAGS, 0, G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); - + g_object_interface_install_property (g_class, + 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_interface_install_property (g_class, + 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)); initialized = TRUE; } @@ -1152,3 +1163,65 @@ ephy_embed_update_navigation_flags (EphyEmbed *embed) return iface->update_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); +} + +void +ephy_embed_set_address (EphyEmbed *embed, + char *address) +{ + EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed); + return iface->set_address (embed, address); +} + diff --git a/embed/ephy-embed.h b/embed/ephy-embed.h index 2c64234e9..b56bfe964 100644 --- a/embed/ephy-embed.h +++ b/embed/ephy-embed.h @@ -108,6 +108,13 @@ typedef enum 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; @@ -242,6 +249,12 @@ struct _EphyEmbedIface void (* set_load_status) (EphyEmbed *embed, gboolean percent); void (* update_navigation_flags) (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); + void (* set_address) (EphyEmbed *embed, char *address); }; GType ephy_embed_net_state_get_type (void); @@ -350,6 +363,15 @@ void ephy_embed_set_load_status (EphyEmbed *embed, gboolean status); /* FIXME void ephy_embed_update_navigation_flags (EphyEmbed *embed); /* FIXME: remove me */ 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); +void ephy_embed_set_address (EphyEmbed *embed, char *address); /* FIXME: remove me */ + /* Encoding */ char *ephy_embed_get_encoding (EphyEmbed *embed); diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp index f2c990849..d0601b170 100644 --- a/embed/mozilla/mozilla-embed.cpp +++ b/embed/mozilla/mozilla-embed.cpp @@ -83,6 +83,9 @@ static void mozilla_embed_document_type_cb (EphyEmbed *embed, static void mozilla_embed_zoom_change_cb (EphyEmbed *embed, float zoom, MozillaEmbed *membed); +static void impl_set_typed_address (EphyEmbed *embed, + const char *address, + EphyEmbedAddressExpire expire); static EphyEmbedSecurityLevel mozilla_embed_security_level (PRUint32 state); @@ -101,6 +104,8 @@ struct MozillaEmbedPrivate EphyBrowser *browser; MozillaEmbedLoadState load_state; + EphyEmbedAddressExpire address_expire; + /* guint address_expire : 2; ? */ EphyEmbedSecurityLevel security_level; /* guint security_level : 3; ? */ EphyEmbedDocumentType document_type; @@ -112,6 +117,8 @@ struct MozillaEmbedPrivate guint is_setting_zoom : 1; gint8 load_percent; + char *address; + char *typed_address; }; #define WINDOWWATCHER_CONTRACTID "@mozilla.org/embedcomp/window-watcher;1" @@ -119,11 +126,13 @@ struct MozillaEmbedPrivate enum { PROP_0, + PROP_ADDRESS, PROP_DOCUMENT_TYPE, PROP_LOAD_PROGRESS, PROP_LOAD_STATUS, PROP_NAVIGATION, PROP_SECURITY, + PROP_TYPED_ADDRESS, PROP_ZOOM }; @@ -228,6 +237,9 @@ mozilla_embed_get_property (GObject *object, 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; @@ -246,6 +258,9 @@ mozilla_embed_get_property (GObject *object, case PROP_NAVIGATION: g_value_set_flags (value, priv->nav_flags); break; + case PROP_TYPED_ADDRESS: + g_value_set_string (value, priv->typed_address); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -261,6 +276,11 @@ mozilla_embed_set_property (GObject *object, { switch (prop_id) { + case PROP_TYPED_ADDRESS: + impl_set_typed_address (EPHY_EMBED (object), g_value_get_string (value), + EPHY_EMBED_ADDRESS_EXPIRE_NOW); + break; + case PROP_ADDRESS: case PROP_DOCUMENT_TYPE: case PROP_LOAD_PROGRESS: case PROP_LOAD_STATUS: @@ -307,8 +327,9 @@ mozilla_embed_class_init (MozillaEmbedClass *klass) static void mozilla_embed_init (MozillaEmbed *embed) { - embed->priv = MOZILLA_EMBED_GET_PRIVATE (embed); - embed->priv->browser = new EphyBrowser (); + MozillaEmbedPrivate *priv = embed->priv; + priv = MOZILLA_EMBED_GET_PRIVATE (embed); + priv->browser = new EphyBrowser (); g_signal_connect_object (embed, "location", G_CALLBACK (mozilla_embed_location_changed_cb), @@ -338,12 +359,14 @@ mozilla_embed_init (MozillaEmbed *embed) G_CALLBACK (mozilla_embed_zoom_change_cb), embed, (GConnectFlags) 0); - embed->priv->document_type = EPHY_EMBED_DOCUMENT_HTML; - embed->priv->security_level = EPHY_EMBED_STATE_IS_UNKNOWN; - embed->priv->zoom = 1.0; - embed->priv->is_setting_zoom = FALSE; - embed->priv->load_percent = 0; - embed->priv->is_loading = FALSE; + priv->document_type = EPHY_EMBED_DOCUMENT_HTML; + priv->security_level = EPHY_EMBED_STATE_IS_UNKNOWN; + priv->zoom = 1.0; + priv->is_setting_zoom = FALSE; + priv->load_percent = 0; + priv->is_loading = FALSE; + priv->typed_address = NULL; + priv->address_expire = EPHY_EMBED_ADDRESS_EXPIRE_NOW; } gpointer @@ -378,6 +401,9 @@ mozilla_embed_finalize (GObject *object) embed->priv->browser = nsnull; } + g_free (embed->priv->address); + g_free (embed->priv->typed_address); + G_OBJECT_CLASS (mozilla_embed_parent_class)->finalize (object); g_object_unref (embed_shell); @@ -1003,6 +1029,70 @@ impl_get_navigation_flags (EphyEmbed *embed) return priv->nav_flags; } +static const char* +impl_get_typed_address (EphyEmbed *embed) +{ + return MOZILLA_EMBED (embed)->priv->typed_address; +} + +static void +impl_set_typed_address (EphyEmbed *embed, + const char *address, + EphyEmbedAddressExpire expire) +{ + MozillaEmbedPrivate *priv = MOZILLA_EMBED (embed)->priv; + + g_free (priv->typed_address); + priv->typed_address = g_strdup (address); + + if (expire == EPHY_EMBED_ADDRESS_EXPIRE_CURRENT && + !priv->is_loading) + { + priv->address_expire = EPHY_EMBED_ADDRESS_EXPIRE_NOW; + } + else + { + priv->address_expire = expire; + } + + g_object_notify (G_OBJECT (embed), "typed-address"); +} + +static const char* +impl_get_address (EphyEmbed *embed) +{ + MozillaEmbedPrivate *priv = MOZILLA_EMBED (embed)->priv; + + return priv->address ? priv->address : "about:blank"; +} + +static void +impl_set_address (EphyEmbed *embed, char *address) +{ + MozillaEmbedPrivate *priv = MOZILLA_EMBED (embed)->priv; + GObject *object = G_OBJECT (embed); + + g_free (priv->address); + priv->address = address; + +#if 0 + priv->is_blank = address == NULL || + strcmp (address, "about:blank") == 0; +#endif + + 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 void mozilla_embed_location_changed_cb (GtkMozEmbed *embed, MozillaEmbed *membed) @@ -1466,6 +1556,10 @@ ephy_embed_iface_init (EphyEmbedIface *iface) iface->set_load_status = impl_set_load_status; iface->update_navigation_flags = impl_update_navigation_flags; iface->get_navigation_flags = impl_get_navigation_flags; + iface->get_typed_address = impl_get_typed_address; + iface->set_typed_address = impl_set_typed_address; + iface->get_address = impl_get_address; + iface->set_address = impl_set_address; } static void |