[gnome-builder/wip/gtk4-port: 201/343] libide/gui: make size restoration overridable




commit 2e492adde1f4d6fc066c7f4bc021a2199c133f44
Author: Christian Hergert <chergert redhat com>
Date:   Wed Mar 30 15:39:50 2022 -0700

    libide/gui: make size restoration overridable

 src/libide/greeter/ide-greeter-workspace.c |  2 ++
 src/libide/gui/ide-workspace.c             | 14 +++++++++++++-
 src/libide/gui/ide-workspace.h             |  6 +++---
 3 files changed, 18 insertions(+), 4 deletions(-)
---
diff --git a/src/libide/greeter/ide-greeter-workspace.c b/src/libide/greeter/ide-greeter-workspace.c
index 6a3879c4e..aa1cf7dce 100644
--- a/src/libide/greeter/ide-greeter-workspace.c
+++ b/src/libide/greeter/ide-greeter-workspace.c
@@ -622,6 +622,8 @@ ide_greeter_workspace_class_init (IdeGreeterWorkspaceClass *klass)
   object_class->get_property = ide_greeter_workspace_get_property;
   object_class->set_property = ide_greeter_workspace_set_property;
 
+  workspace_class->restore_size = NULL;
+
   /**
    * IdeGreeterWorkspace:selection-mode:
    *
diff --git a/src/libide/gui/ide-workspace.c b/src/libide/gui/ide-workspace.c
index b7075beee..53b25dac1 100644
--- a/src/libide/gui/ide-workspace.c
+++ b/src/libide/gui/ide-workspace.c
@@ -311,6 +311,16 @@ ide_workspace_size_allocate (GtkWidget *widget,
     priv->queued_window_save = g_timeout_add_seconds (1, ide_workspace_save_settings, self);
 }
 
+static void
+ide_workspace_restore_size (IdeWorkspace *workspace,
+                            int           width,
+                            int           height)
+{
+  g_assert (IDE_IS_WORKSPACE (workspace));
+
+  gtk_window_set_default_size (GTK_WINDOW (workspace), width, height);
+}
+
 static void
 ide_workspace_realize (GtkWidget *widget)
 {
@@ -326,7 +336,8 @@ ide_workspace_realize (GtkWidget *widget)
   g_settings_get (settings, "window-size", "(ii)", &geom.width, &geom.height);
   g_settings_get (settings, "window-maximized", "b", &maximized);
 
-  gtk_window_set_default_size (GTK_WINDOW (self), geom.width, geom.height);
+  if (IDE_WORKSPACE_GET_CLASS (self)->restore_size)
+    IDE_WORKSPACE_GET_CLASS (self)->restore_size (self, geom.width, geom.height);
 
   GTK_WIDGET_CLASS (ide_workspace_parent_class)->realize (widget);
 
@@ -400,6 +411,7 @@ ide_workspace_class_init (IdeWorkspaceClass *klass)
   klass->context_set = ide_workspace_real_context_set;
   klass->agree_to_close_async = ide_workspace_agree_to_close_async;
   klass->agree_to_close_finish = ide_workspace_agree_to_close_finish;
+  klass->restore_size = ide_workspace_restore_size;
 
   /**
    * IdeWorkspace:context:
diff --git a/src/libide/gui/ide-workspace.h b/src/libide/gui/ide-workspace.h
index a536ea66c..9bb09335e 100644
--- a/src/libide/gui/ide-workspace.h
+++ b/src/libide/gui/ide-workspace.h
@@ -66,9 +66,9 @@ struct _IdeWorkspaceClass
   void     (*add_pane)              (IdeWorkspace         *self,
                                      IdePane              *pane,
                                      IdePanelPosition     *position);
-
-  /*< private >*/
-  gpointer _reserved[8];
+  void     (*restore_size)          (IdeWorkspace         *self,
+                                     int                   width,
+                                     int                   height);
 };
 
 IDE_AVAILABLE_IN_ALL


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