Fix some issues with some combinations of inline-selection and

2007-07-16  Matthias Clasen <mclasen@redhat.com>

        Fix some issues with some combinations of inline-selection
        and inline-completion.  (#457384, Christian Persch)

        * gtk/gtkentry.c (gtk_entry_completion_key_press): Don't store
        the completion_prefix here, and be careful when using
        completion_prefix, because it may be NULL.
        * gtk/gtkentrycompletion.c (gtk_entry_completion_finalize):
        Free completion_prefix here.
        * gtk/gtkentrycompletion.c (gtk_entry_completion_real_insert_prefix):
        (gtk_entry_completion_insert_completion_text): Store the
        completion_prefix here.


svn path=/trunk/; revision=18479
This commit is contained in:
Matthias Clasen 2007-07-16 16:43:54 +00:00 committed by Matthias Clasen
parent 50a0d3b8eb
commit 20580e491e
3 changed files with 33 additions and 32 deletions

View File

@ -4,6 +4,20 @@
if the pointer is really over the returned widget, since the
coordinate check may not always be hit in find_widget_under_pointer().
2007-07-16 Matthias Clasen <mclasen@redhat.com>
Fix some issues with some combinations of inline-selection
and inline-completion. (#457384, Christian Persch)
* gtk/gtkentry.c (gtk_entry_completion_key_press): Don't store
the completion_prefix here, and be careful when using
completion_prefix, because it may be NULL.
* gtk/gtkentrycompletion.c (gtk_entry_completion_finalize):
Free completion_prefix here.
* gtk/gtkentrycompletion.c (gtk_entry_completion_real_insert_prefix):
(gtk_entry_completion_insert_completion_text): Store the
completion_prefix here.
2007-07-16 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkfilechooserbutton.c (model_add_special_get_info_cb):

View File

@ -5870,11 +5870,6 @@ gtk_entry_completion_key_press (GtkWidget *widget,
if (!gtk_tree_selection_get_selected (sel, &model, &iter))
return FALSE;
if (completion->priv->completion_prefix == NULL)
{
completion->priv->completion_prefix = g_strdup (gtk_entry_get_text (GTK_ENTRY (completion->priv->entry)));
}
g_signal_emit_by_name (completion, "cursor_on_match", model,
&iter, &entry_set);
}
@ -5906,7 +5901,11 @@ gtk_entry_completion_key_press (GtkWidget *widget,
/* Escape rejects the tentative completion */
if (event->keyval == GDK_Escape)
{
gtk_entry_set_text (GTK_ENTRY (completion->priv->entry), completion->priv->completion_prefix);
if (completion->priv->completion_prefix)
gtk_entry_set_text (GTK_ENTRY (completion->priv->entry),
completion->priv->completion_prefix);
else
gtk_entry_set_text (GTK_ENTRY (completion->priv->entry), "");
}
/* Move the cursor to the end for Right/Esc, to the

View File

@ -650,6 +650,7 @@ gtk_entry_completion_finalize (GObject *object)
g_object_unref (priv->action_view);
g_free (priv->case_normalized_key);
g_free (priv->completion_prefix);
if (priv->popup_window)
gtk_widget_destroy (priv->popup_window);
@ -1634,6 +1635,9 @@ gtk_entry_completion_real_insert_prefix (GtkEntryCompletion *completion,
key = gtk_entry_get_text (GTK_ENTRY (completion->priv->entry));
key_len = g_utf8_strlen (key, -1);
if (completion->priv->completion_prefix == NULL)
completion->priv->completion_prefix = g_strdup (key);
if (prefix_len > key_len)
{
gint pos = prefix_len;
@ -1674,44 +1678,28 @@ gtk_entry_completion_insert_completion_text (GtkEntryCompletion *completion,
const gchar *text)
{
GtkEntryCompletionPrivate *priv = completion->priv;
gchar *needle;
gint len;
priv = completion->priv;
if (priv->changed_id > 0)
{
g_signal_handler_block (priv->entry,
priv->changed_id);
}
g_signal_handler_block (priv->entry, priv->changed_id);
if (priv->insert_text_id > 0)
{
g_signal_handler_block (completion->priv->entry,
completion->priv->insert_text_id);
}
g_signal_handler_block (priv->entry, priv->insert_text_id);
gtk_entry_set_text (GTK_ENTRY (priv->entry), text);
needle = strstr (text, completion->priv->completion_prefix);
if (needle)
{
len = g_utf8_strlen (text, -1) - g_utf8_strlen (needle, -1)
+ g_utf8_strlen (priv->completion_prefix, -1);
gtk_editable_select_region (GTK_EDITABLE (priv->entry),
len, -1);
}
if (completion->priv->completion_prefix == NULL)
completion->priv->completion_prefix = g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->entry)));
gtk_entry_set_text (GTK_ENTRY (priv->entry), text);
len = strlen (priv->completion_prefix);
gtk_editable_select_region (GTK_EDITABLE (priv->entry), len, -1);
if (priv->changed_id > 0)
{
g_signal_handler_unblock (priv->entry,
priv->changed_id);
}
g_signal_handler_unblock (priv->entry, priv->changed_id);
if (priv->insert_text_id > 0)
{
g_signal_handler_unblock (priv->entry,
priv->insert_text_id);
}
g_signal_handler_unblock (priv->entry, priv->insert_text_id);
}
static gboolean