[gtk+/wip/matthiasc/kill-device-manager: 3/14] Add emoji completion to GtkEntry
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/matthiasc/kill-device-manager: 3/14] Add emoji completion to GtkEntry
- Date: Thu, 23 Nov 2017 21:39:15 +0000 (UTC)
commit 22fdee7dca8396fea5605715ff47ad2ff49e67c5
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Aug 19 14:08:15 2017 -0400
Add emoji completion to GtkEntry
This functionality has to be enabled using the enable-emoji-completion
property.
gtk/gtkentry.c | 40 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 40 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index f4ba6b4..6431996 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -71,6 +71,7 @@
#include "gtkcssnodeprivate.h"
#include "gtkimageprivate.h"
#include "gtkemojichooser.h"
+#include "gtkemojicompletion.h"
#include "a11y/gtkentryaccessible.h"
@@ -244,6 +245,7 @@ struct _GtkEntryPrivate
guint editable : 1;
guint show_emoji_icon : 1;
+ guint enable_emoji_completion : 1;
guint in_drag : 1;
guint overwrite_mode : 1;
guint visible : 1;
@@ -365,6 +367,7 @@ enum {
PROP_POPULATE_ALL,
PROP_TABS,
PROP_SHOW_EMOJI_ICON,
+ PROP_ENABLE_EMOJI_COMPLETION,
PROP_EDITING_CANCELED,
NUM_PROPERTIES = PROP_EDITING_CANCELED
};
@@ -652,6 +655,8 @@ static void buffer_disconnect_signals (GtkEntry *entry);
static GtkEntryBuffer *get_buffer (GtkEntry *entry);
static void set_show_emoji_icon (GtkEntry *entry,
gboolean value);
+static void set_enable_emoji_completion (GtkEntry *entry,
+ gboolean value);
static void gtk_entry_measure (GtkWidget *widget,
GtkOrientation orientation,
@@ -1398,6 +1403,13 @@ gtk_entry_class_init (GtkEntryClass *class)
FALSE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
+ entry_props[PROP_ENABLE_EMOJI_COMPLETION] =
+ g_param_spec_boolean ("enable-emoji-completion",
+ P_("Enable Emoji completion"),
+ P_("Whether to suggest Emoji replacements"),
+ FALSE,
+ GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
+
g_object_class_install_properties (gobject_class, NUM_PROPERTIES, entry_props);
/**
@@ -2184,6 +2196,10 @@ gtk_entry_set_property (GObject *object,
set_show_emoji_icon (entry, g_value_get_boolean (value));
break;
+ case PROP_ENABLE_EMOJI_COMPLETION:
+ set_enable_emoji_completion (entry, g_value_get_boolean (value));
+ break;
+
case PROP_SCROLL_OFFSET:
case PROP_CURSOR_POSITION:
default:
@@ -2416,6 +2432,10 @@ gtk_entry_get_property (GObject *object,
g_value_set_boolean (value, priv->show_emoji_icon);
break;
+ case PROP_ENABLE_EMOJI_COMPLETION:
+ g_value_set_boolean (value, priv->enable_emoji_completion);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -9954,3 +9974,23 @@ set_show_emoji_icon (GtkEntry *entry,
g_object_notify_by_pspec (G_OBJECT (entry), entry_props[PROP_SHOW_EMOJI_ICON]);
gtk_widget_queue_resize (GTK_WIDGET (entry));
}
+
+static void
+set_enable_emoji_completion (GtkEntry *entry,
+ gboolean value)
+{
+ GtkEntryPrivate *priv = entry->priv;
+
+ if (priv->enable_emoji_completion == value)
+ return;
+
+ priv->enable_emoji_completion = value;
+
+ if (priv->enable_emoji_completion)
+ g_object_set_data_full (G_OBJECT (entry), "emoji-completion-popup",
+ gtk_emoji_completion_new (entry), (GDestroyNotify)gtk_widget_destroy);
+ else
+ g_object_set_data (G_OBJECT (entry), "emoji-completion-popup", NULL);
+
+ g_object_notify_by_pspec (G_OBJECT (entry), entry_props[PROP_ENABLE_EMOJI_COMPLETION]);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]