[gnome-builder] stack: focus previously focused view when closing current view
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] stack: focus previously focused view when closing current view
- Date: Thu, 23 Apr 2015 22:16:07 +0000 (UTC)
commit cc3d0b5808d7e463ef90d2ef19996ee42b252581
Author: Christian Hergert <christian hergert me>
Date: Thu Apr 23 15:16:01 2015 -0700
stack: focus previously focused view when closing current view
We tried to do this previously, but the focus list was getting mucked
with between the them we removed the item and the time we checked the
list.
This instead checks the list before performing the operation so that we
have access to it even when the focus chain has been mutated due to
intermittent GtkStack changes.
src/views/gb-view-stack.c | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/src/views/gb-view-stack.c b/src/views/gb-view-stack.c
index 1fd349d..f524cb4 100644
--- a/src/views/gb-view-stack.c
+++ b/src/views/gb-view-stack.c
@@ -183,10 +183,15 @@ gb_view_stack_remove (GbViewStack *self,
GbView *view)
{
GtkWidget *controls;
+ GtkWidget *focus_after_close = NULL;
g_assert (GB_IS_VIEW_STACK (self));
g_assert (GB_IS_VIEW (view));
+ focus_after_close = g_list_nth_data (self->focus_history, 1);
+ if (focus_after_close != NULL)
+ g_object_ref (focus_after_close);
+
gb_view_stack_remove_list_row (self, view);
self->focus_history = g_list_remove (self->focus_history, view);
@@ -195,13 +200,11 @@ gb_view_stack_remove (GbViewStack *self,
gtk_container_remove (GTK_CONTAINER (self->controls_stack), controls);
gtk_container_remove (GTK_CONTAINER (self->stack), GTK_WIDGET (view));
- if (self->focus_history)
+ if (focus_after_close != NULL)
{
- GtkWidget *child;
-
- child = self->focus_history->data;
- gtk_stack_set_visible_child (self->stack, child);
- gtk_widget_grab_focus (GTK_WIDGET (child));
+ gtk_stack_set_visible_child (self->stack, focus_after_close);
+ gtk_widget_grab_focus (GTK_WIDGET (focus_after_close));
+ g_clear_object (&focus_after_close);
}
else
g_signal_emit (self, gSignals [EMPTY], 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]