[anjuta/newproject] am: Improve project propeties
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [anjuta/newproject] am: Improve project propeties
- Date: Thu, 11 Feb 2010 21:36:50 +0000 (UTC)
commit 616b29fb626e57509e7fef3b9fa10db7190d2cf0
Author: Sébastien Granjoux <seb sfo free fr>
Date: Wed Feb 10 22:37:36 2010 +0100
am: Improve project propeties
Use check box for boolean property
Use different property for man target
Use the same property for all types of nodes
plugins/am-project/am-dialogs.c | 21 +++++--
plugins/am-project/am-project-private.h | 22 +-------
plugins/am-project/am-project.c | 95 ++++++++-----------------------
plugins/am-project/am-properties.c | 88 ++++++++++++++++-------------
plugins/am-project/am-properties.h | 2 +-
5 files changed, 90 insertions(+), 138 deletions(-)
---
diff --git a/plugins/am-project/am-dialogs.c b/plugins/am-project/am-dialogs.c
index 13a54b2..dee953d 100644
--- a/plugins/am-project/am-dialogs.c
+++ b/plugins/am-project/am-dialogs.c
@@ -61,18 +61,27 @@ static void
add_entry (AmpProject *project, AnjutaProjectNode *node, AnjutaProjectPropertyInfo *info, GtkWidget *table, gint position)
{
GtkWidget *label;
- GtkWidget *entry;
- const gchar *value;
+ GtkWidget *entry = NULL;
label = gtk_label_new (_(info->name));
gtk_misc_set_alignment (GTK_MISC (label), 0, -1);
gtk_widget_show (label);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, position, position+1,
GTK_FILL, GTK_FILL, 5, 3);
-
- entry = gtk_entry_new ();
- value = info->value;
- gtk_entry_set_text (GTK_ENTRY (entry), value);
+
+ switch (info->type)
+ {
+ case ANJUTA_PROJECT_PROPERTY_STRING:
+ entry = gtk_entry_new ();
+ gtk_entry_set_text (GTK_ENTRY (entry), info->value);
+ break;
+ case ANJUTA_PROJECT_PROPERTY_BOOLEAN:
+ entry = gtk_check_button_new ();
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (entry), (info->value != NULL) && (*info->value == '1'));
+ break;
+ default:
+ return;
+ }
gtk_misc_set_alignment (GTK_MISC (entry), 0, -1);
gtk_widget_show (entry);
gtk_table_attach (GTK_TABLE (table), entry, 1, 2, position, position+1,
diff --git a/plugins/am-project/am-project-private.h b/plugins/am-project/am-project-private.h
index 1b3d302..f9f15ad 100644
--- a/plugins/am-project/am-project-private.h
+++ b/plugins/am-project/am-project-private.h
@@ -48,31 +48,13 @@ struct _AmpProperty {
};
#endif
-struct _AmpProjectPropertyInfo {
+struct _AmpPropertyInfo {
AnjutaProjectPropertyInfo base;
AnjutaToken *ac_init;
gint position;
};
-typedef struct _AmpProjectPropertyInfo AmpProjectPropertyInfo;
-
-struct _AmpGroupPropertyInfo {
- AnjutaProjectPropertyInfo base;
- AnjutaToken *ac_init;
- gint position;
-};
-
-typedef struct _AmpGroupPropertyInfo AmpGroupPropertyInfo;
-
-struct _AmpTargetPropertyInfo {
- AnjutaProjectPropertyInfo base;
- AnjutaToken *ac_init;
- gint position;
-};
-
-typedef struct _AmpTargetPropertyInfo AmpTargetPropertyInfo;
-
-
+typedef struct _AmpPropertyInfo AmpPropertyInfo;
struct _AmpProject {
GObject parent;
diff --git a/plugins/am-project/am-project.c b/plugins/am-project/am-project.c
index 71f2e62..ad55de1 100644
--- a/plugins/am-project/am-project.c
+++ b/plugins/am-project/am-project.c
@@ -50,7 +50,7 @@
#include "am-dialogs.h"
#include "am-writer.h"
//#include "am-config.h"
-//#include "am-properties.h"
+#include "am-properties.h"
#define UNIMPLEMENTED G_STMT_START { g_warning (G_STRLOC": unimplemented"); } G_STMT_END
@@ -346,7 +346,7 @@ file_type (GFile *file, const gchar *filename)
*---------------------------------------------------------------------------*/
/* Remove invalid character according to automake rules */
-gchar*
+static gchar*
canonicalize_automake_variable (gchar *name)
{
gchar *canon_name = g_strdup (name);
@@ -363,7 +363,7 @@ canonicalize_automake_variable (gchar *name)
return canon_name;
}
-gboolean
+static gboolean
split_automake_variable (gchar *name, gint *flags, gchar **module, gchar **primary)
{
GRegex *regex;
@@ -445,7 +445,7 @@ split_automake_variable (gchar *name, gint *flags, gchar **module, gchar **prima
return TRUE;
}
-gchar*
+static gchar*
ac_init_default_tarname (const gchar *name)
{
gchar *tarname;
@@ -491,7 +491,7 @@ amp_config_file_free (AmpConfigFile *config)
/* Package objects
*---------------------------------------------------------------------------*/
-void
+static void
amp_package_set_version (AmpPackage *package, const gchar *compare, const gchar *version)
{
g_return_if_fail (package != NULL);
@@ -568,73 +568,27 @@ amp_project_free_module_hash (AmpProject *project)
/* Properties objects
*---------------------------------------------------------------------------*/
-static AmpProjectPropertyInfo *
-amp_project_property_new (AnjutaToken *ac_init)
+static AmpPropertyInfo *
+amp_property_new (AnjutaToken *ac_init)
{
- AmpProjectPropertyInfo *prop;
+ AmpPropertyInfo *prop;
- prop = g_slice_new0(AmpProjectPropertyInfo);
+ prop = g_slice_new0(AmpPropertyInfo);
prop->ac_init = ac_init;
return prop;
}
static void
-amp_project_property_free (AmpProjectPropertyInfo *prop)
-{
- if (prop->base.override != NULL)
- {
- if ((prop->base.value != NULL) && (prop->base.value != ((AmpProjectPropertyInfo *)(prop->base.override->data))->base.value))
- {
- g_free (prop->base.value);
- }
- g_slice_free (AmpProjectPropertyInfo, prop);
- }
-}
-
-static AmpGroupPropertyInfo *
-amp_group_property_new (void)
-{
- AmpGroupPropertyInfo *prop;
-
- prop = g_slice_new0(AmpGroupPropertyInfo);
-
- return prop;
-}
-
-static void
-amp_group_property_free (AmpGroupPropertyInfo *prop)
-{
- if (prop->base.override != NULL)
- {
- if ((prop->base.value != NULL) && (prop->base.value != ((AmpGroupPropertyInfo *)(prop->base.override->data))->base.value))
- {
- g_free (prop->base.value);
- }
- g_slice_free (AmpGroupPropertyInfo, prop);
- }
-}
-
-static AmpTargetPropertyInfo *
-amp_target_property_new (void)
-{
- AmpTargetPropertyInfo *prop;
-
- prop = g_slice_new0(AmpTargetPropertyInfo);
-
- return prop;
-}
-
-static void
-amp_target_property_free (AmpTargetPropertyInfo *prop)
+amp_property_free (AmpPropertyInfo *prop)
{
if (prop->base.override != NULL)
{
- if ((prop->base.value != NULL) && (prop->base.value != ((AmpTargetPropertyInfo *)(prop->base.override->data))->base.value))
+ if ((prop->base.value != NULL) && (prop->base.value != ((AmpPropertyInfo *)(prop->base.override->data))->base.value))
{
g_free (prop->base.value);
}
- g_slice_free (AmpTargetPropertyInfo, prop);
+ g_slice_free (AmpPropertyInfo, prop);
}
}
@@ -740,7 +694,7 @@ amp_group_free (AmpGroup *node)
gint i;
if (group->base.directory) g_object_unref (group->base.directory);
- anjuta_project_property_foreach (group->base.node.properties, (GFunc)amp_project_property_free, NULL);
+ anjuta_project_property_foreach (group->base.node.properties, (GFunc)amp_property_free, NULL);
if (group->tfile) anjuta_token_file_free (group->tfile);
if (group->makefile) g_object_unref (group->makefile);
for (i = 0; i < AM_GROUP_TOKEN_LAST; i++)
@@ -786,7 +740,7 @@ amp_target_new (const gchar *name, AnjutaProjectTargetType type, const gchar *in
target = g_slice_new0(AmpTargetData);
target->base.node.type = ANJUTA_PROJECT_TARGET;
- target->base.node.properties = amp_get_target_property_list();
+ target->base.node.properties = amp_get_target_property_list(type);
target->base.name = g_strdup (name);
target->base.type = type;
target->install = g_strdup (install);
@@ -801,7 +755,7 @@ amp_target_free (AmpTarget *node)
AmpTargetData *target = AMP_TARGET_DATA (node);
g_free (target->base.name);
- anjuta_project_property_foreach (target->base.node.properties, (GFunc)amp_project_property_free, NULL);
+ anjuta_project_property_foreach (target->base.node.properties, (GFunc)amp_property_free, NULL);
g_free (target->install);
g_slice_free (AmpTargetData, target);
@@ -830,7 +784,7 @@ amp_source_free (AmpSource *node)
AmpSourceData *source = AMP_SOURCE_DATA (node);
g_object_unref (source->base.file);
- anjuta_project_property_foreach (source->base.node.properties, (GFunc)amp_project_property_free, NULL);
+ anjuta_project_property_foreach (source->base.node.properties, (GFunc)amp_property_free, NULL);
g_slice_free (AmpSourceData, source);
g_node_destroy (node);
@@ -1016,24 +970,24 @@ amp_project_load_properties (AmpProject *project, AnjutaToken *macro, AnjutaToke
for (list = anjuta_project_property_first (project->properties); list != NULL; list = anjuta_project_property_next (list))
{
- AmpProjectPropertyInfo *info = anjuta_project_property_get_info (list);
+ AmpPropertyInfo *info = (AmpPropertyInfo *)anjuta_project_property_get_info (list);
if (info->position >= 0)
{
- AmpProjectPropertyInfo *prop;
+ AnjutaProjectPropertyInfo *prop;
AnjutaToken *arg;
prop = anjuta_project_property_lookup (project->properties, list);
if (prop == NULL)
{
- prop = amp_project_property_new (macro);
+ prop = (AnjutaProjectPropertyInfo *)amp_property_new (macro);
project->properties = anjuta_project_property_insert (project->properties, list, prop);
}
arg = anjuta_token_nth_word (args, info->position);
- if ((prop->base.value != NULL) && (prop->base.value != info->base.value)) g_free (prop->base.value);
- prop->base.value = anjuta_token_evaluate (arg);
+ if ((prop->value != NULL) && (prop->value != info->base.value)) g_free (prop->value);
+ prop->value = anjuta_token_evaluate (arg);
}
}
}
@@ -1485,11 +1439,8 @@ remove_config_file (gpointer data, GObject *object, gboolean is_last_ref)
static AmpGroup*
project_load_makefile (AmpProject *project, GFile *file, AnjutaProjectGroup *parent, gboolean dist_only)
{
- //GHashTable *orphan_sources = NULL;
const gchar **filename;
- AmpAmScanner *scanner;
AmpGroup *group;
- //AnjutaToken *significant_tok;
AnjutaTokenFile *tfile;
GFile *makefile = NULL;
@@ -1504,7 +1455,7 @@ project_load_makefile (AmpProject *project, GFile *file, AnjutaProjectGroup *par
{
anjuta_project_node_append (parent, group);
}
-
+
/* Find makefile name
* It has to be in the config_files list with .am extension */
for (filename = valid_am_makefiles; *filename != NULL; filename++)
@@ -1705,7 +1656,7 @@ amp_project_unload (AmpProject *project)
if (project->root_file) g_object_unref (project->root_file);
project->root_file = NULL;
- anjuta_project_property_foreach (project->properties, (GFunc)amp_project_property_free, NULL);
+ anjuta_project_property_foreach (project->properties, (GFunc)amp_property_free, NULL);
project->properties = amp_get_project_property_list ();
/* shortcut hash tables */
diff --git a/plugins/am-project/am-properties.c b/plugins/am-project/am-properties.c
index b7ed100..bd8b0a1 100644
--- a/plugins/am-project/am-properties.c
+++ b/plugins/am-project/am-properties.c
@@ -37,7 +37,7 @@
/* Constants
*---------------------------------------------------------------------------*/
-static AmpProjectPropertyInfo AmpProjectProperties[] = {
+static AmpPropertyInfo AmpProjectProperties[] = {
{{N_("Name:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 0},
{{N_("Version:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 1},
{{N_("Bug report URL:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 2},
@@ -48,7 +48,7 @@ static AmpProjectPropertyInfo AmpProjectProperties[] = {
static GList* AmpProjectPropertyList = NULL;
-static AmpGroupPropertyInfo AmpGroupProperties[] = {
+static AmpPropertyInfo AmpGroupProperties[] = {
{{N_("Linker flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 4},
{{N_("C preprocessor flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 4},
{{N_("C compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 4},
@@ -64,9 +64,9 @@ static AmpGroupPropertyInfo AmpGroupProperties[] = {
static GList* AmpGroupPropertyList = NULL;
-static AmpTargetPropertyInfo AmpTargetProperties[] = {
+static AmpPropertyInfo AmpTargetProperties[] = {
+ {{N_("Do not install:"), ANJUTA_PROJECT_PROPERTY_BOOLEAN, NULL, NULL}, NULL, 3},
{{N_("Installation directory:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 4},
- {{N_("Include in distribution:"), ANJUTA_PROJECT_PROPERTY_BOOLEAN, NULL, NULL}, NULL, 2},
{{N_("Linker flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 4},
{{N_("C preprocessor flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 4},
{{N_("C compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 4},
@@ -78,72 +78,82 @@ static AmpTargetPropertyInfo AmpTargetProperties[] = {
{{N_("Yacc/Bison flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 4},
{{N_("Ratfor compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 4},
{{N_("Additional dependencies:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 4},
+ {{N_("Include in distribution:"), ANJUTA_PROJECT_PROPERTY_BOOLEAN, NULL, NULL}, NULL, 2},
{{N_("Build for check only:"), ANJUTA_PROJECT_PROPERTY_BOOLEAN, NULL, NULL}, NULL, 3},
{{N_("Do not use prefix:"), ANJUTA_PROJECT_PROPERTY_BOOLEAN, NULL, NULL}, NULL, 1},
{{N_("Keep target path:"), ANJUTA_PROJECT_PROPERTY_BOOLEAN, NULL, NULL}, NULL, 0},
- {{N_("Manual section:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 4},
{{NULL, ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 0}};
static GList* AmpTargetPropertyList = NULL;
+static AmpPropertyInfo AmpManTargetProperties[] = {
+ {{N_("Installation directory:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 4},
+ {{N_("Linker flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 4},
+ {{N_("C preprocessor flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 4},
+ {{N_("C compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 4},
+ {{N_("C++ compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 4},
+ {{N_("Java Compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 4},
+ {{N_("Fortan compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 4},
+ {{N_("Objective C compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 4},
+ {{N_("Lex/Flex flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 4},
+ {{N_("Yacc/Bison flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 4},
+ {{N_("Ratfor compiler flags:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 4},
+ {{N_("Additional dependencies:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 4},
+ {{N_("Include in distribution:"), ANJUTA_PROJECT_PROPERTY_BOOLEAN, NULL, NULL}, NULL, 2},
+ {{N_("Keep target path:"), ANJUTA_PROJECT_PROPERTY_BOOLEAN, NULL, NULL}, NULL, 0},
+ {{N_("Manual section:"), ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 4},
+ {{NULL, ANJUTA_PROJECT_PROPERTY_STRING, NULL, NULL}, NULL, 0}};
+
+static GList* AmpManTargetPropertyList = NULL;
+
/* Helper functions
*---------------------------------------------------------------------------*/
/* Private functions
*---------------------------------------------------------------------------*/
-/* Public functions
- *---------------------------------------------------------------------------*/
-
-GList*
-amp_get_project_property_list (void)
+static GList *
+amp_create_property_list (GList **list, AmpPropertyInfo *info)
{
- if (AmpProjectPropertyList == NULL)
+ if (*list == NULL)
{
- AmpProjectPropertyInfo *prop;
+ AmpPropertyInfo *prop;
- for (prop = AmpProjectProperties; prop->base.name != NULL; prop++)
+ for (prop = info; prop->base.name != NULL; prop++)
{
- AmpProjectPropertyList = g_list_prepend (AmpProjectPropertyList, prop);
+ *list = g_list_prepend (*list, prop);
}
- AmpProjectPropertyList = g_list_reverse (AmpProjectPropertyList);
+ *list = g_list_reverse (*list);
}
- return AmpProjectPropertyList;
+ return *list;
}
+/* Public functions
+ *---------------------------------------------------------------------------*/
+
GList*
-amp_get_group_property_list (void)
+amp_get_project_property_list (void)
{
- if (AmpGroupPropertyList == NULL)
- {
- AmpGroupPropertyInfo *prop;
-
- for (prop = AmpGroupProperties; prop->base.name != NULL; prop++)
- {
- AmpGroupPropertyList = g_list_prepend (AmpGroupPropertyList, prop);
- }
- AmpGroupPropertyList = g_list_reverse (AmpGroupPropertyList);
- }
+ return amp_create_property_list (&AmpProjectPropertyList, AmpProjectProperties);
+}
- return AmpGroupPropertyList;
+GList*
+amp_get_group_property_list (void)
+{
+ return amp_create_property_list (&AmpGroupPropertyList, AmpGroupProperties);
}
GList*
-amp_get_target_property_list (void)
+amp_get_target_property_list (AnjutaProjectTargetType type)
{
- if (AmpTargetPropertyList == NULL)
+ switch (type->base)
{
- AmpTargetPropertyInfo *prop;
-
- for (prop = AmpTargetProperties; prop->base.name != NULL; prop++)
- {
- AmpTargetPropertyList = g_list_prepend (AmpTargetPropertyList, prop);
- }
- AmpTargetPropertyList = g_list_reverse (AmpTargetPropertyList);
+ case ANJUTA_TARGET_MAN:
+ return amp_create_property_list (&AmpManTargetPropertyList, AmpManTargetProperties);
+ default:
+ return amp_create_property_list (&AmpTargetPropertyList, AmpTargetProperties);
}
-
- return AmpTargetPropertyList;
}
GList*
diff --git a/plugins/am-project/am-properties.h b/plugins/am-project/am-properties.h
index e6c1005..dc3468f 100644
--- a/plugins/am-project/am-properties.h
+++ b/plugins/am-project/am-properties.h
@@ -30,7 +30,7 @@ G_BEGIN_DECLS
GList* amp_get_project_property_list (void);
GList* amp_get_group_property_list (void);
-GList* amp_get_target_property_list (void);
+GList* amp_get_target_property_list (AnjutaProjectTargetType type);
GList* amp_get_source_property_list (void);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]