Commit 540569da authored by Paolo Borelli's avatar Paolo Borelli Committed by Paolo Borelli

Use gtk_text_buffer_get_insert instead of get_mark. Fixes Bug 497164.

2007-11-17  Paolo Borelli  <pborelli@katamail.com>

	* gtk/gtktextbuffer.c:
	* gtk/gtktextlayout.c:
	* gtk/gtktextview.c:
	Use gtk_text_buffer_get_insert instead of get_mark. Fixes Bug 497164.


svn path=/trunk/; revision=18997
parent abad58b0
2007-11-17 Paolo Borelli <pborelli@katamail.com>
* gtk/gtktextbuffer.c:
* gtk/gtktextlayout.c:
* gtk/gtktextview.c:
Use gtk_text_buffer_get_insert instead of get_mark. Fixes Bug 497164.
2007-11-15 Yevgen Muntyan <muntyan@tamu.edu>
* gtk/gtktextbtree.h:
......
......@@ -918,8 +918,7 @@ gtk_text_buffer_insert_at_cursor (GtkTextBuffer *buffer,
g_return_if_fail (text != NULL);
gtk_text_buffer_get_iter_at_mark (buffer, &iter,
gtk_text_buffer_get_mark (buffer,
"insert"));
gtk_text_buffer_get_insert (buffer));
gtk_text_buffer_insert (buffer, &iter, text, len);
}
......@@ -993,8 +992,7 @@ gtk_text_buffer_insert_interactive_at_cursor (GtkTextBuffer *buffer,
g_return_val_if_fail (text != NULL, FALSE);
gtk_text_buffer_get_iter_at_mark (buffer, &iter,
gtk_text_buffer_get_mark (buffer,
"insert"));
gtk_text_buffer_get_insert (buffer));
return gtk_text_buffer_insert_interactive (buffer, &iter, text, len,
default_editable);
......@@ -1416,7 +1414,6 @@ gtk_text_buffer_insert_range_interactive (GtkTextBuffer *buffer,
g_return_val_if_fail (gtk_text_iter_get_buffer (start)->tag_table ==
buffer->tag_table, FALSE);
if (gtk_text_iter_can_insert (iter, default_editable))
{
gtk_text_buffer_real_insert_range (buffer, iter, start, end, TRUE);
......@@ -1744,9 +1741,7 @@ gtk_text_buffer_delete_interactive (GtkTextBuffer *buffer,
g_assert (!current_state && new_state);
gtk_text_buffer_move_mark (buffer, start_mark,
&iter);
gtk_text_buffer_move_mark (buffer, start_mark, &iter);
current_state = TRUE;
}
......@@ -1755,7 +1750,6 @@ gtk_text_buffer_delete_interactive (GtkTextBuffer *buffer,
break;
}
gtk_text_buffer_delete_mark (buffer, start_mark);
gtk_text_buffer_delete_mark (buffer, end_mark);
......@@ -1931,7 +1925,6 @@ gtk_text_buffer_insert_child_anchor (GtkTextBuffer *buffer,
iter, anchor);
}
/**
* gtk_text_buffer_create_child_anchor:
* @buffer: a #GtkTextBuffer
......@@ -2221,7 +2214,6 @@ gtk_text_buffer_get_mark (GtkTextBuffer *buffer,
return mark;
}
/**
* gtk_text_buffer_move_mark_by_name:
* @buffer: a #GtkTextBuffer
......@@ -2368,7 +2360,6 @@ gtk_text_buffer_place_cursor (GtkTextBuffer *buffer,
gtk_text_buffer_select_range (buffer, where, where);
}
/**
* gtk_text_buffer_select_range:
* @buffer: a #GtkTextBuffer
......@@ -2400,11 +2391,9 @@ gtk_text_buffer_select_range (GtkTextBuffer *buffer,
_gtk_text_btree_select_range (get_btree (buffer), &real_ins, &real_bound);
gtk_text_buffer_mark_set (buffer, &real_ins,
gtk_text_buffer_get_mark (buffer,
"insert"));
gtk_text_buffer_get_insert (buffer));
gtk_text_buffer_mark_set (buffer, &real_bound,
gtk_text_buffer_get_mark (buffer,
"selection_bound"));
gtk_text_buffer_get_selection_bound (buffer));
}
/*
......@@ -2551,7 +2540,6 @@ gtk_text_buffer_emit_tag (GtkTextBuffer *buffer,
tag, &start_tmp, &end_tmp);
}
/**
* gtk_text_buffer_apply_tag:
* @buffer: a #GtkTextBuffer
......@@ -2609,7 +2597,6 @@ gtk_text_buffer_remove_tag (GtkTextBuffer *buffer,
gtk_text_buffer_emit_tag (buffer, tag, FALSE, start, end);
}
/**
* gtk_text_buffer_apply_tag_by_name:
* @buffer: a #GtkTextBuffer
......@@ -3091,13 +3078,13 @@ clipboard_clear_selection_cb (GtkClipboard *clipboard,
GtkTextBuffer *buffer = GTK_TEXT_BUFFER (data);
gtk_text_buffer_get_iter_at_mark (buffer, &insert,
gtk_text_buffer_get_mark (buffer, "insert"));
gtk_text_buffer_get_insert (buffer));
gtk_text_buffer_get_iter_at_mark (buffer, &selection_bound,
gtk_text_buffer_get_mark (buffer, "selection_bound"));
gtk_text_buffer_get_selection_bound (buffer));
if (!gtk_text_iter_equal (&insert, &selection_bound))
gtk_text_buffer_move_mark (buffer,
gtk_text_buffer_get_mark (buffer, "selection_bound"),
gtk_text_buffer_get_selection_bound (buffer),
&insert);
}
......@@ -3263,8 +3250,7 @@ get_paste_point (GtkTextBuffer *buffer,
else
{
gtk_text_buffer_get_iter_at_mark (buffer, &insert_point,
gtk_text_buffer_get_mark (buffer,
"insert"));
gtk_text_buffer_get_insert (buffer));
}
*iter = insert_point;
......@@ -3998,7 +3984,6 @@ gtk_text_buffer_copy_clipboard (GtkTextBuffer *buffer,
gtk_text_buffer_end_user_action (buffer);
}
/**
* gtk_text_buffer_get_selection_bounds:
* @buffer: a #GtkTextBuffer a #GtkTextBuffer
......@@ -4216,7 +4201,6 @@ struct _CacheEntry
PangoLogAttr *attrs;
};
struct _GtkTextLogAttrCache
{
gint chars_changed_stamp;
......
......@@ -519,7 +519,7 @@ gtk_text_layout_set_cursor_visible (GtkTextLayout *layout,
/* Now queue a redraw on the paragraph containing the cursor
*/
gtk_text_buffer_get_iter_at_mark (layout->buffer, &iter,
gtk_text_buffer_get_mark (layout->buffer, "insert"));
gtk_text_buffer_get_insert (layout->buffer));
gtk_text_layout_get_line_yrange (layout, &iter, &y, &height);
gtk_text_layout_emit_changed (layout, y, height, height);
......@@ -859,8 +859,8 @@ gtk_text_layout_update_cursor_line(GtkTextLayout *layout)
GtkTextIter iter;
gtk_text_buffer_get_iter_at_mark (layout->buffer, &iter,
gtk_text_buffer_get_mark (layout->buffer, "insert"));
gtk_text_buffer_get_insert (layout->buffer));
priv->cursor_line = _gtk_text_iter_get_text_line (&iter);
}
......@@ -954,8 +954,6 @@ gtk_text_layout_real_free_line_data (GtkTextLayout *layout,
g_free (line_data);
}
/**
* gtk_text_layout_is_valid:
* @layout: a #GtkTextLayout
......@@ -1432,7 +1430,6 @@ gtk_text_attr_appearance_compare (const PangoAttribute *attr1,
appearance1->underline == appearance2->underline &&
appearance1->strikethrough == appearance2->strikethrough &&
appearance1->draw_bg == appearance2->draw_bg);
}
/**
......@@ -1474,7 +1471,6 @@ gtk_text_attr_appearance_new (const GtkTextAppearance *appearance)
return (PangoAttribute *)result;
}
static void
add_generic_attrs (GtkTextLayout *layout,
GtkTextAppearance *appearance,
......@@ -2721,8 +2717,7 @@ gtk_text_layout_get_cursor_locations (GtkTextLayout *layout,
line, layout);
gtk_text_buffer_get_iter_at_mark (layout->buffer, &insert_iter,
gtk_text_buffer_get_mark (layout->buffer,
"insert"));
gtk_text_buffer_get_insert (layout->buffer));
if (gtk_text_iter_equal (iter, &insert_iter))
index += layout->preedit_cursor - layout->preedit_len;
......
......@@ -2710,8 +2710,7 @@ gtk_text_view_place_cursor_onscreen (GtkTextView *text_view)
g_return_val_if_fail (GTK_IS_TEXT_VIEW (text_view), FALSE);
gtk_text_buffer_get_iter_at_mark (get_buffer (text_view), &insert,
gtk_text_buffer_get_mark (get_buffer (text_view),
"insert"));
gtk_text_buffer_get_insert (get_buffer (text_view)));
if (clamp_iter_onscreen (text_view, &insert))
{
......@@ -4049,13 +4048,10 @@ gtk_text_view_event (GtkWidget *widget, GdkEvent *event)
else if (event->type == GDK_KEY_PRESS ||
event->type == GDK_KEY_RELEASE)
{
GtkTextMark *insert;
GtkTextIter iter;
insert = gtk_text_buffer_get_mark (get_buffer (text_view),
"insert");
gtk_text_buffer_get_iter_at_mark (get_buffer (text_view), &iter, insert);
gtk_text_buffer_get_iter_at_mark (get_buffer (text_view), &iter,
gtk_text_buffer_get_insert (get_buffer (text_view)));
return emit_event_on_tags (widget, event, &iter);
}
......@@ -4993,8 +4989,7 @@ gtk_text_view_move_cursor_internal (GtkTextView *text_view,
}
gtk_text_buffer_get_iter_at_mark (get_buffer (text_view), &insert,
gtk_text_buffer_get_mark (get_buffer (text_view),
"insert"));
gtk_text_buffer_get_insert (get_buffer (text_view)));
newplace = insert;
if (step == GTK_MOVEMENT_DISPLAY_LINES)
......@@ -5104,8 +5099,7 @@ gtk_text_view_move_cursor_internal (GtkTextView *text_view,
{
DV(g_print (G_STRLOC": scrolling onscreen\n"));
gtk_text_view_scroll_mark_onscreen (text_view,
gtk_text_buffer_get_mark (get_buffer (text_view),
"insert"));
gtk_text_buffer_get_insert (get_buffer (text_view)));
if (step == GTK_MOVEMENT_DISPLAY_LINES)
gtk_text_view_set_virtual_cursor_pos (text_view, cursor_x_pos, -1);
......@@ -5199,8 +5193,7 @@ gtk_text_view_set_anchor (GtkTextView *text_view)
GtkTextIter insert;
gtk_text_buffer_get_iter_at_mark (get_buffer (text_view), &insert,
gtk_text_buffer_get_mark (get_buffer (text_view),
"insert"));
gtk_text_buffer_get_insert (get_buffer (text_view)));
gtk_text_buffer_create_mark (get_buffer (text_view), "anchor", &insert, TRUE);
}
......@@ -5214,6 +5207,7 @@ gtk_text_view_scroll_pages (GtkTextView *text_view,
gdouble oldval;
GtkAdjustment *adj;
gint cursor_x_pos, cursor_y_pos;
GtkTextMark *insert_mark;
GtkTextIter old_insert;
GtkTextIter new_insert;
GtkTextIter anchor;
......@@ -5223,6 +5217,8 @@ gtk_text_view_scroll_pages (GtkTextView *text_view,
adj = text_view->vadjustment;
insert_mark = gtk_text_buffer_get_insert (get_buffer (text_view));
/* Make sure we start from the current cursor position, even
* if it was offscreen, but don't queue more scrolls if we're
* already behind.
......@@ -5230,15 +5226,12 @@ gtk_text_view_scroll_pages (GtkTextView *text_view,
if (text_view->pending_scroll)
cancel_pending_scroll (text_view);
else
gtk_text_view_scroll_mark_onscreen (text_view,
gtk_text_buffer_get_mark (get_buffer (text_view),
"insert"));
gtk_text_view_scroll_mark_onscreen (text_view, insert_mark);
/* Validate the region that will be brought into view by the cursor motion
*/
gtk_text_buffer_get_iter_at_mark (get_buffer (text_view),
&old_insert,
gtk_text_buffer_get_mark (get_buffer (text_view), "insert"));
&old_insert, insert_mark);
if (count < 0)
{
......@@ -5293,9 +5286,7 @@ gtk_text_view_scroll_pages (GtkTextView *text_view,
* only guarantees 1 pixel onscreen.
*/
DV(g_print (G_STRLOC": scrolling onscreen\n"));
gtk_text_view_scroll_mark_onscreen (text_view,
gtk_text_buffer_get_mark (get_buffer (text_view),
"insert"));
gtk_text_view_scroll_mark_onscreen (text_view, insert_mark);
return !gtk_text_iter_equal (&old_insert, &new_insert);
}
......@@ -5309,6 +5300,7 @@ gtk_text_view_scroll_hpages (GtkTextView *text_view,
gdouble oldval;
GtkAdjustment *adj;
gint cursor_x_pos, cursor_y_pos;
GtkTextMark *insert_mark;
GtkTextIter old_insert;
GtkTextIter new_insert;
gint y, height;
......@@ -5317,6 +5309,8 @@ gtk_text_view_scroll_hpages (GtkTextView *text_view,
adj = text_view->hadjustment;
insert_mark = gtk_text_buffer_get_insert (get_buffer (text_view));
/* Make sure we start from the current cursor position, even
* if it was offscreen, but don't queue more scrolls if we're
* already behind.
......@@ -5324,15 +5318,13 @@ gtk_text_view_scroll_hpages (GtkTextView *text_view,
if (text_view->pending_scroll)
cancel_pending_scroll (text_view);
else
gtk_text_view_scroll_mark_onscreen (text_view,
gtk_text_buffer_get_mark (get_buffer (text_view),
"insert"));
gtk_text_view_scroll_mark_onscreen (text_view, insert_mark);
/* Validate the line that we're moving within.
*/
gtk_text_buffer_get_iter_at_mark (get_buffer (text_view),
&old_insert,
gtk_text_buffer_get_mark (get_buffer (text_view), "insert"));
&old_insert, insert_mark);
gtk_text_layout_get_line_yrange (text_view->layout, &old_insert, &y, &height);
gtk_text_layout_validate_yrange (text_view->layout, &old_insert, y, y + height);
/* FIXME do we need to update the adjustment ranges here? */
......@@ -5381,9 +5373,7 @@ gtk_text_view_scroll_hpages (GtkTextView *text_view,
* only guarantees 1 pixel onscreen.
*/
DV(g_print (G_STRLOC": scrolling onscreen\n"));
gtk_text_view_scroll_mark_onscreen (text_view,
gtk_text_buffer_get_mark (get_buffer (text_view),
"insert"));
gtk_text_view_scroll_mark_onscreen (text_view, insert_mark);
return !gtk_text_iter_equal (&old_insert, &new_insert);
}
......@@ -5446,10 +5436,8 @@ gtk_text_view_delete_from_cursor (GtkTextView *text_view,
return;
}
gtk_text_buffer_get_iter_at_mark (get_buffer (text_view),
&insert,
gtk_text_buffer_get_mark (get_buffer (text_view),
"insert"));
gtk_text_buffer_get_iter_at_mark (get_buffer (text_view), &insert,
gtk_text_buffer_get_insert (get_buffer (text_view)));
start = insert;
end = insert;
......@@ -5550,7 +5538,7 @@ gtk_text_view_delete_from_cursor (GtkTextView *text_view,
DV(g_print (G_STRLOC": scrolling onscreen\n"));
gtk_text_view_scroll_mark_onscreen (text_view,
gtk_text_buffer_get_mark (get_buffer (text_view), "insert"));
gtk_text_buffer_get_insert (get_buffer (text_view)));
}
else
{
......@@ -5788,14 +5776,11 @@ gtk_text_view_unselect (GtkTextView *text_view)
{
GtkTextIter insert;
gtk_text_buffer_get_iter_at_mark (get_buffer (text_view),
&insert,
gtk_text_buffer_get_mark (get_buffer (text_view),
"insert"));
gtk_text_buffer_get_iter_at_mark (get_buffer (text_view), &insert,
gtk_text_buffer_get_insert (get_buffer (text_view)));
gtk_text_buffer_move_mark (get_buffer (text_view),
gtk_text_buffer_get_mark (get_buffer (text_view),
"selection_bound"),
gtk_text_buffer_get_selection_bound (get_buffer (text_view)),
&insert);
}
......@@ -5856,8 +5841,7 @@ selection_scan_timeout (gpointer data)
DV(g_print (G_STRLOC": calling move_mark_to_pointer_and_scroll\n"));
gtk_text_view_scroll_mark_onscreen (text_view,
gtk_text_buffer_get_mark (get_buffer (text_view),
"insert"));
gtk_text_buffer_get_insert (get_buffer (text_view)));
return TRUE; /* remain installed. */
}
......@@ -7177,8 +7161,7 @@ gtk_text_view_commit_text (GtkTextView *text_view,
gtk_text_buffer_get_iter_at_mark (get_buffer (text_view),
&insert,
gtk_text_buffer_get_mark (get_buffer (text_view),
"insert"));
gtk_text_buffer_get_insert (get_buffer (text_view)));
if (!gtk_text_iter_ends_line (&insert))
gtk_text_view_delete_from_cursor (text_view, GTK_DELETE_CHARS, 1);
}
......@@ -7195,8 +7178,7 @@ gtk_text_view_commit_text (GtkTextView *text_view,
gtk_text_view_set_virtual_cursor_pos (text_view, -1, -1);
DV(g_print (G_STRLOC": scrolling onscreen\n"));
gtk_text_view_scroll_mark_onscreen (text_view,
gtk_text_buffer_get_mark (get_buffer (text_view),
"insert"));
gtk_text_buffer_get_insert (get_buffer (text_view)));
}
static void
......@@ -7227,8 +7209,7 @@ gtk_text_view_preedit_changed_handler (GtkIMContext *context,
if (GTK_WIDGET_HAS_FOCUS (text_view))
gtk_text_view_scroll_mark_onscreen (text_view,
gtk_text_buffer_get_mark (get_buffer (text_view),
"insert"));
gtk_text_buffer_get_insert (get_buffer (text_view)));
}
static gboolean
......@@ -7352,8 +7333,7 @@ gtk_text_view_get_cursor_location (GtkTextView *text_view,
GtkTextIter insert;
gtk_text_buffer_get_iter_at_mark (get_buffer (text_view), &insert,
gtk_text_buffer_get_mark (get_buffer (text_view),
"insert"));
gtk_text_buffer_get_insert (get_buffer (text_view)));
gtk_text_layout_get_cursor_locations (text_view->layout, &insert, pos, NULL);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment