Merge branch 'wip/carlosg/fix-search-entry' into 'master'

Fix search bars

See merge request GNOME/gtk!593
This commit is contained in:
Matthias Clasen 2019-02-20 17:02:15 +00:00
commit b9a41a903b
6 changed files with 23 additions and 14 deletions

View File

@ -35,6 +35,7 @@
#include "gtkeventcontrollerprivate.h"
#include "gtkeventcontrollerkey.h"
#include "gtkbindings.h"
#include "gtkenums.h"
#include <gdk/gdk.h>
@ -342,9 +343,14 @@ gtk_event_controller_key_forward (GtkEventControllerKey *controller,
if (!gtk_widget_get_realized (widget))
gtk_widget_realize (widget);
if (_gtk_widget_captured_event (widget, controller->current_event))
if (gtk_widget_run_controllers (widget, controller->current_event,
GTK_PHASE_CAPTURE))
return TRUE;
if (gtk_widget_event (widget, controller->current_event))
if (gtk_widget_run_controllers (widget, controller->current_event,
GTK_PHASE_TARGET))
return TRUE;
if (gtk_widget_run_controllers (widget, controller->current_event,
GTK_PHASE_BUBBLE))
return TRUE;
return FALSE;

View File

@ -643,6 +643,9 @@ capture_widget_key_handled (GtkEventControllerKey *controller,
GtkSearchBarPrivate *priv = gtk_search_bar_get_instance_private (bar);
gboolean handled;
if (!gtk_widget_get_mapped (GTK_WIDGET (bar)))
return GDK_EVENT_PROPAGATE;
if (priv->reveal_child)
return GDK_EVENT_PROPAGATE;

View File

@ -622,7 +622,7 @@ capture_widget_key_handled (GtkEventControllerKey *controller,
priv->content_changed = FALSE;
priv->search_stopped = FALSE;
handled = gtk_event_controller_key_forward (controller, entry);
handled = gtk_event_controller_key_forward (controller, priv->entry);
return handled && priv->content_changed && !priv->search_stopped ? GDK_EVENT_STOP : GDK_EVENT_PROPAGATE;
}

View File

@ -5076,8 +5076,8 @@ _gtk_widget_set_captured_event_handler (GtkWidget *widget,
g_object_set_data (G_OBJECT (widget), I_("captured-event-handler"), callback);
}
static gboolean
_gtk_widget_run_controllers (GtkWidget *widget,
gboolean
gtk_widget_run_controllers (GtkWidget *widget,
const GdkEvent *event,
GtkPropagationPhase phase)
{
@ -5151,7 +5151,7 @@ _gtk_widget_captured_event (GtkWidget *widget,
return FALSE;
}
return_val = _gtk_widget_run_controllers (widget, event_copy, GTK_PHASE_CAPTURE);
return_val = gtk_widget_run_controllers (widget, event_copy, GTK_PHASE_CAPTURE);
handler = g_object_get_data (G_OBJECT (widget), I_("captured-event-handler"));
if (!handler)
@ -5258,10 +5258,10 @@ gtk_widget_event_internal (GtkWidget *widget,
}
if (widget == gtk_get_event_target (event_copy))
return_val |= _gtk_widget_run_controllers (widget, event_copy, GTK_PHASE_TARGET);
return_val |= gtk_widget_run_controllers (widget, event_copy, GTK_PHASE_TARGET);
if (return_val == FALSE)
return_val |= _gtk_widget_run_controllers (widget, event_copy, GTK_PHASE_BUBBLE);
return_val |= gtk_widget_run_controllers (widget, event_copy, GTK_PHASE_BUBBLE);
g_object_unref (event_copy);
if (return_val == FALSE &&

View File

@ -338,9 +338,9 @@ void gtk_widget_cancel_event_sequence (GtkWidget
GdkEventSequence *sequence,
GtkEventSequenceState state);
gboolean gtk_widget_run_controllers (GtkWidget *widget,
const GdkEvent *event,
GtkPropagationPhase phase);
/* inline getters */

View File

@ -508,7 +508,7 @@ on_search_changed (GtkSearchEntry *entry,
gint length;
gboolean backwards;
length = strlen (gtk_entry_get_text (GTK_ENTRY (entry)));
length = strlen (gtk_editable_get_text (GTK_EDITABLE (entry)));
backwards = length < sl->priv->search_length;
sl->priv->search_length = length;