summaryrefslogtreecommitdiff
path: root/gtk/gtknotebook.c
diff options
context:
space:
mode:
authorTim Janik <timj@gtk.org>2001-07-31 21:23:19 +0000
committerTim Janik <timj@src.gnome.org>2001-07-31 21:23:19 +0000
commit8dfce4590b1308c621e0411faa8a801c65923591 (patch)
treed182216920ff5c7f29ea2bd3903b2b4b287243ba /gtk/gtknotebook.c
parent6fe3d87b10596806abadffadde6a3e91edd98fe4 (diff)
downloadgdk-pixbuf-8dfce4590b1308c621e0411faa8a801c65923591.tar.gz
fix finding of child's page, since we have to validly deal with labels and
Tue Jul 31 22:59:33 2001 Tim Janik <timj@gtk.org> * gtk/gtknotebook.c (gtk_notebook_get_child_property): (gtk_notebook_set_child_property): fix finding of child's page, since we have to validly deal with labels and menus here as well. (gtk_notebook_get_child_property): fix warning. (gtk_notebook_class_init): property tab_pack is of type GTK_TYPE_PACK_TYPE (enum) not boolean. (gtk_notebook_find_child): don't always warn, we might be looking for a label or menu child. (gtk_notebook_map): fix mapping of panel. * gtk/gtkwidget.c (gtk_widget_set_child_visible): always constrain widget's mapped state, regardless of the value being set equals old settings, since things like REALIZED(parent) or MAPPED(parent) may have changed since the old value was set. make it an error to invoke this function on a toplevel widget.
Diffstat (limited to 'gtk/gtknotebook.c')
-rw-r--r--gtk/gtknotebook.c62
1 files changed, 35 insertions, 27 deletions
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index 605695913..a02551d5c 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -103,11 +103,10 @@ struct _GtkNotebookPage
#ifdef G_DISABLE_CHECKS
#define CHECK_FIND_CHILD(notebook, child) \
- gtk_notebook_find_child(notebook, child, \
- G_GNUC_PRETTY_FUNCTION)
+ gtk_notebook_find_child (notebook, child, G_STRLOC)
#else
#define CHECK_FIND_CHILD(notebook, child) \
- gtk_notebook_find_child(notebook, child, NULL)
+ gtk_notebook_find_child (notebook, child, NULL)
#endif
/*** GtkNotebook Methods ***/
@@ -192,7 +191,7 @@ static void gtk_notebook_update_labels (GtkNotebook *notebook);
static gint gtk_notebook_timer (GtkNotebook *notebook);
static gint gtk_notebook_page_compare (gconstpointer a,
gconstpointer b);
-static GList *gtk_notebook_find_child (GtkNotebook *notebook,
+static GList* gtk_notebook_find_child (GtkNotebook *notebook,
GtkWidget *child,
const gchar *function);
static gint gtk_notebook_real_page_position (GtkNotebook *notebook,
@@ -426,9 +425,9 @@ gtk_notebook_class_init (GtkNotebookClass *class)
G_PARAM_READWRITE));
gtk_container_class_install_child_property (container_class,
CHILD_PROP_TAB_PACK,
- g_param_spec_boolean ("tab_pack", NULL, NULL,
- TRUE,
- G_PARAM_READWRITE));
+ g_param_spec_enum ("tab_pack", NULL, NULL,
+ GTK_TYPE_PACK_TYPE, GTK_PACK_START,
+ G_PARAM_READWRITE));
notebook_signals[SWITCH_PAGE] =
gtk_signal_new ("switch_page",
@@ -733,6 +732,9 @@ gtk_notebook_map (GtkWidget *widget)
}
}
+ if (notebook->scrollable)
+ gdk_window_show (notebook->panel);
+
gdk_window_show (widget->window);
}
@@ -1464,6 +1466,10 @@ gtk_notebook_set_child_property (GtkContainer *container,
gboolean fill;
GtkPackType pack_type;
+ /* not finding child's page is valid for menus or labels */
+ if (!gtk_notebook_find_child (GTK_NOTEBOOK (container), child, NULL))
+ return;
+
switch (property_id)
{
case CHILD_PROP_TAB_LABEL:
@@ -1525,10 +1531,12 @@ gtk_notebook_get_child_property (GtkContainer *container,
notebook = GTK_NOTEBOOK (container);
- list = CHECK_FIND_CHILD (notebook, child);
- if (!list)
+ /* not finding child's page is valid for menus or labels */
+ list = gtk_notebook_find_child (notebook, child, NULL);
+ if (!list)
{
- GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
+ /* nothing to set on labels or menus */
+ g_param_value_set_default (pspec, value);
return;
}
@@ -2028,18 +2036,18 @@ gtk_notebook_page_compare (gconstpointer a,
return (((GtkNotebookPage *) a)->child != b);
}
-static GList *
-gtk_notebook_find_child (GtkNotebook *notebook,
- GtkWidget *child,
- const gchar *function)
+static GList*
+gtk_notebook_find_child (GtkNotebook *notebook,
+ GtkWidget *child,
+ const gchar *function)
{
GList *list = g_list_find_custom (notebook->children, child,
gtk_notebook_page_compare);
#ifndef G_DISABLE_CHECKS
- if (!list)
- g_warning ("child argument to '%s' does not refer to the contents of a notebook page",
- function);
+ if (!list && function)
+ g_warning ("%s: unable to find child %p in notebook %p",
+ function, child, notebook);
#endif
return list;
@@ -3796,6 +3804,10 @@ gtk_notebook_insert_page_menu (GtkNotebook *notebook,
gtk_notebook_menu_item_create (notebook,
g_list_find (notebook->children, page));
+ gtk_widget_set_parent (child, GTK_WIDGET (notebook));
+ if (tab_label)
+ gtk_widget_set_parent (tab_label, GTK_WIDGET (notebook));
+
gtk_notebook_update_labels (notebook);
if (!notebook->first_tab)
@@ -3814,10 +3826,6 @@ gtk_notebook_insert_page_menu (GtkNotebook *notebook,
gtk_widget_hide (tab_label);
}
- gtk_widget_set_parent (child, GTK_WIDGET (notebook));
- if (tab_label)
- gtk_widget_set_parent (tab_label, GTK_WIDGET (notebook));
-
if (!notebook->cur_page)
{
gtk_notebook_switch_page (notebook, page, 0);
@@ -4447,7 +4455,7 @@ gtk_notebook_get_tab_label (GtkNotebook *notebook,
GList *list;
g_return_val_if_fail (GTK_IS_NOTEBOOK (notebook), NULL);
- g_return_val_if_fail (child != NULL, NULL);
+ g_return_val_if_fail (GTK_IS_WIDGET (child), NULL);
list = CHECK_FIND_CHILD (notebook, child);
if (!list)
@@ -4478,7 +4486,7 @@ gtk_notebook_set_tab_label (GtkNotebook *notebook,
GList *list;
g_return_if_fail (GTK_IS_NOTEBOOK (notebook));
- g_return_if_fail (child != NULL);
+ g_return_if_fail (GTK_IS_WIDGET (child));
list = CHECK_FIND_CHILD (notebook, child);
if (!list)
@@ -4593,7 +4601,7 @@ gtk_notebook_get_menu_label (GtkNotebook *notebook,
GList *list;
g_return_val_if_fail (GTK_IS_NOTEBOOK (notebook), NULL);
- g_return_val_if_fail (child != NULL, NULL);
+ g_return_val_if_fail (GTK_IS_WIDGET (child), NULL);
list = CHECK_FIND_CHILD (notebook, child);
if (!list)
@@ -4622,7 +4630,7 @@ gtk_notebook_set_menu_label (GtkNotebook *notebook,
GList *list;
g_return_if_fail (GTK_IS_NOTEBOOK (notebook));
- g_return_if_fail (child != NULL);
+ g_return_if_fail (GTK_IS_WIDGET (child));
list = CHECK_FIND_CHILD (notebook, child);
if (!list)
@@ -4750,7 +4758,7 @@ gtk_notebook_set_tab_label_packing (GtkNotebook *notebook,
GList *list;
g_return_if_fail (GTK_IS_NOTEBOOK (notebook));
- g_return_if_fail (child != NULL);
+ g_return_if_fail (GTK_IS_WIDGET (child));
list = CHECK_FIND_CHILD (notebook, child);
if (!list)
@@ -4800,7 +4808,7 @@ gtk_notebook_query_tab_label_packing (GtkNotebook *notebook,
GList *list;
g_return_if_fail (GTK_IS_NOTEBOOK (notebook));
- g_return_if_fail (child != NULL);
+ g_return_if_fail (GTK_IS_WIDGET (child));
list = CHECK_FIND_CHILD (notebook, child);
if (!list)