aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog18
-rw-r--r--embed/ephy-embed-single.c50
-rw-r--r--embed/ephy-embed-single.h14
-rw-r--r--embed/mozilla/EphySingle.cpp7
-rw-r--r--embed/mozilla/EphySingle.h3
-rw-r--r--embed/mozilla/mozilla-embed-single.cpp51
-rw-r--r--src/ephy-window.c27
-rw-r--r--src/epiphany.defs8
-rw-r--r--src/window-commands.c2
9 files changed, 116 insertions, 64 deletions
diff --git a/ChangeLog b/ChangeLog
index b9c02bb0c..14d96b416 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
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.
+
+2005-10-12 Christian Persch <chpe@cvs.gnome.org>
+
* embed/mozilla/EphyAboutModule.cpp:
* embed/mozilla/EphyAboutModule.h:
A embed/mozilla/EphyRedirectChannel.cpp:
diff --git a/embed/ephy-embed-single.c b/embed/ephy-embed-single.c
index 8fb7141ed..ca78fed11 100644
--- a/embed/ephy-embed-single.c
+++ b/embed/ephy-embed-single.c
@@ -51,7 +51,7 @@ ephy_embed_single_get_type (void)
}
static void
-ephy_embed_single_iface_init (gpointer g_class)
+ephy_embed_single_iface_init (gpointer g_iface)
{
static gboolean initialised = FALSE;
@@ -104,23 +104,6 @@ ephy_embed_single_iface_init (gpointer g_class)
G_TYPE_STRING);
/**
- * EphyEmbedSingle::network-status:
- * @single:
- * @offline: the network status
- *
- * The ::network-status signal is emitted when the network status changes.
- **/
- g_signal_new ("network-status",
- EPHY_TYPE_EMBED_SINGLE,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EphyEmbedSingleIface, network_status),
- NULL, NULL,
- g_cclosure_marshal_VOID__BOOLEAN,
- G_TYPE_NONE,
- 1,
- G_TYPE_BOOLEAN);
-
-/**
* EphyEmbedSingle::add-sidebar:
* @single:
* @url: The url of the sidebar to be added
@@ -189,6 +172,19 @@ ephy_embed_single_iface_init (gpointer g_class)
G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE,
G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE);
+/**
+ * EphyEmbedSingle::network-status:
+ *
+ * Whether the network is on-line.
+ */
+ g_object_interface_install_property
+ (g_iface,
+ g_param_spec_boolean ("network-status",
+ "network-status",
+ "network-status",
+ FALSE,
+ G_PARAM_READABLE));
+
initialised = TRUE;
}
}
@@ -228,31 +224,33 @@ ephy_embed_single_clear_auth_cache (EphyEmbedSingle *single)
}
/**
- * ephy_embed_single_set_offline_mode:
+ * ephy_embed_single_get_nework_status:
* @single: the #EphyEmbedSingle
- * @offline: %TRUE to disable networking
+ * @offline: %TRUE if the network is on-line
*
* Sets the state of the network connection.
**/
void
-ephy_embed_single_set_offline_mode (EphyEmbedSingle *single,
- gboolean offline)
+ephy_embed_single_set_network_status (EphyEmbedSingle *single,
+ gboolean status)
{
EphyEmbedSingleIface *iface = EPHY_EMBED_SINGLE_GET_IFACE (single);
- iface->set_offline_mode (single, offline);
+ iface->set_network_status (single, status);
}
/**
- * ephy_embed_single_get_offline_mode:
+ * ephy_embed_single_get_network_status:
* @single: the #EphyEmbedSingle
*
* Gets the state of the network connection.
+ *
+ * Returns: %TRUE iff the network is on-line.
**/
gboolean
-ephy_embed_single_get_offline_mode (EphyEmbedSingle *single)
+ephy_embed_single_get_network_status (EphyEmbedSingle *single)
{
EphyEmbedSingleIface *iface = EPHY_EMBED_SINGLE_GET_IFACE (single);
- return iface->get_offline_mode (single);
+ return iface->get_network_status (single);
}
/**
diff --git a/embed/ephy-embed-single.h b/embed/ephy-embed-single.h
index d275ea116..a89399b2b 100644
--- a/embed/ephy-embed-single.h
+++ b/embed/ephy-embed-single.h
@@ -61,10 +61,6 @@ struct _EphyEmbedSingleIface
char *mime_type,
char *uri);
- void (* network_status) (EphyEmbedSingle *single,
- gboolean offline);
-
-
gboolean (* add_sidebar) (EphyEmbedSingle *single,
const char *url,
const char *title);
@@ -88,9 +84,9 @@ struct _EphyEmbedSingleIface
const char *features);
void (* clear_cache) (EphyEmbedSingle *shell);
void (* clear_auth_cache) (EphyEmbedSingle *shell);
- void (* set_offline_mode) (EphyEmbedSingle *shell,
+ void (* set_network_status)(EphyEmbedSingle *shell,
gboolean offline);
- gboolean (* get_offline_mode) (EphyEmbedSingle *single);
+ gboolean (* get_network_status)(EphyEmbedSingle *single);
GList * (* get_font_list) (EphyEmbedSingle *shell,
const char *langGroup);
};
@@ -107,10 +103,10 @@ void ephy_embed_single_clear_cache (EphyEmbedSingle *single);
void ephy_embed_single_clear_auth_cache (EphyEmbedSingle *single);
-void ephy_embed_single_set_offline_mode (EphyEmbedSingle *single,
- gboolean offline);
+void ephy_embed_single_set_network_status (EphyEmbedSingle *single,
+ gboolean online);
-gboolean ephy_embed_single_get_offline_mode (EphyEmbedSingle *single);
+gboolean ephy_embed_single_get_network_status (EphyEmbedSingle *single);
GList *ephy_embed_single_get_font_list (EphyEmbedSingle *single,
const char *lang_group);
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;
}
diff --git a/src/ephy-window.c b/src/ephy-window.c
index c1d2fa02e..5493b4585 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -152,7 +152,7 @@ static const GtkActionEntry ephy_menu_entries [] = {
{ "FilePrint", GTK_STOCK_PRINT, N_("_Print..."), "<control>P",
N_("Print the current page"),
G_CALLBACK (window_cmd_file_print) },
- { "FileSendTo", STOCK_SEND_MAIL, N_("S_end To..."), "<control>M",
+ { "FileSendTo", STOCK_SEND_MAIL, N_("S_end Link by Email..."), "<control>M",
N_("Send a link of the current page"),
G_CALLBACK (window_cmd_file_send_to) },
{ "FileCloseTab", GTK_STOCK_CLOSE, N_("_Close"), "<control>W",
@@ -1244,7 +1244,6 @@ sync_tab_icon (EphyTab *tab,
icon = ephy_tab_get_icon (tab);
- gtk_window_set_icon (GTK_WINDOW (window), icon);
ephy_toolbar_set_favicon (priv->toolbar, icon);
}
@@ -1565,17 +1564,21 @@ sync_tab_zoom (EphyTab *tab, GParamSpec *pspec, EphyWindow *window)
}
static void
-network_status_changed (EphyEmbedSingle *single,
- gboolean offline,
- EphyWindow *window)
+sync_network_status (EphyEmbedSingle *single,
+ GParamSpec *pspec,
+ EphyWindow *window)
{
+ EphyWindowPrivate *priv = window->priv;
GtkAction *action;
+ gboolean is_online;
- action = gtk_action_group_get_action (window->priv->action_group,
+ is_online = ephy_embed_single_get_network_status (single);
+
+ action = gtk_action_group_get_action (priv->action_group,
"FileWorkOffline");
g_signal_handlers_block_by_func
(action, G_CALLBACK (window_cmd_file_work_offline), window);
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), offline);
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), !is_online);
g_signal_handlers_unblock_by_func
(action, G_CALLBACK (window_cmd_file_work_offline), window);
}
@@ -2512,7 +2515,7 @@ ephy_window_dispose (GObject *object)
single = ephy_embed_shell_get_embed_single (embed_shell);
g_signal_handlers_disconnect_by_func
- (single, G_CALLBACK (network_status_changed), window);
+ (single, G_CALLBACK (sync_network_status), window);
eel_gconf_notification_remove (priv->browse_with_caret_notifier_id);
eel_gconf_notification_remove (priv->allow_popups_notifier_id);
@@ -3012,11 +3015,9 @@ ephy_window_init (EphyWindow *window)
/* network status */
single = EPHY_EMBED_SINGLE (ephy_embed_shell_get_embed_single (embed_shell));
- network_status_changed (single,
- ephy_embed_single_get_offline_mode (single),
- window);
- g_signal_connect (single, "network-status",
- G_CALLBACK (network_status_changed), window);
+ sync_network_status (single, NULL, window);
+ g_signal_connect (single, "notify::network-status",
+ G_CALLBACK (sync_network_status), window);
/* ensure the UI is updated */
gtk_ui_manager_ensure_update (window->priv->manager);
diff --git a/src/epiphany.defs b/src/epiphany.defs
index 6d556aa7b..6ab363578 100644
--- a/src/epiphany.defs
+++ b/src/epiphany.defs
@@ -878,18 +878,18 @@
(return-type "none")
)
-(define-method set_offline_mode
+(define-method set_network_status
(of-object "EphyEmbedSingle")
- (c-name "ephy_embed_single_set_offline_mode")
+ (c-name "ephy_embed_single_set_network_status")
(return-type "none")
(parameters
'("gboolean" "offline")
)
)
-(define-method get_offline_mode
+(define-method get_network_status
(of-object "EphyEmbedSingle")
- (c-name "ephy_embed_single_get_offline_mode")
+ (c-name "ephy_embed_single_get_network_status")
(return-type "gboolean")
)
diff --git a/src/window-commands.c b/src/window-commands.c
index 79659dba9..4ec865a86 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -381,7 +381,7 @@ window_cmd_file_work_offline (GtkAction *action,
single = EPHY_EMBED_SINGLE (ephy_embed_shell_get_embed_single (embed_shell));
offline = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
- ephy_embed_single_set_offline_mode (single, offline);
+ ephy_embed_single_set_network_status (single, !offline);
}
void