From Murray Cumming.
authorMarius Vollmer <marius.vollmer@nokia.com>
Mon, 3 Apr 2006 14:32:49 +0000 (14:32 +0000)
committerMarius Vollmer <marius.vollmer@nokia.com>
Mon, 3 Apr 2006 14:32:49 +0000 (14:32 +0000)
* hildon-lgpl/hildon-caption.c:
(hildon_caption_init): Do the hildon_caption_set_child_expand()
here.
(hildon_caption_new): Use the child property from GtkContainer
instead of calling gtk_container_add(), because _new() functions
should just use g_object_new(), so that language-bindings can do
the same.

* ut/hildon-widgets_tests.c: Added test42 for hildon_caption_new.

hildon-widgets/hildon-caption.c
ut/hildon-widgets_tests.c

index f001b01..666b6fc 100644 (file)
@@ -586,6 +586,8 @@ static void hildon_caption_init( HildonCaption *caption )
 
   gtk_widget_pop_composite_child();
 
+  hildon_caption_set_child_expand( caption, TRUE );
+
   gtk_widget_show_all( priv->caption_area );
 }
 
@@ -803,21 +805,16 @@ GtkSizeGroup *hildon_caption_get_sizegroup( const HildonCaption *self )
  * @Returns : a #GtkWidget pointer of Caption
  */
 GtkWidget *hildon_caption_new( GtkSizeGroup *group, const gchar *value,
-                               GtkWidget *control, GtkWidget *icon,
+                               GtkWidget *child, GtkWidget *icon,
                                HildonCaptionStatus flag)
 {
   GtkWidget *widget;
-  g_return_val_if_fail( GTK_IS_WIDGET(control), NULL );
+  g_return_val_if_fail( GTK_IS_WIDGET(child), NULL );
   
   widget = g_object_new( HILDON_TYPE_CAPTION, "label", value,
-                       "size_group", group, "icon", icon, "status", flag,
+                       "child" /* From GtkContainer */, child, "size_group", group, "icon", icon, "status", flag,
                         NULL );
 
-  /* Pack the captioned widget */
-  hildon_caption_set_child_expand( HILDON_CAPTION(widget), TRUE );
-  gtk_container_add( GTK_CONTAINER(widget), control );
-
-
   return widget;
 }
 
index c6ff3a2..a423dc3 100644 (file)
@@ -50,6 +50,7 @@
 #include <hildon-widgets/hildon-grid.h>
 #include <hildon-widgets/hildon-time-editor.h>
 #include <hildon-widgets/hildon-name-password-dialog.h>
+#include <hildon-widgets/hildon-caption.h>
 #include <outo.h>
 
 /* Icon which must exist (HildonGridItem). */
@@ -337,6 +338,9 @@ int test39b(void);
 #ifndef HILDON_DISABLE_DEPRECATED
 int test41a(void);
 #endif
+
+int test42 (void);
+
 /* this has to be like this (not static). outo
    calls for this! */
 testcase *get_tests(void);
@@ -2913,6 +2917,20 @@ int test39b()
    return 1;
 }
 
+int test42 ()
+{
+  GtkWidget *entry, *caption;
+
+  entry = gtk_entry_new ();
+  caption = hildon_caption_new (NULL /* group */,
+                               "caption text",
+                               GTK_WIDGET(entry), NULL,
+                               HILDON_CAPTION_OPTIONAL /* flag */);
+
+  g_assert (caption);
+  return 1;
+}
+
 testcase tcases[] =
 {
     {*test1a, "hildon_controlbar_new", EXPECT_OK},
@@ -3135,7 +3153,9 @@ testcase tcases[] =
     {*test39b, "namepassword dialog get_password", EXPECT_OK},
 /*    {*test38a, "gtk_confirmation_banner (sometext)", EXPECT_OK},
     {*test38a, "gtk_confirmation_banner (NULL)", EXPECT_OK},*/
-   
+
+    { test42, "hildon_caption_new", EXPECT_OK },
+
     {0} /*REMEMBER THE TERMINATING NULL*/
 };