[gnome-builder] libide/tweaks: add ide_tweaks_window_navigate_initial()



commit 85a22be50b9be59902d7fa5fce3db8c9abf29d54
Author: Christian Hergert <chergert redhat com>
Date:   Tue Aug 23 13:59:22 2022 -0700

    libide/tweaks: add ide_tweaks_window_navigate_initial()
    
    Allows getting back to the "initial state" after showing the window the
    first time. This can be useful to reuse a window and navigate to a new
    toplevel page.

 src/libide/tweaks/ide-tweaks-window.c | 17 +++++++++++++++++
 src/libide/tweaks/ide-tweaks-window.h |  2 ++
 2 files changed, 19 insertions(+)
---
diff --git a/src/libide/tweaks/ide-tweaks-window.c b/src/libide/tweaks/ide-tweaks-window.c
index 3181fd247..62510460d 100644
--- a/src/libide/tweaks/ide-tweaks-window.c
+++ b/src/libide/tweaks/ide-tweaks-window.c
@@ -470,6 +470,10 @@ ide_tweaks_window_dispose (GObject *object)
       g_clear_object (&self->tweaks);
     }
 
+  g_assert (self->addins == NULL);
+  g_assert (self->tweaks == NULL);
+  g_assert (self->muxer == NULL);
+
   G_OBJECT_CLASS (ide_tweaks_window_parent_class)->dispose (object);
 }
 
@@ -737,3 +741,16 @@ ide_tweaks_window_get_can_navigate_back (IdeTweaksWindow *self)
 
   return self->can_navigate_back;
 }
+
+void
+ide_tweaks_window_navigate_initial (IdeTweaksWindow *self)
+{
+  g_return_if_fail (IDE_IS_TWEAKS_WINDOW (self));
+
+  if (self->tweaks != NULL)
+    {
+      ide_tweaks_window_clear (self);
+      ide_action_muxer_remove_all (self->muxer);
+      ide_tweaks_window_rebuild (self);
+    }
+}
diff --git a/src/libide/tweaks/ide-tweaks-window.h b/src/libide/tweaks/ide-tweaks-window.h
index 9448ed47e..6255d2688 100644
--- a/src/libide/tweaks/ide-tweaks-window.h
+++ b/src/libide/tweaks/ide-tweaks-window.h
@@ -49,5 +49,7 @@ void       ide_tweaks_window_navigate_to           (IdeTweaksWindow *self,
                                                     IdeTweaksItem   *item);
 IDE_AVAILABLE_IN_ALL
 void       ide_tweaks_window_navigate_back         (IdeTweaksWindow *self);
+IDE_AVAILABLE_IN_ALL
+void       ide_tweaks_window_navigate_initial      (IdeTweaksWindow *self);
 
 G_END_DECLS


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