SF.net SVN: geany: [2377] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Fri Mar 21 14:03:00 UTC 2008


Revision: 2377
          http://geany.svn.sourceforge.net/geany/?rev=2377&view=rev
Author:   ntrel
Date:     2008-03-21 07:02:59 -0700 (Fri, 21 Mar 2008)

Log Message:
-----------
Only use filetype detection after Save As, not on every save when the
filetype is None (fixes #1891778).

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/dialogs.c
    trunk/src/document.c
    trunk/src/document.h
    trunk/src/win32.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2008-03-21 13:42:31 UTC (rev 2376)
+++ trunk/ChangeLog	2008-03-21 14:02:59 UTC (rev 2377)
@@ -11,6 +11,9 @@
    When closing tabs that were opened left-to-right, don't temporarily
    focus the previous tab when closing tabs, to prevent unnecessary
    checking for disk changes.
+ * src/win32.c, src/dialogs.c, src/document.c, src/document.h:
+   Only use filetype detection after Save As, not on every save when the
+   filetype is None (fixes #1891778).
 
 
 2008-03-20  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>

Modified: trunk/src/dialogs.c
===================================================================
--- trunk/src/dialogs.c	2008-03-21 13:42:31 UTC (rev 2376)
+++ trunk/src/dialogs.c	2008-03-21 14:02:59 UTC (rev 2377)
@@ -386,7 +386,7 @@
 	g_return_if_fail(NZV(utf8_filename));
 
 	if (open_new_tab)
-	{	/* "open" the saved file in a new tab */
+	{	/* "open" the saved file in a new tab and switch to it */
 		idx = document_clone(idx, utf8_filename);
 	}
 	else
@@ -411,7 +411,7 @@
 	}
 
 	utils_replace_filename(idx);
-	document_save_file(idx, TRUE);
+	document_save_file_as(idx);
 
 	if (! open_new_tab)
 		build_menu_update(idx);

Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c	2008-03-21 13:42:31 UTC (rev 2376)
+++ trunk/src/document.c	2008-03-21 14:02:59 UTC (rev 2377)
@@ -1253,6 +1253,34 @@
 }
 
 
+/*
+ * Save the %document specified by @a idx, detecting the filetype.
+ *
+ * @param idx The %document index for the file to save.
+ * @return @c TRUE if the file was saved or @c FALSE if the file could not be saved.
+ * @see document_save_file().
+ */
+gboolean document_save_file_as(gint idx)
+{
+	if (! DOC_IDX_VALID(idx)) return FALSE;
+
+	/* detect filetype */
+	if (FILETYPE_ID(doc_list[idx].file_type) == GEANY_FILETYPES_ALL)
+	{
+		filetype *ft = filetypes_detect_from_file(idx);
+
+		document_set_filetype(idx, ft);
+		if (document_get_cur_idx() == idx)
+		{
+			app->ignore_callback = TRUE;
+			filetypes_select_radio_item(doc_list[idx].file_type);
+			app->ignore_callback = FALSE;
+		}
+	}
+	return document_save_file(idx, TRUE);
+}
+
+
 /**
  *  Save the %document specified by @a idx. Saving includes replacing tabs by spaces,
  *  stripping trailing spaces and adding a final new line at the end of the file (all only if
@@ -1413,19 +1441,8 @@
 		 * timestamp can be ahead of time(NULL) */
 		document_update_timestamp(idx);
 
-		if (FILETYPE_ID(doc_list[idx].file_type) == GEANY_FILETYPES_ALL)
-		{
-			filetype *ft = filetypes_detect_from_file(idx);
-			document_set_filetype(idx, ft);
-			if (document_get_cur_idx() == idx)
-			{
-				app->ignore_callback = TRUE;
-				filetypes_select_radio_item(doc_list[idx].file_type);
-				app->ignore_callback = FALSE;
-			}
-		}
-		else
-			document_set_filetype(idx, doc_list[idx].file_type);
+		/* update filetype-related things */
+		document_set_filetype(idx, doc_list[idx].file_type);
 
 		tm_workspace_update(TM_WORK_OBJECT(app->tm_workspace), TRUE, TRUE, FALSE);
 		gtk_label_set_text(GTK_LABEL(doc_list[idx].tab_label), base_name);

Modified: trunk/src/document.h
===================================================================
--- trunk/src/document.h	2008-03-21 13:42:31 UTC (rev 2376)
+++ trunk/src/document.h	2008-03-21 14:02:59 UTC (rev 2377)
@@ -171,15 +171,19 @@
 
 gboolean document_reload_file(gint idx, const gchar *forced_enc);
 
+
+gboolean document_save_file_as(gint idx);
+
 gboolean document_save_file(gint idx, gboolean force);
 
+
 gboolean document_search_bar_find(gint idx, const gchar *text, gint flags, gboolean inc);
 
 gint document_find_text(gint idx, const gchar *text, gint flags, gboolean search_backwards,
-	gboolean scroll, GtkWidget *parent);
+		gboolean scroll, GtkWidget *parent);
 
 gint document_replace_text(gint idx, const gchar *find_text, const gchar *replace_text,
-	gint flags, gboolean search_backwards);
+		gint flags, gboolean search_backwards);
 
 gboolean document_replace_all(gint idx, const gchar *find_text, const gchar *replace_text,
 		gint flags, gboolean escaped_chars);

Modified: trunk/src/win32.c
===================================================================
--- trunk/src/win32.c	2008-03-21 13:42:31 UTC (rev 2376)
+++ trunk/src/win32.c	2008-03-21 14:02:59 UTC (rev 2377)
@@ -164,7 +164,7 @@
 	}
 	else
 		result = locale_filename;
-	
+
 	return result;
 }
 
@@ -405,7 +405,7 @@
 		gint idx = document_get_cur_idx();
 		/* convert the resulting filename into UTF-8 */
 		doc_list[idx].file_name = g_locale_to_utf8(fname, -1, NULL, NULL, NULL);
-		document_save_file(idx, TRUE);
+		document_save_file_as(idx);
 	}
 	g_free(fname);
 	return (retval != 0);
@@ -665,7 +665,7 @@
 {
 	DWORD exit_code;
 	GetExitCodeProcess(child_pid, &exit_code);
-	
+
 	return (exit_code == 0);
 }
 


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