summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2004-12-08 21:25:08 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2004-12-08 21:25:08 +0000
commit057ab5a4dfb083878ee075a92ece949870aa7c56 (patch)
treeb6cdd0dbf888a0096b90d6f24a8c1eda4ed49d83
parent456ebcea28c2598882069d97381ff7e223fc4a99 (diff)
downloadgdk-pixbuf-057ab5a4dfb083878ee075a92ece949870aa7c56.tar.gz
Fix #111031, reported by Padraig O'Briain:
2004-12-08 Matthias Clasen <mclasen@redhat.com> Fix #111031, reported by Padraig O'Briain: * gtk/gtktextlayout.h: * gtk/gtktextlayout.c (gtk_text_layout_get_iter_at_position): Add a variant of gtk_text_layout_get_iter_at_pixel() which returns the character at the position, not the closest cursor position. * gtk/gtktextview.h: * gtk/gtktextview.c (gtk_text_view_get_iter_at_position): Add a variant of gtk_text_view_get_iter_at_location() which returns the character at the position, not the closest cursor position.
-rw-r--r--ChangeLog16
-rw-r--r--ChangeLog.pre-2-1016
-rw-r--r--ChangeLog.pre-2-616
-rw-r--r--ChangeLog.pre-2-816
-rw-r--r--docs/reference/ChangeLog4
-rw-r--r--docs/reference/gtk/gtk-sections.txt1
-rw-r--r--gtk/gtktextlayout.c27
-rw-r--r--gtk/gtktextlayout.h5
-rw-r--r--gtk/gtktextview.c41
-rw-r--r--gtk/gtktextview.h5
10 files changed, 138 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 2f3a5c5d5..9ec2954ba 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
2004-12-08 Matthias Clasen <mclasen@redhat.com>
+ Fix #111031, reported by Padraig O'Briain:
+
+ * gtk/gtktextlayout.h:
+ * gtk/gtktextlayout.c (gtk_text_layout_get_iter_at_position):
+ Add a variant of gtk_text_layout_get_iter_at_pixel() which
+ returns the character at the position, not the closest
+ cursor position.
+
+ * gtk/gtktextview.h:
+ * gtk/gtktextview.c (gtk_text_view_get_iter_at_position):
+ Add a variant of gtk_text_view_get_iter_at_location() which
+ returns the character at the position, not the closest
+ cursor position.
+
+2004-12-08 Matthias Clasen <mclasen@redhat.com>
+
* gtk/gtkaccelmap.c (internal_change_entry): Remove all
entries for the same key, not just the first one. (#159498,
Christian Persch)
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index 2f3a5c5d5..9ec2954ba 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -1,5 +1,21 @@
2004-12-08 Matthias Clasen <mclasen@redhat.com>
+ Fix #111031, reported by Padraig O'Briain:
+
+ * gtk/gtktextlayout.h:
+ * gtk/gtktextlayout.c (gtk_text_layout_get_iter_at_position):
+ Add a variant of gtk_text_layout_get_iter_at_pixel() which
+ returns the character at the position, not the closest
+ cursor position.
+
+ * gtk/gtktextview.h:
+ * gtk/gtktextview.c (gtk_text_view_get_iter_at_position):
+ Add a variant of gtk_text_view_get_iter_at_location() which
+ returns the character at the position, not the closest
+ cursor position.
+
+2004-12-08 Matthias Clasen <mclasen@redhat.com>
+
* gtk/gtkaccelmap.c (internal_change_entry): Remove all
entries for the same key, not just the first one. (#159498,
Christian Persch)
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index 2f3a5c5d5..9ec2954ba 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -1,5 +1,21 @@
2004-12-08 Matthias Clasen <mclasen@redhat.com>
+ Fix #111031, reported by Padraig O'Briain:
+
+ * gtk/gtktextlayout.h:
+ * gtk/gtktextlayout.c (gtk_text_layout_get_iter_at_position):
+ Add a variant of gtk_text_layout_get_iter_at_pixel() which
+ returns the character at the position, not the closest
+ cursor position.
+
+ * gtk/gtktextview.h:
+ * gtk/gtktextview.c (gtk_text_view_get_iter_at_position):
+ Add a variant of gtk_text_view_get_iter_at_location() which
+ returns the character at the position, not the closest
+ cursor position.
+
+2004-12-08 Matthias Clasen <mclasen@redhat.com>
+
* gtk/gtkaccelmap.c (internal_change_entry): Remove all
entries for the same key, not just the first one. (#159498,
Christian Persch)
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index 2f3a5c5d5..9ec2954ba 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -1,5 +1,21 @@
2004-12-08 Matthias Clasen <mclasen@redhat.com>
+ Fix #111031, reported by Padraig O'Briain:
+
+ * gtk/gtktextlayout.h:
+ * gtk/gtktextlayout.c (gtk_text_layout_get_iter_at_position):
+ Add a variant of gtk_text_layout_get_iter_at_pixel() which
+ returns the character at the position, not the closest
+ cursor position.
+
+ * gtk/gtktextview.h:
+ * gtk/gtktextview.c (gtk_text_view_get_iter_at_position):
+ Add a variant of gtk_text_view_get_iter_at_location() which
+ returns the character at the position, not the closest
+ cursor position.
+
+2004-12-08 Matthias Clasen <mclasen@redhat.com>
+
* gtk/gtkaccelmap.c (internal_change_entry): Remove all
entries for the same key, not just the first one. (#159498,
Christian Persch)
diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog
index a4ca172bf..10b2d10df 100644
--- a/docs/reference/ChangeLog
+++ b/docs/reference/ChangeLog
@@ -1,3 +1,7 @@
+2004-12-08 Matthias Clasen <mclasen@redhat.com>
+
+ * gtk/gtk-sections.txt: Add gtk_text_view_get_iter_at_position.
+
2004-12-07 Matthias Clasen <mclasen@redhat.com>
* gtk/images/colorsel.png:
diff --git a/docs/reference/gtk/gtk-sections.txt b/docs/reference/gtk/gtk-sections.txt
index b1e9496d4..d0efc4cd5 100644
--- a/docs/reference/gtk/gtk-sections.txt
+++ b/docs/reference/gtk/gtk-sections.txt
@@ -3216,6 +3216,7 @@ gtk_text_view_get_iter_location
gtk_text_view_get_line_at_y
gtk_text_view_get_line_yrange
gtk_text_view_get_iter_at_location
+gtk_text_view_get_iter_at_position
gtk_text_view_buffer_to_window_coords
gtk_text_view_window_to_buffer_coords
gtk_text_view_get_window
diff --git a/gtk/gtktextlayout.c b/gtk/gtktextlayout.c
index 56d100d0a..3738a93e5 100644
--- a/gtk/gtktextlayout.c
+++ b/gtk/gtktextlayout.c
@@ -2277,11 +2277,25 @@ gtk_text_layout_get_line_at_y (GtkTextLayout *layout,
void
gtk_text_layout_get_iter_at_pixel (GtkTextLayout *layout,
- GtkTextIter *target_iter,
- gint x, gint y)
+ GtkTextIter *target_iter,
+ gint x,
+ gint y)
+{
+ gint trailing;
+
+ gtk_text_layout_get_iter_at_position (layout, target_iter, &trailing, x, y);
+
+ gtk_text_iter_forward_chars (target_iter, trailing);
+}
+
+void gtk_text_layout_get_iter_at_position (GtkTextLayout *layout,
+ GtkTextIter *target_iter,
+ gint *trailing,
+ gint x,
+ gint y)
{
GtkTextLine *line;
- gint byte_index, trailing;
+ gint byte_index;
gint line_top;
GtkTextLineDisplay *display;
@@ -2301,7 +2315,7 @@ gtk_text_layout_get_iter_at_pixel (GtkTextLayout *layout,
if (y > display->height - display->top_margin - display->bottom_margin)
{
byte_index = _gtk_text_line_byte_count (line);
- trailing = 0;
+ *trailing = 0;
}
else
{
@@ -2310,14 +2324,15 @@ gtk_text_layout_get_iter_at_pixel (GtkTextLayout *layout,
* x-direction.
*/
pango_layout_xy_to_index (display->layout, x * PANGO_SCALE, y * PANGO_SCALE,
- &byte_index, &trailing);
+ &byte_index, trailing);
}
- line_display_index_to_iter (layout, display, target_iter, byte_index, trailing);
+ line_display_index_to_iter (layout, display, target_iter, byte_index, 0);
gtk_text_layout_free_line_display (layout, display);
}
+
/**
* gtk_text_layout_get_cursor_locations:
* @layout: a #GtkTextLayout
diff --git a/gtk/gtktextlayout.h b/gtk/gtktextlayout.h
index f42a7c3c0..0e02b1294 100644
--- a/gtk/gtktextlayout.h
+++ b/gtk/gtktextlayout.h
@@ -319,6 +319,11 @@ void gtk_text_layout_get_iter_at_pixel (GtkTextLayout *layout,
GtkTextIter *iter,
gint x,
gint y);
+void gtk_text_layout_get_iter_at_position (GtkTextLayout *layout,
+ GtkTextIter *iter,
+ gint *trailing,
+ gint x,
+ gint y);
void gtk_text_layout_invalidate (GtkTextLayout *layout,
const GtkTextIter *start,
const GtkTextIter *end);
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 17fc69815..12820f91e 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -1297,9 +1297,44 @@ gtk_text_view_get_iter_at_location (GtkTextView *text_view,
gtk_text_view_ensure_layout (text_view);
gtk_text_layout_get_iter_at_pixel (text_view->layout,
- iter,
- x,
- y);
+ iter, x, y);
+}
+
+/**
+ * gtk_text_view_get_iter_at_position:
+ * @text_view: a #GtkTextView
+ * @iter: a #GtkTextIter
+ * @trailing:
+ * @x: x position, in buffer coordinates
+ * @y: y position, in buffer coordinates
+ *
+ * Retrieves the iterator pointing to the character at buffer
+ * coordinates @x and @y. Buffer coordinates are coordinates for
+ * the entire buffer, not just the currently-displayed portion.
+ * If you have coordinates from an event, you have to convert
+ * those to buffer coordinates with
+ * gtk_text_view_window_to_buffer_coords().
+ *
+ * Note that this is diffferent from gtk_text_view_get_iter_at_location(),
+ * which returns cursor locations, i.e. positions <emphasis>between</emphasis>
+ * characters.
+ *
+ * Since: 2.6
+ **/
+void
+gtk_text_view_get_iter_at_position (GtkTextView *text_view,
+ GtkTextIter *iter,
+ gint *trailing,
+ gint x,
+ gint y)
+{
+ g_return_if_fail (GTK_IS_TEXT_VIEW (text_view));
+ g_return_if_fail (iter != NULL);
+
+ gtk_text_view_ensure_layout (text_view);
+
+ gtk_text_layout_get_iter_at_position (text_view->layout,
+ iter, trailing, x, y);
}
/**
diff --git a/gtk/gtktextview.h b/gtk/gtktextview.h
index dca3881a2..3ad5cd6fe 100644
--- a/gtk/gtktextview.h
+++ b/gtk/gtktextview.h
@@ -250,6 +250,11 @@ void gtk_text_view_get_iter_at_location (GtkTextView *text_view,
GtkTextIter *iter,
gint x,
gint y);
+void gtk_text_view_get_iter_at_position (GtkTextView *text_view,
+ GtkTextIter *iter,
+ gint *trailing,
+ gint x,
+ gint y);
void gtk_text_view_get_line_yrange (GtkTextView *text_view,
const GtkTextIter *iter,
gint *y,