* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
-#include <config.h>
+#include "config.h"
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
/* 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);
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),
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));
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)
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;
}
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
return;
gtk_container_buildable_set_child_property (parser_data->container,
+ parser_data->builder,
parser_data->child,
parser_data->child_prop_name,
text);
* @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.
**/
* @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.
**/
gtk_container_destroy (GtkObject *object)
{
GtkContainer *container = GTK_CONTAINER (object);
-
+
if (GTK_CONTAINER_RESIZE_PENDING (container))
_gtk_container_dequeue_resize_handler (container);
*/
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
* #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,
{
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)));
GtkCallback callback,
GtkCallbackMarshal marshal,
gpointer callback_data,
- GtkDestroyNotify notify)
+ GDestroyNotify notify)
{
g_return_if_fail (GTK_IS_CONTAINER (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;
}
/**
{
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;
*
* 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