[gtk/preedit-highlight: 1/3] imcontext: Define a pango attribute for highlight
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/preedit-highlight: 1/3] imcontext: Define a pango attribute for highlight
- Date: Wed, 13 Jul 2022 21:09:58 +0000 (UTC)
commit e09d2a676cf77fadc41709fcc22c5471f4c52a9d
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Jul 13 17:00:59 2022 -0400
imcontext: Define a pango attribute for highlight
Define our own PangoAttribute type for IM Context
properties. Currently, the only defined property
is for marking the highlighted region.
gtk/gtkimcontext.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
gtk/gtkimcontext.h | 10 ++++++++++
2 files changed, 57 insertions(+)
---
diff --git a/gtk/gtkimcontext.c b/gtk/gtkimcontext.c
index a46f5d7571..2577d27718 100644
--- a/gtk/gtkimcontext.c
+++ b/gtk/gtkimcontext.c
@@ -1005,3 +1005,50 @@ gtk_im_context_set_property (GObject *obj,
break;
}
}
+
+
+static PangoAttribute *
+attr_preedit_properties_copy (const PangoAttribute *attr)
+{
+ const PangoAttrInt *int_attr = (PangoAttrInt *)attr;
+
+ return gtk_im_context_preedit_attr_new (int_attr->value);
+}
+
+static void
+attr_preedit_properties_destroy (PangoAttribute *attr)
+{
+ PangoAttrInt *iattr = (PangoAttrInt *)attr;
+
+ g_slice_free (PangoAttrInt, iattr);
+}
+
+static gboolean
+attr_preedit_properties_equal (const PangoAttribute *attr1,
+ const PangoAttribute *attr2)
+{
+ const PangoAttrInt *int_attr1 = (const PangoAttrInt *)attr1;
+ const PangoAttrInt *int_attr2 = (const PangoAttrInt *)attr2;
+
+ return (int_attr1->value == int_attr2->value);
+}
+
+PangoAttribute *
+gtk_im_context_preedit_attr_new (GtkIMContextPreeditProperties value)
+{
+ PangoAttrInt *result = g_slice_new (PangoAttrInt);
+ static PangoAttrClass klass = {
+ 0,
+ attr_preedit_properties_copy,
+ attr_preedit_properties_destroy,
+ attr_preedit_properties_equal
+ };
+
+ if (!klass.type)
+ klass.type = pango_attr_type_register ("GtkIMContextPreeditProperties");
+
+ pango_attribute_init (&result->attr, &klass);
+ result->value = value;
+
+ return (PangoAttribute *)result;
+}
diff --git a/gtk/gtkimcontext.h b/gtk/gtkimcontext.h
index d4268d7e12..6c3bfd66ee 100644
--- a/gtk/gtkimcontext.h
+++ b/gtk/gtkimcontext.h
@@ -168,6 +168,16 @@ gboolean gtk_im_context_delete_surrounding (GtkIMContext *context,
int offset,
int n_chars);
+
+typedef enum
+{
+ GTK_IM_CONTEXT_PREEDIT_CURSOR,
+} GtkIMContextPreeditProperties;
+
+GDK_AVAILABLE_IN_4_8
+PangoAttribute * gtk_im_context_preedit_attr_new (GtkIMContextPreeditProperties value);
+
+
G_END_DECLS
#endif /* __GTK_IM_CONTEXT_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]