How to disable row and change it color in treeview - liststore?

Hi,
I’m working on Rust and GTK 3 alternative to Fslint(Python 2 and GTK 2), but I now stuck on changing background color and disabling rows in ListStore

This is how it looks in FSlint, rows 2 x 28 etc. are disabled(not selectable) and have changed background color.

I saw that in fslint, row was taken by something like clist.get_data("row_data")

My code(written in Rust)

2 Likes

You mean you want to change the color of selected row ?

1 Like

No,
I want to have 2 types of rows:

  • headers - which are not selectable and have e.g. black background colour (2 x 24 … 4096 - on image above)
  • results - which are selectable and have different color than headers(output … /home/rafal/Projekty - on image above)
    For now my version looks that:

As you can see column with32 x 1071 is selectable, but I don’t want to this.

You can use set_select_function on Gtk.TreeSelection to set a callback that will decide whether a row is selectable.

You can change the colors of a cell by adding an attribute for your cell renderer and changing the cell-background and cell-background-set properties (documentation).

(I don’t remember if it’s those properties, or the background-* ones from Gtk.CellRendererText, but I hope you can find the correct ones from there :slight_smile:)

4 Likes

With your help I implemented colors of different rows(this actually can be also used to color columns or just single cells) here - https://github.com/qarmin/czkawka/commit/4b96634305d5d1e4f7317df60651bc0dd35a3367

But still I don’t know how to disable selection of rows, since in Rust this function have different definition - std::option::Option<std::boxed::Box<(dyn for<'r, 's, 't0> std::ops::Fn(&'r gtk::TreeSelection, &'s gtk::TreeModel, &'t0 gtk::TreePath, bool) -> bool + 'static)>>

Is there any easier method to disable selection?
Why GTK is so hard and not intuitive?
I created some time ago simple UI in Godot and writing logic was a lot of easier(probably also because it use C++)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.