[anjuta/newproject] Emit a signal when a project is loaded.
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta/newproject] Emit a signal when a project is loaded.
- Date: Mon, 5 Apr 2010 09:25:43 +0000 (UTC)
commit c5fe38d8e0e30a4a0ad24c1efb15c13a40a5f084
Author: Sébastien Granjoux <seb sfo free fr>
Date: Sat Apr 3 10:31:20 2010 +0200
Emit a signal when a project is loaded.
libanjuta/anjuta-marshal.list | 1 +
plugins/project-manager/gbf-project-model.c | 24 +++---
plugins/project-manager/gbf-project-model.h | 8 +-
plugins/project-manager/gbf-project-util.c | 36 ++++----
plugins/project-manager/gbf-project-util.h | 12 +-
plugins/project-manager/plugin.c | 141 +++++++++++++++-----------
plugins/project-manager/plugin.h | 5 +-
plugins/project-manager/project.c | 119 +++++++++++++++--------
plugins/project-manager/project.h | 67 +++++++++----
9 files changed, 253 insertions(+), 160 deletions(-)
---
diff --git a/libanjuta/anjuta-marshal.list b/libanjuta/anjuta-marshal.list
index f00e68d..4f949ef 100644
--- a/libanjuta/anjuta-marshal.list
+++ b/libanjuta/anjuta-marshal.list
@@ -23,6 +23,7 @@
VOID:VOID
VOID:BOOLEAN
+VOID:BOXED
VOID:INT,STRING
VOID:INT,OBJECT
VOID:INT,INT,ULONG
diff --git a/plugins/project-manager/gbf-project-model.c b/plugins/project-manager/gbf-project-model.c
index 213deae..36cc432 100644
--- a/plugins/project-manager/gbf-project-model.c
+++ b/plugins/project-manager/gbf-project-model.c
@@ -38,7 +38,7 @@
struct _GbfProjectModelPrivate {
- ProjectManagerProject *proj;
+ AnjutaPmProject *proj;
gulong project_updated_handler;
GtkTreeRowReference *root_row;
@@ -60,7 +60,7 @@ static void gbf_project_model_drag_source_init (GtkTreeDragSourceIface *if
static void gbf_project_model_drag_dest_init (GtkTreeDragDestIface *iface);
static void load_project (GbfProjectModel *model,
- ProjectManagerProject *proj);
+ AnjutaPmProject *proj);
static void insert_empty_node (GbfProjectModel *model);
static void unload_project (GbfProjectModel *model);
@@ -421,7 +421,7 @@ add_target_shortcut (GbfProjectModel *model,
-1);
/* add sources */
- parent = pm_project_get_node (model->priv->proj, target);
+ parent = anjuta_pm_project_get_node (model->priv->proj, target);
for (node = anjuta_project_node_first_child (parent); node; node = anjuta_project_node_next_sibling (node))
add_source (model, node, &iter);
@@ -479,7 +479,7 @@ move_target_shortcut (GbfProjectModel *model,
-1);
/* add sources */
- parent = pm_project_get_node (model->priv->proj, shortcut->shortcut);
+ parent = anjuta_pm_project_get_node (model->priv->proj, shortcut->shortcut);
for (node = anjuta_project_node_first_child (parent); node; node = anjuta_project_node_next_sibling (node))
add_source (model, node, iter);
}
@@ -705,7 +705,7 @@ project_updated_cb (IAnjutaProject *project, GbfProjectModel *model)
}
static void
-load_project (GbfProjectModel *model, ProjectManagerProject *proj)
+load_project (GbfProjectModel *model, AnjutaPmProject *proj)
{
model->priv->proj = proj;
g_object_ref (proj);
@@ -713,10 +713,10 @@ load_project (GbfProjectModel *model, ProjectManagerProject *proj)
/* to get rid of the empty node */
gbf_project_model_clear (model);
- add_target_group (model, pm_project_get_root (proj), NULL);
+ add_target_group (model, anjuta_pm_project_get_root (proj), NULL);
model->priv->project_updated_handler =
- g_signal_connect (pm_project_get_project (model->priv->proj), "project-updated",
+ g_signal_connect (anjuta_pm_project_get_project (model->priv->proj), "project-updated",
(GCallback) project_updated_cb, model);
}
@@ -746,7 +746,7 @@ unload_project (GbfProjectModel *model)
g_list_free (model->priv->shortcuts);
model->priv->shortcuts = NULL;
- g_signal_handler_disconnect (pm_project_get_project (model->priv->proj),
+ 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;
@@ -808,7 +808,7 @@ gbf_project_model_find_tree_data (GbfProjectModel *model,
}
GbfProjectModel *
-gbf_project_model_new (ProjectManagerProject *project)
+gbf_project_model_new (AnjutaPmProject *project)
{
return GBF_PROJECT_MODEL (g_object_new (GBF_TYPE_PROJECT_MODEL,
"project", project,
@@ -816,7 +816,7 @@ gbf_project_model_new (ProjectManagerProject *project)
}
void
-gbf_project_model_set_project (GbfProjectModel *model, ProjectManagerProject *project)
+gbf_project_model_set_project (GbfProjectModel *model, AnjutaPmProject *project)
{
g_return_if_fail (model != NULL && GBF_IS_PROJECT_MODEL (model));
g_return_if_fail (project != NULL);
@@ -828,7 +828,7 @@ gbf_project_model_set_project (GbfProjectModel *model, ProjectManagerProject *pr
load_project (model, project);
}
-ProjectManagerProject *
+AnjutaPmProject *
gbf_project_model_get_project (GbfProjectModel *model)
{
g_return_val_if_fail (model != NULL && GBF_IS_PROJECT_MODEL (model), NULL);
@@ -859,7 +859,7 @@ gbf_project_model_get_node (GbfProjectModel *model,
GBF_PROJECT_MODEL_COLUMN_DATA, &data,
-1);
- return pm_project_get_node (model->priv->proj, data);
+ return anjuta_pm_project_get_node (model->priv->proj, data);
}
void
diff --git a/plugins/project-manager/gbf-project-model.h b/plugins/project-manager/gbf-project-model.h
index 37306f9..a20ca3e 100644
--- a/plugins/project-manager/gbf-project-model.h
+++ b/plugins/project-manager/gbf-project-model.h
@@ -52,14 +52,14 @@ struct _GbfProjectModelClass {
GtkTreeStoreClass parent_class;
};
-typedef struct _ProjectManagerProject ProjectManagerProject;
+typedef struct _AnjutaPmProject AnjutaPmProject;
GType gbf_project_model_get_type (void);
-GbfProjectModel *gbf_project_model_new (ProjectManagerProject *project);
+GbfProjectModel *gbf_project_model_new (AnjutaPmProject *project);
void gbf_project_model_set_project (GbfProjectModel *model,
- ProjectManagerProject *project);
-ProjectManagerProject *gbf_project_model_get_project (GbfProjectModel *model);
+ AnjutaPmProject *project);
+AnjutaPmProject *gbf_project_model_get_project (GbfProjectModel *model);
GtkTreePath *gbf_project_model_get_project_root (GbfProjectModel *model);
gboolean gbf_project_model_remove (GbfProjectModel *model,
diff --git a/plugins/project-manager/gbf-project-util.c b/plugins/project-manager/gbf-project-util.c
index 52d8f6a..5ccf039 100644
--- a/plugins/project-manager/gbf-project-util.c
+++ b/plugins/project-manager/gbf-project-util.c
@@ -76,7 +76,7 @@ groups_filter_fn (GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
}
static void
-setup_groups_treeview (ProjectManagerProject *project,
+setup_groups_treeview (AnjutaPmProject *project,
GtkWidget *view,
GtkTreeIter *select_group)
{
@@ -87,7 +87,7 @@ setup_groups_treeview (ProjectManagerProject *project,
g_return_if_fail (project != NULL);
g_return_if_fail (view != NULL && GBF_IS_PROJECT_VIEW (view));
- model = pm_project_get_model (project);
+ model = anjuta_pm_project_get_model (project);
filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (model), NULL);
gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (filter),
groups_filter_fn, NULL, NULL);
@@ -164,7 +164,7 @@ entry_changed_cb (GtkEditable *editable, gpointer user_data)
}
AnjutaProjectNode*
-gbf_project_util_new_group (ProjectManagerProject *project,
+gbf_project_util_new_group (AnjutaPmProject *project,
GtkWindow *parent,
GtkTreeIter *default_group,
const gchar *default_group_name_to_add)
@@ -222,7 +222,7 @@ gbf_project_util_new_group (ProjectManagerProject *project,
group = gbf_project_view_find_selected (GBF_PROJECT_VIEW (groups_view),
ANJUTA_PROJECT_GROUP);
if (group) {
- new_group = pm_project_add_group (project, group, name, &err);
+ new_group = anjuta_pm_project_add_group (project, group, name, &err);
if (err) {
error_dialog (parent, _("Cannot add group"), "%s",
err->message);
@@ -258,14 +258,14 @@ enum {
/* create a tree model with the target types */
static GtkListStore *
-build_types_store (ProjectManagerProject *project)
+build_types_store (AnjutaPmProject *project)
{
GtkListStore *store;
GtkTreeIter iter;
GList *types;
GList *node;
- types = pm_project_get_target_types (project);
+ types = anjuta_pm_project_get_target_types (project);
store = gtk_list_store_new (TARGET_TYPE_N_COLUMNS,
G_TYPE_POINTER,
G_TYPE_STRING,
@@ -299,7 +299,7 @@ build_types_store (ProjectManagerProject *project)
}
AnjutaProjectNode*
-gbf_project_util_new_target (ProjectManagerProject *project,
+gbf_project_util_new_target (AnjutaPmProject *project,
GtkWindow *parent,
GtkTreeIter *default_group,
const gchar *default_target_name_to_add)
@@ -395,7 +395,7 @@ gbf_project_util_new_target (ProjectManagerProject *project,
}
if (group && type) {
- new_target = pm_project_add_target (project, group, name, type, &err);
+ new_target = anjuta_pm_project_add_target (project, group, name, type, &err);
if (err) {
error_dialog (parent, _("Cannot add target"), "%s",
err->message);
@@ -441,7 +441,7 @@ targets_filter_fn (GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
}
static void
-setup_targets_treeview (ProjectManagerProject *project,
+setup_targets_treeview (AnjutaPmProject *project,
GtkWidget *view,
GtkTreeIter *select_target)
{
@@ -453,7 +453,7 @@ setup_targets_treeview (ProjectManagerProject *project,
g_return_if_fail (project != NULL);
g_return_if_fail (view != NULL && GBF_IS_PROJECT_VIEW (view));
- model = pm_project_get_model (project);
+ model = anjuta_pm_project_get_model (project);
filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (model), NULL);
gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (filter),
targets_filter_fn, NULL, NULL);
@@ -498,7 +498,7 @@ modules_filter_fn (GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
}
static void
-setup_modules_treeview (ProjectManagerProject *project,
+setup_modules_treeview (AnjutaPmProject *project,
GtkWidget *view,
GtkTreeIter *select_module)
{
@@ -510,7 +510,7 @@ setup_modules_treeview (ProjectManagerProject *project,
g_return_if_fail (model != NULL);
g_return_if_fail (view != NULL && GBF_IS_PROJECT_VIEW (view));
- model = pm_project_get_model (project);
+ model = anjuta_pm_project_get_model (project);
filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (model), NULL);
gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (filter),
modules_filter_fn, NULL, NULL);
@@ -622,7 +622,7 @@ on_row_changed(GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter, gpoint
}
AnjutaProjectNode*
-gbf_project_util_add_source (ProjectManagerProject *project,
+gbf_project_util_add_source (AnjutaPmProject *project,
GtkWindow *parent,
GtkTreeIter *default_target,
const gchar *default_uri)
@@ -652,7 +652,7 @@ gbf_project_util_add_source (ProjectManagerProject *project,
}
GList*
-gbf_project_util_add_source_multi (ProjectManagerProject *project,
+gbf_project_util_add_source_multi (AnjutaPmProject *project,
GtkWindow *parent,
GtkTreeIter *default_target,
GList *uris_to_add)
@@ -767,7 +767,7 @@ gbf_project_util_add_source_multi (ProjectManagerProject *project,
COLUMN_URI, &uri, -1);
source_file = g_file_new_for_uri (uri);
- new_source = pm_project_add_source (project,
+ new_source = anjuta_pm_project_add_source (project,
target,
source_file,
&err);
@@ -887,7 +887,7 @@ on_cursor_changed(GtkTreeView* view, gpointer data)
}
GList*
-gbf_project_util_add_module (ProjectManagerProject *project,
+gbf_project_util_add_module (AnjutaPmProject *project,
GtkWindow *parent,
GtkTreeIter *default_target,
const gchar *default_module)
@@ -1087,7 +1087,7 @@ on_changed_disconnect (GtkEditable* entry, gpointer data)
}
GList*
-gbf_project_util_add_package (ProjectManagerProject *project,
+gbf_project_util_add_package (AnjutaPmProject *project,
GtkWindow *parent,
GtkTreeIter *default_module,
GList *packages_to_add)
@@ -1124,7 +1124,7 @@ gbf_project_util_add_package (ProjectManagerProject *project,
store = gtk_list_store_new(1, G_TYPE_STRING);
gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (module_entry), 0);
- model = pm_project_get_model(project);
+ model = anjuta_pm_project_get_model(project);
for (valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &root); valid != FALSE; valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (model), &root))
{
GbfTreeData *data;
diff --git a/plugins/project-manager/gbf-project-util.h b/plugins/project-manager/gbf-project-util.h
index b3835fd..e86e6cf 100644
--- a/plugins/project-manager/gbf-project-util.h
+++ b/plugins/project-manager/gbf-project-util.h
@@ -30,33 +30,33 @@
G_BEGIN_DECLS
-AnjutaProjectNode* gbf_project_util_new_group (ProjectManagerProject *project,
+AnjutaProjectNode* gbf_project_util_new_group (AnjutaPmProject *project,
GtkWindow *parent,
GtkTreeIter *default_group,
const gchar *default_group_name_to_add);
-AnjutaProjectNode* gbf_project_util_new_target (ProjectManagerProject *project,
+AnjutaProjectNode* gbf_project_util_new_target (AnjutaPmProject *project,
GtkWindow *parent,
GtkTreeIter *default_group,
const gchar *default_target_name_to_add);
-AnjutaProjectNode* gbf_project_util_add_source (ProjectManagerProject *project,
+AnjutaProjectNode* gbf_project_util_add_source (AnjutaPmProject *project,
GtkWindow *parent,
GtkTreeIter *default_target,
const gchar *default_uri_to_add);
-GList* gbf_project_util_add_module (ProjectManagerProject *project,
+GList* gbf_project_util_add_module (AnjutaPmProject *project,
GtkWindow *parent,
GtkTreeIter *default_target,
const gchar *default_module_name_to_add);
-GList* gbf_project_util_add_package (ProjectManagerProject *project,
+GList* gbf_project_util_add_package (AnjutaPmProject *project,
GtkWindow *parent,
GtkTreeIter *default_module,
GList *packages_to_add);
-GList* gbf_project_util_add_source_multi (ProjectManagerProject *project,
+GList* gbf_project_util_add_source_multi (AnjutaPmProject *project,
GtkWindow *parent,
GtkTreeIter *default_target,
GList *uris_to_add);
diff --git a/plugins/project-manager/plugin.c b/plugins/project-manager/plugin.c
index e642307..acddae9 100644
--- a/plugins/project-manager/plugin.c
+++ b/plugins/project-manager/plugin.c
@@ -435,10 +435,10 @@ project_manager_show_node_properties_dialog (ProjectManagerPlugin *plugin,
{
case GBF_TREE_NODE_GROUP:
title = _("Group properties");
- node = pm_project_get_node (plugin->project, data);
+ node = anjuta_pm_project_get_node (plugin->project, data);
if (node != NULL)
{
- properties = pm_project_configure (plugin->project, node);
+ properties = anjuta_pm_project_configure (plugin->project, node);
if (properties == NULL)
{
@@ -449,10 +449,10 @@ project_manager_show_node_properties_dialog (ProjectManagerPlugin *plugin,
break;
case GBF_TREE_NODE_TARGET:
title = _("Target properties");
- node = pm_project_get_node (plugin->project, data);
+ node = anjuta_pm_project_get_node (plugin->project, data);
if (node != NULL)
{
- properties = pm_project_configure (plugin->project, node);
+ properties = anjuta_pm_project_configure (plugin->project, node);
if (properties == NULL)
{
@@ -490,7 +490,7 @@ project_manager_show_project_properties_dialog (ProjectManagerPlugin *plugin)
project_manager_create_properties_dialog(plugin,
&plugin->properties_dialog,
_("Project properties"),
- pm_project_configure (plugin->project, NULL));
+ anjuta_pm_project_configure (plugin->project, NULL));
}
}
@@ -511,7 +511,7 @@ on_refresh_idle (gpointer user_data)
anjuta_status_push (status, _("Refreshing symbol treeâ?¦"));
anjuta_status_busy_push (status);
- pm_project_refresh (plugin->project, &err);
+ anjuta_pm_project_refresh (plugin->project, &err);
if (err)
{
anjuta_util_dialog_error (get_plugin_parent_window (plugin),
@@ -840,11 +840,11 @@ on_popup_remove (GtkAction *action, ProjectManagerPlugin *plugin)
case GBF_TREE_NODE_GROUP:
case GBF_TREE_NODE_TARGET:
case GBF_TREE_NODE_SOURCE:
- node = pm_project_get_node(plugin->project, data);
+ node = anjuta_pm_project_get_node(plugin->project, data);
if (node != NULL)
{
if (!update) update_operation_begin (plugin);
- pm_project_remove (plugin->project, node, &err);
+ anjuta_pm_project_remove (plugin->project, node, &err);
if (err)
{
gchar *name;
@@ -861,7 +861,7 @@ on_popup_remove (GtkAction *action, ProjectManagerPlugin *plugin)
}
break;
case GBF_TREE_NODE_SHORTCUT:
- pm_project_remove_data (plugin->project, data, NULL);
+ anjuta_pm_project_remove_data (plugin->project, data, NULL);
break;
default:
break;
@@ -1054,7 +1054,7 @@ update_ui (ProjectManagerPlugin *plugin)
GtkAction *action;
IAnjutaProjectCapabilities caps;
- caps = pm_project_get_capabilities (plugin->project);
+ caps = anjuta_pm_project_get_capabilities (plugin->project);
ui = anjuta_shell_get_ui (ANJUTA_PLUGIN (plugin)->shell, NULL);
for (j = 0; j < G_N_ELEMENTS (pm_actions); j++)
@@ -1066,7 +1066,7 @@ update_ui (ProjectManagerPlugin *plugin)
{
/* 'close' menuitem is never disabled */
g_object_set (G_OBJECT (action), "sensitive",
- pm_project_is_open (plugin->project), NULL);
+ anjuta_pm_project_is_open (plugin->project), NULL);
}
}
@@ -1074,19 +1074,19 @@ update_ui (ProjectManagerPlugin *plugin)
action = anjuta_ui_get_action (ui, "ActionGroupProjectManager",
"ActionProjectAddGroup");
g_object_set (G_OBJECT (action), "sensitive",
- (pm_project_is_open (plugin->project) &&
+ (anjuta_pm_project_is_open (plugin->project) &&
(caps & IANJUTA_PROJECT_CAN_ADD_GROUP)), NULL);
action = anjuta_ui_get_action (ui, "ActionGroupProjectManager",
"ActionProjectAddTarget");
g_object_set (G_OBJECT (action), "sensitive",
- (pm_project_is_open (plugin->project) &&
+ (anjuta_pm_project_is_open (plugin->project) &&
(caps & IANJUTA_PROJECT_CAN_ADD_TARGET)), NULL);
action = anjuta_ui_get_action (ui, "ActionGroupProjectManager",
"ActionProjectAddSource");
g_object_set (G_OBJECT (action), "sensitive",
- (pm_project_is_open (plugin->project) &&
+ (anjuta_pm_project_is_open (plugin->project) &&
(caps & IANJUTA_PROJECT_CAN_ADD_SOURCE)), NULL);
/* Popup menus */
@@ -1097,7 +1097,7 @@ update_ui (ProjectManagerPlugin *plugin)
if (popup_actions[j].callback)
{
g_object_set (G_OBJECT (action), "sensitive",
- pm_project_is_open (plugin->project), NULL);
+ anjuta_pm_project_is_open (plugin->project), NULL);
}
}
}
@@ -1127,7 +1127,7 @@ on_treeview_selection_changed (GtkTreeSelection *sel,
"ActionPopupProjectRemove");
g_object_set (G_OBJECT (action), "sensitive", FALSE, NULL);
- caps = pm_project_get_capabilities (plugin->project);
+ caps = anjuta_pm_project_get_capabilities (plugin->project);
node = gbf_project_view_find_selected (GBF_PROJECT_VIEW (plugin->view),
ANJUTA_PROJECT_SOURCE);
if (node && anjuta_project_node_get_type (node) == ANJUTA_PROJECT_SOURCE)
@@ -1371,6 +1371,53 @@ value_removed_current_editor (AnjutaPlugin *plugin,
}
static void
+on_project_updated (AnjutaPmProject *project, GError *error, ProjectManagerPlugin *plugin)
+{
+ AnjutaStatus *status;
+ gchar *dirname;
+
+ dirname = anjuta_util_get_local_path_from_uri (plugin->project_root_uri);
+ status = anjuta_shell_get_status (ANJUTA_PLUGIN (plugin)->shell, NULL);
+ if (error)
+ {
+ GtkWidget *toplevel;
+ GtkWindow *win;
+
+ toplevel = gtk_widget_get_toplevel (plugin->scrolledwindow);
+ if (toplevel && GTK_IS_WINDOW (toplevel))
+ win = GTK_WINDOW (toplevel);
+ else
+ win = GTK_WINDOW (ANJUTA_PLUGIN (plugin)->shell);
+
+ anjuta_util_dialog_error (win, _("Failed to parse project (the project is opened, but there will be no project view) %s: %s\n"
+ ""),
+ dirname, error->message);
+ }
+ else
+ {
+ gchar *basename = g_path_get_basename (dirname);
+
+ anjuta_status_progress_tick (status, NULL, _("Update project viewâ?¦"));
+ update_ui (plugin);
+ anjuta_shell_present_widget (ANJUTA_PLUGIN (plugin)->shell,
+ plugin->scrolledwindow,
+ NULL);
+
+ anjuta_status_set_default (status, _("Project"), basename);
+ g_free (basename);
+ }
+ g_free (dirname);
+
+ if (plugin->busy)
+ {
+ anjuta_status_pop (status);
+ anjuta_status_busy_pop (status);
+ plugin->busy = FALSE;
+ }
+
+}
+
+static void
project_manager_load_gbf (ProjectManagerPlugin *pm_plugin)
{
AnjutaStatus *status;
@@ -1392,39 +1439,12 @@ project_manager_load_gbf (ProjectManagerPlugin *pm_plugin)
basename = g_path_get_basename (dirname);
anjuta_status_push (status, _("Loading project: %s"), basename);
anjuta_status_busy_push (status);
+ pm_plugin->busy = TRUE;
DEBUG_PRINT ("loading project %s\n\n", dirname);
- pm_project_load (pm_plugin->project, dirfile, &error);
+ anjuta_pm_project_load (pm_plugin->project, dirfile, &error);
g_message ("try loading %s %p", dirname, error);
- if (error)
- {
- GtkWidget *toplevel;
- GtkWindow *win;
-
- toplevel = gtk_widget_get_toplevel (pm_plugin->scrolledwindow);
- if (toplevel && GTK_IS_WINDOW (toplevel))
- win = GTK_WINDOW (toplevel);
- else
- win = GTK_WINDOW (ANJUTA_PLUGIN (pm_plugin)->shell);
-
- anjuta_util_dialog_error (win, _("Failed to parse project (the project is opened, but there will be no project view) %s: %s\n"
- ""),
- dirname, error->message);
- }
- else
- {
- anjuta_status_progress_tick (status, NULL, _("Created project viewâ?¦"));
- update_ui (pm_plugin);
- anjuta_shell_present_widget (ANJUTA_PLUGIN (pm_plugin)->shell,
- pm_plugin->scrolledwindow,
- NULL);
-
- anjuta_status_set_default (status, _("Project"), basename);
- }
-
- anjuta_status_pop (status);
- anjuta_status_busy_pop (status);
g_free (basename);
g_free (dirname);
g_object_unref (dirfile);
@@ -1435,7 +1455,7 @@ project_manager_unload_gbf (ProjectManagerPlugin *pm_plugin)
{
AnjutaStatus *status;
- if (pm_project_is_open (pm_plugin->project))
+ if (anjuta_pm_project_is_open (pm_plugin->project))
{
IAnjutaDocumentManager *docman;
@@ -1499,7 +1519,7 @@ project_manager_unload_gbf (ProjectManagerPlugin *pm_plugin)
pm_plugin->properties_dialog = NULL;
/* Release project */
- pm_project_unload (pm_plugin->project, NULL);
+ anjuta_pm_project_unload (pm_plugin->project, NULL);
update_ui (pm_plugin);
status = anjuta_shell_get_status (ANJUTA_PLUGIN (pm_plugin)->shell,
NULL);
@@ -1617,13 +1637,14 @@ project_manager_plugin_activate_plugin (AnjutaPlugin *plugin)
pm_plugin->prefs = anjuta_shell_get_preferences (plugin->shell, NULL);
/* Create project */
- pm_plugin->project = pm_project_new (plugin);
+ pm_plugin->project = anjuta_pm_project_new (plugin);
+ g_signal_connect (pm_plugin->project, "updated", G_CALLBACK (on_project_updated), plugin);
/* create model & view and bind them */
view = gbf_project_view_new ();
gtk_tree_view_set_model (GTK_TREE_VIEW (view),
- GTK_TREE_MODEL (pm_project_get_model (pm_plugin->project)));
+ GTK_TREE_MODEL (anjuta_pm_project_get_model (pm_plugin->project)));
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
@@ -1766,7 +1787,7 @@ project_manager_plugin_deactivate_plugin (AnjutaPlugin *plugin)
pm_plugin->popup_action_group);
/* Destroy project */
- pm_project_free (pm_plugin->project);
+ anjuta_pm_project_free (pm_plugin->project);
return TRUE;
}
@@ -1889,7 +1910,7 @@ get_element_file_from_node (ProjectManagerPlugin *plugin, AnjutaProjectNode *nod
{
gchar *rel_path;
- rel_path = g_file_get_relative_path (anjuta_project_group_get_directory (pm_project_get_root (plugin->project)), file);
+ rel_path = g_file_get_relative_path (anjuta_project_group_get_directory (anjuta_pm_project_get_root (plugin->project)), file);
if (rel_path)
{
@@ -1931,7 +1952,7 @@ get_project_node_from_file (ProjectManagerPlugin *plugin, GFile *file, AnjutaPro
break;
}
- node = pm_project_get_node (plugin->project, data);
+ node = anjuta_pm_project_get_node (plugin->project, data);
gbf_tree_data_free (data);
return node;
@@ -1944,7 +1965,7 @@ get_tree_iter_from_file (ProjectManagerPlugin *plugin, GtkTreeIter* iter, GFile
gboolean found;
data = gbf_tree_data_new_for_file (file, type);
- found = gbf_project_model_find_tree_data (pm_project_get_model (plugin->project), iter, data);
+ found = gbf_project_model_find_tree_data (anjuta_pm_project_get_model (plugin->project), iter, data);
gbf_tree_data_free (data);
return found ? iter : NULL;
@@ -1971,7 +1992,7 @@ iproject_manager_get_elements (IAnjutaProjectManager *project_manager,
plugin = ANJUTA_PLUGIN_PROJECT_MANAGER (G_OBJECT (project_manager));
- return gbf_project_util_replace_by_file (gbf_project_util_node_all (pm_project_get_root (plugin->project), element_type));
+ return gbf_project_util_replace_by_file (gbf_project_util_node_all (anjuta_pm_project_get_root (plugin->project), element_type));
}
static AnjutaProjectTargetClass
@@ -2017,7 +2038,7 @@ iproject_manager_get_targets (IAnjutaProjectManager *project_manager,
plugin = ANJUTA_PLUGIN_PROJECT_MANAGER (G_OBJECT (project_manager));
/* Get all targets */
- targets = gbf_project_util_node_all (pm_project_get_root (plugin->project), ANJUTA_PROJECT_TARGET);
+ targets = gbf_project_util_node_all (anjuta_pm_project_get_root (plugin->project), ANJUTA_PROJECT_TARGET);
/* Remove all targets not in specified class */
for (node = g_list_first (targets); node != NULL;)
@@ -2087,7 +2108,7 @@ iproject_manager_get_selected (IAnjutaProjectManager *project_manager,
g_return_val_if_fail (ANJUTA_IS_PLUGIN (project_manager), NULL);
plugin = ANJUTA_PLUGIN_PROJECT_MANAGER (G_OBJECT (project_manager));
- if (!pm_project_is_open (plugin->project)) return NULL;
+ if (!anjuta_pm_project_is_open (plugin->project)) return NULL;
node = gbf_project_view_find_selected (GBF_PROJECT_VIEW (plugin->view),
ANJUTA_PROJECT_SOURCE);
@@ -2123,7 +2144,7 @@ iproject_manager_get_capabilities (IAnjutaProjectManager *project_manager,
IANJUTA_PROJECT_CAN_ADD_NONE);
plugin = ANJUTA_PLUGIN_PROJECT_MANAGER (G_OBJECT (project_manager));
- return pm_project_get_capabilities (plugin->project);
+ return anjuta_pm_project_get_capabilities (plugin->project);
}
static GFile*
@@ -2176,7 +2197,7 @@ iproject_manager_add_source_quiet (IAnjutaProjectManager *project_manager,
target = get_project_node_from_file (plugin, location_file, ANJUTA_PROJECT_TARGET);
source_file = g_file_new_for_uri (source_uri_to_add);
update_operation_begin (plugin);
- source_id = pm_project_add_source (plugin->project,
+ source_id = anjuta_pm_project_add_source (plugin->project,
target,
source_file,
err);
@@ -2297,7 +2318,7 @@ iproject_manager_is_open (IAnjutaProjectManager *project_manager, GError **err)
plugin = ANJUTA_PLUGIN_PROJECT_MANAGER (G_OBJECT (project_manager));
- return pm_project_is_open (plugin->project);
+ return anjuta_pm_project_is_open (plugin->project);
}
static GList*
@@ -2307,7 +2328,7 @@ iproject_manager_get_packages (IAnjutaProjectManager *project_manager, GError **
plugin = ANJUTA_PLUGIN_PROJECT_MANAGER (G_OBJECT (project_manager));
- return pm_project_get_packages (plugin->project);
+ return anjuta_pm_project_get_packages (plugin->project);
}
static void
diff --git a/plugins/project-manager/plugin.h b/plugins/project-manager/plugin.h
index e3ebc10..3e224b0 100644
--- a/plugins/project-manager/plugin.h
+++ b/plugins/project-manager/plugin.h
@@ -42,7 +42,7 @@ typedef struct _ProjectManagerPluginClass ProjectManagerPluginClass;
struct _ProjectManagerPlugin{
AnjutaPlugin parent;
- ProjectManagerProject *project;
+ AnjutaPmProject *project;
AnjutaUI *ui;
AnjutaPreferences *prefs;
@@ -74,6 +74,9 @@ struct _ProjectManagerPlugin{
/* project properties dialog */
GtkWidget *properties_dialog;
+
+ /* project is loading */
+ gboolean busy;
};
struct _ProjectManagerPluginClass{
diff --git a/plugins/project-manager/project.c b/plugins/project-manager/project.c
index 8587450..b8205d5 100644
--- a/plugins/project-manager/project.c
+++ b/plugins/project-manager/project.c
@@ -24,32 +24,36 @@
#endif
#include "project.h"
+#include <libanjuta/anjuta-marshal.h>
#include <libanjuta/anjuta-debug.h>
+#include <libanjuta/anjuta-error.h>
#include <libanjuta/interfaces/ianjuta-project-backend.h>
#include "gbf-project-model.h"
#include "gbf-project-view.h"
-/* Public functions
+/* Signal
*---------------------------------------------------------------------------*/
-struct _ProjectManagerProject{
- AnjutaPlugin *plugin;
-
- IAnjutaProject *project;
- GbfProjectModel *model;
+enum
+{
+ UPDATED,
+ LAST_SIGNAL
};
+static unsigned int signals[LAST_SIGNAL] = { 0 };
+
/* Public functions
*---------------------------------------------------------------------------*/
gboolean
-pm_project_load (ProjectManagerProject *project, GFile *file, GError **error)
+anjuta_pm_project_load (AnjutaPmProject *project, GFile *file, GError **error)
{
AnjutaPluginManager *plugin_manager;
GList *desc;
IAnjutaProjectBackend *backend;
gint found = 0;
gboolean ok;
+ GError *err = NULL;
g_return_val_if_fail (file != NULL, FALSE);
@@ -120,11 +124,9 @@ pm_project_load (ProjectManagerProject *project, GFile *file, GError **error)
return FALSE;
}
- /* FIXME: use the error parameter to determine if the project
- * was loaded successfully */
- ok = ianjuta_project_load (project->project, file, error);
+ ianjuta_project_load (project->project, file, &err);
g_message ("load project %s %p ok %d", g_file_get_path (file), project->project, ok);
- if (!ok)
+ if (err != NULL)
{
g_warning ("unable to load project");
/* Unable to load project, destroy project object */
@@ -135,12 +137,14 @@ pm_project_load (ProjectManagerProject *project, GFile *file, GError **error)
{
g_object_set (G_OBJECT (project->model), "project", project, NULL);
}
-
- return ok;
+ g_signal_emit (G_OBJECT (project), signals[UPDATED], 0, err);
+ g_error_free (err);
+
+ return TRUE;
}
gboolean
-pm_project_unload (ProjectManagerProject *project, GError **error)
+anjuta_pm_project_unload (AnjutaPmProject *project, GError **error)
{
g_object_set (G_OBJECT (project->model), "project", NULL, NULL);
g_object_unref (project->project);
@@ -150,7 +154,7 @@ pm_project_unload (ProjectManagerProject *project, GError **error)
}
gboolean
-pm_project_refresh (ProjectManagerProject *project, GError **error)
+anjuta_pm_project_refresh (AnjutaPmProject *project, GError **error)
{
ianjuta_project_refresh (project->project, error);
@@ -158,7 +162,7 @@ pm_project_refresh (ProjectManagerProject *project, GError **error)
}
GtkWidget *
-pm_project_configure (ProjectManagerProject *project, AnjutaProjectNode *node)
+anjuta_pm_project_configure (AnjutaPmProject *project, AnjutaProjectNode *node)
{
GtkWidget *properties;
@@ -175,7 +179,7 @@ pm_project_configure (ProjectManagerProject *project, AnjutaProjectNode *node)
}
IAnjutaProjectCapabilities
-pm_project_get_capabilities (ProjectManagerProject *project)
+anjuta_pm_project_get_capabilities (AnjutaPmProject *project)
{
IAnjutaProjectCapabilities caps = IANJUTA_PROJECT_CAN_ADD_NONE;
@@ -186,7 +190,7 @@ pm_project_get_capabilities (ProjectManagerProject *project)
}
GList *
-pm_project_get_target_types (ProjectManagerProject *project)
+anjuta_pm_project_get_target_types (AnjutaPmProject *project)
{
g_return_val_if_fail (project->project != NULL, NULL);
@@ -194,7 +198,7 @@ pm_project_get_target_types (ProjectManagerProject *project)
}
AnjutaProjectNode *
-pm_project_get_root (ProjectManagerProject *project)
+anjuta_pm_project_get_root (AnjutaPmProject *project)
{
if (project->project == NULL) return NULL;
@@ -202,7 +206,7 @@ pm_project_get_root (ProjectManagerProject *project)
}
GList *
-pm_project_get_packages (ProjectManagerProject *project)
+anjuta_pm_project_get_packages (AnjutaPmProject *project)
{
if (project->project == NULL) return NULL;
@@ -210,7 +214,7 @@ pm_project_get_packages (ProjectManagerProject *project)
}
AnjutaProjectNode *
-pm_project_add_group (ProjectManagerProject *project, AnjutaProjectNode *group, const gchar *name, GError **error)
+anjuta_pm_project_add_group (AnjutaPmProject *project, AnjutaProjectNode *group, const gchar *name, GError **error)
{
g_return_val_if_fail (project->project != NULL, NULL);
@@ -218,7 +222,7 @@ pm_project_add_group (ProjectManagerProject *project, AnjutaProjectNode *group,
}
AnjutaProjectNode *
-pm_project_add_target (ProjectManagerProject *project, AnjutaProjectNode *group, const gchar *name, AnjutaProjectTargetType type, GError **error)
+anjuta_pm_project_add_target (AnjutaPmProject *project, AnjutaProjectNode *group, const gchar *name, AnjutaProjectTargetType type, GError **error)
{
g_return_val_if_fail (project->project != NULL, NULL);
@@ -226,7 +230,7 @@ pm_project_add_target (ProjectManagerProject *project, AnjutaProjectNode *group,
}
AnjutaProjectNode *
-pm_project_add_source (ProjectManagerProject *project, AnjutaProjectNode *target, GFile *file, GError **error)
+anjuta_pm_project_add_source (AnjutaPmProject *project, AnjutaProjectNode *target, GFile *file, GError **error)
{
AnjutaProjectNode *source;
@@ -238,7 +242,7 @@ pm_project_add_source (ProjectManagerProject *project, AnjutaProjectNode *target
}
gboolean
-pm_project_remove (ProjectManagerProject *project, AnjutaProjectNode *node, GError **error)
+anjuta_pm_project_remove (AnjutaPmProject *project, AnjutaProjectNode *node, GError **error)
{
ianjuta_project_remove_node (project->project, node, error);
@@ -246,7 +250,7 @@ pm_project_remove (ProjectManagerProject *project, AnjutaProjectNode *node, GErr
}
gboolean
-pm_project_remove_data (ProjectManagerProject *project, GbfTreeData *data, GError **error)
+anjuta_pm_project_remove_data (AnjutaPmProject *project, GbfTreeData *data, GError **error)
{
GtkTreeIter iter;
@@ -264,25 +268,25 @@ pm_project_remove_data (ProjectManagerProject *project, GbfTreeData *data, GErro
gboolean
-pm_project_is_open (ProjectManagerProject *project)
+anjuta_pm_project_is_open (AnjutaPmProject *project)
{
return project->project != NULL;
}
IAnjutaProject *
-pm_project_get_project (ProjectManagerProject *project)
+anjuta_pm_project_get_project (AnjutaPmProject *project)
{
return project->project;
}
GbfProjectModel *
-pm_project_get_model (ProjectManagerProject *project)
+anjuta_pm_project_get_model (AnjutaPmProject *project)
{
return project->model;
}
AnjutaProjectNode *
-pm_project_get_node (ProjectManagerProject *project, GbfTreeData *data)
+anjuta_pm_project_get_node (AnjutaPmProject *project, GbfTreeData *data)
{
AnjutaProjectNode *node = NULL;
@@ -292,7 +296,7 @@ pm_project_get_node (ProjectManagerProject *project, GbfTreeData *data)
AnjutaProjectNode *group = NULL;
AnjutaProjectNode *target = NULL;
- root = pm_project_get_root (project);
+ root = anjuta_pm_project_get_root (project);
if ((root != NULL) && (data->group != NULL))
{
group = anjuta_project_group_get_node_from_file (root, data->group);
@@ -314,26 +318,63 @@ pm_project_get_node (ProjectManagerProject *project, GbfTreeData *data)
return node;
}
+/* Implement GObject
+ *---------------------------------------------------------------------------*/
+
+G_DEFINE_TYPE (AnjutaPmProject, anjuta_pm_project, G_TYPE_OBJECT);
+
+static void
+anjuta_pm_project_init (AnjutaPmProject *project)
+{
+ project->model = gbf_project_model_new (NULL);
+ project->plugin = NULL;
+}
+
+static void
+anjuta_pm_project_finalize (GObject *object)
+{
+ AnjutaPmProject *project = ANJUTA_PM_PROJECT(object);
+
+ g_object_unref (G_OBJECT (project->model));
+
+ G_OBJECT_CLASS (anjuta_pm_project_parent_class)->finalize (object);
+}
+
+static void
+anjuta_pm_project_class_init (AnjutaPmProjectClass *klass)
+{
+ GObjectClass* object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = anjuta_pm_project_finalize;
+
+ signals[UPDATED] = g_signal_new ("updated",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (AnjutaPmProjectClass, updated),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOXED,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_ERROR);
+
+}
/* Constructor & Destructor
*---------------------------------------------------------------------------*/
-ProjectManagerProject*
-pm_project_new (AnjutaPlugin *plugin)
+AnjutaPmProject*
+anjuta_pm_project_new (AnjutaPlugin *plugin)
{
- ProjectManagerProject *project;
+ AnjutaPmProject *project;
- project = g_new0 (ProjectManagerProject, 1);
+ project = g_object_new (ANJUTA_TYPE_PM_PROJECT, NULL);
project->plugin = plugin;
- project->project = NULL;
- project->model = gbf_project_model_new (NULL);
return project;
}
void
-pm_project_free (ProjectManagerProject* project)
+anjuta_pm_project_free (AnjutaPmProject* project)
{
- g_object_unref (G_OBJECT (project->model));
- g_free (project);
+ g_object_unref (project);
}
diff --git a/plugins/project-manager/project.h b/plugins/project-manager/project.h
index 4126177..c49d4ed 100644
--- a/plugins/project-manager/project.h
+++ b/plugins/project-manager/project.h
@@ -33,34 +33,61 @@
G_BEGIN_DECLS
-//typedef struct _ProjectManagerProject ProjectManagerProject;
+#define ANJUTA_TYPE_PM_PROJECT (anjuta_pm_project_get_type ())
+#define ANJUTA_PM_PROJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ANJUTA_TYPE_PM_PROJECT, AnjutaPmProject))
+#define ANJUTA_PM_PROJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ANJUTA_TYPE_PM_PROJECT, AnjutaPmProjectClass))
+#define ANJUTA_IS_PM_PROJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ANJUTA_TYPE_PM_PROJECT))
+#define ANJUTA_IS_PM_PROJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ANJUTA_TYPE_PM_PROJECT))
+#define ANJUTA_PM_PROJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ANJUTA_TYPE_PM_PROJECT, AnjutaPmProjectClass))
-ProjectManagerProject* pm_project_new (AnjutaPlugin *plugin);
-void pm_project_free (ProjectManagerProject* project);
+typedef struct _AnjutaPmProjectClass AnjutaPmProjectClass;
+//typedef struct _AnjutaPmProject AnjutaPmProject;
-gboolean pm_project_load (ProjectManagerProject *project, GFile *file, GError **error);
-gboolean pm_project_unload (ProjectManagerProject *project, GError **error);
-gboolean pm_project_refresh (ProjectManagerProject *project, GError **error);
+struct _AnjutaPmProjectClass
+{
+ GObjectClass parent_class;
-GtkWidget *pm_project_configure (ProjectManagerProject *project, AnjutaProjectNode *node);
-IAnjutaProjectCapabilities pm_project_get_capabilities (ProjectManagerProject *project);
-GList *pm_project_get_target_types (ProjectManagerProject *project);
+ void (*updated) (GError *error);
+};
-GList *pm_project_get_packages (ProjectManagerProject *project);
+struct _AnjutaPmProject
+{
+ GObject parent_instance;
-AnjutaProjectNode *pm_project_add_group (ProjectManagerProject *project, AnjutaProjectNode *group, const gchar *name, GError **error);
-AnjutaProjectNode *pm_project_add_target (ProjectManagerProject *project, AnjutaProjectNode *group, const gchar *name, AnjutaProjectTargetType type, GError **error);
-AnjutaProjectNode *pm_project_add_source (ProjectManagerProject *project, AnjutaProjectNode *target, GFile *file, GError **error);
-AnjutaProjectNode *pm_project_get_root (ProjectManagerProject *project);
-gboolean pm_project_remove (ProjectManagerProject *project, AnjutaProjectNode *node, GError **error);
-gboolean pm_project_remove_data (ProjectManagerProject *project, GbfTreeData *data, GError **error);
+ AnjutaPlugin *plugin;
+
+ IAnjutaProject *project;
+ GbfProjectModel *model;
+};
-gboolean pm_project_is_open (ProjectManagerProject *project);
+GType anjuta_pm_project_get_type (void) G_GNUC_CONST;
-IAnjutaProject *pm_project_get_project (ProjectManagerProject *project);
-GbfProjectModel *pm_project_get_model (ProjectManagerProject *project);
+AnjutaPmProject* anjuta_pm_project_new (AnjutaPlugin *plugin);
+void anjuta_pm_project_free (AnjutaPmProject* project);
-AnjutaProjectNode *pm_project_get_node (ProjectManagerProject *project, GbfTreeData *data);
+gboolean anjuta_pm_project_load (AnjutaPmProject *project, GFile *file, GError **error);
+gboolean anjuta_pm_project_unload (AnjutaPmProject *project, GError **error);
+gboolean anjuta_pm_project_refresh (AnjutaPmProject *project, GError **error);
+
+GtkWidget *anjuta_pm_project_configure (AnjutaPmProject *project, AnjutaProjectNode *node);
+IAnjutaProjectCapabilities anjuta_pm_project_get_capabilities (AnjutaPmProject *project);
+GList *anjuta_pm_project_get_target_types (AnjutaPmProject *project);
+
+GList *anjuta_pm_project_get_packages (AnjutaPmProject *project);
+
+AnjutaProjectNode *anjuta_pm_project_add_group (AnjutaPmProject *project, AnjutaProjectNode *group, const gchar *name, GError **error);
+AnjutaProjectNode *anjuta_pm_project_add_target (AnjutaPmProject *project, AnjutaProjectNode *group, const gchar *name, AnjutaProjectTargetType type, GError **error);
+AnjutaProjectNode *anjuta_pm_project_add_source (AnjutaPmProject *project, AnjutaProjectNode *target, GFile *file, GError **error);
+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_is_open (AnjutaPmProject *project);
+
+IAnjutaProject *anjuta_pm_project_get_project (AnjutaPmProject *project);
+GbfProjectModel *anjuta_pm_project_get_model (AnjutaPmProject *project);
+
+AnjutaProjectNode *anjuta_pm_project_get_node (AnjutaPmProject *project, GbfTreeData *data);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]