Skip to content

Commit

Permalink
Merge pull request #214 from DaPigGuy/pig/adw-spinner
Browse files Browse the repository at this point in the history
Port to AdwSpinner
  • Loading branch information
amka authored Nov 6, 2024
2 parents 535d00f + 9972c75 commit c9d32b2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions data/ui/welcome_page.blp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ template $WelcomePage : Adw.NavigationPage {
// }

[start]
Spinner spinner {
spinning: false;
Adw.Spinner spinner {
visible: false;
}

[end]
Expand Down
2 changes: 1 addition & 1 deletion flatpak/com.github.tenderowl.frog.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"app-id" : "com.github.tenderowl.frog",
"runtime" : "org.gnome.Platform",
"runtime-version" : "46",
"runtime-version" : "47",
"sdk" : "org.gnome.Sdk",
"command" : "frog",
"finish-args" : [
Expand Down
2 changes: 1 addition & 1 deletion frog/widgets/welcome_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
class WelcomePage(Adw.NavigationPage):
__gtype_name__ = "WelcomePage"

spinner: Gtk.Spinner = Gtk.Template.Child()
spinner: Adw.Spinner = Gtk.Template.Child()
welcome: Adw.StatusPage = Gtk.Template.Child()
lang_combo: Gtk.MenuButton = Gtk.Template.Child()
language_popover: LanguagePopover = Gtk.Template.Child()
Expand Down
11 changes: 5 additions & 6 deletions frog/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ def on_language_change(self, widget: Gtk.ListBox, row: Gtk.ListBoxRow) -> None:
def get_screenshot(self, copy: bool = False) -> None:
self.extracted_page.listen_cancel()
lang = self.get_language()
# self.welcome_page.spinner.start()
self.hide()
self.backend.capture(lang, copy)

Expand Down Expand Up @@ -178,11 +177,11 @@ def on_shot_done(self, sender, text: str, copy: bool) -> None:

finally:
self.present()
self.welcome_page.spinner.stop()
self.welcome_page.spinner.set_visible(False)

def on_shot_error(self, sender, message: str) -> None:
self.present()
self.welcome_page.spinner.stop()
self.welcome_page.spinner.set_visible(False)
if message:
self.show_toast(message)
# self.display_error(self, message)
Expand All @@ -207,7 +206,7 @@ def on_open_image(self, dialog: Gtk.FileDialog, result: Gio.AsyncResult) -> None
try:
item = dialog.open_finish(result)
lang = self.get_language()
self.welcome_page.spinner.start()
self.welcome_page.spinner.set_visible(True)
GObjectWorker.call(self.backend.decode_image, (lang, item.get_path()))
except GLib.Error as e:
if not e.matches(Gio.io_error_quark(), Gio.IOErrorEnum.CANCELLED):
Expand All @@ -219,7 +218,7 @@ def _on_paste_from_clipboard(
pngbytes = BytesIO(texture.save_to_png_bytes().get_data())
try:
lang = self.get_language()
self.welcome_page.spinner.start()
self.welcome_page.spinner.set_visible(True)
GObjectWorker.call(self.backend.decode_image, (lang, pngbytes))
except GLib.Error as e:
if not e.matches(Gio.io_error_quark(), Gio.IOErrorEnum.CANCELLED):
Expand Down Expand Up @@ -261,7 +260,7 @@ def on_dnd_drop(self, drop_target, value: Gdk.FileList, x: int, y: int) -> None:
return self.show_toast(_("Only images can be processed that way."))

lang = self.get_language()
self.welcome_page.spinner.start()
self.welcome_page.spinner.set_visible(True)
GObjectWorker.call(self.backend.decode_image, (lang, item.get_path()))

def on_configure_event(self, window, event):
Expand Down

0 comments on commit c9d32b2

Please sign in to comment.