[gnome-builder] libide/gui: start on simple session saving for workspace state
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide/gui: start on simple session saving for workspace state
- Date: Thu, 15 Sep 2022 08:35:17 +0000 (UTC)
commit 9f8bd89245c2ed94d95c8dcd0012a7a4a578f074
Author: Christian Hergert <chergert redhat com>
Date: Thu Sep 15 01:35:10 2022 -0700
libide/gui: start on simple session saving for workspace state
src/libide/editor/ide-editor-workspace.c | 13 +++++++++++
src/libide/gui/ide-primary-workspace.c | 13 +++++++++++
src/libide/gui/ide-workspace-private.h | 4 ++++
src/libide/gui/ide-workspace.c | 37 ++++++++++++++++++++++++++++++++
4 files changed, 67 insertions(+)
---
diff --git a/src/libide/editor/ide-editor-workspace.c b/src/libide/editor/ide-editor-workspace.c
index 4f3aa2f57..cf835c634 100644
--- a/src/libide/editor/ide-editor-workspace.c
+++ b/src/libide/editor/ide-editor-workspace.c
@@ -260,6 +260,18 @@ ide_editor_workspace_get_id (IdeWorkspace *workspace)
return IDE_EDITOR_WORKSPACE (workspace)->id;
}
+static void
+ide_editor_workspace_save_session (IdeWorkspace *workspace,
+ IdeSession *session)
+{
+ IdeEditorWorkspace *self = (IdeEditorWorkspace *)workspace;
+
+ g_assert (IDE_IS_EDITOR_WORKSPACE (self));
+ g_assert (IDE_IS_SESSION (session));
+
+ _ide_workspace_save_session_simple (workspace, session, self->dock, self->grid);
+}
+
static void
ide_editor_workspace_dispose (GObject *object)
{
@@ -298,6 +310,7 @@ ide_editor_workspace_class_init (IdeEditorWorkspaceClass *klass)
workspace_class->get_header_bar = ide_editor_workspace_get_header_bar;
workspace_class->get_id = ide_editor_workspace_get_id;
workspace_class->get_most_recent_frame = ide_editor_workspace_get_most_recent_frame;
+ workspace_class->save_session = ide_editor_workspace_save_session;
ide_workspace_class_set_kind (workspace_class, "editor");
diff --git a/src/libide/gui/ide-primary-workspace.c b/src/libide/gui/ide-primary-workspace.c
index 0bb9531fc..81261246b 100644
--- a/src/libide/gui/ide-primary-workspace.c
+++ b/src/libide/gui/ide-primary-workspace.c
@@ -271,6 +271,18 @@ ide_primary_workspace_get_id (IdeWorkspace *workspace)
return "primary";
}
+static void
+ide_primary_workspace_save_session (IdeWorkspace *workspace,
+ IdeSession *session)
+{
+ IdePrimaryWorkspace *self = (IdePrimaryWorkspace *)workspace;
+
+ g_assert (IDE_IS_PRIMARY_WORKSPACE (self));
+ g_assert (IDE_IS_SESSION (session));
+
+ _ide_workspace_save_session_simple (workspace, session, self->dock, self->grid);
+}
+
static void
ide_primary_workspace_dispose (GObject *object)
{
@@ -309,6 +321,7 @@ ide_primary_workspace_class_init (IdePrimaryWorkspaceClass *klass)
workspace_class->get_id = ide_primary_workspace_get_id;
workspace_class->get_most_recent_frame = ide_primary_workspace_get_most_recent_frame;
workspace_class->remove_overlay = ide_primary_workspace_remove_overlay;
+ workspace_class->save_session = ide_primary_workspace_save_session;
ide_workspace_class_set_kind (workspace_class, "primary");
diff --git a/src/libide/gui/ide-workspace-private.h b/src/libide/gui/ide-workspace-private.h
index 6d69c41ff..a1a106fff 100644
--- a/src/libide/gui/ide-workspace-private.h
+++ b/src/libide/gui/ide-workspace-private.h
@@ -60,6 +60,10 @@ void _ide_workspace_agree_to_close_async (IdeWorkspace *self,
gboolean _ide_workspace_agree_to_close_finish (IdeWorkspace *self,
GAsyncResult *result,
GError **error);
+void _ide_workspace_save_session_simple (IdeWorkspace *self,
+ IdeSession *session,
+ PanelDock *dock,
+ IdeGrid *grid);
void _ide_workspace_save_session (IdeWorkspace *self,
IdeSession *session);
diff --git a/src/libide/gui/ide-workspace.c b/src/libide/gui/ide-workspace.c
index 95d911be1..a7ffd6155 100644
--- a/src/libide/gui/ide-workspace.c
+++ b/src/libide/gui/ide-workspace.c
@@ -1698,6 +1698,8 @@ _ide_workspace_save_session (IdeWorkspace *self,
{
IdeWorkspacePrivate *priv = ide_workspace_get_instance_private (self);
+ IDE_ENTRY;
+
g_return_if_fail (IDE_IS_WORKSPACE (self));
g_return_if_fail (IDE_IS_SESSION (session));
@@ -1707,4 +1709,39 @@ _ide_workspace_save_session (IdeWorkspace *self,
ide_extension_set_adapter_foreach (priv->addins,
ide_workspace_addin_save_session_cb,
session);
+
+ IDE_EXIT;
+}
+
+void
+_ide_workspace_save_session_simple (IdeWorkspace *self,
+ IdeSession *session,
+ PanelDock *dock,
+ IdeGrid *grid)
+{
+ g_autoptr(IdeSessionItem) item = NULL;
+ int width;
+ int height;
+
+ IDE_ENTRY;
+
+ g_return_if_fail (IDE_IS_WORKSPACE (self));
+ g_return_if_fail (IDE_IS_SESSION (session));
+
+ gtk_window_get_default_size (GTK_WINDOW (self), &width, &height);
+
+ item = ide_session_item_new ();
+ ide_session_item_set_id (item, ide_workspace_get_id (self));
+ ide_session_item_set_module_name (item, "libide-gui");
+ ide_session_item_set_type_hint (item, G_OBJECT_TYPE_NAME (self));
+ ide_session_item_set_metadata (item, "size", "(ii)", width, height);
+ if (gtk_window_is_active (GTK_WINDOW (self)))
+ ide_session_item_set_metadata (item, "is-active", "b", TRUE);
+ if (gtk_window_is_maximized (GTK_WINDOW (self)))
+ ide_session_item_set_metadata (item, "is-maximized", "b", TRUE);
+ ide_session_prepend (session, item);
+
+ /* TODO: Save panel and grid frame size/positions */
+
+ IDE_EXIT;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]