[anjuta/newproject] libanjuta: Add boxed type for AnjutaProjectProperty and AnjutaProjectNodeInfo
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta/newproject] libanjuta: Add boxed type for AnjutaProjectProperty and AnjutaProjectNodeInfo
- Date: Sun, 24 Oct 2010 21:01:31 +0000 (UTC)
commit 1a97b7048b9ee30e00f575a1832b0f0d99823c13
Author: Abderrahim Kitouni <a kitouni gmail com>
Date: Sun Oct 24 22:18:03 2010 +0200
libanjuta: Add boxed type for AnjutaProjectProperty and AnjutaProjectNodeInfo
libanjuta/anjuta-project.c | 115 +++++++++++++++++++++++++++++++++----------
libanjuta/anjuta-project.h | 14 +++++-
2 files changed, 101 insertions(+), 28 deletions(-)
---
diff --git a/libanjuta/anjuta-project.c b/libanjuta/anjuta-project.c
index f9ee2ba..1a49923 100644
--- a/libanjuta/anjuta-project.c
+++ b/libanjuta/anjuta-project.c
@@ -691,24 +691,53 @@ anjuta_project_node_remove_property (AnjutaProjectNode *node, AnjutaProjectPrope
return removed;
}
+/**
+ * anjuta_project_property_new:
+ * name: (transfer none):
+ * value: (transfer none):
+ * native: (allow-none) (transfer none):
+ *
+ * Returns: (transfer full):
+ */
+AnjutaProjectProperty *
+anjuta_project_property_new (const gchar *name, AnjutaProjectValueType type,
+ const gchar *value, AnjutaProjectProperty *native)
+{
+ AnjutaProjectProperty *prop = g_slice_new0(AnjutaProjectProperty);
+ prop->name = g_strdup (name);
+ prop->type = type;
+ prop->value = g_strdup (value);
+ prop->native = native;
+ return prop;
+}
-/*const gchar *
-anjuta_project_node_get_property_value (AnjutaProjectNode *node, AnjutaProjectProperty prop)
+AnjutaProjectProperty *
+anjuta_project_property_copy (AnjutaProjectProperty *prop)
{
- GList *item;
+ return anjuta_project_property_new (prop->name, prop->type,
+ prop->value, prop->native);
+}
- for (item = g_list_first (NODE_DATA (node)->properties); item != NULL; item = g_list_next (item))
- {
- AnjutaProjectPropertyInfo *info = (AnjutaProjectPropertyInfo *)item->data;
+void
+anjuta_project_property_free (AnjutaProjectProperty *prop)
+{
+ g_free (prop->name);
+ g_free (prop->value);
+ g_slice_free (AnjutaProjectProperty, prop);
+}
- if ((info == prop) || ((info->override != NULL) && (info->override->data == prop)))
- {
- return info->value;
- }
- }
-
- return NULL;
-}*/
+GType
+anjuta_project_property_get_type ()
+{
+ static GType type_id = 0;
+
+ if (!type_id)
+ type_id = g_boxed_type_register_static ("AnjutaProjectProperty",
+ (GBoxedCopyFunc) anjuta_project_property_copy,
+ (GBoxedFreeFunc) anjuta_project_property_free);
+
+ return type_id;
+}
/* Group access functions
*---------------------------------------------------------------------------*/
@@ -858,6 +887,48 @@ anjuta_project_node_info_type (const AnjutaProjectNodeInfo *info)
return info->type;
}
+/**
+ * anjuta_project_node_info_new:
+ * name: (transfer none):
+ * mime_type: (transfer none):
+ *
+ * Returns: (transfer full):
+ */
+AnjutaProjectNodeInfo *
+anjuta_project_node_info_new (AnjutaProjectNodeType type,
+ const gchar *name,
+ const gchar *mime_type)
+{
+ AnjutaProjectNodeInfo *info = g_slice_new0 (AnjutaProjectNodeInfo);
+ info->type = type;
+ info->name = g_strdup (name);
+ info->mime_type = g_strdup (mime_type);
+}
+
+AnjutaProjectNodeInfo *
+anjuta_project_node_info_copy (AnjutaProjectNodeInfo *info)
+{
+ return anjuta_project_node_info_new (info->type, info->name, info->mime_type);
+}
+
+void anjuta_project_node_info_free (AnjutaProjectNodeInfo *info)
+{
+ g_slice_free (AnjutaProjectNodeInfo, info);
+}
+
+GType
+anjuta_project_node_info_get_type ()
+{
+ static GType type_id = 0;
+
+ if (!type_id)
+ type_id = g_boxed_type_register_static ("AnjutaProjectNodeInfo",
+ (GBoxedCopyFunc) anjuta_project_node_info_copy,
+ (GBoxedFreeFunc) anjuta_project_node_info_free);
+
+ return type_id;
+}
+
/* Implement GObject
*---------------------------------------------------------------------------*/
@@ -1134,12 +1205,8 @@ anjuta_project_proxy_new (AnjutaProjectNode *node)
{
AnjutaProjectProperty *prop = (AnjutaProjectProperty *)item->data;
AnjutaProjectProperty *new_prop;
-
- new_prop = g_slice_new0(AnjutaProjectProperty);
- new_prop->name = g_strdup (prop->name);
- new_prop->type = prop->type;
- new_prop->value = g_strdup (prop->value);
- new_prop->native = prop->native;
+
+ new_prop = anjuta_project_property_copy (prop);
item->data = new_prop;
}
@@ -1197,12 +1264,6 @@ reparent_children (AnjutaProjectNode *node, gpointer data)
node->parent = ANJUTA_PROJECT_NODE (data);
}
-static void
-free_node_property (gpointer data, gpointer user_data)
-{
- g_slice_free (AnjutaProjectProperty, data);
-}
-
AnjutaProjectNode *
anjuta_project_proxy_exchange (AnjutaProjectNode *proxy, AnjutaProjectNode *node)
{
@@ -1236,7 +1297,7 @@ anjuta_project_proxy_exchange (AnjutaProjectNode *proxy, AnjutaProjectNode *node
anjuta_project_node_children_foreach (node, reparent_children, node);
/* Delete node temporary properties */
- g_list_foreach (node->custom_properties, free_node_property, NULL);
+ g_list_foreach (node->custom_properties, anjuta_project_property_free, NULL);
node->custom_properties = proxy->custom_properties;
proxy->custom_properties = NULL;
diff --git a/libanjuta/anjuta-project.h b/libanjuta/anjuta-project.h
index a398acc..5d1e651 100644
--- a/libanjuta/anjuta-project.h
+++ b/libanjuta/anjuta-project.h
@@ -98,6 +98,8 @@ typedef struct _AnjutaProjectTargetInformation
gchar *mime_type;
} AnjutaProjectNodeInfo;
+#define ANJUTA_TYPE_PROJECT_NODE_INFO (anjuta_project_node_info_get_type ())
+
typedef enum
{
ANJUTA_PROJECT_PROPERTY_STRING = 1,
@@ -125,6 +127,7 @@ struct _AnjutaProjectProperty
};
#define ANJUTA_IS_PROJECT_PROPERTY
+#define ANJUTA_TYPE_PROJECT_PROPERTY (anjuta_project_property_get_type ())
typedef struct
{
@@ -225,7 +228,10 @@ GList *anjuta_project_node_get_custom_properties (AnjutaProjectNode *node);
AnjutaProjectProperty *anjuta_project_node_get_property (AnjutaProjectNode *node, AnjutaProjectProperty *property);
AnjutaProjectProperty *anjuta_project_node_insert_property (AnjutaProjectNode *node, AnjutaProjectProperty *native, AnjutaProjectProperty *property);
AnjutaProjectProperty *anjuta_project_node_remove_property (AnjutaProjectNode *node, AnjutaProjectProperty *property);
-
+AnjutaProjectProperty *anjuta_project_property_new (const gchar *name, AnjutaProjectValueType type, const gchar *value, AnjutaProjectProperty *native);
+AnjutaProjectProperty * anjuta_project_property_copy (AnjutaProjectProperty *prop);
+void anjuta_project_property_free (AnjutaProjectProperty *prop);
+GType anjuta_project_property_get_type ();
//const gchar *anjuta_project_node_get_property_value (AnjutaProjectNode *node, AnjutaProjectProperty prop);
@@ -242,10 +248,16 @@ const gchar *anjuta_project_target_get_name (const AnjutaProjectNode *target);
GFile *anjuta_project_source_get_file (const AnjutaProjectNode *source);
+AnjutaProjectNodeInfo *anjuta_project_node_info_new (AnjutaProjectNodeType type, const gchar *name, const gchar *mime_type);
+AnjutaProjectNodeInfo *anjuta_project_node_info_copy (AnjutaProjectNodeInfo *info);
+void anjuta_project_node_info_free (AnjutaProjectNodeInfo *info);
+GType anjuta_project_node_info_get_type ();
const gchar *anjuta_project_node_info_name (const AnjutaProjectNodeInfo *info);
const gchar *anjuta_project_node_info_mime (const AnjutaProjectNodeInfo *info);
AnjutaProjectNodeType anjuta_project_node_info_type (const AnjutaProjectNodeInfo *info);
+
+
AnjutaProjectNode *anjuta_project_proxy_new (AnjutaProjectNode *node);
AnjutaProjectNode *anjuta_project_proxy_unref (AnjutaProjectNode *node);
AnjutaProjectNode *anjuta_project_proxy_exchange (AnjutaProjectNode *proxy, AnjutaProjectNode *node);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]