[gtksourceview/wip/undo-redo: 2/2] UndoManager: new implementation based on GQueues (not finished)



commit 5188042c1fd60f8c926558c366a26c1e3538ecc3
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sun Aug 31 17:40:40 2014 +0200

    UndoManager: new implementation based on GQueues (not finished)

 gtksourceview/gtksourceundomanagerdefault.c |   47 +++++++++++++++++++++++++++
 1 files changed, 47 insertions(+), 0 deletions(-)
---
diff --git a/gtksourceview/gtksourceundomanagerdefault.c b/gtksourceview/gtksourceundomanagerdefault.c
index f843613..94b2641 100644
--- a/gtksourceview/gtksourceundomanagerdefault.c
+++ b/gtksourceview/gtksourceundomanagerdefault.c
@@ -134,6 +134,46 @@ G_DEFINE_TYPE_WITH_CODE (GtkSourceUndoManagerDefault,
                          G_IMPLEMENT_INTERFACE (GTK_SOURCE_TYPE_UNDO_MANAGER,
                                                 gtk_source_undo_manager_iface_init))
 
+/* Utilities functions */
+
+static void
+free_action (Action *action)
+{
+       if (action == NULL)
+       {
+               return;
+       }
+
+       switch (action->action_type)
+       {
+               case ACTION_TYPE_INSERT:
+                       g_free (action->action.insert.text);
+                       break;
+
+               case ACTION_TYPE_DELETE:
+                       g_free (action->action.delete.text);
+                       break;
+
+               default:
+                       g_return_if_reached ();
+                       break;
+       }
+
+       g_slice_free (Action, action);
+}
+
+static void
+free_action_group (ActionGroup *action_group)
+{
+       if (action_group != NULL)
+       {
+               g_queue_free_full (action_group->actions,
+                                  (GDestroyNotify) free_action);
+
+               g_slice_free (ActionGroup, action_group);
+       }
+}
+
 /* Buffer signal handlers */
 
 static void
@@ -275,6 +315,11 @@ gtk_source_undo_manager_default_dispose (GObject *object)
 static void
 gtk_source_undo_manager_default_finalize (GObject *object)
 {
+       GtkSourceUndoManagerDefault *manager = GTK_SOURCE_UNDO_MANAGER_DEFAULT (object);
+
+       g_queue_free_full (manager->priv->action_groups,
+                          (GDestroyNotify) free_action_group);
+
        G_OBJECT_CLASS (gtk_source_undo_manager_default_parent_class)->finalize (object);
 }
 
@@ -311,6 +356,8 @@ static void
 gtk_source_undo_manager_default_init (GtkSourceUndoManagerDefault *manager)
 {
        manager->priv = gtk_source_undo_manager_default_get_instance_private (manager);
+
+       manager->priv->action_groups = g_queue_new ();
 }
 
 /* Interface implementation */


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