[libgd] tagged-entry: Add method to get tag's position



commit 6bca681f549714171110e0b4ffa1f505627b348e
Author: Bastien Nocera <hadess hadess net>
Date:   Sun Jan 26 17:32:38 2014 +0100

    tagged-entry: Add method to get tag's position
    
    This is necessary to get GtkPopovers pointing to the tag, rather
    than the entry altogether.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=723030

 libgd/gd-tagged-entry.c |   27 +++++++++++++++++++++++++++
 libgd/gd-tagged-entry.h |    3 +++
 2 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/libgd/gd-tagged-entry.c b/libgd/gd-tagged-entry.c
index 42cdb9e..b92226b 100644
--- a/libgd/gd-tagged-entry.c
+++ b/libgd/gd-tagged-entry.c
@@ -394,6 +394,33 @@ gd_tagged_entry_tag_event_is_button (GdTaggedEntryTag *tag,
   return FALSE;
 }
 
+gboolean
+gd_tagged_entry_tag_get_area (GdTaggedEntryTag      *tag,
+                              cairo_rectangle_int_t *rect)
+{
+  GtkStyleContext *context;
+  GtkAllocation background_allocation;
+  int window_x, window_y;
+  GtkAllocation alloc;
+
+  g_return_val_if_fail (GD_IS_TAGGED_ENTRY_TAG (tag), FALSE);
+  g_return_val_if_fail (rect != NULL, FALSE);
+
+  gdk_window_get_position (tag->priv->window, &window_x, &window_y);
+  gtk_widget_get_allocation (GTK_WIDGET (tag->priv->entry), &alloc);
+  context = gd_tagged_entry_tag_get_context (tag, tag->priv->entry);
+  gd_tagged_entry_tag_get_relative_allocations (tag, tag->priv->entry, context,
+                                                &background_allocation,
+                                                NULL, NULL);
+
+  rect->x = window_x - alloc.x + background_allocation.x;
+  rect->y = window_y - alloc.y + background_allocation.y;
+  rect->width = background_allocation.width;
+  rect->height = background_allocation.height;
+
+  return TRUE;
+}
+
 static void
 gd_tagged_entry_tag_draw (GdTaggedEntryTag *tag,
                           cairo_t *cr,
diff --git a/libgd/gd-tagged-entry.h b/libgd/gd-tagged-entry.h
index 18b9d0f..ba9f673 100644
--- a/libgd/gd-tagged-entry.h
+++ b/libgd/gd-tagged-entry.h
@@ -109,6 +109,9 @@ void gd_tagged_entry_tag_set_style (GdTaggedEntryTag *tag,
                                     const gchar *style);
 const gchar *gd_tagged_entry_tag_get_style (GdTaggedEntryTag *tag);
 
+gboolean gd_tagged_entry_tag_get_area (GdTaggedEntryTag      *tag,
+                                       cairo_rectangle_int_t *rect);
+
 G_END_DECLS
 
 #endif /* __GD_TAGGED_ENTRY_H__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]