Add edit button to shortcut rows

This commit is contained in:
2025-09-17 13:30:09 +02:00
parent de29f522ba
commit decc80341f
2 changed files with 28 additions and 20 deletions

View File

@@ -14,8 +14,8 @@
</child>
<property name="content">
<object class="AdwOverlaySplitView" id="split_view">
<property name="min-sidebar-width">250</property>
<property name="max-sidebar-width">250</property>
<property name="min-sidebar-width">300</property>
<property name="max-sidebar-width">300</property>
<property name="show-sidebar"
bind-source="show_sidebar_button"
bind-property="active"

View File

@@ -1,6 +1,7 @@
namespace App.UI.Models;
using Adw;
using Gtk;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
@@ -57,30 +58,37 @@ public class PasswordStoreShortcutCollection : ObservableCollection<PasswordStor
var row = new ActionRow();
UpdateRowFromItem(shortcut, ref row);
row.SetActivatable(true);
row.SetActivatable(true);
row.OnActivated += (sender, args) => {
Console.WriteLine($"[DEBUG] Opening: {shortcut.Path}");
};
return row;
}
private void UpdateRowFromItem(PasswordStoreShortcut shortcut, ref ActionRow row)
{
row.SetTitle(shortcut.DisplayName);
row.SetSubtitle(shortcut.Path);
}
private void UpdateRowFromItem(PasswordStoreShortcut shortcut, ref ActionRow row)
{
row.SetTitle(shortcut.DisplayName);
row.SetSubtitle(shortcut.Path);
//Update icon
var existingIcon = row.GetFirstChild() as Gtk.Image;
if (existingIcon == null)
{
var icon = new Gtk.Image();
icon.SetFromIconName(shortcut.IconName);
row.AddPrefix(icon);
}
else
{
existingIcon.SetFromIconName(shortcut.IconName);
}
var existingIcon = row.GetFirstChild() as Gtk.Image;
if (existingIcon == null)
{
var icon = new Gtk.Image();
icon.SetFromIconName(shortcut.IconName);
row.AddPrefix(icon);
}
else
{
existingIcon.SetFromIconName(shortcut.IconName);
}
// Edit button
var edit = new Button();
edit.AddCssClass("flat");
edit.SetValign(Align.Center);
edit.IconName = "document-edit-symbolic";
row.AddSuffix(edit);
}
}