make sure the has-selection property is updated when the delection is

2006-08-17  Paolo Borelli  <pborelli@katamail.com>

	* gtk/gtktextbuffer.c: make sure the has-selection property is
	updated when the delection is deleted. Bug #329752
	* tests/testtext.c: add a copy menu item and show how to
	update its sensitivity tracking the has-selection property.
This commit is contained in:
Paolo Borelli
2006-08-17 01:12:02 +00:00
committed by Paolo Borelli
parent 6f4fa65833
commit 2bca4a48d0
4 changed files with 60 additions and 10 deletions

View File

@ -1388,6 +1388,8 @@ gtk_text_buffer_real_delete_range (GtkTextBuffer *buffer,
GtkTextIter *start,
GtkTextIter *end)
{
gboolean has_selection;
g_return_if_fail (GTK_IS_TEXT_BUFFER (buffer));
g_return_if_fail (start != NULL);
g_return_if_fail (end != NULL);
@ -1397,6 +1399,13 @@ gtk_text_buffer_real_delete_range (GtkTextBuffer *buffer,
/* may have deleted the selection... */
update_selection_clipboards (buffer);
has_selection = gtk_text_buffer_get_selection_bounds (buffer, NULL, NULL);
if (has_selection != buffer->has_selection)
{
buffer->has_selection = has_selection;
g_object_notify (G_OBJECT (buffer), "has-selection");
}
g_signal_emit (buffer, signals[CHANGED], 0);
g_object_notify (G_OBJECT (buffer), "cursor-position");
}
@ -1854,12 +1863,6 @@ gtk_text_buffer_set_mark (GtkTextBuffer *buffer,
iter,
should_exist);
if (_gtk_text_btree_mark_is_insert (get_btree (buffer), mark) ||
_gtk_text_btree_mark_is_selection_bound (get_btree (buffer), mark))
{
update_selection_clipboards (buffer);
}
_gtk_text_btree_get_iter_at_mark (get_btree (buffer),
&location,
mark);
@ -2200,7 +2203,6 @@ gtk_text_buffer_select_range (GtkTextBuffer *buffer,
gtk_text_buffer_mark_set (buffer, &real_bound,
gtk_text_buffer_get_mark (buffer,
"selection_bound"));
update_selection_clipboards (buffer);
}
/*
@ -2306,6 +2308,8 @@ gtk_text_buffer_real_mark_set (GtkTextBuffer *buffer,
{
gboolean has_selection;
update_selection_clipboards (buffer);
has_selection = gtk_text_buffer_get_selection_bounds (buffer,
NULL,
NULL);