SF.net SVN: geany: [663] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Wed Aug 2 10:51:04 UTC 2006


Revision: 663
Author:   eht16
Date:     2006-08-02 03:50:53 -0700 (Wed, 02 Aug 2006)
ViewCVS:  http://svn.sourceforge.net/geany/?rev=663&view=rev

Log Message:
-----------
Fixed wrong behaviour of Save As on unchanged files.
Don't set file as changed when changing encoding to the same one.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/callbacks.c
    trunk/src/dialogs.c
    trunk/src/document.c
    trunk/src/document.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-08-02 09:55:22 UTC (rev 662)
+++ trunk/ChangeLog	2006-08-02 10:50:53 UTC (rev 663)
@@ -1,3 +1,11 @@
+2006-08-02  Enrico Tröger  <enrico.troeger at uvena.de>
+
+ * src/callbacks.c:
+   Don't set file as changed when changing encoding to the same one.
+ * src/document.c, src/callbacks.c, dialogs.c:
+   Fixed wrong behaviour of Save As on unchanged files.
+
+
 2006-08-01  Enrico Tröger  <enrico.troeger at uvena.de>
 
  * geany.glade, src/interface.c, src/callbacks.c, src/keybindings.c,

Modified: trunk/src/callbacks.c
===================================================================
--- trunk/src/callbacks.c	2006-08-02 09:55:22 UTC (rev 662)
+++ trunk/src/callbacks.c	2006-08-02 10:50:53 UTC (rev 663)
@@ -270,7 +270,7 @@
 		if (doc_list[idx].file_name == NULL)
 			dialogs_show_save_as();
 		else
-			document_save_file(idx);
+			document_save_file(idx, FALSE);
 	}
 }
 
@@ -296,7 +296,7 @@
 		if (doc_list[idx].file_name == NULL)
 			dialogs_show_save_as();
 		else
-			document_save_file(idx);
+			document_save_file(idx, FALSE);
 	}
 	utils_update_tag_list(cur_idx, TRUE);
 	utils_set_window_title(cur_idx);
@@ -925,7 +925,7 @@
 		doc_list[idx].file_name = new_filename;
 
 		utils_replace_filename(idx);
-		document_save_file(idx);
+		document_save_file(idx, TRUE);
 
 		utils_build_show_hide(idx);
 
@@ -1511,7 +1511,7 @@
 				}
 				case 1:
 				{
-					if (doc_list[idx].changed) document_save_file(idx);
+					if (doc_list[idx].changed) document_save_file(idx, FALSE);
 					break;
 				}
 				case 2:
@@ -1604,7 +1604,7 @@
 	gint idx = document_get_cur_idx();
 	GPid child_pid = (GPid) 0;
 
-	if (doc_list[idx].changed) document_save_file(idx);
+	if (doc_list[idx].changed) document_save_file(idx, FALSE);
 
 	if (doc_list[idx].file_type->id == GEANY_FILETYPES_LATEX)
 		child_pid = build_compile_tex_file(idx, 0);
@@ -1626,7 +1626,7 @@
 	gint idx = document_get_cur_idx();
 	GPid child_pid = (GPid) 0;
 
-	if (doc_list[idx].changed) document_save_file(idx);
+	if (doc_list[idx].changed) document_save_file(idx, FALSE);
 
 	switch (GPOINTER_TO_INT(user_data))
 	{
@@ -1651,7 +1651,7 @@
 	gint idx = document_get_cur_idx();
 	GPid child_pid = (GPid) 0;
 
-	if (doc_list[idx].changed) document_save_file(idx);
+	if (doc_list[idx].changed) document_save_file(idx, FALSE);
 
 	if (doc_list[idx].file_type->id == GEANY_FILETYPES_LATEX)
 		child_pid = build_compile_tex_file(idx, 1);
@@ -1706,7 +1706,7 @@
 		{
 			GPid child_pid;
 
-			if (doc_list[idx].changed) document_save_file(idx);
+			if (doc_list[idx].changed) document_save_file(idx, FALSE);
 
 			child_pid = build_make_file(idx, make_object);
 			if (child_pid != (GPid) 0)
@@ -1737,7 +1737,7 @@
 		// save the file only if the run command uses it
 		if (doc_list[idx].changed &&
 			strstr(doc_list[idx].file_type->programs->run_cmd, "%f") != NULL)
-				document_save_file(idx);
+				document_save_file(idx, FALSE);
 		if (build_run_cmd(idx) == (GPid) 0)
 		{
 			msgwin_status_add(_("Failed to execute the terminal program"));
@@ -1773,7 +1773,7 @@
 		gint idx = document_get_cur_idx();
 		GPid child_pid;
 
-		if (doc_list[idx].changed) document_save_file(idx);
+		if (doc_list[idx].changed) document_save_file(idx, FALSE);
 
 		strncpy(app->build_make_custopt, gtk_entry_get_text(GTK_ENTRY(user_data)), 255);
 
@@ -2593,7 +2593,8 @@
 	gint idx = document_get_cur_idx();
 	guint i = GPOINTER_TO_INT(user_data);
 
-	if (idx < 0 || encodings[i].charset == NULL) return;
+	if (idx < 0 || encodings[i].charset == NULL ||
+		utils_strcmp(encodings[i].charset, doc_list[idx].encoding)) return;
 
 	g_free(doc_list[idx].encoding);
 	doc_list[idx].encoding = g_strdup(encodings[i].charset);

Modified: trunk/src/dialogs.c
===================================================================
--- trunk/src/dialogs.c	2006-08-02 09:55:22 UTC (rev 662)
+++ trunk/src/dialogs.c	2006-08-02 10:50:53 UTC (rev 663)
@@ -154,7 +154,7 @@
 
 
 /* This shows the file selection dialog to save a file. */
-void dialogs_show_save_as ()
+void dialogs_show_save_as()
 {
 #ifdef G_OS_WIN32
 	win32_show_file_dialog(FALSE);
@@ -320,7 +320,7 @@
 			if (doc_list[idx].file_name == NULL)
 				dialogs_show_save_as();
 			else
-				document_save_file(idx);
+				document_save_file(idx, FALSE);
 			ret = TRUE;
 			break;
 		}
@@ -361,7 +361,7 @@
 					"clicked", G_CALLBACK(on_font_apply_button_clicked), NULL);
 
 		gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(app->open_fontsel), app->editor_font);
-		gtk_window_set_transient_for(GTK_WINDOW (app->open_fontsel), GTK_WINDOW(app->window));
+		gtk_window_set_transient_for(GTK_WINDOW(app->open_fontsel), GTK_WINDOW(app->window));
 	}
 	/* We make sure the dialog is visible. */
 	gtk_window_present(GTK_WINDOW(app->open_fontsel));
@@ -558,7 +558,7 @@
 		item = gtk_image_menu_item_new_with_mnemonic(_("_Set Includes and Arguments"));
 		gtk_widget_show(item);
 		GEANY_ADD_WIDGET_ACCEL(GEANY_KEYS_BUILD_OPTIONS, item);
-		gtk_container_add(GTK_CONTAINER (menu), item);
+		gtk_container_add(GTK_CONTAINER(menu), item);
 		gtk_tooltips_set_tip(tooltips, item,
 					_("Sets the includes and library paths for the compiler and "
 					  "the program arguments for execution"), NULL);
@@ -666,7 +666,7 @@
 	if (keys[GEANY_KEYS_BUILD_OPTIONS]->key)
 		gtk_widget_add_accelerator(item, "activate", accel_group, keys[GEANY_KEYS_BUILD_OPTIONS]->key,
 			keys[GEANY_KEYS_BUILD_OPTIONS]->mods, GTK_ACCEL_VISIBLE);
-	gtk_container_add(GTK_CONTAINER (menu), item);
+	gtk_container_add(GTK_CONTAINER(menu), item);
 	gtk_tooltips_set_tip(tooltips, item,
 				_("Sets the program paths and arguments"), NULL);
 	image = gtk_image_new_from_stock("gtk-preferences", GTK_ICON_SIZE_MENU);
@@ -726,8 +726,8 @@
 	gtk_entry_set_max_length(GTK_ENTRY(entry), 248);
 	gtk_entry_set_width_chars(GTK_ENTRY(entry), 30);
 
-	g_signal_connect((gpointer) entry, "activate", G_CALLBACK (on_make_target_entry_activate), dialog);
-	g_signal_connect((gpointer) dialog, "response", G_CALLBACK (on_make_target_dialog_response), entry);
+	g_signal_connect((gpointer) entry, "activate", G_CALLBACK(on_make_target_entry_activate), dialog);
+	g_signal_connect((gpointer) dialog, "response", G_CALLBACK(on_make_target_dialog_response), entry);
 	g_signal_connect((gpointer) dialog, "delete_event", G_CALLBACK(gtk_widget_destroy), NULL);
 
 	gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), label);

Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c	2006-08-02 09:55:22 UTC (rev 662)
+++ trunk/src/document.c	2006-08-02 10:50:53 UTC (rev 663)
@@ -255,6 +255,8 @@
 	sci_set_symbol_margin(sci, app->show_markers_margin);
 	sci_set_line_numbers(sci, app->show_linenumber_margin, 0);
 	sci_set_lines_wrapped(sci, app->pref_editor_line_breaking);
+	SSM(sci, SCI_SETLAYOUTCACHE, SC_CACHE_PAGE, 0);
+
 	pfd = pango_font_description_from_string(app->editor_font);
 	fname = g_strdup_printf("!%s", pango_font_description_get_family(pfd));
 	document_set_font(new_idx, fname, pango_font_description_get_size(pfd) / PANGO_SCALE);
@@ -372,6 +374,7 @@
 		g_free(template);
 
 		doc_list[idx].encoding = g_strdup(encodings[app->pref_editor_default_encoding].charset);
+		//document_set_filetype(idx, (ft == NULL) ? filetypes[GEANY_FILETYPES_ALL] : ft);
 		document_set_filetype(idx, ft);
 		utils_set_window_title(idx);
 		utils_build_show_hide(idx);
@@ -681,15 +684,17 @@
 }
 
 
-/* This saves the file */
-void document_save_file(gint idx)
+/* This saves the file.
+ * When force is set then it is always saved, even if it is unchanged(useful when using Save As) */
+void document_save_file(gint idx, gboolean force)
 {
 	gchar *data;
 	FILE *fp;
 	gint bytes_written, len;
 	gchar *locale_filename = NULL;
 
-	if (idx == -1 || ! doc_list[idx].changed) return;
+	if (idx == -1) return;
+	if (! force && ! doc_list[idx].changed) return;
 
 	if (doc_list[idx].file_name == NULL)
 	{

Modified: trunk/src/document.h
===================================================================
--- trunk/src/document.h	2006-08-02 09:55:22 UTC (rev 662)
+++ trunk/src/document.h	2006-08-02 10:50:53 UTC (rev 663)
@@ -88,9 +88,9 @@
 int document_reload_file(gint idx, const gchar *forced_enc);
 
 
-/* This saves the file, which is in on-disk encoding (which may not
-   be UTF-8). */
-void document_save_file (gint);
+/* This saves the file.
+ * When force is set then it is always saved, even if it is unchanged(useful when using Save As) */
+void document_save_file(gint, gboolean force);
 
 /* special search function, used from the find entry in the toolbar */
 void document_find_next(gint, const gchar*, gint, gboolean, gboolean);


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