SF.net SVN: geany: [2043] trunk
eht16 at users.sourceforge.net
eht16 at xxxxx
Sun Nov 11 19:06:41 UTC 2007
Revision: 2043
http://geany.svn.sourceforge.net/geany/?rev=2043&view=rev
Author: eht16
Date: 2007-11-11 11:06:41 -0800 (Sun, 11 Nov 2007)
Log Message:
-----------
Apply patch from Bo Lorentsen to add support for project session files (thank you).
Modified Paths:
--------------
trunk/ChangeLog
trunk/THANKS
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-11 10:19:50 UTC (rev 2042)
+++ trunk/ChangeLog 2007-11-11 19:06:41 UTC (rev 2043)
@@ -9,8 +9,10 @@
Enable close tab on middle-clicking a notebook tab label.
Enable toggle additional widgets on double-clicking notebook tab
label.
+ * THANKS, src/project.c, src/project.h, src/keyfile.c, src/keyfile.h,
+ src/main.c: Apply patch from Bo Lorentsen to add support for project
+ session files (thank you).
-
2007-11-08 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* src/prefs.c:
Modified: trunk/THANKS
===================================================================
--- trunk/THANKS 2007-11-11 10:19:50 UTC (rev 2042)
+++ trunk/THANKS 2007-11-11 19:06:41 UTC (rev 2043)
@@ -38,6 +38,7 @@
blackdog <blackdog(at)ipowerhouse(dot)com> - Haxe filetype patch
Sebastian Kraft <kraft(dot)sebastian(at)googlemail(dot)com> - new Geany icon
Catalin Marinas <catalin(dot)marinas(at)gmail(dot)com> - newline strips trailing spaces patch
+Bo Lorentsen <bl(at)lue(dot)dk> - project session patch
Translators:
------------
Modified: trunk/src/keyfile.c
===================================================================
--- trunk/src/keyfile.c 2007-11-11 10:19:50 UTC (rev 2042)
+++ trunk/src/keyfile.c 2007-11-11 19:06:41 UTC (rev 2043)
@@ -87,7 +87,7 @@
}
-static void save_session_files(GKeyFile *config)
+void configuration_save_session_files(GKeyFile *config)
{
gint idx, npage;
gchar *tmp;
@@ -350,7 +350,7 @@
save_ui_prefs(config);
project_save_prefs(config); // save project filename, etc.
save_recent_files(config);
- save_session_files(config);
+ configuration_save_session_files(config);
// write the file
data = g_key_file_to_data(config, NULL, NULL);
@@ -361,8 +361,11 @@
g_free(configfile);
}
-
-static void load_file_lists(GKeyFile *config)
+/*
+ * Load session list from the given keyfile, and store it in the global
+ * session_files variable for later file loading
+ * */
+void configuration_load_session_files(GKeyFile *config)
{
gchar **recent_files;
guint i;
@@ -385,6 +388,10 @@
}
g_strfreev(recent_files);
+ // the project may load another list than the main setting
+ if (session_files != NULL)
+ g_ptr_array_free(session_files, TRUE);
+
session_files = g_ptr_array_new();
have_session_files = TRUE;
i = 0;
@@ -681,7 +688,7 @@
load_dialog_prefs(config);
load_ui_prefs(config);
project_load_prefs(config);
- load_file_lists(config);
+ configuration_load_session_files(config);
g_key_file_free(config);
g_free(configfile);
@@ -761,6 +768,7 @@
document_colourise_new();
g_ptr_array_free(session_files, TRUE);
+ session_files = NULL;
if (failure)
ui_set_statusbar(TRUE, _("Failed to load one or more session files."));
Modified: trunk/src/keyfile.h
===================================================================
--- trunk/src/keyfile.h 2007-11-11 10:19:50 UTC (rev 2042)
+++ trunk/src/keyfile.h 2007-11-11 19:06:41 UTC (rev 2043)
@@ -31,6 +31,10 @@
gboolean configuration_open_files();
+void configuration_load_session_files(GKeyFile *config);
+
+void configuration_save_session_files(GKeyFile *config);
+
void configuration_read_filetype_extensions();
void configuration_read_autocompletions();
Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c 2007-11-11 10:19:50 UTC (rev 2042)
+++ trunk/src/main.c 2007-11-11 19:06:41 UTC (rev 2043)
@@ -733,7 +733,7 @@
{
load_project_file();
- // load session files
+ // load session files into tabs, as they are found in the session_files variable
if (! configuration_open_files())
{
ui_update_popup_copy_items(-1);
@@ -790,6 +790,9 @@
if (want_plugins)
plugins_free();
#endif
+ if (app->project != NULL)
+ project_close();
+
navqueue_free();
keybindings_free();
filetypes_save_commands();
@@ -802,7 +805,6 @@
document_finalize();
symbols_finalize();
editor_finalize();
- if (app->project != NULL) project_close();
tm_workspace_free(TM_WORK_OBJECT(app->tm_workspace));
g_free(app->configdir);
Modified: trunk/src/project.c
===================================================================
--- trunk/src/project.c 2007-11-11 10:19:50 UTC (rev 2042)
+++ trunk/src/project.c 2007-11-11 19:06:41 UTC (rev 2043)
@@ -37,6 +37,7 @@
#include "ui_utils.h"
#include "msgwindow.h"
#include "main.h"
+#include "keyfile.h"
#ifdef G_OS_WIN32
# include "win32.h"
#endif
@@ -208,6 +209,7 @@
goto retry;
}
g_free(filename);
+ configuration_open_files();
}
}
#endif
@@ -229,7 +231,12 @@
file = win32_show_project_open_dialog(_("Open Project"), dir, FALSE);
if (file != NULL)
{
- load_config(file);
+ // try to load the config
+ if (! project_load_file(file))
+ {
+ SHOW_ERR1(_("Project file \"%s\" could not be loaded."), file);
+ }
+ configuration_open_files();
g_free(file);
}
#else
@@ -282,13 +289,21 @@
}
+void project_save()
+{
+ g_return_if_fail(app->project != NULL);
+
+ write_config();
+
+ ui_set_statusbar(TRUE, _("Project \"%s\" saved."), app->project->name);
+}
+
+
void project_close()
{
+ //~ gint i, max = gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook));
g_return_if_fail(app->project != NULL);
- /// TODO handle open project files
-
- write_config();
ui_set_statusbar(TRUE, _("Project \"%s\" closed."), app->project->name);
g_free(app->project->name);
@@ -300,6 +315,16 @@
g_free(app->project);
app->project = NULL;
+/// TODO really close all tabs? maybe it should configurable
+/*
+ for(i = 0; i < max; i++)
+ {
+ if (! document_remove(0))
+ break;
+ }
+ tm_workspace_update(TM_WORK_OBJECT(app->tm_workspace), TRUE, TRUE, FALSE);
+*/
+
update_ui();
}
@@ -834,6 +859,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);
+ // fetch session files too
+ configuration_load_session_files(config);
+
g_key_file_free(config);
update_ui();
@@ -870,6 +898,10 @@
g_key_file_set_string_list(config, "project", "file_patterns",
(const gchar**) p->file_patterns, g_strv_length(p->file_patterns));
+ // store the session files into the project too
+ /// TODO maybe it is useful to store relative file names if base_path is relative
+ configuration_save_session_files(config);
+
// write the file
data = g_key_file_to_data(config, NULL, NULL);
ret = (utils_write_file(filename, data) == 0);
@@ -920,6 +952,9 @@
}
g_key_file_set_string(config, "project", "project_file_path",
NVL(local_prefs.project_file_path, ""));
+
+ if (project != NULL)
+ write_config(); // to store project session files
}
Modified: trunk/src/project.h
===================================================================
--- trunk/src/project.h 2007-11-11 10:19:50 UTC (rev 2042)
+++ trunk/src/project.h 2007-11-11 19:06:41 UTC (rev 2043)
@@ -53,6 +53,8 @@
void project_open();
+void project_save();
+
void project_close();
void project_properties();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list