Re: Check Boxes Don't Work Independently



On Thu, Aug 30, 2007 at 10:00:55AM -0400, dhk wrote:
The attached and inline program

Please, please, send it with something that does not wrap
lines the next time, the code does not like it when it
happens in the middle of a string or //-comment.

Can someone explain why this happens and where the mouseover event is
coming from?  If you run the program you'll see what I mean.

...

  /* Redisplay the toggle with the appropriate state.
   * gtk-demo doesn't have this but it seems necessary. */
  gtk_cell_renderer_toggle_set_active(cell, toggle_item);

The Gtk+ demo is right and your are wrong here.  Please read
what I replied you the last time -- or the Gtk+ Tree View
Tutorial if my gibbernglish is too hard to understand -- to
grasp the concepts.

Your code (equivalent to g_object_set(cell, "active", TRUE, NULL);)
here says:

  I'm setting the "active" property to TRUE.  Therefore any
  time in the future, if you wish to render a cell with this
  renderer, render it as active.

And that's exactly what happens, all cells start to be
rendered as active (or inactive).

You have to either use a cell data function or bind the
model column to the "active" property.  But not

  // Why does setting attributes cause errors and seems unnecessary
anyway?
  //gtk_tree_view_column_set_attributes(column, renderer, "activatable",
TRUE, "active", FALSE, NULL);

like this.  The arguments of gtk_tree_view_column_set_attributes()
are *columns* (column numbers), not values.  Since TRUE is 1
and FALSE is 0, you bind "activatable" to the model column 1
and "active" to the model column 0.  Not what you want.

You always want the cell renderer to be activatable, so just
set

  g_object_set(renderer, "activatable", TRUE, NULL);

and you want its "active" property be controlled by the
column DISABLE so just set

  gtk_tree_view_column_add_attribute(column, renderer,
                                     "active", COL_DISABLE);

(the meaning will be `enable' not `disable' of course, if
you want the view to display the opposite of what's in the
model, you have to set a cell data function -- like for
essentially any other transform).

Yeti

--
http://gwyddion.net/



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