forked from AuroraMiddleware/gtk
Apply a number of patches by Xan Lopez to improve the interaction between
2007-09-08 Matthias Clasen <mclasen@redhat.com> * gtk/gtkentrycompletion.c: * gtk/gtkentry.c: Apply a number of patches by Xan Lopez to improve the interaction between actions and inline selection. (#471132) svn path=/trunk/; revision=18761
This commit is contained in:
parent
54139b8806
commit
5067b99881
@ -1,8 +1,15 @@
|
||||
2007-09-08 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/gtkentrycompletion.c:
|
||||
* gtk/gtkentry.c: Apply a number of patches by Xan Lopez
|
||||
to improve the interaction between actions and inline
|
||||
selection. (#471132)
|
||||
|
||||
2007-09-07 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/gtktoolbar.c: Use g_slice for ToolbarContent.
|
||||
(#474696, Christian Persch)
|
||||
|
||||
|
||||
2007-09-07 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/gtkprintunixdialog.c: Add an internal child name for
|
||||
|
@ -5849,6 +5849,14 @@ gtk_entry_completion_key_press (GtkWidget *widget,
|
||||
{
|
||||
gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (GTK_TREE_VIEW (completion->priv->tree_view)));
|
||||
gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (GTK_TREE_VIEW (completion->priv->action_view)));
|
||||
|
||||
if (completion->priv->inline_selection &&
|
||||
completion->priv->completion_prefix)
|
||||
{
|
||||
gtk_entry_set_text (GTK_ENTRY (completion->priv->entry),
|
||||
completion->priv->completion_prefix);
|
||||
gtk_editable_set_position (GTK_EDITABLE (widget), -1);
|
||||
}
|
||||
}
|
||||
else if (completion->priv->current_selected < matches)
|
||||
{
|
||||
@ -5870,6 +5878,9 @@ 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);
|
||||
}
|
||||
@ -5881,6 +5892,14 @@ gtk_entry_completion_key_press (GtkWidget *widget,
|
||||
path = gtk_tree_path_new_from_indices (completion->priv->current_selected - matches, -1);
|
||||
gtk_tree_view_set_cursor (GTK_TREE_VIEW (completion->priv->action_view),
|
||||
path, NULL, FALSE);
|
||||
|
||||
if (completion->priv->inline_selection &&
|
||||
completion->priv->completion_prefix)
|
||||
{
|
||||
gtk_entry_set_text (GTK_ENTRY (completion->priv->entry),
|
||||
completion->priv->completion_prefix);
|
||||
gtk_editable_set_position (GTK_EDITABLE (widget), -1);
|
||||
}
|
||||
}
|
||||
|
||||
gtk_tree_path_free (path);
|
||||
@ -5893,16 +5912,12 @@ gtk_entry_completion_key_press (GtkWidget *widget,
|
||||
event->keyval == GDK_Right ||
|
||||
event->keyval == GDK_KP_Right)
|
||||
{
|
||||
GtkTreeSelection *sel;
|
||||
GtkTreeIter iter;
|
||||
GtkTreeModel *model = NULL;
|
||||
gboolean retval = TRUE;
|
||||
|
||||
_gtk_entry_reset_im_context (GTK_ENTRY (widget));
|
||||
_gtk_entry_completion_popdown (completion);
|
||||
|
||||
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (completion->priv->tree_view));
|
||||
if (!gtk_tree_selection_get_selected (sel, &model, &iter))
|
||||
if (completion->priv->current_selected < 0)
|
||||
{
|
||||
retval = FALSE;
|
||||
goto keypress_completion_out;
|
||||
@ -5959,6 +5974,8 @@ keypress_completion_out:
|
||||
event->keyval == GDK_KP_Enter ||
|
||||
event->keyval == GDK_Return)
|
||||
{
|
||||
gboolean retval = TRUE;
|
||||
|
||||
_gtk_entry_reset_im_context (GTK_ENTRY (widget));
|
||||
_gtk_entry_completion_popdown (completion);
|
||||
|
||||
@ -5970,34 +5987,31 @@ keypress_completion_out:
|
||||
gboolean entry_set;
|
||||
|
||||
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (completion->priv->tree_view));
|
||||
if (!gtk_tree_selection_get_selected (sel, &model, &iter))
|
||||
return FALSE;
|
||||
|
||||
g_signal_handler_block (widget, completion->priv->changed_id);
|
||||
g_signal_emit_by_name (completion, "match_selected",
|
||||
model, &iter, &entry_set);
|
||||
g_signal_handler_unblock (widget, completion->priv->changed_id);
|
||||
|
||||
if (!entry_set)
|
||||
if (gtk_tree_selection_get_selected (sel, &model, &iter))
|
||||
{
|
||||
gchar *str = NULL;
|
||||
g_signal_handler_block (widget, completion->priv->changed_id);
|
||||
g_signal_emit_by_name (completion, "match_selected",
|
||||
model, &iter, &entry_set);
|
||||
g_signal_handler_unblock (widget, completion->priv->changed_id);
|
||||
|
||||
gtk_tree_model_get (model, &iter,
|
||||
completion->priv->text_column, &str,
|
||||
-1);
|
||||
if (!entry_set)
|
||||
{
|
||||
gchar *str = NULL;
|
||||
|
||||
gtk_entry_set_text (GTK_ENTRY (widget), str);
|
||||
gtk_tree_model_get (model, &iter,
|
||||
completion->priv->text_column, &str,
|
||||
-1);
|
||||
|
||||
/* move the cursor to the end */
|
||||
gtk_editable_set_position (GTK_EDITABLE (widget), -1);
|
||||
gtk_entry_set_text (GTK_ENTRY (widget), str);
|
||||
|
||||
g_free (str);
|
||||
/* move the cursor to the end */
|
||||
gtk_editable_set_position (GTK_EDITABLE (widget), -1);
|
||||
|
||||
g_free (str);
|
||||
}
|
||||
}
|
||||
|
||||
g_free (completion->priv->completion_prefix);
|
||||
completion->priv->completion_prefix = NULL;
|
||||
|
||||
return TRUE;
|
||||
else
|
||||
retval = FALSE;
|
||||
}
|
||||
else if (completion->priv->current_selected - matches >= 0)
|
||||
{
|
||||
@ -6010,9 +6024,12 @@ keypress_completion_out:
|
||||
g_signal_emit_by_name (completion, "action_activated",
|
||||
gtk_tree_path_get_indices (path)[0]);
|
||||
gtk_tree_path_free (path);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
g_free (completion->priv->completion_prefix);
|
||||
completion->priv->completion_prefix = NULL;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
@ -1635,9 +1635,6 @@ 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;
|
||||
@ -1688,9 +1685,6 @@ gtk_entry_completion_insert_completion_text (GtkEntryCompletion *completion,
|
||||
if (priv->insert_text_id > 0)
|
||||
g_signal_handler_block (priv->entry, priv->insert_text_id);
|
||||
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user