diff options
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | lib/ephy-node.c | 146 | ||||
-rw-r--r-- | lib/ephy-node.h | 18 | ||||
-rw-r--r-- | src/epiphany.defs | 60 |
4 files changed, 217 insertions, 18 deletions
@@ -1,3 +1,14 @@ +2006-05-16 Jean-François Rameau <jframeau@cvs.gnome.org> + + * lib/ephy-node.h: + * lib/ephy-node.c: + * src/epiphany.defs: + + Add methods to EphyNode to set typed properties. This change improves the + Python API so it should be easy now to play with bookmarks. + + Also clean up the code with unnecessary checks. + 2006-05-16 Christian Persch <chpe@cvs.gnome.org> * configure.in: diff --git a/lib/ephy-node.c b/lib/ephy-node.c index 39c72f647..82b198981 100644 --- a/lib/ephy-node.c +++ b/lib/ephy-node.c @@ -444,16 +444,33 @@ real_set_property (EphyNode *node, g_ptr_array_index (node->properties, property_id) = value; } +static inline void +ephy_node_set_property_internal (EphyNode *node, + guint property_id, + GValue *value) +{ + EphyNodeChange change; + + real_set_property (node, property_id, value); + + change.node = node; + change.property_id = property_id; + g_hash_table_foreach (node->parents, + (GHFunc) child_changed, + &change); + + ephy_node_emit_signal (node, EPHY_NODE_CHANGED, property_id); + +} + void ephy_node_set_property (EphyNode *node, guint property_id, const GValue *value) { GValue *new; - EphyNodeChange change; g_return_if_fail (EPHY_IS_NODE (node)); - g_return_if_fail (property_id >= 0); g_return_if_fail (value != NULL); if (ephy_node_db_is_immutable (node->db)) return; @@ -462,15 +479,7 @@ ephy_node_set_property (EphyNode *node, g_value_init (new, G_VALUE_TYPE (value)); g_value_copy (value, new); - real_set_property (node, property_id, new); - - change.node = node; - change.property_id = property_id; - g_hash_table_foreach (node->parents, - (GHFunc) child_changed, - &change); - - ephy_node_emit_signal (node, EPHY_NODE_CHANGED, property_id); + ephy_node_set_property_internal (node, property_id, new); } gboolean @@ -481,7 +490,6 @@ ephy_node_get_property (EphyNode *node, GValue *ret; g_return_val_if_fail (EPHY_IS_NODE (node), FALSE); - g_return_val_if_fail (property_id >= 0, FALSE); g_return_val_if_fail (value != NULL, FALSE); if (property_id >= node->properties->len) { @@ -499,6 +507,24 @@ ephy_node_get_property (EphyNode *node, return TRUE; } +void +ephy_node_set_property_string (EphyNode *node, + guint property_id, + const char *value) +{ + GValue *new; + + g_return_if_fail (EPHY_IS_NODE (node)); + + if (ephy_node_db_is_immutable (node->db)) return; + + new = g_new0 (GValue, 1); + g_value_init (new, G_TYPE_STRING); + g_value_set_string (new, value); + + ephy_node_set_property_internal (node, property_id, new); +} + const char * ephy_node_get_property_string (EphyNode *node, guint property_id) @@ -507,7 +533,6 @@ ephy_node_get_property_string (EphyNode *node, const char *retval; g_return_val_if_fail (EPHY_IS_NODE (node), NULL); - g_return_val_if_fail (property_id >= 0, NULL); if (property_id >= node->properties->len) { return NULL; @@ -523,6 +548,24 @@ ephy_node_get_property_string (EphyNode *node, return retval; } +void +ephy_node_set_property_boolean (EphyNode *node, + guint property_id, + gboolean value) +{ + GValue *new; + + g_return_if_fail (EPHY_IS_NODE (node)); + + if (ephy_node_db_is_immutable (node->db)) return; + + new = g_new0 (GValue, 1); + g_value_init (new, G_TYPE_BOOLEAN); + g_value_set_boolean (new, value); + + ephy_node_set_property_internal (node, property_id, new); +} + gboolean ephy_node_get_property_boolean (EphyNode *node, guint property_id) @@ -531,7 +574,6 @@ ephy_node_get_property_boolean (EphyNode *node, gboolean retval; g_return_val_if_fail (EPHY_IS_NODE (node), FALSE); - g_return_val_if_fail (property_id >= 0, FALSE); if (property_id >= node->properties->len) { return FALSE; @@ -547,6 +589,24 @@ ephy_node_get_property_boolean (EphyNode *node, return retval; } +void +ephy_node_set_property_long (EphyNode *node, + guint property_id, + long value) +{ + GValue *new; + + g_return_if_fail (EPHY_IS_NODE (node)); + + if (ephy_node_db_is_immutable (node->db)) return; + + new = g_new0 (GValue, 1); + g_value_init (new, G_TYPE_LONG); + g_value_set_long (new, value); + + ephy_node_set_property_internal (node, property_id, new); +} + long ephy_node_get_property_long (EphyNode *node, guint property_id) @@ -555,7 +615,6 @@ ephy_node_get_property_long (EphyNode *node, long retval; g_return_val_if_fail (EPHY_IS_NODE (node), -1); - g_return_val_if_fail (property_id >= 0, -1); if (property_id >= node->properties->len) { return -1; @@ -571,6 +630,24 @@ ephy_node_get_property_long (EphyNode *node, return retval; } +void +ephy_node_set_property_int (EphyNode *node, + guint property_id, + int value) +{ + GValue *new; + + g_return_if_fail (EPHY_IS_NODE (node)); + + if (ephy_node_db_is_immutable (node->db)) return; + + new = g_new0 (GValue, 1); + g_value_init (new, G_TYPE_INT); + g_value_set_int (new, value); + + ephy_node_set_property_internal (node, property_id, new); +} + int ephy_node_get_property_int (EphyNode *node, guint property_id) @@ -579,7 +656,6 @@ ephy_node_get_property_int (EphyNode *node, int retval; g_return_val_if_fail (EPHY_IS_NODE (node), -1); - g_return_val_if_fail (property_id >= 0, -1); if (property_id >= node->properties->len) { return -1; @@ -595,6 +671,24 @@ ephy_node_get_property_int (EphyNode *node, return retval; } +void +ephy_node_set_property_double (EphyNode *node, + guint property_id, + double value) +{ + GValue *new; + + g_return_if_fail (EPHY_IS_NODE (node)); + + if (ephy_node_db_is_immutable (node->db)) return; + + new = g_new0 (GValue, 1); + g_value_init (new, G_TYPE_DOUBLE); + g_value_set_double (new, value); + + ephy_node_set_property_internal (node, property_id, new); +} + double ephy_node_get_property_double (EphyNode *node, guint property_id) @@ -603,7 +697,6 @@ ephy_node_get_property_double (EphyNode *node, double retval; g_return_val_if_fail (EPHY_IS_NODE (node), -1); - g_return_val_if_fail (property_id >= 0, -1); if (property_id >= node->properties->len) { return -1; @@ -619,6 +712,24 @@ ephy_node_get_property_double (EphyNode *node, return retval; } +void +ephy_node_set_property_float (EphyNode *node, + guint property_id, + float value) +{ + GValue *new; + + g_return_if_fail (EPHY_IS_NODE (node)); + + if (ephy_node_db_is_immutable (node->db)) return; + + new = g_new0 (GValue, 1); + g_value_init (new, G_TYPE_FLOAT); + g_value_set_float (new, value); + + ephy_node_set_property_internal (node, property_id, new); +} + float ephy_node_get_property_float (EphyNode *node, guint property_id) @@ -627,7 +738,6 @@ ephy_node_get_property_float (EphyNode *node, float retval; g_return_val_if_fail (EPHY_IS_NODE (node), -1); - g_return_val_if_fail (property_id >= 0, -1); if (property_id >= node->properties->len) { return -1; diff --git a/lib/ephy-node.h b/lib/ephy-node.h index f4e0b0411..ec87315f9 100644 --- a/lib/ephy-node.h +++ b/lib/ephy-node.h @@ -89,16 +89,34 @@ gboolean ephy_node_get_property (EphyNode *node, const char *ephy_node_get_property_string (EphyNode *node, guint property_id); +void ephy_node_set_property_string (EphyNode *node, + guint property_id, + const char *value); gboolean ephy_node_get_property_boolean (EphyNode *node, guint property_id); +void ephy_node_set_property_boolean (EphyNode *node, + guint property_id, + gboolean value); long ephy_node_get_property_long (EphyNode *node, guint property_id); +void ephy_node_set_property_long (EphyNode *node, + guint property_id, + long value); int ephy_node_get_property_int (EphyNode *node, guint property_id); +void ephy_node_set_property_int (EphyNode *node, + guint property_id, + int value); double ephy_node_get_property_double (EphyNode *node, guint property_id); +void ephy_node_set_property_double (EphyNode *node, + guint property_id, + double value); float ephy_node_get_property_float (EphyNode *node, guint property_id); +void ephy_node_set_property_float (EphyNode *node, + guint property_id, + float value); EphyNode *ephy_node_get_property_node (EphyNode *node, guint property_id); diff --git a/src/epiphany.defs b/src/epiphany.defs index e3b4ef116..546212962 100644 --- a/src/epiphany.defs +++ b/src/epiphany.defs @@ -2176,6 +2176,16 @@ ) ) +(define-method set_property_string + (of-object "EphyNode") + (c-name "ephy_node_set_property_string") + (return-type "none") + (parameters + '("guint" "property_id") + '("const-char*" "value") + ) +) + (define-method get_property_string (of-object "EphyNode") (c-name "ephy_node_get_property_string") @@ -2185,6 +2195,16 @@ ) ) +(define-method set_property_boolean + (of-object "EphyNode") + (c-name "ephy_node_set_property_boolean") + (return-type "none") + (parameters + '("guint" "property_id") + '("gboolean" "value") + ) +) + (define-method get_property_boolean (of-object "EphyNode") (c-name "ephy_node_get_property_boolean") @@ -2194,6 +2214,16 @@ ) ) +(define-method set_property_long + (of-object "EphyNode") + (c-name "ephy_node_set_property_long") + (return-type "none") + (parameters + '("guint" "property_id") + '("long" "value") + ) +) + (define-method get_property_long (of-object "EphyNode") (c-name "ephy_node_get_property_long") @@ -2203,6 +2233,16 @@ ) ) +(define-method set_property_int + (of-object "EphyNode") + (c-name "ephy_node_set_property_int") + (return-type "none") + (parameters + '("guint" "property_id") + '("int" "value") + ) +) + (define-method get_property_int (of-object "EphyNode") (c-name "ephy_node_get_property_int") @@ -2212,6 +2252,16 @@ ) ) +(define-method set_property_double + (of-object "EphyNode") + (c-name "ephy_node_set_property_double") + (return-type "none") + (parameters + '("guint" "property_id") + '("double" "value") + ) +) + (define-method get_property_double (of-object "EphyNode") (c-name "ephy_node_get_property_double") @@ -2221,6 +2271,16 @@ ) ) +(define-method set_property_float + (of-object "EphyNode") + (c-name "ephy_node_set_property_float") + (return-type "none") + (parameters + '("guint" "property_id") + '("float" "value") + ) +) + (define-method get_property_float (of-object "EphyNode") (c-name "ephy_node_get_property_float") |