summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErnestas Kulik <ernestask@gnome.org>2018-05-22 12:37:36 +0300
committerErnestas Kulik <ernestask@gnome.org>2018-05-28 13:13:56 +0300
commit2e62e2def6100f9022bbcf9af23948850f08d4aa (patch)
tree1eeb37f2c57ee2c1d4aa114fa839f1778e5b4bd2
parentebac1a33d20eaaf5121b7ccc968a6b47365ea395 (diff)
downloadnautilus-2e62e2def6100f9022bbcf9af23948850f08d4aa.tar.gz
window: Use GdkEvent accessors
-rw-r--r--src/nautilus-window-slot.c18
-rw-r--r--src/nautilus-window-slot.h2
-rw-r--r--src/nautilus-window.c26
3 files changed, 31 insertions, 15 deletions
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index 6cbc0cf11..f9a15620c 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -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)
diff --git a/src/nautilus-window-slot.h b/src/nautilus-window-slot.h
index 6f1813062..883da5762 100644
--- a/src/nautilus-window-slot.h
+++ b/src/nautilus-window-slot.h
@@ -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);
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 28e6b0314..d655769d2 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -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