fix: get_text was not defined on all the widgets
* Use `get_text` when available * Use `get_font` when Gtk.FontButton * Raise TypeError exception otherwise
This commit is contained in:
parent
8d27125f08
commit
e19f1a192b
|
@ -277,7 +277,8 @@ class Preferences:
|
||||||
for k in self.int_prefs:
|
for k in self.int_prefs:
|
||||||
self.int_prefs[k] = widgets[k].get_value_as_int()
|
self.int_prefs[k] = widgets[k].get_value_as_int()
|
||||||
for k in self.string_prefs:
|
for k in self.string_prefs:
|
||||||
self.string_prefs[k] = utils.null_to_empty(widgets[k].get_text())
|
text = self._getWidgetText(widgets[k])
|
||||||
|
self.string_prefs[k] = utils.null_to_empty(text)
|
||||||
try:
|
try:
|
||||||
ss = []
|
ss = []
|
||||||
for k, bool_value in self.bool_prefs.items():
|
for k, bool_value in self.bool_prefs.items():
|
||||||
|
@ -375,6 +376,20 @@ class Preferences:
|
||||||
table.show()
|
table.show()
|
||||||
return table
|
return table
|
||||||
|
|
||||||
|
def _getWidgetText(self, widget):
|
||||||
|
text = ""
|
||||||
|
if (
|
||||||
|
isinstance(widget, Gtk.Entry) or
|
||||||
|
isinstance(widget, utils.EncodingMenu) or
|
||||||
|
isinstance(widget, _FileEntry)
|
||||||
|
):
|
||||||
|
text = widget.get_text()
|
||||||
|
elif isinstance(widget, Gtk.FontButton):
|
||||||
|
text = widget.get_font()
|
||||||
|
else:
|
||||||
|
raise TypeError(f"Don't know how to get text from type: {type(widget)}")
|
||||||
|
return text
|
||||||
|
|
||||||
# get/set methods to manipulate the preference values
|
# get/set methods to manipulate the preference values
|
||||||
def getBool(self, name: str) -> bool:
|
def getBool(self, name: str) -> bool:
|
||||||
return self.bool_prefs[name]
|
return self.bool_prefs[name]
|
||||||
|
|
Loading…
Reference in New Issue