Re: Undeprecate GtkAlignment ?
- Date: Tue, 2 Jun 2015 15:45:44 +0100
- From: Emmanuele Bassi <ebassi@xxxxxxxxx>
- Subject: Re: Undeprecate GtkAlignment ?
On 2 June 2015 at 14:34, Pierre Wieser <pwieser@xxxxxxxxxxxx> wrote:
>> you probably wanted to use gtk-devel-list, not gtk-list.
> So forwarding to gtk-devel-list. Sorry.
>> As per usual: the widget may be deprecated, but it won't be removed
>> until GTK+ 4.0 is released — and, obviously, even then GTK+ 3.x will
>> keep the existing ABI.
> I was not afraid to suddenly lose the ABI. The existance of an end date
> is enough for me to worry about.
There is no "end date": systems are still shipping GTK+ 2.24, a
whopping 4 and half years after its release, and we're still doing
2.24 releases as well. Once GTK+ 4.0 gets released, we'll still do
GTK+ 3.x releases, and distributions will still ship it for a while.
>> > Rightly or not, I do a heavy use of GtkAlignment as it provides in
>> > Glade some sort of transparent container, where I am able to later
>> > add any widget from the code.
>> You can use any container for that; GtkFrame is probably the preferred
>> placeholder container, these days.
> You're right. I may have forgotten it as Glade uses to insert a pre-configured
> GtkFrame with a GtkLabel and a GtkAklignement.. But I have to try this..
It shouldn't be doing that any more.
>> Except you'd be using the generic API, instead of the
>> GtkAlignment-specific implementation of those very same properties;
>> you'd also miss things like baseline alignment and automatic
>> propagation of the expansion flags.
> I was not conscious there was a "generic API" and a "specific implementation".
> I do just make use of Gtk+3 API.
The "generic API" is inside GtkWidget; GtkAlignment cannot use that
because it implements its own, floating-point based alignment instead
of using the GtkAlign enumeration. That's one of the inconsistencies
that led to the deprecation of GtkAlignment — on top of the obvious
duplication of functionality.
>> Since you're creating a widget programmatically, you should set the
>> expansion, alignment, and margin flags alongside the other widget
>> properties, where they belong, instead of setting them on the
>> container. Alternatively, and preferably, you could use GtkBuilder
>> templates and custom classes to avoid repeating the same code.
> OK I was not clear enough. I do not use to create widgets from code. I just
> put together pieces of windows. In another application , I have built
> with Glade a library of widget sets, and I programatically put them
> together in dynamic windows, so that the window which is displayed to
> the user is exactly setup according to the current context of the application.
That's what I mean by "programmatically".
>> My strong suggestion is to start looking at widget templates and
>> GtkBuilder; they are a far easier and better way to create widgets
>> with pre-set packing properties than using an additional container.
> I've already took a glance at widget templates, and though I may use them
> in the future, I'm not convinced they answer to this particular problem.
> But, yes, as you suggest above, GtkFrame may be a piste...
Using templates allows you to define a GtkBuilder definition of a
widget and set its properties/signal handlers based on a type. This
allows you to set up the widgets the way you want them, and then
simply instantiate them ready to be used. This includes setting the
alignment and expansion flags inside the XML description (either by
hand or via Glade), instead of doing that from code.
[@] ebassi [@gmail.com]
gtk-devel-list mailing list