[gnome-builder/gnome-builder-3-30] editor: add interstitial screen while restoring editor state



commit a8f1223f4bbb688d70180650d9f0feaa51f10cd9
Author: Christian Hergert <chergert redhat com>
Date:   Wed Oct 3 12:14:47 2018 -0700

    editor: add interstitial screen while restoring editor state
    
    This allows us to hide the editor views while we are restoring state, which
    is useful because it means that we don't need to do any drawing while the
    documents load (and therefore, no CSS idle-sizer which was causing some
    critical's in the console).
    
    Fixes #656

 src/libide/editor/ide-editor-perspective.c   | 12 ++++++++++++
 src/libide/editor/ide-editor-perspective.ui  | 24 ++++++++++++++++++++++--
 src/libide/editor/ide-editor-private.h       |  3 +++
 src/libide/editor/ide-editor-session-addin.c | 18 +++++++++++++++++-
 4 files changed, 54 insertions(+), 3 deletions(-)
---
diff --git a/src/libide/editor/ide-editor-perspective.c b/src/libide/editor/ide-editor-perspective.c
index 5d2a20dfb..b5e43a3a9 100644
--- a/src/libide/editor/ide-editor-perspective.c
+++ b/src/libide/editor/ide-editor-perspective.c
@@ -343,6 +343,7 @@ ide_editor_perspective_class_init (IdeEditorPerspectiveClass *klass)
   gtk_widget_class_bind_template_child (widget_class, IdeEditorPerspective, grid);
   gtk_widget_class_bind_template_child (widget_class, IdeEditorPerspective, overlay);
   gtk_widget_class_bind_template_child (widget_class, IdeEditorPerspective, properties);
+  gtk_widget_class_bind_template_child (widget_class, IdeEditorPerspective, loading_stack);
 
   g_type_ensure (IDE_TYPE_EDITOR_PROPERTIES);
   g_type_ensure (IDE_TYPE_EDITOR_SIDEBAR);
@@ -944,3 +945,14 @@ ide_editor_perspective_get_overlay (IdeEditorPerspective *self)
 
   return GTK_WIDGET (self->overlay);
 }
+
+void
+_ide_editor_perspective_set_loading (IdeEditorPerspective *self,
+                                     gboolean              loading)
+{
+  g_return_if_fail (IDE_IS_EDITOR_PERSPECTIVE (self));
+
+  gtk_widget_set_visible (GTK_WIDGET (self->grid), !loading);
+  gtk_stack_set_visible_child_name (self->loading_stack,
+                                    loading ? "empty_state" : "grid");
+}
diff --git a/src/libide/editor/ide-editor-perspective.ui b/src/libide/editor/ide-editor-perspective.ui
index 8d98bdb92..5a46e695f 100644
--- a/src/libide/editor/ide-editor-perspective.ui
+++ b/src/libide/editor/ide-editor-perspective.ui
@@ -15,9 +15,29 @@
       <object class="GtkOverlay" id="overlay">
         <property name="visible">true</property>
         <child>
-          <object class="IdeLayoutGrid" id="grid">
-            <property name="orientation">horizontal</property>
+          <object class="GtkStack" id="loading_stack">
             <property name="visible">true</property>
+            <property name="transition-type">crossfade</property>
+            <child>
+              <object class="DzlEmptyState" id="empty_state">
+                <property name="icon-name">document-open-recent-symbolic</property>
+                <property name="title" translatable="yes">Restoring previous session</property>
+                <property name="subtitle" translatable="yes">Your previous session will be ready 
momentarily.</property>
+                <property name="visible">true</property>
+              </object>
+              <packing>
+                <property name="name">empty_state</property>
+              </packing>
+            </child>
+            <child>
+              <object class="IdeLayoutGrid" id="grid">
+                <property name="orientation">horizontal</property>
+                <property name="visible">true</property>
+              </object>
+              <packing>
+                <property name="name">grid</property>
+              </packing>
+            </child>
           </object>
         </child>
       </object>
diff --git a/src/libide/editor/ide-editor-private.h b/src/libide/editor/ide-editor-private.h
index 5cdbe8777..4551f48cd 100644
--- a/src/libide/editor/ide-editor-private.h
+++ b/src/libide/editor/ide-editor-private.h
@@ -44,6 +44,7 @@ struct _IdeEditorPerspective
   IdeLayoutGrid       *grid;
   GtkOverlay          *overlay;
   IdeEditorProperties *properties;
+  GtkStack            *loading_stack;
 
   /* State before entering focus mode */
   guint                prefocus_had_left : 1;
@@ -97,6 +98,8 @@ void _ide_editor_sidebar_set_open_pages      (IdeEditorSidebar     *self,
                                               GListModel           *open_pages);
 void _ide_editor_perspective_show_properties (IdeEditorPerspective *self,
                                               IdeEditorView        *view);
+void _ide_editor_perspective_set_loading     (IdeEditorPerspective *self,
+                                              gboolean              loading);
 void _ide_editor_perspective_init_actions    (IdeEditorPerspective *self);
 void _ide_editor_perspective_init_shortcuts  (IdeEditorPerspective *self);
 
diff --git a/src/libide/editor/ide-editor-session-addin.c b/src/libide/editor/ide-editor-session-addin.c
index b2408353d..f330ee73a 100644
--- a/src/libide/editor/ide-editor-session-addin.c
+++ b/src/libide/editor/ide-editor-session-addin.c
@@ -29,6 +29,7 @@
 #include "buffers/ide-buffer-manager.h"
 #include "editor/ide-editor-session-addin.h"
 #include "editor/ide-editor-perspective.h"
+#include "editor/ide-editor-private.h"
 #include "editor/ide-editor-view.h"
 #include "files/ide-file.h"
 #include "layout/ide-layout-grid.h"
@@ -272,6 +273,8 @@ load_state_finish (IdeEditorSessionAddin *self,
 
       gtk_container_add (GTK_CONTAINER (stack), GTK_WIDGET (view));
     }
+
+  _ide_editor_perspective_set_loading (IDE_EDITOR_PERSPECTIVE (editor), FALSE);
 }
 
 static void
@@ -373,6 +376,9 @@ ide_editor_session_addin_restore_async (IdeSessionAddin     *addin,
   g_autoptr(GSettings) settings = NULL;
   const gchar *uri;
   LoadState *load_state;
+  IdeContext *context;
+  IdeWorkbench *workbench;
+  IdePerspective *editor;
   GVariantIter iter;
   gint column, row, depth;
 
@@ -390,6 +396,13 @@ ide_editor_session_addin_restore_async (IdeSessionAddin     *addin,
       return;
     }
 
+  context = ide_object_get_context (IDE_OBJECT (addin));
+  workbench = IDE_WORKBENCH (ide_context_get_workbench (context));
+  editor = ide_workbench_get_perspective_by_name (workbench, "editor");
+
+  /* Hide the grid until we've loaded */
+  _ide_editor_perspective_set_loading (IDE_EDITOR_PERSPECTIVE (editor), TRUE);
+
   uris = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
 
   load_state = g_slice_new0 (LoadState);
@@ -435,7 +448,10 @@ ide_editor_session_addin_restore_async (IdeSessionAddin     *addin,
   load_state->active--;
 
   if (load_state->active == 0)
-    ide_task_return_boolean (task, TRUE);
+    {
+      _ide_editor_perspective_set_loading (IDE_EDITOR_PERSPECTIVE (editor), FALSE);
+      ide_task_return_boolean (task, TRUE);
+    }
 }
 
 static gboolean


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