[gnome-builder/wip/vim] vim: add GbEditorVim:phrase property for observers
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/vim] vim: add GbEditorVim:phrase property for observers
- Date: Thu, 2 Oct 2014 10:10:20 +0000 (UTC)
commit c20d02c85448b7444338283f41e9989a670359aa
Author: Christian Hergert <christian hergert me>
Date: Thu Oct 2 02:55:58 2014 -0700
vim: add GbEditorVim:phrase property for observers
src/editor/gb-editor-vim.c | 43 +++++++++++++++++++++++++++++--------------
1 files changed, 29 insertions(+), 14 deletions(-)
---
diff --git a/src/editor/gb-editor-vim.c b/src/editor/gb-editor-vim.c
index 27eb511..8b4b515 100644
--- a/src/editor/gb-editor-vim.c
+++ b/src/editor/gb-editor-vim.c
@@ -118,6 +118,7 @@ enum
PROP_0,
PROP_ENABLED,
PROP_MODE,
+ PROP_PHRASE,
PROP_TEXT_VIEW,
LAST_PROP
};
@@ -351,6 +352,15 @@ gb_editor_vim_get_mode (GbEditorVim *vim)
return vim->priv->mode;
}
+static void
+gb_editor_vim_clear_phrase (GbEditorVim *vim)
+{
+ g_assert (GB_IS_EDITOR_VIM (vim));
+
+ g_string_truncate (vim->priv->phrase, 0);
+ g_object_notify_by_pspec (G_OBJECT (vim), gParamSpecs [PROP_PHRASE]);
+}
+
void
gb_editor_vim_set_mode (GbEditorVim *vim,
GbEditorVimMode mode)
@@ -393,7 +403,7 @@ gb_editor_vim_set_mode (GbEditorVim *vim,
/*
* Clear any in flight phrases.
*/
- g_string_truncate (vim->priv->phrase, 0);
+ gb_editor_vim_clear_phrase (vim);
/*
* If we are going back to navigation mode, stash our current buffer
@@ -1812,18 +1822,6 @@ gb_editor_vim_unindent (GbEditorVim *vim)
gb_source_view_unindent_selection (view);
}
-static void
-gb_editor_vim_clear_phrase (GbEditorVim *vim)
-{
- g_assert (GB_IS_EDITOR_VIM (vim));
-
- g_string_truncate (vim->priv->phrase, 0);
-
-#if 0
- g_object_notify_by_pspec (G_OBJECT (vim), gParamSpecs [PROP_PHRASE]);
-#endif
-}
-
static GbEditorVimPhraseStatus
gb_editor_vim_parse_phrase (GbEditorVim *vim,
GbEditorVimPhrase *phrase)
@@ -2010,7 +2008,10 @@ gb_editor_vim_handle_normal (GbEditorVim *vim,
*/
if (!gb_str_empty0 (event->string))
- g_string_append (vim->priv->phrase, event->string);
+ {
+ g_string_append (vim->priv->phrase, event->string);
+ g_object_notify_by_pspec (G_OBJECT (vim), gParamSpecs [PROP_PHRASE]);
+ }
status = gb_editor_vim_parse_phrase (vim, &phrase);
@@ -2491,6 +2492,10 @@ gb_editor_vim_get_property (GObject *object,
g_value_set_enum (value, gb_editor_vim_get_mode (vim));
break;
+ case PROP_PHRASE:
+ g_value_set_string (value, vim->priv->phrase->str);
+ break;
+
case PROP_TEXT_VIEW:
g_value_set_object (value, gb_editor_vim_get_text_view (vim));
break;
@@ -3128,6 +3133,16 @@ gb_editor_vim_class_init (GbEditorVimClass *klass)
g_object_class_install_property (object_class, PROP_MODE,
gParamSpecs [PROP_MODE]);
+ gParamSpecs [PROP_PHRASE] =
+ g_param_spec_string ("phrase",
+ _("Phrase"),
+ _("The current phrase input."),
+ NULL,
+ (G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class, PROP_PHRASE,
+ gParamSpecs [PROP_PHRASE]);
+
gParamSpecs [PROP_TEXT_VIEW] =
g_param_spec_object ("text-view",
_("Text View"),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]