[gtk+] Use the split-cursor setting for textview cursors
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Use the split-cursor setting for textview cursors
- Date: Thu, 1 Dec 2011 00:20:06 +0000 (UTC)
commit 3c6842222abb1284e0f13760bc0f0c48d41b0c8f
Author: Paolo Borelli <pborelli gnome org>
Date: Sun Nov 27 15:12:36 2011 +0100
Use the split-cursor setting for textview cursors
Explicitely check the split-cursor setting when drawing the textview
insertion cursor instead of relying on the cursor_direction set in the
textlayout. This makes the cursor drawin code more uniform with other
widgets in preparation to refactoring the cursor drawing code in a
shared function.
https://bugzilla.gnome.org/show_bug.cgi?id=640317
gtk/gtktextdisplay.c | 55 ++++++++++++++++++++++++++++++++-----------------
1 files changed, 36 insertions(+), 19 deletions(-)
---
diff --git a/gtk/gtktextdisplay.c b/gtk/gtktextdisplay.c
index 6911dae..dad8e40 100644
--- a/gtk/gtktextdisplay.c
+++ b/gtk/gtktextdisplay.c
@@ -912,39 +912,56 @@ gtk_text_layout_draw (GtkTextLayout *layout,
{
int index;
PangoRectangle strong_pos, weak_pos;
+ PangoRectangle *cursor1, *cursor2;
+ gboolean split_cursor;
+ GtkTextDirection dir1, dir2;
GdkRectangle cursor_location;
index = g_array_index(line_display->cursors, int, i);
pango_layout_get_cursor_pos (line_display->layout, index, &strong_pos, &weak_pos);
- cursor_location.x = line_display->x_offset + PANGO_PIXELS (strong_pos.x);
- cursor_location.y = line_display->top_margin + PANGO_PIXELS (strong_pos.y);
- cursor_location.width = 0;
- cursor_location.height = PANGO_PIXELS (strong_pos.height);
+ dir1 = line_display->direction;
+ dir2 = GTK_TEXT_DIR_NONE;
+
+ g_object_get (gtk_widget_get_settings (widget),
+ "gtk-split-cursor", &split_cursor,
+ NULL);
- if (layout->cursor_direction == GTK_TEXT_DIR_NONE ||
- line_display->direction == layout->cursor_direction)
+ if (split_cursor)
{
- gtk_draw_insertion_cursor (widget, cr,
- &cursor_location, TRUE, line_display->direction,
- layout->cursor_direction != GTK_TEXT_DIR_NONE);
+ cursor1 = &strong_pos;
+ if (strong_pos.x != weak_pos.x || strong_pos.y != weak_pos.y)
+ {
+ dir2 = (line_display->direction == GTK_TEXT_DIR_LTR) ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR;
+ cursor2 = &weak_pos;
+ }
}
-
- if ((strong_pos.x != weak_pos.x || strong_pos.y != weak_pos.y) &&
- (layout->cursor_direction == GTK_TEXT_DIR_NONE ||
- line_display->direction != layout->cursor_direction))
+ else
{
- GtkTextDirection dir;
+ if (layout->keyboard_direction == line_display->direction)
+ cursor1 = &strong_pos;
+ else
+ cursor1 = &weak_pos;
+ }
+
+ cursor_location.x = line_display->x_offset + PANGO_PIXELS (cursor1->x);
+ cursor_location.y = line_display->top_margin + PANGO_PIXELS (cursor1->y);
+ cursor_location.width = 0;
+ cursor_location.height = PANGO_PIXELS (cursor1->height);
- dir = (line_display->direction == GTK_TEXT_DIR_RTL) ? GTK_TEXT_DIR_LTR : GTK_TEXT_DIR_RTL;
+ gtk_draw_insertion_cursor (widget, cr,
+ &cursor_location, TRUE, dir1,
+ dir2 != GTK_TEXT_DIR_NONE);
- cursor_location.x = line_display->x_offset + PANGO_PIXELS (weak_pos.x);
- cursor_location.y = line_display->top_margin + PANGO_PIXELS (weak_pos.y);
+ if (dir2 != GTK_TEXT_DIR_NONE)
+ {
+ cursor_location.x = line_display->x_offset + PANGO_PIXELS (cursor2->x);
+ cursor_location.y = line_display->top_margin + PANGO_PIXELS (cursor2->y);
cursor_location.width = 0;
- cursor_location.height = PANGO_PIXELS (weak_pos.height);
+ cursor_location.height = PANGO_PIXELS (cursor2->height);
gtk_draw_insertion_cursor (widget, cr,
- &cursor_location, FALSE, dir,
+ &cursor_location, FALSE, dir2,
TRUE);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]