[anjuta/newproject] Restore expanded shortcuts with the new interface
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta/newproject] Restore expanded shortcuts with the new interface
- Date: Mon, 5 Apr 2010 09:25:59 +0000 (UTC)
commit ea0de6eb4595bfdbc6ceb7c01d4a35da65dda5ac
Author: Sébastien Granjoux <seb sfo free fr>
Date: Sun Apr 4 17:27:43 2010 +0200
Restore expanded shortcuts with the new interface
libanjuta/anjuta-project.h | 8 ++++-
plugins/project-manager/gbf-project-view.c | 4 ++-
plugins/project-manager/plugin.c | 42 +++++++++++++++++++++------
plugins/project-manager/plugin.h | 3 ++
4 files changed, 45 insertions(+), 12 deletions(-)
---
diff --git a/libanjuta/anjuta-project.h b/libanjuta/anjuta-project.h
index 3bc83dc..68e6004 100644
--- a/libanjuta/anjuta-project.h
+++ b/libanjuta/anjuta-project.h
@@ -42,7 +42,13 @@ typedef enum
ANJUTA_PROJECT_PACKAGE = 6 << 16,
ANJUTA_PROJECT_VARIABLE = 7 << 16
} AnjutaProjectNodeType;
-
+
+typedef enum
+{
+ ANJUTA_PROJECT_LOADING = 1 << 0,
+ ANJUTA_PROJECT_SAVED = 1 << 1
+} AnjutaProjectNodeState;
+
typedef enum
{
ANJUTA_TARGET_UNKNOWN,
diff --git a/plugins/project-manager/gbf-project-view.c b/plugins/project-manager/gbf-project-view.c
index b9f78e3..55b9621 100644
--- a/plugins/project-manager/gbf-project-view.c
+++ b/plugins/project-manager/gbf-project-view.c
@@ -576,7 +576,7 @@ gbf_project_view_set_shortcut_list (GbfProjectView *view, GList *shortcuts)
GbfTreeData *data;
GtkTreeIter shortcut;
gboolean expand = FALSE;
- const gchar *path = (const gchar *)node->data;
+ gchar *path = (gchar *)node->data;
if (strncmp (path, "E ", 2) == 0)
{
@@ -611,6 +611,8 @@ gbf_project_view_set_shortcut_list (GbfProjectView *view, GList *shortcuts)
gtk_tree_view_expand_row (GTK_TREE_VIEW (view), path, FALSE);
gtk_tree_path_free (path);
}
+ /* Mark the shortcut as used */
+ *path = 'U';
}
gbf_tree_data_free (data);
diff --git a/plugins/project-manager/plugin.c b/plugins/project-manager/plugin.c
index acddae9..af9eae1 100644
--- a/plugins/project-manager/plugin.c
+++ b/plugins/project-manager/plugin.c
@@ -191,18 +191,12 @@ on_session_save (AnjutaShell *shell, AnjutaSessionPhase phase,
static void
on_session_load (AnjutaShell *shell, AnjutaSessionPhase phase, AnjutaSession *session, ProjectManagerPlugin *plugin)
{
- GList *list;
-
if (phase != ANJUTA_SESSION_PHASE_NORMAL)
return;
- list = anjuta_session_get_string_list (session, "Project Manager", "Shortcut");
- if (list != NULL)
- {
- gbf_project_view_set_shortcut_list (GBF_PROJECT_VIEW (plugin->view), list);
- g_list_foreach (list, (GFunc)g_free, NULL);
- g_list_free (list);
- }
+ g_list_foreach (plugin->shortcuts, (GFunc)g_free, NULL);
+ g_list_free (plugin->shortcuts);
+ plugin->shortcuts = anjuta_session_get_string_list (session, "Project Manager", "Shortcut");
}
static void
@@ -1395,6 +1389,29 @@ on_project_updated (AnjutaPmProject *project, GError *error, ProjectManagerPlugi
}
else
{
+ /* Restore existing shortcut */
+ if (plugin->shortcuts != NULL)
+ {
+ GList *item;
+
+ gbf_project_view_set_shortcut_list (GBF_PROJECT_VIEW (plugin->view), plugin->shortcuts);
+ /* Remove used shortcuts */
+ for (item = g_list_first (plugin->shortcuts); item != NULL;)
+ {
+ if (*((char *)item->data) == 'U')
+ {
+ GList *next = g_list_next (item);
+
+ g_free (item->data);
+ plugin->shortcuts = g_list_remove_link (plugin->shortcuts, item);
+ item = next;
+ }
+ else
+ {
+ item = g_list_next (item);
+ }
+ }
+ }
gchar *basename = g_path_get_basename (dirname);
anjuta_status_progress_tick (status, NULL, _("Update project viewâ?¦"));
@@ -1402,7 +1419,6 @@ on_project_updated (AnjutaPmProject *project, GError *error, ProjectManagerPlugi
anjuta_shell_present_widget (ANJUTA_PLUGIN (plugin)->shell,
plugin->scrolledwindow,
NULL);
-
anjuta_status_set_default (status, _("Project"), basename);
g_free (basename);
}
@@ -1786,6 +1802,11 @@ project_manager_plugin_deactivate_plugin (AnjutaPlugin *plugin)
anjuta_ui_remove_action_group (pm_plugin->ui,
pm_plugin->popup_action_group);
+ /* Remove shortcuts list */
+ g_list_foreach (pm_plugin->shortcuts, (GFunc)g_free, NULL);
+ g_list_free (pm_plugin->shortcuts);
+ pm_plugin->shortcuts = NULL;
+
/* Destroy project */
anjuta_pm_project_free (pm_plugin->project);
@@ -1822,6 +1843,7 @@ project_manager_plugin_instance_init (GObject *obj)
plugin->current_editor_uri = NULL;
plugin->session_by_me = FALSE;
plugin->close_project_idle = -1;
+ plugin->shortcuts = NULL;
}
static void
diff --git a/plugins/project-manager/plugin.h b/plugins/project-manager/plugin.h
index 3e224b0..92bf4c8 100644
--- a/plugins/project-manager/plugin.h
+++ b/plugins/project-manager/plugin.h
@@ -60,6 +60,9 @@ struct _ProjectManagerPlugin{
gchar *current_editor_uri;
gchar *project_root_uri;
gchar *project_uri;
+
+ /* Target shortcuts */
+ GList *shortcuts;
/* Update state recording */
GList *pre_update_sources;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]