Merge branch 'event-controller-sensitive' into 'master'

Event controller sensitive

Closes #1861

See merge request GNOME/gtk!812
This commit is contained in:
Matthias Clasen 2019-05-02 21:03:41 +00:00
commit 05cb7e7412
4 changed files with 35 additions and 2 deletions

View File

@ -73,6 +73,18 @@ gtk_event_controller_unset_widget (GtkEventController *self)
priv->widget = NULL; priv->widget = NULL;
} }
static gboolean
gtk_event_controller_filter_event_default (GtkEventController *self,
const GdkEvent *event)
{
GtkEventControllerPrivate *priv = gtk_event_controller_get_instance_private (self);
if (priv->widget)
return !gtk_widget_is_sensitive (priv->widget);
return FALSE;
}
static gboolean static gboolean
gtk_event_controller_handle_event_default (GtkEventController *self, gtk_event_controller_handle_event_default (GtkEventController *self,
const GdkEvent *event) const GdkEvent *event)
@ -128,7 +140,7 @@ gtk_event_controller_class_init (GtkEventControllerClass *klass)
klass->set_widget = gtk_event_controller_set_widget; klass->set_widget = gtk_event_controller_set_widget;
klass->unset_widget = gtk_event_controller_unset_widget; klass->unset_widget = gtk_event_controller_unset_widget;
klass->filter_event = gtk_event_controller_handle_event_default; klass->filter_event = gtk_event_controller_filter_event_default;
klass->handle_event = gtk_event_controller_handle_event_default; klass->handle_event = gtk_event_controller_handle_event_default;
object_class->set_property = gtk_event_controller_set_property; object_class->set_property = gtk_event_controller_set_property;

View File

@ -628,7 +628,10 @@ gtk_gesture_filter_event (GtkEventController *controller,
* subclasses which punch the holes in for the events * subclasses which punch the holes in for the events
* they can possibly handle. * they can possibly handle.
*/ */
return EVENT_IS_TOUCHPAD_GESTURE (event); if (EVENT_IS_TOUCHPAD_GESTURE (event))
return FALSE;
return GTK_EVENT_CONTROLLER_CLASS (gtk_gesture_parent_class)->filter_event (controller, event);
} }
static gboolean static gboolean

View File

@ -809,6 +809,14 @@ button_released_cb (GtkGestureMultiPress *gesture,
} }
} }
static void
button_cancel_cb (GtkGesture *gesture,
GdkEventSequence *sequence,
GtkSpinButton *spin_button)
{
gtk_spin_button_stop_spinning (spin_button);
}
static void static void
key_controller_key_released (GtkEventControllerKey *key, key_controller_key_released (GtkEventControllerKey *key,
guint keyval, guint keyval,
@ -886,6 +894,7 @@ gtk_spin_button_init (GtkSpinButton *spin_button)
GTK_PHASE_CAPTURE); GTK_PHASE_CAPTURE);
g_signal_connect (gesture, "pressed", G_CALLBACK (button_pressed_cb), spin_button); g_signal_connect (gesture, "pressed", G_CALLBACK (button_pressed_cb), spin_button);
g_signal_connect (gesture, "released", G_CALLBACK (button_released_cb), spin_button); g_signal_connect (gesture, "released", G_CALLBACK (button_released_cb), spin_button);
g_signal_connect (gesture, "cancel", G_CALLBACK (button_cancel_cb), spin_button);
gtk_widget_add_controller (GTK_WIDGET (priv->down_button), GTK_EVENT_CONTROLLER (gesture)); gtk_widget_add_controller (GTK_WIDGET (priv->down_button), GTK_EVENT_CONTROLLER (gesture));
priv->up_button = gtk_button_new (); priv->up_button = gtk_button_new ();
@ -902,6 +911,7 @@ gtk_spin_button_init (GtkSpinButton *spin_button)
GTK_PHASE_CAPTURE); GTK_PHASE_CAPTURE);
g_signal_connect (gesture, "pressed", G_CALLBACK (button_pressed_cb), spin_button); g_signal_connect (gesture, "pressed", G_CALLBACK (button_pressed_cb), spin_button);
g_signal_connect (gesture, "released", G_CALLBACK (button_released_cb), spin_button); g_signal_connect (gesture, "released", G_CALLBACK (button_released_cb), spin_button);
g_signal_connect (gesture, "cancel", G_CALLBACK (button_cancel_cb), spin_button);
gtk_widget_add_controller (GTK_WIDGET (priv->up_button), GTK_EVENT_CONTROLLER (gesture)); gtk_widget_add_controller (GTK_WIDGET (priv->up_button), GTK_EVENT_CONTROLLER (gesture));
gtk_spin_button_set_adjustment (spin_button, NULL); gtk_spin_button_set_adjustment (spin_button, NULL);

View File

@ -6363,6 +6363,7 @@ gtk_widget_set_sensitive (GtkWidget *widget,
gboolean sensitive) gboolean sensitive)
{ {
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget); GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
GList *l;
g_return_if_fail (GTK_IS_WIDGET (widget)); g_return_if_fail (GTK_IS_WIDGET (widget));
@ -6373,6 +6374,13 @@ gtk_widget_set_sensitive (GtkWidget *widget,
priv->sensitive = sensitive; priv->sensitive = sensitive;
for (l = priv->event_controllers; l; l = l->next)
{
GtkEventController *controller = l->data;
gtk_event_controller_reset (controller);
}
if (priv->parent == NULL if (priv->parent == NULL
|| gtk_widget_is_sensitive (priv->parent)) || gtk_widget_is_sensitive (priv->parent))
{ {