Skip to content

Commit

Permalink
add sync indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
mrvladus committed Jan 9, 2024
1 parent 1356d32 commit a607950
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions errands/utils/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-License-Identifier: MIT

import datetime, urllib3
from typing import Callable
from caldav import Calendar, DAVClient, Principal, Todo
from caldav.elements import dav
from gi.repository import Adw, GLib
Expand Down Expand Up @@ -39,10 +40,14 @@ def sync(self) -> None:
GLib.idle_add(self.window.lists.update_ui)
return
if not self.provider:
GLib.idle_add(self.window.lists.sync_indicator.set_visible, True)
self.init(self.window)
GLib.idle_add(self.window.lists.sync_indicator.set_visible, False)
if self.provider and self.provider.can_sync:
GLib.idle_add(self.window.lists.sync_indicator.set_visible, True)
self.provider.sync()
GLib.idle_add(self.window.lists.update_ui)
GLib.idle_add(self.window.lists.sync_indicator.set_visible, False)

@classmethod
def test_connection(self) -> bool:
Expand Down
8 changes: 8 additions & 0 deletions errands/widgets/lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def _build_ui(self):
)
self.add_list_btn.connect("clicked", self.on_add_btn_clicked)
hb.pack_start(self.add_list_btn)

# Main menu
menu: Gio.Menu = Gio.Menu.new()
top_section = Gio.Menu.new()
Expand All @@ -162,6 +163,13 @@ def _build_ui(self):
tooltip_text=_("Main Menu"),
)
hb.pack_end(menu_btn)

# Sync indicator
self.sync_indicator = Gtk.Spinner(
tooltip_text=_("Syncing..."), visible=False, spinning=True
)
hb.pack_end(self.sync_indicator)

# Lists
self.lists = Gtk.ListBox(css_classes=["navigation-sidebar"])
self.lists.connect("row-selected", self.on_list_swiched)
Expand Down

0 comments on commit a607950

Please sign in to comment.