[anjuta] document-manager: Close all documents when closing a project
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] document-manager: Close all documents when closing a project
- Date: Sat, 31 Aug 2013 15:24:58 +0000 (UTC)
commit 4220da2c4eb61ab99ae62b0f7268eeb921605caf
Author: Sébastien Granjoux <seb sfo free fr>
Date: Sat Aug 31 16:54:17 2013 +0200
document-manager: Close all documents when closing a project
And ask if the documents need to be saved before closing them.
One reason to do this is to close all glade documents to avoid a warning when
the glade plugin is removed.
plugins/document-manager/plugin.c | 4 +++-
plugins/glade/plugin.c | 6 +++---
plugins/project-manager/plugin.c | 21 +++++++++++++++++++++
plugins/symbol-db/symbol-db-engine-core.c | 13 ++++++++-----
4 files changed, 35 insertions(+), 9 deletions(-)
---
diff --git a/plugins/document-manager/plugin.c b/plugins/document-manager/plugin.c
index ae9dae8..9ca4839 100644
--- a/plugins/document-manager/plugin.c
+++ b/plugins/document-manager/plugin.c
@@ -1409,7 +1409,7 @@ on_session_save (AnjutaShell *shell, AnjutaSessionPhase phase,
if (phase != ANJUTA_SESSION_PHASE_NORMAL)
return;
-
+
files = anjuta_session_get_string_list (session, "File Loader", "Files"); /* probably NULL */
/* buffers list is ordered last-opened to first-opened */
docwids = anjuta_docman_get_all_doc_widgets (ANJUTA_DOCMAN (plugin->docman));
@@ -1434,6 +1434,8 @@ on_session_save (AnjutaShell *shell, AnjutaSessionPhase phase,
files = g_list_prepend (files,
anjuta_session_get_relative_uri_from_file (session, file, line_number));
g_free (line_number);
}
+ /* Close document */
+ anjuta_docman_remove_document (ANJUTA_DOCMAN (plugin->docman),
IANJUTA_DOCUMENT (node->data));
}
}
g_list_free (docwids);
diff --git a/plugins/glade/plugin.c b/plugins/glade/plugin.c
index 250074b..4025494 100644
--- a/plugins/glade/plugin.c
+++ b/plugins/glade/plugin.c
@@ -1,3 +1,5 @@
+
+
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/* plugin.c
@@ -366,9 +368,6 @@ on_session_save (AnjutaShell *shell, AnjutaSessionPhase phase,
AnjutaSession *session, GladePlugin *plugin)
{
GList *files, *docwids, *node;
- /* GtkTreeModel *model;
- GtkTreeIter iter;
- */
IAnjutaDocumentManager *docman;
if (phase != ANJUTA_SESSION_PHASE_NORMAL)
@@ -393,6 +392,7 @@ on_session_save (AnjutaShell *shell, AnjutaSessionPhase phase,
files = g_list_prepend (files,
anjuta_session_get_relative_uri_from_file (session, file, NULL));
g_object_unref (file);
/* uri is not freed here */
+ ianjuta_document_manager_remove_document (docman, IANJUTA_DOCUMENT
(node->data), FALSE, NULL);
}
}
}
diff --git a/plugins/project-manager/plugin.c b/plugins/project-manager/plugin.c
index 8729f0d..962cf01 100644
--- a/plugins/project-manager/plugin.c
+++ b/plugins/project-manager/plugin.c
@@ -1502,10 +1502,31 @@ on_profile_descoped (AnjutaProfile *profile, ProjectManagerPlugin *plugin)
static void
project_manager_plugin_close (ProjectManagerPlugin *plugin)
{
+ AnjutaSavePrompt *save_prompt;
AnjutaProfileManager *profile_manager;
AnjutaProfile *profile;
GError *error = NULL;
+ /* Check for unsaved data */
+ save_prompt = anjuta_save_prompt_new (GTK_WINDOW (ANJUTA_PLUGIN (plugin)->shell));
+ anjuta_shell_save_prompt (ANJUTA_PLUGIN (plugin)->shell, save_prompt, NULL);
+ if (anjuta_save_prompt_get_items_count (save_prompt) > 0)
+ {
+ switch (gtk_dialog_run (GTK_DIALOG (save_prompt)))
+ {
+ case GTK_RESPONSE_DELETE_EVENT:
+ case ANJUTA_SAVE_PROMPT_RESPONSE_CANCEL:
+ gtk_widget_destroy (GTK_WIDGET (save_prompt));
+ /* Do not exit now */
+ return;
+ case ANJUTA_SAVE_PROMPT_RESPONSE_DISCARD:
+ case ANJUTA_SAVE_PROMPT_RESPONSE_SAVE_CLOSE:
+ /* exit now */
+ break;
+ }
+ }
+ gtk_widget_destroy (GTK_WIDGET (save_prompt));
+
/* Remove project profile */
profile_manager =
anjuta_shell_get_profile_manager (ANJUTA_PLUGIN (plugin)->shell, NULL);
diff --git a/plugins/symbol-db/symbol-db-engine-core.c b/plugins/symbol-db/symbol-db-engine-core.c
index e551c5f..1f56908 100644
--- a/plugins/symbol-db/symbol-db-engine-core.c
+++ b/plugins/symbol-db/symbol-db-engine-core.c
@@ -140,6 +140,7 @@ enum {
*/
typedef struct _UpdateFileSymbolsData {
gchar *project;
+ gchar *project_directory;
gboolean update_prj_analyse_time;
GPtrArray * files_path;
@@ -2661,7 +2662,7 @@ symbol_db_engine_close_db (SymbolDBEngine *dbe)
g_free (priv->db_directory);
priv->db_directory = NULL;
-
+
g_free (priv->project_directory);
priv->project_directory = NULL;
@@ -5207,20 +5208,20 @@ on_scan_update_files_symbols_end (SymbolDBEngine * dbe,
{
gchar *node = (gchar *) g_ptr_array_index (files_to_scan, i);
- if (strstr (node, priv->project_directory) == NULL)
+ if (strstr (node, update_data->project_directory) == NULL)
{
g_warning ("node %s is shorter than "
"prj_directory %s",
- node, priv->project_directory);
+ node, update_data->project_directory);
continue;
}
/* clean the db from old un-updated with the last update step () */
if (sdb_engine_update_file (dbe, node +
- strlen (priv->project_directory)) ==
FALSE)
+ strlen
(update_data->project_directory)) == FALSE)
{
g_warning ("Error processing file %s", node +
- strlen (priv->project_directory));
+ strlen (update_data->project_directory));
return;
}
}
@@ -5272,6 +5273,7 @@ on_scan_update_files_symbols_end (SymbolDBEngine * dbe,
g_ptr_array_unref (files_to_scan);
g_free (update_data->project);
+ g_free (update_data->project_directory);
g_free (update_data);
}
@@ -5340,6 +5342,7 @@ symbol_db_engine_update_files_symbols (SymbolDBEngine * dbe, const gchar * proje
update_data->update_prj_analyse_time = update_prj_analyse_time;
update_data->files_path = ready_files;
update_data->project = g_strdup (project);
+ update_data->project_directory = g_strdup (priv->project_directory);
/* data will be freed when callback will be called. The signal will be
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]