inspector: Update to using GdkEvent API

This commit is contained in:
Carlos Garnacho 2017-08-25 16:57:26 +02:00
parent 177f3ef655
commit 261fdad7ca
4 changed files with 40 additions and 27 deletions

View File

@ -223,8 +223,9 @@ property_query_event (GtkWidget *widget,
gpointer data)
{
GtkInspectorWindow *iw = (GtkInspectorWindow *)data;
GdkEventType event_type = gdk_event_get_event_type (event);
if (event->type == GDK_BUTTON_RELEASE)
if (event_type == GDK_BUTTON_RELEASE)
{
g_signal_handlers_disconnect_by_func (widget, property_query_event, data);
gtk_grab_remove (widget);
@ -234,15 +235,15 @@ property_query_event (GtkWidget *widget,
on_inspect_widget (widget, event, data);
}
else if (event->type == GDK_MOTION_NOTIFY)
else if (event_type == GDK_MOTION_NOTIFY)
{
on_highlight_widget (widget, event, data);
}
else if (event->type == GDK_KEY_PRESS)
else if (event_type == GDK_KEY_PRESS)
{
GdkEventKey *ke = (GdkEventKey*)event;
guint keyval;
if (ke->keyval == GDK_KEY_Escape)
if (gdk_event_get_keyval (event, &keyval) && keyval == GDK_KEY_Escape)
{
g_signal_handlers_disconnect_by_func (widget, property_query_event, data);
gtk_grab_remove (widget);

View File

@ -704,7 +704,11 @@ key_press_event (GtkWidget *window,
GdkEvent *event,
GtkInspectorObjectTree *wt)
{
if (gtk_widget_get_mapped (GTK_WIDGET (wt)))
guint keyval, state;
if (gtk_widget_get_mapped (GTK_WIDGET (wt)) &&
gdk_event_get_keyval (event, &keyval) &&
gdk_event_get_state (event, &state))
{
GdkModifierType default_accel;
gboolean search_started;
@ -713,9 +717,9 @@ key_press_event (GtkWidget *window,
default_accel = gtk_widget_get_modifier_mask (GTK_WIDGET (wt), GDK_MODIFIER_INTENT_PRIMARY_ACCELERATOR);
if (search_started &&
(event->key.keyval == GDK_KEY_Return ||
event->key.keyval == GDK_KEY_ISO_Enter ||
event->key.keyval == GDK_KEY_KP_Enter))
(keyval == GDK_KEY_Return ||
keyval == GDK_KEY_ISO_Enter ||
keyval == GDK_KEY_KP_Enter))
{
GtkTreeSelection *selection;
GtkTreeModel *model;
@ -737,14 +741,14 @@ key_press_event (GtkWidget *window,
return GDK_EVENT_PROPAGATE;
}
else if (search_started &&
(event->key.keyval == GDK_KEY_Escape))
(keyval == GDK_KEY_Escape))
{
gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (wt->priv->search_bar), FALSE);
return GDK_EVENT_STOP;
}
else if (search_started &&
((event->key.state & (default_accel | GDK_SHIFT_MASK)) == (default_accel | GDK_SHIFT_MASK)) &&
(event->key.keyval == GDK_KEY_g || event->key.keyval == GDK_KEY_G))
((state & (default_accel | GDK_SHIFT_MASK)) == (default_accel | GDK_SHIFT_MASK)) &&
(keyval == GDK_KEY_g || keyval == GDK_KEY_G))
{
GtkTreeIter iter;
if (gtk_tree_walk_next_match (wt->priv->walk, TRUE, TRUE, &iter))
@ -755,8 +759,8 @@ key_press_event (GtkWidget *window,
return GDK_EVENT_STOP;
}
else if (search_started &&
((event->key.state & (default_accel | GDK_SHIFT_MASK)) == default_accel) &&
(event->key.keyval == GDK_KEY_g || event->key.keyval == GDK_KEY_G))
((state & (default_accel | GDK_SHIFT_MASK)) == default_accel) &&
(keyval == GDK_KEY_g || keyval == GDK_KEY_G))
{
GtkTreeIter iter;

View File

@ -395,7 +395,11 @@ key_press_event (GtkWidget *window,
GdkEvent *event,
GtkInspectorResourceList *sl)
{
if (gtk_widget_get_mapped (GTK_WIDGET (sl)))
guint keyval, state;
if (gtk_widget_get_mapped (GTK_WIDGET (sl)) &&
gdk_event_get_keyval (event, &keyval) &&
gdk_event_get_state (event, &state))
{
GdkModifierType default_accel;
gboolean search_started;
@ -404,9 +408,9 @@ key_press_event (GtkWidget *window,
default_accel = gtk_widget_get_modifier_mask (GTK_WIDGET (sl), GDK_MODIFIER_INTENT_PRIMARY_ACCELERATOR);
if (search_started &&
(event->key.keyval == GDK_KEY_Return ||
event->key.keyval == GDK_KEY_ISO_Enter ||
event->key.keyval == GDK_KEY_KP_Enter))
(keyval == GDK_KEY_Return ||
keyval == GDK_KEY_ISO_Enter ||
keyval == GDK_KEY_KP_Enter))
{
GtkTreeSelection *selection;
GtkTreeModel *model;
@ -428,14 +432,14 @@ key_press_event (GtkWidget *window,
return GDK_EVENT_PROPAGATE;
}
else if (search_started &&
(event->key.keyval == GDK_KEY_Escape))
(keyval == GDK_KEY_Escape))
{
gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (sl->priv->search_bar), FALSE);
return GDK_EVENT_STOP;
}
else if (search_started &&
((event->key.state & (default_accel | GDK_SHIFT_MASK)) == (default_accel | GDK_SHIFT_MASK)) &&
(event->key.keyval == GDK_KEY_g || event->key.keyval == GDK_KEY_G))
((state & (default_accel | GDK_SHIFT_MASK)) == (default_accel | GDK_SHIFT_MASK)) &&
(keyval == GDK_KEY_g || keyval == GDK_KEY_G))
{
GtkTreeIter iter;
if (gtk_tree_walk_next_match (sl->priv->walk, TRUE, TRUE, &iter))
@ -446,8 +450,8 @@ key_press_event (GtkWidget *window,
return GDK_EVENT_STOP;
}
else if (search_started &&
((event->key.state & (default_accel | GDK_SHIFT_MASK)) == default_accel) &&
(event->key.keyval == GDK_KEY_g || event->key.keyval == GDK_KEY_G))
((state & (default_accel | GDK_SHIFT_MASK)) == default_accel) &&
(keyval == GDK_KEY_g || keyval == GDK_KEY_G))
{
GtkTreeIter iter;

View File

@ -252,11 +252,15 @@ key_press_event (GtkWidget *window,
GdkEvent *event,
GtkInspectorStatistics *sl)
{
if (gtk_widget_get_mapped (GTK_WIDGET (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 (event->key.keyval == GDK_KEY_Return ||
event->key.keyval == GDK_KEY_ISO_Enter ||
event->key.keyval == GDK_KEY_KP_Enter)
if (keyval == GDK_KEY_Return ||
keyval == GDK_KEY_ISO_Enter ||
keyval == GDK_KEY_KP_Enter)
{
GtkTreeSelection *selection;
GtkTreeModel *model;