[gnome-builder] libide/gui: make session restore work for IdePane



commit 258195789b2d18ef8eba9eb5ab5d41568a93b230
Author: Christian Hergert <chergert redhat com>
Date:   Fri Sep 16 21:10:44 2022 -0700

    libide/gui: make session restore work for IdePane

 src/libide/gui/ide-workbench-session.c |  2 --
 src/libide/gui/ide-workbench.c         | 23 ++++++++++++++++++++++-
 src/libide/gui/ide-workspace-session.c |  9 +++++++--
 3 files changed, 29 insertions(+), 5 deletions(-)
---
diff --git a/src/libide/gui/ide-workbench-session.c b/src/libide/gui/ide-workbench-session.c
index 7e08cccf0..bebb31e4c 100644
--- a/src/libide/gui/ide-workbench-session.c
+++ b/src/libide/gui/ide-workbench-session.c
@@ -128,8 +128,6 @@ _ide_workbench_restore_workspaces (IdeWorkbench *self,
               if (is_maximized)
                 gtk_window_maximize (GTK_WINDOW (workspace));
 
-              _ide_workspace_restore_session (workspace, session);
-
               if (is_active)
                 active_window = workspace;
               else
diff --git a/src/libide/gui/ide-workbench.c b/src/libide/gui/ide-workbench.c
index d7857d416..8046cc4b6 100644
--- a/src/libide/gui/ide-workbench.c
+++ b/src/libide/gui/ide-workbench.c
@@ -958,6 +958,19 @@ ide_workbench_project_loaded_foreach_cb (PeasExtensionSet *set,
   ide_workbench_addin_project_loaded (addin, self->project_info);
 }
 
+static void
+ide_workbench_restore_workspace_session_cb (IdeWorkspace *workspace,
+                                            gpointer      user_data)
+{
+  IdeSession *session = user_data;
+
+  g_assert (IDE_IS_MAIN_THREAD ());
+  g_assert (IDE_IS_WORKSPACE (workspace));
+  g_assert (IDE_IS_SESSION (session));
+
+  _ide_workspace_restore_session (workspace, session);
+}
+
 static void
 ide_workbench_load_project_completed (IdeWorkbench *self,
                                       IdeTask      *task)
@@ -1005,7 +1018,6 @@ ide_workbench_load_project_completed (IdeWorkbench *self,
         lp->workspace_type = G_TYPE_INVALID;
 
       _ide_workbench_addins_restore_session (self, self->addins, self->session);
-      g_clear_object (&self->session);
     }
 
   if (lp->workspace_type != G_TYPE_INVALID)
@@ -1034,6 +1046,15 @@ ide_workbench_load_project_completed (IdeWorkbench *self,
   ide_action_mixin_set_enabled (self, "configure", TRUE);
   ide_action_mixin_set_enabled (self, "configure-page", TRUE);
 
+  /* Now restore the workspace sessions */
+  if (self->session)
+    {
+      ide_workbench_foreach_workspace (self,
+                                       ide_workbench_restore_workspace_session_cb,
+                                       self->session);
+      g_clear_object (&self->session);
+    }
+
   ide_task_return_boolean (task, TRUE);
 }
 
diff --git a/src/libide/gui/ide-workspace-session.c b/src/libide/gui/ide-workspace-session.c
index ccd7bd10e..a6a861e8f 100644
--- a/src/libide/gui/ide-workspace-session.c
+++ b/src/libide/gui/ide-workspace-session.c
@@ -118,6 +118,7 @@ ide_workspace_save_session_frame_cb (PanelFrame *frame,
   g_autoptr(IdeSessionItem) item = NULL;
   IdeSession *session = user_data;
   IdeWorkspace *workspace;
+  const char *workspace_id;
   int requested_size;
   guint n_pages;
 
@@ -129,6 +130,7 @@ ide_workspace_save_session_frame_cb (PanelFrame *frame,
 
   position = panel_frame_get_position (frame);
   workspace = ide_widget_get_workspace (GTK_WIDGET (frame));
+  workspace_id = ide_workspace_get_id (workspace);
   requested_size = panel_frame_get_requested_size (frame);
 
 #if 0
@@ -139,7 +141,7 @@ ide_workspace_save_session_frame_cb (PanelFrame *frame,
   ide_session_item_set_module_name (item, "libide-gui");
   ide_session_item_set_type_hint (item, G_OBJECT_TYPE_NAME (frame));
   ide_session_item_set_position (item, position);
-  ide_session_item_set_workspace (item, ide_workspace_get_id (workspace));
+  ide_session_item_set_workspace (item, workspace_id);
 
   if (requested_size > -1)
     ide_session_item_set_metadata (item, "size", "i", requested_size);
@@ -163,11 +165,12 @@ ide_workspace_save_session_frame_cb (PanelFrame *frame,
 
           page_item = ide_session_item_new ();
           ide_session_item_set_id (page_item, id);
+          ide_session_item_set_workspace (page_item, workspace_id);
           ide_session_item_set_type_hint (page_item, "IdePane");
           ide_session_item_set_module_name (page_item, "libide-gui");
           ide_session_item_set_position (page_item, page_position);
 
-          ide_session_append (session, item);
+          ide_session_append (session, page_item);
         }
     }
 
@@ -329,6 +332,8 @@ ide_workspace_restore_frame (IdeWorkspace     *self,
       while (panel_paned_get_n_children (paned) <= column)
         {
           frame = panel_frame_new ();
+          gtk_orientable_set_orientation (GTK_ORIENTABLE (frame),
+                                          GTK_ORIENTATION_HORIZONTAL);
           panel_paned_append (paned, GTK_WIDGET (frame));
         }
 


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