[gtk+] gtk: add gtk_entry_get_text_area() and gtk_entry_get_icon_area()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] gtk: add gtk_entry_get_text_area() and gtk_entry_get_icon_area()
- Date: Fri, 22 Oct 2010 12:48:33 +0000 (UTC)
commit ba9efeda4bc0f8013b455e339963d93d6f4ee874
Author: Michael Natterer <mitch gimp org>
Date: Fri Oct 22 14:46:48 2010 +0200
gtk: add gtk_entry_get_text_area() and gtk_entry_get_icon_area()
as replacement for the removed get_foo_window() functions, so draw()
callbacks can figure where to paint.
gtk/gtk.symbols | 2 +
gtk/gtkentry.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
gtk/gtkentry.h | 6 ++++
3 files changed, 99 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index 8020851..a2aeaf4 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -1075,6 +1075,7 @@ gtk_entry_get_current_icon_drag_source
gtk_entry_get_cursor_hadjustment
gtk_entry_get_has_frame
gtk_entry_get_icon_activatable
+gtk_entry_get_icon_area
gtk_entry_get_icon_at_pos
gtk_entry_get_icon_gicon
gtk_entry_get_icon_name
@@ -1093,6 +1094,7 @@ gtk_entry_get_overwrite_mode
gtk_entry_get_progress_fraction
gtk_entry_get_progress_pulse_step
gtk_entry_get_text
+gtk_entry_get_text_area
gtk_entry_get_text_length
gtk_entry_get_type G_GNUC_CONST
gtk_entry_get_visibility
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 7a041ca..4d10e36 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -6656,6 +6656,47 @@ gtk_entry_set_buffer (GtkEntry *entry,
}
/**
+ * gtk_entry_get_text_area:
+ * @entry: a #GtkEntry
+ * @text_area: Return location for the text area.
+ *
+ * Returns the area where the entry's text is drawn. This function is
+ * useful when drawing something to the entry in a draw callback.
+ *
+ * See also gtk_entry_get_icon_area().
+ *
+ * Since: 3.0
+ **/
+void
+gtk_entry_get_text_area (GtkEntry *entry,
+ GdkRectangle *text_area)
+{
+ g_return_if_fail (GTK_IS_ENTRY (entry));
+ g_return_if_fail (text_area != NULL);
+
+ if (entry->text_area)
+ {
+ GtkAllocation allocation;
+ gint x, y;
+
+ gtk_widget_get_allocation (GTK_WIDGET (entry), &allocation);
+ gdk_window_get_position (entry->text_area, &x, &y);
+
+ text_area->x = x - allocation.x;
+ text_area->y = y - allocation.y;
+ text_area->width = gdk_window_get_width (entry->text_area);
+ text_area->height = gdk_window_get_height (entry->text_area);
+ }
+ else
+ {
+ text_area->x = 0;
+ text_area->y = 0;
+ text_area->width = 0;
+ text_area->height = 0;
+ }
+}
+
+/**
* gtk_entry_set_text:
* @entry: a #GtkEntry
* @text: the new text
@@ -8064,6 +8105,56 @@ gtk_entry_get_current_icon_drag_source (GtkEntry *entry)
return -1;
}
+/**
+ * gtk_entry_get_icon_area:
+ * @entry: A #GtkEntry
+ * @icon_pos: Icon position
+ * @icon_area: Return location for the icon's area
+ *
+ * Returns the area where entry's icon at @icon_pos is drawn.
+ * This function is useful when drawing something to the
+ * entry in a draw callback.
+ *
+ * See also gtk_entry_get_text_area()
+ *
+ * Since: 3.0
+ */
+void
+gtk_entry_get_icon_area (GtkEntry *entry,
+ GtkEntryIconPosition icon_pos,
+ GdkRectangle *icon_area)
+{
+ GtkEntryPrivate *priv;
+ EntryIconInfo *icon_info;
+
+ g_return_if_fail (GTK_IS_ENTRY (entry));
+ g_return_if_fail (icon_area != NULL);
+
+ priv = GTK_ENTRY_GET_PRIVATE (entry);
+
+ icon_info = priv->icons[icon_pos];
+
+ if (icon_info)
+ {
+ GtkAllocation primary;
+ GtkAllocation secondary;
+
+ get_icon_allocations (entry, &primary, &secondary);
+
+ if (icon_pos == GTK_ENTRY_ICON_PRIMARY)
+ *icon_area = primary;
+ else
+ *icon_area = secondary;
+ }
+ else
+ {
+ icon_area->x = 0;
+ icon_area->y = 0;
+ icon_area->width = 0;
+ icon_area->height = 0;
+ }
+}
+
static void
ensure_has_tooltip (GtkEntry *entry)
{
diff --git a/gtk/gtkentry.h b/gtk/gtkentry.h
index 365e409..2810bbf 100644
--- a/gtk/gtkentry.h
+++ b/gtk/gtkentry.h
@@ -172,6 +172,9 @@ GtkEntryBuffer* gtk_entry_get_buffer (GtkEntry *entry);
void gtk_entry_set_buffer (GtkEntry *entry,
GtkEntryBuffer *buffer);
+void gtk_entry_get_text_area (GtkEntry *entry,
+ GdkRectangle *text_area);
+
void gtk_entry_set_visibility (GtkEntry *entry,
gboolean visible);
gboolean gtk_entry_get_visibility (GtkEntry *entry);
@@ -301,6 +304,9 @@ void gtk_entry_set_icon_drag_source (GtkEntry *
GtkTargetList *target_list,
GdkDragAction actions);
gint gtk_entry_get_current_icon_drag_source (GtkEntry *entry);
+void gtk_entry_get_icon_area (GtkEntry *entry,
+ GtkEntryIconPosition icon_pos,
+ GdkRectangle *icon_area);
gboolean gtk_entry_im_context_filter_keypress (GtkEntry *entry,
GdkEventKey *event);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]