actor: Add set_request_mode() method

We should not require the use g_object_set()/_get() for accessing
the :request-mode property. A proper accessors pair should be
preferred.
This commit is contained in:
Emmanuele Bassi 2009-10-07 15:15:02 +01:00 committed by Emmanuele Bassi
parent 19317520b5
commit b5895335ab
3 changed files with 46 additions and 7 deletions

View File

@ -473,8 +473,6 @@ static void clutter_actor_set_natural_width_set (ClutterActor *self,
gboolean use_natural_width);
static void clutter_actor_set_natural_height_set (ClutterActor *self,
gboolean use_natural_height);
static void clutter_actor_set_request_mode (ClutterActor *self,
ClutterRequestMode mode);
static void clutter_actor_update_map_state (ClutterActor *self,
MapStateChange change);
static void clutter_actor_unrealize_not_hiding (ClutterActor *self);
@ -3297,7 +3295,7 @@ clutter_actor_class_init (ClutterActorClass *klass)
* gfloat natural_width, min_width;
* gfloat natural_height, min_height;
*
* g_object_get (G_OBJECT (child), "request-mode", &mode, NULL);
* mode = clutter_actor_get_request_mode (child);
* if (mode == CLUTTER_REQUEST_HEIGHT_FOR_WIDTH)
* {
* clutter_actor_get_preferred_width (child, -1,
@ -5184,11 +5182,28 @@ clutter_actor_set_natural_height_set (ClutterActor *self,
clutter_actor_queue_relayout (self);
}
static void
clutter_actor_set_request_mode (ClutterActor *self,
ClutterRequestMode mode)
/**
* clutter_actor_set_request_mode:
* @self: a #ClutterActor
* @mode: the request mode
*
* Sets the geometry request mode of @self.
*
* The @mode determines the order for invoking
* clutter_actor_get_preferred_width() and
* clutter_actor_get_preferred_height()
*
* Since: 1.2
*/
void
clutter_actor_set_request_mode (ClutterActor *self,
ClutterRequestMode mode)
{
ClutterActorPrivate *priv = self->priv;
ClutterActorPrivate *priv;
g_return_if_fail (CLUTTER_IS_ACTOR (self));
priv = self->priv;
if (priv->request_mode == mode)
return;
@ -5203,6 +5218,25 @@ clutter_actor_set_request_mode (ClutterActor *self,
clutter_actor_queue_relayout (self);
}
/**
* clutter_actor_get_request_mode:
* @self: a #ClutterActor
*
* Retrieves the geometry request mode of @self
*
* Return value: the request mode for the actor
*
* Since: 1.2
*/
ClutterRequestMode
clutter_actor_get_request_mode (ClutterActor *self)
{
g_return_val_if_fail (CLUTTER_IS_ACTOR (self),
CLUTTER_REQUEST_HEIGHT_FOR_WIDTH);
return self->priv->request_mode;
}
/* variant of set_width() without checks and without notification
* freeze+thaw, for internal usage only
*/

View File

@ -301,6 +301,9 @@ void clutter_actor_queue_relayout (ClutterActor
void clutter_actor_destroy (ClutterActor *self);
/* size negotiation */
void clutter_actor_set_request_mode (ClutterActor *self,
ClutterRequestMode mode);
ClutterRequestMode clutter_actor_get_request_mode (ClutterActor *self);
void clutter_actor_get_preferred_width (ClutterActor *self,
gfloat for_height,
gfloat *min_width_p,

View File

@ -305,6 +305,8 @@ clutter_actor_get_preferred_width
clutter_actor_get_preferred_height
clutter_actor_set_fixed_position_set
clutter_actor_get_fixed_position_set
clutter_actor_set_request_mode
clutter_actor_get_request_mode
<SUBSECTION>
clutter_actor_set_geometry