Question about Gtk programming for Linux experts.
Actually, I already asked the question on the Gtk Discourse app, but I am posting it here on the fediverse in the hope that maybe a few more people will see it. I don’t mind if you answer in Discorse or here on the fediverse.
#tech #software #Linux #LinuxProgramming #Gtk #Gtk3
So my goal was to have a read-only GtkTextView widgets in which text can be arranged with layouts like grids, flowbox, vbox, or hbox layouts. Imagine my app to be a textual dashboard where end-users can decide how to place each dashboard widget, following the principles of tiling window managers.
I did not have much luck achieving this with GtkTextViews, so I tried a different approach of adding GtkLabels to GtkGrid and GtkFlowBox widgets all with the “selectable” property enabled. So far so good. However the default behavior for GtkGrid or GtkFlowBox seems to always highlight all of the text in the first selectable GtkLabel added to whatever container I am using. I would instead like for nothing to be selected until it is explicitly selected by the end-user.
The attached image shows what the window looks like when it is first made visible and before any user interaction — the upper-left GtkLabel is highlighted. I would like for this to not happen until the end-user drags over the widget with the mouse, but I am not sure how to go about it.
A different but related question: I would also like if the user drags beyond the boundary of a GtkLabel for the selection to continue to neighboring GtkLabel widgets, sort-of like how it works in a web browser. Is there an easy way to achieve this in Gtk without writing lots of custom drag event handlers for all the the widgets I construct in the UI?