From d2aa891c8ecb23b4496d44f6ceec17bf2646d483 Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Tue, 6 Jan 1998 21:59:43 +0000 Subject: [PATCH] Added "switch_page" signal. (gtk-hamann_jeske-971212-0.patch) -owt --- gtk/gtknotebook.c | 55 ++++++++++++++++++++++++++++++++++++++++++++--- gtk/gtknotebook.h | 3 +++ 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index f278bed521..db6adce54c 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -16,6 +16,7 @@ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "gtknotebook.h" +#include "gtksignal.h" #define CHILD_SPACING 2 @@ -23,6 +24,15 @@ #define TAB_CURVATURE 1 +enum { + SWITCH_PAGE, + LAST_SIGNAL +}; + +typedef void (*GtkNotebookSignal) (GtkObject *object, + gpointer arg1, + gpointer data); + static void gtk_notebook_class_init (GtkNotebookClass *klass); static void gtk_notebook_init (GtkNotebook *notebook); static void gtk_notebook_destroy (GtkObject *object); @@ -60,9 +70,16 @@ static void gtk_notebook_page_allocate (GtkNotebook *notebook, GtkNotebookPage *page, GtkAllocation *allocation); +static void gtk_real_notebook_switch_page (GtkNotebook *notebook, + GtkNotebookPage *page); + +static void gtk_notebook_marshal_signal (GtkObject *object, + GtkSignalFunc func, + gpointer func_data, + GtkArg *args); static GtkContainerClass *parent_class = NULL; - +static gint notebook_signals[LAST_SIGNAL] = { 0 }; guint gtk_notebook_get_type () @@ -100,6 +117,17 @@ gtk_notebook_class_init (GtkNotebookClass *class) parent_class = gtk_type_class (gtk_container_get_type ()); + notebook_signals[SWITCH_PAGE] = + gtk_signal_new ("switch_page", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (GtkNotebookClass, switch_page), + gtk_notebook_marshal_signal, + GTK_TYPE_NONE, 1, + GTK_TYPE_POINTER); + + gtk_object_class_add_signals (object_class, notebook_signals, LAST_SIGNAL); + object_class->destroy = gtk_notebook_destroy; widget_class->map = gtk_notebook_map; @@ -115,6 +143,8 @@ gtk_notebook_class_init (GtkNotebookClass *class) container_class->add = gtk_notebook_add; container_class->remove = gtk_notebook_remove; container_class->foreach = gtk_notebook_foreach; + + class->switch_page = gtk_real_notebook_switch_page; } static void @@ -1027,8 +1057,8 @@ gtk_notebook_foreach (GtkContainer *container, } static void -gtk_notebook_switch_page (GtkNotebook *notebook, - GtkNotebookPage *page) +gtk_real_notebook_switch_page (GtkNotebook *notebook, + GtkNotebookPage *page) { g_return_if_fail (notebook != NULL); g_return_if_fail (page != NULL); @@ -1420,3 +1450,22 @@ gtk_notebook_page_allocate (GtkNotebook *notebook, gtk_widget_size_allocate (page->tab_label, &child_allocation); } + +static void +gtk_notebook_switch_page (GtkNotebook *notebook, GtkNotebookPage *page) +{ + gtk_signal_emit (GTK_OBJECT (notebook), notebook_signals[SWITCH_PAGE], page); +} + +static void +gtk_notebook_marshal_signal (GtkObject *object, + GtkSignalFunc func, + gpointer func_data, + GtkArg *args) +{ + GtkNotebookSignal rfunc; + + rfunc = (GtkNotebookSignal) func; + + (* rfunc) (object, GTK_VALUE_OBJECT (args[0]), func_data); +} diff --git a/gtk/gtknotebook.h b/gtk/gtknotebook.h index 402823b2e3..5cbcf6fc59 100644 --- a/gtk/gtknotebook.h +++ b/gtk/gtknotebook.h @@ -52,6 +52,9 @@ struct _GtkNotebook struct _GtkNotebookClass { GtkContainerClass parent_class; + + void (* switch_page) (GtkNotebook *notebook, + GtkNotebookPage *page); }; struct _GtkNotebookPage