[maemo-developers] GtkCellRendererToggle on Fremantle

From: Cornelius Hald hald at icandy.de
Date: Mon Oct 5 11:18:39 EEST 2009
On Mon, 2009-10-05 at 00:02 +0100, Graham Cobb wrote:
> gpe-calendar contains GtkTreeView with a list of calendars that are being 
> shown.  One column is rendered using a GtkCellRendererToggle: i.e. it shows a 
> checkbox to allow the user to control whether the calendar should be shown.
> In scratchbox this looks fine.  However, on the real device apparently the 
> checkbox is just a black square, whether it is TRUE or FALSE.  It still 
> reacts to clicks, and changes state, but the rendering doesn't change.  This 
> means, of course, that the user cannot see whether the calendar is enabled or 
> not.
> Is there any way to get this to be visible?  I realise that it is not finger 
> friendly, but that is a separate issue.  I would be quite happy for this 
> element to only be modifiable using the stylus.

Unfortunately I don't know why it's not visible at all. I had the
problem, that it was displayed but small and ugly and I wanted it to be
displayed like the check box in HildonCheckButton.
I finally found out that to make it show like that you have to give it a
certain style which then takes a different image from the theme to
render it. Maybe that helps you as well.

Have a look here:

Search for the comment /* Setup the cell renderer */

The code is this:

GtkStyle *style = gtk_rc_get_style_by_paths (gtk_widget_get_settings
"*.HildonCheckButton.GtkAlignment.GtkHBox.GtkCellView", G_TYPE_NONE);

gtk_widget_set_style(priv->cell_view, style);

/* Make sure that the check box is always shown, no matter the value of gtk-button-images */
g_signal_connect (priv->cell_view, "notify::visible", G_CALLBACK (gtk_widget_show), NULL);

gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (priv->cell_view), GTK_CELL_RENDERER (priv->toggle_renderer), TRUE);

/* Set the indicator to the right size (the size of the pixmap) */
g_object_set (priv->toggle_renderer, "indicator-size", 38, NULL);

Hope that helps somehow :)

More information about the maemo-developers mailing list