forked from AuroraMiddleware/gtk
inspector: Stop using ::key-press-event
This commit is contained in:
parent
75024fea60
commit
c2bd7fcf35
@ -48,6 +48,7 @@
|
||||
#include "gtkstylecontext.h"
|
||||
#include "gtksearchbar.h"
|
||||
#include "gtksearchentry.h"
|
||||
#include "gtkeventcontrollerkey.h"
|
||||
#include "treewalk.h"
|
||||
|
||||
enum
|
||||
@ -714,15 +715,13 @@ move_search_to_row (GtkInspectorObjectTree *wt,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
key_press_event (GtkWidget *window,
|
||||
GdkEvent *event,
|
||||
GtkInspectorObjectTree *wt)
|
||||
key_pressed (GtkEventController *controller,
|
||||
guint keyval,
|
||||
guint keycode,
|
||||
GdkModifierType state,
|
||||
GtkInspectorObjectTree *wt)
|
||||
{
|
||||
guint keyval, state;
|
||||
|
||||
if (gtk_widget_get_mapped (GTK_WIDGET (wt)) &&
|
||||
gdk_event_get_keyval (event, &keyval) &&
|
||||
gdk_event_get_state (event, &state))
|
||||
if (gtk_widget_get_mapped (GTK_WIDGET (wt)))
|
||||
{
|
||||
GdkModifierType default_accel;
|
||||
gboolean search_started;
|
||||
@ -786,7 +785,8 @@ key_press_event (GtkWidget *window,
|
||||
return GDK_EVENT_STOP;
|
||||
}
|
||||
|
||||
return gtk_search_bar_handle_event (GTK_SEARCH_BAR (wt->priv->search_bar), event);
|
||||
return gtk_search_bar_handle_event (GTK_SEARCH_BAR (wt->priv->search_bar),
|
||||
gtk_get_current_event ());
|
||||
}
|
||||
else
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
@ -796,10 +796,16 @@ static void
|
||||
on_hierarchy_changed (GtkWidget *widget,
|
||||
GtkWidget *previous_toplevel)
|
||||
{
|
||||
GtkEventController *controller;
|
||||
GtkWidget *toplevel;
|
||||
|
||||
if (previous_toplevel)
|
||||
g_signal_handlers_disconnect_by_func (previous_toplevel, key_press_event, widget);
|
||||
g_signal_connect (gtk_widget_get_toplevel (widget), "key-press-event",
|
||||
G_CALLBACK (key_press_event), widget);
|
||||
g_object_set_data (G_OBJECT (previous_toplevel), "controller", NULL);
|
||||
|
||||
toplevel = gtk_widget_get_toplevel (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);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -35,7 +35,9 @@
|
||||
#include "gtkpopover.h"
|
||||
#include "gtksearchentry.h"
|
||||
#include "gtklabel.h"
|
||||
#include "gtkmain.h"
|
||||
#include "gtkstack.h"
|
||||
#include "gtkeventcontrollerkey.h"
|
||||
|
||||
enum
|
||||
{
|
||||
@ -82,18 +84,22 @@ search_close_clicked (GtkWidget *button,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
key_press_event (GtkWidget *window,
|
||||
GdkEvent *event,
|
||||
GtkInspectorPropList *pl)
|
||||
key_pressed (GtkEventController *controller,
|
||||
guint keyval,
|
||||
guint keycode,
|
||||
GdkModifierType state,
|
||||
GtkInspectorPropList *pl)
|
||||
{
|
||||
if (!gtk_widget_get_mapped (GTK_WIDGET (pl)))
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
|
||||
if (gtk_search_entry_handle_event (GTK_SEARCH_ENTRY (pl->priv->search_entry), event))
|
||||
if (gtk_search_entry_handle_event (GTK_SEARCH_ENTRY (pl->priv->search_entry),
|
||||
gtk_get_current_event ()))
|
||||
{
|
||||
gtk_stack_set_visible_child (GTK_STACK (pl->priv->search_stack), pl->priv->search_entry);
|
||||
return GDK_EVENT_STOP;
|
||||
}
|
||||
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
}
|
||||
|
||||
@ -101,10 +107,16 @@ static void
|
||||
hierarchy_changed (GtkWidget *widget,
|
||||
GtkWidget *previous_toplevel)
|
||||
{
|
||||
GtkEventController *controller;
|
||||
GtkWidget *toplevel;
|
||||
|
||||
if (previous_toplevel)
|
||||
g_signal_handlers_disconnect_by_func (previous_toplevel, key_press_event, widget);
|
||||
g_signal_connect (gtk_widget_get_toplevel (widget), "key-press-event",
|
||||
G_CALLBACK (key_press_event), widget);
|
||||
g_object_set_data (G_OBJECT (previous_toplevel), "controller", NULL);
|
||||
|
||||
toplevel = gtk_widget_get_toplevel (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);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "gtktextbuffer.h"
|
||||
#include "gtktreeselection.h"
|
||||
#include "gtktreestore.h"
|
||||
#include "gtkeventcontrollerkey.h"
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
|
||||
@ -394,15 +395,13 @@ move_search_to_row (GtkInspectorResourceList *sl,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
key_press_event (GtkWidget *window,
|
||||
GdkEvent *event,
|
||||
GtkInspectorResourceList *sl)
|
||||
key_pressed (GtkEventController *controller,
|
||||
guint keyval,
|
||||
guint keycode,
|
||||
GdkModifierType state,
|
||||
GtkInspectorResourceList *sl)
|
||||
{
|
||||
guint keyval, state;
|
||||
|
||||
if (gtk_widget_get_mapped (GTK_WIDGET (sl)) &&
|
||||
gdk_event_get_keyval (event, &keyval) &&
|
||||
gdk_event_get_state (event, &state))
|
||||
if (gtk_widget_get_mapped (GTK_WIDGET (sl)))
|
||||
{
|
||||
GdkModifierType default_accel;
|
||||
gboolean search_started;
|
||||
@ -466,7 +465,8 @@ key_press_event (GtkWidget *window,
|
||||
return GDK_EVENT_STOP;
|
||||
}
|
||||
|
||||
return gtk_search_bar_handle_event (GTK_SEARCH_BAR (sl->priv->search_bar), event);
|
||||
return gtk_search_bar_handle_event (GTK_SEARCH_BAR (sl->priv->search_bar),
|
||||
gtk_get_current_event ());
|
||||
}
|
||||
else
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
@ -476,10 +476,16 @@ static void
|
||||
on_hierarchy_changed (GtkWidget *widget,
|
||||
GtkWidget *previous_toplevel)
|
||||
{
|
||||
GtkEventController *controller;
|
||||
GtkWidget *toplevel;
|
||||
|
||||
if (previous_toplevel)
|
||||
g_signal_handlers_disconnect_by_func (previous_toplevel, key_press_event, widget);
|
||||
g_signal_connect (gtk_widget_get_toplevel (widget), "key-press-event",
|
||||
G_CALLBACK (key_press_event), widget);
|
||||
g_object_set_data (G_OBJECT (previous_toplevel), "controller", NULL);
|
||||
|
||||
toplevel = gtk_widget_get_toplevel (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);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -29,6 +29,8 @@
|
||||
#include "gtktogglebutton.h"
|
||||
#include "gtktreeselection.h"
|
||||
#include "gtktreeview.h"
|
||||
#include "gtkeventcontrollerkey.h"
|
||||
#include "gtkmain.h"
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
|
||||
@ -250,15 +252,13 @@ type_data_free (gpointer data)
|
||||
}
|
||||
|
||||
static gboolean
|
||||
key_press_event (GtkWidget *window,
|
||||
GdkEvent *event,
|
||||
GtkInspectorStatistics *sl)
|
||||
key_pressed (GtkEventController *controller,
|
||||
guint keyval,
|
||||
guint keycode,
|
||||
GdkModifierType state,
|
||||
GtkInspectorStatistics *sl)
|
||||
{
|
||||
guint keyval, state;
|
||||
|
||||
if (gtk_widget_get_mapped (GTK_WIDGET (sl)) &&
|
||||
gdk_event_get_keyval (event, &keyval) &&
|
||||
gdk_event_get_state (event, &state))
|
||||
if (gtk_widget_get_mapped (GTK_WIDGET (sl)))
|
||||
{
|
||||
if (keyval == GDK_KEY_Return ||
|
||||
keyval == GDK_KEY_ISO_Enter ||
|
||||
@ -282,7 +282,8 @@ key_press_event (GtkWidget *window,
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
}
|
||||
|
||||
return gtk_search_bar_handle_event (GTK_SEARCH_BAR (sl->priv->search_bar), event);
|
||||
return gtk_search_bar_handle_event (GTK_SEARCH_BAR (sl->priv->search_bar),
|
||||
gtk_get_current_event ());
|
||||
}
|
||||
else
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
@ -328,10 +329,16 @@ static void
|
||||
hierarchy_changed (GtkWidget *widget,
|
||||
GtkWidget *previous_toplevel)
|
||||
{
|
||||
GtkEventController *controller;
|
||||
GtkWidget *toplevel;
|
||||
|
||||
if (previous_toplevel)
|
||||
g_signal_handlers_disconnect_by_func (previous_toplevel, key_press_event, widget);
|
||||
g_signal_connect (gtk_widget_get_toplevel (widget), "key-press-event",
|
||||
G_CALLBACK (key_press_event), widget);
|
||||
g_object_set_data (G_OBJECT (previous_toplevel), "controller", NULL);
|
||||
|
||||
toplevel = gtk_widget_get_toplevel (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);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user