From 642ef2c7db71909256f5a2b3fda4a8cacef8be12 Mon Sep 17 00:00:00 2001 From: Tim Janik Date: Thu, 9 Mar 2006 13:51:18 +0000 Subject: [PATCH] clean up the GInitiallyUnowned floating flag when setting GTK_FLOATING. Thu Mar 9 14:49:35 2006 Tim Janik * gtk/gtkobject.c (gtk_object_init): clean up the GInitiallyUnowned floating flag when setting GTK_FLOATING. added tests/floatingcheck (a weakened variant of what gtk+-2.10 has). --- ChangeLog | 6 ++++ ChangeLog.pre-2-10 | 6 ++++ gtk/gtkobject.c | 5 ++++ tests/Makefile.am | 6 ++++ tests/floatingtest.c | 65 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 88 insertions(+) create mode 100644 tests/floatingtest.c diff --git a/ChangeLog b/ChangeLog index fd220cfe14..bea3a0bb17 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Thu Mar 9 14:49:35 2006 Tim Janik + + * gtk/gtkobject.c (gtk_object_init): clean up the GInitiallyUnowned + floating flag when setting GTK_FLOATING. + added tests/floatingcheck (a weakened variant of what gtk+-2.10 has). + 2006-03-08 Matthias Clasen * Bump version diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index fd220cfe14..bea3a0bb17 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,9 @@ +Thu Mar 9 14:49:35 2006 Tim Janik + + * gtk/gtkobject.c (gtk_object_init): clean up the GInitiallyUnowned + floating flag when setting GTK_FLOATING. + added tests/floatingcheck (a weakened variant of what gtk+-2.10 has). + 2006-03-08 Matthias Clasen * Bump version diff --git a/gtk/gtkobject.c b/gtk/gtkobject.c index 4a51f2d990..9d577218e1 100644 --- a/gtk/gtkobject.c +++ b/gtk/gtkobject.c @@ -382,6 +382,11 @@ static void gtk_object_init (GtkObject *object, GtkObjectClass *klass) { + if (gobject_floating_flag_handler) + { + /* sink the GInitiallyUnowned floating flag */ + gobject_floating_flag_handler (object, -1); + } GTK_OBJECT_FLAGS (object) = GTK_FLOATING; } diff --git a/tests/Makefile.am b/tests/Makefile.am index ea7a885518..3e1f441f87 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -25,8 +25,10 @@ if USE_X11 testsocket_programs = testsocket testsocket_child endif +TESTS = floatingtest noinst_PROGRAMS = \ + $(TESTS) \ simple \ testcairo \ testcalendar \ @@ -71,6 +73,7 @@ noinst_PROGRAMS = \ testmerge \ testactions +floatingtest_DEPENDENCIES = $(TEST_DEPS) simple_DEPENDENCIES = $(TEST_DEPS) testicontheme_DEPENDENCIES = $(TEST_DEPS) testiconview_DEPENDENCIES = $(TEST_DEPS) @@ -109,6 +112,7 @@ testxinerama_DEPENDENCIES = $(TEST_DEPS) testmerge_DEPENDENCIES = $(TEST_DEPS) testactions_DEPENDENCIES = $(TEST_DEPS) +floatingtest_LDADD = $(LDADDS) simple_LDADD = $(LDADDS) testcairo_LDADD = $(LDADDS) testcalendar_LDADD = $(LDADDS) @@ -154,6 +158,8 @@ pixbuf_threads_LDADD = $(LDADDS) $(GLIB_LIBS) testmerge_LDADD = $(LDADDS) testactions_LDADD = $(LDADDS) +floatingtest_SOURCES = floatingtest.c + testfilechooser_SOURCES = \ prop-editor.c \ testfilechooser.c diff --git a/tests/floatingtest.c b/tests/floatingtest.c new file mode 100644 index 0000000000..abd2f6fb06 --- /dev/null +++ b/tests/floatingtest.c @@ -0,0 +1,65 @@ +/* floatingtest.c - test floating flag uses + * Copyright (C) 2005 Tim Janik + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ +#undef GTK_DISABLE_DEPRECATED +#include "../gtk/gtk.h" + +static gboolean destroyed = FALSE; +static void destroy (void) { destroyed = TRUE; } + +int +main (int argc, + char *argv[]) +{ + GtkWidget *widget; + gtk_init (&argc, &argv); + + widget = g_object_new (GTK_TYPE_LABEL, NULL); + g_object_connect (widget, "signal::destroy", destroy, NULL, NULL); + + g_assert (GTK_OBJECT_FLOATING (widget)); + //g_assert (g_object_is_floating (widget)); + + GTK_OBJECT_UNSET_FLAGS (widget, GTK_FLOATING); + g_assert (!GTK_OBJECT_FLOATING (widget)); + //g_assert (!g_object_is_floating (widget)); + + GTK_OBJECT_SET_FLAGS (widget, GTK_FLOATING); + g_assert (GTK_OBJECT_FLOATING (widget)); + //g_assert (g_object_is_floating (widget)); + + g_object_ref (widget); + gtk_object_sink (GTK_OBJECT (widget)); + g_assert (!GTK_OBJECT_FLOATING (widget)); + //g_assert (!g_object_is_floating (widget)); + + GTK_OBJECT_SET_FLAGS (GTK_OBJECT (widget), GTK_FLOATING); + g_assert (GTK_OBJECT_FLOATING (widget)); + //g_assert (g_object_is_floating (widget)); + + g_object_ref (widget); + gtk_object_sink (GTK_OBJECT (widget)); + g_assert (!GTK_OBJECT_FLOATING (widget)); + //g_assert (!g_object_is_floating (widget)); + + g_assert (!destroyed); + g_object_unref (widget); + g_assert (destroyed); + + return 0; +}