diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2005-10-13 03:45:07 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2005-10-13 03:45:07 +0800 |
commit | 85939a287cbb2b9c789581ddc6d529dd24d2c870 (patch) | |
tree | 1e3c11cf2b7bd036c4d07f4c82ae2f0728255f43 /embed/mozilla | |
parent | 5f02d1125ef8c08ebd3d145565b6f054084f2658 (diff) | |
download | gsoc2013-epiphany-85939a287cbb2b9c789581ddc6d529dd24d2c870.tar gsoc2013-epiphany-85939a287cbb2b9c789581ddc6d529dd24d2c870.tar.gz gsoc2013-epiphany-85939a287cbb2b9c789581ddc6d529dd24d2c870.tar.bz2 gsoc2013-epiphany-85939a287cbb2b9c789581ddc6d529dd24d2c870.tar.lz gsoc2013-epiphany-85939a287cbb2b9c789581ddc6d529dd24d2c870.tar.xz gsoc2013-epiphany-85939a287cbb2b9c789581ddc6d529dd24d2c870.tar.zst gsoc2013-epiphany-85939a287cbb2b9c789581ddc6d529dd24d2c870.zip |
Remove the "network-status" signal from the embed single, and make it a
2005-10-12 Christian Persch <chpe@cvs.gnome.org>
* embed/ephy-embed-single.c: (ephy_embed_single_iface_init),
(ephy_embed_single_set_network_status),
(ephy_embed_single_get_network_status):
* embed/ephy-embed-single.h:
* embed/mozilla/EphySingle.cpp:
* embed/mozilla/EphySingle.h:
* embed/mozilla/mozilla-embed-single.cpp:
* src/ephy-window.c: (sync_tab_icon), (sync_network_status),
(ephy_window_dispose), (ephy_window_init):
* src/epiphany.defs:
* src/window-commands.c: (window_cmd_file_work_offline):
Remove the "network-status" signal from the embed single, and
make it a property instead. Keep track of the network status in
EphySingle, and emit property notification when it changes.
Diffstat (limited to 'embed/mozilla')
-rw-r--r-- | embed/mozilla/EphySingle.cpp | 7 | ||||
-rw-r--r-- | embed/mozilla/EphySingle.h | 3 | ||||
-rw-r--r-- | embed/mozilla/mozilla-embed-single.cpp | 51 |
3 files changed, 50 insertions, 11 deletions
diff --git a/embed/mozilla/EphySingle.cpp b/embed/mozilla/EphySingle.cpp index 0d920900a..3a3948de0 100644 --- a/embed/mozilla/EphySingle.cpp +++ b/embed/mozilla/EphySingle.cpp @@ -45,6 +45,7 @@ NS_IMPL_ISUPPORTS1(EphySingle, nsIObserver) EphySingle::EphySingle() : mOwner(nsnull) +, mIsOnline(PR_TRUE) /* nsIOService doesn't send an initial notification, assume we start on-line */ { LOG ("EphySingle ctor"); } @@ -233,11 +234,9 @@ NS_IMETHODIMP EphySingle::Observe(nsISupports *aSubject, else if (strcmp (aTopic, "network:offline-status-changed") == 0) { /* aData is either (PRUnichar[]) "offline" or "online" */ - gboolean offline; + mIsOnline = (aData && aData[0] == 'o' && aData[1] == 'n'); - offline = (aData[1] == 'f'); - - g_signal_emit_by_name (mOwner, "network-status", offline); + g_object_notify (G_OBJECT (mOwner), "network-status"); } else { diff --git a/embed/mozilla/EphySingle.h b/embed/mozilla/EphySingle.h index aff9de9a6..9bbc3f863 100644 --- a/embed/mozilla/EphySingle.h +++ b/embed/mozilla/EphySingle.h @@ -45,6 +45,8 @@ public: nsresult Init (EphyEmbedSingle *aOwner); nsresult Detach (); + PRBool IsOnline() { return mIsOnline; } + protected: nsresult EmitCookieNotification (const char *name, nsISupports *aSubject); nsresult EmitPermissionNotification (const char *name, nsISupports *aSubject); @@ -52,6 +54,7 @@ protected: private: nsCOMPtr<nsIObserverService> mObserverService; EphyEmbedSingle *mOwner; + PRBool mIsOnline; }; EphyCookie *mozilla_cookie_to_ephy_cookie (nsICookie *cookie); diff --git a/embed/mozilla/mozilla-embed-single.cpp b/embed/mozilla/mozilla-embed-single.cpp index f01fbcab3..da5272b96 100644 --- a/embed/mozilla/mozilla-embed-single.cpp +++ b/embed/mozilla/mozilla-embed-single.cpp @@ -105,6 +105,14 @@ struct MozillaEmbedSinglePrivate GtkWidget *theme_window; EphySingle *mSingleObserver; + + guint online : 1; +}; + +enum +{ + PROP_0, + PROP_NETWORK_STATUS }; static void mozilla_embed_single_class_init (MozillaEmbedSingleClass *klass); @@ -626,18 +634,23 @@ impl_clear_auth_cache (EphyEmbedSingle *shell) } static void -impl_set_offline_mode (EphyEmbedSingle *shell, - gboolean offline) +impl_set_network_status (EphyEmbedSingle *single, + gboolean online) { nsCOMPtr<nsIIOService> io = do_GetService(NS_IOSERVICE_CONTRACTID); if (!io) return; - io->SetOffline(offline); + io->SetOffline (!online); } static gboolean -impl_get_offline_mode (EphyEmbedSingle *shell) +impl_get_network_status (EphyEmbedSingle *esingle) { + MozillaEmbedSingle *single = MOZILLA_EMBED_SINGLE (esingle); + MozillaEmbedSinglePrivate *priv = single->priv; + + NS_ENSURE_TRUE (priv->mSingleObserver, TRUE); + nsCOMPtr<nsIIOService> io = do_GetService(NS_IOSERVICE_CONTRACTID); if (!io) return FALSE; /* no way to check the state, assume offline */ @@ -646,7 +659,12 @@ impl_get_offline_mode (EphyEmbedSingle *shell) rv = io->GetOffline(&isOffline); NS_ENSURE_SUCCESS (rv, FALSE); - return isOffline; + PRBool isOnline = !isOffline; + PRBool reallyOnline = priv->mSingleObserver->IsOnline (); + + g_return_val_if_fail (reallyOnline == isOnline, TRUE); + + return !isOffline; } static GList * @@ -985,6 +1003,22 @@ impl_open_window (EphyEmbedSingle *single, } static void +mozilla_embed_single_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + EphyEmbedSingle *single = EPHY_EMBED_SINGLE (object); + + switch (prop_id) + { + case PROP_NETWORK_STATUS: + g_value_set_boolean (value, ephy_embed_single_get_network_status (single)); + break; + } +} + +static void mozilla_embed_single_class_init (MozillaEmbedSingleClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); @@ -993,6 +1027,9 @@ mozilla_embed_single_class_init (MozillaEmbedSingleClass *klass) object_class->dispose = mozilla_embed_single_dispose; object_class->finalize = mozilla_embed_single_finalize; + object_class->get_property = mozilla_embed_single_get_property; + + g_object_class_override_property (object_class, PROP_NETWORK_STATUS, "network-status"); g_type_class_add_private (object_class, sizeof (MozillaEmbedSinglePrivate)); } @@ -1002,8 +1039,8 @@ ephy_embed_single_iface_init (EphyEmbedSingleIface *iface) { iface->clear_cache = impl_clear_cache; iface->clear_auth_cache = impl_clear_auth_cache; - iface->set_offline_mode = impl_set_offline_mode; - iface->get_offline_mode = impl_get_offline_mode; + iface->set_network_status = impl_set_network_status; + iface->get_network_status = impl_get_network_status; iface->get_font_list = impl_get_font_list; iface->open_window = impl_open_window; } |