Add document_close_all() and use it in project.c.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@2521 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Nick Treleaven 2008-04-23 17:07:52 +00:00
parent af67ff3cd5
commit dc398a3b59
4 changed files with 16 additions and 15 deletions

View File

@ -8,6 +8,8 @@
geany.glade:
Make disk check timeout configurable in the prefs dialog Files tab.
Make a value of zero disable disk checks.
* src/project.c, src/document.c, src/document.h:
Add document_close_all() and use it in project.c.
2008-04-22 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>

View File

@ -516,6 +516,14 @@ static gint document_create(const gchar *utf8_filename)
}
void document_close_all()
{
/* the code is in callbacks.c because when quitting, checking for changes
* has to be done before saving the session */
on_close_all1_activate(NULL, NULL);
}
/**
* Remove the given notebook tab at @a page_num and clear all related information
* in the document list.

View File

@ -148,11 +148,14 @@ void document_finalize(void);
void document_set_text_changed(gint idx);
void document_apply_update_prefs(gint idx);
void document_close_all();
gboolean document_remove(guint page_num);
gint document_new_file_if_non_open();
gint document_new_file(const gchar *filename, filetype *ft, const gchar *text);

View File

@ -44,7 +44,6 @@
#include "build.h"
#include "document.h"
#include "geanyobject.h"
#include "callbacks.h"
ProjectPrefs project_prefs = { NULL, 0 };
@ -306,7 +305,6 @@ static void update_ui(void)
/* open_default will make function reload default session files on close */
void project_close(gboolean open_default)
{
gint i, max = gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook));
g_return_if_fail(app->project != NULL);
ui_set_statusbar(TRUE, _("Project \"%s\" closed."), app->project->name);
@ -326,13 +324,7 @@ void project_close(gboolean open_default)
if (project_prefs.project_session)
{
/* close all existing tabs first */
main_status.closing_all = TRUE;
for (i = 0; i < max; i++)
{
if (! document_remove(0))
break;
}
main_status.closing_all = FALSE;
document_close_all(NULL, NULL);
/* after closing all tabs let's open the tabs found in the default config */
if (open_default == TRUE && cl_options.load_session)
@ -348,8 +340,6 @@ void project_close(gboolean open_default)
{
g_signal_emit_by_name(geany_object, "project-close");
}
tm_workspace_update(TM_WORK_OBJECT(app->tm_workspace), TRUE, TRUE, FALSE);
update_ui();
}
@ -915,9 +905,7 @@ static gboolean load_config(const gchar *filename)
/* save current (non-project) session (it could has been changed since program startup) */
configuration_save_default_session();
/* now close all open files */
/** TODO make this a general, non-callback function, use it also in project_close()
* and remove include of callbacks.h */
on_close_all1_activate(NULL, NULL);
document_close_all(NULL, NULL);
/* read session files so they can be opened with configuration_open_files() */
configuration_load_session_files(config);
}