[gtk/a11y/atspi-action: 1/4] Add GtkEntry icon signals emitter
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/a11y/atspi-action: 1/4] Add GtkEntry icon signals emitter
- Date: Thu, 15 Oct 2020 23:29:40 +0000 (UTC)
commit 9fcdf02dd30d9ac329d9025bd9e531e00fab6231
Author: Emmanuele Bassi <ebassi gnome org>
Date: Thu Oct 15 21:13:19 2020 +0100
Add GtkEntry icon signals emitter
We need a (private) way to programmatically trigger the activation of
the entry's icons, so that we can call it from the accessibility layer.
gtk/gtkentry.c | 33 +++++++++++++++++++++++++++++++++
gtk/gtkentryprivate.h | 3 +++
2 files changed, 36 insertions(+)
---
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 532d3896fe..3717dcea2a 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -3723,3 +3723,36 @@ gtk_entry_get_extra_menu (GtkEntry *entry)
return gtk_text_get_extra_menu (GTK_TEXT (priv->text));
}
+
+/*< private >
+ * gtk_entry_activate_icon:
+ * @entry: a #GtkEntry
+ * @pos: the icon position
+ *
+ * Emits the #GtkEntry::icon-press and #GtkEntry::icon-release signals on
+ * the @entry icon at the given @pos, if the icon is set and activatable.
+ *
+ * Returns: %TRUE if the signal was emitted
+ */
+gboolean
+gtk_entry_activate_icon (GtkEntry *entry,
+ GtkEntryIconPosition pos)
+{
+ GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry);
+ EntryIconInfo *icon_info;
+
+ g_return_val_if_fail (GTK_IS_ENTRY (entry), FALSE);
+
+ icon_info = priv->icons[pos];
+
+ if (icon_info != NULL &&
+ gtk_image_get_storage_type (GTK_IMAGE (icon_info->widget)) != GTK_IMAGE_EMPTY &&
+ !icon_info->nonactivatable)
+ {
+ g_signal_emit (entry, signals[ICON_PRESS], 0, pos);
+ g_signal_emit (entry, signals[ICON_RELEASE], 0, pos);
+ return TRUE;
+ }
+
+ return FALSE;
+}
diff --git a/gtk/gtkentryprivate.h b/gtk/gtkentryprivate.h
index eb98ac938d..05e4c6addb 100644
--- a/gtk/gtkentryprivate.h
+++ b/gtk/gtkentryprivate.h
@@ -106,6 +106,9 @@ GtkIMContext * _gtk_entry_get_im_context (GtkEntry *entry);
GtkEventController * gtk_entry_get_key_controller (GtkEntry *entry);
GtkText *gtk_entry_get_text_widget (GtkEntry *entry);
+gboolean gtk_entry_activate_icon (GtkEntry *entry,
+ GtkEntryIconPosition pos);
+
G_END_DECLS
#endif /* __GTK_ENTRY_PRIVATE_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]