[sysprof] libsysprof-ui: add API to reload pages



commit d525f065f482fa85a8a5d5cb873aec6aa0a76a45
Author: Christian Hergert <chergert redhat com>
Date:   Tue Feb 18 19:17:38 2020 -0800

    libsysprof-ui: add API to reload pages
    
    This can be useful when the page is interactive and needs to reload.

 src/libsysprof-ui/sysprof-display.c    | 20 ++++++++++++++++++++
 src/libsysprof-ui/sysprof-page.c       | 13 +++++++++++++
 src/libsysprof-ui/sysprof-page.h       |  2 ++
 src/libsysprof-ui/sysprof-ui-private.h |  2 ++
 4 files changed, 37 insertions(+)
---
diff --git a/src/libsysprof-ui/sysprof-display.c b/src/libsysprof-ui/sysprof-display.c
index 9c100e9..5a5de3f 100644
--- a/src/libsysprof-ui/sysprof-display.c
+++ b/src/libsysprof-ui/sysprof-display.c
@@ -1225,3 +1225,23 @@ sysprof_display_save (SysprofDisplay *self)
   g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_TITLE]);
   gtk_native_dialog_destroy (GTK_NATIVE_DIALOG (native));
 }
+
+void
+_sysprof_display_reload_page (SysprofDisplay *self,
+                              SysprofPage    *page)
+{
+  SysprofDisplayPrivate *priv = sysprof_display_get_instance_private (self);
+  SysprofSelection *selection;
+
+  g_return_if_fail (SYSPROF_IS_DISPLAY (self));
+  g_return_if_fail (SYSPROF_IS_PAGE (page));
+  g_return_if_fail (priv->reader != NULL);
+
+  selection = sysprof_visualizers_frame_get_selection (priv->visualizers);
+
+  sysprof_page_load_async (page,
+                           priv->reader,
+                           selection,
+                           priv->filter,
+                           NULL, NULL, NULL);
+}
diff --git a/src/libsysprof-ui/sysprof-page.c b/src/libsysprof-ui/sysprof-page.c
index af5f927..3644276 100644
--- a/src/libsysprof-ui/sysprof-page.c
+++ b/src/libsysprof-ui/sysprof-page.c
@@ -22,7 +22,9 @@
 
 #include "config.h"
 
+#include "sysprof-display.h"
 #include "sysprof-page.h"
+#include "sysprof-ui-private.h"
 
 typedef struct
 {
@@ -233,3 +235,14 @@ sysprof_page_set_hadjustment (SysprofPage   *self,
   if (SYSPROF_PAGE_GET_CLASS (self)->set_hadjustment)
     SYSPROF_PAGE_GET_CLASS (self)->set_hadjustment (self, hadjustment);
 }
+
+void
+sysprof_page_reload (SysprofPage *self)
+{
+  GtkWidget *display;
+
+  g_return_if_fail (SYSPROF_IS_PAGE (self));
+
+  if ((display = gtk_widget_get_ancestor (GTK_WIDGET (self), SYSPROF_TYPE_DISPLAY)))
+    _sysprof_display_reload_page (SYSPROF_DISPLAY (display), self);
+}
diff --git a/src/libsysprof-ui/sysprof-page.h b/src/libsysprof-ui/sysprof-page.h
index 783d998..f8fc3b3 100644
--- a/src/libsysprof-ui/sysprof-page.h
+++ b/src/libsysprof-ui/sysprof-page.h
@@ -71,6 +71,8 @@ SYSPROF_AVAILABLE_IN_ALL
 gboolean     sysprof_page_load_finish     (SysprofPage              *self,
                                            GAsyncResult             *result,
                                            GError                  **error);
+SYSPROF_AVAILABLE_IN_3_36
+void         sysprof_page_reload          (SysprofPage              *self);
 SYSPROF_AVAILABLE_IN_ALL
 const gchar *sysprof_page_get_title       (SysprofPage              *self);
 SYSPROF_AVAILABLE_IN_ALL
diff --git a/src/libsysprof-ui/sysprof-ui-private.h b/src/libsysprof-ui/sysprof-ui-private.h
index a0a08fd..0216d3b 100644
--- a/src/libsysprof-ui/sysprof-ui-private.h
+++ b/src/libsysprof-ui/sysprof-ui-private.h
@@ -33,6 +33,8 @@ void   _sysprof_memory_page_set_failed          (SysprofCallgraphPage     *self)
 void   _sysprof_memory_page_set_loading         (SysprofCallgraphPage     *self,
                                                  gboolean                  loading);
 void   _sysprof_display_focus_record            (SysprofDisplay           *self);
+void   _sysprof_display_reload_page             (SysprofDisplay           *self,
+                                                 SysprofPage              *page);
 void   _sysprof_profiler_assistant_focus_record (SysprofProfilerAssistant *self);
 gchar *_sysprof_format_duration                 (gint64                    duration);
 


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