From 74f0afa5dce7725f7aff27a226a6ab7993569ba4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrico=20Tr=C3=B6ger?= Date: Sun, 7 Mar 2010 17:37:00 +0000 Subject: [PATCH] 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 --- ChangeLog | 4 ++++ src/ui_utils.c | 12 +++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2e9e79a8..8776fa05 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/src/ui_utils.c b/src/ui_utils.c index 2b192d81..2f4dab7d 100644 --- a/src/ui_utils.c +++ b/src/ui_utils.c @@ -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); } }