How to block the user from moving the GtkPaned handle?

Should I post an issue at GTK or is there a way to do it?

Hi,

What do you mean by “disable”?
making it invisible?
hiding one of the sides?
blocking the handle to prevent moves?

Can you give more context and describe what you’re trying to achieve?

1 Like

block the user from moving the handle, yes, is there a way to do it?

I wanna still to be able to set the :position property programatically.

What I’m trying to do is a responsive UI, in desktop mode, I want the user to be able to move the handle, but when the UI changes to mobile (narrow) mode, the GtkPaned will change to vertical orientation, set the :position property to 0 (which just shrinks the start child) and disable the movement of the handle.

Setting :sensitive property to false almost do the trick, but it disables everything inside the GtkPaned, which is not desirable.

Hmm… honestly, that would be much easier to just reparent the widget you want to move in a vertical GtkBox.

Something like:

  • create a vertical GtkBox
  • add the GtkPaned in the box
  • in desktop mode, add both side widgets as children of the paned
  • in mobile mode, add one side widget as child of the paned, and the other one as child of the box (i.e. sibling of the paned)
  • reparent the child widget when switching from one mode to another

If you really want to stick with the paned, maybe try connecting to the notify::position signal, and force the value back to zero when you detect an unwanted change (not tested, not sure if that works…).

1 Like