From f9038c03a5c1c976fde28643fc4ed8254da07b97 Mon Sep 17 00:00:00 2001 From: Padraig O'Briain Date: Mon, 19 Aug 2002 14:39:44 +0000 Subject: [PATCH] Use gtk_entry_set_positions() to update current_pos and selection_bound so * gtk/gtkentry.c (gtk_entry_real_delete_text): Use gtk_entry_set_positions() to update current_pos and selection_bound so notifications are emitted (#90548) --- ChangeLog | 6 ++++++ ChangeLog.pre-2-10 | 6 ++++++ ChangeLog.pre-2-2 | 6 ++++++ ChangeLog.pre-2-4 | 6 ++++++ ChangeLog.pre-2-6 | 6 ++++++ ChangeLog.pre-2-8 | 6 ++++++ gtk/gtkentry.c | 17 ++++++++++++----- 7 files changed, 48 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index ac3ac8ead9..2b124b67f8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2002-08-19 Padraig O'Briain + + * gtk/gtkentry.c (gtk_entry_real_delete_text): Use + gtk_entry_set_positions() to update current_pos and selection_bound + so notifications are emitted (#90548) + 2002-08-16 jacob berkman * gtk/gtkdialog.h (struct _GtkDialog): switch vbox and action_area diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index ac3ac8ead9..2b124b67f8 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,9 @@ +2002-08-19 Padraig O'Briain + + * gtk/gtkentry.c (gtk_entry_real_delete_text): Use + gtk_entry_set_positions() to update current_pos and selection_bound + so notifications are emitted (#90548) + 2002-08-16 jacob berkman * gtk/gtkdialog.h (struct _GtkDialog): switch vbox and action_area diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index ac3ac8ead9..2b124b67f8 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,9 @@ +2002-08-19 Padraig O'Briain + + * gtk/gtkentry.c (gtk_entry_real_delete_text): Use + gtk_entry_set_positions() to update current_pos and selection_bound + so notifications are emitted (#90548) + 2002-08-16 jacob berkman * gtk/gtkdialog.h (struct _GtkDialog): switch vbox and action_area diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index ac3ac8ead9..2b124b67f8 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,9 @@ +2002-08-19 Padraig O'Briain + + * gtk/gtkentry.c (gtk_entry_real_delete_text): Use + gtk_entry_set_positions() to update current_pos and selection_bound + so notifications are emitted (#90548) + 2002-08-16 jacob berkman * gtk/gtkdialog.h (struct _GtkDialog): switch vbox and action_area diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index ac3ac8ead9..2b124b67f8 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,9 @@ +2002-08-19 Padraig O'Briain + + * gtk/gtkentry.c (gtk_entry_real_delete_text): Use + gtk_entry_set_positions() to update current_pos and selection_bound + so notifications are emitted (#90548) + 2002-08-16 jacob berkman * gtk/gtkdialog.h (struct _GtkDialog): switch vbox and action_area diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index ac3ac8ead9..2b124b67f8 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,9 @@ +2002-08-19 Padraig O'Briain + + * gtk/gtkentry.c (gtk_entry_real_delete_text): Use + gtk_entry_set_positions() to update current_pos and selection_bound + so notifications are emitted (#90548) + 2002-08-16 jacob berkman * gtk/gtkdialog.h (struct _GtkDialog): switch vbox and action_area diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index 7762a36130..8879fb405e 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -1943,22 +1943,29 @@ gtk_entry_real_delete_text (GtkEditable *editable, { gint start_index = g_utf8_offset_to_pointer (entry->text, start_pos) - entry->text; gint end_index = g_utf8_offset_to_pointer (entry->text, end_pos) - entry->text; + gint current_pos; + gint selection_bound; g_memmove (entry->text + start_index, entry->text + end_index, entry->n_bytes + 1 - end_index); entry->text_length -= (end_pos - start_pos); entry->n_bytes -= (end_index - start_index); - if (entry->current_pos > start_pos) - entry->current_pos -= MIN (entry->current_pos, end_pos) - start_pos; + current_pos = entry->current_pos; + if (current_pos > start_pos) + current_pos -= MIN (current_pos, end_pos) - start_pos; + + selection_bound = entry->selection_bound; + if (selection_bound > start_pos) + selection_bound -= MIN (selection_bound, end_pos) - start_pos; + + gtk_entry_set_positions (entry, current_pos, selection_bound); - if (entry->selection_bound > start_pos) - entry->selection_bound -= MIN (entry->selection_bound, end_pos) - start_pos; /* We might have deleted the selection */ gtk_entry_update_primary_selection (entry); gtk_entry_recompute (entry); - + g_signal_emit_by_name (editable, "changed"); g_object_notify (G_OBJECT (editable), "text"); }