From b858a3e3e12bd4adbc397bc2c3be88d8fc4bac44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrico=20Tr=C3=B6ger?= Date: Thu, 31 Jan 2008 14:35:03 +0000 Subject: [PATCH] Open a new, empty file when closing a project and no session files are available or when opening a project without stored session files. Close all open files when opening projects. git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@2200 ea778897-0a13-0410-b9d1-a72fbfd435f5 --- ChangeLog | 8 ++++++++ src/project.c | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/ChangeLog b/ChangeLog index 0e567b44f..3371f7afb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-01-31 Enrico Tröger + + * src/project.c: + Open a new, empty file when closing a project and no session files + are available or when opening a project without stored session files. + Close all open files when opening projects. + + 2008-01-29 Nick Treleaven * src/search.c: diff --git a/src/project.c b/src/project.c index 1d1c1e09e..590f5bbf3 100644 --- a/src/project.c +++ b/src/project.c @@ -44,6 +44,7 @@ #include "build.h" #include "document.h" #include "geanyobject.h" +#include "callbacks.h" ProjectPrefs project_prefs = { NULL, 0 }; @@ -213,7 +214,13 @@ static void run_open_dialog(GtkDialog *dialog) } g_free(filename); if (project_prefs.project_session) + { configuration_open_files(); + // open a new file if no other file was opened + /// TODO refactor the following into a function to be used here and in main() + if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook)) == 0) + document_new_file(NULL, NULL, NULL); + } } } #endif @@ -241,7 +248,12 @@ void project_open() SHOW_ERR1(_("Project file \"%s\" could not be loaded."), file); } if (project_prefs.project_session) + { configuration_open_files(); + // open a new file if no other file was opened + if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook)) == 0) + document_new_file(NULL, NULL, NULL); + } g_free(file); } #else @@ -328,6 +340,9 @@ void project_close(gboolean open_default) { configuration_reload_default_session(); configuration_open_files(); + // open a new file if no other file was opened + if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook)) == 0) + document_new_file(NULL, NULL, NULL); } } @@ -893,6 +908,10 @@ 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); // read session files so they can be opened with configuration_open_files() configuration_load_session_files(config); }