SF.net SVN: geany: [1671] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Fri Jul 6 12:37:08 UTC 2007


Revision: 1671
          http://svn.sourceforge.net/geany/?rev=1671&view=rev
Author:   eht16
Date:     2007-07-06 05:37:07 -0700 (Fri, 06 Jul 2007)

Log Message:
-----------
Use the default GTK file save dialog on Windows. Prevent some (probably) unnecessary filename encoding conversions.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/doc/geany.docbook
    trunk/src/callbacks.c
    trunk/src/dialogs.c
    trunk/src/document.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-07-06 10:19:28 UTC (rev 1670)
+++ trunk/ChangeLog	2007-07-06 12:37:07 UTC (rev 1671)
@@ -2,6 +2,9 @@
 
  * doc/geany.docbook, src/editor.c, src/editor.h, src/keybindings.c,
    src/keybindings.h: Add keybinding for select current paragraph.
+ * doc/geany.docbook, src/callbacks.c, src/dialogs.c, src/document.c:
+   Use the default GTK file save dialog on Windows.
+   Prevent some (probably) unnecessary filename encoding conversions.
 
 
 2007-07-05  Enrico Tröger  <enrico.troeger at uvena.de>

Modified: trunk/doc/geany.docbook
===================================================================
--- trunk/doc/geany.docbook	2007-07-06 10:19:28 UTC (rev 1670)
+++ trunk/doc/geany.docbook	2007-07-06 12:37:07 UTC (rev 1671)
@@ -2821,10 +2821,10 @@
 						<row>
 							<entry>GEANY_USE_WIN32_DIALOG</entry>
 							<entry>Set this to 1 if you want to use the default Windows
-								   file open dialog instead GTK's file open dialog. The default
-								   Windows file open dialog is missing some nice features like
-								   choosing a filetype or an encoding. Do not touch this
-								   setting when building on a non-Win32 system.</entry>
+								   file open and save dialogs instead GTK's file open and save
+								   dialogs. The default Windows file dialogs are missing some nice
+								   features like choosing a filetype or an encoding. Do not touch
+								   this setting when building on a non-Win32 system.</entry>
 							<entry>0</entry>
 						</row>
 					</tbody>

Modified: trunk/src/callbacks.c
===================================================================
--- trunk/src/callbacks.c	2007-07-06 10:19:28 UTC (rev 1670)
+++ trunk/src/callbacks.c	2007-07-06 12:37:07 UTC (rev 1671)
@@ -856,8 +856,11 @@
 		gboolean rename_file = gtk_toggle_button_get_active(
 				GTK_TOGGLE_BUTTON(lookup_widget(app->save_filesel, "check_rename")));
 
+#ifdef G_OS_WIN32
+		utf8_filename = g_strdup(new_filename);
+#else
 		utf8_filename = utils_get_utf8_from_locale(new_filename);
-
+#endif
 		// check if file exists and ask whether to overwrite or not
 		if (g_file_test(new_filename, G_FILE_TEST_EXISTS))
 		{
@@ -907,10 +910,14 @@
 			{
 				if (rename_file)
 				{	// delete the previous file name
+#ifdef G_OS_WIN32
+					g_unlink(doc_list[idx].file_name);
+#else
 					gchar *old_filename = utils_get_locale_from_utf8(doc_list[idx].file_name);
 
 					g_unlink(old_filename);
 					g_free(old_filename);
+#endif
 				}
 				// create a new tm_source_file object otherwise tagmanager won't work correctly
 				tm_workspace_remove_object(doc_list[idx].tm_file, TRUE);

Modified: trunk/src/dialogs.c
===================================================================
--- trunk/src/dialogs.c	2007-07-06 10:19:28 UTC (rev 1670)
+++ trunk/src/dialogs.c	2007-07-06 12:37:07 UTC (rev 1671)
@@ -56,8 +56,8 @@
 
 #if ! GEANY_USE_WIN32_DIALOG
 static GtkWidget *add_file_open_extra_widget();
+static void on_save_as_new_tab_toggled(GtkToggleButton *togglebutton, gpointer user_data);
 #endif
-static void on_save_as_new_tab_toggled(GtkToggleButton *togglebutton, gpointer user_data);
 
 
 /* This shows the file selection dialog to open a file. */
@@ -269,7 +269,7 @@
  * the file was saved. */
 gboolean dialogs_show_save_as()
 {
-#ifdef G_OS_WIN32
+#if GEANY_USE_WIN32_DIALOG
 	return win32_show_file_dialog(FALSE);
 #else
 	gint idx = document_get_cur_idx(), resp;
@@ -318,13 +318,18 @@
 	// If the current document has a filename we use that as the default.
 	if (doc_list[idx].file_name != NULL)
 	{
+#ifdef G_OS_WIN32
+		gchar *locale_filename = doc_list[idx].file_name;
+#else
 		gchar *locale_filename = utils_get_locale_from_utf8(doc_list[idx].file_name);
-
+#endif
 		if (g_path_is_absolute(locale_filename))
 			gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(app->save_filesel), locale_filename);
 		else
 			gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(app->save_filesel), locale_filename);
+#ifndef G_OS_WIN32
 		g_free(locale_filename);
+#endif
 	}
 	else
 	{
@@ -344,8 +349,16 @@
 		if (app->default_open_path != NULL && *app->default_open_path != '\0')
 		{
 			if (g_path_is_absolute(app->default_open_path))
+			{
+#ifdef G_OS_WIN32
 				gtk_file_chooser_set_current_folder(
 					GTK_FILE_CHOOSER(app->save_filesel), app->default_open_path);
+#else
+				gchar *def_path = utils_get_locale_from_utf8(app->default_open_path);
+				gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(app->save_filesel), def_path);
+				g_free(def_path);
+#endif
+			}
 		}
 		g_free(fname);
 	}

Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c	2007-07-06 10:19:28 UTC (rev 1670)
+++ trunk/src/document.c	2007-07-06 12:37:07 UTC (rev 1671)
@@ -969,7 +969,9 @@
 	gchar *data;
 	FILE *fp;
 	gint bytes_written, len;
+#ifndef G_OS_WIN32
 	gchar *locale_filename = NULL;
+#endif
 
 	if (! DOC_IDX_VALID(idx)) return FALSE;
 	// the changed flag should exclude the readonly flag, but check it anyway for safety
@@ -1043,12 +1045,16 @@
 	{
 		len = strlen(data);
 	}
+#ifdef G_OS_WIN32
+	fp = fopen(doc_list[idx].file_name, "wb"); // this should fix the windows \n problem
+#else
 	locale_filename = utils_get_locale_from_utf8(doc_list[idx].file_name);
-	fp = fopen(locale_filename, "wb"); // this should fix the windows \n problem
+	fp = fopen(locale_filename, "w");
 	g_free(locale_filename);
+#endif
 	if (fp == NULL)
 	{
-		msgwin_status_add(_("Error saving file (%s)."), strerror(errno));
+		msgwin_status_add(_("Error saving file (%s)."), g_strerror(errno));
 		utils_beep();
 		g_free(data);
 		return FALSE;


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