Started working on loading password list from viewModel

This commit is contained in:
2025-09-30 19:05:53 +02:00
parent c8d98e72d0
commit e117748bb5
6 changed files with 152 additions and 12 deletions

View File

@@ -8,19 +8,22 @@ public class MainWindow
{
public Window Window { get; }
private PreferencesGroup shortcutsGroup;
private PasswordList passwordCollection;
private PasswordStoreShortcutCollection shortcuts;
private Gtk.ToggleButton searchToggleButton;
private Gtk.Stack titleStack;
private Gtk.SearchEntry searchEntry;
private PreferencesGroup passwordList;
private readonly IPasswordStoreService passwordStoreService;
private readonly string windowId = "main_window";
private readonly string shortcutsGroupId = "shortcuts_group";
private readonly string addShortcutButtonId = "add_shortcut_button";
private readonly string searchToggleButtonId = "search_button";
private readonly string titleStackId = "title_stack";
private readonly string searchEntryId = "search_entry";
private const string windowId = "main_window";
private const string shortcutsGroupId = "shortcuts_group";
private const string addShortcutButtonId = "add_shortcut_button";
private const string searchToggleButtonId = "search_button";
private const string titleStackId = "title_stack";
private const string searchEntryId = "search_entry";
private const string passwordListId = "password_list";
public MainWindow(IPasswordStoreService passwordStoreService)
{
@@ -38,7 +41,9 @@ public class MainWindow
{
shortcutsGroup = builder.GetObject(shortcutsGroupId) as PreferencesGroup;
if (shortcutsGroup == null)
{
throw new Exception(shortcutsGroupId);
}
var addButton = builder.GetObject(addShortcutButtonId) as Gtk.Button;
if (addButton == null)
@@ -72,16 +77,26 @@ public class MainWindow
searchToggleButton.Active = false;
};
searchEntry.AddController(focusController);
passwordList = builder.GetObject(passwordListId) as PreferencesGroup;
if (passwordList == null)
{
throw new Exception(passwordListId);
}
}
catch (Exception e)
{
throw new Exception("Failed to load UI element with ID: " + e.Message);
}
// Initialize the observable collection with property binding
shortcuts = new PasswordStoreShortcutCollection(shortcutsGroup, passwordStoreService);
// Initialize the observable collection with property binding
shortcuts = new PasswordStoreShortcutCollection(shortcutsGroup, passwordStoreService);
if (shortcuts.Count == 0)
{
LoadDefaultShortcuts();
}
LoadDefaultShortcuts();
passwordCollection = new PasswordList(passwordList);
}
private void OnAddShortcutClicked(object sender, EventArgs e)