[sysprof/wip/gtk4-port] notebook: add notebook helpers



commit 4d8d8d19a170456fa58c21304965030ec45f7525
Author: Christian Hergert <chergert redhat com>
Date:   Fri Oct 1 14:23:03 2021 -0700

    notebook: add notebook helpers

 src/libsysprof-ui/sysprof-notebook.c | 44 ++++++++++++++++++++++++++++++++++++
 src/libsysprof-ui/sysprof-notebook.h | 11 +++++++++
 2 files changed, 55 insertions(+)
---
diff --git a/src/libsysprof-ui/sysprof-notebook.c b/src/libsysprof-ui/sysprof-notebook.c
index 4e644b48..01f88ec9 100644
--- a/src/libsysprof-ui/sysprof-notebook.c
+++ b/src/libsysprof-ui/sysprof-notebook.c
@@ -528,3 +528,47 @@ buildable_iface_init (GtkBuildableIface *iface)
 {
   iface->add_child = sysprof_notebook_add_child;
 }
+
+guint
+sysprof_notebook_get_n_pages (SysprofNotebook *self)
+{
+  SysprofNotebookPrivate *priv = sysprof_notebook_get_instance_private (self);
+
+  g_return_val_if_fail (SYSPROF_IS_NOTEBOOK (self), 0);
+
+  return gtk_notebook_get_n_pages (priv->notebook);
+}
+
+SysprofDisplay *
+sysprof_notebook_get_nth_page (SysprofNotebook *self,
+                               guint            nth)
+{
+  SysprofNotebookPrivate *priv = sysprof_notebook_get_instance_private (self);
+
+  g_return_val_if_fail (SYSPROF_IS_NOTEBOOK (self), NULL);
+
+  return SYSPROF_DISPLAY (gtk_notebook_get_nth_page (priv->notebook, nth));
+}
+
+void
+sysprof_notebook_set_current_page (SysprofNotebook *self,
+                                   int              nth)
+{
+  SysprofNotebookPrivate *priv = sysprof_notebook_get_instance_private (self);
+
+  g_return_if_fail (SYSPROF_IS_NOTEBOOK (self));
+
+  gtk_notebook_set_current_page (priv->notebook, nth);
+}
+
+int
+sysprof_notebook_append (SysprofNotebook *self,
+                         SysprofDisplay  *display)
+{
+  SysprofNotebookPrivate *priv = sysprof_notebook_get_instance_private (self);
+
+  g_return_val_if_fail (SYSPROF_IS_NOTEBOOK (self), -1);
+  g_return_val_if_fail (SYSPROF_IS_DISPLAY (display), -1);
+
+  return gtk_notebook_append_page (priv->notebook, GTK_WIDGET (display), NULL);
+}
diff --git a/src/libsysprof-ui/sysprof-notebook.h b/src/libsysprof-ui/sysprof-notebook.h
index e256db73..943dc1f1 100644
--- a/src/libsysprof-ui/sysprof-notebook.h
+++ b/src/libsysprof-ui/sysprof-notebook.h
@@ -70,5 +70,16 @@ gboolean        sysprof_notebook_get_always_show_tabs (SysprofNotebook *self);
 SYSPROF_AVAILABLE_IN_ALL
 void            sysprof_notebook_set_always_show_tabs (SysprofNotebook *self,
                                                        gboolean         always_show_tabs);
+SYSPROF_AVAILABLE_IN_ALL
+guint           sysprof_notebook_get_n_pages          (SysprofNotebook *self);
+SYSPROF_AVAILABLE_IN_ALL
+SysprofDisplay *sysprof_notebook_get_nth_page         (SysprofNotebook *self,
+                                                       guint            nth);
+SYSPROF_AVAILABLE_IN_ALL
+void            sysprof_notebook_set_current_page     (SysprofNotebook *self,
+                                                       int              page);
+SYSPROF_AVAILABLE_IN_ALL
+int             sysprof_notebook_append               (SysprofNotebook *self,
+                                                       SysprofDisplay  *display);
 
 G_END_DECLS


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