When editing non-existent config files using the Tools->Configuration Files menu, explicitly set the real_path to avoid presenting the Save As dialog when saving the file (patch by Tony Rick, thanks).

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@4732 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Enrico Tröger 2010-03-07 17:37:00 +00:00
parent 2ec40e1a01
commit 74f0afa5dc
2 changed files with 13 additions and 3 deletions

View File

@ -23,6 +23,10 @@
* src/dialog.c:
Fix setting the icon for some dialogs if the parent itself is also
a dialog.
* src/ui_utils.c:
When editing non-existent config files using the Tools->Configuration
Files menu, explicitly set the real_path to avoid presenting the Save
As dialog when saving the file (patch by Tony Rick, thanks).
2010-03-05 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>

View File

@ -1737,18 +1737,24 @@ static void on_config_file_clicked(GtkWidget *widget, gpointer user_data)
document_open_file(file_name, FALSE, ft, NULL);
else
{
gchar *utf8 = utils_get_utf8_from_locale(file_name);
gchar *utf8_filename = utils_get_utf8_from_locale(file_name);
gchar *base_name = g_path_get_basename(file_name);
gchar *global_file = g_build_filename(app->datadir, base_name, NULL);
gchar *global_content = NULL;
GeanyDocument *doc;
/* if the requested file doesn't exist in the user's config dir, try loading the file
* from the global data directory and use its contents for the newly created file */
if (g_file_test(global_file, G_FILE_TEST_EXISTS))
g_file_get_contents(global_file, &global_content, NULL, NULL);
document_new_file(utf8, ft, global_content);
utils_free_pointers(4, utf8, base_name, global_file, global_content, NULL);
doc = document_new_file(utf8_filename, ft, global_content);
/* Enforce config file override policy by populating doc->real_path, which in turn
* allows document to be saved directly to file_name location. */
doc->real_path = g_strdup(utf8_filename);
utils_free_pointers(4, utf8_filename, base_name, global_file, global_content, NULL);
}
}