Add static typing for utils.EncodingMenu
This commit is contained in:
parent
94aa293f1a
commit
92da1244fb
|
@ -55,7 +55,7 @@ class MessageDialog(Gtk.MessageDialog):
|
||||||
|
|
||||||
# widget to help pick an encoding
|
# widget to help pick an encoding
|
||||||
class EncodingMenu(Gtk.Box):
|
class EncodingMenu(Gtk.Box):
|
||||||
def __init__(self, prefs, autodetect=False):
|
def __init__(self, prefs: Preferences, autodetect: bool = False) -> None:
|
||||||
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
|
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
|
||||||
self.combobox = combobox = Gtk.ComboBoxText.new()
|
self.combobox = combobox = Gtk.ComboBoxText.new()
|
||||||
self.encodings = prefs.getEncodings()[:]
|
self.encodings = prefs.getEncodings()[:]
|
||||||
|
@ -67,12 +67,12 @@ class EncodingMenu(Gtk.Box):
|
||||||
self.pack_start(combobox, False, False, 0)
|
self.pack_start(combobox, False, False, 0)
|
||||||
combobox.show()
|
combobox.show()
|
||||||
|
|
||||||
def set_text(self, encoding):
|
def set_text(self, encoding: Optional[str]) -> None:
|
||||||
encoding = norm_encoding(encoding)
|
encoding = norm_encoding(encoding)
|
||||||
if encoding in self.encodings:
|
if encoding in self.encodings:
|
||||||
self.combobox.set_active(self.encodings.index(encoding))
|
self.combobox.set_active(self.encodings.index(encoding))
|
||||||
|
|
||||||
def get_text(self):
|
def get_text(self) -> Optional[str]:
|
||||||
i = self.combobox.get_active()
|
i = self.combobox.get_active()
|
||||||
return self.encodings[i] if i >= 0 else None
|
return self.encodings[i] if i >= 0 else None
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue