2929gi .require_version ("Gtk" , "3.0" )
3030from gi .repository import Gtk , GdkPixbuf
3131
32- from typing import Optional , Callable , Dict , Any , Union , List
32+ from typing import Callable , Any
3333
3434from .gtk_utils import load_icon , is_theme_light
3535
3838t = gettext .translation ("desktop-linux-manager" , fallback = True )
3939_ = t .gettext
4040
41- NONE_CATEGORY = {"None" : _ ("(none)" )}
41+ NONE_CATEGORY : dict [ Any | str | None , str ] = {"None" : _ ("(none)" )}
4242
4343
4444class TokenName (Gtk .Box ):
@@ -50,12 +50,12 @@ def __init__(
5050 self ,
5151 token_name : str ,
5252 qapp : qubesadmin .Qubes ,
53- categories : Optional [ Dict [ str , str ]] = None ,
53+ categories : dict [ Any | str | None , str ] | None = None ,
5454 ):
5555 """
5656 :param token_name: string for of the token
5757 :param qapp: Qubes object
58- :param categories: dict of human-readable names for token strings
58+ :param categories: dict of human-readable names for tokens
5959 """
6060 super ().__init__ (orientation = Gtk .Orientation .HORIZONTAL )
6161 self .qapp = qapp
@@ -88,7 +88,7 @@ class QubeName(Gtk.Box):
8888 bolded.
8989 """
9090
91- def __init__ (self , vm : Optional [ qubesadmin .vm .QubesVM ] ):
91+ def __init__ (self , vm : qubesadmin .vm .QubesVM | None ):
9292 """
9393 :param vm: Qubes VM to be represented.
9494 """
@@ -151,8 +151,8 @@ class TextModeler(TraitSelector):
151151 def __init__ (
152152 self ,
153153 combobox : Gtk .ComboBoxText ,
154- values : Dict [str , Any ],
155- selected_value : Optional [ Any ] = None ,
154+ values : dict [str , Any ],
155+ selected_value : Any = None ,
156156 style_changes : bool = False ,
157157 ):
158158 """
@@ -166,7 +166,7 @@ def __init__(
166166 applied when combobox value is different from initial value.
167167 """
168168 self ._combo : Gtk .ComboBoxText = combobox
169- self ._values : Dict [str , Any ] = values
169+ self ._values : dict [str , Any ] = values
170170
171171 if selected_value and selected_value not in self ._values .values ():
172172 self ._values [selected_value ] = selected_value
@@ -228,12 +228,12 @@ def __init__(
228228 self ,
229229 combobox : Gtk .ComboBox ,
230230 qapp : qubesadmin .Qubes ,
231- filter_function : Optional [ Callable [[qubesadmin .vm .QubesVM ], bool ]] = None ,
232- event_callback : Optional [ Callable [[], None ]] = None ,
233- default_value : Optional [ Union [ qubesadmin .vm .QubesVM , str ]] = None ,
234- current_value : Optional [ Union [ qubesadmin .vm .QubesVM , str ]] = None ,
231+ filter_function : Callable [[qubesadmin .vm .QubesVM ], bool ] | None = None ,
232+ event_callback : Callable [[], None ] | None = None ,
233+ default_value : qubesadmin .vm .QubesVM | str | None = None ,
234+ current_value : qubesadmin .vm .QubesVM | str | None = None ,
235235 style_changes : bool = False ,
236- additional_options : Optional [ Dict [ str , str ]] = None ,
236+ additional_options : dict [ qubesadmin . vm . QubesVM | str | None , str ] | None = None ,
237237 ):
238238 """
239239 :param combobox: target ComboBox object
@@ -253,17 +253,17 @@ def __init__(
253253 :param style_changes: if True, combo-changed style class will be
254254 applied when combobox value changes
255255 :param additional_options: Dictionary of token: readable name of
256- addiitonal options to be added to the combobox
256+ additonal options to be added to the combobox
257257 """
258258 self .qapp = qapp
259259 self .combo = combobox
260260 self .entry_box = self .combo .get_child ()
261261 self .change_function = event_callback
262262 self .style_changes = style_changes
263263
264- self ._entries : Dict [str , Dict [str , Any ]] = {}
264+ self ._entries : dict [str , dict [str , Any ]] = {}
265265
266- self ._icons : Dict [str , Gtk .Image ] = {}
266+ self ._icons : dict [str , Gtk .Image ] = {}
267267 self ._icon_size = 20
268268
269269 self ._create_entries (
@@ -321,10 +321,10 @@ def _get_icon(self, name):
321321
322322 def _create_entries (
323323 self ,
324- filter_function : Optional [ Callable [[qubesadmin .vm .QubesVM ], bool ]] ,
325- default_value : Optional [ Union [ qubesadmin .vm .QubesVM , str ]] ,
326- additional_options : Optional [ Dict [ str , str ]] = None ,
327- current_value : Optional [ str ] = None ,
324+ filter_function : Callable [[qubesadmin .vm .QubesVM ], bool ] | None ,
325+ default_value : qubesadmin .vm .QubesVM | str | None ,
326+ additional_options : dict [ qubesadmin . vm . QubesVM | str | None , str ] | None = None ,
327+ current_value : str | None = None ,
328328 ):
329329
330330 if additional_options :
@@ -458,7 +458,7 @@ def _event_callback(self, *_args):
458458 def __str__ (self ):
459459 return self .entry_box .get_text ()
460460
461- def get_selected (self ) -> Optional [ qubesadmin .vm .QubesVM ] :
461+ def get_selected (self ) -> qubesadmin .vm .QubesVM | None :
462462 """
463463 Get currently selected VM, if any
464464 :return: QubesVM object
@@ -498,9 +498,9 @@ class ImageListModeler(TraitSelector):
498498 def __init__ (
499499 self ,
500500 combobox : Gtk .ComboBox ,
501- value_list : Dict [str , Dict [str , Any ]],
502- event_callback : Optional [ Callable [[], None ]] = None ,
503- selected_value : Optional [ str ] = None ,
501+ value_list : dict [str , dict [str , Any ]],
502+ event_callback : Callable [[], None ] | None = None ,
503+ selected_value : str | None = None ,
504504 style_changes : bool = False ,
505505 ):
506506 """
@@ -522,7 +522,7 @@ def __init__(
522522
523523 self .icon_size = 20
524524
525- self ._entries : Dict [str , Dict [str , Any ]] = value_list
525+ self ._entries : dict [str , dict [str , Any ]] = value_list
526526
527527 for entry in self ._entries .values ():
528528 entry ["loaded_icon" ] = load_icon (
@@ -609,7 +609,7 @@ def _event_callback(self, *_args):
609609 def __str__ (self ):
610610 return self .entry_box .get_text ()
611611
612- def get_selected (self ) -> Optional [ Any ] :
612+ def get_selected (self ) -> Any :
613613 """
614614 Get currently selected object, if any
615615 :return: any object
@@ -633,9 +633,9 @@ class ImageTextButton(Gtk.Button):
633633 def __init__ (
634634 self ,
635635 icon_name : str ,
636- label : Optional [ str ] ,
637- click_function : Optional [ Callable [[Any ], Any ]] = None ,
638- style_classes : Optional [ List [ str ]] = None ,
636+ label : str | None ,
637+ click_function : Callable [[Any ], Any ] | None = None ,
638+ style_classes : list [ str ] | None = None ,
639639 ):
640640 super ().__init__ ()
641641 self .box = Gtk .Box (orientation = Gtk .Orientation .HORIZONTAL )
@@ -707,10 +707,10 @@ def __init__(
707707 event_button : Gtk .Button ,
708708 data_container : Gtk .Container ,
709709 icon : Gtk .Image ,
710- label : Optional [ Gtk .Label ] = None ,
711- text_shown : Optional [ str ] = None ,
712- text_hidden : Optional [ str ] = None ,
713- event_callback : Optional [ Callable [[bool ], None ]] = None ,
710+ label : Gtk .Label | None = None ,
711+ text_shown : str | None = None ,
712+ text_hidden : str | None = None ,
713+ event_callback : Callable [[bool ], None ] | None = None ,
714714 ):
715715 """
716716 :param event_button: Gtk.Button that collects the click event
@@ -773,7 +773,7 @@ class ViewportHandler:
773773 def __init__ (
774774 self ,
775775 main_window : Gtk .Window ,
776- scrolled_windows : List [Gtk .ScrolledWindow ],
776+ scrolled_windows : list [Gtk .ScrolledWindow ],
777777 ):
778778 self .scrolled_windows = scrolled_windows
779779 self .main_window = main_window
0 commit comments