Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

How can I prevent the handle of a GtkPaned from being moved? For instance, I want to lock it according to the status of a GtkToggleButton.

share|improve this question

1 Answer 1

Assuming the the True state of the GtkToggleButton locks the handle of the GtkPaned, this behavior can be achieved by:

  1. connecting the GtkPaned to the button-press event
  2. returning with the GtkToggleButton state from the handler

Here is a minimalistic example in python using pygtk

import gtk

def on_paned_button_press_event(*args):
    return toggle.get_active() # This is step 2.

win = gtk.Window()
win.set_title('Lock/Unlock the GtkPaned handle example')
win.set_size_request(400, 100)

paned = gtk.HPaned()
toggle = gtk.ToggleButton('Toggle me')
toggle.set_size_request(100, -1)
paned.add1(toggle)
paned.add2(gtk.Label('Toggle the button on the left to lock/unlock the handle'))

paned.connect('button-press-event', on_paned_button_press_event) # This is step 1.

win.add(paned)

win.connect('destroy', gtk.main_quit)

win.show_all()

gtk.main()

It might still be possible to move the handle with the keyboard, so you'd want to connect to the move-handle signal as well for a complete lock.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.