Skip to content

Commit

Permalink
fix: use GLib.Error instead of GError
Browse files Browse the repository at this point in the history
  • Loading branch information
tfuxu committed Nov 10, 2024
1 parent f2912dc commit 44ab559
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions halftone/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions halftone/views/dither_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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"))
)
4 changes: 2 additions & 2 deletions halftone/views/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 44ab559

Please sign in to comment.