summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2002-09-23 22:05:41 +0000
committerOwen Taylor <otaylor@src.gnome.org>2002-09-23 22:05:41 +0000
commit9879b5b45c7d7643b199936011ab7f1c3cebdead (patch)
tree24f9d7faf36cb5d2b253a38cd31b228336f9937d /gtk
parent4d7d94f63331f656b32f1f5fab7da99ae47ba7fb (diff)
downloadgtk+-9879b5b45c7d7643b199936011ab7f1c3cebdead.tar.gz
i Add gtk_notebook_get_n_pages (#73229, Havoc Pennington)
Mon Sep 23 18:01:52 2002 Owen Taylor <otaylor@redhat.com> i * gtk/gtknotebook.[ch]: Add gtk_notebook_get_n_pages (#73229, Havoc Pennington) * gtk/gtknotebook.c (gtk_notebook_get_nth_page): Handle -1 to mean the last page, as we do elsewhere. (#73229)
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtknotebook.c32
-rw-r--r--gtk/gtknotebook.h1
2 files changed, 29 insertions, 4 deletions
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index 3900fd67bd..c7c2ad6896 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -4109,7 +4109,8 @@ gtk_notebook_get_current_page (GtkNotebook *notebook)
/**
* gtk_notebook_get_nth_page:
* @notebook: a #GtkNotebook
- * @page_num: the index of a page in the noteobok
+ * @page_num: the index of a page in the noteobok, or -1
+ * to get the last page.
*
* Returns the child widget contained in page number @page_num.
*
@@ -4121,18 +4122,41 @@ gtk_notebook_get_nth_page (GtkNotebook *notebook,
gint page_num)
{
GtkNotebookPage *page;
+ GList *list;
g_return_val_if_fail (GTK_IS_NOTEBOOK (notebook), NULL);
- page = g_list_nth_data (notebook->children, page_num);
+ if (page_num >= 0)
+ list = g_list_nth (notebook->children, page_num);
+ else
+ list = g_list_last (notebook->children);
- if (page)
- return page->child;
+ if (list)
+ {
+ page = list->data;
+ return page->child;
+ }
return NULL;
}
/**
+ * gtk_notebook_get_nth_page:
+ * @notebook: a #GtkNotebook
+ *
+ * Gets the number of pages in a notebook.
+ *
+ * Return value: the number of pages in the notebook.
+ **/
+gint
+gtk_notebook_get_n_pages (GtkNotebook *notebook)
+{
+ g_return_val_if_fail (GTK_IS_NOTEBOOK (notebook), 0);
+
+ return g_list_length (notebook->children);
+}
+
+/**
* gtk_notebook_page_num:
* @notebook: a #GtkNotebook
* @child: a #GtkWidget
diff --git a/gtk/gtknotebook.h b/gtk/gtknotebook.h
index 7ed5ed0652..e6d0cd8d70 100644
--- a/gtk/gtknotebook.h
+++ b/gtk/gtknotebook.h
@@ -150,6 +150,7 @@ void gtk_notebook_remove_page (GtkNotebook *notebook,
gint gtk_notebook_get_current_page (GtkNotebook *notebook);
GtkWidget* gtk_notebook_get_nth_page (GtkNotebook *notebook,
gint page_num);
+gint gtk_notebook_get_n_pages (GtkNotebook *notebook);
gint gtk_notebook_page_num (GtkNotebook *notebook,
GtkWidget *child);
void gtk_notebook_set_current_page (GtkNotebook *notebook,