aboutsummaryrefslogtreecommitdiffstats
path: root/src/ephy-shell.c
diff options
context:
space:
mode:
authorClaudio Saavedra <csaavedra@igalia.com>2011-06-24 04:18:37 +0800
committerClaudio Saavedra <csaavedra@igalia.com>2011-06-24 05:00:18 +0800
commit3af15cdbcd31a7ac4eda748ae83180a228d30a80 (patch)
tree1454d2f428a9b6ef143efb54447ed4ebd49827a8 /src/ephy-shell.c
parentab913fa36787366d68e08a0831403872d3e62ffc (diff)
downloadgsoc2013-epiphany-3af15cdbcd31a7ac4eda748ae83180a228d30a80.tar
gsoc2013-epiphany-3af15cdbcd31a7ac4eda748ae83180a228d30a80.tar.gz
gsoc2013-epiphany-3af15cdbcd31a7ac4eda748ae83180a228d30a80.tar.bz2
gsoc2013-epiphany-3af15cdbcd31a7ac4eda748ae83180a228d30a80.tar.lz
gsoc2013-epiphany-3af15cdbcd31a7ac4eda748ae83180a228d30a80.tar.xz
gsoc2013-epiphany-3af15cdbcd31a7ac4eda748ae83180a228d30a80.tar.zst
gsoc2013-epiphany-3af15cdbcd31a7ac4eda748ae83180a228d30a80.zip
Use a gdbus-codegen generated GDBusProxy to monitor NM state
Get rid of the EphyNetMonitor code and instead generate a GDBusProxy subclass that monitors the StateChanged signal and State property in org.gnome.NetworkManager. This proxy exports these features as standard GObject signal and property, respectively, so we can use it directly through the relevant accessors. https://bugzilla.gnome.org/show_bug.cgi?id=622903
Diffstat (limited to 'src/ephy-shell.c')
-rw-r--r--src/ephy-shell.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index ef45fb493..6a246ee76 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -58,7 +58,8 @@
#include "ephy-web-view.h"
#ifdef ENABLE_NETWORK_MANAGER
-#include "ephy-net-monitor.h"
+#include <NetworkManager.h>
+#include "ephy-network-manager.h"
#endif
#define EPHY_SHELL_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_SHELL, EphyShellPrivate))
@@ -72,7 +73,7 @@ struct _EphyShellPrivate
EggToolbarsModel *fs_toolbars_model;
EphyExtensionsManager *extensions_manager;
#ifdef ENABLE_NETWORK_MANAGER
- EphyNetMonitor *net_monitor;
+ EphyNetworkManager *nm_proxy;
#endif
GtkWidget *bme;
GtkWidget *history_window;
@@ -151,8 +152,8 @@ ephy_shell_new_window_cb (EphyEmbedSingle *single,
#ifdef ENABLE_NETWORK_MANAGER
static void
-ephy_shell_sync_network_status (EphyNetMonitor *net_monitor,
- GParamSpec *pspec,
+ephy_shell_sync_network_status (EphyNetworkManager *nm_proxy,
+ NMState state,
EphyShell *shell)
{
EphyShellPrivate *priv = shell->priv;
@@ -163,7 +164,7 @@ ephy_shell_sync_network_status (EphyNetMonitor *net_monitor,
single = EPHY_EMBED_SINGLE (ephy_embed_shell_get_embed_single (EPHY_EMBED_SHELL (shell)));
- net_status = ephy_net_monitor_get_net_status (net_monitor);
+ net_status = state == NM_STATE_CONNECTED;
ephy_embed_single_set_network_status (single, net_status);
}
@@ -190,7 +191,9 @@ impl_get_embed_single (EphyEmbedShell *embed_shell)
#ifdef ENABLE_NETWORK_MANAGER
/* Now we need the net monitor */
ephy_shell_get_net_monitor (shell);
- ephy_shell_sync_network_status (priv->net_monitor, NULL, shell);
+ ephy_shell_sync_network_status (priv->nm_proxy,
+ ephy_network_manager_get_state (priv->nm_proxy),
+ shell);
#endif
}
@@ -291,13 +294,13 @@ ephy_shell_dispose (GObject *object)
}
#ifdef ENABLE_NETWORK_MANAGER
- if (priv->net_monitor != NULL)
+ if (priv->nm_proxy != NULL)
{
LOG ("Unref net monitor");
g_signal_handlers_disconnect_by_func
- (priv->net_monitor, G_CALLBACK (ephy_shell_sync_network_status), shell);
- g_object_unref (priv->net_monitor);
- priv->net_monitor = NULL;
+ (priv->nm_proxy, G_CALLBACK (ephy_shell_sync_network_status), shell);
+ g_object_unref (priv->nm_proxy);
+ priv->nm_proxy = NULL;
}
#endif /* ENABLE_NETWORK_MANAGER */
@@ -669,14 +672,19 @@ ephy_shell_get_net_monitor (EphyShell *shell)
#ifdef ENABLE_NETWORK_MANAGER
EphyShellPrivate *priv = shell->priv;
- if (priv->net_monitor == NULL)
+ if (priv->nm_proxy == NULL)
{
- priv->net_monitor = ephy_net_monitor_new ();
- g_signal_connect (priv->net_monitor, "notify::network-status",
+ priv->nm_proxy = ephy_network_manager_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NM_DBUS_SERVICE,
+ NM_DBUS_PATH,
+ NULL,
+ NULL);
+ g_signal_connect (priv->nm_proxy, "state-changed",
G_CALLBACK (ephy_shell_sync_network_status), shell);
}
- return G_OBJECT (priv->net_monitor);
+ return G_OBJECT (priv->nm_proxy);
#else
return NULL;
#endif /* ENABLE_NETWORK_MANAGER */