[anjuta/newproject] Move property dialog in the project manager plugin



commit a1ae6afeec18b1c387f326f6723b2cd9414fe7a6
Author: Sébastien Granjoux <seb sfo free fr>
Date:   Wed Apr 21 11:59:46 2010 +0200

    Move property dialog in the project manager plugin

 plugins/am-project/Makefile.am                     |    2 -
 plugins/am-project/am-project.c                    |   15 +-----
 plugins/project-manager/Makefile.am                |    4 +-
 .../am-dialogs.c => project-manager/dialogs.c}     |   58 +++++++++++++-------
 .../am-dialogs.h => project-manager/dialogs.h}     |   10 ++--
 plugins/project-manager/project.c                  |   24 +++++++-
 6 files changed, 69 insertions(+), 44 deletions(-)
---
diff --git a/plugins/am-project/Makefile.am b/plugins/am-project/Makefile.am
index f27f452..d1fc213 100644
--- a/plugins/am-project/Makefile.am
+++ b/plugins/am-project/Makefile.am
@@ -43,8 +43,6 @@ libam_project_la_SOURCES = \
 	am-writer.h \
 	am-writer.c \
 	am-project-private.h \
-	am-dialogs.h \
-	am-dialogs.c \
 	am-properties.c \
 	am-properties.h
 
diff --git a/plugins/am-project/am-project.c b/plugins/am-project/am-project.c
index 9bdb2ae..407bab8 100644
--- a/plugins/am-project/am-project.c
+++ b/plugins/am-project/am-project.c
@@ -47,7 +47,6 @@
 #include "ac-scanner.h"
 #include "ac-writer.h"
 #include "am-scanner.h"
-#include "am-dialogs.h"
 #include "am-writer.h"
 //#include "am-config.h"
 #include "am-properties.h"
@@ -3158,7 +3157,7 @@ iproject_add_target (IAnjutaProject *obj, AnjutaProjectNode *parent,  const gcha
 static GtkWidget* 
 iproject_configure (IAnjutaProject *obj, GError **err)
 {
-	return amp_configure_project_dialog (AMP_PROJECT (obj), AMP_PROJECT (obj)->root_node, err);
+	return NULL;
 }
 
 static guint 
@@ -3225,17 +3224,7 @@ iproject_refresh (IAnjutaProject *obj, GError **err)
 static GtkWidget*
 iproject_configure_node (IAnjutaProject *obj, AnjutaProjectNode *node, GError **err)
 {
-	switch (anjuta_project_node_get_type (node))
-	{
-		case ANJUTA_PROJECT_GROUP:
-			return amp_configure_group_dialog (AMP_PROJECT (obj), AMP_GROUP (node), err);
-		case ANJUTA_PROJECT_TARGET:
-			return amp_configure_target_dialog (AMP_PROJECT (obj), AMP_TARGET (node), err);
-		case ANJUTA_PROJECT_SOURCE:
-			return amp_configure_source_dialog (AMP_PROJECT (obj), AMP_SOURCE (node), err);
-		default:
-			return NULL;
-	}
+	return NULL;
 }
 
 static AnjutaProjectNode *
diff --git a/plugins/project-manager/Makefile.am b/plugins/project-manager/Makefile.am
index ad4c850..825b2bd 100644
--- a/plugins/project-manager/Makefile.am
+++ b/plugins/project-manager/Makefile.am
@@ -49,7 +49,9 @@ libanjuta_project_manager_la_SOURCES = \
 	pkg-config.c		\
 	pkg-config.h		\
 	project.h		\
-	project.c
+	project.c		\
+	dialogs.c		\
+	dialogs.h
 
 libanjuta_project_manager_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
 
diff --git a/plugins/am-project/am-dialogs.c b/plugins/project-manager/dialogs.c
similarity index 83%
rename from plugins/am-project/am-dialogs.c
rename to plugins/project-manager/dialogs.c
index c35e690..11cb30c 100644
--- a/plugins/am-project/am-dialogs.c
+++ b/plugins/project-manager/dialogs.c
@@ -26,7 +26,7 @@
 
 #include <glib/gi18n.h>
 
-#include "am-dialogs.h"
+#include "dialogs.h"
 
 #include <libanjuta/anjuta-debug.h>
 #include <libanjuta/anjuta-utils.h>
@@ -36,12 +36,12 @@
 /* Types
   *---------------------------------------------------------------------------*/
 
-typedef struct _AmpConfigureProjectDialog
+typedef struct _ConfigureProjectDialog
 {
-	AmpProject *project;
+	IAnjutaProject *project;
 
 	GtkWidget *top_level;
-} AmpConfigureProjectDialog;
+} ConfigureProjectDialog;
 
 enum {
 	NAME_COLUMN,
@@ -56,15 +56,33 @@ enum {
 /* Private functions
  *---------------------------------------------------------------------------*/
 
+static AnjutaProjectNodeInfo *
+project_get_type_info (IAnjutaProject *project, AnjutaProjectNodeType type)
+{
+	GList *item;
+	AnjutaProjectNodeInfo *info = NULL;
+
+	g_message ("get node info list %p", ianjuta_project_get_node_info (project, NULL));
+	for (item = ianjuta_project_get_node_info (project, NULL); item != NULL; item = g_list_next (item))
+	{
+		info = (AnjutaProjectNodeInfo *)item->data;
+
+		g_message ("check node name %s type %x look for %x", info->name, info->type, type);
+		if (info->type == type) break;
+	}
+
+	return info;
+}
+
 static void
-on_project_widget_destroy (GtkWidget *wid, AmpConfigureProjectDialog *dlg)
+on_project_widget_destroy (GtkWidget *wid, ConfigureProjectDialog *dlg)
 {
 	g_object_unref (dlg->top_level);
 	g_free (dlg);
 }
 
 static void
-add_entry (AmpProject *project, AnjutaProjectNode *node, AnjutaProjectProperty *prop, GtkWidget *table, gint *position)
+add_entry (IAnjutaProject *project, AnjutaProjectNode *node, AnjutaProjectProperty *prop, GtkWidget *table, gint *position)
 {
 	GtkWidget *label;
 	GtkWidget *entry = NULL;
@@ -178,10 +196,10 @@ add_label (const gchar *display_name, const gchar *value, GtkWidget *table, gint
  *---------------------------------------------------------------------------*/
 
 GtkWidget *
-amp_configure_project_dialog (AmpProject *project, AnjutaProjectNode *node, GError **error)
+pm_configure_project_dialog (IAnjutaProject *project, AnjutaProjectNode *node, GError **error)
 {
 	GtkBuilder *bxml = gtk_builder_new ();
-	AmpConfigureProjectDialog *dlg;
+	ConfigureProjectDialog *dlg;
 	GtkWidget *table;
 	gint pos;
 	gchar *name;
@@ -190,7 +208,7 @@ amp_configure_project_dialog (AmpProject *project, AnjutaProjectNode *node, GErr
 	bxml = anjuta_util_builder_new (GLADE_FILE, NULL);
 	if (!bxml) return NULL;
 
-	dlg = g_new0 (AmpConfigureProjectDialog, 1);
+	dlg = g_new0 (ConfigureProjectDialog, 1);
 	anjuta_util_builder_get_objects (bxml,
 	    							"general_properties_table", &table,
 	                                NULL);
@@ -199,7 +217,7 @@ amp_configure_project_dialog (AmpProject *project, AnjutaProjectNode *node, GErr
 	g_signal_connect (table, "destroy", G_CALLBACK (on_project_widget_destroy), dlg);
 
 	pos = 0;
-	name = g_file_get_parse_name (amp_project_get_file (project));
+	name = g_file_get_parse_name (anjuta_project_node_get_file (node));
 	add_label (_("Path:"), name, table, &pos);
 	g_free (name);
 
@@ -221,7 +239,7 @@ amp_configure_project_dialog (AmpProject *project, AnjutaProjectNode *node, GErr
 }
 
 GtkWidget *
-amp_configure_group_dialog (AmpProject *project, AnjutaProjectNode *group, GError **error)
+pm_configure_group_dialog (IAnjutaProject *project, AnjutaProjectNode *group, GError **error)
 {
 	GtkBuilder *bxml = gtk_builder_new ();
 	GtkWidget *properties;
@@ -229,14 +247,14 @@ amp_configure_group_dialog (AmpProject *project, AnjutaProjectNode *group, GErro
 	gint main_pos;
 	GtkWidget *extra_table;
 	gint extra_pos;
-	AmpConfigureProjectDialog *dlg;
+	ConfigureProjectDialog *dlg;
 	gchar *name;
 	AnjutaProjectProperty *prop;
 
 	bxml = anjuta_util_builder_new (GLADE_FILE, NULL);
 	if (!bxml) return NULL;
 
-	dlg = g_new0 (AmpConfigureProjectDialog, 1);
+	dlg = g_new0 (ConfigureProjectDialog, 1);
 	anjuta_util_builder_get_objects (bxml,
 	                                "properties", &properties,
 	    							"main_table", &main_table,
@@ -248,7 +266,7 @@ amp_configure_group_dialog (AmpProject *project, AnjutaProjectNode *group, GErro
 
 	main_pos = 0;
 	extra_pos = 0;
-	name = g_file_get_parse_name (amp_group_get_directory (group));
+	name = g_file_get_parse_name (anjuta_project_node_get_file (group));
 	add_label (_("Name:"), name, main_table, &main_pos);
 	g_free (name);
 
@@ -274,7 +292,7 @@ amp_configure_group_dialog (AmpProject *project, AnjutaProjectNode *group, GErro
 }
 
 GtkWidget *
-amp_configure_target_dialog (AmpProject *project, AnjutaProjectNode *target, GError **error)
+pm_configure_target_dialog (IAnjutaProject *project, AnjutaProjectNode *target, GError **error)
 {
 	GtkBuilder *bxml = gtk_builder_new ();
 	GtkWidget *properties;
@@ -282,7 +300,7 @@ amp_configure_target_dialog (AmpProject *project, AnjutaProjectNode *target, GEr
 	gint main_pos;
 	GtkWidget *extra_table;
 	gint extra_pos;
-	AmpConfigureProjectDialog *dlg;
+	ConfigureProjectDialog *dlg;
 	AnjutaProjectNodeInfo* info;
 	const gchar *name;
 	AnjutaProjectProperty *prop;
@@ -290,7 +308,7 @@ amp_configure_target_dialog (AmpProject *project, AnjutaProjectNode *target, GEr
 	bxml = anjuta_util_builder_new (GLADE_FILE, NULL);
 	if (!bxml) return NULL;
 
-	dlg = g_new0 (AmpConfigureProjectDialog, 1);
+	dlg = g_new0 (ConfigureProjectDialog, 1);
 	anjuta_util_builder_get_objects (bxml,
 	                                "properties", &properties,
 	    							"main_table", &main_table,
@@ -302,9 +320,9 @@ amp_configure_target_dialog (AmpProject *project, AnjutaProjectNode *target, GEr
 
 	main_pos = 0;
 	extra_pos = 0;
-	name = amp_target_get_name (target);
+	name = anjuta_project_node_get_name (target);
 	add_label (_("Name:"), name, main_table, &main_pos);
-	info = amp_project_get_type_info (project, anjuta_project_node_get_type (target));;
+	info = project_get_type_info (project, anjuta_project_node_get_type (target));;
 	add_label (_("Type:"), anjuta_project_node_info_name (info), main_table, &main_pos);
 
 	for (prop = anjuta_project_node_first_valid_property (target); prop != NULL; prop = anjuta_project_property_next (prop))
@@ -329,7 +347,7 @@ amp_configure_target_dialog (AmpProject *project, AnjutaProjectNode *target, GEr
 }
 
 GtkWidget *
-amp_configure_source_dialog (AmpProject *project, AmpSource *target, GError **error)
+pm_configure_source_dialog (IAnjutaProject *project, AnjutaProjectNode *source, GError **error)
 {
 	return NULL;
 }
diff --git a/plugins/am-project/am-dialogs.h b/plugins/project-manager/dialogs.h
similarity index 67%
rename from plugins/am-project/am-dialogs.h
rename to plugins/project-manager/dialogs.h
index eba0cc3..c66029a 100644
--- a/plugins/am-project/am-dialogs.h
+++ b/plugins/project-manager/dialogs.h
@@ -23,14 +23,14 @@
 #define _AM_DIALOGS_H_
 
 #include <gtk/gtk.h>
-#include "am-project.h"
+#include <libanjuta/interfaces/ianjuta-project.h>
 
 G_BEGIN_DECLS
 
-GtkWidget *amp_configure_project_dialog (AmpProject *project, AnjutaProjectNode *node, GError **error);
-GtkWidget *amp_configure_group_dialog (AmpProject *project, AnjutaProjectNode *group, GError **error);
-GtkWidget *amp_configure_target_dialog (AmpProject *project, AnjutaProjectNode *target, GError **error);
-GtkWidget *amp_configure_source_dialog (AmpProject *project, AnjutaProjectNode *target, GError **error);
+GtkWidget *pm_configure_project_dialog (IAnjutaProject *project, AnjutaProjectNode *node, GError **error);
+GtkWidget *pm_configure_group_dialog (IAnjutaProject *project, AnjutaProjectNode *group, GError **error);
+GtkWidget *pm_configure_target_dialog (IAnjutaProject *project, AnjutaProjectNode *target, GError **error);
+GtkWidget *pm_configure_source_dialog (IAnjutaProject *project, AnjutaProjectNode *target, GError **error);
 
 G_END_DECLS
 
diff --git a/plugins/project-manager/project.c b/plugins/project-manager/project.c
index 4a2dee4..6e98242 100644
--- a/plugins/project-manager/project.c
+++ b/plugins/project-manager/project.c
@@ -30,6 +30,7 @@
 #include <libanjuta/interfaces/ianjuta-project-backend.h>
 #include "project-model.h"
 #include "project-view.h"
+#include "dialogs.h"
 
 
 /*
@@ -507,13 +508,30 @@ anjuta_pm_project_configure (AnjutaPmProject *project, AnjutaProjectNode *node)
 	
 	if (node == NULL)
 	{
-		properties = ianjuta_project_configure (project->project, NULL);
+		properties = pm_configure_project_dialog (project->project, node, NULL);
 	}
 	else
 	{
-		properties = ianjuta_project_configure_node (project->project, node, NULL);
+		switch (anjuta_project_node_get_type (node))
+		{
+		case ANJUTA_PROJECT_ROOT:
+			properties = pm_configure_project_dialog (project->project, node, NULL);
+			break;
+		case ANJUTA_PROJECT_GROUP:
+			properties = pm_configure_group_dialog (project->project, node, NULL);
+			break;
+		case ANJUTA_PROJECT_TARGET:
+			properties = pm_configure_target_dialog (project->project, node, NULL);
+			break;
+		case ANJUTA_PROJECT_SOURCE:
+			properties = pm_configure_source_dialog (project->project, node, NULL);
+			break;
+		default:
+			properties = NULL;
+			break;
+		}
 	}
-
+	
 	return properties;
 }
 



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