summaryrefslogtreecommitdiff
path: root/gtk/gtkentrycompletion.c
diff options
context:
space:
mode:
authorMatthias Clasen <maclas@gmx.de>2004-06-06 03:17:45 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2004-06-06 03:17:45 +0000
commit1640e34c8c08507fdf678aa14c597045f291dd10 (patch)
tree77cecbf194b7d79314540f81acdd060e2ef0aef3 /gtk/gtkentrycompletion.c
parente47c0d46b16e5eef904a807cec70a70570a1868f (diff)
downloadgtk+-1640e34c8c08507fdf678aa14c597045f291dd10.tar.gz
Add an ignore_enter flag and use it as in the menu code to avoid the
Sat Jun 5 23:07:30 2004 Matthias Clasen <maclas@gmx.de> * gtk/gtkentrycompletion.c: (gtk_entry_completion_init), (gtk_entry_completion_list_enter_notify), (gtk_entry_completion_list_motion_notify), (_gtk_entry_completion_popup), (_gtk_entry_completion_popdown): * gtk/gtkentryprivate.h: Add an ignore_enter flag and use it as in the menu code to avoid the initial selection if the window pops up under the pointer. (Anders Carlsson)
Diffstat (limited to 'gtk/gtkentrycompletion.c')
-rw-r--r--gtk/gtkentrycompletion.c48
1 files changed, 45 insertions, 3 deletions
diff --git a/gtk/gtkentrycompletion.c b/gtk/gtkentrycompletion.c
index 4747cb3a81..3d6f15a889 100644
--- a/gtk/gtkentrycompletion.c
+++ b/gtk/gtkentrycompletion.c
@@ -109,7 +109,12 @@ static gboolean gtk_entry_completion_action_button_press (GtkWidget
gpointer user_data);
static void gtk_entry_completion_selection_changed (GtkTreeSelection *selection,
gpointer data);
-
+static gboolean gtk_entry_completion_list_enter_notify (GtkWidget *widget,
+ GdkEventCrossing *event,
+ gpointer data);
+static gboolean gtk_entry_completion_list_motion_notify (GtkWidget *widget,
+ GdkEventMotion *event,
+ gpointer data);
static void gtk_entry_completion_insert_action (GtkEntryCompletion *completion,
gint index,
const gchar *string,
@@ -292,6 +297,12 @@ gtk_entry_completion_init (GtkEntryCompletion *completion)
g_signal_connect (priv->tree_view, "button_press_event",
G_CALLBACK (gtk_entry_completion_list_button_press),
completion);
+ g_signal_connect (priv->tree_view, "enter_notify_event",
+ G_CALLBACK (gtk_entry_completion_list_enter_notify),
+ completion);
+ g_signal_connect (priv->tree_view, "motion_notify_event",
+ G_CALLBACK (gtk_entry_completion_list_motion_notify),
+ completion);
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (priv->tree_view), FALSE);
gtk_tree_view_set_hover_selection (GTK_TREE_VIEW (priv->tree_view), TRUE);
@@ -324,6 +335,12 @@ gtk_entry_completion_init (GtkEntryCompletion *completion)
g_signal_connect (priv->action_view, "button_press_event",
G_CALLBACK (gtk_entry_completion_action_button_press),
completion);
+ g_signal_connect (priv->action_view, "enter_notify_event",
+ G_CALLBACK (gtk_entry_completion_list_enter_notify),
+ completion);
+ g_signal_connect (priv->action_view, "motion_notify_event",
+ G_CALLBACK (gtk_entry_completion_list_motion_notify),
+ completion);
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (priv->action_view), FALSE);
gtk_tree_view_set_hover_selection (GTK_TREE_VIEW (priv->action_view), TRUE);
@@ -1127,6 +1144,29 @@ get_borders (GtkEntry *entry,
}
}
+static gboolean
+gtk_entry_completion_list_enter_notify (GtkWidget *widget,
+ GdkEventCrossing *event,
+ gpointer data)
+{
+ GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (data);
+
+ return completion->priv->ignore_enter;
+}
+
+static gboolean
+gtk_entry_completion_list_motion_notify (GtkWidget *widget,
+ GdkEventMotion *event,
+ gpointer data)
+{
+ GtkEntryCompletion *completion = GTK_ENTRY_COMPLETION (data);
+
+ completion->priv->ignore_enter = FALSE;
+
+ return FALSE;
+}
+
+
/* some nasty size requisition */
gboolean
_gtk_entry_completion_resize_popup (GtkEntryCompletion *completion)
@@ -1227,8 +1267,8 @@ _gtk_entry_completion_popup (GtkEntryCompletion *completion)
if (GTK_WIDGET_MAPPED (completion->priv->popup_window))
return;
- completion->priv->may_wrap = TRUE;
-
+ completion->priv->ignore_enter = TRUE;
+
column = gtk_tree_view_get_column (GTK_TREE_VIEW (completion->priv->action_view), 0);
renderers = gtk_tree_view_column_get_cell_renderers (column);
gtk_widget_ensure_style (completion->priv->tree_view);
@@ -1254,6 +1294,8 @@ _gtk_entry_completion_popup (GtkEntryCompletion *completion)
void
_gtk_entry_completion_popdown (GtkEntryCompletion *completion)
{
+ completion->priv->ignore_enter = FALSE;
+
gdk_pointer_ungrab (GDK_CURRENT_TIME);
gtk_grab_remove (completion->priv->popup_window);