Switching to dialog approach
This commit is contained in:
@@ -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)
|
||||
@@ -30,8 +30,7 @@ public class AddShortcutWindow
|
||||
private async void BrowseFolder(object sender, EventArgs e)
|
||||
{
|
||||
var fileDialog = new Gtk.FileDialog();
|
||||
var selectedFolder = await fileDialog.SelectFolderAsync(Window);
|
||||
|
||||
var selectedFolder = await fileDialog.SelectFolderAsync((Window)Dialog.Parent.Parent);
|
||||
if (selectedFolder != null)
|
||||
{
|
||||
var buttonContent = (ButtonContent)browseButton.Child;
|
||||
|
||||
@@ -1,26 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<object class="AdwWindow" id="add_shortcut_window">
|
||||
<property name="width-request">350</property>
|
||||
<property name="height-request">300</property>
|
||||
<property name="default-width">500</property>
|
||||
<property name="default-height">600</property>
|
||||
<child>
|
||||
<object class="AdwBreakpoint">
|
||||
<condition>max-width: 500sp</condition>
|
||||
</object>
|
||||
</child>
|
||||
<property name="content">
|
||||
<object class="AdwDialog" id="add_shortcut_dialog">
|
||||
<property name="content-width">400</property>
|
||||
<property name="content-height">350</property>
|
||||
<property name="child">
|
||||
<object class="AdwToolbarView">
|
||||
<child type="top">
|
||||
<object class="AdwHeaderBar">
|
||||
<property name="title-widget">
|
||||
<object class="AdwWindowTitle">
|
||||
<property name="title" translatable="yes" context="label" comments="Verb. Marks a preferences page where the user can add new password stores. Store as in storage">Add New Store</property>
|
||||
</object>
|
||||
</property>
|
||||
<property name="show-end-title-buttons">False</property>
|
||||
<child type="start">
|
||||
<object class="GtkButton">
|
||||
<property name="valign">center</property>
|
||||
<property name="label" translatable="yes" context="label" comments="Verb">Cancel</property>
|
||||
</object>
|
||||
</child>
|
||||
<child type="end">
|
||||
<object class="GtkButton">
|
||||
<style>
|
||||
<class name="suggested-action" />
|
||||
</style>
|
||||
<property name="valign">center</property>
|
||||
<property name="label" translatable="yes" context="label" comments="Verb">Save</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<property name="content">
|
||||
<object class="AdwPreferencesPage">
|
||||
<child>
|
||||
<object class="AdwPreferencesGroup" id="shortcuts_group">
|
||||
<property name="title" translatable="yes" context="label" comments="Verb. Marks a preferences page where the user can add new password stores. Store as in storage">Add New Store</property>
|
||||
<child>
|
||||
<object class="AdwEntryRow">
|
||||
<property name="title" translatable="yes" context="Input field placeholder" comments="Noun. Tells the user that the display name of the new password store is to be supplied here">Name</property>
|
||||
|
||||
@@ -42,9 +42,8 @@ public class MainWindow
|
||||
|
||||
private void OnAddShortcutClicked(object sender, EventArgs e)
|
||||
{
|
||||
var window = new AddShortcutWindow().Window;
|
||||
window.Application = Window.Application;
|
||||
window.Show();
|
||||
var dialog = new AddShortcutWindow().Dialog;
|
||||
dialog.Present(Window);
|
||||
}
|
||||
|
||||
public void AddShortcut(string path)
|
||||
|
||||
Reference in New Issue
Block a user