]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkfixed.c
call gdk_flush() after showing the menu so we can definitely grab on it.
[~andy/gtk] / gtk / gtkfixed.c
index 4781c0f8989b26284346a9441501a979fdb4d6f6..beaac5c5113ebd3fcda26f772406c9d8b6327cc0 100644 (file)
  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
+#include <config.h>
 #include "gtkfixed.h"
+#include "gtkprivate.h"
 #include "gtkintl.h"
-
+#include "gtkalias.h"
 enum {
   CHILD_PROP_0,
   CHILD_PROP_X,
   CHILD_PROP_Y
 };
 
-static void gtk_fixed_class_init    (GtkFixedClass    *klass);
-static void gtk_fixed_init          (GtkFixed         *fixed);
 static void gtk_fixed_realize       (GtkWidget        *widget);
 static void gtk_fixed_size_request  (GtkWidget        *widget,
                                     GtkRequisition   *requisition);
@@ -48,7 +48,7 @@ static void gtk_fixed_forall        (GtkContainer     *container,
                                     gboolean          include_internals,
                                     GtkCallback       callback,
                                     gpointer          callback_data);
-static GtkType gtk_fixed_child_type (GtkContainer     *container);
+static GType gtk_fixed_child_type   (GtkContainer     *container);
 
 static void gtk_fixed_set_child_property (GtkContainer *container,
                                           GtkWidget    *child,
@@ -61,47 +61,17 @@ static void gtk_fixed_get_child_property (GtkContainer *container,
                                           GValue       *value,
                                           GParamSpec   *pspec);
 
-static GtkContainerClass *parent_class = NULL;
-
-
-GtkType
-gtk_fixed_get_type (void)
-{
-  static GtkType fixed_type = 0;
-
-  if (!fixed_type)
-    {
-      static const GtkTypeInfo fixed_info =
-      {
-       "GtkFixed",
-       sizeof (GtkFixed),
-       sizeof (GtkFixedClass),
-       (GtkClassInitFunc) gtk_fixed_class_init,
-       (GtkObjectInitFunc) gtk_fixed_init,
-       /* reserved_1 */ NULL,
-        /* reserved_2 */ NULL,
-        (GtkClassInitFunc) NULL,
-      };
-
-      fixed_type = gtk_type_unique (GTK_TYPE_CONTAINER, &fixed_info);
-    }
-
-  return fixed_type;
-}
+G_DEFINE_TYPE (GtkFixed, gtk_fixed, GTK_TYPE_CONTAINER)
 
 static void
 gtk_fixed_class_init (GtkFixedClass *class)
 {
-  GtkObjectClass *object_class;
   GtkWidgetClass *widget_class;
   GtkContainerClass *container_class;
 
-  object_class = (GtkObjectClass*) class;
   widget_class = (GtkWidgetClass*) class;
   container_class = (GtkContainerClass*) class;
 
-  parent_class = gtk_type_class (GTK_TYPE_CONTAINER);
-
   widget_class->realize = gtk_fixed_realize;
   widget_class->size_request = gtk_fixed_size_request;
   widget_class->size_allocate = gtk_fixed_size_allocate;
@@ -117,25 +87,25 @@ gtk_fixed_class_init (GtkFixedClass *class)
   gtk_container_class_install_child_property (container_class,
                                              CHILD_PROP_X,
                                              g_param_spec_int ("x",
-                                                                _("X position"),
-                                                                _("X position of child widget"),
+                                                                P_("X position"),
+                                                                P_("X position of child widget"),
                                                                 G_MININT,
                                                                 G_MAXINT,
                                                                 0,
-                                                                G_PARAM_READWRITE));
+                                                                GTK_PARAM_READWRITE));
 
   gtk_container_class_install_child_property (container_class,
                                              CHILD_PROP_Y,
                                              g_param_spec_int ("y",
-                                                                _("Y position"),
-                                                                _("Y position of child widget"),
+                                                                P_("Y position"),
+                                                                P_("Y position of child widget"),
                                                                 G_MININT,
                                                                 G_MAXINT,
                                                                 0,
-                                                                G_PARAM_READWRITE));
+                                                                GTK_PARAM_READWRITE));
 }
 
-static GtkType
+static GType
 gtk_fixed_child_type (GtkContainer     *container)
 {
   return GTK_TYPE_WIDGET;
@@ -152,10 +122,7 @@ gtk_fixed_init (GtkFixed *fixed)
 GtkWidget*
 gtk_fixed_new (void)
 {
-  GtkFixed *fixed;
-
-  fixed = gtk_type_new (GTK_TYPE_FIXED);
-  return GTK_WIDGET (fixed);
+  return g_object_new (GTK_TYPE_FIXED, NULL);
 }
 
 static GtkFixedChild*
@@ -188,7 +155,7 @@ gtk_fixed_put (GtkFixed       *fixed,
   GtkFixedChild *child_info;
 
   g_return_if_fail (GTK_IS_FIXED (fixed));
-  g_return_if_fail (widget != NULL);
+  g_return_if_fail (GTK_IS_WIDGET (widget));
 
   child_info = g_new (GtkFixedChild, 1);
   child_info->widget = widget;
@@ -244,10 +211,6 @@ gtk_fixed_move (GtkFixed       *fixed,
                 gint            x,
                 gint            y)
 {
-  g_return_if_fail (GTK_IS_FIXED (fixed));
-  g_return_if_fail (GTK_IS_WIDGET (widget));
-  g_return_if_fail (widget->parent == GTK_WIDGET (fixed));
-
   gtk_fixed_move_internal (fixed, widget, TRUE, x, TRUE, y);
 }
 
@@ -309,10 +272,8 @@ gtk_fixed_realize (GtkWidget *widget)
   GdkWindowAttr attributes;
   gint attributes_mask;
 
-  g_return_if_fail (GTK_IS_FIXED (widget));
-
   if (GTK_WIDGET_NO_WINDOW (widget))
-    GTK_WIDGET_CLASS (parent_class)->realize (widget);
+    GTK_WIDGET_CLASS (gtk_fixed_parent_class)->realize (widget);
   else
     {
       GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
@@ -348,9 +309,6 @@ gtk_fixed_size_request (GtkWidget      *widget,
   GList *children;
   GtkRequisition child_requisition;
 
-  g_return_if_fail (GTK_IS_FIXED (widget));
-  g_return_if_fail (requisition != NULL);
-
   fixed = GTK_FIXED (widget);
   requisition->width = 0;
   requisition->height = 0;
@@ -389,9 +347,6 @@ gtk_fixed_size_allocate (GtkWidget     *widget,
   GList *children;
   guint16 border_width;
 
-  g_return_if_fail (GTK_IS_FIXED(widget));
-  g_return_if_fail (allocation != NULL);
-
   fixed = GTK_FIXED (widget);
 
   widget->allocation = *allocation;
@@ -437,9 +392,6 @@ static void
 gtk_fixed_add (GtkContainer *container,
               GtkWidget    *widget)
 {
-  g_return_if_fail (GTK_IS_FIXED (container));
-  g_return_if_fail (widget != NULL);
-
   gtk_fixed_put (GTK_FIXED (container), widget, 0, 0);
 }
 
@@ -451,9 +403,6 @@ gtk_fixed_remove (GtkContainer *container,
   GtkFixedChild *child;
   GList *children;
 
-  g_return_if_fail (GTK_IS_FIXED (container));
-  g_return_if_fail (widget != NULL);
-
   fixed = GTK_FIXED (container);
 
   children = fixed->children;
@@ -491,7 +440,6 @@ gtk_fixed_forall (GtkContainer *container,
   GtkFixedChild *child;
   GList *children;
 
-  g_return_if_fail (GTK_IS_FIXED (container));
   g_return_if_fail (callback != NULL);
 
   fixed = GTK_FIXED (container);
@@ -512,10 +460,13 @@ gtk_fixed_forall (GtkContainer *container,
  * @has_window: %TRUE if a separate window should be created
  * 
  * Sets whether a #GtkFixed widget is created with a separate
- * #GdkWindow for widget->window or not. (By default, it will be
+ * #GdkWindow for @widget->window or not. (By default, it will be
  * created with no separate #GdkWindow). This function must be called
- * while the is not realized, for instance, immediately after the
+ * while the #GtkFixed is not realized, for instance, immediately after the
  * window is created.
+ * 
+ * This function was added to provide an easy migration path for
+ * older applications which may expect #GtkFixed to have a separate window.
  **/
 void
 gtk_fixed_set_has_window (GtkFixed *fixed,
@@ -537,10 +488,10 @@ gtk_fixed_set_has_window (GtkFixed *fixed,
  * gtk_fixed_get_has_window:
  * @fixed: a #GtkWidget
  * 
- * Gets whether the #GtkFixed has it's own #GdkWindow.
+ * Gets whether the #GtkFixed has its own #GdkWindow.
  * See gdk_fixed_set_has_window().
  * 
- * Return value: 
+ * Return value: %TRUE if @fixed has its own window.
  **/
 gboolean
 gtk_fixed_get_has_window (GtkFixed *fixed)
@@ -549,3 +500,6 @@ gtk_fixed_get_has_window (GtkFixed *fixed)
 
   return !GTK_WIDGET_NO_WINDOW (fixed);
 }
+
+#define __GTK_FIXED_C__
+#include "gtkaliasdef.c"