[gnome-builder/wip/chergert/headerbar] workbench: use workbench to swap perspectives



commit f0783daf85488b712b6965dfedfbf55754ef1172
Author: Christian Hergert <chergert redhat com>
Date:   Mon Jun 20 17:04:08 2016 -0700

    workbench: use workbench to swap perspectives
    
    Instead of directly toggling the stack, use the workbench to toggle the
    perspective. This simplifies things so we don't have to watch the stack
    in the workbench (and be re-entrant safe).

 libide/workbench/ide-perspective-menu-button.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/libide/workbench/ide-perspective-menu-button.c b/libide/workbench/ide-perspective-menu-button.c
index 1f21c9b..c0e99a8 100644
--- a/libide/workbench/ide-perspective-menu-button.c
+++ b/libide/workbench/ide-perspective-menu-button.c
@@ -22,6 +22,7 @@
 
 #include "workbench/ide-perspective.h"
 #include "workbench/ide-perspective-menu-button.h"
+#include "workbench/ide-workbench.h"
 
 struct _IdePerspectiveMenuButton
 {
@@ -254,16 +255,25 @@ ide_perspective_menu_button_row_activated (IdePerspectiveMenuButton *self,
                                            GtkListBox               *list_box)
 {
   const gchar *id;
+  GtkWidget *workbench;
 
   g_assert (IDE_IS_PERSPECTIVE_MENU_BUTTON (self));
   g_assert (GTK_IS_LIST_BOX_ROW (row));
   g_assert (GTK_IS_LIST_BOX (list_box));
 
+  workbench = gtk_widget_get_ancestor (GTK_WIDGET (self), IDE_TYPE_WORKBENCH);
   id = g_object_get_data (G_OBJECT (row), "IDE_PERSPECTIVE_ID");
 
-  if (id != NULL && GTK_IS_STACK (self->stack))
+  /*
+   * We use the workbench to set the perspective name rather than the stack
+   * so that it can have a simpler implementation of handling changes between
+   * perspectives. Otherwise, we have to be much more careful about
+   * re-entrancy issues.
+   */
+
+  if (id != NULL && IDE_IS_WORKBENCH (workbench))
     {
-      gtk_stack_set_visible_child_name (GTK_STACK (self->stack), id);
+      ide_workbench_set_visible_perspective_name (IDE_WORKBENCH (workbench), id);
       gtk_widget_hide (GTK_WIDGET (self->popover));
     }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]