From 726b0d8736a9d5ac8d7f2395f234662b204290fc Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 31 Jan 2011 17:34:37 -0500 Subject: Bandaid fix for icon view subclassing I've decided that it is isn't feasible to make cell areas runtime-settable in the time we have left before 3.0, therefore, I'm going with the approach to allow init() functions to instantiate the default cell area and issue a warning if a construct property is ignored. This is not ideal, but it keeps existing icon view and combo box subclasses working. https://bugzilla.gnome.org/show_bug.cgi?id=639139 --- gtk/gtkcelllayout.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'gtk/gtkcelllayout.c') diff --git a/gtk/gtkcelllayout.c b/gtk/gtkcelllayout.c index 7291a4b533..d0ff6caacc 100644 --- a/gtk/gtkcelllayout.c +++ b/gtk/gtkcelllayout.c @@ -83,6 +83,55 @@ * * * + * + * + * Subclassing GtkCellLayout implementations + * + * When subclassing a widget that implements #GtkCellLayout like + * #GtkIconView or #GtkComboBox, there are some considerations related + * to the fact that these widgets internally use a #GtkCellArea. + * The cell area is exposed as a construct-only property by these + * widgets. This means that it is possible to e.g. do + * + * combo = g_object_new (GTK_TYPE_COMBO_BOX, "cell-area", my_cell_area, NULL); + * + * to use a custom cell area with a combo box. But construct properties + * are only initialized after instance init() + * functions have run, which means that using functions which rely on + * the existence of the cell area in your subclass' init() function will + * cause the default cell area to be instantiated. In this case, a provided + * construct property value will be ignored (with a warning, to alert + * you to the problem). + * + * static void + * my_combo_box_init (MyComboBox *b) + * { + * GtkCellRenderer *cell; + * + * cell = gtk_cell_renderer_pixbuf_new (); + * /* The following call causes the default cell area for combo boxes, + * * a GtkCellAreaBox, to be instantiated + * */ + * gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (b), cell, FALSE); + * ... + * } + * + * GtkWidget * + * my_combo_box_new (GtkCellArea *area) + * { + * /* This call is going to cause a warning + * * about area being ignored + * */ + * return g_object_new (MY_TYPE_COMBO_BOX, "cell-area", area, NULL); + * } + * + * If supporting alternative cell areas with your derived widget is + * not important, then this does not have to concern you. If you want + * to support alternative cell areas, you can do so by moving the + * problematic calls out of init() and into a constructor() + * for your class. + * + * */ #include "config.h" -- cgit v1.2.1