inspector: Use search bar API to capture key events from the toplevel

This commit is contained in:
Carlos Garnacho 2018-03-11 13:54:54 +01:00
parent 20c1e24b60
commit 0b3b81a8bf
3 changed files with 18 additions and 17 deletions

View File

@ -784,18 +784,16 @@ key_pressed (GtkEventController *controller,
return GDK_EVENT_STOP;
}
return gtk_search_bar_handle_event (GTK_SEARCH_BAR (wt->priv->search_bar),
gtk_get_current_event ());
}
else
return GDK_EVENT_PROPAGATE;
return GDK_EVENT_PROPAGATE;
}
static void
on_hierarchy_changed (GtkWidget *widget,
GtkWidget *previous_toplevel)
{
GtkInspectorObjectTree *wt = GTK_INSPECTOR_OBJECT_TREE (widget);
GtkEventController *controller;
GtkWidget *toplevel;
@ -806,6 +804,9 @@ on_hierarchy_changed (GtkWidget *widget,
controller = gtk_event_controller_key_new (toplevel);
g_object_set_data_full (G_OBJECT (toplevel), "controller", controller, g_object_unref);
g_signal_connect (controller, "key-pressed", G_CALLBACK (key_pressed), widget);
gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (wt->priv->search_bar),
toplevel);
}
static void

View File

@ -464,18 +464,16 @@ key_pressed (GtkEventController *controller,
return GDK_EVENT_STOP;
}
return gtk_search_bar_handle_event (GTK_SEARCH_BAR (sl->priv->search_bar),
gtk_get_current_event ());
}
else
return GDK_EVENT_PROPAGATE;
return GDK_EVENT_PROPAGATE;
}
static void
on_hierarchy_changed (GtkWidget *widget,
GtkWidget *previous_toplevel)
{
GtkInspectorResourceList *sl = GTK_INSPECTOR_RESOURCE_LIST (widget);
GtkEventController *controller;
GtkWidget *toplevel;
@ -486,6 +484,9 @@ on_hierarchy_changed (GtkWidget *widget,
controller = gtk_event_controller_key_new (toplevel);
g_object_set_data_full (G_OBJECT (toplevel), "controller", controller, g_object_unref);
g_signal_connect (controller, "key-pressed", G_CALLBACK (key_pressed), widget);
gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (sl->priv->search_bar),
toplevel);
}
static void

View File

@ -278,15 +278,10 @@ key_pressed (GtkEventController *controller,
return GDK_EVENT_STOP;
}
else
return GDK_EVENT_PROPAGATE;
}
return gtk_search_bar_handle_event (GTK_SEARCH_BAR (sl->priv->search_bar),
gtk_get_current_event ());
}
else
return GDK_EVENT_PROPAGATE;
return GDK_EVENT_PROPAGATE;
}
static gboolean
@ -329,6 +324,7 @@ static void
hierarchy_changed (GtkWidget *widget,
GtkWidget *previous_toplevel)
{
GtkInspectorStatistics *sl = GTK_INSPECTOR_STATISTICS (widget);
GtkEventController *controller;
GtkWidget *toplevel;
@ -339,6 +335,9 @@ hierarchy_changed (GtkWidget *widget,
controller = gtk_event_controller_key_new (toplevel);
g_object_set_data_full (G_OBJECT (toplevel), "controller", controller, g_object_unref);
g_signal_connect (controller, "key-pressed", G_CALLBACK (key_pressed), widget);
gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (sl->priv->search_bar),
toplevel);
}
static void