Question

I want to programmatically retrieve the value of the word wrap setting for GEdit3 from inside a Python plugin.

The GtkSettings class provides a method to set a string property, but how does one retrieve the value of a string property? I see no "getter" method.

I have also consulted pydoc gi.repository.Gtk.Settings - the methods listed there are the same as the online docs.

I am able to retrieve the property value of interest with the gsettings CLI utility. The command gsettings get org.gnome.gedit.preferences.editor wrap-mode yields the value 'word'. I was hoping not to have to use subprocess.Popen() just to retrieve this property, however.

Was it helpful?

Solution

This will work

from gi.repository import Gio
a = Gio.Settings('org.gnome.gedit.preferences.editor')
a.get_string('wrap-mode')

Since you're using automatic generated bindings, C code samples will work just fine for you, it is just about changing the syntax.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top