Commit 3abaf0c6 authored by Christian Hergert's avatar Christian Hergert

workbench: propagate focus to perspectives

This can be handy to ensure we land our focus back on the perspective.
parent f03f8f98
......@@ -388,6 +388,16 @@ ide_editor_perspective_grid_empty (IdeEditorPerspective *self,
gtk_stack_set_visible_child_name (GTK_STACK (stack), "empty_state");
}
static void
ide_editor_perspective_grab_focus (GtkWidget *widget)
{
IdeEditorPerspective *self = (IdeEditorPerspective *)widget;
g_assert (IDE_IS_EDITOR_PERSPECTIVE (self));
gtk_widget_grab_focus (GTK_WIDGET (self->grid));
}
static void
ide_editor_perspective_get_property (GObject *object,
guint prop_id,
......@@ -417,6 +427,8 @@ ide_editor_perspective_class_init (IdeEditorPerspectiveClass *klass)
object_class->get_property = ide_editor_perspective_get_property;
object_class->finalize = ide_editor_perspective_finalize;
widget_class->grab_focus = ide_editor_perspective_grab_focus;
container_class->add = ide_editor_perspective_add;
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/builder/ui/ide-editor-perspective.ui");
......
......@@ -191,6 +191,19 @@ ide_workbench_delete_event (GtkWidget *widget,
return GDK_EVENT_PROPAGATE;
}
static void
ide_workbench_grab_focus (GtkWidget *widget)
{
IdeWorkbench *self = (IdeWorkbench *)widget;
GtkWidget *child;
g_assert (IDE_IS_WORKBENCH (self));
child = gtk_stack_get_visible_child (self->perspectives_stack);
if (child != NULL)
gtk_widget_grab_focus (child);
}
static void
ide_workbench_constructed (GObject *object)
{
......@@ -299,6 +312,7 @@ ide_workbench_class_init (IdeWorkbenchClass *klass)
object_class->get_property = ide_workbench_get_property;
object_class->set_property = ide_workbench_set_property;
widget_class->grab_focus = ide_workbench_grab_focus;
widget_class->delete_event = ide_workbench_delete_event;
/**
......
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