Re: Programming question



On Tue, Sep 18, 2018 at 10:49 AM rastersoft <raster rastersoft com> wrote:

Yes, but the question is: which method should I use to implement the part of the second argument? How can I 
specify that the actor being added must fill in X, but not fill neither expand in Y?

It depends. (Helpful, I know)

ClutterActor has a set of properties that containers/layout-managers
are encouraged to consider when distributing available space to
children:
x-expand/y-expand (bool) and x-align/y-align (ClutterActorAlign).

If `this.appsContainer` supports those properties, the above code can
be written as:

this.appsInnterContainer.set({
    x_align: Clutter.ActorAlign.FILL,
    y_align: Clutter.ActorAlign.CENTER,
    x_expand: false,
    y_expand: false
});
this.appsContainer.add_child(this.appsInnerContainer);

Although the align properties are only relevant if the container
distributes extra space to the child, which it won't do with the
expand properties set to false. So the whole set() call is redundant.


Then there are still containers that do not support those generic
properties. There the container defines a set of possible child
properties that influence how space is distributed. What those
properties are depends on the container in question - for example if
`this.appsContainer` is an StBin, the above code would be

this.appsContainer.add_child(this.appsInnerContainer);
this.appsContainer.child_set(this.appsInnerContainer, {
    x_fill: true,
    y_fill: false,
    x_expand: false,
    y_expand: false
});

Finally, as the above is a bit cumbersome, there is a convenience
method added by gnome-shell that combines the two methods (and is
probably what you were thinking of with your code snippet):

this.appsContainer.add(this.appsInnerContainer, {
    x_fill: true,
    y_fill: false,
    x_expand: false,
    y_expand: false
});

Cheers,
Florian


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]