NetworkManager r3896 - in trunk: . src
- From: dcbw svn gnome org
- To: svn-commits-list gnome org
- Subject: NetworkManager r3896 - in trunk: . src
- Date: Mon, 4 Aug 2008 22:24:58 +0000 (UTC)
Author: dcbw
Date: Mon Aug 4 22:24:58 2008
New Revision: 3896
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=3896&view=rev
Log:
2008-08-04 Dan Williams <dcbw redhat com>
Patch from Sjoerd Simons <sjoerd simons collabora co uk>
* src/NetworkManager.c
src/nm-manager.c
src/nm-manager.h
- More explicitly make the NMManager a singleton
Modified:
trunk/ChangeLog
trunk/src/NetworkManager.c
trunk/src/nm-manager.c
trunk/src/nm-manager.h
Modified: trunk/src/NetworkManager.c
==============================================================================
--- trunk/src/NetworkManager.c (original)
+++ trunk/src/NetworkManager.c Mon Aug 4 22:24:58 2008
@@ -303,7 +303,7 @@
goto done;
}
- manager = nm_manager_new ();
+ manager = nm_manager_get ();
if (manager == NULL) {
nm_error ("Failed to initialize the network manager.");
goto done;
Modified: trunk/src/nm-manager.c
==============================================================================
--- trunk/src/nm-manager.c (original)
+++ trunk/src/nm-manager.c Mon Aug 4 22:24:58 2008
@@ -1353,49 +1353,54 @@
}
NMManager *
-nm_manager_new (void)
+nm_manager_get (void)
{
- GObject *object;
+ static NMManager *singleton = NULL;
NMManagerPrivate *priv;
- object = g_object_new (NM_TYPE_MANAGER, NULL);
- priv = NM_MANAGER_GET_PRIVATE (object);
+ if (singleton)
+ return g_object_ref (singleton);
+
+ singleton = (NMManager *) g_object_new (NM_TYPE_MANAGER, NULL);
+ g_assert (singleton);
+
+ priv = NM_MANAGER_GET_PRIVATE (singleton);
dbus_g_connection_register_g_object (nm_dbus_manager_get_connection (priv->dbus_mgr),
NM_DBUS_PATH,
- object);
+ G_OBJECT (singleton));
g_signal_connect (priv->dbus_mgr,
"name-owner-changed",
G_CALLBACK (nm_manager_name_owner_changed),
- NM_MANAGER (object));
+ singleton);
- g_idle_add ((GSourceFunc) initial_get_connections, NM_MANAGER (object));
+ g_idle_add ((GSourceFunc) initial_get_connections, singleton);
priv->hal_mgr = nm_hal_manager_new ();
- priv->sync_devices_id = g_idle_add (deferred_sync_devices, object);
+ priv->sync_devices_id = g_idle_add (deferred_sync_devices, singleton);
g_signal_connect (priv->hal_mgr,
"udi-added",
G_CALLBACK (hal_manager_udi_added_cb),
- NM_MANAGER (object));
+ singleton);
g_signal_connect (priv->hal_mgr,
"udi-removed",
G_CALLBACK (hal_manager_udi_removed_cb),
- NM_MANAGER (object));
+ singleton);
g_signal_connect (priv->hal_mgr,
"rfkill-changed",
G_CALLBACK (hal_manager_rfkill_changed_cb),
- NM_MANAGER (object));
+ singleton);
g_signal_connect (priv->hal_mgr,
"hal-reappeared",
G_CALLBACK (hal_manager_hal_reappeared_cb),
- NM_MANAGER (object));
+ singleton);
- return NM_MANAGER (object);
+ return singleton;
}
static void
Modified: trunk/src/nm-manager.h
==============================================================================
--- trunk/src/nm-manager.h (original)
+++ trunk/src/nm-manager.h Mon Aug 4 22:24:58 2008
@@ -52,7 +52,7 @@
GType nm_manager_get_type (void);
-NMManager *nm_manager_new (void);
+NMManager *nm_manager_get (void);
/* Device handling */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]