diff options
-rw-r--r-- | embed/ephy-embed.c | 38 | ||||
-rw-r--r-- | embed/ephy-embed.h | 8 | ||||
-rw-r--r-- | embed/mozilla/mozilla-embed.cpp | 31 | ||||
-rw-r--r-- | src/ephy-tab.c | 61 | ||||
-rw-r--r-- | src/ephy-window.c | 20 | ||||
-rw-r--r-- | src/epiphany.defs | 6 |
6 files changed, 89 insertions, 75 deletions
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c index 97e46d6a3..2b3c99383 100644 --- a/embed/ephy-embed.c +++ b/embed/ephy-embed.c @@ -447,6 +447,15 @@ ephy_embed_base_init (gpointer g_class) 1.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_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)); + initialized = TRUE; } @@ -1055,3 +1064,32 @@ 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_set_load_percent: + * @embed: an #EphyEmbed + * @percent: a percentage, from 0 to 100. + * + * Sets the load percentage. + **/ +void +ephy_embed_set_load_percent (EphyEmbed *embed, int percent) +{ + EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed); + return iface->set_load_percent (embed, percent); +} diff --git a/embed/ephy-embed.h b/embed/ephy-embed.h index 599174c51..da8e8557e 100644 --- a/embed/ephy-embed.h +++ b/embed/ephy-embed.h @@ -229,7 +229,8 @@ struct _EphyEmbedIface gboolean (* has_modified_forms) (EphyEmbed *embed); void (* close) (EphyEmbed *embed); EphyEmbedDocumentType (* get_document_type) (EphyEmbed *embed); - + int (* get_load_percent) (EphyEmbed *embed); + void (* set_load_percent) (EphyEmbed *embed, int percent); }; GType ephy_embed_net_state_get_type (void); @@ -326,6 +327,11 @@ void ephy_embed_scroll_pixels (EphyEmbed *embed, EphyEmbedDocumentType ephy_embed_get_document_type (EphyEmbed *embed); +/* Progress */ + +int ephy_embed_get_load_percent (EphyEmbed *embed); +void ephy_embed_set_load_percent (EphyEmbed *embed, int percent); + /* Encoding */ char *ephy_embed_get_encoding (EphyEmbed *embed); diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp index 538641804..57ce9467d 100644 --- a/embed/mozilla/mozilla-embed.cpp +++ b/embed/mozilla/mozilla-embed.cpp @@ -106,6 +106,7 @@ struct MozillaEmbedPrivate EphyEmbedDocumentType document_type; float zoom; guint is_setting_zoom : 1; + gint8 load_percent; }; #define WINDOWWATCHER_CONTRACTID "@mozilla.org/embedcomp/window-watcher;1" @@ -114,6 +115,7 @@ enum { PROP_0, PROP_DOCUMENT_TYPE, + PROP_LOAD_PROGRESS, PROP_SECURITY, PROP_ZOOM }; @@ -228,6 +230,9 @@ mozilla_embed_get_property (GObject *object, case PROP_ZOOM: g_value_set_float (value, priv->zoom); break; + case PROP_LOAD_PROGRESS: + g_value_set_int (value, priv->load_percent); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -244,6 +249,7 @@ mozilla_embed_set_property (GObject *object, switch (prop_id) { case PROP_DOCUMENT_TYPE: + case PROP_LOAD_PROGRESS: case PROP_SECURITY: case PROP_ZOOM: /* read only */ @@ -276,6 +282,7 @@ mozilla_embed_class_init (MozillaEmbedClass *klass) g_object_class_override_property (object_class, PROP_DOCUMENT_TYPE, "document-type"); g_object_class_override_property (object_class, PROP_SECURITY, "security-level"); g_object_class_override_property (object_class, PROP_ZOOM, "zoom"); + g_object_class_override_property (object_class, PROP_ZOOM, "load-progress"); g_type_class_add_private (object_class, sizeof(MozillaEmbedPrivate)); } @@ -318,6 +325,7 @@ mozilla_embed_init (MozillaEmbed *embed) 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; } gpointer @@ -896,6 +904,27 @@ impl_get_document_type (EphyEmbed *embed) return mpriv->document_type; } +static int +impl_get_load_percent (EphyEmbed *embed) +{ + MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(embed)->priv; + + return mpriv->load_percent; +} + +static void +impl_set_load_percent (EphyEmbed *embed, int percent) +{ + MozillaEmbedPrivate *mpriv = MOZILLA_EMBED (embed)->priv; + + if (percent != mpriv->load_percent) + { + mpriv->load_percent = percent; + + g_object_notify (G_OBJECT (embed), "load-progress"); + } +} + static void mozilla_embed_location_changed_cb (GtkMozEmbed *embed, MozillaEmbed *membed) @@ -1353,6 +1382,8 @@ ephy_embed_iface_init (EphyEmbedIface *iface) iface->print_preview_navigate = impl_print_preview_navigate; iface->has_modified_forms = impl_has_modified_forms; iface->get_document_type = impl_get_document_type; + iface->get_load_percent = impl_get_load_percent; + iface->set_load_percent = impl_set_load_percent; } static void diff --git a/src/ephy-tab.c b/src/ephy-tab.c index b7b4852ad..c8f718188 100644 --- a/src/ephy-tab.c +++ b/src/ephy-tab.c @@ -98,7 +98,6 @@ struct _EphyTabPrivate EphyTabNavigationFlags nav_flags; guint idle_resize_handler; - gint8 load_percent; /* Flags */ guint is_blank : 1; guint is_loading : 1; @@ -122,7 +121,6 @@ enum PROP_ADDRESS, PROP_ICON, PROP_ICON_ADDRESS, - PROP_LOAD_PROGRESS, PROP_LOAD_STATUS, PROP_MESSAGE, PROP_NAVIGATION, @@ -154,8 +152,6 @@ static void ephy_tab_set_load_status (EphyTab *tab, gboolean status); static void ephy_tab_set_link_message (EphyTab *tab, char *message); -static void ephy_tab_set_load_percent (EphyTab *tab, - int percent); static void ephy_tab_update_navigation_flags(EphyTab *tab, EphyEmbed *embed); static void ephy_tab_set_title (EphyTab *tab, @@ -231,7 +227,6 @@ ephy_tab_set_property (GObject *object, break; case PROP_ADDRESS: case PROP_ICON: - case PROP_LOAD_PROGRESS: case PROP_LOAD_STATUS: case PROP_MESSAGE: case PROP_NAVIGATION: @@ -262,9 +257,6 @@ ephy_tab_get_property (GObject *object, case PROP_ICON_ADDRESS: g_value_set_string (value, priv->icon_address); 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; @@ -404,16 +396,6 @@ ephy_tab_class_init (EphyTabClass *class) (G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB))); g_object_class_install_property (object_class, - PROP_LOAD_PROGRESS, - g_param_spec_int ("load-progress", - "Load progress", - "The tab'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 (object_class, PROP_LOAD_STATUS, g_param_spec_boolean ("load-status", "Load status", @@ -1636,7 +1618,7 @@ build_progress_from_requests (EphyTab *tab, EphyEmbedNetState state) load_percent = build_load_percent (tab->priv->cur_requests, tab->priv->total_requests); - ephy_tab_set_load_percent (tab, load_percent); + ephy_embed_set_load_percent (ephy_tab_get_embed (tab), load_percent); } } @@ -1679,7 +1661,7 @@ ephy_tab_net_state_cb (EphyEmbed *embed, priv->total_requests = 0; priv->cur_requests = 0; - ephy_tab_set_load_percent (tab, 0); + ephy_embed_set_load_percent (ephy_tab_get_embed (tab), 0); ephy_tab_set_load_status (tab, TRUE); ephy_tab_update_navigation_flags (tab, embed); @@ -1695,7 +1677,7 @@ ephy_tab_net_state_cb (EphyEmbed *embed, g_object_freeze_notify (object); - ephy_tab_set_load_percent (tab, 100); + ephy_embed_set_load_percent (ephy_tab_get_embed (tab), 100); ephy_tab_set_load_status (tab, FALSE); ephy_tab_update_navigation_flags (tab, embed); @@ -1953,7 +1935,6 @@ ephy_tab_init (EphyTab *tab) tab->priv->cur_requests = 0; tab->priv->width = -1; tab->priv->height = -1; - tab->priv->load_percent = 0; tab->priv->is_loading = FALSE; priv->title = NULL; priv->is_blank = TRUE; @@ -2010,42 +1991,6 @@ ephy_tab_init (EphyTab *tab) tab, 0); } -/** - * ephy_tab_set_load_percent: - * @tab: an #EphyTab - * @percent: a percentage, from 0 to 100. - * - * Sets the load percentage. This will be displayed in the progressbar. - **/ -void -ephy_tab_set_load_percent (EphyTab *tab, int percent) -{ - g_return_if_fail (EPHY_IS_TAB (tab)); - - if (percent != tab->priv->load_percent) - { - tab->priv->load_percent = percent; - - g_object_notify (G_OBJECT (tab), "load-progress"); - } -} - -/** - * ephy_tab_get_load_percent: - * @tab: an #EphyTab - * - * Returns the page load percentage (displayed in the progressbar). - * - * Return value: a percentage from 0 to 100. - **/ -int -ephy_tab_get_load_percent (EphyTab *tab) -{ - g_return_val_if_fail (EPHY_IS_TAB (tab), 0); - - return tab->priv->load_percent; -} - static void ephy_tab_update_navigation_flags (EphyTab *tab, EphyEmbed *embed) { diff --git a/src/ephy-window.c b/src/ephy-window.c index efeb48605..0ee4a68f4 100644 --- a/src/ephy-window.c +++ b/src/ephy-window.c @@ -1441,12 +1441,12 @@ sync_tab_icon (EphyTab *tab, } static void -sync_tab_load_progress (EphyTab *tab, GParamSpec *pspec, EphyWindow *window) +sync_tab_load_progress (EphyEmbed *embed, GParamSpec *pspec, EphyWindow *window) { if (window->priv->closing) return; ephy_statusbar_set_progress (EPHY_STATUSBAR (window->priv->statusbar), - ephy_tab_get_load_percent (tab)); + ephy_embed_get_load_percent (embed)); } static void @@ -2152,9 +2152,6 @@ ephy_window_set_active_tab (EphyWindow *window, EphyTab *new_tab) G_CALLBACK (sync_tab_icon), window); g_signal_handlers_disconnect_by_func (old_tab, - G_CALLBACK (sync_tab_load_progress), - window); - g_signal_handlers_disconnect_by_func (old_tab, G_CALLBACK (sync_tab_load_status), window); g_signal_handlers_disconnect_by_func (old_tab, @@ -2184,7 +2181,9 @@ ephy_window_set_active_tab (EphyWindow *window, EphyTab *new_tab) g_signal_handlers_disconnect_by_func (embed, G_CALLBACK (sync_tab_zoom), window); - + g_signal_handlers_disconnect_by_func (embed, + G_CALLBACK (sync_tab_load_progress), + window); g_signal_handlers_disconnect_by_func (embed, G_CALLBACK (tab_context_menu_cb), window); @@ -2202,10 +2201,10 @@ ephy_window_set_active_tab (EphyWindow *window, EphyTab *new_tab) sync_tab_security (embed, NULL, window); sync_tab_document_type (embed, NULL, window); sync_tab_zoom (embed, NULL, window); + sync_tab_load_progress (embed, NULL, window); sync_tab_address (new_tab, NULL, window); sync_tab_icon (new_tab, NULL, window); - sync_tab_load_progress (new_tab, NULL, window); sync_tab_load_status (new_tab, NULL, window); sync_tab_message (new_tab, NULL, window); sync_tab_navigation (new_tab, NULL, window); @@ -2219,9 +2218,6 @@ ephy_window_set_active_tab (EphyWindow *window, EphyTab *new_tab) g_signal_connect_object (new_tab, "notify::icon", G_CALLBACK (sync_tab_icon), window, 0); - g_signal_connect_object (new_tab, "notify::load-progress", - G_CALLBACK (sync_tab_load_progress), - window, 0); g_signal_connect_object (new_tab, "notify::load-status", G_CALLBACK (sync_tab_load_status), window, 0); @@ -2256,6 +2252,10 @@ ephy_window_set_active_tab (EphyWindow *window, EphyTab *new_tab) g_signal_connect_object (embed, "size-to", G_CALLBACK (tab_size_to_cb), window, 0); + g_signal_connect_object (embed, "notify::load-progress", + G_CALLBACK (sync_tab_load_progress), + window, 0); + g_object_notify (G_OBJECT (window), "active-tab"); } diff --git a/src/epiphany.defs b/src/epiphany.defs index d9ea18035..ee0c10c5b 100644 --- a/src/epiphany.defs +++ b/src/epiphany.defs @@ -3356,12 +3356,6 @@ (return-type "const-char*") ) -(define-method get_load_percent - (of-object "EphyTab") - (c-name "ephy_tab_get_load_percent") - (return-type "int") -) - (define-method get_address (of-object "EphyTab") (c-name "ephy_tab_get_address") |