]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkcontainer.c
Revert name change
[~andy/gtk] / gtk / gtkcontainer.c
index 9305db57d8ac4baea55a8f0a61f88d21b7954a15..a93ddeec7c0affe8d71433a845d2256e94190ab9 100644 (file)
@@ -24,7 +24,7 @@
  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
-#include <config.h>
+#include "config.h"
 #include <stdarg.h>
 #include <string.h>
 #include <stdlib.h>
@@ -102,7 +102,7 @@ static gchar* gtk_container_child_default_composite_name (GtkContainer *containe
 
 /* GtkBuildable */
 static void gtk_container_buildable_init           (GtkBuildableIface *iface);
-static void gtk_container_buildable_add            (GtkBuildable *buildable,
+static void gtk_container_buildable_add_child      (GtkBuildable *buildable,
                                                    GtkBuilder   *builder,
                                                    GObject      *child,
                                                    const gchar  *type);
@@ -296,16 +296,16 @@ static void
 gtk_container_buildable_init (GtkBuildableIface *iface)
 {
   parent_buildable_iface = g_type_interface_peek_parent (iface);
-  iface->add = gtk_container_buildable_add;
+  iface->add_child = gtk_container_buildable_add_child;
   iface->custom_tag_start = gtk_container_buildable_custom_tag_start;
   iface->custom_tag_end = gtk_container_buildable_custom_tag_end;
 }
 
 static void
-gtk_container_buildable_add (GtkBuildable  *buildable,
-                            GtkBuilder    *builder,
-                            GObject       *child,
-                            const gchar   *type)
+gtk_container_buildable_add_child (GtkBuildable  *buildable,
+                                  GtkBuilder    *builder,
+                                  GObject       *child,
+                                  const gchar   *type)
 {
   g_return_if_fail (GTK_IS_WIDGET (child));
 
@@ -314,13 +314,15 @@ gtk_container_buildable_add (GtkBuildable  *buildable,
 
 static void
 gtk_container_buildable_set_child_property (GtkContainer *container,
+                                           GtkBuilder   *builder,
                                            GtkWidget    *child,
                                            gchar        *name,
                                            const gchar  *value)
 {
   GParamSpec *pspec;
   GValue gvalue = { 0, };
-
+  GError *error = NULL;
+  
   pspec = gtk_container_class_find_child_property
     (G_OBJECT_GET_CLASS (container), name);
   if (!pspec)
@@ -330,13 +332,15 @@ gtk_container_buildable_set_child_property (GtkContainer *container,
       return;
     }
 
-  if (!gtk_builder_value_from_string (pspec, value, &gvalue))
+  if (!gtk_builder_value_from_string (builder, pspec, value, &gvalue, &error))
     {
-      g_warning ("Could not read property %s:%s with value %s of type %s",
+      g_warning ("Could not read property %s:%s with value %s of type %s: %s",
                 g_type_name (G_OBJECT_TYPE (container)),
                 name,
                 value,
-                g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)));
+                g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
+                error->message);
+      g_error_free (error);
       return;
     }
 
@@ -385,6 +389,7 @@ attributes_text_element (GMarkupParseContext *context,
     return;
 
   gtk_container_buildable_set_child_property (parser_data->container,
+                                             parser_data->builder,
                                              parser_data->child,
                                              parser_data->child_prop_name,
                                              text);
@@ -532,8 +537,8 @@ container_set_child_property (GtkContainer       *container,
  * @container: a #GtkContainer
  * @child: a widget which is a child of @container
  * @first_property_name: the name of the first property to get
- * @var_args: a %NULL-terminated list of property names and #GValue*, 
- *           starting with @first_prop_name.
+ * @var_args: return location for the first property, followed 
+ *     optionally by more name/return location pairs, followed by %NULL
  * 
  * Gets the values of one or more child properties for @child and @container.
  **/
@@ -814,6 +819,7 @@ gtk_container_add_with_properties (GtkContainer *container,
   g_return_if_fail (GTK_IS_CONTAINER (container));
   g_return_if_fail (GTK_IS_WIDGET (widget));
   g_return_if_fail (widget->parent == NULL);
+  g_return_if_fail (widget->parent == container);
 
   g_object_ref (container);
   g_object_ref (widget);
@@ -866,8 +872,8 @@ gtk_container_child_set (GtkContainer      *container,
  * @container: a #GtkContainer
  * @child: a widget which is a child of @container
  * @first_prop_name: the name of the first property to get
- * @Varargs: a %NULL-terminated list of property names and #GValue*, 
- *           starting with @first_prop_name
+ * @Varargs: return location for the first property, followed 
+ *     optionally by more name/return location pairs, followed by %NULL
  * 
  * Gets the values of one or more child properties for @child and @container.
  **/
@@ -1078,8 +1084,9 @@ gtk_container_get_property (GObject         *object,
  * #GtkWindow; because toplevel windows can't leave space outside,
  * they leave the space inside. The border is added on all sides of
  * the container. To add space to only one side, one approach is to
- * create a #GtkAlignment widget, call gtk_widget_set_usize() to give
- * it a size, and place it on the side of the container as a spacer.
+ * create a #GtkAlignment widget, call gtk_widget_set_size_request()
+ * to give it a size, and place it on the side of the container as
+ * a spacer.
  **/
 void
 gtk_container_set_border_width (GtkContainer *container,
@@ -1139,7 +1146,8 @@ gtk_container_add (GtkContainer *container,
     {
       g_warning ("Attempting to add a widget with type %s to a container of "
                  "type %s, but the widget is already inside a container of type %s, "
-                 "the GTK+ FAQ at http://www.gtk.org/faq/ explains how to reparent a widget.",
+                 "the GTK+ FAQ at http://library.gnome.org/devel/gtk-faq/stable/ "
+                 "explains how to reparent a widget.",
                  g_type_name (G_OBJECT_TYPE (widget)),
                  g_type_name (G_OBJECT_TYPE (container)),
                  g_type_name (G_OBJECT_TYPE (widget->parent)));
@@ -1506,7 +1514,7 @@ gtk_container_foreach_full (GtkContainer       *container,
                            GtkCallback         callback,
                            GtkCallbackMarshal  marshal,
                            gpointer            callback_data,
-                           GtkDestroyNotify    notify)
+                           GDestroyNotify      notify)
 {
   g_return_if_fail (GTK_IS_CONTAINER (container));
 
@@ -1531,6 +1539,17 @@ gtk_container_foreach_full (GtkContainer       *container,
     notify (callback_data);
 }
 
+/**
+ * gtk_container_set_focus_child:
+ * @container: a #GtkContainer
+ * @widget: a #GtkWidget, or %NULL
+ *
+ * Sets, or unsets if @widget is %NULL, the focused child of @container.
+ *
+ * This function emits the GtkContainer::set_focus_child signal of
+ * @container. Implementations of #GtkContainer can override the
+ * default behaviour by overriding the class closure of this signal.
+ */
 void
 gtk_container_set_focus_child (GtkContainer *container,
                               GtkWidget    *widget)
@@ -1542,6 +1561,25 @@ gtk_container_set_focus_child (GtkContainer *container,
   g_signal_emit (container, container_signals[SET_FOCUS_CHILD], 0, widget);
 }
 
+/**
+ * gtk_container_get_focus_child:
+ * @container: a #GtkContainer
+ *
+ * Returns the current focus child widget inside @container.
+ *
+ * Returns: The child widget which has the focus
+ *          inside @container, or %NULL if none is set.
+ *
+ * Since: 2.14
+ **/
+GtkWidget *
+gtk_container_get_focus_child (GtkContainer *container)
+{
+  g_return_val_if_fail (GTK_IS_CONTAINER (container), NULL);
+
+  return container->focus_child;
+}
+
 /**
  * gtk_container_get_children:
  * @container: a #GtkContainer
@@ -1861,8 +1899,8 @@ old_focus_coords (GtkContainer *container,
 {
   GtkWidget *widget = GTK_WIDGET (container);
   GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
-  
-  if (toplevel && GTK_IS_WINDOW (toplevel) && GTK_WINDOW (toplevel)->focus_widget)
+
+  if (GTK_IS_WINDOW (toplevel) && GTK_WINDOW (toplevel)->focus_widget)
     {
       GtkWidget *old_focus = GTK_WINDOW (toplevel)->focus_widget;
       
@@ -2454,9 +2492,9 @@ gtk_container_get_focus_vadjustment (GtkContainer *container)
  * 
  * Hooks up an adjustment to focus handling in a container, so when a child 
  * of the container is focused, the adjustment is scrolled to show that 
- * widget. This function sets the horizontal alignment. See gt
- * k_scrolled_window_get_hadjustment() for a typical way of obtaining the 
- * adjustment and gtk_container_set_focus_vadjustment() for setting
+ * widget. This function sets the horizontal alignment. 
+ * See gtk_scrolled_window_get_hadjustment() for a typical way of obtaining 
+ * the adjustment and gtk_container_set_focus_vadjustment() for setting
  * the vertical adjustment.
  *
  * The adjustments have to be in pixel units and in the same coordinate