mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-08-24 18:25:50 +00:00
window: Use GdkEvent accessors
This commit is contained in:
parent
ebac1a33d2
commit
2e62e2def6
|
@ -610,18 +610,29 @@ nautilus_window_slot_search (NautilusWindowSlot *self,
|
|||
|
||||
gboolean
|
||||
nautilus_window_slot_handle_event (NautilusWindowSlot *self,
|
||||
GdkEventKey *event)
|
||||
GdkEvent *event)
|
||||
{
|
||||
NautilusWindowSlotPrivate *priv;
|
||||
gboolean retval;
|
||||
GAction *action;
|
||||
guint keyval;
|
||||
|
||||
priv = nautilus_window_slot_get_instance_private (self);
|
||||
retval = FALSE;
|
||||
action = g_action_map_lookup_action (G_ACTION_MAP (priv->slot_action_group),
|
||||
"search-visible");
|
||||
|
||||
if (event->keyval == GDK_KEY_Escape)
|
||||
if (gdk_event_get_event_type (event) != GDK_KEY_PRESS)
|
||||
{
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
}
|
||||
|
||||
if (G_UNLIKELY (!gdk_event_get_keyval (event, &keyval)))
|
||||
{
|
||||
g_return_val_if_reached (GDK_EVENT_PROPAGATE);
|
||||
}
|
||||
|
||||
if (keyval == GDK_KEY_Escape)
|
||||
{
|
||||
g_autoptr (GVariant) state = NULL;
|
||||
|
||||
|
@ -636,8 +647,7 @@ nautilus_window_slot_handle_event (NautilusWindowSlot *self,
|
|||
/* If the action is not enabled, don't try to handle search */
|
||||
if (g_action_get_enabled (action))
|
||||
{
|
||||
retval = nautilus_query_editor_handle_event (priv->query_editor,
|
||||
(GdkEvent *) event);
|
||||
retval = nautilus_query_editor_handle_event (priv->query_editor, event);
|
||||
}
|
||||
|
||||
if (retval)
|
||||
|
|
|
@ -92,7 +92,7 @@ const gchar *nautilus_window_slot_get_title (NautilusWindowSlot *
|
|||
void nautilus_window_slot_update_title (NautilusWindowSlot *slot);
|
||||
|
||||
gboolean nautilus_window_slot_handle_event (NautilusWindowSlot *slot,
|
||||
GdkEventKey *event);
|
||||
GdkEvent *event);
|
||||
|
||||
void nautilus_window_slot_queue_reload (NautilusWindowSlot *slot);
|
||||
|
||||
|
|
|
@ -2458,26 +2458,32 @@ nautilus_window_key_press_event (GtkWidget *widget,
|
|||
GdkEventKey *event)
|
||||
{
|
||||
NautilusWindow *window;
|
||||
guint keyval;
|
||||
GtkWidget *focus_widget;
|
||||
int i;
|
||||
|
||||
window = NAUTILUS_WINDOW (widget);
|
||||
|
||||
if (G_UNLIKELY (!gdk_event_get_keyval ((GdkEvent *) event, &keyval)))
|
||||
{
|
||||
g_return_val_if_reached (GDK_EVENT_PROPAGATE);
|
||||
}
|
||||
|
||||
focus_widget = gtk_window_get_focus (GTK_WINDOW (window));
|
||||
if (focus_widget != NULL && GTK_IS_EDITABLE (focus_widget))
|
||||
{
|
||||
/* if we have input focus on a GtkEditable (e.g. a GtkEntry), forward
|
||||
* the event to it before activating accelerator bindings too.
|
||||
*/
|
||||
if (gtk_window_propagate_key_event (GTK_WINDOW (window), event))
|
||||
if (gtk_window_propagate_key_event (GTK_WINDOW (window),
|
||||
(GdkEventKey *) event))
|
||||
{
|
||||
return TRUE;
|
||||
return GDK_EVENT_STOP;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (extra_window_keybindings); i++)
|
||||
for (int i = 0; i < G_N_ELEMENTS (extra_window_keybindings); i++)
|
||||
{
|
||||
if (extra_window_keybindings[i].keyval == event->keyval)
|
||||
if (extra_window_keybindings[i].keyval == keyval)
|
||||
{
|
||||
GAction *action;
|
||||
|
||||
|
@ -2487,7 +2493,7 @@ nautilus_window_key_press_event (GtkWidget *widget,
|
|||
if (g_action_get_enabled (action))
|
||||
{
|
||||
g_action_activate (action, NULL);
|
||||
return TRUE;
|
||||
return GDK_EVENT_STOP;
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -2496,15 +2502,15 @@ nautilus_window_key_press_event (GtkWidget *widget,
|
|||
|
||||
if (GTK_WIDGET_CLASS (nautilus_window_parent_class)->key_press_event (widget, event))
|
||||
{
|
||||
return TRUE;
|
||||
return GDK_EVENT_STOP;
|
||||
}
|
||||
|
||||
if (nautilus_window_slot_handle_event (window->active_slot, event))
|
||||
if (nautilus_window_slot_handle_event (window->active_slot, (GdkEvent *) event))
|
||||
{
|
||||
return TRUE;
|
||||
return GDK_EVENT_STOP;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in a new issue