forked from AuroraMiddleware/gtk
search bar: Stop using ::key-press-event
Use a key event controller instead.
This commit is contained in:
parent
f231ac6541
commit
b033e30318
@ -1,11 +1,14 @@
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static gboolean
|
||||
window_key_press_event_cb (GtkWidget *window,
|
||||
GdkEvent *event,
|
||||
GtkSearchBar *search_bar)
|
||||
window_key_pressed (GtkEventController *controller,
|
||||
guint keyval,
|
||||
guint keycode,
|
||||
GdkModifierType state,
|
||||
GtkSearchBar *search_bar)
|
||||
{
|
||||
return gtk_search_bar_handle_event (search_bar, event);
|
||||
return gtk_search_bar_handle_event (search_bar,
|
||||
gtk_get_current_event ());
|
||||
}
|
||||
|
||||
static void
|
||||
@ -17,6 +20,7 @@ activate_cb (GtkApplication *app,
|
||||
GtkWidget *box;
|
||||
GtkWidget *entry;
|
||||
GtkWidget *menu_button;
|
||||
GtkEventController *controller;
|
||||
|
||||
window = gtk_application_window_new (app);
|
||||
gtk_widget_show (window);
|
||||
@ -37,8 +41,10 @@ activate_cb (GtkApplication *app,
|
||||
|
||||
gtk_search_bar_connect_entry (GTK_SEARCH_BAR (search_bar), GTK_ENTRY (entry));
|
||||
|
||||
g_signal_connect (window, "key-press-event",
|
||||
G_CALLBACK (window_key_press_event_cb), search_bar);
|
||||
controller = gtk_event_controller_key_new (window);
|
||||
g_object_set_data_full (G_OBJECT (window), "controller", controller, g_object_unref);
|
||||
g_signal_connect (controller, "key-pressed",
|
||||
G_CALLBACK (window_key_pressed), search_bar);
|
||||
}
|
||||
|
||||
gint
|
||||
|
Loading…
Reference in New Issue
Block a user