Switching to dialog approach

This commit is contained in:
2025-09-18 15:36:30 +02:00
parent 9f67e85088
commit 4d06e6740e
3 changed files with 39 additions and 28 deletions

View File

@@ -4,7 +4,7 @@ namespace Keychain.UI;
public class AddShortcutWindow
{
public Window Window { get; }
public Dialog Dialog { get; }
private EntryRow? pathEntry;
private Gtk.Button? browseButton;
@@ -12,12 +12,12 @@ public class AddShortcutWindow
{
var builder = new Gtk.Builder("Keychain.UI.AddShortcutWindow.AddShortcutWindow.xml");
var window = builder.GetObject("add_shortcut_window") as Window;
if (window == null)
var dialog = builder.GetObject("add_shortcut_dialog") as Dialog;
if (dialog == null)
{
throw new Exception("Failed to load embedded resource AddShortcutWindow.xml");
}
Window = window;
Dialog = dialog;
browseButton = builder.GetObject("folder_browse_button") as Gtk.Button;
if (browseButton == null)
@@ -29,9 +29,8 @@ public class AddShortcutWindow
private async void BrowseFolder(object sender, EventArgs e)
{
var fileDialog = new Gtk.FileDialog();
var selectedFolder = await fileDialog.SelectFolderAsync(Window);
var fileDialog = new Gtk.FileDialog();
var selectedFolder = await fileDialog.SelectFolderAsync((Window)Dialog.Parent.Parent);
if (selectedFolder != null)
{
var buttonContent = (ButtonContent)browseButton.Child;