[anjuta] project-manager: Restore shortcuts for all primary targets by default
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] project-manager: Restore shortcuts for all primary targets by default
- Date: Sat, 18 Dec 2010 18:36:40 +0000 (UTC)
commit d539c469b3afb2665750b658243e566aab489c9a
Author: Sébastien Granjoux <seb sfo free fr>
Date: Sat Dec 18 19:25:20 2010 +0100
project-manager: Restore shortcuts for all primary targets by default
plugins/project-manager/project-model.c | 31 ++++++++++++++++++-------------
plugins/project-manager/project-model.h | 1 +
plugins/project-manager/project-view.c | 22 ++++++++--------------
plugins/project-manager/project-view.h | 2 --
4 files changed, 27 insertions(+), 29 deletions(-)
---
diff --git a/plugins/project-manager/project-model.c b/plugins/project-manager/project-model.c
index 8760369..54f06ce 100644
--- a/plugins/project-manager/project-model.c
+++ b/plugins/project-manager/project-model.c
@@ -44,6 +44,7 @@ struct _GbfProjectModelPrivate {
GtkTreeRowReference *root_group;
GList *shortcuts;
+ gboolean default_shortcut; /* Add shortcut for each primary node */
};
enum {
@@ -196,6 +197,7 @@ gbf_project_model_instance_init (GbfProjectModel *model)
types);
model->priv = g_new0 (GbfProjectModelPrivate, 1);
+ model->priv->default_shortcut = TRUE;
/* sorting function */
gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (model),
@@ -438,7 +440,7 @@ default_sort_func (GtkTreeModel *model,
}
-void
+void
gbf_project_model_add_source (GbfProjectModel *model,
AnjutaProjectNode *source,
GtkTreeIter *parent)
@@ -605,7 +607,7 @@ gbf_project_model_move_target_shortcut (GbfProjectModel *model,
}
-void
+void
gbf_project_model_add_package (GbfProjectModel *model,
AnjutaProjectNode *package,
GtkTreeIter *parent)
@@ -630,7 +632,7 @@ gbf_project_model_add_package (GbfProjectModel *model,
}
}
-void
+void
gbf_project_model_add_module (GbfProjectModel *model,
AnjutaProjectNode *module,
GtkTreeIter *parent)
@@ -655,7 +657,7 @@ gbf_project_model_add_module (GbfProjectModel *model,
}
}
-void
+void
gbf_project_model_add_target (GbfProjectModel *model,
AnjutaProjectNode *target,
GtkTreeIter *parent)
@@ -679,18 +681,14 @@ gbf_project_model_add_target (GbfProjectModel *model,
gbf_project_model_add_source (model, l, &iter);
}
- /* add a shortcut to the target if the target's type is a primary */
- /* FIXME: this shouldn't be here. We would rather provide a
- * set of public functions to add/remove shortcuts to save
- * this information in the project metadata (when that's
- * implemented) */
- /*if (anjuta_project_node_get_full_type (target) & ANJUTA_PROJECT_PRIMARY)
+ /* Add shortcut if needed */
+ if ((data != NULL) && model->priv->default_shortcut && (anjuta_project_node_get_full_type (target) & ANJUTA_PROJECT_PRIMARY))
{
- add_target_shortcut (model, NULL, data, NULL);
- }*/
+ gbf_project_model_add_target_shortcut (model, NULL, data, NULL, NULL);
+ }
}
-void
+void
gbf_project_model_add_target_group (GbfProjectModel *model,
AnjutaProjectNode *group,
GtkTreeIter *parent)
@@ -1012,3 +1010,10 @@ gbf_project_model_add_shortcut (GbfProjectModel *model,
gbf_project_model_add_target_shortcut (model, iter, target, path, NULL);
gtk_tree_path_free (path);
}
+
+void
+gbf_project_model_set_default_shortcut (GbfProjectModel *model,
+ gboolean enable)
+{
+ model->priv->default_shortcut = enable;
+}
diff --git a/plugins/project-manager/project-model.h b/plugins/project-manager/project-model.h
index d11a169..4949a03 100644
--- a/plugins/project-manager/project-model.h
+++ b/plugins/project-manager/project-model.h
@@ -116,6 +116,7 @@ void gbf_project_model_move_target_shortcut (GbfProjectModel *mode
GbfTreeData *shortcut,
GtkTreePath *before_path);
GtkTreeRowReference * gbf_project_model_get_root (GbfProjectModel *model);
+void gbf_project_model_set_default_shortcut (GbfProjectModel *model, gboolean enable);
diff --git a/plugins/project-manager/project-view.c b/plugins/project-manager/project-view.c
index 770a6d9..9f5ae9a 100644
--- a/plugins/project-manager/project-view.c
+++ b/plugins/project-manager/project-view.c
@@ -337,23 +337,11 @@ row_activated (GtkTreeView *tree_view,
}
static void
-free_expanded_node (GNode *node, gpointer data)
-{
- g_free (node->data);
-}
-
-static void
dispose (GObject *object)
{
GbfProjectView *view;
view = GBF_PROJECT_VIEW (object);
- if (view->expanded != NULL)
- {
- g_node_children_foreach (view->expanded, G_TRAVERSE_ALL, free_expanded_node, NULL);
- g_node_destroy (view->expanded);
- view->expanded = NULL;
- }
if (view->filter)
{
@@ -673,8 +661,6 @@ gbf_project_view_init (GbfProjectView *tree)
gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
- tree->expanded = NULL;
-
/* Create model */
tree->model = gbf_project_model_new (NULL);
tree->filter = GTK_TREE_MODEL_FILTER (pm_project_model_filter_new (GTK_TREE_MODEL (tree->model), NULL));
@@ -1146,6 +1132,8 @@ gbf_project_view_set_shortcut_list (GbfProjectView *view, GList *shortcuts)
{
GList *item;
+ gbf_project_model_set_default_shortcut (view->model, shortcuts == NULL);
+
for (item = g_list_first (shortcuts); item != NULL; item = g_list_next (item))
{
gchar *name = (gchar *)item->data;
@@ -1323,6 +1311,12 @@ on_node_loaded (AnjutaPmProject *sender, AnjutaProjectNode *node, gboolean compl
g_signal_emit (G_OBJECT (view), signals[NODE_LOADED], 0, &iter, complete, NULL);
}
+
+ if (complete)
+ {
+ // Add shortcut for all new primary targets
+ gbf_project_model_set_default_shortcut (view->model, TRUE);
+ }
}
diff --git a/plugins/project-manager/project-view.h b/plugins/project-manager/project-view.h
index 29c0a07..b17af22 100644
--- a/plugins/project-manager/project-view.h
+++ b/plugins/project-manager/project-view.h
@@ -44,8 +44,6 @@ struct _GbfProjectView {
GbfProjectModel *model;
GtkTreeModelFilter *filter;
-
- GNode *expanded;
};
struct _GbfProjectViewClass {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]