]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkcontainer.c
Deprecate flag macros for toplevel, state, no window and composite child
[~andy/gtk] / gtk / gtkcontainer.c
index 30eb06ff2bab4bbcb79d3a9cbf3e8418b4cd6a71..4c3af7427f0a662687e24c26913684985f0fad7b 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "gtkcontainer.h"
 #include "gtkbuildable.h"
+#include "gtkbuilderprivate.h"
 #include "gtkprivate.h"
 #include "gtkmain.h"
 #include "gtkmarshalers.h"
@@ -154,7 +155,7 @@ gtk_container_get_type (void)
        NULL,       /* value_table */
       };
 
-      static const GInterfaceInfo buildable_info =
+      const GInterfaceInfo buildable_info =
       {
        (GInterfaceInitFunc) gtk_container_buildable_init,
        NULL,
@@ -311,7 +312,7 @@ gtk_container_buildable_add_child (GtkBuildable  *buildable,
     {
       GTK_BUILDER_WARN_INVALID_CHILD_TYPE (buildable, type);
     }
-  else if (GTK_IS_WIDGET (child) && GTK_WIDGET_TOPLEVEL (child) == FALSE)
+  else if (GTK_IS_WIDGET (child) && GTK_WIDGET (child)->parent == NULL)
     {
       gtk_container_add (GTK_CONTAINER (buildable), GTK_WIDGET (child));
     }
@@ -361,6 +362,8 @@ typedef struct {
   GtkContainer *container;
   GtkWidget    *child;
   gchar        *child_prop_name;
+  gchar        *context;
+  gboolean     translatable;
 } PackingPropertiesData;
 
 static void
@@ -379,6 +382,20 @@ attributes_start_element (GMarkupParseContext *context,
       for (i = 0; names[i]; i++)
        if (strcmp (names[i], "name") == 0)
          parser_data->child_prop_name = g_strdup (values[i]);
+       else if (strcmp (names[i], "translatable") == 0)
+         {
+           if (!_gtk_builder_boolean_from_string (values[1],
+                                                  &parser_data->translatable,
+                                                  error))
+             return;
+         }
+       else if (strcmp (names[i], "comments") == 0)
+         ; /* for translators */
+       else if (strcmp (names[i], "context") == 0)
+         parser_data->context = g_strdup (values[1]);
+       else
+         g_warning ("Unsupported attribute for GtkContainer Child "
+                    "property: %s\n", names[i]);
     }
   else if (strcmp (element_name, "packing") == 0)
     return;
@@ -394,18 +411,37 @@ attributes_text_element (GMarkupParseContext *context,
                         GError             **error)
 {
   PackingPropertiesData *parser_data = (PackingPropertiesData*)user_data;
+  gchar* value;
 
   if (!parser_data->child_prop_name)
     return;
+  
+  if (parser_data->translatable && text_len)
+    {
+      const gchar* domain;
+      domain = gtk_builder_get_translation_domain (parser_data->builder);
+      
+      value = _gtk_builder_parser_translate (domain,
+                                            parser_data->context,
+                                            text);
+    }
+  else
+    {
+      value = g_strdup (text);
+    }
 
   gtk_container_buildable_set_child_property (parser_data->container,
                                              parser_data->builder,
                                              parser_data->child,
                                              parser_data->child_prop_name,
-                                             text);
+                                             value);
 
   g_free (parser_data->child_prop_name);
+  g_free (parser_data->context);
+  g_free (value);
   parser_data->child_prop_name = NULL;
+  parser_data->context = NULL;
+  parser_data->translatable = FALSE;
 }
 
 static const GMarkupParser attributes_parser =
@@ -1225,7 +1261,7 @@ gtk_container_set_resize_mode (GtkContainer  *container,
   g_return_if_fail (GTK_IS_CONTAINER (container));
   g_return_if_fail (resize_mode <= GTK_RESIZE_IMMEDIATE);
   
-  if (GTK_WIDGET_TOPLEVEL (container) &&
+  if (gtk_widget_is_toplevel (GTK_WIDGET (container)) &&
       resize_mode == GTK_RESIZE_PARENT)
     {
       resize_mode = GTK_RESIZE_QUEUE;
@@ -1344,7 +1380,7 @@ _gtk_container_queue_resize (GtkContainer *container)
   if (resize_container)
     {
       if (GTK_WIDGET_VISIBLE (resize_container) &&
-         (GTK_WIDGET_TOPLEVEL (resize_container) || GTK_WIDGET_REALIZED (resize_container)))
+         (gtk_widget_is_toplevel (GTK_WIDGET (resize_container)) || GTK_WIDGET_REALIZED (resize_container)))
        {
          switch (resize_container->resize_mode)
            {
@@ -1550,7 +1586,7 @@ gtk_container_foreach_full (GtkContainer       *container,
 /**
  * gtk_container_set_focus_child:
  * @container: a #GtkContainer
- * @child: a #GtkWidget, or %NULL
+ * @child: (allow-none): a #GtkWidget, or %NULL
  *
  * Sets, or unsets if @child is %NULL, the focused child of @container.
  *
@@ -1593,9 +1629,9 @@ gtk_container_get_focus_child (GtkContainer *container)
  * @container: a #GtkContainer
  * 
  * Returns the container's non-internal children. See
- * gtk_container_forall() for details on what constitutes an "internal" child. 
+ * gtk_container_forall() for details on what constitutes an "internal" child.
  *
- * Return value: a newly-allocated list of the container's non-internal children.
+ * Return value: (element-type GtkWidget) (transfer container): a newly-allocated list of the container's non-internal children.
  **/
 GList*
 gtk_container_get_children (GtkContainer *container)
@@ -1654,11 +1690,14 @@ gchar*
 _gtk_container_child_composite_name (GtkContainer *container,
                                    GtkWidget    *child)
 {
+  gboolean composite_child;
+
   g_return_val_if_fail (GTK_IS_CONTAINER (container), NULL);
   g_return_val_if_fail (GTK_IS_WIDGET (child), NULL);
   g_return_val_if_fail (child->parent == GTK_WIDGET (container), NULL);
 
-  if (GTK_WIDGET_COMPOSITE_CHILD (child))
+  g_object_get (child, "composite-child", &composite_child, NULL);
+  if (composite_child)
     {
       static GQuark quark_composite_name = 0;
       gchar *name;
@@ -2367,7 +2406,8 @@ gtk_container_set_focus_chain (GtkContainer *container,
 /**
  * gtk_container_get_focus_chain:
  * @container:         a #GtkContainer
- * @focusable_widgets: location to store the focus chain of the
+ * @focusable_widgets: (element-type GtkWidget) (out) (transfer container): location
+ *                     to store the focus chain of the
  *                     container, or %NULL. You should free this list
  *                     using g_list_free() when you are done with it, however
  *                     no additional reference count is added to the
@@ -2477,7 +2517,7 @@ gtk_container_set_focus_vadjustment (GtkContainer  *container,
  * Retrieves the vertical focus adjustment for the container. See
  * gtk_container_set_focus_vadjustment().
  *
- * Return value: the vertical focus adjustment, or %NULL if
+ * Return value: (transfer none): the vertical focus adjustment, or %NULL if
  *   none has been set.
  **/
 GtkAdjustment *
@@ -2532,7 +2572,7 @@ gtk_container_set_focus_hadjustment (GtkContainer  *container,
  * Retrieves the horizontal focus adjustment for the container. See
  * gtk_container_set_focus_hadjustment ().
  *
- * Return value: the horizontal focus adjustment, or %NULL if
+ * Return value: (transfer none): the horizontal focus adjustment, or %NULL if
  *   none has been set.
  **/
 GtkAdjustment *