mirror of
https://gitlab.gnome.org/World/Authenticator.git
synced 2025-03-05 17:20:57 +01:00
Use correctly working otp accounts for switching views
This commit is contained in:
parent
22e15355e6
commit
7734a94158
3 changed files with 12 additions and 9 deletions
|
@ -45,11 +45,7 @@ class Application(Gtk.Application):
|
|||
if self.is_locked:
|
||||
Window.get_default().view = WindowView.LOCKED
|
||||
else:
|
||||
count = Database.get_default().accounts_count
|
||||
if count == 0:
|
||||
Window.get_default().view = WindowView.EMPTY
|
||||
else:
|
||||
Window.get_default().view = WindowView.NORMAL
|
||||
Window.get_default().refresh_view()
|
||||
@staticmethod
|
||||
def get_default():
|
||||
if Application.instance is None:
|
||||
|
|
|
@ -54,6 +54,13 @@ class AccountsManager(GObject.GObject):
|
|||
def accounts(self):
|
||||
return self._accounts
|
||||
|
||||
@property
|
||||
def accounts_count(self):
|
||||
count = 0
|
||||
for _, accounts in self._accounts:
|
||||
count += len(accounts)
|
||||
return count
|
||||
|
||||
def clear(self):
|
||||
self._accounts = []
|
||||
|
||||
|
|
|
@ -135,16 +135,16 @@ class Window(Gtk.ApplicationWindow, GObject.GObject):
|
|||
|
||||
# Set up accounts Widget
|
||||
accounts_widget = AccountsWidget.get_default()
|
||||
accounts_widget.connect("account-removed", self.__on_accounts_changed)
|
||||
accounts_widget.connect("account-added", self.__on_accounts_changed)
|
||||
accounts_widget.connect("account-removed", self.refresh_view)
|
||||
accounts_widget.connect("account-added", self.refresh_view)
|
||||
self.accounts_viewport.add(accounts_widget)
|
||||
|
||||
self.search_bar.bind_property("search-mode-enabled", self.search_btn,
|
||||
"active",
|
||||
GObject.BindingFlags.BIDIRECTIONAL)
|
||||
|
||||
def __on_accounts_changed(self, *_):
|
||||
if Database.get_default().accounts_count == 0:
|
||||
def refresh_view(self, *_):
|
||||
if AccountsManager.get_default().accounts_count == 0:
|
||||
self.props.view = WindowView.EMPTY
|
||||
else:
|
||||
self.props.view = WindowView.NORMAL
|
||||
|
|
Loading…
Add table
Reference in a new issue