From de985fb58e80be74a181fee5e6f2d85d390c9140 Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Sun, 1 Jul 2001 00:57:21 +0000 Subject: [PATCH] Remove change check for GTK_TYPE_OBJECT derivation to G_TYPE_OBJECTS - Sat Jun 30 20:44:48 2001 Owen Taylor * gtk/gtktypeutils.c (gtk_type_class): Remove change check for GTK_TYPE_OBJECT derivation to G_TYPE_OBJECTS - it's Tim-approved to use this for arbitary objects. * gtk/gtkwindow.c gtk/gtkcontainer.[ch]: underscore prefix gtk_container_dequeue_resize_handler(). * gtk/gtkwidget.[ch]: Add a previous_toplevel argument to the hierarachy_changed signal, since you otherwise have to always keep that around. * gtk/gtkmenubar.c gtk/gtklabel.c gtk/gtksocket.c: Adapt for extra argument to hierarchy_changed. --- ChangeLog | 17 +++++++++++++++++ ChangeLog.pre-2-0 | 17 +++++++++++++++++ ChangeLog.pre-2-10 | 17 +++++++++++++++++ ChangeLog.pre-2-2 | 17 +++++++++++++++++ ChangeLog.pre-2-4 | 17 +++++++++++++++++ ChangeLog.pre-2-6 | 17 +++++++++++++++++ ChangeLog.pre-2-8 | 17 +++++++++++++++++ gtk/gtkcontainer.c | 4 ++-- gtk/gtkcontainer.h | 2 +- gtk/gtklabel.c | 6 ++++-- gtk/gtkmenubar.c | 33 ++++++++------------------------- gtk/gtkmenubar.h | 2 -- gtk/gtksocket.c | 6 ++++-- gtk/gtktypeutils.c | 2 +- gtk/gtkwidget.c | 41 +++++++++++++++++++++++++++++------------ gtk/gtkwidget.h | 3 ++- gtk/gtkwindow.c | 2 +- 17 files changed, 171 insertions(+), 49 deletions(-) diff --git a/ChangeLog b/ChangeLog index c256b216e5..94abf571b9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +Sat Jun 30 20:44:48 2001 Owen Taylor + + * gtk/gtktypeutils.c (gtk_type_class): Remove + change check for GTK_TYPE_OBJECT derivation to + G_TYPE_OBJECTS - it's Tim-approved to use this + for arbitary objects. + + * gtk/gtkwindow.c gtk/gtkcontainer.[ch]: underscore + prefix gtk_container_dequeue_resize_handler(). + + * gtk/gtkwidget.[ch]: Add a previous_toplevel argument + to the hierarachy_changed signal, since you otherwise + have to always keep that around. + + * gtk/gtkmenubar.c gtk/gtklabel.c gtk/gtksocket.c: Adapt + for extra argument to hierarchy_changed. + Tue Jun 26 19:39:03 2001 Owen Taylor * gtk/gtkwidget.c (gtk_widget_set_style): Allow %NULL diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index c256b216e5..94abf571b9 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,20 @@ +Sat Jun 30 20:44:48 2001 Owen Taylor + + * gtk/gtktypeutils.c (gtk_type_class): Remove + change check for GTK_TYPE_OBJECT derivation to + G_TYPE_OBJECTS - it's Tim-approved to use this + for arbitary objects. + + * gtk/gtkwindow.c gtk/gtkcontainer.[ch]: underscore + prefix gtk_container_dequeue_resize_handler(). + + * gtk/gtkwidget.[ch]: Add a previous_toplevel argument + to the hierarachy_changed signal, since you otherwise + have to always keep that around. + + * gtk/gtkmenubar.c gtk/gtklabel.c gtk/gtksocket.c: Adapt + for extra argument to hierarchy_changed. + Tue Jun 26 19:39:03 2001 Owen Taylor * gtk/gtkwidget.c (gtk_widget_set_style): Allow %NULL diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index c256b216e5..94abf571b9 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,20 @@ +Sat Jun 30 20:44:48 2001 Owen Taylor + + * gtk/gtktypeutils.c (gtk_type_class): Remove + change check for GTK_TYPE_OBJECT derivation to + G_TYPE_OBJECTS - it's Tim-approved to use this + for arbitary objects. + + * gtk/gtkwindow.c gtk/gtkcontainer.[ch]: underscore + prefix gtk_container_dequeue_resize_handler(). + + * gtk/gtkwidget.[ch]: Add a previous_toplevel argument + to the hierarachy_changed signal, since you otherwise + have to always keep that around. + + * gtk/gtkmenubar.c gtk/gtklabel.c gtk/gtksocket.c: Adapt + for extra argument to hierarchy_changed. + Tue Jun 26 19:39:03 2001 Owen Taylor * gtk/gtkwidget.c (gtk_widget_set_style): Allow %NULL diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index c256b216e5..94abf571b9 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,20 @@ +Sat Jun 30 20:44:48 2001 Owen Taylor + + * gtk/gtktypeutils.c (gtk_type_class): Remove + change check for GTK_TYPE_OBJECT derivation to + G_TYPE_OBJECTS - it's Tim-approved to use this + for arbitary objects. + + * gtk/gtkwindow.c gtk/gtkcontainer.[ch]: underscore + prefix gtk_container_dequeue_resize_handler(). + + * gtk/gtkwidget.[ch]: Add a previous_toplevel argument + to the hierarachy_changed signal, since you otherwise + have to always keep that around. + + * gtk/gtkmenubar.c gtk/gtklabel.c gtk/gtksocket.c: Adapt + for extra argument to hierarchy_changed. + Tue Jun 26 19:39:03 2001 Owen Taylor * gtk/gtkwidget.c (gtk_widget_set_style): Allow %NULL diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index c256b216e5..94abf571b9 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,20 @@ +Sat Jun 30 20:44:48 2001 Owen Taylor + + * gtk/gtktypeutils.c (gtk_type_class): Remove + change check for GTK_TYPE_OBJECT derivation to + G_TYPE_OBJECTS - it's Tim-approved to use this + for arbitary objects. + + * gtk/gtkwindow.c gtk/gtkcontainer.[ch]: underscore + prefix gtk_container_dequeue_resize_handler(). + + * gtk/gtkwidget.[ch]: Add a previous_toplevel argument + to the hierarachy_changed signal, since you otherwise + have to always keep that around. + + * gtk/gtkmenubar.c gtk/gtklabel.c gtk/gtksocket.c: Adapt + for extra argument to hierarchy_changed. + Tue Jun 26 19:39:03 2001 Owen Taylor * gtk/gtkwidget.c (gtk_widget_set_style): Allow %NULL diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index c256b216e5..94abf571b9 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,20 @@ +Sat Jun 30 20:44:48 2001 Owen Taylor + + * gtk/gtktypeutils.c (gtk_type_class): Remove + change check for GTK_TYPE_OBJECT derivation to + G_TYPE_OBJECTS - it's Tim-approved to use this + for arbitary objects. + + * gtk/gtkwindow.c gtk/gtkcontainer.[ch]: underscore + prefix gtk_container_dequeue_resize_handler(). + + * gtk/gtkwidget.[ch]: Add a previous_toplevel argument + to the hierarachy_changed signal, since you otherwise + have to always keep that around. + + * gtk/gtkmenubar.c gtk/gtklabel.c gtk/gtksocket.c: Adapt + for extra argument to hierarchy_changed. + Tue Jun 26 19:39:03 2001 Owen Taylor * gtk/gtkwidget.c (gtk_widget_set_style): Allow %NULL diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index c256b216e5..94abf571b9 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,20 @@ +Sat Jun 30 20:44:48 2001 Owen Taylor + + * gtk/gtktypeutils.c (gtk_type_class): Remove + change check for GTK_TYPE_OBJECT derivation to + G_TYPE_OBJECTS - it's Tim-approved to use this + for arbitary objects. + + * gtk/gtkwindow.c gtk/gtkcontainer.[ch]: underscore + prefix gtk_container_dequeue_resize_handler(). + + * gtk/gtkwidget.[ch]: Add a previous_toplevel argument + to the hierarachy_changed signal, since you otherwise + have to always keep that around. + + * gtk/gtkmenubar.c gtk/gtklabel.c gtk/gtksocket.c: Adapt + for extra argument to hierarchy_changed. + Tue Jun 26 19:39:03 2001 Owen Taylor * gtk/gtkwidget.c (gtk_widget_set_style): Allow %NULL diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c index 455eef7104..b73529d113 100644 --- a/gtk/gtkcontainer.c +++ b/gtk/gtkcontainer.c @@ -717,7 +717,7 @@ gtk_container_destroy (GtkObject *object) container = GTK_CONTAINER (object); if (GTK_CONTAINER_RESIZE_PENDING (container)) - gtk_container_dequeue_resize_handler (container); + _gtk_container_dequeue_resize_handler (container); if (container->resize_widgets) gtk_container_clear_resize_widgets (container); @@ -894,7 +894,7 @@ gtk_container_remove (GtkContainer *container, } void -gtk_container_dequeue_resize_handler (GtkContainer *container) +_gtk_container_dequeue_resize_handler (GtkContainer *container) { g_return_if_fail (GTK_IS_CONTAINER (container)); g_return_if_fail (GTK_CONTAINER_RESIZE_PENDING (container)); diff --git a/gtk/gtkcontainer.h b/gtk/gtkcontainer.h index d668a418fb..cebb10b826 100644 --- a/gtk/gtkcontainer.h +++ b/gtk/gtkcontainer.h @@ -205,7 +205,7 @@ void gtk_container_forall (GtkContainer *container, gpointer callback_data); gchar* gtk_container_child_composite_name (GtkContainer *container, GtkWidget *child); -void gtk_container_dequeue_resize_handler (GtkContainer *container); +void _gtk_container_dequeue_resize_handler (GtkContainer *container); #ifdef __cplusplus } diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index b1e85ffff2..64f85330ed 100644 --- a/gtk/gtklabel.c +++ b/gtk/gtklabel.c @@ -113,7 +113,8 @@ static void set_markup (GtkLabel *label, const gchar *str, gboolean with_uline); static void gtk_label_recalculate (GtkLabel *label); -static void gtk_label_hierarchy_changed (GtkWidget *widget); +static void gtk_label_hierarchy_changed (GtkWidget *widget, + GtkWidget *old_toplevel); static void gtk_label_create_window (GtkLabel *label); static void gtk_label_destroy_window (GtkLabel *label); @@ -502,7 +503,8 @@ gtk_label_setup_mnemonic (GtkLabel *label, } static void -gtk_label_hierarchy_changed (GtkWidget *widget) +gtk_label_hierarchy_changed (GtkWidget *widget, + GtkWidget *old_toplevel) { GtkLabel *label = GTK_LABEL (widget); diff --git a/gtk/gtkmenubar.c b/gtk/gtkmenubar.c index e5b20b8560..2982418928 100644 --- a/gtk/gtkmenubar.c +++ b/gtk/gtkmenubar.c @@ -48,7 +48,8 @@ static void gtk_menu_bar_paint (GtkWidget *widget, GdkRectangle *area); static gint gtk_menu_bar_expose (GtkWidget *widget, GdkEventExpose *event); -static void gtk_menu_bar_hierarchy_changed (GtkWidget *widget); +static void gtk_menu_bar_hierarchy_changed (GtkWidget *widget, + GtkWidget *old_toplevel); static GtkShadowType get_shadow_type (GtkMenuBar *menubar); static GtkMenuShellClass *parent_class = NULL; @@ -460,30 +461,20 @@ add_to_window (GtkWindow *window, "key_press_event", G_CALLBACK (window_key_press_handler), menubar); - - menubar->toplevel = GTK_WIDGET (window); } static void remove_from_window (GtkWindow *window, GtkMenuBar *menubar) { - g_return_if_fail (menubar->toplevel == GTK_WIDGET (window)); - g_signal_handlers_disconnect_by_func (G_OBJECT (window), G_CALLBACK (window_key_press_handler), menubar); - - /* dnotify zeroes menubar->toplevel */ - g_object_set_data (G_OBJECT (window), - "gtk-menu-bar", - NULL); - - menubar->toplevel = NULL; } static void -gtk_menu_bar_hierarchy_changed (GtkWidget *widget) +gtk_menu_bar_hierarchy_changed (GtkWidget *widget, + GtkWidget *old_toplevel) { GtkWidget *toplevel; GtkMenuBar *menubar; @@ -492,19 +483,11 @@ gtk_menu_bar_hierarchy_changed (GtkWidget *widget) toplevel = gtk_widget_get_toplevel (widget); - if (menubar->toplevel && - toplevel != menubar->toplevel) - { - remove_from_window (GTK_WINDOW (menubar->toplevel), - menubar); - } + if (old_toplevel && GTK_IS_WINDOW (old_toplevel)) + remove_from_window (old_toplevel, menubar); - if (toplevel && - GTK_IS_WINDOW (toplevel)) - { - add_to_window (GTK_WINDOW (toplevel), - menubar); - } + if (toplevel && GTK_IS_WINDOW (toplevel)) + add_to_window (GTK_WINDOW (toplevel), menubar); } static GtkShadowType diff --git a/gtk/gtkmenubar.h b/gtk/gtkmenubar.h index e1d55830a3..195f94ee35 100644 --- a/gtk/gtkmenubar.h +++ b/gtk/gtkmenubar.h @@ -51,8 +51,6 @@ typedef struct _GtkMenuBarClass GtkMenuBarClass; struct _GtkMenuBar { GtkMenuShell menu_shell; - - GtkWidget *toplevel; }; struct _GtkMenuBarClass diff --git a/gtk/gtksocket.c b/gtk/gtksocket.c index 77d391b294..f28310bccc 100644 --- a/gtk/gtksocket.c +++ b/gtk/gtksocket.c @@ -46,7 +46,8 @@ static void gtk_socket_size_request (GtkWidget *widget GtkRequisition *requisition); static void gtk_socket_size_allocate (GtkWidget *widget, GtkAllocation *allocation); -static void gtk_socket_hierarchy_changed (GtkWidget *widget); +static void gtk_socket_hierarchy_changed (GtkWidget *widget, + GtkWidget *old_toplevel); static void gtk_socket_grab_notify (GtkWidget *widget, gboolean was_grabbed); static gboolean gtk_socket_key_press_event (GtkWidget *widget, @@ -541,7 +542,8 @@ toplevel_focus_out_handler (GtkWidget *toplevel, } static void -gtk_socket_hierarchy_changed (GtkWidget *widget) +gtk_socket_hierarchy_changed (GtkWidget *widget, + GtkWidget *old_toplevel) { GtkSocket *socket = GTK_SOCKET (widget); GtkWidget *toplevel = gtk_widget_get_toplevel (widget); diff --git a/gtk/gtktypeutils.c b/gtk/gtktypeutils.c index 6b7de94ccc..c49a69a8db 100644 --- a/gtk/gtktypeutils.c +++ b/gtk/gtktypeutils.c @@ -62,7 +62,7 @@ gtk_type_class (GtkType type) gpointer class; if (!G_TYPE_IS_ENUM (type) && !G_TYPE_IS_FLAGS (type)) - g_return_val_if_fail (GTK_TYPE_IS_OBJECT (type), NULL); + g_return_val_if_fail (G_TYPE_IS_OBJECT (type), NULL); /* ok, this is a bit ugly, GLib reference counts classes, * and gtk_type_class() used to always return static classes. diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 3851d0952f..6bff279225 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -604,8 +604,9 @@ gtk_widget_class_init (GtkWidgetClass *klass) GTK_RUN_LAST, GTK_CLASS_TYPE (object_class), GTK_SIGNAL_OFFSET (GtkWidgetClass, hierarchy_changed), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); + gtk_marshal_VOID__OBJECT, + GTK_TYPE_NONE, 1, + GTK_TYPE_WIDGET); widget_signals[STYLE_SET] = gtk_signal_new ("style_set", GTK_RUN_FIRST, @@ -1475,6 +1476,7 @@ gtk_widget_unparent (GtkWidget *widget) { GObjectNotifyQueue *nqueue; GtkWidget *toplevel; + GtkWidget *ancestor; GtkWidget *old_parent; g_return_if_fail (widget != NULL); @@ -1524,6 +1526,14 @@ gtk_widget_unparent (GtkWidget *widget) gtk_window_set_default (GTK_WINDOW (toplevel), NULL); } + /* If we are unanchoring the child, we save around the toplevel + * to emit hierarchy changed + */ + if (GTK_WIDGET_ANCHORED (widget->parent)) + g_object_ref (toplevel); + else + toplevel = NULL; + if (GTK_IS_RESIZE_CONTAINER (widget)) gtk_container_clear_resize_widgets (GTK_CONTAINER (widget)); @@ -1536,20 +1546,20 @@ gtk_widget_unparent (GtkWidget *widget) * Write a g_slist_conditional_remove (GSList, gboolean (*)(gpointer)) * Change resize_widgets to a GList */ - toplevel = widget->parent; - while (toplevel) + ancestor = widget->parent; + while (ancestor) { GSList *slist; GSList *prev; - if (!GTK_CONTAINER (toplevel)->resize_widgets) + if (!GTK_CONTAINER (ancestor)->resize_widgets) { - toplevel = toplevel->parent; + ancestor = ancestor->parent; continue; } prev = NULL; - slist = GTK_CONTAINER (toplevel)->resize_widgets; + slist = GTK_CONTAINER (ancestor)->resize_widgets; while (slist) { GtkWidget *child; @@ -1571,7 +1581,7 @@ gtk_widget_unparent (GtkWidget *widget) if (prev) prev->next = slist; else - GTK_CONTAINER (toplevel)->resize_widgets = slist; + GTK_CONTAINER (ancestor)->resize_widgets = slist; g_slist_free_1 (last); } @@ -1579,7 +1589,7 @@ gtk_widget_unparent (GtkWidget *widget) prev = last; } - toplevel = toplevel->parent; + ancestor = ancestor->parent; } gtk_widget_queue_clear_child (widget); @@ -1599,7 +1609,12 @@ gtk_widget_unparent (GtkWidget *widget) widget->parent = NULL; gtk_widget_set_parent_window (widget, NULL); gtk_signal_emit (GTK_OBJECT (widget), widget_signals[PARENT_SET], old_parent); - gtk_widget_propagate_hierarchy_changed (widget, NULL); + if (toplevel) + { + gtk_widget_propagate_hierarchy_changed (widget, toplevel); + g_object_unref (toplevel); + } + g_object_notify (G_OBJECT (widget), "parent"); g_object_thaw_notify (G_OBJECT (widget)); if (!widget->parent) @@ -3455,7 +3470,8 @@ gtk_widget_set_parent (GtkWidget *widget, gtk_widget_set_style_recurse (widget, NULL); gtk_signal_emit (GTK_OBJECT (widget), widget_signals[PARENT_SET], NULL); - gtk_widget_propagate_hierarchy_changed (widget, NULL); + if (GTK_WIDGET_ANCHORED (widget->parent)) + gtk_widget_propagate_hierarchy_changed (widget, NULL); g_object_notify (G_OBJECT (widget), "parent"); } @@ -3928,7 +3944,8 @@ gtk_widget_propagate_hierarchy_changed (GtkWidget *widget, else GTK_PRIVATE_UNSET_FLAG (widget, GTK_ANCHORED); - g_signal_emit (GTK_OBJECT (widget), widget_signals[HIERARCHY_CHANGED], 0); + g_signal_emit (GTK_OBJECT (widget), widget_signals[HIERARCHY_CHANGED], + 0, client_data); if (GTK_IS_CONTAINER (widget)) gtk_container_forall (GTK_CONTAINER (widget), diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index 83f416e4b2..e8f525fe15 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -266,7 +266,8 @@ struct _GtkWidgetClass GtkStateType previous_state); void (* parent_set) (GtkWidget *widget, GtkWidget *previous_parent); - void (* hierarchy_changed) (GtkWidget *widget); + void (* hierarchy_changed) (GtkWidget *widget, + GtkWidget *previous_toplevel); void (* style_set) (GtkWidget *widget, GtkStyle *previous_style); void (* direction_changed) (GtkWidget *widget, diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index b4b6f9f26b..1ebd9f19f6 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -2898,7 +2898,7 @@ gtk_window_move_resize (GtkWindow *window) */ gtk_widget_queue_resize (GTK_WIDGET (container)); if (container->resize_mode == GTK_RESIZE_QUEUE) - gtk_container_dequeue_resize_handler (container); + _gtk_container_dequeue_resize_handler (container); } else {