[gtk/matthiasc/for-master: 6/9] text: Add some missing setters and getters
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master: 6/9] text: Add some missing setters and getters
- Date: Sat, 3 Oct 2020 17:11:37 +0000 (UTC)
commit 1b1bf6c90aa15d2e1c63cb786f4b676eeb20158c
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Oct 3 12:20:58 2020 -0400
text: Add some missing setters and getters
Add getters and setters for the enable-emoji-completion,
propagate-text-width and truncate-multiline properties.
docs/reference/gtk/gtk4-sections.txt | 6 ++
gtk/gtktext.c | 172 ++++++++++++++++++++++++++++-------
gtk/gtktext.h | 21 +++++
3 files changed, 166 insertions(+), 33 deletions(-)
---
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index eca66b8690..a2e4dbc60a 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -1030,6 +1030,12 @@ gtk_text_get_tabs
gtk_text_grab_focus_without_selecting
gtk_text_set_extra_menu
gtk_text_get_extra_menu
+gtk_text_set_enable_emoji_completion
+gtk_text_get_enable_emoji_completion
+gtk_text_set_propagate_text_width
+gtk_text_get_propagate_text_width
+gtk_text_set_truncate_multiline
+gtk_text_get_truncate_multiline
<SUBSECTION Private>
gtk_text_get_type
</SECTION>
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index da11cffe9b..6910aeff8b 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -526,8 +526,6 @@ static void gtk_text_get_scroll_limits (GtkText *self,
int *min_offset,
int *max_offset);
static GtkEntryBuffer *get_buffer (GtkText *self);
-static void set_enable_emoji_completion (GtkText *self,
- gboolean value);
static void set_text_cursor (GtkWidget *widget);
static void update_placeholder_visibility (GtkText *self);
@@ -1597,11 +1595,7 @@ gtk_text_set_property (GObject *object,
break;
case PROP_TRUNCATE_MULTILINE:
- if (priv->truncate_multiline != g_value_get_boolean (value))
- {
- priv->truncate_multiline = g_value_get_boolean (value);
- g_object_notify_by_pspec (object, pspec);
- }
+ gtk_text_set_truncate_multiline (self, g_value_get_boolean (value));
break;
case PROP_OVERWRITE_MODE:
@@ -1644,16 +1638,11 @@ gtk_text_set_property (GObject *object,
break;
case PROP_ENABLE_EMOJI_COMPLETION:
- set_enable_emoji_completion (self, g_value_get_boolean (value));
+ gtk_text_set_enable_emoji_completion (self, g_value_get_boolean (value));
break;
case PROP_PROPAGATE_TEXT_WIDTH:
- if (priv->propagate_text_width != g_value_get_boolean (value))
- {
- priv->propagate_text_width = g_value_get_boolean (value);
- gtk_widget_queue_resize (GTK_WIDGET (self));
- g_object_notify_by_pspec (object, pspec);
- }
+ gtk_text_set_propagate_text_width (self, g_value_get_boolean (value));
break;
case PROP_EXTRA_MENU:
@@ -6849,25 +6838,6 @@ gtk_text_insert_emoji (GtkText *self)
gtk_popover_popup (GTK_POPOVER (chooser));
}
-static void
-set_enable_emoji_completion (GtkText *self,
- gboolean value)
-{
- GtkTextPrivate *priv = gtk_text_get_instance_private (self);
-
- if (priv->enable_emoji_completion == value)
- return;
-
- priv->enable_emoji_completion = value;
-
- if (priv->enable_emoji_completion)
- priv->emoji_completion = gtk_emoji_completion_new (self);
- else
- g_clear_pointer (&priv->emoji_completion, gtk_widget_unparent);
-
- g_object_notify_by_pspec (G_OBJECT (self), text_props[PROP_ENABLE_EMOJI_COMPLETION]);
-}
-
static void
set_text_cursor (GtkWidget *widget)
{
@@ -6924,6 +6894,142 @@ gtk_text_get_extra_menu (GtkText *self)
return priv->extra_menu;
}
+/**
+ * gtk_text_set_enable_emoji_completion:
+ * @self: a #GtkText
+ * @enable_emoji_completion: %TRUE to enable Emoji completion
+ *
+ * Sets whether Emoji completion is enabled. If it is,
+ * typing ':', followed by a recognized keyword, will pop
+ * up a window with suggested Emojis matching the keyword.
+ */
+void
+gtk_text_set_enable_emoji_completion (GtkText *self,
+ gboolean enable_emoji_completion)
+{
+ GtkTextPrivate *priv = gtk_text_get_instance_private (self);
+
+ g_return_if_fail (GTK_IS_TEXT (self));
+
+ if (priv->enable_emoji_completion == enable_emoji_completion)
+ return;
+
+ priv->enable_emoji_completion = enable_emoji_completion;
+
+ if (priv->enable_emoji_completion)
+ priv->emoji_completion = gtk_emoji_completion_new (self);
+ else
+ g_clear_pointer (&priv->emoji_completion, gtk_widget_unparent);
+
+ g_object_notify_by_pspec (G_OBJECT (self), text_props[PROP_ENABLE_EMOJI_COMPLETION]);
+}
+
+/**
+ * gtk_text_get_enable_emoji_completion:
+ * @self: a #GtkText
+ *
+ * Returns whether Emoji completion is enabled for this
+ * GtkText widget.
+ *
+ * Returns: %TRUE if Emoji completion is enabled
+ */
+gboolean
+gtk_text_get_enable_emoji_completion (GtkText *self)
+{
+ GtkTextPrivate *priv = gtk_text_get_instance_private (self);
+
+ g_return_val_if_fail (GTK_IS_TEXT (self), FALSE);
+
+ return priv->enable_emoji_completion;
+}
+
+/**
+ * gtk_text_set_propagate_text_width:
+ * @self: a #GtkText
+ * @propagate_text_width: %TRUE to propagate the text width
+ *
+ * Sets whether the GtkText should grow and shrink with the content.
+ */
+void
+gtk_text_set_propagate_text_width (GtkText *self,
+ gboolean propagate_text_width)
+{
+ GtkTextPrivate *priv = gtk_text_get_instance_private (self);
+
+ g_return_if_fail (GTK_IS_TEXT (self));
+
+ if (priv->propagate_text_width == propagate_text_width)
+ return;
+
+ priv->propagate_text_width = propagate_text_width;
+
+ gtk_widget_queue_resize (GTK_WIDGET (self));
+
+ g_object_notify_by_pspec (G_OBJECT (self), text_props[PROP_PROPAGATE_TEXT_WIDTH]);
+}
+
+/**
+ * gtk_text_get_propagate_text_width:
+ * @self: a #GtkText
+ *
+ * Returns whether the #GtkText will grow and shrink
+ * with the content.
+ *
+ * Returns: %TRUE if @self will propagate the text width
+ */
+gboolean
+gtk_text_get_propagate_text_width (GtkText *self)
+{
+ GtkTextPrivate *priv = gtk_text_get_instance_private (self);
+
+ g_return_val_if_fail (GTK_IS_TEXT (self), FALSE);
+
+ return priv->propagate_text_width;
+}
+
+/**
+ * gtk_text_set_truncate_multiline:
+ * @self: a #GtkText
+ * @truncate_multiline: %TRUE to truncate multi-line text
+ *
+ * Sets whether the GtkText should truncate multi-line text
+ * that is pasted into the widget.
+ */
+void
+gtk_text_set_truncate_multiline (GtkText *self,
+ gboolean truncate_multiline)
+{
+ GtkTextPrivate *priv = gtk_text_get_instance_private (self);
+
+ g_return_if_fail (GTK_IS_TEXT (self));
+
+ if (priv->truncate_multiline == truncate_multiline)
+ return;
+
+ priv->truncate_multiline = truncate_multiline;
+
+ g_object_notify_by_pspec (G_OBJECT (self), text_props[PROP_TRUNCATE_MULTILINE]);
+}
+
+/**
+ * gtk_text_get_truncate_multiline:
+ * @self: a #GtkText
+ *
+ * Returns whether the #GtkText will truncate multi-line text
+ * that is pasted into the widget
+ *
+ * Returns: %TRUE if @self will truncate multi-line text
+ */
+gboolean
+gtk_text_get_truncate_multiline (GtkText *self)
+{
+ GtkTextPrivate *priv = gtk_text_get_instance_private (self);
+
+ g_return_val_if_fail (GTK_IS_TEXT (self), FALSE);
+
+ return priv->truncate_multiline;
+}
+
static void
gtk_text_real_undo (GtkWidget *widget,
const char *action_name,
diff --git a/gtk/gtktext.h b/gtk/gtktext.h
index 0fa6db6c5e..38ae25c421 100644
--- a/gtk/gtktext.h
+++ b/gtk/gtktext.h
@@ -140,6 +140,27 @@ void gtk_text_set_extra_menu (GtkText *self,
GDK_AVAILABLE_IN_ALL
GMenuModel * gtk_text_get_extra_menu (GtkText *self);
+GDK_AVAILABLE_IN_ALL
+void gtk_text_set_enable_emoji_completion (GtkText *self,
+ gboolean enable_emoji_completion);
+GDK_AVAILABLE_IN_ALL
+gboolean gtk_text_get_enable_emoji_completion (GtkText *self);
+
+
+GDK_AVAILABLE_IN_ALL
+void gtk_text_set_propagate_text_width (GtkText *self,
+ gboolean propagate_text_width);
+GDK_AVAILABLE_IN_ALL
+gboolean gtk_text_get_propagate_text_width (GtkText *self);
+
+GDK_AVAILABLE_IN_ALL
+void gtk_text_set_truncate_multiline (GtkText *self,
+ gboolean truncate_multiline);
+GDK_AVAILABLE_IN_ALL
+gboolean gtk_text_get_truncate_multiline (GtkText *self);
+
+
+
G_END_DECLS
#endif /* __GTK_TEXT_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]