Implemented more UI functionality
This commit is contained in:
@@ -5,19 +5,42 @@ namespace Keychain.UI;
|
|||||||
public class AddShortcutWindow
|
public class AddShortcutWindow
|
||||||
{
|
{
|
||||||
public Dialog Dialog { get; }
|
public Dialog Dialog { get; }
|
||||||
private EntryRow? pathEntry;
|
private Gtk.Button? closeButton;
|
||||||
|
private Gtk.Button? iconPickerButton;
|
||||||
private Gtk.Button? browseButton;
|
private Gtk.Button? browseButton;
|
||||||
|
private Gtk.Button? clearSelectedFolderButton;
|
||||||
|
private Gtk.Button? saveButton;
|
||||||
|
|
||||||
public AddShortcutWindow()
|
public AddShortcutWindow()
|
||||||
{
|
{
|
||||||
var builder = new Gtk.Builder("Keychain.UI.AddShortcutWindow.AddShortcutWindow.xml");
|
var builder = new Gtk.Builder("Keychain.UI.AddShortcutWindow.AddShortcutWindow.xml");
|
||||||
|
|
||||||
var dialog = builder.GetObject("add_shortcut_dialog") as Dialog;
|
Dialog = builder.GetObject("add_shortcut_dialog") as Dialog;
|
||||||
if (dialog == null)
|
if (Dialog == null)
|
||||||
{
|
{
|
||||||
throw new Exception("Failed to load embedded resource AddShortcutWindow.xml");
|
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;
|
browseButton = builder.GetObject("folder_browse_button") as Gtk.Button;
|
||||||
if (browseButton == null)
|
if (browseButton == null)
|
||||||
@@ -25,6 +48,35 @@ public class AddShortcutWindow
|
|||||||
throw new Exception("Failed to load UI element with ID: folder_browse_button");
|
throw new Exception("Failed to load UI element with ID: folder_browse_button");
|
||||||
}
|
}
|
||||||
browseButton.OnClicked += BrowseFolder;
|
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)
|
private async void BrowseFolder(object sender, EventArgs e)
|
||||||
@@ -35,6 +87,7 @@ public class AddShortcutWindow
|
|||||||
{
|
{
|
||||||
var buttonContent = (ButtonContent)browseButton.Child;
|
var buttonContent = (ButtonContent)browseButton.Child;
|
||||||
buttonContent.Label = selectedFolder.GetPath();
|
buttonContent.Label = selectedFolder.GetPath();
|
||||||
|
clearSelectedFolderButton.Sensitive = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
<interface>
|
<interface>
|
||||||
<object class="AdwDialog" id="add_shortcut_dialog">
|
<object class="AdwDialog" id="add_shortcut_dialog">
|
||||||
<property name="content-width">400</property>
|
<property name="content-width">400</property>
|
||||||
<property name="content-height">350</property>
|
|
||||||
<property name="child">
|
<property name="child">
|
||||||
<object class="AdwToolbarView">
|
<object class="AdwToolbarView">
|
||||||
<child type="top">
|
<child type="top">
|
||||||
@@ -14,13 +13,13 @@
|
|||||||
</property>
|
</property>
|
||||||
<property name="show-end-title-buttons">False</property>
|
<property name="show-end-title-buttons">False</property>
|
||||||
<child type="start">
|
<child type="start">
|
||||||
<object class="GtkButton">
|
<object class="GtkButton" id="close_button">
|
||||||
<property name="valign">center</property>
|
<property name="valign">center</property>
|
||||||
<property name="label" translatable="yes" context="label" comments="Verb">Cancel</property>
|
<property name="label" translatable="yes" context="label" comments="Verb">Cancel</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child type="end">
|
<child type="end">
|
||||||
<object class="GtkButton">
|
<object class="GtkButton" id="save_button">
|
||||||
<style>
|
<style>
|
||||||
<class name="suggested-action" />
|
<class name="suggested-action" />
|
||||||
</style>
|
</style>
|
||||||
@@ -33,7 +32,7 @@
|
|||||||
<property name="content">
|
<property name="content">
|
||||||
<object class="AdwPreferencesPage">
|
<object class="AdwPreferencesPage">
|
||||||
<child>
|
<child>
|
||||||
<object class="AdwPreferencesGroup" id="shortcuts_group">
|
<object class="AdwPreferencesGroup">
|
||||||
<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>
|
||||||
@@ -45,11 +44,8 @@
|
|||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="icon_picker_button">
|
<object class="GtkButton" id="icon_picker_button">
|
||||||
<property name="valign">center</property>
|
<property name="valign">center</property>
|
||||||
<child>
|
<property name="halign">center</property>
|
||||||
<object class="AdwButtonContent">
|
<property name="icon-name">emoji-symbols-symbolic</property>
|
||||||
<property name="icon-name">emoji-symbols-symbolic</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
@@ -97,4 +93,4 @@
|
|||||||
</object>
|
</object>
|
||||||
</property>
|
</property>
|
||||||
</object>
|
</object>
|
||||||
</interface>
|
</interface>
|
||||||
|
|||||||
Reference in New Issue
Block a user