Re: Moving to GtkBox (Re: Minutes of the GTK+ Team Meeting - 2008-09-23)
- From: Peter Clifton <pcjc2 cam ac uk>
- To: Tim Janik <timj imendio com>
- Cc: Michael Natterer <mitch gimp org>, Gtk+ Developers <gtk-devel-list gnome org>, Alexander Larsson <alexl redhat com>, Morten Welinder <mortenw gnome org>
- Subject: Re: Moving to GtkBox (Re: Minutes of the GTK+ Team Meeting - 2008-09-23)
- Date: Fri, 26 Sep 2008 11:48:37 +0100
On Fri, 2008-09-26 at 11:44 +0200, Tim Janik wrote:
> On Thu, 25 Sep 2008, Mike Kestner wrote:
[snip]
> - Change the packing defaults for gtk_box_pack_start_defaults and friends
> unless old compat types are detected, i.e.:
> void
> gtk_box_pack_start_defaults (GtkBox *box, GtkWidget *child)
> {
> gboolean compat_type =
> g_type_is_named (G_OBJECT_TYPE (box), "GtkHBox") ||
> g_type_is_named (G_OBJECT_TYPE (box), "GtkVBox");
> gboolean expand = compat_type ? TRUE : FALSE;
> gboolean fill = compat_type ? TRUE : FALSE;
> gtk_box_pack_start (box, child, expand, fill, 0);
> }
> I've used a new helper function g_type_is_named() here, since adding
> that might be helpful in a couple other compat cases as well. It roughly
> amounts to g_type_is_a (type, g_type_from_name (type_name)); and doesn't
> require the checked for type to actually be registered.
>
> - Change additional defaults as needed, e.g.:
> gtk_box_init (GtkBox *self)
> {
> gboolean compat_type =
> g_type_is_named (G_OBJECT_TYPE (box), "GtkHBox") ||
> g_type_is_named (G_OBJECT_TYPE (box), "GtkVBox");
> if (!compat_type)
> gtk_widget_show (self); // GtkBox defaults to ::visible=TRUE
> }
Why not store the defaults as class struct memebers. GtkBox can
initialise the class members to the new defaults, then the shallow
compat subclasses can override them.
This avoids the string compare for each operation where multiple
defaults exist. (I assume from the is necessary with the type lookup).
It also avoids leaving any trace of the names GtkHBox / GtkVBox in GTK.
It seems kindof silly remove the TINY API for using these old classes,
but have to retain lots of:
if (detect_old_class_names) {
foo;
else
bar;
Since the legacy is still there! Plus the code would presumably run much
faster if you could just do GTK_IS_HBOX() rather than look up the name
by string.
--
Peter Clifton
Electrical Engineering Division,
Engineering Department,
University of Cambridge,
9, JJ Thomson Avenue,
Cambridge
CB3 0FA
Tel: +44 (0)7729 980173 - (No signal in the lab!)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]