[gnome-builder/wip/gtk4-port] libide/gui: update page MRU when focus changes



commit 5fa3b78fae06958d780a3ef28d97d8bf23181573
Author: Christian Hergert <chergert redhat com>
Date:   Fri Jun 3 14:25:09 2022 -0700

    libide/gui: update page MRU when focus changes
    
    We never finished updating this with the port. The missing bit was pushing
    the page to the front the MRU when the focus changes.

 src/libide/gui/ide-page-private.h | 29 +++++++++++++++++++++++++++++
 src/libide/gui/ide-page.c         |  8 ++++++++
 src/libide/gui/ide-workspace.c    |  4 ++++
 src/libide/gui/meson.build        |  1 +
 4 files changed, 42 insertions(+)
---
diff --git a/src/libide/gui/ide-page-private.h b/src/libide/gui/ide-page-private.h
new file mode 100644
index 000000000..002a692c8
--- /dev/null
+++ b/src/libide/gui/ide-page-private.h
@@ -0,0 +1,29 @@
+/* ide-page-private.h
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include "ide-page.h"
+
+G_BEGIN_DECLS
+
+GList *_ide_page_get_mru_link (IdePage *self);
+
+G_END_DECLS
diff --git a/src/libide/gui/ide-page.c b/src/libide/gui/ide-page.c
index 75fec6371..697931fbb 100644
--- a/src/libide/gui/ide-page.c
+++ b/src/libide/gui/ide-page.c
@@ -70,6 +70,14 @@ static GtkBuildableIface *parent_buildable;
 static GParamSpec *properties [N_PROPS];
 static guint signals [N_SIGNALS];
 
+GList *
+_ide_page_get_mru_link (IdePage *self)
+{
+  IdePagePrivate *priv = ide_page_get_instance_private (self);
+  g_assert (IDE_IS_PAGE (self));
+  return &priv->mru_link;
+}
+
 static void
 ide_page_real_agree_to_close_async (IdePage             *self,
                                     GCancellable        *cancellable,
diff --git a/src/libide/gui/ide-workspace.c b/src/libide/gui/ide-workspace.c
index f1891f825..62f248974 100644
--- a/src/libide/gui/ide-workspace.c
+++ b/src/libide/gui/ide-workspace.c
@@ -26,6 +26,7 @@
 #include <libide-plugins.h>
 
 #include "ide-gui-global.h"
+#include "ide-page-private.h"
 #include "ide-search-popover-private.h"
 #include "ide-shortcut-bundle-private.h"
 #include "ide-workspace-addin.h"
@@ -310,6 +311,9 @@ ide_workspace_notify_focus_widget (IdeWorkspace *self,
       /* Focus changed, and we have a new widget */
       g_set_weak_pointer (&priv->current_page_ptr, focus);
 
+      /* And move this page to the front of the MRU */
+      _ide_workspace_move_front_page_mru (self, _ide_page_get_mru_link (focus));
+
       if (priv->addins != NULL)
         {
           g_object_ref (focus);
diff --git a/src/libide/gui/meson.build b/src/libide/gui/meson.build
index b78c03941..df09c7006 100644
--- a/src/libide/gui/meson.build
+++ b/src/libide/gui/meson.build
@@ -51,6 +51,7 @@ libide_gui_private_headers = [
   'ide-notification-list-box-row-private.h',
   'ide-notification-stack-private.h',
   'ide-notification-view-private.h',
+  'ide-page-private.h',
   'ide-preferences-builtin-private.h',
   'ide-primary-workspace-private.h',
   'ide-recoloring-private.h',


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