Re: How can i change background color of first column data




But i don't know how to change first column background just in the
data.

There are two ways. If you need to have individual colors for each row
you would define a column that you use to store your background color
in for every entry of your GtkListStore. Let's say you define a column
as COLUMN_BACKGROUND like this:

enum {
    ...
    COLUMN_BACKGROUND,
    ...
    N_COLUMNS
};

Then you could do the following:

gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter,
    ...
    COLUMN_BACKGROUND, "#ff00ff",
    -1);

GtkTreeViewColumn *first_column;
first_column = gtk_tree_view_column_new_with_attributes(
    "First Column", first_column_renderer,
    ...
    "cell-background", COLUMN_BACKGROUND,
    NULL);

The other ways is to set it directly on the cell renderer:

GtkCellRenderer* first_renderer;
first_renderer = gtk_cell_renderer_text_new();
g_object_set(first_renderer,
    ...
    "cell-background", "#ff00ff",
    NULL);

Hope that helps.

Cheers,

--Tilo


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