aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/ephy-node.c22
-rw-r--r--lib/ephy-node.h2
2 files changed, 22 insertions, 2 deletions
diff --git a/lib/ephy-node.c b/lib/ephy-node.c
index b75df9349..c9ee9aa76 100644
--- a/lib/ephy-node.c
+++ b/lib/ephy-node.c
@@ -96,12 +96,14 @@ enum
LAST_SIGNAL
};
+#define RESERVED_IDS 10
+
static GObjectClass *parent_class = NULL;
static guint ephy_node_signals[LAST_SIGNAL] = { 0 };
static GMutex *id_factory_lock = NULL;
-static long id_factory = 0;
+static long id_factory = RESERVED_IDS;
static GStaticRWLock *id_to_node_lock = NULL;
static GPtrArray *id_to_node;
@@ -392,6 +394,22 @@ ephy_node_new (void)
return node;
}
+EphyNode *
+ephy_node_new_with_id (gulong reserved_id)
+{
+ EphyNode *node;
+
+ g_return_val_if_fail (reserved_id < RESERVED_IDS, NULL);
+
+ node = EPHY_NODE (g_object_new (EPHY_TYPE_NODE,
+ "id", reserved_id,
+ NULL));
+
+ g_return_val_if_fail (node->priv != NULL, NULL);
+
+ return node;
+}
+
long
ephy_node_get_id (EphyNode *node)
{
@@ -1367,7 +1385,7 @@ ephy_node_system_init (void)
g_static_rw_lock_init (id_to_node_lock);
/* id factory */
- id_factory = 0;
+ id_factory = RESERVED_IDS;
id_factory_lock = g_mutex_new ();
}
diff --git a/lib/ephy-node.h b/lib/ephy-node.h
index 2e5f92210..5a3413617 100644
--- a/lib/ephy-node.h
+++ b/lib/ephy-node.h
@@ -62,6 +62,8 @@ GType ephy_node_get_type (void);
EphyNode *ephy_node_new (void);
+EphyNode *ephy_node_new_with_id (gulong reserved_id);
+
/* unique node ID */
long ephy_node_get_id (EphyNode *node);