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:
|
if self.is_locked:
|
||||||
Window.get_default().view = WindowView.LOCKED
|
Window.get_default().view = WindowView.LOCKED
|
||||||
else:
|
else:
|
||||||
count = Database.get_default().accounts_count
|
Window.get_default().refresh_view()
|
||||||
if count == 0:
|
|
||||||
Window.get_default().view = WindowView.EMPTY
|
|
||||||
else:
|
|
||||||
Window.get_default().view = WindowView.NORMAL
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_default():
|
def get_default():
|
||||||
if Application.instance is None:
|
if Application.instance is None:
|
||||||
|
|
|
@ -54,6 +54,13 @@ class AccountsManager(GObject.GObject):
|
||||||
def accounts(self):
|
def accounts(self):
|
||||||
return self._accounts
|
return self._accounts
|
||||||
|
|
||||||
|
@property
|
||||||
|
def accounts_count(self):
|
||||||
|
count = 0
|
||||||
|
for _, accounts in self._accounts:
|
||||||
|
count += len(accounts)
|
||||||
|
return count
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
self._accounts = []
|
self._accounts = []
|
||||||
|
|
||||||
|
|
|
@ -135,16 +135,16 @@ class Window(Gtk.ApplicationWindow, GObject.GObject):
|
||||||
|
|
||||||
# Set up accounts Widget
|
# Set up accounts Widget
|
||||||
accounts_widget = AccountsWidget.get_default()
|
accounts_widget = AccountsWidget.get_default()
|
||||||
accounts_widget.connect("account-removed", self.__on_accounts_changed)
|
accounts_widget.connect("account-removed", self.refresh_view)
|
||||||
accounts_widget.connect("account-added", self.__on_accounts_changed)
|
accounts_widget.connect("account-added", self.refresh_view)
|
||||||
self.accounts_viewport.add(accounts_widget)
|
self.accounts_viewport.add(accounts_widget)
|
||||||
|
|
||||||
self.search_bar.bind_property("search-mode-enabled", self.search_btn,
|
self.search_bar.bind_property("search-mode-enabled", self.search_btn,
|
||||||
"active",
|
"active",
|
||||||
GObject.BindingFlags.BIDIRECTIONAL)
|
GObject.BindingFlags.BIDIRECTIONAL)
|
||||||
|
|
||||||
def __on_accounts_changed(self, *_):
|
def refresh_view(self, *_):
|
||||||
if Database.get_default().accounts_count == 0:
|
if AccountsManager.get_default().accounts_count == 0:
|
||||||
self.props.view = WindowView.EMPTY
|
self.props.view = WindowView.EMPTY
|
||||||
else:
|
else:
|
||||||
self.props.view = WindowView.NORMAL
|
self.props.view = WindowView.NORMAL
|
||||||
|
|
Loading…
Add table
Reference in a new issue