From 44ab559b9aa6b67e4f6332b7af5fb4f6005a8afc Mon Sep 17 00:00:00 2001 From: tfuxu <73042332+tfuxu@users.noreply.github.com> Date: Sun, 10 Nov 2024 14:34:51 +0100 Subject: [PATCH] fix: use `GLib.Error` instead of `GError` --- halftone/main.py | 4 ++-- halftone/views/dither_page.py | 10 +++++----- halftone/views/main_window.py | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/halftone/main.py b/halftone/main.py index 51b809b..d8cef07 100644 --- a/halftone/main.py +++ b/halftone/main.py @@ -100,7 +100,7 @@ def show_image_external(self, _action, image_path: GLib.Variant, *args): try: image_file = Gio.File.new_for_path(image_path.get_string()) - except GLib.GError as e: + except GLib.Error as e: logging.traceback_error("Failed to construct a new Gio.File object from path.", exc=e, show_exception=True) else: @@ -109,7 +109,7 @@ def show_image_external(self, _action, image_path: GLib.Variant, *args): def open_image_finish(_, result, *args): try: launcher.launch_finish(result) - except GLib.GError as e: + except GLib.Error as e: if e.code != 2: # 'The portal dialog was dismissed by the user' error logging.traceback_error("Failed to finish Gtk.FileLauncher procedure.", exc=e, show_exception=True) diff --git a/halftone/views/dither_page.py b/halftone/views/dither_page.py index 8f1429d..38dfb28 100644 --- a/halftone/views/dither_page.py +++ b/halftone/views/dither_page.py @@ -183,7 +183,7 @@ def update_preview_image(self, path: str, output_options: OutputOptions, try: self.set_updated_paintable(self.preview_image_path) - except GLib.GError: + except GLib.Error: self.win.show_error_page() raise @@ -199,7 +199,7 @@ def load_preview_image(self, file: Gio.File): try: self.set_original_paintable(self.input_image_path) - except GLib.GError: + except GLib.Error: self.win.show_error_page() raise @@ -414,7 +414,7 @@ def on_breakpoint_unapply(self, *args): def set_original_paintable(self, path: str): try: self.original_paintable = Gdk.Texture.new_from_filename(path) - except GLib.GError as e: + except GLib.Error as e: logging.traceback_error( "Failed to construct new Gdk.Texture from path.", exc=e, show_exception=True) @@ -426,7 +426,7 @@ def set_original_paintable(self, path: str): def set_updated_paintable(self, path: str): try: self.updated_paintable = Gdk.Texture.new_from_filename(path) - except GLib.GError as e: + except GLib.Error as e: logging.traceback_error( "Failed to construct new Gdk.Texture from path.", exc=e, show_exception=True) @@ -519,7 +519,7 @@ def start_task(self, task: callable, *args): #callback: callable thread.start() self.task_id = thread.ident self.tasks.append(thread) - except GLib.GError: + except GLib.Error: self.toast_overlay.add_toast( Adw.Toast(title=_("Failed to load preview image")) ) diff --git a/halftone/views/main_window.py b/halftone/views/main_window.py index 470bf37..38112b0 100644 --- a/halftone/views/main_window.py +++ b/halftone/views/main_window.py @@ -93,7 +93,7 @@ def setup(self): def setup_image_dialog(self): supported_filter = get_file_filter( - _("Supported image formats"), supported_formats + _("Supported image formats"), supported_input_formats ) filters = Gio.ListStore.new(Gtk.FileFilter) @@ -111,7 +111,7 @@ def load_image(self, file: Gio.File): self.show_loading_page() try: self.dither_page.load_preview_image(file) - except GLib.GError as e: + except GLib.Error as e: # TODO: Modify error page for different error codes if e.code == 3: # Unrecognized image file format pass