button: rename "toggle-mode" to "is-toggle"

Rename the "toggle-mode" property so it is more clear that it is a boolean
property to control whether the button can be toggled.
This commit is contained in:
Thomas Wood 2010-03-19 14:35:05 +00:00
parent f83f12cebb
commit 1beb192d95
5 changed files with 40 additions and 16 deletions

View File

@ -59,7 +59,7 @@ enum
PROP_0,
PROP_LABEL,
PROP_TOGGLE_MODE,
PROP_IS_TOGGLE,
PROP_TOGGLED
};
@ -438,8 +438,8 @@ mx_button_set_property (GObject *gobject,
case PROP_LABEL:
mx_button_set_label (button, g_value_get_string (value));
break;
case PROP_TOGGLE_MODE:
mx_button_set_toggle_mode (button, g_value_get_boolean (value));
case PROP_IS_TOGGLE:
mx_button_set_is_toggle (button, g_value_get_boolean (value));
break;
case PROP_TOGGLED:
mx_button_set_toggled (button, g_value_get_boolean (value));
@ -464,7 +464,7 @@ mx_button_get_property (GObject *gobject,
case PROP_LABEL:
g_value_set_string (value, priv->text);
break;
case PROP_TOGGLE_MODE:
case PROP_IS_TOGGLE:
g_value_set_boolean (value, priv->is_toggle);
break;
case PROP_TOGGLED:
@ -658,11 +658,11 @@ mx_button_class_init (MxButtonClass *klass)
NULL, MX_PARAM_READWRITE);
g_object_class_install_property (gobject_class, PROP_LABEL, pspec);
pspec = g_param_spec_boolean ("toggle-mode",
"Toggle Mode",
pspec = g_param_spec_boolean ("is-toggle",
"Is Toggle",
"Enable or disable toggling",
FALSE, MX_PARAM_READWRITE);
g_object_class_install_property (gobject_class, PROP_TOGGLE_MODE, pspec);
g_object_class_install_property (gobject_class, PROP_IS_TOGGLE, pspec);
pspec = g_param_spec_boolean ("toggled",
"Toggled",
@ -788,15 +788,24 @@ mx_button_set_label (MxButton *button,
}
/**
* mx_button_get_toggle_mode:
* mx_button_get_is_toggle:
* @button: a #MxButton
*
* Get the toggle mode status of the button.
*
* Returns: #TRUE if toggle mode is set, otherwise #FALSE
*/
#ifndef MX_DISABLE_DEPRECATED
gboolean
mx_button_get_toggle_mode (MxButton *button)
{
g_warning ("mx_button_get_toggle_mode is deprecated."
" Use mx_button_get_is_toggle instead.");
return mx_button_get_is_toggle (button);
}
#endif
gboolean
mx_button_get_is_toggle (MxButton *button)
{
g_return_val_if_fail (MX_IS_BUTTON (button), FALSE);
@ -804,22 +813,32 @@ mx_button_get_toggle_mode (MxButton *button)
}
/**
* mx_button_set_toggle_mode:
* mx_button_set_is_toggle:
* @button: a #Mxbutton
* @toggle: #TRUE or #FALSE
*
* Enables or disables toggle mode for the button. In toggle mode, the active
* state will be "toggled" when the user clicks the button.
*/
#ifndef MX_DISABLE_DEPRECATED
void
mx_button_set_toggle_mode (MxButton *button,
gboolean toggle)
{
g_warning ("mx_button_set_toggle_mode is deprecated."
" Use mx_button_set_is_toggle instead.");
mx_button_set_is_toggle (button, toggle);
}
#endif
void
mx_button_set_is_toggle (MxButton *button,
gboolean toggle)
{
g_return_if_fail (MX_IS_BUTTON (button));
button->priv->is_toggle = toggle;
g_object_notify (G_OBJECT (button), "toggle-mode");
g_object_notify (G_OBJECT (button), "is-toggle");
}
/**

View File

@ -82,9 +82,14 @@ ClutterActor *mx_button_new_with_label (const gchar *text);
G_CONST_RETURN gchar *mx_button_get_label (MxButton *button);
void mx_button_set_label (MxButton *button,
const gchar *text);
void mx_button_set_toggle_mode (MxButton *button,
#ifndef MX_DISABLE_DEPRECATED
G_GNUC_DEPRECATED void mx_button_set_toggle_mode (MxButton *button,
gboolean toggle);
G_GNUC_DEPRECATED gboolean mx_button_get_toggle_mode (MxButton *button);
#endif
void mx_button_set_is_toggle (MxButton *button,
gboolean toggle);
gboolean mx_button_get_toggle_mode (MxButton *button);
gboolean mx_button_get_is_toggle (MxButton *button);
void mx_button_set_toggled (MxButton *button,
gboolean toggled);
gboolean mx_button_get_toggled (MxButton *button);

View File

@ -34,7 +34,7 @@ _add_button_clicked_cb (MxButton *add_button,
button = mx_button_new_with_label (button_str);
g_free (button_str);
g_list_free (children);
mx_button_set_toggle_mode ((MxButton *) button, TRUE);
mx_button_set_is_toggle ((MxButton *) button, TRUE);
clutter_container_add_actor (CLUTTER_CONTAINER (button_box),
button);
mx_button_group_add (button_group, (MxButton *) button);
@ -105,7 +105,7 @@ button_group_main (ClutterContainer *stage)
clutter_container_add_actor (CLUTTER_CONTAINER (control_box), button);
button = mx_button_new_with_label ("Allow no active");
mx_button_set_toggle_mode ((MxButton *) button, TRUE);
mx_button_set_is_toggle ((MxButton *) button, TRUE);
g_signal_connect (button, "notify::toggled",
(GCallback) _no_active_toggled_cb, NULL);
mx_button_set_toggled ((MxButton *)button,

View File

@ -53,7 +53,7 @@ buttons_main (ClutterContainer *stage)
"toggle");
g_signal_connect (button, "long-press", G_CALLBACK (button_long_press_cb),
NULL);
mx_button_set_toggle_mode (MX_BUTTON (button), TRUE);
mx_button_set_is_toggle (MX_BUTTON (button), TRUE);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), button);
clutter_actor_set_position (button, 100, 100);
}

View File

@ -116,7 +116,7 @@ add_tab (ClutterContainer *box,
ClutterActor *button;
button = mx_button_new_with_label (name);
mx_button_set_toggle_mode (MX_BUTTON (button), TRUE);
mx_button_set_is_toggle (MX_BUTTON (button), TRUE);
clutter_container_add_actor (box, button);
mx_button_group_add (group, MX_BUTTON (button));