[gtksourceview/wip/chergert/vim] add set parent helper



commit ae1e57fe87ff3fe7ee875c12be573ef5c6edabfa
Author: Christian Hergert <chergert redhat com>
Date:   Thu Oct 28 14:17:41 2021 -0700

    add set parent helper
    
    for cases where we want a child state, but not *the* child for events.

 gtksourceview/vim/gtk-source-vim-state.c | 19 +++++++++++++++++++
 gtksourceview/vim/gtk-source-vim-state.h |  2 ++
 2 files changed, 21 insertions(+)
---
diff --git a/gtksourceview/vim/gtk-source-vim-state.c b/gtksourceview/vim/gtk-source-vim-state.c
index c41a238b..6ca165f2 100644
--- a/gtksourceview/vim/gtk-source-vim-state.c
+++ b/gtksourceview/vim/gtk-source-vim-state.c
@@ -785,3 +785,22 @@ gtk_source_vim_state_set_count (GtkSourceVimState *self,
 
        priv->count = count ? count : 1;
 }
+
+void
+gtk_source_vim_state_set_parent (GtkSourceVimState *self,
+                                 GtkSourceVimState *parent)
+{
+       GtkSourceVimStatePrivate *priv = gtk_source_vim_state_get_instance_private (self);
+       GtkSourceVimStatePrivate *parent_priv = gtk_source_vim_state_get_instance_private (parent);
+
+       g_return_if_fail (GTK_SOURCE_IS_VIM_STATE (self));
+       g_return_if_fail (!parent || GTK_SOURCE_IS_VIM_STATE (parent));
+
+       if (parent != NULL && parent_priv->child == self)
+               parent_priv->child = NULL;
+
+       if (g_set_object (&priv->parent, parent))
+       {
+               g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_PARENT]);
+       }
+}
diff --git a/gtksourceview/vim/gtk-source-vim-state.h b/gtksourceview/vim/gtk-source-vim-state.h
index 2ade8ab1..43061a70 100644
--- a/gtksourceview/vim/gtk-source-vim-state.h
+++ b/gtksourceview/vim/gtk-source-vim-state.h
@@ -57,6 +57,8 @@ struct _GtkSourceVimStateClass
                                     GString           *string);
 };
 
+void               gtk_source_vim_state_set_parent            (GtkSourceVimState *self,
+                                                               GtkSourceVimState *parent);
 void               gtk_source_vim_state_push                  (GtkSourceVimState *self,
                                                                GtkSourceVimState *new_state);
 void               gtk_source_vim_state_pop                   (GtkSourceVimState *self);


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