[gtksourceview/wip/chergert/vim: 277/363] add format-text signal on im context
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/vim: 277/363] add format-text signal on im context
- Date: Mon, 8 Nov 2021 19:53:53 +0000 (UTC)
commit 1caf4257dbadc54cd5b8fbb26ac18a077906829a
Author: Christian Hergert <chergert redhat com>
Date: Wed Nov 3 17:38:37 2021 -0700
add format-text signal on im context
gtksourceview/gtksourcevimimcontext.c | 44 +++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
---
diff --git a/gtksourceview/gtksourcevimimcontext.c b/gtksourceview/gtksourcevimimcontext.c
index 7b846134..5b730a21 100644
--- a/gtksourceview/gtksourcevimimcontext.c
+++ b/gtksourceview/gtksourcevimimcontext.c
@@ -53,6 +53,7 @@ enum {
enum {
EXECUTE_COMMAND,
+ FORMAT_TEXT,
OBSERVE_KEY,
N_SIGNALS
};
@@ -109,6 +110,20 @@ on_vim_ready_cb (GtkSourceVimIMContext *self,
self->reset_observer = TRUE;
}
+static void
+on_vim_format_cb (GtkSourceVimIMContext *self,
+ GtkTextIter *begin,
+ GtkTextIter *end,
+ GtkSourceVim *vim)
+{
+ g_assert (GTK_SOURCE_IS_VIM_IM_CONTEXT (self));
+ g_assert (begin != NULL);
+ g_assert (end != NULL);
+ g_assert (GTK_SOURCE_IS_VIM (vim));
+
+ g_signal_emit (self, signals [FORMAT_TEXT], 0, begin, end);
+}
+
static void
gtk_source_vim_im_context_set_client_widget (GtkIMContext *context,
GtkWidget *widget)
@@ -137,6 +152,12 @@ gtk_source_vim_im_context_set_client_widget (GtkIMContext *context,
self,
G_CONNECT_SWAPPED);
+ g_signal_connect_object (self->vim,
+ "format",
+ G_CALLBACK (on_vim_format_cb),
+ self,
+ G_CONNECT_SWAPPED);
+
g_signal_connect_object (self->vim,
"ready",
G_CALLBACK (on_vim_ready_cb),
@@ -293,6 +314,29 @@ gtk_source_vim_im_context_class_init (GtkSourceVimIMContextClass *klass)
1,
G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE);
+ /**
+ * GtkSourceVimIMContext::format-text:
+ * @self: a #GtkSourceVimIMContext
+ * @begin: the start location
+ * @end: the end location
+ *
+ * Requests that the application format the text between
+ * @begin and @end.
+ *
+ * Since: 5.4
+ */
+ signals[FORMAT_TEXT] =
+ g_signal_new ("format-text",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ NULL,
+ G_TYPE_NONE,
+ 2,
+ GTK_TYPE_TEXT_ITER,
+ GTK_TYPE_TEXT_ITER);
+
signals[OBSERVE_KEY] =
g_signal_new ("observe-key",
G_TYPE_FROM_CLASS (klass),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]