41 lines
1.2 KiB
C#
41 lines
1.2 KiB
C#
using Adw;
|
|
|
|
namespace Keychain.UI;
|
|
|
|
public class AddShortcutWindow
|
|
{
|
|
public Dialog Dialog { get; }
|
|
private EntryRow? pathEntry;
|
|
private Gtk.Button? browseButton;
|
|
|
|
public AddShortcutWindow()
|
|
{
|
|
var builder = new Gtk.Builder("Keychain.UI.AddShortcutWindow.AddShortcutWindow.xml");
|
|
|
|
var dialog = builder.GetObject("add_shortcut_dialog") as Dialog;
|
|
if (dialog == null)
|
|
{
|
|
throw new Exception("Failed to load embedded resource AddShortcutWindow.xml");
|
|
}
|
|
Dialog = dialog;
|
|
|
|
browseButton = builder.GetObject("folder_browse_button") as Gtk.Button;
|
|
if (browseButton == null)
|
|
{
|
|
throw new Exception("Failed to load UI element with ID: folder_browse_button");
|
|
}
|
|
browseButton.OnClicked += BrowseFolder;
|
|
}
|
|
|
|
private async void BrowseFolder(object sender, EventArgs e)
|
|
{
|
|
var fileDialog = new Gtk.FileDialog();
|
|
var selectedFolder = await fileDialog.SelectFolderAsync((Window)Dialog.Parent.Parent);
|
|
if (selectedFolder != null)
|
|
{
|
|
var buttonContent = (ButtonContent)browseButton.Child;
|
|
buttonContent.Label = selectedFolder.GetPath();
|
|
}
|
|
}
|
|
}
|