[anjuta] libanjuta: correctly register gobject properties for AnjutaProjectNode



commit b32592cd20be2920ed65c74f8ab05263be68c489
Author: Abderrahim Kitouni <akitouni src gnome org>
Date:   Mon Jan 31 22:50:32 2011 +0100

    libanjuta: correctly register gobject properties for AnjutaProjectNode

 libanjuta/anjuta-project.c                       |  164 ++++++++++++++++------
 plugins/language-support-vala/libanjuta-3.0.vapi |   36 ++++-
 2 files changed, 150 insertions(+), 50 deletions(-)
---
diff --git a/libanjuta/anjuta-project.c b/libanjuta/anjuta-project.c
index 10a5f49..97120b6 100644
--- a/libanjuta/anjuta-project.c
+++ b/libanjuta/anjuta-project.c
@@ -21,6 +21,7 @@
 
 #include "anjuta-debug.h" 
 #include "anjuta-marshal.h"
+#include "anjuta-enum-types.h"
 
 #include <string.h>
 
@@ -830,7 +831,8 @@ enum {
 	PROP_FILE,
 	PROP_STATE,
 	PROP_TYPE,
-	PROP_DATA
+	PROP_NATIVE_PROPERTIES,
+	PROP_CUSTOM_PROPERTIES
 };
 
 
@@ -887,26 +889,76 @@ anjuta_project_node_finalize (GObject *object)
 
 static void 
 anjuta_project_node_get_gobject_property (GObject    *object,
-	      guint       prop_id,
-	      GValue     *value,
-	      GParamSpec *pspec)
+                                          guint       prop_id,
+                                          GValue     *value,
+                                          GParamSpec *pspec)
 {
-	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+	AnjutaProjectNode *node = ANJUTA_PROJECT_NODE(object);
+	switch (prop_id) {
+		case PROP_NAME:
+			g_value_set_string (value, anjuta_project_node_get_name (node));
+			break;
+		case PROP_FILE:
+			g_value_set_object (value, node->file);
+			break;
+		case PROP_STATE:
+			g_value_set_flags (value, anjuta_project_node_get_state (node));
+			break;
+		case PROP_TYPE:
+			g_value_set_flags (value, anjuta_project_node_get_node_type (node));
+			break;
+		case PROP_NATIVE_PROPERTIES:
+			g_value_set_pointer (value, node->native_properties);
+			break;
+		case PROP_CUSTOM_PROPERTIES:
+			g_value_set_pointer (value, node->custom_properties);
+			break;
+		default:
+			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+	}
 }
 
 static void 
 anjuta_project_node_set_gobject_property (GObject      *object,
-	      guint         prop_id,
-	      const GValue *value,
-	      GParamSpec   *pspec)
+                                          guint         prop_id,
+                                          const GValue *value,
+                                          GParamSpec   *pspec)
 {
-	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+	AnjutaProjectNode *node = ANJUTA_PROJECT_NODE(object);
+	switch (prop_id) {
+		case PROP_NAME:
+			if (node->name != NULL)
+				g_free (node->name);
+			node->name = g_value_dup_string (value);
+			break;
+		case PROP_FILE:
+			if (node->file != NULL)
+				g_object_unref (node->file);
+			node->file = g_value_dup_object (value);
+			break;
+		case PROP_STATE:
+			anjuta_project_node_set_state (node, g_value_get_flags (value));
+			break;
+		case PROP_TYPE:
+			node->type = g_value_get_flags (value);
+			break;
+		case PROP_NATIVE_PROPERTIES:
+			node->native_properties = g_value_get_pointer (value);
+			break;
+		/* XXX: We may need to copy this instead */
+		case PROP_CUSTOM_PROPERTIES:
+			node->custom_properties = g_value_get_pointer (value);
+			break;
+		default:
+			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+	}
 }
 
 static void
 anjuta_project_node_class_init (AnjutaProjectNodeClass *klass)
 {
 	GObjectClass* object_class = G_OBJECT_CLASS (klass);
+	GParamSpec* pspec;
 	
 	object_class->finalize = anjuta_project_node_finalize;
 	object_class->dispose = anjuta_project_node_dispose;
@@ -948,42 +1000,64 @@ anjuta_project_node_class_init (AnjutaProjectNodeClass *klass)
 	    G_TYPE_POINTER,
 		G_TYPE_ERROR);
 
-	g_object_class_install_property 
-                (G_OBJECT_CLASS (klass), PROP_TYPE,
-                 g_param_spec_pointer ("type", 
-                                       "Type",
-                                       "Node type",
-                                       G_PARAM_READWRITE));
-
-	g_object_class_install_property 
-                (G_OBJECT_CLASS (klass), PROP_STATE,
-                 g_param_spec_pointer ("state", 
-                                       "Stroject",
-                                       "GbfProject Object",
-                                       G_PARAM_READWRITE));
-
-	g_object_class_install_property 
-                (G_OBJECT_CLASS (klass), PROP_DATA,
-                 g_param_spec_pointer ("project", 
-                                       "Project",
-                                       "GbfProject Object",
-                                       G_PARAM_READWRITE));
-
-	g_object_class_install_property 
-                (G_OBJECT_CLASS (klass), PROP_NAME,
-                 g_param_spec_string ("name", 
-                                      "Name",
-                                      "GbfProject Object",
-				       "",
-                                       G_PARAM_READWRITE));
-
-	g_object_class_install_property 
-                (G_OBJECT_CLASS (klass), PROP_FILE,
-                 g_param_spec_object ("file", 
-                                       "PDroject",
-                                       "GbfProject Object",
-				       G_TYPE_FILE,
-                                       G_PARAM_READWRITE));
+	pspec = g_param_spec_flags ("type",
+	                            "Type",
+	                            "Node type",
+	                            ANJUTA_TYPE_PROJECT_NODE_TYPE,
+	                            0,
+	                            G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+	g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_TYPE,
+	                                 pspec);
+
+	pspec = g_param_spec_flags ("state",
+	                            "State",
+	                            "Node state",
+	                            ANJUTA_TYPE_PROJECT_NODE_STATE,
+	                            0,
+	                            G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+	g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_STATE,
+	                                 pspec);
+
+	pspec = g_param_spec_string ("name",
+	                             "Name",
+	                             "Node name",
+	                             "",
+	                             G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+	g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_NAME,
+	                                 pspec);
+
+	pspec = g_param_spec_object ("file",
+	                             "File",
+	                             "The GFile for the node",
+	                             G_TYPE_FILE,
+	                             G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+	g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_FILE,
+	                                 pspec);
+
+/**
+ * AnjutaProjectNode:native-properties:
+ *
+ * type: GLib.List<Anjuta.ProjectProperty>
+ * Transfer: none
+ */
+	pspec = g_param_spec_pointer ("native-properties",
+	                              "Native properties",
+	                              "The list of all possible properties",
+	                              G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+	g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_NATIVE_PROPERTIES,
+	                                 pspec);
+/**
+ * AnjutaProjectNode:custom-properties:
+ *
+ * Type: GLib.List<Anjuta.ProjectProperty>
+ * Transfer: none
+ */
+	pspec = g_param_spec_pointer ("custom-properties",
+	                              "Custom properties",
+	                              "The list of overriden properties",
+	                              G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+	g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_CUSTOM_PROPERTIES,
+	                                 pspec);
 
 }
 
diff --git a/plugins/language-support-vala/libanjuta-3.0.vapi b/plugins/language-support-vala/libanjuta-3.0.vapi
index 4bbb263..1f0ff64 100644
--- a/plugins/language-support-vala/libanjuta-3.0.vapi
+++ b/plugins/language-support-vala/libanjuta-3.0.vapi
@@ -4,6 +4,8 @@
 namespace Anjuta {
 	[CCode (cheader_filename = "libanjuta/libanjuta.h")]
 	public class AsyncCommand : Anjuta.Command {
+		[CCode (has_construct_function = false)]
+		protected AsyncCommand ();
 		public static string get_error_message (Anjuta.Command command);
 		public void @lock ();
 		public static void set_error_message (Anjuta.Command command, string error_message);
@@ -51,6 +53,8 @@ namespace Anjuta {
 	}
 	[CCode (cheader_filename = "libanjuta/libanjuta.h")]
 	public class Command : GLib.Object {
+		[CCode (has_construct_function = false)]
+		protected Command ();
 		public virtual void cancel ();
 		public virtual string get_error_message ();
 		public bool is_running ();
@@ -95,6 +99,8 @@ namespace Anjuta {
 	}
 	[CCode (cheader_filename = "libanjuta/libanjuta.h")]
 	public class DockPane : GLib.Object {
+		[CCode (has_construct_function = false)]
+		protected DockPane ();
 		public void notify_multiple_selection_changed ();
 		public void notify_single_selection_changed ();
 		public virtual void refresh ();
@@ -111,6 +117,8 @@ namespace Anjuta {
 	[Compact]
 	[CCode (copy_function = "g_boxed_copy", free_function = "g_boxed_free", type_id = "anjuta_encoding_get_type ()", cheader_filename = "libanjuta/libanjuta.h")]
 	public class Encoding {
+		[CCode (has_construct_function = false)]
+		protected Encoding ();
 		public Anjuta.Encoding copy ();
 		public void free ();
 		public unowned string get_charset ();
@@ -148,6 +156,8 @@ namespace Anjuta {
 		public void set_relative_path (string path);
 		[NoAccessorMethod]
 		public string relative_path { owned get; set; }
+		[NoAccessorMethod]
+		public bool show_add_button { get; set; }
 	}
 	[CCode (cheader_filename = "libanjuta/libanjuta.h")]
 	public class GluePlugin : GLib.TypeModule {
@@ -184,6 +194,8 @@ namespace Anjuta {
 	}
 	[CCode (cheader_filename = "libanjuta/libanjuta.h")]
 	public class Plugin : GLib.Object {
+		[CCode (has_construct_function = false)]
+		protected Plugin ();
 		public virtual bool activate ();
 		public uint add_watch (string name, [CCode (delegate_target_pos = 3.1)] Anjuta.PluginValueAdded added, [CCode (delegate_target_pos = 3.1)] Anjuta.PluginValueRemoved removed);
 		public virtual bool deactivate ();
@@ -320,11 +332,11 @@ namespace Anjuta {
 	[CCode (cheader_filename = "libanjuta/libanjuta.h")]
 	public class ProjectNode : GLib.InitiallyUnowned {
 		public weak Anjuta.ProjectNode children;
-		public weak GLib.List<weak void*> custom_properties;
-		public weak GLib.List<weak void*> native_properties;
 		public weak Anjuta.ProjectNode next;
 		public weak Anjuta.ProjectNode parent;
 		public weak Anjuta.ProjectNode prev;
+		[CCode (has_construct_function = false)]
+		protected ProjectNode ();
 		public void check ();
 		public bool clear_state (Anjuta.ProjectNodeState state);
 		public void dump ();
@@ -340,13 +352,15 @@ namespace Anjuta {
 		public Anjuta.ProjectProperty remove_property (Anjuta.ProjectProperty property);
 		public bool set_state (Anjuta.ProjectNodeState state);
 		[NoAccessorMethod]
+		public GLib.List<weak Anjuta.ProjectProperty> custom_properties { owned get; set; }
+		[NoAccessorMethod]
 		public GLib.File file { owned get; set; }
 		public string name { get; set; }
 		[NoAccessorMethod]
-		public void* project { get; set; }
-		public void* state { get; set; }
+		public GLib.List<weak Anjuta.ProjectProperty> native_properties { owned get; set; }
+		public Anjuta.ProjectNodeState state { get; set; }
 		[NoAccessorMethod]
-		public void* type { get; set; }
+		public Anjuta.ProjectNodeType type { get; set; }
 		public virtual signal void loaded (void* object, GLib.Error p0);
 		public virtual signal void updated (void* object, GLib.Error p0);
 	}
@@ -356,6 +370,8 @@ namespace Anjuta {
 		public weak string mime_type;
 		public weak string name;
 		public Anjuta.ProjectNodeType type;
+		[CCode (has_construct_function = false)]
+		public ProjectNodeInfo (Anjuta.ProjectNodeType type, string name, string mime_type);
 		public Anjuta.ProjectNodeInfo copy ();
 		public void free ();
 		public unowned string mime ();
@@ -369,6 +385,8 @@ namespace Anjuta {
 		public weak Anjuta.ProjectProperty native;
 		public Anjuta.ProjectValueType type;
 		public weak string value;
+		[CCode (has_construct_function = false)]
+		public ProjectProperty (string name, Anjuta.ProjectValueType type, string value, Anjuta.ProjectProperty native);
 		public Anjuta.ProjectProperty copy ();
 		public void free ();
 	}
@@ -432,6 +450,8 @@ namespace Anjuta {
 	}
 	[CCode (cheader_filename = "libanjuta/libanjuta.h")]
 	public class SyncCommand : Anjuta.Command {
+		[CCode (has_construct_function = false)]
+		protected SyncCommand ();
 	}
 	[CCode (cheader_filename = "libanjuta/libanjuta.h")]
 	public class Tabber : Gtk.Container, Atk.Implementor, Gtk.Buildable {
@@ -1220,6 +1240,12 @@ namespace IAnjuta {
 		public abstract void toggle_current () throws GLib.Error;
 	}
 	[CCode (cheader_filename = "libanjuta/interfaces/libanjuta-interfaces.h")]
+	public interface EditorGladeSignal : IAnjuta.Editor, GLib.Object {
+		public static GLib.Quark error_quark ();
+		public virtual signal void drop (GLib.Object iterator, string signal_data);
+		public virtual signal bool drop_possible (GLib.Object iterator);
+	}
+	[CCode (cheader_filename = "libanjuta/interfaces/libanjuta-interfaces.h")]
 	public interface EditorGoto : IAnjuta.Editor, GLib.Object {
 		public abstract void end_block () throws GLib.Error;
 		public static GLib.Quark error_quark ();



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]