From 88977f73ebc235e7fb36a7f1752145249b36a426 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Fri, 22 Jan 2010 17:20:01 +0100 Subject: [PATCH] Bug 607778 - Add accessors for GtkEntry's windows Add gtk_entry_get_text_window() and get_icon_window() so we can distinguigh them in expose-event callbacks. --- gtk/gtk.symbols | 2 ++ gtk/gtkentry.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ gtk/gtkentry.h | 13 +++++++++++ 3 files changed, 73 insertions(+) diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols index dccf5564cf..c959c7f6f6 100644 --- a/gtk/gtk.symbols +++ b/gtk/gtk.symbols @@ -1368,6 +1368,7 @@ gtk_entry_get_icon_stock gtk_entry_get_icon_storage_type gtk_entry_get_icon_tooltip_markup gtk_entry_get_icon_tooltip_text +gtk_entry_get_icon_window gtk_entry_get_inner_border gtk_entry_get_invisible_char gtk_entry_get_layout @@ -1381,6 +1382,7 @@ gtk_entry_get_text_length gtk_entry_get_type G_GNUC_CONST gtk_entry_get_visibility gtk_entry_get_width_chars +gtk_entry_get_text_window gtk_entry_layout_index_to_text_index gtk_entry_new gtk_entry_new_with_buffer diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index a04b83f547..31637b71b1 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -6703,6 +6703,29 @@ gtk_entry_set_buffer (GtkEntry *entry, g_object_thaw_notify (obj); } +/** + * gtk_entry_get_text_window: + * @entry: a #GtkEntry + * + * Returns the #GdkWindow which contains the text. This function is + * useful when drawing something to the entry in an expose-event + * callback because it enables the callback to distinguish between + * the text window and entry's icon windows. + * + * See also gtk_entry_get_icon_window(). + * + * Return value: the entry's text window. + * + * Since: 2.20 + **/ +GdkWindow * +gtk_entry_get_text_window (GtkEntry *entry) +{ + g_return_val_if_fail (GTK_IS_ENTRY (entry), NULL); + + return entry->text_area; +} + /** * gtk_entry_set_text: @@ -8218,6 +8241,41 @@ gtk_entry_get_current_icon_drag_source (GtkEntry *entry) return -1; } +/** + * gtk_entry_get_icon_window: + * @entry: A #GtkEntry + * @icon_pos: Icon position + * + * Returns the #GdkWindow which contains the entry's icon at + * @icon_pos. This function is useful when drawing something to the + * entry in an expose-event callback because it enables the callback + * to distinguish between the text window and entry's icon windows. + * + * See also gtk_entry_get_text_window(). + * + * Return value: the entry's icon window at @icon_pos. + * + * Since: 2.20 + */ +GdkWindow * +gtk_entry_get_icon_window (GtkEntry *entry, + GtkEntryIconPosition icon_pos) +{ + GtkEntryPrivate *priv; + EntryIconInfo *icon_info; + + g_return_val_if_fail (GTK_IS_ENTRY (entry), NULL); + + priv = GTK_ENTRY_GET_PRIVATE (entry); + + icon_info = priv->icons[icon_pos]; + + if (icon_info) + return icon_info->window; + + return NULL; +} + static void ensure_has_tooltip (GtkEntry *entry) { diff --git a/gtk/gtkentry.h b/gtk/gtkentry.h index d7f4bfb0f5..0c82c63224 100644 --- a/gtk/gtkentry.h +++ b/gtk/gtkentry.h @@ -166,30 +166,40 @@ struct _GtkEntryClass GType gtk_entry_get_type (void) G_GNUC_CONST; GtkWidget* gtk_entry_new (void); GtkWidget* gtk_entry_new_with_buffer (GtkEntryBuffer *buffer); + GtkEntryBuffer* gtk_entry_get_buffer (GtkEntry *entry); void gtk_entry_set_buffer (GtkEntry *entry, GtkEntryBuffer *buffer); + +GdkWindow *gtk_entry_get_text_window (GtkEntry *entry); + void gtk_entry_set_visibility (GtkEntry *entry, gboolean visible); gboolean gtk_entry_get_visibility (GtkEntry *entry); + void gtk_entry_set_invisible_char (GtkEntry *entry, gunichar ch); gunichar gtk_entry_get_invisible_char (GtkEntry *entry); void gtk_entry_unset_invisible_char (GtkEntry *entry); + void gtk_entry_set_has_frame (GtkEntry *entry, gboolean setting); gboolean gtk_entry_get_has_frame (GtkEntry *entry); + void gtk_entry_set_inner_border (GtkEntry *entry, const GtkBorder *border); G_CONST_RETURN GtkBorder* gtk_entry_get_inner_border (GtkEntry *entry); + void gtk_entry_set_overwrite_mode (GtkEntry *entry, gboolean overwrite); gboolean gtk_entry_get_overwrite_mode (GtkEntry *entry); + /* text is truncated if needed */ void gtk_entry_set_max_length (GtkEntry *entry, gint max); gint gtk_entry_get_max_length (GtkEntry *entry); guint16 gtk_entry_get_text_length (GtkEntry *entry); + void gtk_entry_set_activates_default (GtkEntry *entry, gboolean setting); gboolean gtk_entry_get_activates_default (GtkEntry *entry); @@ -293,6 +303,9 @@ void gtk_entry_set_icon_drag_source (GtkEntry * GdkDragAction actions); gint gtk_entry_get_current_icon_drag_source (GtkEntry *entry); +GdkWindow * gtk_entry_get_icon_window (GtkEntry *entry, + GtkEntryIconPosition icon_pos); + /* Deprecated compatibility functions */