label: add mx_label_new_with_text and remove parameter from mx_label_new

Remove the text parameter from mx_label_new as it is not a construct
property. Add mx_label_new_with_text() to provide the convenience
functionality.
This commit is contained in:
Thomas Wood 2010-03-16 18:20:03 +00:00
parent b31ae35aef
commit 7fc4f68bc9
7 changed files with 29 additions and 15 deletions

View File

@ -336,6 +336,19 @@ mx_label_init (MxLabel *label)
/**
* mx_label_new:
*
* Create a new #MxLabel
*
* Returns: a new #MxLabel
*/
ClutterActor *
mx_label_new (void)
{
return g_object_new (MX_TYPE_LABEL, NULL);
}
/**
* mx_label_new_with_text:
* @text: text to set the label to
*
* Create a new #MxLabel with the specified label
@ -343,7 +356,7 @@ mx_label_init (MxLabel *label)
* Returns: a new #MxLabel
*/
ClutterActor *
mx_label_new (const gchar *text)
mx_label_new_with_text (const gchar *text)
{
if (text == NULL || *text == '\0')
return g_object_new (MX_TYPE_LABEL, NULL);

View File

@ -65,7 +65,8 @@ struct _MxLabelClass
GType mx_label_get_type (void) G_GNUC_CONST;
ClutterActor *mx_label_new (const gchar *text);
ClutterActor *mx_label_new (void);
ClutterActor *mx_label_new_with_text (const gchar *text);
G_CONST_RETURN gchar *mx_label_get_text (MxLabel *label);
void mx_label_set_text (MxLabel *label,
const gchar *text);

View File

@ -597,7 +597,7 @@ mx_popup_add_action (MxPopup *popup,
}
}
label = mx_label_new (mx_action_get_display_name (action));
label = mx_label_new_with_text (mx_action_get_display_name (action));
clutter_container_add_actor (CLUTTER_CONTAINER (child.button),
label);

View File

@ -119,9 +119,9 @@ main (int argc, char *argv[])
"col-span", 3,
NULL);
label = mx_label_new ("Period");
label = mx_label_new_with_text ("Period");
slider = mx_slider_new ();
properties_info[0].value_label = mx_label_new ("0.0");
properties_info[0].value_label = mx_label_new_with_text ("0.0");
clutter_actor_set_width (slider, 200);
g_signal_connect (slider, "notify::progress",
G_CALLBACK (on_progress_changed), &properties_info[0]);
@ -153,9 +153,9 @@ main (int argc, char *argv[])
"x-fill", FALSE,
NULL);
label = mx_label_new ("Angle");
label = mx_label_new_with_text ("Angle");
slider = mx_slider_new ();
properties_info[1].value_label = mx_label_new ("0.00");
properties_info[1].value_label = mx_label_new_with_text ("0.00");
clutter_actor_set_width (slider, 200);
g_signal_connect (slider, "notify::progress",
G_CALLBACK (on_progress_changed), &properties_info[1]);
@ -188,9 +188,9 @@ main (int argc, char *argv[])
"x-fill", FALSE,
NULL);
label = mx_label_new ("Radius");
label = mx_label_new_with_text ("Radius");
slider = mx_slider_new ();
properties_info[2].value_label = mx_label_new ("24.00");
properties_info[2].value_label = mx_label_new_with_text ("24.00");
clutter_actor_set_width (slider, 200);
mx_slider_set_progress (MX_SLIDER (slider), 0.24);
g_signal_connect (slider, "notify::progress",

View File

@ -36,7 +36,7 @@ label_main (ClutterContainer *stage)
g_warning ("%s", err->message);
}
label = mx_label_new ("Hello World!");
label = mx_label_new_with_text ("Hello World!");
clutter_actor_set_position (label, 50, 50);
mx_stylable_set_style (MX_STYLABLE (label), style);

View File

@ -43,10 +43,10 @@ main (int argc,
clutter_actor_set_width (table, 300);
clutter_container_add (CLUTTER_CONTAINER (stage), table, NULL);
label = mx_label_new ("Short top text");
label = mx_label_new_with_text ("Short top text");
mx_table_add_actor (MX_TABLE (table), label, 0, 0);
label2 = mx_label_new ("");
label2 = mx_label_new_with_text ("");
txt = mx_label_get_clutter_text(MX_LABEL(label2));
clutter_text_set_ellipsize (CLUTTER_TEXT (txt), PANGO_ELLIPSIZE_NONE);
@ -61,7 +61,7 @@ main (int argc,
"x-expand", FALSE,
NULL);
label = mx_label_new ("Short Bottom text");
label = mx_label_new_with_text ("Short Bottom text");
mx_table_add_actor (MX_TABLE (table), label, 2, 0);
mx_label_set_text (MX_LABEL (label2), "Really really long long long long long long long long long long long long long long long long long long (ooooh this is verrrrrrry long!) long longlong long long longlong long long long \nlong longlong long long long longlonglonglonglonglonglonglonglonglonglonglonglong long long long long long long long long long Loooooooooooooooong text");

View File

@ -54,7 +54,7 @@ main (int argc, char **argv)
clutter_container_add_actor (CLUTTER_CONTAINER (stage), table);
toggle = mx_toggle_new ();
label = mx_label_new ("Toggle small-screen mode");
label = mx_label_new_with_text ("Toggle small-screen mode");
g_signal_connect (toggle, "notify::active",
G_CALLBACK (small_screen_cb), stage);
mx_table_add_actor_with_properties (MX_TABLE (table),
@ -74,7 +74,7 @@ main (int argc, char **argv)
NULL);
toggle = mx_toggle_new ();
label = mx_label_new ("Toggle full-screen mode");
label = mx_label_new_with_text ("Toggle full-screen mode");
g_signal_connect (toggle, "notify::active",
G_CALLBACK (fullscreen_cb), stage);
mx_table_add_actor_with_properties (MX_TABLE (table),