Exemplo n.º 1
0
 def _on_account_deleted(self, accounts_list, account=None):
     if account:
         AccountsManager.get_default().delete(account)
     if len(accounts_list.get_children()) == 0:
         self._to_delete.append(accounts_list)
     self._reorder()
     self._clean_unneeded_providers_widgets()
     self.emit("account-removed")
Exemplo n.º 2
0
 def _on_add(self, *_):
     account_obj = self.account_config.account
     # Create a new account
     account = Account.create(account_obj["username"], account_obj["token"],
                              account_obj["provider"].id)
     # Add it to the AccountsManager
     AccountsManager.get_default().add(account_obj["provider"], account)
     AccountsWidget.get_default().append(account)
     self.destroy()
Exemplo n.º 3
0
 def _on_add(self, *_):
     from .list import AccountsWidget
     from Authenticator.models import AccountsManager, Account
     account_obj = self.account_config.account
     # Create a new account
     account = Account.create(account_obj["username"], account_obj["token"],
                              account_obj["provider"].provider_id)
     # Add it to the AccountsManager
     AccountsManager.get_default().add(account_obj["provider"], account)
     AccountsWidget.get_default().append(account)
     self._on_quit()
Exemplo n.º 4
0
    def __init__(self):
        super(Window, self).__init__()

        self.connect("notify::view", self.__state_changed)

        self.key_press_signal = None
        self.restore_state()
        # Start the Account Manager
        AccountsManager.get_default()

        self.__init_widgets()
Exemplo n.º 5
0
 def export_accounts() -> [dict]:
     accounts = AccountsManager.get_default().accounts
     exported_accounts = []
     for account in accounts:
         json_account = account.to_json()
         exported_accounts.append(json_account)
     return exported_accounts
Exemplo n.º 6
0
 def __init_widgets(self):
     accounts_manager = AccountsManager.get_default()
     accounts_manager.connect("counter_updated", self._on_counter_updated)
     # Add different accounts to the main view
     for provider, accounts in accounts_manager.accounts_per_provider:
         for account in accounts:
             self.append(account)
Exemplo n.º 7
0
    def __init_widgets(self):
        """Build main window widgets."""
        # Register Actions
        self.__add_action("add-account", self.add_account)
        self.__add_action("toggle-searchbar", self.toggle_search)

        # Set up accounts Widget
        accounts_widget = AccountsWidget.get_default()
        accounts_widget.connect("account-removed", self.refresh_view)
        accounts_widget.connect("account-added", self.refresh_view)
        self.accounts_stack.add_named(accounts_widget, "accounts")
        self.accounts_stack.set_visible_child_name("accounts")

        AccountsManager.get_default().connect("notify::empty",
                                              self.refresh_view)

        self.search_bar.bind_property("search-mode-enabled", self.search_btn,
                                      "active",
                                      GObject.BindingFlags.BIDIRECTIONAL)
Exemplo n.º 8
0
 def import_accounts(accounts: [dict]):
     accounts_widget = AccountsWidget.get_default()
     accounts_manager = AccountsManager.get_default()
     for account in accounts:
         try:
             new_account = Account.create_from_json(account)
             accounts_manager.add(new_account.provider, new_account)
             accounts_widget.append(new_account)
         except Exception as e:
             Logger.error("[Restore] Failed to import accounts")
             Logger.error(str(e))
Exemplo n.º 9
0
 def close(self):
     self.save_state()
     AccountsManager.get_default().kill()
     self.destroy()
Exemplo n.º 10
0
 def refresh_view(self, *_):
     if AccountsManager.get_default().props.empty:
         self.props.view = WindowView.EMPTY
     else:
         self.props.view = WindowView.NORMAL