RE: separator and disable item in GtkTreeView



On Mon, 2003-12-29 at 16:00 +0800, Liu Neo-W4135C wrote:
> I think the properties is for all cells in the one column, not a cell in one row. So set property will apply to all cells, not just the disabled one.

You can set cell properties per-row with a custom cell-data func. The
only "gotcha" is that if you set a property once you must set it all the
time.

So, for example, in the cell-data func, you'd do:

static void cell_data_func (GtkCellLayout *cell_layout, GtkCellRenderer
*cell, GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data)
{
  if (row_is_sensitive)
    {
      fg = get_fg_color ();
      bg = get_bg_color ();
    }
  else
    {
      fg = bg = NULL;
    }

  g_object_set (cell, "foreground", fg, "background", bg, NULL);
}

Doing a subclass with a "sensitive" property would change the above to:

static void cell_data_func (GtkCellLayout *cell_layout, GtkCellRenderer
*cell, GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data)
{
  g_object_set (cell, "sensitive", row_is_sensitive, NULL);
}

And the subclass would handle the fg/bg drawing for insensitive items
(using the proper theme/GtkStyle function to draw the insensitive text/
pixbuf/whatever). This method has the added benefit of allowing the
programmer to simply bind the "sensitive" property to a column in the
model (via gtk_cell_layout_set_attributes ||
gtk_cell_layout_add_attribute).

-- 
Peace,

    Jim Cape
    http://ignore-your.tv

    "It is literally true that, like Christianity, Socialism
     has conquered the world by defeating itself."
        -- Alexander Berkman, ABC of Anarchism

Attachment: signature.asc
Description: This is a digitally signed message part



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