Commit 20580e49 authored by Matthias Clasen's avatar Matthias Clasen Committed by Matthias Clasen

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
parent 50a0d3b8
......@@ -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):
......
......@@ -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
......
......@@ -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
......
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