anjuta r4140 - in trunk: . plugins/editor plugins/sourceview



Author: jhs
Date: Fri Aug 15 10:05:16 2008
New Revision: 4140
URL: http://svn.gnome.org/viewvc/anjuta?rev=4140&view=rev

Log:
2008-08-15  Johannes Schmid  <jhs gnome org>

	* plugins/editor/text_editor.c: save in correct encoding (fixes build warnings)
	* plugins/sourceview/sourceview-io.c (sourceview_io_init),
	(sourceview_io_save_as), (append_buffer):
	* plugins/sourceview/sourceview-io.h:
	* plugins/sourceview/sourceview.c (on_overwrite_toggled),
	(sourceview_instance_init):
	- #420279 â INS and OVR do not immediately change in status bar
	- Save files in their original encoding

Modified:
   trunk/ChangeLog
   trunk/plugins/editor/text_editor.c
   trunk/plugins/sourceview/sourceview-io.c
   trunk/plugins/sourceview/sourceview-io.h
   trunk/plugins/sourceview/sourceview.c

Modified: trunk/plugins/editor/text_editor.c
==============================================================================
--- trunk/plugins/editor/text_editor.c	(original)
+++ trunk/plugins/editor/text_editor.c	Fri Aug 15 10:05:16 2008
@@ -1049,31 +1049,31 @@
 	unsigned char c; /* unix-char */
 	unsigned char b; /* dos-char */
 } tr_dos[]= {
-	{ 'Ã', 0x84 },
-	{ 'Ã', 0x8e },
-	{ 'Ã', 0xe1 },
-	{ 'Ã', 0x81 },
-	{ 'Ã', 0x9a },
-	{ 'Ã', 0x94 },
-	{ 'Ã', 0x99 },
-	{ 'Ã', 0x82 },
-	{ 'Ã', 0x90 },
-	{ 'Ã', 0x9a },
-	{ 'Ã', 0xd4 },
-	{ 'Ã', 0x88 },
-	{ 'Ã', 0xd2 },
-	{ 'Ã', 0xa0 },
-	{ 'Ã', 0xb5 },
-	{ 'Ã', 0x85 },
-	{ 'Ã', 0xb7 },
-	{ 'Ã', 0x83 },
-	{ 'Ã', 0xb6 },
-	{ 'Ã', 0xa3 },
-	{ 'Ã', 0xe9 },
-	{ 'Ã', 0x97 },
-	{ 'Ã', 0xeb },
-	{ 'Ã', 0x96 },
-	{ 'Ã', 0xea }
+	{ 'ä 0x84 },
+	{ 'Ä, 0x8e },
+	{ 'ß, 0xe1 },
+	{ 'ü81 },
+	{ 'Ü, 0x9a },
+	{ 'ö0x94 },
+	{ 'Ö, 0x99 },
+	{ 'é 0x82 },
+	{ 'É, 0x90 },
+	{ 'è 0x9a },
+	{ 'È, 0xd4 },
+	{ 'ê 0x88 },
+	{ 'Ê, 0xd2 },
+	{ 'á 0xa0 },
+	{ 'Á, 0xb5 },
+	{ 'à 0x85 },
+	{ 'À, 0xb7 },
+	{ 'â 0x83 },
+	{ 'Â, 0xb6 },
+	{ 'úxa3 },
+	{ 'Ú, 0xe9 },
+	{ 'ùx97 },
+	{ 'Ù, 0xeb },
+	{ 'ûx96 },
+	{ 'Û, 0xea }
 };
 
 /*

Modified: trunk/plugins/sourceview/sourceview-io.c
==============================================================================
--- trunk/plugins/sourceview/sourceview-io.c	(original)
+++ trunk/plugins/sourceview/sourceview-io.c	Fri Aug 15 10:05:16 2008
@@ -54,6 +54,7 @@
 	object->write_buffer = NULL;
 	object->cancel = g_cancellable_new();
 	object->monitor = NULL;
+	object->last_encoding = NULL;
 }
 
 static void
@@ -280,8 +281,30 @@
 			}
 		}
 	}
-	sio->write_buffer = ianjuta_editor_get_text_all (IANJUTA_EDITOR(sio->sv), 
-													 NULL);
+	
+	if (sio->last_encoding == NULL)
+	{
+		sio->write_buffer = ianjuta_editor_get_text_all (IANJUTA_EDITOR(sio->sv), 
+														 NULL);
+	}
+	else
+	{
+		GError* err = NULL;
+		gchar* buffer_text = ianjuta_editor_get_text_all (IANJUTA_EDITOR(sio->sv), 
+														  NULL);
+		sio->write_buffer = anjuta_convert_from_utf8 (buffer_text,
+													  -1,
+													  sio->last_encoding,
+													  NULL,
+													  &err);
+		g_free (buffer_text);
+		if (err != NULL)
+		{
+			g_signal_emit_by_name (sio, "save-failed", err);
+			g_error_free(err);
+			return;
+		}
+	}
 	g_cancellable_reset (sio->cancel);
 	g_output_stream_write_async (G_OUTPUT_STREAM (output_stream),
 								 sio->write_buffer,
@@ -358,6 +381,7 @@
 			g_cancellable_cancel (sio->cancel);
 			return;
 		}
+		sio->last_encoding = enc;
 		insert_text_in_document (sio, converted_text, new_len);
 		g_free (converted_text);
 	}

Modified: trunk/plugins/sourceview/sourceview-io.h
==============================================================================
--- trunk/plugins/sourceview/sourceview-io.h	(original)
+++ trunk/plugins/sourceview/sourceview-io.h	Fri Aug 15 10:05:16 2008
@@ -22,6 +22,7 @@
 
 #include <glib-object.h>
 #include <gio/gio.h>
+#include <libanjuta/anjuta-encodings.h>
 #include "sourceview.h"
 
 G_BEGIN_DECLS
@@ -60,6 +61,8 @@
 	GCancellable* cancel;
 	GFileMonitor* monitor;
 	guint monitor_idle;
+	
+	const AnjutaEncoding* last_encoding;
 };
 
 GType sourceview_io_get_type (void) G_GNUC_CONST;

Modified: trunk/plugins/sourceview/sourceview.c
==============================================================================
--- trunk/plugins/sourceview/sourceview.c	(original)
+++ trunk/plugins/sourceview/sourceview.c	Fri Aug 15 10:05:16 2008
@@ -252,6 +252,14 @@
 						  !gtk_text_buffer_get_modified(buffer));
 }
 
+/* Update document status */
+static void on_overwrite_toggled (GtkTextView* view,
+								  Sourceview* sv)
+{
+	g_signal_emit_by_name(G_OBJECT(sv), "update_ui");
+}
+
+
 static void on_mark_set (GtkTextBuffer *buffer,
 						 GtkTextIter* location,
 						 GtkTextMark* mark,
@@ -518,6 +526,8 @@
 					 
 	/* Create View instance */
 	sv->priv->view = ANJUTA_VIEW(anjuta_view_new(sv));
+	g_signal_connect_after (G_OBJECT(sv->priv->view), "toggle-overwrite", 
+					  G_CALLBACK(on_overwrite_toggled), sv);
 	g_signal_connect (G_OBJECT(sv->priv->view), "query-tooltip",
 					  G_CALLBACK (on_sourceview_hover_over), sv);
 	g_object_set (G_OBJECT (sv->priv->view), "has-tooltip", TRUE, NULL);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]