]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkobject.c
Include "config.h" instead of <config.h> Command used: find -name
[~andy/gtk] / gtk / gtkobject.c
index 953670d4087112be89f6aface62d6aed104ccec2..a2dde92d8423f87899c91ee7983efa124073d7da 100644 (file)
  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
-#include <config.h>
+#include "config.h"
+
 #include <stdarg.h>
 #include <string.h>
 #include <stdio.h>
+
+#undef GTK_DISABLE_DEPRECATED
+
 #include "gtkobject.h"
 #include "gtkintl.h"
 #include "gtkmarshalers.h"
-#include "gtksignal.h"
 #include "gtkprivate.h"
+
+#define GTK_DISABLE_DEPRECATED
 #include "gtkalias.h"
 
 
@@ -46,7 +51,6 @@ enum {
 };
 
 
-extern void      gtk_object_init_type           (void);        /* for gtktypeutils.h */
 static void       gtk_object_base_class_init     (GtkObjectClass *class);
 static void       gtk_object_base_class_finalize (GtkObjectClass *class);
 static void       gtk_object_class_init          (GtkObjectClass *klass);
@@ -82,7 +86,7 @@ gtk_object_get_type (void)
 
   if (!object_type)
     {
-      static const GTypeInfo object_info =
+      const GTypeInfo object_info =
       {
        sizeof (GtkObjectClass),
        (GBaseInitFunc) gtk_object_base_class_init,
@@ -96,7 +100,7 @@ gtk_object_get_type (void)
        NULL,           /* value_table */
       };
       
-      object_type = g_type_register_static (G_TYPE_OBJECT, I_("GtkObject"), 
+      object_type = g_type_register_static (G_TYPE_INITIALLY_UNOWNED, I_("GtkObject"), 
                                            &object_info, G_TYPE_FLAG_ABSTRACT);
     }
 
@@ -314,13 +318,46 @@ gtk_object_add_arg_type (const gchar *arg_name,
   g_object_class_install_property (oclass, arg_id, pspec);
 }
 
+static guint (*gobject_floating_flag_handler) (GtkObject*,gint) = NULL;
+
+static guint
+gtk_object_floating_flag_handler (GtkObject *object,
+                                  gint       job)
+{
+  /* FIXME: remove this whole thing once GTK+ breaks ABI */
+  if (!GTK_IS_OBJECT (object))
+    return gobject_floating_flag_handler (object, job);
+  switch (job)
+    {
+      guint32 oldvalue;
+    case +1:    /* force floating if possible */
+      do
+        oldvalue = g_atomic_int_get (&object->flags);
+      while (!g_atomic_int_compare_and_exchange (&object->flags, oldvalue, oldvalue | GTK_FLOATING));
+      return oldvalue & GTK_FLOATING;
+    case -1:    /* sink if possible */
+      do
+        oldvalue = g_atomic_int_get (&object->flags);
+      while (!g_atomic_int_compare_and_exchange (&object->flags, oldvalue, oldvalue & ~(guint32) GTK_FLOATING));
+      return oldvalue & GTK_FLOATING;
+    default:    /* check floating */
+      return 0 != (g_atomic_int_get (&object->flags) & GTK_FLOATING);
+    }
+}
+
 static void
 gtk_object_class_init (GtkObjectClass *class)
 {
   GObjectClass *gobject_class = G_OBJECT_CLASS (class);
+  gboolean is_glib_2_10_1;
 
   parent_class = g_type_class_ref (G_TYPE_OBJECT);
 
+  is_glib_2_10_1 = g_object_compat_control (3, &gobject_floating_flag_handler);
+  if (!is_glib_2_10_1)
+    g_error ("this version of Gtk+ requires GLib-2.10.1");
+  g_object_compat_control (2, gtk_object_floating_flag_handler);
+
   gobject_class->set_property = gtk_object_set_property;
   gobject_class->get_property = gtk_object_get_property;
   gobject_class->dispose = gtk_object_dispose;
@@ -348,6 +385,12 @@ static void
 gtk_object_init (GtkObject      *object,
                 GtkObjectClass *klass)
 {
+  gboolean was_floating;
+  /* sink the GInitiallyUnowned floating flag */
+  was_floating = gobject_floating_flag_handler (object, -1);
+  /* set GTK_FLOATING via gtk_object_floating_flag_handler */
+  if (was_floating)
+    g_object_force_floating (G_OBJECT (object));
 }
 
 /********************************************