Revision: 2057 http://geany.svn.sourceforge.net/geany/?rev=2057&view=rev Author: eht16 Date: 2007-11-18 10:24:23 -0800 (Sun, 18 Nov 2007)
Log Message: ----------- Apply patch from Bo Lorentsen to improve support for project session files (thank you).
Modified Paths: -------------- trunk/ChangeLog trunk/src/callbacks.c trunk/src/keyfile.c trunk/src/keyfile.h trunk/src/main.c trunk/src/project.c trunk/src/project.h
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-11-18 17:40:08 UTC (rev 2056) +++ trunk/ChangeLog 2007-11-18 18:24:23 UTC (rev 2057) @@ -9,6 +9,10 @@ Disable use of non-ASCII characters for PHP parser, it caused problems when using with locales other than "C". Add missing line break characters in error messages in lregex.c. + * src/callbacks.c, src/keyfile.c, src/keyfile.h, src/main.c, + src/project.c, src/project.h: + Apply patch from Bo Lorentsen to improve support for project session + files (thank you).
2007-11-17 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: trunk/src/callbacks.c =================================================================== --- trunk/src/callbacks.c 2007-11-18 17:40:08 UTC (rev 2056) +++ trunk/src/callbacks.c 2007-11-18 18:24:23 UTC (rev 2057) @@ -1871,7 +1871,7 @@ on_project_close1_activate (GtkMenuItem *menuitem, gpointer user_data) { - project_close(); + project_close(TRUE); }
Modified: trunk/src/keyfile.c =================================================================== --- trunk/src/keyfile.c 2007-11-18 17:40:08 UTC (rev 2056) +++ trunk/src/keyfile.c 2007-11-18 18:24:23 UTC (rev 2057) @@ -698,6 +698,46 @@ }
+/* + * Save current session in default configuration file + */ +void configuration_save_default_session() +{ + gchar *configfile = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "geany.conf", NULL); + gchar *data; + GKeyFile *config = g_key_file_new(); + + g_key_file_load_from_file(config, configfile, G_KEY_FILE_NONE, NULL); + + configuration_save_session_files(config); + + // write the file + data = g_key_file_to_data(config, NULL, NULL); + utils_write_file(configfile, data); + g_free(data); + + g_key_file_free(config); + g_free(configfile); +} + + +/* + * Only reload the session part of the default configuration + */ +void configuration_reload_default_session() +{ + gchar *configfile = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "geany.conf", NULL); + GKeyFile *config = g_key_file_new(); + + g_key_file_load_from_file(config, configfile, G_KEY_FILE_NONE, NULL); + + configuration_load_session_files(config); + + g_key_file_free(config); + g_free(configfile); +} + + gboolean configuration_load() { gchar *configfile = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "geany.conf", NULL);
Modified: trunk/src/keyfile.h =================================================================== --- trunk/src/keyfile.h 2007-11-18 17:40:08 UTC (rev 2056) +++ trunk/src/keyfile.h 2007-11-18 18:24:23 UTC (rev 2057) @@ -31,6 +31,10 @@
gboolean configuration_open_files();
+void configuration_reload_default_session(); + +void configuration_save_default_session(); + void configuration_load_session_files(GKeyFile *config);
void configuration_save_session_files(GKeyFile *config);
Modified: trunk/src/main.c =================================================================== --- trunk/src/main.c 2007-11-18 17:40:08 UTC (rev 2056) +++ trunk/src/main.c 2007-11-18 18:24:23 UTC (rev 2057) @@ -799,7 +799,7 @@ plugins_free(); #endif if (app->project != NULL) - project_close(); + project_close(FALSE);
navqueue_free(); keybindings_free();
Modified: trunk/src/project.c =================================================================== --- trunk/src/project.c 2007-11-18 17:40:08 UTC (rev 2056) +++ trunk/src/project.c 2007-11-18 18:24:23 UTC (rev 2057) @@ -42,6 +42,7 @@ # include "win32.h" #endif #include "build.h" +#include "document.h"
ProjectPrefs project_prefs = {NULL}; @@ -299,9 +300,10 @@ }
-void project_close() +// 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)); + 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); @@ -315,16 +317,21 @@ g_free(app->project); app->project = NULL;
-/// TODO really close all tabs? maybe it should configurable -/* - for(i = 0; i < max; i++) + // close all existing tabs first + for (i = 0; i < max; i++) { if (! document_remove(0)) break; } + + // after closing all tabs let's open the tabs found in the default config + if (open_default == TRUE) + { + configuration_reload_default_session(); + configuration_open_files(); + } + tm_workspace_update(TM_WORK_OBJECT(app->tm_workspace), TRUE, TRUE, FALSE); -*/ - update_ui(); }
@@ -524,7 +531,7 @@ _("Do you want to close it before proceeding?"), _("The '%s' project is already open. "), app->project->name)) { - project_close(); + project_close(FALSE); return TRUE; } else @@ -844,7 +851,7 @@ g_return_val_if_fail(app->project == NULL && filename != NULL, FALSE);
config = g_key_file_new(); - if (! g_key_file_load_from_file(config, filename, G_KEY_FILE_KEEP_COMMENTS, NULL)) + if (! g_key_file_load_from_file(config, filename, G_KEY_FILE_NONE, NULL)) { g_key_file_free(config); return FALSE; @@ -859,6 +866,9 @@ p->run_cmd = utils_get_setting_string(config, "project", "run_cmd", ""); p->file_patterns = g_key_file_get_string_list(config, "project", "file_patterns", NULL, NULL);
+ // save current (non-project) session (it could has been changed since program startup) + configuration_save_default_session(); + // fetch session files too configuration_load_session_files(config);
@@ -885,7 +895,7 @@ config = g_key_file_new(); // try to load an existing config to keep manually added comments filename = utils_get_locale_from_utf8(p->file_name); - g_key_file_load_from_file(config, filename, G_KEY_FILE_KEEP_COMMENTS, NULL); + g_key_file_load_from_file(config, filename, G_KEY_FILE_NONE, NULL);
g_key_file_set_string(config, "project", "name", p->name); g_key_file_set_string(config, "project", "base_path", p->base_path);
Modified: trunk/src/project.h =================================================================== --- trunk/src/project.h 2007-11-18 17:40:08 UTC (rev 2056) +++ trunk/src/project.h 2007-11-18 18:24:23 UTC (rev 2057) @@ -55,7 +55,7 @@
void project_save();
-void project_close(); +void project_close(gboolean open_default);
void project_properties();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.