Switching to dialog approach
This commit is contained in:
@@ -4,7 +4,7 @@ namespace Keychain.UI;
|
|||||||
|
|
||||||
public class AddShortcutWindow
|
public class AddShortcutWindow
|
||||||
{
|
{
|
||||||
public Window Window { get; }
|
public Dialog Dialog { get; }
|
||||||
private EntryRow? pathEntry;
|
private EntryRow? pathEntry;
|
||||||
private Gtk.Button? browseButton;
|
private Gtk.Button? browseButton;
|
||||||
|
|
||||||
@@ -12,12 +12,12 @@ public class AddShortcutWindow
|
|||||||
{
|
{
|
||||||
var builder = new Gtk.Builder("Keychain.UI.AddShortcutWindow.AddShortcutWindow.xml");
|
var builder = new Gtk.Builder("Keychain.UI.AddShortcutWindow.AddShortcutWindow.xml");
|
||||||
|
|
||||||
var window = builder.GetObject("add_shortcut_window") as Window;
|
var dialog = builder.GetObject("add_shortcut_dialog") as Dialog;
|
||||||
if (window == null)
|
if (dialog == null)
|
||||||
{
|
{
|
||||||
throw new Exception("Failed to load embedded resource AddShortcutWindow.xml");
|
throw new Exception("Failed to load embedded resource AddShortcutWindow.xml");
|
||||||
}
|
}
|
||||||
Window = window;
|
Dialog = dialog;
|
||||||
|
|
||||||
browseButton = builder.GetObject("folder_browse_button") as Gtk.Button;
|
browseButton = builder.GetObject("folder_browse_button") as Gtk.Button;
|
||||||
if (browseButton == null)
|
if (browseButton == null)
|
||||||
@@ -29,9 +29,8 @@ public class AddShortcutWindow
|
|||||||
|
|
||||||
private async void BrowseFolder(object sender, EventArgs e)
|
private async void BrowseFolder(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var fileDialog = new Gtk.FileDialog();
|
var fileDialog = new Gtk.FileDialog();
|
||||||
var selectedFolder = await fileDialog.SelectFolderAsync(Window);
|
var selectedFolder = await fileDialog.SelectFolderAsync((Window)Dialog.Parent.Parent);
|
||||||
|
|
||||||
if (selectedFolder != null)
|
if (selectedFolder != null)
|
||||||
{
|
{
|
||||||
var buttonContent = (ButtonContent)browseButton.Child;
|
var buttonContent = (ButtonContent)browseButton.Child;
|
||||||
|
|||||||
@@ -1,26 +1,39 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface>
|
<interface>
|
||||||
<object class="AdwWindow" id="add_shortcut_window">
|
<object class="AdwDialog" id="add_shortcut_dialog">
|
||||||
<property name="width-request">350</property>
|
<property name="content-width">400</property>
|
||||||
<property name="height-request">300</property>
|
<property name="content-height">350</property>
|
||||||
<property name="default-width">500</property>
|
<property name="child">
|
||||||
<property name="default-height">600</property>
|
<object class="AdwToolbarView">
|
||||||
<child>
|
|
||||||
<object class="AdwBreakpoint">
|
|
||||||
<condition>max-width: 500sp</condition>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<property name="content">
|
|
||||||
<object class="AdwToolbarView">
|
|
||||||
<child type="top">
|
<child type="top">
|
||||||
<object class="AdwHeaderBar">
|
<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>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<property name="content">
|
<property name="content">
|
||||||
<object class="AdwPreferencesPage">
|
<object class="AdwPreferencesPage">
|
||||||
<child>
|
<child>
|
||||||
<object class="AdwPreferencesGroup" id="shortcuts_group">
|
<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>
|
<child>
|
||||||
<object class="AdwEntryRow">
|
<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>
|
<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>
|
||||||
@@ -83,5 +96,5 @@
|
|||||||
</property>
|
</property>
|
||||||
</object>
|
</object>
|
||||||
</property>
|
</property>
|
||||||
</object>
|
</object>
|
||||||
</interface>
|
</interface>
|
||||||
@@ -38,13 +38,12 @@ public class MainWindow
|
|||||||
shortcuts = new PasswordStoreShortcutCollection(shortcutsGroup);
|
shortcuts = new PasswordStoreShortcutCollection(shortcutsGroup);
|
||||||
|
|
||||||
LoadDefaultShortcuts();
|
LoadDefaultShortcuts();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnAddShortcutClicked(object sender, EventArgs e)
|
private void OnAddShortcutClicked(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var window = new AddShortcutWindow().Window;
|
var dialog = new AddShortcutWindow().Dialog;
|
||||||
window.Application = Window.Application;
|
dialog.Present(Window);
|
||||||
window.Show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddShortcut(string path)
|
public void AddShortcut(string path)
|
||||||
|
|||||||
Reference in New Issue
Block a user