[anjuta/newproject] pm: Allow to modify project property from the GUI
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta/newproject] pm: Allow to modify project property from the GUI
- Date: Thu, 27 May 2010 20:48:34 +0000 (UTC)
commit e348d92100af60034fed50363cd8da7551199dac
Author: Sébastien Granjoux <seb sfo free fr>
Date: Thu May 27 22:46:28 2010 +0200
pm: Allow to modify project property from the GUI
libanjuta/anjuta-project.c | 9 +-
libanjuta/anjuta-project.h | 5 +
libanjuta/anjuta-token-file.c | 4 +-
libanjuta/interfaces/libanjuta.idl | 14 ++
plugins/am-project/ac-writer.c | 20 ++--
plugins/am-project/am-project.c | 12 ++
plugins/am-project/am-writer.c | 12 +-
plugins/dir-project/dir-project.c | 11 ++
plugins/mk-project/mk-project.c | 11 ++
plugins/project-manager/dialogs.c | 221 +++++++++++++++++++++++++------
plugins/project-manager/dialogs.h | 2 +-
plugins/project-manager/project-model.c | 12 +-
plugins/project-manager/project.c | 42 +++++-
plugins/project-manager/project.h | 3 +
14 files changed, 303 insertions(+), 75 deletions(-)
---
diff --git a/libanjuta/anjuta-project.c b/libanjuta/anjuta-project.c
index 5a54530..b98f863 100644
--- a/libanjuta/anjuta-project.c
+++ b/libanjuta/anjuta-project.c
@@ -533,13 +533,18 @@ AnjutaProjectProperty *
anjuta_project_node_get_property (AnjutaProjectNode *node, AnjutaProjectProperty *property)
{
GList *item;
-
+ AnjutaProjectPropertyInfo *info;
+
+ /* Get main property */
+ info = (AnjutaProjectPropertyInfo *)property->data;
+ if (info->override != NULL) property = info->override;
+
/* Get properties list */
item = g_list_first (NODE_DATA (node)->properties);
for (; item != NULL; item = g_list_next (item))
{
- AnjutaProjectPropertyInfo *info = (AnjutaProjectPropertyInfo *)item->data;
+ info = (AnjutaProjectPropertyInfo *)item->data;
if (info->override == NULL)
{
diff --git a/libanjuta/anjuta-project.h b/libanjuta/anjuta-project.h
index a16d1a7..05276bb 100644
--- a/libanjuta/anjuta-project.h
+++ b/libanjuta/anjuta-project.h
@@ -108,6 +108,11 @@ typedef struct
typedef GList AnjutaProjectProperty;
+typedef struct
+{
+ AnjutaProjectProperty *property;
+ gchar *value;
+} AnjutaProjectPropertyValue;
typedef struct
{
diff --git a/libanjuta/anjuta-token-file.c b/libanjuta/anjuta-token-file.c
index 7964cff..4d2b356 100644
--- a/libanjuta/anjuta-token-file.c
+++ b/libanjuta/anjuta-token-file.c
@@ -333,8 +333,8 @@ anjuta_token_file_update (AnjutaTokenFile *file, AnjutaToken *token)
}
}
- fprintf (stdout, "Dump config list from file:\n");
- anjuta_token_dump (file->content);
+ //fprintf (stdout, "Dump config list from file:\n");
+ //anjuta_token_dump (file->content);
return TRUE;
diff --git a/libanjuta/interfaces/libanjuta.idl b/libanjuta/interfaces/libanjuta.idl
index fce90e0..bd92d32 100644
--- a/libanjuta/interfaces/libanjuta.idl
+++ b/libanjuta/interfaces/libanjuta.idl
@@ -3126,6 +3126,20 @@ interface IAnjutaProject
void free_node (AnjutaProjectNode *node);
/**
+ * ianjuta_project_set_property:
+ * @obj: Self
+ * @node: Node
+ * @property: Property
+ * @value: Value
+ * @err: Error propagation and reporting
+ *
+ * Change a properties on node.
+ *
+ * Return value: FALSE if some properties cannot be set.
+ */
+ gboolean set_property (AnjutaProjectNode *parent, AnjutaProjectProperty* property, const gchar *value);
+
+ /**
* ianjuta_project_new_root_node:
* @obj: Self
* @file: Project file or directory
diff --git a/plugins/am-project/ac-writer.c b/plugins/am-project/ac-writer.c
index 7524f00..0525707 100644
--- a/plugins/am-project/ac-writer.c
+++ b/plugins/am-project/ac-writer.c
@@ -157,22 +157,22 @@ amp_project_update_property (AmpProject *project, AnjutaProjectProperty *propert
token = anjuta_token_insert_after (group, anjuta_token_new_static (ANJUTA_TOKEN_LAST | ANJUTA_TOKEN_ADDED, NULL));
anjuta_token_merge (group, token);
anjuta_token_insert_after (token, anjuta_token_new_string (EOL | ANJUTA_TOKEN_ADDED, "\n"));
- fprintf(stdout, "whole file\n");
- anjuta_token_dump (project->configure_token);
+ //fprintf(stdout, "whole file\n");
+ //anjuta_token_dump (project->configure_token);
}
- fprintf(stdout, "ac_init before replace\n");
- anjuta_token_dump (project->args);
+ //fprintf(stdout, "ac_init before replace\n");
+ //anjuta_token_dump (project->args);
token = anjuta_token_new_string (ANJUTA_TOKEN_NAME | ANJUTA_TOKEN_ADDED, value);
arg = anjuta_token_insert_before (token, anjuta_token_new_static (ANJUTA_TOKEN_ITEM | ANJUTA_TOKEN_ADDED, NULL));
anjuta_token_merge (arg, token);
anjuta_token_replace_nth_word (project->args, pos, arg);
- fprintf(stdout, "ac_init after replace\n");
- anjuta_token_dump (project->args);
- fprintf(stdout, "ac_init after replace link\n");
- anjuta_token_dump_link (project->args);
+ //fprintf(stdout, "ac_init after replace\n");
+ //anjuta_token_dump (project->args);
+ //fprintf(stdout, "ac_init after replace link\n");
+ //anjuta_token_dump_link (project->args);
anjuta_token_style_format (project->arg_list, project->args);
- fprintf(stdout, "ac_init after update link\n");
- anjuta_token_dump (project->args);
+ //fprintf(stdout, "ac_init after update link\n");
+ //anjuta_token_dump (project->args);
anjuta_token_file_update (project->configure_file, token);
return TRUE;
diff --git a/plugins/am-project/am-project.c b/plugins/am-project/am-project.c
index 1349e85..47b5d64 100644
--- a/plugins/am-project/am-project.c
+++ b/plugins/am-project/am-project.c
@@ -3339,6 +3339,17 @@ iproject_save_node (IAnjutaProject *obj, AnjutaProjectNode *node, GError **error
return node;
}
+static gboolean
+iproject_set_property (IAnjutaProject *obj, AnjutaProjectNode *node, AnjutaProjectProperty *property, const gchar *value, GError **error)
+{
+ AnjutaProjectProperty *new_prop;
+
+ new_prop = amp_node_property_set (node, property, value);
+ amp_project_update_property (AMP_PROJECT (obj), new_prop);
+
+ return TRUE;
+}
+
static AnjutaProjectNode *
iproject_new_node (IAnjutaProject *obj, AnjutaProjectNode *parent, AnjutaProjectNodeType type, GFile *file, const gchar *name, GError **err)
{
@@ -3431,6 +3442,7 @@ iproject_iface_init(IAnjutaProjectIface* iface)
iface->configure_node = iproject_configure_node;
iface->load_node = iproject_load_node;
iface->save_node = iproject_save_node;
+ iface->set_property = iproject_set_property;
iface->new_node = iproject_new_node;
iface->free_node = iproject_free_node;
iface->new_root_node = iproject_new_root_node;
diff --git a/plugins/am-project/am-writer.c b/plugins/am-project/am-writer.c
index a68f534..2168137 100644
--- a/plugins/am-project/am-writer.c
+++ b/plugins/am-project/am-writer.c
@@ -113,8 +113,8 @@ amp_project_write_config_file (AmpProject *project, AnjutaToken *list, gboolean
AnjutaToken *token;
token = anjuta_token_new_string (ANJUTA_TOKEN_NAME | ANJUTA_TOKEN_ADDED, filename);
- fprintf (stdout, "Dump config list:\n");
- anjuta_token_dump (list);
+ //fprintf (stdout, "Dump config list:\n");
+ //anjuta_token_dump (list);
if (after)
{
anjuta_token_insert_word_after (list, sibling, token);
@@ -123,13 +123,13 @@ amp_project_write_config_file (AmpProject *project, AnjutaToken *list, gboolean
{
anjuta_token_insert_word_before (list, sibling, token);
}
- fprintf (stdout, "Dump config list after insertion:\n");
- anjuta_token_dump (list);
+ //fprintf (stdout, "Dump config list after insertion:\n");
+ //anjuta_token_dump (list);
anjuta_token_style_format (project->ac_space_list, list);
- fprintf (stdout, "Dump config list after format:\n");
- anjuta_token_dump (list);
+ //fprintf (stdout, "Dump config list after format:\n");
+ //anjuta_token_dump (list);
anjuta_token_file_update (project->configure_file, list);
diff --git a/plugins/dir-project/dir-project.c b/plugins/dir-project/dir-project.c
index 831953d..252ffd5 100644
--- a/plugins/dir-project/dir-project.c
+++ b/plugins/dir-project/dir-project.c
@@ -1034,6 +1034,16 @@ iproject_free_node (IAnjutaProject *obj, AnjutaProjectNode *node, GError **err)
project_node_destroy (DIR_PROJECT (obj), node);
}
+static gboolean
+iproject_set_property (IAnjutaProject *obj, AnjutaProjectNode *node, AnjutaProjectProperty *property, const gchar *value, GError **error)
+{
+ g_set_error (error, IANJUTA_PROJECT_ERROR,
+ IANJUTA_PROJECT_ERROR_NOT_SUPPORTED,
+ _("Project doesn't allow to set properties"));
+
+ return FALSE;
+}
+
static AnjutaProjectNode *
iproject_new_root_node (IAnjutaProject *obj, GFile *file, GError **error)
{
@@ -1119,6 +1129,7 @@ iproject_iface_init(IAnjutaProjectIface* iface)
iface->save_node = iproject_save_node;
iface->new_node = iproject_new_node;
iface->free_node = iproject_free_node;
+ iface->set_property = iproject_set_property;
iface->add_group = iproject_add_group;
iface->add_source = iproject_add_source;
diff --git a/plugins/mk-project/mk-project.c b/plugins/mk-project/mk-project.c
index 655c0b6..ed67446 100644
--- a/plugins/mk-project/mk-project.c
+++ b/plugins/mk-project/mk-project.c
@@ -1437,6 +1437,16 @@ iproject_save_node (IAnjutaProject *obj, AnjutaProjectNode *node, GError **err)
return NULL;
}
+static gboolean
+iproject_set_property (IAnjutaProject *obj, AnjutaProjectNode *node, AnjutaProjectProperty *property, const gchar *value, GError **error)
+{
+ g_set_error (error, IANJUTA_PROJECT_ERROR,
+ IANJUTA_PROJECT_ERROR_NOT_SUPPORTED,
+ _("Project doesn't allow to set properties"));
+
+ return FALSE;
+}
+
static AnjutaProjectNode *
iproject_new_root_node (IAnjutaProject *obj, GFile *file, GError **err)
{
@@ -1508,6 +1518,7 @@ iproject_iface_init(IAnjutaProjectIface* iface)
iface->refresh = iproject_refresh;
iface->load_node = iproject_load_node;
iface->save_node = iproject_save_node;
+ iface->set_property = iproject_set_property;
iface->new_root_node = iproject_new_root_node;
iface->add_file_node = iproject_add_file_node;
iface->add_name_node = iproject_add_name_node;
diff --git a/plugins/project-manager/dialogs.c b/plugins/project-manager/dialogs.c
index 7ba728b..306ea5d 100644
--- a/plugins/project-manager/dialogs.c
+++ b/plugins/project-manager/dialogs.c
@@ -42,12 +42,25 @@
/* Types
*---------------------------------------------------------------------------*/
-typedef struct _ConfigureProjectDialog
+typedef struct _PropertiesTable
{
- IAnjutaProject *project;
+ AnjutaPmProject *project;
+ GtkWidget *table;
+ AnjutaProjectNode *node;
+ GList *properties;
+} PropertiesTable;
- GtkWidget *top_level;
-} ConfigureProjectDialog;
+typedef struct _PropertyEntry
+{
+ GtkWidget *entry;
+ AnjutaProjectProperty *property;
+} PropertyEntry;
+
+typedef struct _PropertyValue
+{
+ AnjutaProjectProperty *property;
+ const gchar *value;
+} PropertyValue;
enum {
NAME_COLUMN,
@@ -107,6 +120,42 @@ error_dialog (GtkWindow *parent, const gchar *summary, const gchar *msg, ...)
/* Private nodes functions
*---------------------------------------------------------------------------*/
+static PropertyEntry*
+pm_property_entry_new (GtkWidget *entry, AnjutaProjectProperty *property)
+{
+ PropertyEntry *prop;
+
+ prop = g_slice_new0(PropertyEntry);
+ prop->entry = entry;
+ prop->property = property;
+
+ return prop;
+}
+
+static void
+pm_property_entry_free (PropertyEntry *prop)
+{
+ g_slice_free (PropertyEntry, prop);
+}
+
+static PropertyValue*
+pm_property_value_new (AnjutaProjectProperty *property, const gchar *value)
+{
+ PropertyValue *prop;
+
+ prop = g_slice_new0(PropertyValue);
+ prop->property = property;
+ prop->value = value;
+
+ return prop;
+}
+
+static void
+pm_property_value_free (PropertyValue *prop)
+{
+ g_slice_free (PropertyValue, prop);
+}
+
static gboolean
parent_filter_func (GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
{
@@ -333,14 +382,7 @@ browse_button_clicked_cb (GtkWidget *widget, gpointer user_data)
/* Private properties functions
*---------------------------------------------------------------------------*/
-static void
-on_project_widget_destroy (GtkWidget *wid, ConfigureProjectDialog *dlg)
-{
- g_object_unref (dlg->top_level);
- g_free (dlg);
-}
-
-static void
+static GtkWidget *
add_entry (IAnjutaProject *project, AnjutaProjectNode *node, AnjutaProjectProperty *prop, GtkWidget *table, gint *position)
{
GtkWidget *label;
@@ -422,13 +464,15 @@ add_entry (IAnjutaProject *project, AnjutaProjectNode *node, AnjutaProjectProper
break;
default:
- return;
+ return NULL;
}
gtk_widget_show (entry);
gtk_table_attach (GTK_TABLE (table), entry, 1, 2, *position, *position+1,
GTK_FILL | GTK_EXPAND, GTK_FILL, 5, 3);
*position = *position + 1;
+
+ return entry;
}
static void
@@ -451,15 +495,16 @@ add_label (const gchar *display_name, const gchar *value, GtkWidget *table, gint
*position = *position + 1;
}
-static GtkWidget *
+static PropertiesTable*
create_properties_table (IAnjutaProject *project, AnjutaProjectNode *node)
{
GtkBuilder *bxml;
- ConfigureProjectDialog *dlg;
+ PropertiesTable *table;
GtkWidget *properties;
GtkWidget *main_table;
GtkWidget *extra_table;
GtkWidget *extra_expand;
+
gint main_pos;
gint extra_pos;
gchar *path;
@@ -473,16 +518,16 @@ create_properties_table (IAnjutaProject *project, AnjutaProjectNode *node)
bxml = anjuta_util_builder_new (GLADE_FILE, NULL);
if (!bxml) return NULL;
- dlg = g_new0 (ConfigureProjectDialog, 1);
+ table = g_new0 (PropertiesTable, 1);
+ table->node = node;
anjuta_util_builder_get_objects (bxml,
"properties", &properties,
"main_table", &main_table,
"extra_table", &extra_table,
"extra_expand", &extra_expand,
NULL);
- dlg->top_level = properties;
+ table->table = properties;
g_object_ref (properties);
- g_signal_connect (properties, "destroy", G_CALLBACK (on_project_widget_destroy), dlg);
main_pos = 0;
extra_pos = 0;
@@ -520,20 +565,28 @@ create_properties_table (IAnjutaProject *project, AnjutaProjectNode *node)
for (valid_prop = anjuta_project_node_first_valid_property (node); valid_prop != NULL; valid_prop = anjuta_project_property_next (valid_prop))
{
AnjutaProjectProperty *prop;
+ GtkWidget *entry;
prop = anjuta_project_node_get_property (node, valid_prop);
if (prop != NULL)
{
/* This property has been set, display it in the main part */
- add_entry (project, node, prop, main_table, &main_pos);
+ entry = add_entry (project, node, prop, main_table, &main_pos);
}
else
{
/* This property has not been set, hide it by default */
- add_entry (project, node, valid_prop, extra_table, &extra_pos);
+ entry = add_entry (project, node, valid_prop, extra_table, &extra_pos);
single = TRUE;
}
+
+ if (entry != NULL)
+ {
+ table->properties = g_list_prepend (table->properties,
+ pm_property_entry_new (entry, valid_prop));
+ }
}
+ table->properties = g_list_reverse (table->properties);
gtk_widget_show_all (properties);
@@ -542,29 +595,113 @@ create_properties_table (IAnjutaProject *project, AnjutaProjectNode *node)
g_object_unref (bxml);
- return properties;
+ return table;
}
static void
-on_properties_dialog_response (GtkDialog *win,
+on_properties_dialog_response (GtkWidget *dialog,
gint id,
- GtkWidget **dialog)
+ PropertiesTable *table)
{
- gtk_widget_destroy (*dialog);
- *dialog = NULL;
+ if (id == GTK_RESPONSE_APPLY)
+ {
+ GList *item;
+ GList *modified = NULL;
+
+ /* Get all modified properties */
+ for (item = g_list_first (table->properties); item != NULL; item = g_list_next (item))
+ {
+ PropertyEntry *entry = (PropertyEntry *)item->data;
+ AnjutaProjectProperty *prop;
+ AnjutaProjectPropertyInfo *info;
+ const gchar *text;
+
+ /* Get property value in node */
+ prop = anjuta_project_node_get_property (table->node, entry->property);
+ if (prop == NULL) prop = entry->property;
+
+ info = anjuta_project_property_get_info (prop);
+ switch (info->type)
+ {
+ case ANJUTA_PROJECT_PROPERTY_STRING:
+ text = gtk_entry_get_text (GTK_ENTRY (entry->entry));
+ if (*text == '\0')
+ {
+ if ((info->value != NULL) && (*info->value != '\0'))
+ {
+ /* Remove */
+ PropertyValue *value;
+
+ value = g_slice_new0 (PropertyValue);
+ value->property = prop;
+ modified = g_list_prepend (modified, value);
+ }
+ }
+ else
+ {
+ if (g_strcmp0 (info->value, text) != 0)
+ {
+ /* Modified */
+ PropertyValue *value;
+
+ value = g_slice_new0 (PropertyValue);
+ value->property = prop;
+ value->value = text;
+ modified = g_list_prepend (modified, value);
+ }
+ }
+ break;
+ case ANJUTA_PROJECT_PROPERTY_BOOLEAN:
+ text = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (entry->entry)) ? "1" : "0";
+ if (g_strcmp0 (info->value, text) != 0)
+ {
+ /* Modified */
+ PropertyValue *value;
+
+ value = g_slice_new0 (PropertyValue);
+ value->property = prop;
+ value->value = text;
+ modified = g_list_prepend (modified, value);
+ }
+ break;
+ case ANJUTA_PROJECT_PROPERTY_LIST:
+ break;
+ default:
+ break;
+ }
+ }
+
+ /* Update all modified properties */
+ anjuta_pm_project_set_properties (table->project, table->node, modified, NULL);
+
+ /* Display modified properties */
+ /*for (item = g_list_first (modified); item != NULL; item = g_list_next (item))
+ {
+ PropertyValue *value = (PropertyValue *)item->data;
+ AnjutaProjectPropertyInfo *info;
+
+ info = anjuta_project_property_get_info (value->property);
+
+ }*/
+
+ g_list_foreach (modified, (GFunc)pm_property_value_free, NULL);
+ }
+ g_list_foreach (table->properties, (GFunc)pm_property_entry_free, NULL);
+ g_free (table);
+ gtk_widget_destroy (dialog);
}
/* Properties dialog
*---------------------------------------------------------------------------*/
-gboolean
-pm_project_create_properties_dialog (IAnjutaProject *project, GtkWidget **dialog, GtkWindow *parent, AnjutaProjectNode *node)
+GtkWidget *
+pm_project_create_properties_dialog (AnjutaPmProject *project, GtkWindow *parent, AnjutaProjectNode *node)
{
const char *title;
- GtkWidget *properties;
+ PropertiesTable *table;
+ GtkWidget *dialog;
g_return_val_if_fail (node != NULL, FALSE);
- g_return_val_if_fail (*dialog == NULL, FALSE);
switch (anjuta_project_node_get_type (node))
{
@@ -584,26 +721,30 @@ pm_project_create_properties_dialog (IAnjutaProject *project, GtkWidget **dialog
return FALSE;
}
- properties = create_properties_table (project, node);
+ table = create_properties_table (project->project, node);
- if (properties)
+ if (table != NULL)
{
- *dialog = gtk_dialog_new_with_buttons (title,
+ table->project = project;
+ dialog = gtk_dialog_new_with_buttons (title,
parent,
GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL, NULL);
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
+ GTK_STOCK_APPLY,
+ GTK_RESPONSE_APPLY, NULL);
- g_signal_connect (*dialog, "response",
+ g_signal_connect (dialog, "response",
G_CALLBACK (on_properties_dialog_response),
- dialog);
+ table);
- gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG(*dialog))),
- properties);
- gtk_window_set_default_size (GTK_WINDOW (*dialog), 450, -1);
- gtk_widget_show (*dialog);
+ gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG(dialog))),
+ table->table);
+ gtk_window_set_default_size (GTK_WINDOW (dialog), 450, -1);
+ gtk_widget_show (dialog);
}
- return *dialog != NULL;
+ return dialog;
}
/* Group dialog
diff --git a/plugins/project-manager/dialogs.h b/plugins/project-manager/dialogs.h
index dec27a3..eb81323 100644
--- a/plugins/project-manager/dialogs.h
+++ b/plugins/project-manager/dialogs.h
@@ -36,7 +36,7 @@ GList* anjuta_pm_project_new_module (AnjutaPmProject *project, GtkWindow *parent
GList* anjuta_pm_project_new_package (AnjutaPmProject *project, GtkWindow *parent, GtkTreeIter *default_module, GList *packages_to_add);
-gboolean pm_project_create_properties_dialog (IAnjutaProject *project, GtkWidget **dialog, GtkWindow *parent, AnjutaProjectNode *node);
+GtkWidget *pm_project_create_properties_dialog (AnjutaPmProject *project, GtkWindow *parent, AnjutaProjectNode *node);
G_END_DECLS
diff --git a/plugins/project-manager/project-model.c b/plugins/project-manager/project-model.c
index 6ad090c..c92119f 100644
--- a/plugins/project-manager/project-model.c
+++ b/plugins/project-manager/project-model.c
@@ -662,9 +662,9 @@ load_project (GbfProjectModel *model, AnjutaPmProject *proj)
//model->priv->project_updated_handler =
// g_signal_connect (anjuta_pm_project_get_project (model->priv->proj), "project-updated",
// (GCallback) project_updated_cb, model);
- model->priv->project_updated_handler =
- g_signal_connect (anjuta_pm_project_get_project (model->priv->proj), "project-updated",
- (GCallback) project_updated_cb, model);
+ //model->priv->project_updated_handler =
+ // g_signal_connect (anjuta_pm_project_get_project (model->priv->proj), "project-updated",
+ // (GCallback) project_updated_cb, model);
}
static void
@@ -693,9 +693,9 @@ unload_project (GbfProjectModel *model)
g_list_free (model->priv->shortcuts);
model->priv->shortcuts = NULL;
- g_signal_handler_disconnect (anjuta_pm_project_get_project (model->priv->proj),
- model->priv->project_updated_handler);
- model->priv->project_updated_handler = 0;
+ //g_signal_handler_disconnect (anjuta_pm_project_get_project (model->priv->proj),
+ // model->priv->project_updated_handler);
+ //model->priv->project_updated_handler = 0;
model->priv->proj = NULL;
insert_empty_node (model);
diff --git a/plugins/project-manager/project.c b/plugins/project-manager/project.c
index 1b5dc3c..5b49a01 100644
--- a/plugins/project-manager/project.c
+++ b/plugins/project-manager/project.c
@@ -102,6 +102,7 @@ typedef enum
{
LOAD = 0,
RELOAD,
+ SAVE,
ADD,
REMOVE,
EXIT,
@@ -598,6 +599,9 @@ static PmCommandWork PmCommands[LAST_COMMAND] = {
{pm_command_load_setup,
pm_command_load_work,
pm_command_load_complete},
+ {NULL,
+ pm_command_save_work,
+ NULL},
{pm_command_add_setup,
pm_command_save_work,
NULL},
@@ -931,6 +935,25 @@ anjuta_pm_project_remove (AnjutaPmProject *project, AnjutaProjectNode *node, GEr
}
gboolean
+anjuta_pm_project_set_properties (AnjutaPmProject *project, AnjutaProjectNode *node, GList *properties, GError **error)
+{
+ GList *item;
+ gboolean valid = FALSE;
+
+ for (item = g_list_first (properties); item != NULL; item = g_list_next (item))
+ {
+ AnjutaProjectPropertyValue *prop = (AnjutaProjectPropertyValue *)item->data;
+
+ valid = ianjuta_project_set_property (project->project, node, prop->property, prop->value, error);
+ if (!valid) break;
+ }
+
+ if (valid) pm_project_push_command (project, SAVE, node);
+
+ return valid;
+}
+
+gboolean
anjuta_pm_project_remove_data (AnjutaPmProject *project, GbfTreeData *data, GError **error)
{
GtkTreeIter iter;
@@ -1024,34 +1047,37 @@ anjuta_pm_project_get_node_from_file (AnjutaPmProject *project, AnjutaProjectNod
gboolean
anjuta_pm_project_show_properties_dialog (AnjutaPmProject *project, GbfTreeData *data)
{
- GtkWidget **dialog;
+ GtkWidget **dialog_ptr;
AnjutaProjectNode *node;
if (data == NULL)
{
/* Show project properties dialog */
- dialog = &project->properties_dialog;
+ dialog_ptr = &project->properties_dialog;
node = project->root;
}
else
{
/* Show node properties dialog */
- dialog = &data->properties_dialog;
+ dialog_ptr = &data->properties_dialog;
node = anjuta_pm_project_get_node (project, data);
}
- if (*dialog != NULL)
+ if (*dialog_ptr != NULL)
{
/* Show already existing dialog */
- gtk_window_present (GTK_WINDOW (*dialog));
+ gtk_window_present (GTK_WINDOW (*dialog_ptr));
}
else
{
- pm_project_create_properties_dialog (
- project->project,
- dialog,
+ *dialog_ptr = pm_project_create_properties_dialog (
+ project,
GTK_WINDOW (project->plugin->shell),
node);
+ if (*dialog_ptr != NULL)
+ {
+ g_object_add_weak_pointer (*dialog_ptr, dialog_ptr);
+ }
}
return TRUE;
diff --git a/plugins/project-manager/project.h b/plugins/project-manager/project.h
index f44989a..462ef31 100644
--- a/plugins/project-manager/project.h
+++ b/plugins/project-manager/project.h
@@ -98,6 +98,9 @@ AnjutaProjectNode *anjuta_pm_project_get_root (AnjutaPmProject *project);
gboolean anjuta_pm_project_remove (AnjutaPmProject *project, AnjutaProjectNode *node, GError **error);
gboolean anjuta_pm_project_remove_data (AnjutaPmProject *project, GbfTreeData *data, GError **error);
+gboolean anjuta_pm_project_set_properties (AnjutaPmProject *project, AnjutaProjectNode *node, GList *properties, GError **error);
+
+
gboolean anjuta_pm_project_is_open (AnjutaPmProject *project);
IAnjutaProject *anjuta_pm_project_get_project (AnjutaPmProject *project);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]