1515#
1616# SPDX-License-Identifier: GPL-3.0-or-later
1717
18- from typing import Callable , Dict , Optional , Tuple , Union
18+ from collections .abc import Callable
19+ from typing import Optional
1920from gi .repository import Gtk , Gio , Adw , Gdk , GLib
2021
2122from gradia .ui .drawing_actions import DrawingMode
@@ -77,7 +78,7 @@ def create_header_bar() -> Adw.HeaderBar:
7778 return header_bar
7879
7980
80- def create_image_stack () -> Tuple [Gtk .Stack , Gtk .Picture , Adw .Spinner , 'DrawingOverlay' ]:
81+ def create_image_stack () -> tuple [Gtk .Stack , Gtk .Picture , Adw .Spinner , 'DrawingOverlay' ]:
8182 stack = Gtk .Stack .new ()
8283 stack .set_vexpand (True )
8384 stack .set_hexpand (True )
@@ -110,7 +111,7 @@ def create_image_overlay(picture: Gtk.Picture, drawing_overlay: 'DrawingOverlay'
110111
111112 return overlay
112113
113- def create_controls_overlay () -> Gtk .Widget :
114+ def create_controls_overlay () -> Gtk .Box :
114115 undo_btn = Gtk .Button .new_from_icon_name ("edit-undo-symbolic" )
115116 undo_btn .set_tooltip_text (_ ("Undo the last action" ))
116117
@@ -156,7 +157,7 @@ def create_drawing_overlay(picture: Gtk.Picture) -> 'DrawingOverlay':
156157 drawing_overlay .set_picture_reference (picture )
157158 return drawing_overlay
158159
159- def create_spinner_widget () -> Gtk .Widget :
160+ def create_spinner_widget () -> tuple [ Gtk .Box , Adw . Spinner ] :
160161 spinner = Adw .Spinner .new ()
161162 spinner .set_size_request (48 , 48 )
162163
@@ -173,8 +174,8 @@ def create_spinner_widget() -> Gtk.Widget:
173174 spinner_box .append (spinner )
174175 return spinner_box , spinner
175176
176- def create_status_page () -> Gtk . Widget :
177- screenshot_btn = Gtk .Button .new_with_label ("_Take a screenshot…" )
177+ def create_status_page () -> Adw . StatusPage :
178+ screenshot_btn = Gtk .Button .new_with_label (_ ( "_Take a screenshot…" ) )
178179 screenshot_btn .set_use_underline (True )
179180 screenshot_btn .set_halign (Gtk .Align .CENTER )
180181
@@ -185,7 +186,7 @@ def create_status_page() -> Gtk.Widget:
185186
186187 screenshot_btn .set_action_name ("app.screenshot" )
187188
188- open_status_btn = Gtk .Button .new_with_label ("_Open Image…" )
189+ open_status_btn = Gtk .Button .new_with_label (_ ( "_Open Image…" ) )
189190 open_status_btn .set_use_underline (True )
190191 open_status_btn .set_halign (Gtk .Align .CENTER )
191192
@@ -202,8 +203,8 @@ def create_status_page() -> Gtk.Widget:
202203
203204 status_page = Adw .StatusPage .new ()
204205 status_page .set_icon_name ("image-x-generic-symbolic" )
205- status_page .set_title ("No Image Loaded" )
206- status_page .set_description ("Drag and drop one here" )
206+ status_page .set_title (_ ( "No Image Loaded" ) )
207+ status_page .set_description (_ ( "Drag and drop one here" ) )
207208 status_page .set_child (button_box )
208209
209210 return status_page
@@ -223,14 +224,12 @@ def on_file_dropped(_target: Gtk.DropTarget, value: Gio.File, _x: int, _y: int)
223224 drop_target .connect ("drop" , on_file_dropped )
224225 stack .add_controller (drop_target )
225226
226-
227-
228227def create_image_options_group (
229228 on_padding_changed : Callable [[Adw .SpinRow ], None ],
230229 on_aspect_ratio_changed : Callable [[Gtk .Entry ], None ],
231230 on_corner_radius_changed : Callable [[Adw .SpinRow ], None ],
232231 on_shadow_strength_changed : Callable [[Gtk .Scale ], None ]
233- ) -> Tuple [Adw .PreferencesGroup , Adw .SpinRow , Gtk .Entry ]:
232+ ) -> tuple [Adw .PreferencesGroup , Adw .SpinRow , Gtk .Entry ]:
234233 padding_group = Adw .PreferencesGroup (title = _ ("Image Options" ))
235234
236235 padding_adjustment = Gtk .Adjustment (value = 5 , lower = - 25 , upper = 75 , step_increment = 5 , page_increment = 5 )
@@ -267,12 +266,12 @@ def create_image_options_group(
267266
268267 return padding_group , padding_row , aspect_ratio_entry
269268
270- def create_file_info_group () -> Tuple [Adw .PreferencesGroup , Adw .ActionRow , Adw .ActionRow , Adw .ActionRow ]:
271- file_info_group = Adw .PreferencesGroup (title = "Current File" )
269+ def create_file_info_group () -> tuple [Adw .PreferencesGroup , Adw .ActionRow , Adw .ActionRow , Adw .ActionRow ]:
270+ file_info_group = Adw .PreferencesGroup (title = _ ( "Current File" ) )
272271
273272 filename_row = Adw .ActionRow (title = _ ("Name" ), subtitle = _ ("No file loaded" ))
274273 location_row = Adw .ActionRow (title = _ ("Location" ), subtitle = _ ("No file loaded" ))
275- processed_size_row = Adw .ActionRow (title = _ ("Modified image size" ), subtitle = "N/A" )
274+ processed_size_row = Adw .ActionRow (title = _ ("Modified image size" ), subtitle = _ ( "N/A" ) )
276275
277276 file_info_group .add (filename_row )
278277 file_info_group .add (location_row )
@@ -407,7 +406,7 @@ def create_sidebar_ui(
407406 on_corner_radius_changed : Callable [[Adw .SpinRow ], None ],
408407 on_aspect_ratio_changed : Callable [[Gtk .Entry ], None ],
409408 on_shadow_strength_changed : Callable [[Gtk .Scale ], None ],
410- ) -> Dict [str , Union [ Gtk .Widget , Adw .ActionRow , Adw .SpinRow , Gtk .Entry ] ]:
409+ ) -> dict [str , Gtk .Widget | Adw .ActionRow | Adw .SpinRow | Gtk .Entry ]:
411410 sidebar_box = Gtk .Box (orientation = Gtk .Orientation .VERTICAL , spacing = 0 )
412411 settings_scroll = Gtk .ScrolledWindow (vexpand = True )
413412 controls_box = Gtk .Box (orientation = Gtk .Orientation .VERTICAL , spacing = 20 ,
0 commit comments