Commit 2a8d52e1 authored by Guido Gunther's avatar Guido Gunther
Browse files

Merge branch 'overview-search' into 'master'

overview: Focus search when user starts typing

Closes #564

See merge request !861
parents 48a45abf 60f6a2e1
Pipeline #69789 passed with stages
in 52 minutes and 50 seconds
......@@ -605,6 +605,22 @@ phosh_app_grid_focus_search (PhoshAppGrid *self)
}
gboolean
phosh_app_grid_handle_search (PhoshAppGrid *self, GdkEvent *event)
{
PhoshAppGridPrivate *priv;
gboolean ret;
g_return_val_if_fail (PHOSH_IS_APP_GRID (self), GDK_EVENT_PROPAGATE);
priv = phosh_app_grid_get_instance_private (self);
ret = gtk_search_entry_handle_event (GTK_SEARCH_ENTRY (priv->search), event);
if (ret == GDK_EVENT_STOP)
gtk_entry_grab_focus_without_selecting (GTK_ENTRY (priv->search));
return ret;
}
void
phosh_app_grid_set_filter_adaptive (PhoshAppGrid *self, gboolean enable)
{
......
......@@ -37,6 +37,7 @@ struct _PhoshAppGridClass
GtkWidget *phosh_app_grid_new (void);
void phosh_app_grid_reset (PhoshAppGrid *self);
void phosh_app_grid_focus_search (PhoshAppGrid *self);
gboolean phosh_app_grid_handle_search (PhoshAppGrid *self, GdkEvent *event);
void phosh_app_grid_set_filter_adaptive (PhoshAppGrid *self, gboolean enable);
......
......@@ -202,22 +202,29 @@ on_has_activities_changed (PhoshHome *self)
static gboolean
key_press_event_cb (PhoshHome *self, GdkEventKey *event, gpointer data)
window_key_press_event_cb (PhoshHome *self, GdkEvent *event, gpointer data)
{
gboolean handled = FALSE;
g_return_val_if_fail (PHOSH_IS_HOME (self), FALSE);
gboolean ret = GDK_EVENT_PROPAGATE;
guint keyval;
g_return_val_if_fail (PHOSH_IS_HOME (self), GDK_EVENT_PROPAGATE);
switch (event->keyval) {
if (self->state != PHOSH_HOME_STATE_UNFOLDED)
return GDK_EVENT_PROPAGATE;
if (!gdk_event_get_keyval (event, &keyval))
return GDK_EVENT_PROPAGATE;
switch (keyval) {
case GDK_KEY_Escape:
phosh_home_set_state (self, PHOSH_HOME_STATE_FOLDED);
handled = TRUE;
ret = GDK_EVENT_STOP;
break;
default:
/* nothing to do */
break;
/* Focus search when typing */
ret = phosh_overview_handle_search (PHOSH_OVERVIEW (self->overview), event);
}
return handled;
return ret;
}
......@@ -313,12 +320,6 @@ phosh_home_constructed (GObject *object)
G_CALLBACK (phosh_home_resize),
NULL);
gtk_widget_add_events (GTK_WIDGET (self), GDK_KEY_PRESS_MASK);
g_signal_connect (G_OBJECT (self),
"key_press_event",
G_CALLBACK (key_press_event_cb),
NULL);
g_object_connect (self->settings,
"swapped-signal::changed::" KEYBINDING_KEY_TOGGLE_OVERVIEW,
on_keybindings_changed, self,
......@@ -402,6 +403,7 @@ phosh_home_class_init (PhoshHomeClass *klass)
gtk_widget_class_bind_template_callback (widget_class, home_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, on_has_activities_changed);
gtk_widget_class_bind_template_callback (widget_class, osk_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, window_key_press_event_cb);
gtk_widget_class_set_css_name (widget_class, "phosh-home");
}
......
......@@ -517,6 +517,18 @@ phosh_overview_focus_app_search (PhoshOverview *self)
phosh_app_grid_focus_search (PHOSH_APP_GRID (priv->app_grid));
}
gboolean
phosh_overview_handle_search (PhoshOverview *self, GdkEvent *event)
{
PhoshOverviewPrivate *priv;
g_return_val_if_fail(PHOSH_IS_OVERVIEW (self), GDK_EVENT_PROPAGATE);
priv = phosh_overview_get_instance_private (self);
return phosh_app_grid_handle_search (PHOSH_APP_GRID (priv->app_grid), event);
}
gboolean
phosh_overview_has_running_activities (PhoshOverview *self)
{
......
......@@ -21,6 +21,7 @@ GtkWidget *phosh_overview_new (void);
void phosh_overview_reset (PhoshOverview *self);
void phosh_overview_focus_app_search (PhoshOverview *self);
gboolean phosh_overview_has_running_activities (PhoshOverview *self);
gboolean phosh_overview_handle_search (PhoshOverview *self, GdkEvent *event);
PhoshAppGrid *phosh_overview_get_app_grid (PhoshOverview *self);
G_END_DECLS
......@@ -4,6 +4,7 @@
<requires lib="gtk+" version="3.20"/>
<template class="PhoshHome" parent="PhoshLayerSurface">
<property name="can_focus">False</property>
<signal name="key-press-event" handler="window_key_press_event_cb"/>
<child>
<placeholder/>
</child>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment