[gnome-builder] gtk: add helper to check if an iter is visible.
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] gtk: add helper to check if an iter is visible.
- Date: Wed, 31 Dec 2014 23:09:06 +0000 (UTC)
commit c18aa8a740160ec28c5209cea6c36b942b4e0cb7
Author: Christian Hergert <christian hergert me>
Date: Wed Dec 31 15:08:11 2014 -0800
gtk: add helper to check if an iter is visible.
src/util/gb-gtk.c | 16 ++++++++++++++++
src/util/gb-gtk.h | 3 +++
2 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/src/util/gb-gtk.c b/src/util/gb-gtk.c
index 3055f39..c6e77b5 100644
--- a/src/util/gb-gtk.c
+++ b/src/util/gb-gtk.c
@@ -138,3 +138,19 @@ gb_gtk_text_view_scroll_to_iter (GtkTextView *text_view,
g_timeout_add (50, gb_gtk_text_view_scroll_to_iter_cb, state);
}
+
+gboolean
+gb_gtk_text_view_get_iter_visible (GtkTextView *text_view,
+ GtkTextIter *iter)
+{
+ GdkRectangle visible_rect;
+ GdkRectangle iter_location;
+
+ g_return_val_if_fail (GTK_IS_TEXT_VIEW (text_view), FALSE);
+ g_return_val_if_fail (iter, FALSE);
+
+ gtk_text_view_get_visible_rect (text_view, &visible_rect);
+ gtk_text_view_get_iter_location (text_view, iter, &iter_location);
+
+ return gdk_rectangle_intersect (&visible_rect, &iter_location, NULL);
+}
diff --git a/src/util/gb-gtk.h b/src/util/gb-gtk.h
index 21e3905..66304c4 100644
--- a/src/util/gb-gtk.h
+++ b/src/util/gb-gtk.h
@@ -35,6 +35,9 @@ void gb_gtk_text_view_scroll_to_iter (GtkTextView *text_view,
gdouble xalign,
gdouble yalign);
+gboolean gb_gtk_text_view_get_iter_visible (GtkTextView *text_view,
+ GtkTextIter *iter);
+
G_END_DECLS
#endif /* GB_GTK_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]