]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkcontainer.c
Updated Basque translation.
[~andy/gtk] / gtk / gtkcontainer.c
index 9305db57d8ac4baea55a8f0a61f88d21b7954a15..c01a3737023b2a9dfea5c8becbda510cfd165676 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);
@@ -274,7 +274,7 @@ gtk_container_class_init (GtkContainerClass *class)
                  G_TYPE_NONE, 1,
                  GTK_TYPE_WIDGET);
   container_signals[CHECK_RESIZE] =
-    g_signal_new (I_("check_resize"),
+    g_signal_new (I_("check-resize"),
                  G_OBJECT_CLASS_TYPE (object_class),
                  G_SIGNAL_RUN_LAST,
                  G_STRUCT_OFFSET (GtkContainerClass, check_resize),
@@ -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;
     }
 
@@ -363,9 +367,11 @@ attributes_start_element (GMarkupParseContext *context,
   guint i;
 
   if (strcmp (element_name, "property") == 0)
-    for (i = 0; names[i]; i++)
-      if (strcmp (names[i], "name") == 0)
-       parser_data->child_prop_name = g_strdup (values[i]);
+    {
+      for (i = 0; names[i]; i++)
+       if (strcmp (names[i], "name") == 0)
+         parser_data->child_prop_name = g_strdup (values[i]);
+    }
   else if (strcmp (element_name, "packing") == 0)
     return;
   else
@@ -385,6 +391,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 +539,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.
  **/
@@ -866,8 +873,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.
  **/
@@ -1002,7 +1009,7 @@ static void
 gtk_container_destroy (GtkObject *object)
 {
   GtkContainer *container = GTK_CONTAINER (object);
-  
+
   if (GTK_CONTAINER_RESIZE_PENDING (container))
     _gtk_container_dequeue_resize_handler (container);
 
@@ -1011,11 +1018,10 @@ gtk_container_destroy (GtkObject *object)
    */
   if (container->has_focus_chain)
     gtk_container_unset_focus_chain (container);
-  
+
   gtk_container_foreach (container, (GtkCallback) gtk_widget_destroy, NULL);
-  
-  if (GTK_OBJECT_CLASS (parent_class)->destroy)
-    (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+
+  GTK_OBJECT_CLASS (parent_class)->destroy (object);
 }
 
 static void
@@ -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,15 +1539,45 @@ gtk_container_foreach_full (GtkContainer       *container,
     notify (callback_data);
 }
 
+/**
+ * gtk_container_set_focus_child:
+ * @container: a #GtkContainer
+ * @child: a #GtkWidget, or %NULL
+ *
+ * Sets, or unsets if @child 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)
+                              GtkWidget    *child)
 {
   g_return_if_fail (GTK_IS_CONTAINER (container));
-  if (widget)
-    g_return_if_fail (GTK_IS_WIDGET (widget));
+  if (child)
+    g_return_if_fail (GTK_IS_WIDGET (child));
+
+  g_signal_emit (container, container_signals[SET_FOCUS_CHILD], 0, child);
+}
+
+/**
+ * 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);
 
-  g_signal_emit (container, container_signals[SET_FOCUS_CHILD], 0, widget);
+  return container->focus_child;
 }
 
 /**
@@ -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