Niepce July 2023 updates

This is the July 2023 update for Niepce.

The importer

Where we left, the workspace tree view didn't display the hierarchy.

First, I discovered bug in the SQL triggers for folder path update. I was missing the AFTER keyword to have it run after the update.

Workspace

Second, I need to specify a parent when adding items to the model, then locate the parent, add to it. The problem is that we get a list of folders in some order (I can order by any of the SQL columns). The problem is adding an item to a parent that is not yet int the model. There are few ways to go about it.

  1. Sort the folder list in order of a flattened tree. To be fair my SQL skills are not good enough, and I'm not even sure I can do that in sqlite. This would solve most of the problems.
  2. Sort the folder list once received. But this might not always work.
  3. Handle the case in the model: add with a placeholder parent and re-parent as needed when the parent is added.

For now I chose 3. The risk is that if the parent doesn't exist then the tree will stay lingering. It's just the view though.

Here is the result:

Workspace

Tree view cleanup

Back in November, I re-implemented the workspace tree view using gtk4::ListView. But it has some issues, due to limitations in the widget implementation, with the way the expander (the arrow to expand a sub-tree) is handled. The ListView expect to know whether it can be expanded when it is created in the factory. Either there is a model and it can be expanded, or there is no model, and it can't be. The problem is that if you don't want to have an expander because there is no children, you can't. Not with the API.

Can we hide the expander? The answer is yes. Simply in CSS set the icon source to none.

listview > row > box > treeexpander > expander {
	-gtk-icon-source: none;
}

This CSS selector grab just any expander in a list view. Now we need to do it as needed.

First give the list view a name: workspace. Then we'll programatically set a style for the row item when it doesn't have any children. We'll use nochildren, and add/remove the CSS class as needed. The bind and unbind are a good place.

listview#workspace > row > box.nochildren > treeexpander > expander {
	-gtk-icon-source: none;
}

Fixed Workspace

I suspect there might be a few update problems, likely when adding or removing items. We'll see. I will need to implement some testing at one point, but that's a topic for another day.

Also I fixed the display of item counts that didn't work with deeper levels of the tree. This was a long standing issue logic issue introduced with the move to GtkListView.

Build

Using the GNOME templates, I added CI so that we get builds and check automatically,

I also removed some no longer used C++ code.

Other

I then diverted my efforts into libopenraw trying to wrap up the Rust port by finishing the C API. I'll have a detailed post about that soon.

Thanks you for reading.