Implemented more UI functionality
This commit is contained in:
@@ -5,19 +5,42 @@ namespace Keychain.UI;
|
||||
public class AddShortcutWindow
|
||||
{
|
||||
public Dialog Dialog { get; }
|
||||
private EntryRow? pathEntry;
|
||||
private Gtk.Button? closeButton;
|
||||
private Gtk.Button? iconPickerButton;
|
||||
private Gtk.Button? browseButton;
|
||||
private Gtk.Button? clearSelectedFolderButton;
|
||||
private Gtk.Button? saveButton;
|
||||
|
||||
public AddShortcutWindow()
|
||||
{
|
||||
var builder = new Gtk.Builder("Keychain.UI.AddShortcutWindow.AddShortcutWindow.xml");
|
||||
|
||||
var dialog = builder.GetObject("add_shortcut_dialog") as Dialog;
|
||||
if (dialog == null)
|
||||
Dialog = builder.GetObject("add_shortcut_dialog") as Dialog;
|
||||
if (Dialog == null)
|
||||
{
|
||||
throw new Exception("Failed to load embedded resource AddShortcutWindow.xml");
|
||||
}
|
||||
Dialog = dialog;
|
||||
|
||||
closeButton = builder.GetObject("close_button") as Gtk.Button;
|
||||
if (closeButton == null)
|
||||
{
|
||||
throw new Exception("Failed to load UI element with ID: close_button");
|
||||
}
|
||||
closeButton.OnClicked += Close;
|
||||
|
||||
iconPickerButton = builder.GetObject("icon_picker_button") as Gtk.Button;
|
||||
if (iconPickerButton == null)
|
||||
{
|
||||
throw new Exception("Failed to load UI element with ID: icon_picker_button");
|
||||
}
|
||||
iconPickerButton.OnClicked += OpenIconPicker;
|
||||
|
||||
clearSelectedFolderButton = builder.GetObject("clear_selected_folder_button") as Gtk.Button;
|
||||
if (clearSelectedFolderButton == null)
|
||||
{
|
||||
throw new Exception("Failed to load UI element with ID: icon_picker_button");
|
||||
}
|
||||
clearSelectedFolderButton.OnClicked += ClearSelectedFolder;
|
||||
|
||||
browseButton = builder.GetObject("folder_browse_button") as Gtk.Button;
|
||||
if (browseButton == null)
|
||||
@@ -25,6 +48,35 @@ public class AddShortcutWindow
|
||||
throw new Exception("Failed to load UI element with ID: folder_browse_button");
|
||||
}
|
||||
browseButton.OnClicked += BrowseFolder;
|
||||
|
||||
saveButton = builder.GetObject("save_button") as Gtk.Button;
|
||||
if (saveButton == null)
|
||||
{
|
||||
throw new Exception("Failed to load UI element with ID: save_button");
|
||||
}
|
||||
}
|
||||
|
||||
private void OpenIconPicker(object sender, EventArgs e)
|
||||
{
|
||||
var chooser = new Gtk.EmojiChooser();
|
||||
chooser.SetParent(iconPickerButton);
|
||||
chooser.OnEmojiPicked += (s, e) =>
|
||||
{
|
||||
iconPickerButton.Label = e.Text;
|
||||
};
|
||||
chooser.Show();
|
||||
}
|
||||
|
||||
private void Close(object sender, EventArgs e)
|
||||
{
|
||||
Dialog.Close();
|
||||
}
|
||||
|
||||
private void ClearSelectedFolder(object sender, EventArgs e)
|
||||
{
|
||||
var buttonContent = (ButtonContent)browseButton.Child;
|
||||
buttonContent.Label = "Browse";
|
||||
clearSelectedFolderButton.Sensitive = false;
|
||||
}
|
||||
|
||||
private async void BrowseFolder(object sender, EventArgs e)
|
||||
@@ -35,6 +87,7 @@ public class AddShortcutWindow
|
||||
{
|
||||
var buttonContent = (ButtonContent)browseButton.Child;
|
||||
buttonContent.Label = selectedFolder.GetPath();
|
||||
clearSelectedFolderButton.Sensitive = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
<interface>
|
||||
<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">
|
||||
@@ -14,13 +13,13 @@
|
||||
</property>
|
||||
<property name="show-end-title-buttons">False</property>
|
||||
<child type="start">
|
||||
<object class="GtkButton">
|
||||
<object class="GtkButton" id="close_button">
|
||||
<property name="valign">center</property>
|
||||
<property name="label" translatable="yes" context="label" comments="Verb">Cancel</property>
|
||||
</object>
|
||||
</child>
|
||||
<child type="end">
|
||||
<object class="GtkButton">
|
||||
<object class="GtkButton" id="save_button">
|
||||
<style>
|
||||
<class name="suggested-action" />
|
||||
</style>
|
||||
@@ -33,7 +32,7 @@
|
||||
<property name="content">
|
||||
<object class="AdwPreferencesPage">
|
||||
<child>
|
||||
<object class="AdwPreferencesGroup" id="shortcuts_group">
|
||||
<object class="AdwPreferencesGroup">
|
||||
<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>
|
||||
@@ -45,15 +44,12 @@
|
||||
<child>
|
||||
<object class="GtkButton" id="icon_picker_button">
|
||||
<property name="valign">center</property>
|
||||
<child>
|
||||
<object class="AdwButtonContent">
|
||||
<property name="halign">center</property>
|
||||
<property name="icon-name">emoji-symbols-symbolic</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="AdwActionRow">
|
||||
<property name="title" translatable="yes" context="Label" comments="Noun. Marks a button that allows the user to pick a folder where the new store will be.">Location</property>
|
||||
|
||||
Reference in New Issue
Block a user