pidgin/gtksourceundomanager.c

changeset 26378
e85d894af8a5
parent 25888
d0fdd378a635
child 30623
d0368101bd0d
--- a/pidgin/gtksourceundomanager.c	Sun Mar 08 06:20:04 2009 +0000
+++ b/pidgin/gtksourceundomanager.c	Sun Mar 08 06:24:15 2009 +0000
@@ -4,8 +4,8 @@
  * This file is part of GtkSourceView
  *
  * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
- * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi 
- * Copyright (C) 2002-2005  Paolo Maggi 
+ * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi
+ * Copyright (C) 2002-2005  Paolo Maggi
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -19,7 +19,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
  * Boston, MA 02111-1301, USA.
  */
 
@@ -49,14 +49,14 @@
 	GTK_SOURCE_UNDO_ACTION_INSERT_ANCHOR,
 } GtkSourceUndoActionType;
 
-/* 
+/*
  * We use offsets instead of GtkTextIters because the last ones
  * require to much memory in this context without giving us any advantage.
- */ 
+ */
 
 struct _GtkSourceUndoInsertAction
 {
-	gint   pos; 
+	gint   pos;
 	gchar *text;
 	gint   length;
 	gint   chars;
@@ -79,7 +79,7 @@
 struct _GtkSourceUndoAction
 {
 	GtkSourceUndoActionType action_type;
-	
+
 	union {
 		GtkSourceUndoInsertAction  insert;
 		GtkSourceUndoDeleteAction  delete;
@@ -92,7 +92,7 @@
 	guint mergeable : 1;
 
 	/* It is TRUE whether the action is marked as "modified".
-	 * An action is marked as "modified" if it changed the 
+	 * An action is marked as "modified" if it changed the
 	 * state of the buffer from "not modified" to "modified". Only the first
 	 * action of a group can be marked as modified.
 	 * There can be a single action marked as "modified" in the actions list.
@@ -106,29 +106,29 @@
 struct _GtkSourceUndoManagerPrivate
 {
 	GtkTextBuffer	*document;
-	
+
 	GList*		 actions;
-	gint 		 next_redo;	
+	gint 		 next_redo;
 
 	gint 		 actions_in_current_group;
-	
+
 	gint		 running_not_undoable_actions;
 
 	gint		 num_of_groups;
 
 	gint		 max_undo_levels;
-	
+
 	guint	 	 can_undo : 1;
 	guint		 can_redo : 1;
-	
+
 	/* It is TRUE whether, while undoing an action of the current group (with order_in_group > 1),
 	 * the state of the buffer changed from "not modified" to "modified".
 	 */
-	guint	 	 modified_undoing_group : 1;	
+	guint	 	 modified_undoing_group : 1;
 
 	/* Pointer to the action (in the action list) marked as "modified".
-	 * It is NULL when no action is marked as "modified". 
-	 * It is INVALID when the action marked as "modified" has been removed 
+	 * It is NULL when no action is marked as "modified".
+	 * It is INVALID when the action marked as "modified" has been removed
 	 * from the action list (freeing the list or resizing it) */
 	GtkSourceUndoAction *modified_action;
 };
@@ -143,33 +143,33 @@
 static void gtk_source_undo_manager_init 			(GtkSourceUndoManager 		*um);
 static void gtk_source_undo_manager_finalize 			(GObject 			*object);
 
-static void gtk_source_undo_manager_insert_text_handler 	(GtkTextBuffer 			*buffer, 
+static void gtk_source_undo_manager_insert_text_handler 	(GtkTextBuffer 			*buffer,
 							 	 GtkTextIter 			*pos,
-		                             		 	 const 	gchar 			*text, 
-							 	 gint 				 length, 
+		                             		 	 const 	gchar 			*text,
+							 	 gint 				 length,
 							 	 GtkSourceUndoManager 		*um);
 static void gtk_source_undo_manager_insert_anchor_handler (GtkTextBuffer *buffer,
 			                   GtkTextIter            *pos,
 			                   GtkTextChildAnchor     *anchor,
 			                   GtkSourceUndoManager   *um);
-static void gtk_source_undo_manager_delete_range_handler 	(GtkTextBuffer 			*buffer, 
+static void gtk_source_undo_manager_delete_range_handler 	(GtkTextBuffer 			*buffer,
 							 	 GtkTextIter 			*start,
                         		      		 	 GtkTextIter 			*end,
 							 	 GtkSourceUndoManager 		*um);
-static void gtk_source_undo_manager_begin_user_action_handler 	(GtkTextBuffer 			*buffer, 
+static void gtk_source_undo_manager_begin_user_action_handler 	(GtkTextBuffer 			*buffer,
 								 GtkSourceUndoManager 		*um);
 static void gtk_source_undo_manager_modified_changed_handler	(GtkTextBuffer                  *buffer,
 								 GtkSourceUndoManager           *um);
 
 static void gtk_source_undo_manager_free_action_list 		(GtkSourceUndoManager 		*um);
 
-static void gtk_source_undo_manager_add_action 			(GtkSourceUndoManager 		*um, 
+static void gtk_source_undo_manager_add_action 			(GtkSourceUndoManager 		*um,
 		                                         	 const GtkSourceUndoAction 	*undo_action);
-static void gtk_source_undo_manager_free_first_n_actions 	(GtkSourceUndoManager 		*um, 
+static void gtk_source_undo_manager_free_first_n_actions 	(GtkSourceUndoManager 		*um,
 								 gint 				 n);
 static void gtk_source_undo_manager_check_list_size 		(GtkSourceUndoManager 		*um);
 
-static gboolean gtk_source_undo_manager_merge_action 		(GtkSourceUndoManager 		*um, 
+static gboolean gtk_source_undo_manager_merge_action 		(GtkSourceUndoManager 		*um,
 		                                        	 const GtkSourceUndoAction 	*undo_action);
 
 static GObjectClass 	*parent_class 				= NULL;
@@ -216,7 +216,7 @@
 
         klass->can_undo 	= NULL;
 	klass->can_redo 	= NULL;
-	
+
 	undo_manager_signals[CAN_UNDO] =
    		g_signal_new ("can_undo",
 			      G_OBJECT_CLASS_TYPE (object_class),
@@ -269,7 +269,7 @@
 
 	g_return_if_fail (object != NULL);
 	g_return_if_fail (GTK_SOURCE_IS_UNDO_MANAGER (object));
-	
+
    	um = GTK_SOURCE_UNDO_MANAGER (object);
 
 	g_return_if_fail (um->priv != NULL);
@@ -280,19 +280,19 @@
 	}
 
 	g_signal_handlers_disconnect_by_func (G_OBJECT (um->priv->document),
-			  G_CALLBACK (gtk_source_undo_manager_delete_range_handler), 
+			  G_CALLBACK (gtk_source_undo_manager_delete_range_handler),
 			  um);
 
 	g_signal_handlers_disconnect_by_func (G_OBJECT (um->priv->document),
-			  G_CALLBACK (gtk_source_undo_manager_insert_text_handler), 
+			  G_CALLBACK (gtk_source_undo_manager_insert_text_handler),
 			  um);
-	
+
 	g_signal_handlers_disconnect_by_func (G_OBJECT (um->priv->document),
-			  G_CALLBACK (gtk_source_undo_manager_insert_anchor_handler), 
+			  G_CALLBACK (gtk_source_undo_manager_insert_anchor_handler),
 			  um);
-	
+
 	g_signal_handlers_disconnect_by_func (G_OBJECT (um->priv->document),
-			  G_CALLBACK (gtk_source_undo_manager_begin_user_action_handler), 
+			  G_CALLBACK (gtk_source_undo_manager_begin_user_action_handler),
 			  um);
 
 	g_free (um->priv);
@@ -311,19 +311,19 @@
   	um->priv->document = buffer;
 
 	g_signal_connect (G_OBJECT (buffer), "insert_text",
-			  G_CALLBACK (gtk_source_undo_manager_insert_text_handler), 
+			  G_CALLBACK (gtk_source_undo_manager_insert_text_handler),
 			  um);
 
 	g_signal_connect (G_OBJECT (buffer), "insert_child_anchor",
-			  G_CALLBACK (gtk_source_undo_manager_insert_anchor_handler), 
+			  G_CALLBACK (gtk_source_undo_manager_insert_anchor_handler),
 			  um);
 
 	g_signal_connect (G_OBJECT (buffer), "delete_range",
-			  G_CALLBACK (gtk_source_undo_manager_delete_range_handler), 
+			  G_CALLBACK (gtk_source_undo_manager_delete_range_handler),
 			  um);
 
 	g_signal_connect (G_OBJECT (buffer), "begin_user_action",
-			  G_CALLBACK (gtk_source_undo_manager_begin_user_action_handler), 
+			  G_CALLBACK (gtk_source_undo_manager_begin_user_action_handler),
 			  um);
 
 	g_signal_connect (G_OBJECT (buffer), "modified_changed",
@@ -332,7 +332,7 @@
 	return um;
 }
 
-void 
+void
 gtk_source_undo_manager_begin_not_undoable_action (GtkSourceUndoManager *um)
 {
 	g_return_if_fail (GTK_SOURCE_IS_UNDO_MANAGER (um));
@@ -341,18 +341,18 @@
 	++um->priv->running_not_undoable_actions;
 }
 
-static void 
+static void
 gtk_source_undo_manager_end_not_undoable_action_internal (GtkSourceUndoManager *um)
 {
 	g_return_if_fail (GTK_SOURCE_IS_UNDO_MANAGER (um));
 	g_return_if_fail (um->priv != NULL);
 
 	g_return_if_fail (um->priv->running_not_undoable_actions > 0);
-	
+
 	--um->priv->running_not_undoable_actions;
 }
 
-void 
+void
 gtk_source_undo_manager_end_not_undoable_action (GtkSourceUndoManager *um)
 {
 	g_return_if_fail (GTK_SOURCE_IS_UNDO_MANAGER (um));
@@ -361,26 +361,26 @@
 	gtk_source_undo_manager_end_not_undoable_action_internal (um);
 
 	if (um->priv->running_not_undoable_actions == 0)
-	{	
+	{
 		gtk_source_undo_manager_free_action_list (um);
-	
-		um->priv->next_redo = -1;	
+
+		um->priv->next_redo = -1;
 
 		if (um->priv->can_undo)
 		{
 			um->priv->can_undo = FALSE;
-			g_signal_emit (G_OBJECT (um), 
-				       undo_manager_signals [CAN_UNDO], 
-				       0, 
+			g_signal_emit (G_OBJECT (um),
+				       undo_manager_signals [CAN_UNDO],
+				       0,
 				       FALSE);
 		}
 
 		if (um->priv->can_redo)
 		{
 			um->priv->can_redo = FALSE;
-			g_signal_emit (G_OBJECT (um), 
-				       undo_manager_signals [CAN_REDO], 
-				       0, 
+			g_signal_emit (G_OBJECT (um),
+				       undo_manager_signals [CAN_REDO],
+				       0,
 				       FALSE);
 		}
 	}
@@ -395,7 +395,7 @@
 	return um->priv->can_undo;
 }
 
-gboolean 
+gboolean
 gtk_source_undo_manager_can_redo (const GtkSourceUndoManager *um)
 {
 	g_return_val_if_fail (GTK_SOURCE_IS_UNDO_MANAGER (um), FALSE);
@@ -408,31 +408,31 @@
 set_cursor (GtkTextBuffer *buffer, gint cursor)
 {
 	GtkTextIter iter;
-	
+
 	/* Place the cursor at the requested position */
 	gtk_text_buffer_get_iter_at_offset (buffer, &iter, cursor);
 	gtk_text_buffer_place_cursor (buffer, &iter);
 }
 
-static void 
+static void
 insert_text (GtkTextBuffer *buffer, gint pos, const gchar *text, gint len)
 {
 	GtkTextIter iter;
-	
+
 	gtk_text_buffer_get_iter_at_offset (buffer, &iter, pos);
 	gtk_text_buffer_insert (buffer, &iter, text, len);
 }
 
-static void 
+static void
 insert_anchor (GtkTextBuffer *buffer, gint pos, GtkTextChildAnchor *anchor)
 {
 	GtkTextIter iter;
-	
+
 	gtk_text_buffer_get_iter_at_offset (buffer, &iter, pos);
 	gtk_text_buffer_insert_child_anchor (buffer, &iter, anchor);
 }
 
-static void 
+static void
 delete_text (GtkTextBuffer *buffer, gint start, gint end)
 {
 	GtkTextIter start_iter;
@@ -464,7 +464,7 @@
 	return gtk_text_buffer_get_slice (buffer, &start_iter, &end_iter, TRUE);
 }
 
-void 
+void
 gtk_source_undo_manager_undo (GtkSourceUndoManager *um)
 {