Skip to content

Setting the current working directory from a plugin

Hi ,

Thanks very much for thunarx-python. I am currently writing a set of plugins using thunarx-python and everything is great so far.

But what I can't figure out is how to set Thunar's current directory from within a plugin. For example I'd like to have a context menu entry which when clicked changes Thunar's current working directory to a specific folder.

This is what I tried:

def get_file_menu_items(window, elements):
    ...
    window.props.current_directory  # contains a ThunarFile
    window.get_property("current-directory") # same
    window.props.current_directory = "/path"  # doesn't work, needs to be a ThunarFile
    window.set_property("current-directory","/path")  # same
    ThunarFile = window.props.current_directory.__class__
    path = ThunarFile("path") # doesn't work, constructor takes no arguments
    path = ThunarFile()
    path.set_path("/path")  # doesn't exist
    window.props.current_directory = path  # crashes Thunar 

So how does one do this? 😣

Any help is much appreciated!