From 79b4e8a6e6363ecf1dc0c867f33735aed41e0f97 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Mon, 3 Apr 2006 14:32:49 +0000 Subject: [PATCH 1/1] From Murray Cumming. * 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 | 13 +++++-------- ut/hildon-widgets_tests.c | 22 +++++++++++++++++++++- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/hildon-widgets/hildon-caption.c b/hildon-widgets/hildon-caption.c index f001b01..666b6fc 100644 --- a/hildon-widgets/hildon-caption.c +++ b/hildon-widgets/hildon-caption.c @@ -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; } diff --git a/ut/hildon-widgets_tests.c b/ut/hildon-widgets_tests.c index c6ff3a2..a423dc3 100644 --- a/ut/hildon-widgets_tests.c +++ b/ut/hildon-widgets_tests.c @@ -50,6 +50,7 @@ #include #include #include +#include #include /* 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*/ }; -- 1.7.9.5